src/jdk/nashorn/internal/runtime/Property.java

Print this page
rev 758 : 8021350: Share script classes between threads/globals within context
Reviewed-by: lagergren, sundar


  67     private static final int MODIFY_MASK     = (NOT_WRITABLE | NOT_ENUMERABLE | NOT_CONFIGURABLE);
  68 
  69     /** Is this a spill property? See {@link AccessorProperty} */
  70     public static final int IS_SPILL         = 1 << 3;
  71 
  72     /** Is this a function parameter? */
  73     public static final int IS_PARAMETER     = 1 << 4;
  74 
  75     /** Is parameter accessed thru arguments? */
  76     public static final int HAS_ARGUMENTS    = 1 << 5;
  77 
  78     /** Is this property always represented as an Object? See {@link ObjectClassGenerator} and dual fields flag. */
  79     public static final int IS_ALWAYS_OBJECT = 1 << 6;
  80 
  81     /** Can this property be primitive? */
  82     public static final int CAN_BE_PRIMITIVE = 1 << 7;
  83 
  84     /** Can this property be undefined? */
  85     public static final int CAN_BE_UNDEFINED = 1 << 8;
  86 
  87     /* Is this a function declaration property ? */
  88     public static final int IS_FUNCTION_DECLARATION = 1 << 9;
  89 




  90     /** Property key. */
  91     private final String key;
  92 
  93     /** Property flags. */
  94     protected int flags;
  95 
  96     /** Property field number or spill slot. */
  97     private final int slot;
  98 
  99     /**
 100      * Constructor
 101      *
 102      * @param key   property key
 103      * @param flags property flags
 104      * @param slot  property field number or spill slot
 105      */
 106     Property(final String key, final int flags, final int slot) {
 107         assert key != null;
 108         this.key   = key;
 109         this.flags = flags;


 232     }
 233 
 234     /**
 235      * Check whether this property is in an object with arguments field
 236      * @return true if has arguments
 237      */
 238     public boolean hasArguments() {
 239         return (flags & HAS_ARGUMENTS) == HAS_ARGUMENTS;
 240     }
 241 
 242     /**
 243      * Check whether this is a spill property, i.e. one that will not
 244      * be stored in a specially generated field in the property class.
 245      * The spill pool is maintained separately, as a growing Object array
 246      * in the {@link ScriptObject}.
 247      *
 248      * @return true if spill property
 249      */
 250     public boolean isSpill() {
 251         return (flags & IS_SPILL) == IS_SPILL;










 252     }
 253 
 254     /**
 255      * Does this property use any slots in the spill array described in
 256      * {@link Property#isSpill}? In that case how many. Currently a property
 257      * only uses max one spill slot, but this may change in future representations
 258      * Only {@link AccessorProperty} instances use spill slots
 259      *
 260      * @return number of spill slots a property is using
 261      */
 262     public int getSpillCount() {
 263         return isSpill() ? 1 : 0;
 264     }
 265 
 266     /**
 267      * Add more property flags to the property. Properties are immutable here,
 268      * so any property change that results in a larger flag set results in the
 269      * property being cloned. Use only the return value
 270      *
 271      * @param propertyFlags flags to be OR:ed to the existing property flags




  67     private static final int MODIFY_MASK     = (NOT_WRITABLE | NOT_ENUMERABLE | NOT_CONFIGURABLE);
  68 
  69     /** Is this a spill property? See {@link AccessorProperty} */
  70     public static final int IS_SPILL         = 1 << 3;
  71 
  72     /** Is this a function parameter? */
  73     public static final int IS_PARAMETER     = 1 << 4;
  74 
  75     /** Is parameter accessed thru arguments? */
  76     public static final int HAS_ARGUMENTS    = 1 << 5;
  77 
  78     /** Is this property always represented as an Object? See {@link ObjectClassGenerator} and dual fields flag. */
  79     public static final int IS_ALWAYS_OBJECT = 1 << 6;
  80 
  81     /** Can this property be primitive? */
  82     public static final int CAN_BE_PRIMITIVE = 1 << 7;
  83 
  84     /** Can this property be undefined? */
  85     public static final int CAN_BE_UNDEFINED = 1 << 8;
  86 
  87     /** Is this a function declaration property ? */
  88     public static final int IS_FUNCTION_DECLARATION = 1 << 9;
  89 
  90     /** Is this property bound to a receiver? This means get/set operations will be delegated to
  91      *  a statically defined object instead of the object passed as callsite parameter. */
  92     public static final int IS_BOUND = 1 << 10;
  93 
  94     /** Property key. */
  95     private final String key;
  96 
  97     /** Property flags. */
  98     protected int flags;
  99 
 100     /** Property field number or spill slot. */
 101     private final int slot;
 102 
 103     /**
 104      * Constructor
 105      *
 106      * @param key   property key
 107      * @param flags property flags
 108      * @param slot  property field number or spill slot
 109      */
 110     Property(final String key, final int flags, final int slot) {
 111         assert key != null;
 112         this.key   = key;
 113         this.flags = flags;


 236     }
 237 
 238     /**
 239      * Check whether this property is in an object with arguments field
 240      * @return true if has arguments
 241      */
 242     public boolean hasArguments() {
 243         return (flags & HAS_ARGUMENTS) == HAS_ARGUMENTS;
 244     }
 245 
 246     /**
 247      * Check whether this is a spill property, i.e. one that will not
 248      * be stored in a specially generated field in the property class.
 249      * The spill pool is maintained separately, as a growing Object array
 250      * in the {@link ScriptObject}.
 251      *
 252      * @return true if spill property
 253      */
 254     public boolean isSpill() {
 255         return (flags & IS_SPILL) == IS_SPILL;
 256     }
 257 
 258     /**
 259      * Is this property bound to a receiver? If this method returns {@code true} get and set operations
 260      * will be delegated to a statically bound object instead of the object passed as parameter.
 261      *
 262      * @return true if this is a bound property
 263      */
 264     public boolean isBound() {
 265         return (flags & IS_BOUND) == IS_BOUND;
 266     }
 267 
 268     /**
 269      * Does this property use any slots in the spill array described in
 270      * {@link Property#isSpill}? In that case how many. Currently a property
 271      * only uses max one spill slot, but this may change in future representations
 272      * Only {@link AccessorProperty} instances use spill slots
 273      *
 274      * @return number of spill slots a property is using
 275      */
 276     public int getSpillCount() {
 277         return isSpill() ? 1 : 0;
 278     }
 279 
 280     /**
 281      * Add more property flags to the property. Properties are immutable here,
 282      * so any property change that results in a larger flag set results in the
 283      * property being cloned. Use only the return value
 284      *
 285      * @param propertyFlags flags to be OR:ed to the existing property flags