Skip to content

Commit c6ad07d

Browse files
committed
Pass the location to createAssumption() to ensure correct ordering by the DSL
1 parent 75a7a27 commit c6ad07d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/org/truffleruby/language/objects/WriteObjectFieldNode.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private void executeBoundary(DynamicObject object, Object value, boolean general
6666
public void writeExistingField(DynamicObject object, Object value, boolean generalize,
6767
@Cached("getLocation(object, value)") Location location,
6868
@Cached("object.getShape()") Shape cachedShape,
69-
@Cached("createAssumption(cachedShape)") Assumption validLocation,
69+
@Cached("createAssumption(cachedShape, location)") Assumption validLocation,
7070
@Cached("isShared(cachedShape)") boolean shared,
7171
@Cached("createWriteBarrierNode(shared)") WriteBarrierNode writeBarrierNode,
7272
@Cached("createProfile(shared)") BranchProfile shapeRaceProfile) {
@@ -114,7 +114,7 @@ public void writeNewField(DynamicObject object, Object value, boolean generalize
114114
@Cached("object.getShape()") Shape oldShape,
115115
@Cached("defineProperty(oldShape, value, generalize)") Shape newShape,
116116
@Cached("getNewLocation(newShape)") Location newLocation,
117-
@Cached("createAssumption(oldShape)") Assumption validLocation,
117+
@Cached("createAssumption(oldShape, newLocation)") Assumption validLocation,
118118
@Cached("isShared(oldShape)") boolean shared,
119119
@Cached("createWriteBarrierNode(shared)") WriteBarrierNode writeBarrierNode,
120120
@Cached("createProfile(shared)") BranchProfile shapeRaceProfile) {
@@ -196,7 +196,9 @@ protected Location getNewLocation(Shape newShape) {
196196
return newShape.getProperty(name).getLocation();
197197
}
198198

199-
protected Assumption createAssumption(Shape shape) {
199+
// The location is passed here even though it's not used,
200+
// to make sure the DSL checks this Assumption after all lookups are done in executeAndSpecialize().
201+
protected Assumption createAssumption(Shape shape, Location location) {
200202
if (!shape.isValid()) {
201203
return NeverValidAssumption.INSTANCE;
202204
}

0 commit comments

Comments
 (0)