Skip to content

Commit

Permalink
Evaluate shape guard condition before setting the shape.
Browse files Browse the repository at this point in the history
  • Loading branch information
woess committed Aug 12, 2020
1 parent 2743b68 commit b611e8a
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,7 @@ protected boolean putImpl(DynamicObject object, Shape cachedShape, Object key, O
return false;
} else {
LocationImpl location = getLocation(newProperty);
boolean guardCondition = object.getShape() == oldShape;
if (location.canStore(value)) {
Shape newShape = c.newShape;
if (newShape != oldShape) {
Expand All @@ -1254,7 +1255,7 @@ protected boolean putImpl(DynamicObject object, Shape cachedShape, Object key, O
continue;
}
try {
location.set(object, value, object.getShape() == oldShape);
location.set(object, value, guardCondition);
} catch (IncompatibleLocationException | FinalLocationException e) {
throw shouldNotHappen(e);
}
Expand Down Expand Up @@ -1287,14 +1288,15 @@ protected boolean putIntImpl(DynamicObject object, Shape cachedShape, Object key
} else {
LocationImpl location = getLocation(newProperty);
Shape newShape = c.newShape;
boolean guardCondition = object.getShape() == oldShape;
if (location.isIntLocation()) {
if (newShape != oldShape) {
ACCESS.growAndSetShape(object, oldShape, newShape);
} else if (location.isFinal()) {
continue;
}
try {
location.setInt(object, value, object.getShape() == oldShape);
location.setInt(object, value, guardCondition);
} catch (IncompatibleLocationException | FinalLocationException e) {
throw shouldNotHappen(e);
}
Expand All @@ -1307,7 +1309,7 @@ protected boolean putIntImpl(DynamicObject object, Shape cachedShape, Object key
continue;
}
try {
location.setLong(object, value, object.getShape() == oldShape);
location.setLong(object, value, guardCondition);
} catch (IncompatibleLocationException | FinalLocationException e) {
throw shouldNotHappen(e);
}
Expand All @@ -1320,7 +1322,7 @@ protected boolean putIntImpl(DynamicObject object, Shape cachedShape, Object key
continue;
}
try {
location.setDouble(object, value, object.getShape() == oldShape);
location.setDouble(object, value, guardCondition);
} catch (IncompatibleLocationException | FinalLocationException e) {
throw shouldNotHappen(e);
}
Expand All @@ -1333,7 +1335,7 @@ protected boolean putIntImpl(DynamicObject object, Shape cachedShape, Object key
continue;
}
try {
location.set(object, value, object.getShape() == oldShape);
location.set(object, value, guardCondition);
} catch (IncompatibleLocationException | FinalLocationException e) {
throw shouldNotHappen(e);
}
Expand Down Expand Up @@ -1363,6 +1365,7 @@ protected boolean putLongImpl(DynamicObject object, Shape cachedShape, Object ke
return false;
} else {
LocationImpl location = getLocation(newProperty);
boolean guardCondition = object.getShape() == oldShape;
if (location.isLongLocation()) {
Shape newShape = c.newShape;
if (newShape != oldShape) {
Expand All @@ -1371,7 +1374,7 @@ protected boolean putLongImpl(DynamicObject object, Shape cachedShape, Object ke
continue;
}
try {
location.setLong(object, value, object.getShape() == oldShape);
location.setLong(object, value, guardCondition);
} catch (IncompatibleLocationException | FinalLocationException e) {
throw shouldNotHappen(e);
}
Expand All @@ -1385,7 +1388,7 @@ protected boolean putLongImpl(DynamicObject object, Shape cachedShape, Object ke
continue;
}
try {
location.set(object, value, object.getShape() == oldShape);
location.set(object, value, guardCondition);
} catch (IncompatibleLocationException | FinalLocationException e) {
throw shouldNotHappen(e);
}
Expand Down Expand Up @@ -1415,6 +1418,7 @@ protected boolean putDoubleImpl(DynamicObject object, Shape cachedShape, Object
return false;
} else {
LocationImpl location = getLocation(newProperty);
boolean guardCondition = object.getShape() == oldShape;
if (location.isDoubleLocation()) {
Shape newShape = c.newShape;
if (newShape != oldShape) {
Expand All @@ -1423,7 +1427,7 @@ protected boolean putDoubleImpl(DynamicObject object, Shape cachedShape, Object
continue;
}
try {
location.setDouble(object, value, object.getShape() == oldShape);
location.setDouble(object, value, guardCondition);
} catch (IncompatibleLocationException | FinalLocationException e) {
throw shouldNotHappen(e);
}
Expand All @@ -1437,7 +1441,7 @@ protected boolean putDoubleImpl(DynamicObject object, Shape cachedShape, Object
continue;
}
try {
location.set(object, value, object.getShape() == oldShape);
location.set(object, value, guardCondition);
} catch (IncompatibleLocationException | FinalLocationException e) {
throw shouldNotHappen(e);
}
Expand Down Expand Up @@ -1467,6 +1471,7 @@ protected boolean putBooleanImpl(DynamicObject object, Shape cachedShape, Object
return false;
} else {
LocationImpl location = getLocation(newProperty);
boolean guardCondition = object.getShape() == oldShape;
if (location.canStore(value)) {
Shape newShape = c.newShape;
if (newShape != oldShape) {
Expand All @@ -1475,7 +1480,7 @@ protected boolean putBooleanImpl(DynamicObject object, Shape cachedShape, Object
continue;
}
try {
location.set(object, value, object.getShape() == oldShape);
location.set(object, value, guardCondition);
} catch (IncompatibleLocationException | FinalLocationException e) {
throw shouldNotHappen(e);
}
Expand Down

0 comments on commit b611e8a

Please sign in to comment.