src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java
changeset 49257 82f763a9cc22
parent 48354 c96d4c720995
child 49421 458c790b6995
equal deleted inserted replaced
49256:ca2780cd2056 49257:82f763a9cc22
   960     }
   960     }
   961 
   961 
   962     /**
   962     /**
   963      * Fast initialization functions for ScriptFunctions that are strict, to avoid
   963      * Fast initialization functions for ScriptFunctions that are strict, to avoid
   964      * creating setters that probably aren't used. Inject directly into the spill pool
   964      * creating setters that probably aren't used. Inject directly into the spill pool
   965      * the defaults for "arguments" and "caller"
   965      * the defaults for "arguments" and "caller", asserting the property is already
   966      *
   966      * defined in the map.
   967      * @param key           property key
   967      *
   968      * @param propertyFlags flags
   968      * @param key     property key
   969      * @param getter        getter for {@link UserAccessorProperty}, null if not present or N/A
   969      * @param getter  getter for {@link UserAccessorProperty}
   970      * @param setter        setter for {@link UserAccessorProperty}, null if not present or N/A
   970      * @param setter  setter for {@link UserAccessorProperty}
   971      */
   971      */
   972     protected final void initUserAccessors(final String key, final int propertyFlags, final ScriptFunction getter, final ScriptFunction setter) {
   972     protected final void initUserAccessors(final String key, final ScriptFunction getter, final ScriptFunction setter) {
   973         final PropertyMap oldMap = getMap();
   973         final PropertyMap map = getMap();
   974         final int slot = oldMap.getFreeSpillSlot();
   974         final Property property = map.findProperty(key);
   975         ensureSpillSize(slot);
   975         assert property instanceof UserAccessorProperty;
   976         objectSpill[slot] = new UserAccessorProperty.Accessors(getter, setter);
   976         ensureSpillSize(property.getSlot());
   977         Property    newProperty;
   977         objectSpill[property.getSlot()] = new UserAccessorProperty.Accessors(getter, setter);
   978         PropertyMap newMap;
       
   979         do {
       
   980             newProperty = new UserAccessorProperty(key, propertyFlags, slot);
       
   981             newMap = oldMap.addProperty(newProperty);
       
   982         } while (!compareAndSetMap(oldMap, newMap));
       
   983     }
   978     }
   984 
   979 
   985     /**
   980     /**
   986      * Modify a property in the object
   981      * Modify a property in the object
   987      *
   982      *