@@ -293,68 +293,6 @@ public static Property[] getPropertyArray(@SuppressWarnings("unused") DynamicObj
293293 return cachedShape .getPropertyArray ();
294294 }
295295
296- @ TruffleBoundary
297- protected static boolean putGeneric (DynamicObject object , Object key , Object value , int newPropertyFlags , int putFlags , Shape s , Property existingProperty ) {
298- if (existingProperty == null && Flags .isSetExisting (putFlags )) {
299- return false ;
300- }
301- if (existingProperty != null && !Flags .isUpdateFlags (putFlags ) && existingProperty .getLocation ().canStore (value )) {
302- existingProperty .getLocation ().setSafe (object , value , false , false );
303- return true ;
304- } else {
305- return putGenericSlowPath (object , key , value , newPropertyFlags , putFlags , s , existingProperty );
306- }
307- }
308-
309- private static boolean putGenericSlowPath (DynamicObject object , Object key , Object value , int newPropertyFlags , int putFlags ,
310- Shape initialShape , Property propertyOfInitialShape ) {
311- CompilerAsserts .neverPartOfCompilation ();
312- ObsolescenceStrategy .singleton ().updateShape (object );
313- Shape oldShape ;
314- Property existingProperty ;
315- Shape newShape ;
316- Property property ;
317- do {
318- oldShape = object .getShape ();
319- if (oldShape == initialShape ) {
320- existingProperty = propertyOfInitialShape ;
321- } else {
322- existingProperty = oldShape .getProperty (key );
323- }
324- if (existingProperty == null ) {
325- if (Flags .isSetExisting (putFlags )) {
326- return false ;
327- } else {
328- newShape = ObsolescenceStrategy .singleton ().defineProperty (oldShape , key , value , newPropertyFlags , existingProperty , putFlags );
329- property = newShape .getProperty (key );
330- }
331- } else if (Flags .isUpdateFlags (putFlags ) && newPropertyFlags != existingProperty .getFlags ()) {
332- newShape = ObsolescenceStrategy .singleton ().defineProperty (oldShape , key , value , newPropertyFlags , existingProperty , putFlags );
333- property = newShape .getProperty (key );
334- } else {
335- if (existingProperty .getLocation ().canStore (value )) {
336- newShape = oldShape ;
337- property = existingProperty ;
338- } else {
339- newShape = ObsolescenceStrategy .singleton ().defineProperty (oldShape , key , value , existingProperty .getFlags (), existingProperty , putFlags );
340- property = newShape .getProperty (key );
341- }
342- }
343- } while (ObsolescenceStrategy .singleton ().updateShape (object ));
344-
345- assert object .getShape () == oldShape ;
346- Location location = property .getLocation ();
347- if (oldShape != newShape ) {
348- DynamicObjectSupport .grow (object , oldShape , newShape );
349- location .setSafe (object , value , false , true );
350- DynamicObjectSupport .setShapeWithStoreFence (object , newShape );
351- ObsolescenceStrategy .singleton ().updateShape (object );
352- } else {
353- location .setSafe (object , value , false , false );
354- }
355- return true ;
356- }
357-
358296 static RemovePlan prepareRemove (Shape shapeBefore , Shape shapeAfter , Property removedProperty ) {
359297 assert !shapeBefore .isShared ();
360298 List <Move > moves = new ArrayList <>();
@@ -710,7 +648,7 @@ public double getDoubleOrDefault(DynamicObject object, Shape cachedShape, Object
710648
711649 @ Override
712650 public boolean put (DynamicObject object , Shape cachedShape , Object key , Object value , int propertyFlags , int putFlags ) {
713- return putGeneric (object , key , value , propertyFlags , putFlags , cachedShape , cachedShape .getProperty (key ));
651+ return ObsolescenceStrategy . singleton (). putGeneric (object , key , value , propertyFlags , putFlags , cachedShape , cachedShape .getProperty (key ));
714652 }
715653
716654 @ Override
@@ -1287,7 +1225,7 @@ protected boolean putImpl(DynamicObject object, Shape cachedShape, Object key, O
12871225 Shape oldShape = cachedShape ;
12881226 MutateCacheData start = cache ;
12891227 if (start == MutateCacheData .GENERIC || !cachedShape .isValid ()) {
1290- return putGeneric (object , key , value , propertyFlags , putFlags , cachedShape , oldProperty );
1228+ return ObsolescenceStrategy . singleton (). putGeneric (object , key , value , propertyFlags , putFlags , cachedShape , oldProperty );
12911229 }
12921230 for (MutateCacheData c = start ; c != null ; c = c .next ) {
12931231 if (!c .isValid ()) {
@@ -1325,7 +1263,7 @@ protected boolean putIntImpl(DynamicObject object, Shape cachedShape, Object key
13251263 Shape oldShape = cachedShape ;
13261264 MutateCacheData start = cache ;
13271265 if (start == MutateCacheData .GENERIC || !cachedShape .isValid ()) {
1328- return putGeneric (object , key , value , propertyFlags , putFlags , cachedShape , oldProperty );
1266+ return ObsolescenceStrategy . singleton (). putGeneric (object , key , value , propertyFlags , putFlags , cachedShape , oldProperty );
13291267 }
13301268 for (MutateCacheData c = start ; c != null ; c = c .next ) {
13311269 if (!c .isValid ()) {
@@ -1393,7 +1331,7 @@ protected boolean putLongImpl(DynamicObject object, Shape cachedShape, Object ke
13931331 Shape oldShape = cachedShape ;
13941332 MutateCacheData start = cache ;
13951333 if (start == MutateCacheData .GENERIC ) {
1396- return putGeneric (object , key , value , propertyFlags , putFlags , cachedShape , oldProperty );
1334+ return ObsolescenceStrategy . singleton (). putGeneric (object , key , value , propertyFlags , putFlags , cachedShape , oldProperty );
13971335 }
13981336 for (MutateCacheData c = start ; c != null ; c = c .next ) {
13991337 if (!c .isValid ()) {
@@ -1442,7 +1380,7 @@ protected boolean putDoubleImpl(DynamicObject object, Shape cachedShape, Object
14421380 Shape oldShape = cachedShape ;
14431381 MutateCacheData start = cache ;
14441382 if (start == MutateCacheData .GENERIC ) {
1445- return putGeneric (object , key , value , propertyFlags , putFlags , cachedShape , oldProperty );
1383+ return ObsolescenceStrategy . singleton (). putGeneric (object , key , value , propertyFlags , putFlags , cachedShape , oldProperty );
14461384 }
14471385 for (MutateCacheData c = start ; c != null ; c = c .next ) {
14481386 if (!c .isValid ()) {
0 commit comments