@@ -114,7 +114,7 @@ public void writeNewField(DynamicObject object, Object value, boolean generalize
114
114
@ Cached ("object.getShape()" ) Shape oldShape ,
115
115
@ Cached ("defineProperty(oldShape, value, generalize)" ) Shape newShape ,
116
116
@ Cached ("getNewLocation(newShape)" ) Location newLocation ,
117
- @ Cached ("createAssumption(oldShape, newLocation)" ) Assumption validLocation ,
117
+ @ Cached ("createAssumption(oldShape, newShape, newLocation)" ) Assumption validLocation ,
118
118
@ Cached ("isShared(oldShape)" ) boolean shared ,
119
119
@ Cached ("createWriteBarrierNode(shared)" ) WriteBarrierNode writeBarrierNode ,
120
120
@ Cached ("createProfile(shared)" ) BranchProfile shapeRaceProfile ) {
@@ -205,6 +205,15 @@ protected Assumption createAssumption(Shape shape, Location location) {
205
205
return Truffle .getRuntime ().createAssumption ("object location is valid" );
206
206
}
207
207
208
+ // The location is passed here even though it's not used,
209
+ // to make sure the DSL checks this Assumption after all lookups are done in executeAndSpecialize().
210
+ protected Assumption createAssumption (Shape oldShape , Shape newShape , Location location ) {
211
+ if (!oldShape .isValid () || !newShape .isValid ()) {
212
+ return NeverValidAssumption .INSTANCE ;
213
+ }
214
+ return Truffle .getRuntime ().createAssumption ("object location is valid" );
215
+ }
216
+
208
217
protected int getCacheLimit () {
209
218
return getContext ().getOptions ().INSTANCE_VARIABLE_CACHE ;
210
219
}
0 commit comments