src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Property.java
author hannesw
Wed, 21 Mar 2018 16:55:34 +0100
changeset 49275 c639a6b33c5c
parent 47216 71c04702a3d5
child 58379 8511c662083b
permissions -rw-r--r--
8199869: Missing copyright headers in nashorn source code Reviewed-by: sundar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     1
/*
16151
97c1e756ae1e 8005663: Update copyright year to 2013
jlaskey
parents: 16147
diff changeset
     2
 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     4
 *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    10
 *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    15
 * accompanied this code).
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    16
 *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    20
 *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    23
 * questions.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    24
 */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    25
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    26
package jdk.nashorn.internal.runtime;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    27
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    28
import static jdk.nashorn.internal.runtime.PropertyDescriptor.CONFIGURABLE;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    29
import static jdk.nashorn.internal.runtime.PropertyDescriptor.ENUMERABLE;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    30
import static jdk.nashorn.internal.runtime.PropertyDescriptor.WRITABLE;
23767
7c0614b75e23 8038638: Persistent store for compiled scripts
hannesw
parents: 23372
diff changeset
    31
import java.io.Serializable;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    32
import java.lang.invoke.MethodHandle;
24738
be2026c9717c 8039746: Transform applies to calls wherever possible, for ScriptFunctions and JSObjects.
lagergren
parents: 24727
diff changeset
    33
import java.lang.invoke.SwitchPoint;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    34
import java.util.Objects;
16240
e1468b33e201 8008239: Unpublicized parts of the code generator package that were only package internal.
lagergren
parents: 16224
diff changeset
    35
import jdk.nashorn.internal.codegen.ObjectClassGenerator;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    36
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    37
/**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    38
 * This is the abstract superclass representing a JavaScript Property.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    39
 * The {@link PropertyMap} map links keys to properties, and consequently
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    40
 * instances of this class make up the values in the PropertyMap
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    41
 *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    42
 * @see PropertyMap
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    43
 * @see AccessorProperty
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    44
 * @see UserAccessorProperty
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    45
 */
23767
7c0614b75e23 8038638: Persistent store for compiled scripts
hannesw
parents: 23372
diff changeset
    46
public abstract class Property implements Serializable {
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    47
    /*
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    48
     * ECMA 8.6.1 Property Attributes
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    49
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    50
     * We use negative flags because most properties are expected to
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    51
     * be 'writable', 'configurable' and 'enumerable'. With negative flags,
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    52
     * we can use leave flag byte initialized with (the default) zero value.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    53
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    54
17774
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 17771
diff changeset
    55
    /** Mask for property being both writable, enumerable and configurable */
17771
9fedae4933e4 8015354: JSON.parse should not use [[Put]] but use [[DefineOwnProperty]] instead
sundar
parents: 17770
diff changeset
    56
    public static final int WRITABLE_ENUMERABLE_CONFIGURABLE = 0b0000_0000_0000;
9fedae4933e4 8015354: JSON.parse should not use [[Put]] but use [[DefineOwnProperty]] instead
sundar
parents: 17770
diff changeset
    57
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    58
    /** ECMA 8.6.1 - Is this property not writable? */
21685
ff0187bbe5c0 8027700: function redeclaration checks missing for declaration binding instantiation
sundar
parents: 19105
diff changeset
    59
    public static final int NOT_WRITABLE     = 1 << 0;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    60
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    61
    /** ECMA 8.6.1 - Is this property not enumerable? */
21685
ff0187bbe5c0 8027700: function redeclaration checks missing for declaration binding instantiation
sundar
parents: 19105
diff changeset
    62
    public static final int NOT_ENUMERABLE   = 1 << 1;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    63
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    64
    /** ECMA 8.6.1 - Is this property not configurable? */
21685
ff0187bbe5c0 8027700: function redeclaration checks missing for declaration binding instantiation
sundar
parents: 19105
diff changeset
    65
    public static final int NOT_CONFIGURABLE = 1 << 2;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    66
24720
75f8388b79df 8035836: Array performance improvements
lagergren
parents: 24719
diff changeset
    67
    private static final int MODIFY_MASK     = NOT_WRITABLE | NOT_ENUMERABLE | NOT_CONFIGURABLE;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    68
16224
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
    69
    /** Is this a function parameter? */
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
    70
    public static final int IS_PARAMETER     = 1 << 3;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    71
16224
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
    72
    /** Is parameter accessed thru arguments? */
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
    73
    public static final int HAS_ARGUMENTS    = 1 << 4;
21685
ff0187bbe5c0 8027700: function redeclaration checks missing for declaration binding instantiation
sundar
parents: 19105
diff changeset
    74
23372
09707b3e5fb0 8021350: Share script classes between threads/globals within context
hannesw
parents: 21685
diff changeset
    75
    /** Is this a function declaration property ? */
24751
ccbd9cd3f720 8042118: Separate types from symbols
attila
parents: 24742
diff changeset
    76
    public static final int IS_FUNCTION_DECLARATION = 1 << 5;
21685
ff0187bbe5c0 8027700: function redeclaration checks missing for declaration binding instantiation
sundar
parents: 19105
diff changeset
    77
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
    78
    /**
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
    79
     * Is this is a primitive field given to us by Nasgen, i.e.
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
    80
     * something we can be sure remains a constant whose type
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
    81
     * is narrower than object, e.g. Math.PI which is declared
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
    82
     * as a double
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
    83
     */
26377
028dad61662f 8051889: Implement block scoping in symbol assignment and scope computation
hannesw
parents: 26068
diff changeset
    84
    public static final int IS_NASGEN_PRIMITIVE     = 1 << 6;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    85
26768
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
    86
    /** Is this a builtin property, e.g. Function.prototype.apply */
27814
96427359f4fe 8057691: Nashorn: let & const declarations are not shared between scripts
hannesw
parents: 27307
diff changeset
    87
    public static final int IS_BUILTIN              = 1 << 7;
26768
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
    88
23372
09707b3e5fb0 8021350: Share script classes between threads/globals within context
hannesw
parents: 21685
diff changeset
    89
    /** Is this property bound to a receiver? This means get/set operations will be delegated to
09707b3e5fb0 8021350: Share script classes between threads/globals within context
hannesw
parents: 21685
diff changeset
    90
     *  a statically defined object instead of the object passed as callsite parameter. */
27814
96427359f4fe 8057691: Nashorn: let & const declarations are not shared between scripts
hannesw
parents: 27307
diff changeset
    91
    public static final int IS_BOUND                = 1 << 8;
26377
028dad61662f 8051889: Implement block scoping in symbol assignment and scope computation
hannesw
parents: 26068
diff changeset
    92
028dad61662f 8051889: Implement block scoping in symbol assignment and scope computation
hannesw
parents: 26068
diff changeset
    93
    /** Is this a lexically scoped LET or CONST variable that is dead until it is declared. */
27814
96427359f4fe 8057691: Nashorn: let & const declarations are not shared between scripts
hannesw
parents: 27307
diff changeset
    94
    public static final int NEEDS_DECLARATION       = 1 << 9;
96427359f4fe 8057691: Nashorn: let & const declarations are not shared between scripts
hannesw
parents: 27307
diff changeset
    95
96427359f4fe 8057691: Nashorn: let & const declarations are not shared between scripts
hannesw
parents: 27307
diff changeset
    96
    /** Is this property an ES6 lexical binding? */
96427359f4fe 8057691: Nashorn: let & const declarations are not shared between scripts
hannesw
parents: 27307
diff changeset
    97
    public static final int IS_LEXICAL_BINDING      = 1 << 10;
23372
09707b3e5fb0 8021350: Share script classes between threads/globals within context
hannesw
parents: 21685
diff changeset
    98
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
    99
    /** Does this property support dual field representation? */
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   100
    public static final int DUAL_FIELDS             = 1 << 11;
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   101
36023
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   102
    /** Is this an accessor property as as defined in ES5 8.6.1? */
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   103
    public static final int IS_ACCESSOR_PROPERTY    = 1 << 12;
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   104
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   105
    /** Property key. */
33690
46a1bc24cf2c 8141702: Add support for Symbol property keys
hannesw
parents: 31548
diff changeset
   106
    private final Object key;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   107
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   108
    /** Property flags. */
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   109
    private int flags;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   110
17513
b9a691fc1df5 8006220: Simplify PropertyMaps
jlaskey
parents: 16240
diff changeset
   111
    /** Property field number or spill slot. */
16224
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   112
    private final int slot;
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   113
27307
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   114
    /**
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   115
     * Current type of this object, in object only mode, this is an Object.class. In dual-fields mode
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   116
     * null means undefined, and primitive types are allowed. The reason a special type is used for
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   117
     * undefined, is that are no bits left to represent it in primitive types
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   118
     */
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   119
    private Class<?> type;
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   120
24742
a9afb384e654 8040655: When processing a RewriteException debug object, the return value has already been reset to null. We need to catch this value before that.
lagergren
parents: 24738
diff changeset
   121
    /** SwitchPoint that is invalidated when property is changed, optional */
26768
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   122
    protected transient SwitchPoint builtinSwitchPoint;
24738
be2026c9717c 8039746: Transform applies to calls wherever possible, for ScriptFunctions and JSObjects.
lagergren
parents: 24727
diff changeset
   123
23767
7c0614b75e23 8038638: Persistent store for compiled scripts
hannesw
parents: 23372
diff changeset
   124
    private static final long serialVersionUID = 2099814273074501176L;
7c0614b75e23 8038638: Persistent store for compiled scripts
hannesw
parents: 23372
diff changeset
   125
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   126
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   127
     * Constructor
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   128
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   129
     * @param key   property key
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   130
     * @param flags property flags
16224
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   131
     * @param slot  property field number or spill slot
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   132
     */
33690
46a1bc24cf2c 8141702: Add support for Symbol property keys
hannesw
parents: 31548
diff changeset
   133
    Property(final Object key, final int flags, final int slot) {
16224
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   134
        assert key != null;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   135
        this.key   = key;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   136
        this.flags = flags;
16224
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   137
        this.slot  = slot;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   138
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   139
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   140
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   141
     * Copy constructor
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   142
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   143
     * @param property source property
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   144
     */
24727
attila
parents: 24725 23372
diff changeset
   145
    Property(final Property property, final int flags) {
26768
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   146
        this.key                = property.key;
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   147
        this.slot               = property.slot;
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   148
        this.builtinSwitchPoint = property.builtinSwitchPoint;
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   149
        this.flags              = flags;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   150
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   151
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   152
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   153
     * Copy function
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   154
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   155
     * @return cloned property
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   156
     */
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   157
    public abstract Property copy();
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   158
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   159
    /**
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   160
     * Copy function
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   161
     *
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   162
     * @param  newType new type
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   163
     * @return cloned property with new type
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   164
     */
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   165
    public abstract Property copy(final Class<?> newType);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   166
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   167
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   168
     * Property flag utility method for {@link PropertyDescriptor}s. Given two property descriptors,
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   169
     * return the result of merging their flags.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   170
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   171
     * @param oldDesc  first property descriptor
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   172
     * @param newDesc  second property descriptor
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   173
     * @return merged flags.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   174
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   175
    static int mergeFlags(final PropertyDescriptor oldDesc, final PropertyDescriptor newDesc) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   176
        int     propFlags = 0;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   177
        boolean value;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   178
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   179
        value = newDesc.has(CONFIGURABLE) ? newDesc.isConfigurable() : oldDesc.isConfigurable();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   180
        if (!value) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   181
            propFlags |= NOT_CONFIGURABLE;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   182
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   183
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   184
        value = newDesc.has(ENUMERABLE) ? newDesc.isEnumerable() : oldDesc.isEnumerable();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   185
        if (!value) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   186
            propFlags |= NOT_ENUMERABLE;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   187
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   188
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   189
        value = newDesc.has(WRITABLE) ? newDesc.isWritable() : oldDesc.isWritable();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   190
        if (!value) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   191
            propFlags |= NOT_WRITABLE;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   192
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   193
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   194
        return propFlags;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   195
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   196
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   197
    /**
24742
a9afb384e654 8040655: When processing a RewriteException debug object, the return value has already been reset to null. We need to catch this value before that.
lagergren
parents: 24738
diff changeset
   198
     * Set the change callback for this property, i.e. a SwitchPoint
a9afb384e654 8040655: When processing a RewriteException debug object, the return value has already been reset to null. We need to catch this value before that.
lagergren
parents: 24738
diff changeset
   199
     * that will be invalidated when the value of the property is
a9afb384e654 8040655: When processing a RewriteException debug object, the return value has already been reset to null. We need to catch this value before that.
lagergren
parents: 24738
diff changeset
   200
     * changed
a9afb384e654 8040655: When processing a RewriteException debug object, the return value has already been reset to null. We need to catch this value before that.
lagergren
parents: 24738
diff changeset
   201
     * @param sp SwitchPoint to use for change callback
a9afb384e654 8040655: When processing a RewriteException debug object, the return value has already been reset to null. We need to catch this value before that.
lagergren
parents: 24738
diff changeset
   202
     */
26768
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   203
    public final void setBuiltinSwitchPoint(final SwitchPoint sp) {
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   204
        this.builtinSwitchPoint = sp;
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   205
    }
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   206
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   207
    /**
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   208
     * Builtin properties have an invalidation switchpoint that is
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   209
     * invalidated when they are set, this is a getter for it
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   210
     * @return builtin switchpoint, or null if none
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   211
     */
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   212
    public final SwitchPoint getBuiltinSwitchPoint() {
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   213
        return builtinSwitchPoint;
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   214
    }
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   215
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   216
    /**
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   217
     * Checks if this is a builtin property, this means that it has
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   218
     * a builtin switchpoint that hasn't been invalidated by a setter
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   219
     * @return true if builtin, untouched (unset) property
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   220
     */
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   221
    public boolean isBuiltin() {
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   222
        return builtinSwitchPoint != null && !builtinSwitchPoint.hasBeenInvalidated();
24738
be2026c9717c 8039746: Transform applies to calls wherever possible, for ScriptFunctions and JSObjects.
lagergren
parents: 24727
diff changeset
   223
    }
be2026c9717c 8039746: Transform applies to calls wherever possible, for ScriptFunctions and JSObjects.
lagergren
parents: 24727
diff changeset
   224
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   225
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   226
     * Property flag utility method for {@link PropertyDescriptor}. Get the property flags
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   227
     * conforming to any Property using this PropertyDescriptor
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   228
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   229
     * @param desc property descriptor
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   230
     * @return flags for properties that conform to property descriptor
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   231
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   232
    static int toFlags(final PropertyDescriptor desc) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   233
        int propFlags = 0;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   234
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   235
        if (!desc.isConfigurable()) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   236
            propFlags |= NOT_CONFIGURABLE;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   237
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   238
        if (!desc.isEnumerable()) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   239
            propFlags |= NOT_ENUMERABLE;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   240
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   241
        if (!desc.isWritable()) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   242
            propFlags |= NOT_WRITABLE;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   243
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   244
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   245
        return propFlags;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   246
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   247
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   248
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   249
     * Check whether this property has a user defined getter function. See {@link UserAccessorProperty}
18617
f6fe338f62c3 8008458: Strict functions dont share property map
jlaskey
parents: 18615
diff changeset
   250
     * @param obj object containing getter
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   251
     * @return true if getter function exists, false is default
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   252
     */
18617
f6fe338f62c3 8008458: Strict functions dont share property map
jlaskey
parents: 18615
diff changeset
   253
    public boolean hasGetterFunction(final ScriptObject obj) {
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   254
        return false;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   255
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   256
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   257
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   258
     * Check whether this property has a user defined setter function. See {@link UserAccessorProperty}
18617
f6fe338f62c3 8008458: Strict functions dont share property map
jlaskey
parents: 18615
diff changeset
   259
     * @param obj object containing setter
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   260
     * @return true if getter function exists, false is default
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   261
     */
18617
f6fe338f62c3 8008458: Strict functions dont share property map
jlaskey
parents: 18615
diff changeset
   262
    public boolean hasSetterFunction(final ScriptObject obj) {
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   263
        return false;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   264
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   265
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   266
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   267
     * Check whether this property is writable (see ECMA 8.6.1)
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   268
     * @return true if writable
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   269
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   270
    public boolean isWritable() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   271
        return (flags & NOT_WRITABLE) == 0;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   272
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   273
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   274
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   275
     * Check whether this property is writable (see ECMA 8.6.1)
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   276
     * @return true if configurable
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   277
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   278
    public boolean isConfigurable() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   279
        return (flags & NOT_CONFIGURABLE) == 0;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   280
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   281
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   282
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   283
     * Check whether this property is enumerable (see ECMA 8.6.1)
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   284
     * @return true if enumerable
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   285
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   286
    public boolean isEnumerable() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   287
        return (flags & NOT_ENUMERABLE) == 0;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   288
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   289
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   290
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   291
     * Check whether this property is used as a function parameter
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   292
     * @return true if parameter
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   293
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   294
    public boolean isParameter() {
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   295
        return (flags & IS_PARAMETER) != 0;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   296
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   297
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   298
    /**
16224
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   299
     * Check whether this property is in an object with arguments field
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   300
     * @return true if has arguments
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   301
     */
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   302
    public boolean hasArguments() {
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   303
        return (flags & HAS_ARGUMENTS) != 0;
16224
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   304
    }
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   305
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   306
    /**
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   307
     * Check whether this is a spill property, i.e. one that will not
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   308
     * be stored in a specially generated field in the property class.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   309
     * The spill pool is maintained separately, as a growing Object array
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   310
     * in the {@link ScriptObject}.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   311
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   312
     * @return true if spill property
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   313
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   314
    public boolean isSpill() {
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   315
        return false;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   316
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   317
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   318
    /**
23372
09707b3e5fb0 8021350: Share script classes between threads/globals within context
hannesw
parents: 21685
diff changeset
   319
     * Is this property bound to a receiver? If this method returns {@code true} get and set operations
09707b3e5fb0 8021350: Share script classes between threads/globals within context
hannesw
parents: 21685
diff changeset
   320
     * will be delegated to a statically bound object instead of the object passed as parameter.
09707b3e5fb0 8021350: Share script classes between threads/globals within context
hannesw
parents: 21685
diff changeset
   321
     *
09707b3e5fb0 8021350: Share script classes between threads/globals within context
hannesw
parents: 21685
diff changeset
   322
     * @return true if this is a bound property
09707b3e5fb0 8021350: Share script classes between threads/globals within context
hannesw
parents: 21685
diff changeset
   323
     */
09707b3e5fb0 8021350: Share script classes between threads/globals within context
hannesw
parents: 21685
diff changeset
   324
    public boolean isBound() {
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   325
        return (flags & IS_BOUND) != 0;
23372
09707b3e5fb0 8021350: Share script classes between threads/globals within context
hannesw
parents: 21685
diff changeset
   326
    }
09707b3e5fb0 8021350: Share script classes between threads/globals within context
hannesw
parents: 21685
diff changeset
   327
09707b3e5fb0 8021350: Share script classes between threads/globals within context
hannesw
parents: 21685
diff changeset
   328
    /**
26377
028dad61662f 8051889: Implement block scoping in symbol assignment and scope computation
hannesw
parents: 26068
diff changeset
   329
     * Is this a LET or CONST property that needs to see its declaration before being usable?
028dad61662f 8051889: Implement block scoping in symbol assignment and scope computation
hannesw
parents: 26068
diff changeset
   330
     *
028dad61662f 8051889: Implement block scoping in symbol assignment and scope computation
hannesw
parents: 26068
diff changeset
   331
     * @return true if this is a block-scoped variable
028dad61662f 8051889: Implement block scoping in symbol assignment and scope computation
hannesw
parents: 26068
diff changeset
   332
     */
028dad61662f 8051889: Implement block scoping in symbol assignment and scope computation
hannesw
parents: 26068
diff changeset
   333
    public boolean needsDeclaration() {
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   334
        return (flags & NEEDS_DECLARATION) != 0;
26377
028dad61662f 8051889: Implement block scoping in symbol assignment and scope computation
hannesw
parents: 26068
diff changeset
   335
    }
028dad61662f 8051889: Implement block scoping in symbol assignment and scope computation
hannesw
parents: 26068
diff changeset
   336
028dad61662f 8051889: Implement block scoping in symbol assignment and scope computation
hannesw
parents: 26068
diff changeset
   337
    /**
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   338
     * Add more property flags to the property. Properties are immutable here,
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   339
     * so any property change that results in a larger flag set results in the
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   340
     * property being cloned. Use only the return value
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   341
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   342
     * @param propertyFlags flags to be OR:ed to the existing property flags
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   343
     * @return new property if property set was changed, {@code this} otherwise
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   344
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   345
    public Property addFlags(final int propertyFlags) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   346
        if ((this.flags & propertyFlags) != propertyFlags) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   347
            final Property cloned = this.copy();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   348
            cloned.flags |= propertyFlags;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   349
            return cloned;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   350
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   351
        return this;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   352
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   353
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   354
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   355
     * Get the flags for this property
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   356
     * @return property flags
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   357
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   358
    public int getFlags() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   359
        return flags;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   360
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   361
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   362
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   363
     * Remove property flags from the property. Properties are immutable here,
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   364
     * so any property change that results in a smaller flag set results in the
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   365
     * property being cloned. Use only the return value
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   366
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   367
     * @param propertyFlags flags to be subtracted from the existing property flags
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   368
     * @return new property if property set was changed, {@code this} otherwise
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   369
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   370
    public Property removeFlags(final int propertyFlags) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   371
        if ((this.flags & propertyFlags) != 0) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   372
            final Property cloned = this.copy();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   373
            cloned.flags &= ~propertyFlags;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   374
            return cloned;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   375
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   376
        return this;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   377
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   378
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   379
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   380
     * Reset the property for this property. Properties are immutable here,
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   381
     * so any property change that results in a different flag sets results in the
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   382
     * property being cloned. Use only the return value
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   383
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   384
     * @param propertyFlags flags that are replacing from the existing property flags
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   385
     * @return new property if property set was changed, {@code this} otherwise
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   386
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   387
    public Property setFlags(final int propertyFlags) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   388
        if (this.flags != propertyFlags) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   389
            final Property cloned = this.copy();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   390
            cloned.flags &= ~MODIFY_MASK;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   391
            cloned.flags |= propertyFlags & MODIFY_MASK;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   392
            return cloned;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   393
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   394
        return this;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   395
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   396
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   397
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   398
     * Abstract method for retrieving the getter for the property. We do not know
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   399
     * anything about the internal representation when we request the getter, we only
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   400
     * know that the getter will return the property as the given type.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   401
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   402
     * @param type getter return value type
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   403
     * @return a getter for this property as {@code type}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   404
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   405
    public abstract MethodHandle getGetter(final Class<?> type);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   406
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   407
    /**
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   408
     * Get an optimistic getter that throws an exception if type is not the known given one
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   409
     * @param type          type
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   410
     * @param programPoint  program point
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   411
     * @return getter
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   412
     */
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   413
    public abstract MethodHandle getOptimisticGetter(final Class<?> type, final int programPoint);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   414
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   415
    /**
23767
7c0614b75e23 8038638: Persistent store for compiled scripts
hannesw
parents: 23372
diff changeset
   416
     * Hook to initialize method handles after deserialization.
7c0614b75e23 8038638: Persistent store for compiled scripts
hannesw
parents: 23372
diff changeset
   417
     *
7c0614b75e23 8038638: Persistent store for compiled scripts
hannesw
parents: 23372
diff changeset
   418
     * @param structure the structure class
7c0614b75e23 8038638: Persistent store for compiled scripts
hannesw
parents: 23372
diff changeset
   419
     */
7c0614b75e23 8038638: Persistent store for compiled scripts
hannesw
parents: 23372
diff changeset
   420
    abstract void initMethodHandles(final Class<?> structure);
7c0614b75e23 8038638: Persistent store for compiled scripts
hannesw
parents: 23372
diff changeset
   421
7c0614b75e23 8038638: Persistent store for compiled scripts
hannesw
parents: 23372
diff changeset
   422
    /**
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   423
     * Get the key for this property. This key is an ordinary string. The "name".
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   424
     * @return key for property
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   425
     */
33690
46a1bc24cf2c 8141702: Add support for Symbol property keys
hannesw
parents: 31548
diff changeset
   426
    public Object getKey() {
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   427
        return key;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   428
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   429
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   430
    /**
17513
b9a691fc1df5 8006220: Simplify PropertyMaps
jlaskey
parents: 16240
diff changeset
   431
     * Get the field number or spill slot
b9a691fc1df5 8006220: Simplify PropertyMaps
jlaskey
parents: 16240
diff changeset
   432
     * @return number/slot, -1 if none exists
b9a691fc1df5 8006220: Simplify PropertyMaps
jlaskey
parents: 16240
diff changeset
   433
     */
b9a691fc1df5 8006220: Simplify PropertyMaps
jlaskey
parents: 16240
diff changeset
   434
    public int getSlot() {
b9a691fc1df5 8006220: Simplify PropertyMaps
jlaskey
parents: 16240
diff changeset
   435
        return slot;
b9a691fc1df5 8006220: Simplify PropertyMaps
jlaskey
parents: 16240
diff changeset
   436
    }
b9a691fc1df5 8006220: Simplify PropertyMaps
jlaskey
parents: 16240
diff changeset
   437
b9a691fc1df5 8006220: Simplify PropertyMaps
jlaskey
parents: 16240
diff changeset
   438
    /**
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   439
     * get the Object value of this property from {@code owner}. This allows to bypass creation of the
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   440
     * getter MethodHandle for spill and user accessor properties.
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   441
     *
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   442
     * @param self the this object
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   443
     * @param owner the owner of the property
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   444
     * @return  the property value
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   445
     */
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   446
    public abstract int getIntValue(final ScriptObject self, final ScriptObject owner);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   447
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   448
    /**
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   449
     * get the Object value of this property from {@code owner}. This allows to bypass creation of the
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   450
     * getter MethodHandle for spill and user accessor properties.
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   451
     *
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   452
     * @param self the this object
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   453
     * @param owner the owner of the property
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   454
     * @return  the property value
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   455
     */
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   456
    public abstract double getDoubleValue(final ScriptObject self, final ScriptObject owner);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   457
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   458
    /**
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   459
     * get the Object value of this property from {@code owner}. This allows to bypass creation of the
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   460
     * getter MethodHandle for spill and user accessor properties.
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   461
     *
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   462
     * @param self the this object
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   463
     * @param owner the owner of the property
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   464
     * @return  the property value
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   465
     */
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   466
    public abstract Object getObjectValue(final ScriptObject self, final ScriptObject owner);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   467
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   468
    /**
17770
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   469
     * Set the value of this property in {@code owner}. This allows to bypass creation of the
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   470
     * setter MethodHandle for spill and user accessor properties.
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   471
     *
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   472
     * @param self the this object
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   473
     * @param owner the owner object
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   474
     * @param value the new property value
17774
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 17771
diff changeset
   475
     * @param strict is this a strict setter?
17770
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   476
     */
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   477
    public abstract void setValue(final ScriptObject self, final ScriptObject owner, final int value, final boolean strict);
17770
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   478
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   479
    /**
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   480
     * Set the value of this property in {@code owner}. This allows to bypass creation of the
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   481
     * setter MethodHandle for spill and user accessor properties.
17770
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   482
     *
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   483
     * @param self the this object
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   484
     * @param owner the owner object
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   485
     * @param value the new property value
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   486
     * @param strict is this a strict setter?
17770
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   487
     */
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   488
    public abstract void setValue(final ScriptObject self, final ScriptObject owner, final double value, final boolean strict);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   489
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   490
    /**
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   491
     * Set the value of this property in {@code owner}. This allows to bypass creation of the
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   492
     * setter MethodHandle for spill and user accessor properties.
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   493
     *
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   494
     * @param self the this object
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   495
     * @param owner the owner object
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   496
     * @param value the new property value
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   497
     * @param strict is this a strict setter?
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   498
     */
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   499
    public abstract void setValue(final ScriptObject self, final ScriptObject owner, final Object value, final boolean strict);
17770
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   500
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   501
    /**
36023
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   502
     * Returns true if this property has a low-level setter handle. This can be used to determine whether a
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   503
     * nasgen-generated accessor property should be treated as non-writable. For user-created accessor properties
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   504
     * {@link #hasSetterFunction(ScriptObject)} should be used to find whether a setter function exists in
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   505
     * a given object.
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   506
     *
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   507
     * @return true if a native setter handle exists
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   508
     */
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   509
    public abstract boolean hasNativeSetter();
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   510
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   511
    /**
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   512
     * Abstract method for retrieving the setter for the property. We do not know
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   513
     * anything about the internal representation when we request the setter, we only
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   514
     * know that the setter will take the property as a parameter of the given type.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   515
     * <p>
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   516
     * Note that we have to pass the current property map from which we retrieved
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   517
     * the property here. This is necessary for map guards if, e.g. the internal
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   518
     * representation of the field, and consequently also the setter, changes. Then
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   519
     * we automatically get a map guard that relinks the call site so that the
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   520
     * older setter will never be used again.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   521
     * <p>
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   522
     * see {@link ObjectClassGenerator#createSetter(Class, Class, MethodHandle, MethodHandle)}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   523
     * if you are interested in the internal details of this. Note that if you
27307
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   524
     * are running with {@code -Dnashorn.fields.objects=true}, the setters
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   525
     * will currently never change, as all properties are represented as Object field,
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   526
     * the Object fields are Initialized to {@code ScriptRuntime.UNDEFINED} and primitives are
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   527
     * boxed/unboxed upon every access, which is not necessarily optimal
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   528
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   529
     * @param type setter parameter type
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   530
     * @param currentMap current property map for property
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   531
     * @return a getter for this property as {@code type}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   532
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   533
    public abstract MethodHandle getSetter(final Class<?> type, final PropertyMap currentMap);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   534
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   535
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   536
     * Get the user defined getter function if one exists. Only {@link UserAccessorProperty} instances
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   537
     * can have user defined getters
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   538
     * @param obj the script object
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   539
     * @return user defined getter function, or {@code null} if none exists
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   540
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   541
    public ScriptFunction getGetterFunction(final ScriptObject obj) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   542
        return null;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   543
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   544
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   545
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   546
     * Get the user defined setter function if one exists. Only {@link UserAccessorProperty} instances
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   547
     * can have user defined getters
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   548
     * @param obj the script object
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   549
     * @return user defined getter function, or {@code null} if none exists
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   550
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   551
    public ScriptFunction getSetterFunction(final ScriptObject obj) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   552
        return null;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   553
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   554
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   555
    @Override
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   556
    public int hashCode() {
31548
d158ec7e1e30 8130663: 6 fields can be static fields in Global class
sundar
parents: 29834
diff changeset
   557
        final Class<?> t = getLocalType();
d158ec7e1e30 8130663: 6 fields can be static fields in Global class
sundar
parents: 29834
diff changeset
   558
        return Objects.hashCode(this.key) ^ flags ^ getSlot() ^ (t == null ? 0 : t.hashCode());
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   559
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   560
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   561
    @Override
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   562
    public boolean equals(final Object other) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   563
        if (this == other) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   564
            return true;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   565
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   566
16224
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   567
        if (other == null || this.getClass() != other.getClass()) {
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   568
            return false;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   569
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   570
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   571
        final Property otherProperty = (Property)other;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   572
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   573
        return equalsWithoutType(otherProperty) &&
27307
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   574
                getLocalType() == otherProperty.getLocalType();
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   575
    }
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   576
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   577
    boolean equalsWithoutType(final Property otherProperty) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   578
        return getFlags() == otherProperty.getFlags() &&
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   579
                getSlot() == otherProperty.getSlot() &&
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   580
                getKey().equals(otherProperty.getKey());
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   581
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   582
31548
d158ec7e1e30 8130663: 6 fields can be static fields in Global class
sundar
parents: 29834
diff changeset
   583
    private static String type(final Class<?> type) {
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   584
        if (type == null) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   585
            return "undef";
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   586
        } else if (type == int.class) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   587
            return "i";
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   588
        } else if (type == double.class) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   589
            return "d";
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   590
        } else {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   591
            return "o";
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   592
        }
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   593
    }
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   594
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   595
    /**
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   596
     * Short toString version
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   597
     * @return short toString
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   598
     */
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   599
    public final String toStringShort() {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   600
        final StringBuilder sb   = new StringBuilder();
31548
d158ec7e1e30 8130663: 6 fields can be static fields in Global class
sundar
parents: 29834
diff changeset
   601
        final Class<?>      t = getLocalType();
d158ec7e1e30 8130663: 6 fields can be static fields in Global class
sundar
parents: 29834
diff changeset
   602
        sb.append(getKey()).append(" (").append(type(t)).append(')');
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   603
        return sb.toString();
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   604
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   605
24725
7bb1f687a852 8033334: Make sure that scope depth information is maintained in the RecompilableScriptFunctionDatas, to avoid unnecessary slow proto linkage when doing on demand compilation
lagergren
parents: 24720
diff changeset
   606
    private static String indent(final String str, final int indent) {
7bb1f687a852 8033334: Make sure that scope depth information is maintained in the RecompilableScriptFunctionDatas, to avoid unnecessary slow proto linkage when doing on demand compilation
lagergren
parents: 24720
diff changeset
   607
        final StringBuilder sb = new StringBuilder();
7bb1f687a852 8033334: Make sure that scope depth information is maintained in the RecompilableScriptFunctionDatas, to avoid unnecessary slow proto linkage when doing on demand compilation
lagergren
parents: 24720
diff changeset
   608
        sb.append(str);
7bb1f687a852 8033334: Make sure that scope depth information is maintained in the RecompilableScriptFunctionDatas, to avoid unnecessary slow proto linkage when doing on demand compilation
lagergren
parents: 24720
diff changeset
   609
        for (int i = 0; i < indent - str.length(); i++) {
7bb1f687a852 8033334: Make sure that scope depth information is maintained in the RecompilableScriptFunctionDatas, to avoid unnecessary slow proto linkage when doing on demand compilation
lagergren
parents: 24720
diff changeset
   610
            sb.append(' ');
7bb1f687a852 8033334: Make sure that scope depth information is maintained in the RecompilableScriptFunctionDatas, to avoid unnecessary slow proto linkage when doing on demand compilation
lagergren
parents: 24720
diff changeset
   611
        }
7bb1f687a852 8033334: Make sure that scope depth information is maintained in the RecompilableScriptFunctionDatas, to avoid unnecessary slow proto linkage when doing on demand compilation
lagergren
parents: 24720
diff changeset
   612
        return sb.toString();
7bb1f687a852 8033334: Make sure that scope depth information is maintained in the RecompilableScriptFunctionDatas, to avoid unnecessary slow proto linkage when doing on demand compilation
lagergren
parents: 24720
diff changeset
   613
     }
7bb1f687a852 8033334: Make sure that scope depth information is maintained in the RecompilableScriptFunctionDatas, to avoid unnecessary slow proto linkage when doing on demand compilation
lagergren
parents: 24720
diff changeset
   614
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   615
    @Override
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   616
    public String toString() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   617
        final StringBuilder sb   = new StringBuilder();
31548
d158ec7e1e30 8130663: 6 fields can be static fields in Global class
sundar
parents: 29834
diff changeset
   618
        final Class<?>      t = getLocalType();
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   619
33690
46a1bc24cf2c 8141702: Add support for Symbol property keys
hannesw
parents: 31548
diff changeset
   620
        sb.append(indent(getKey().toString(), 20)).
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   621
            append(" id=").
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   622
            append(Debug.id(this)).
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   623
            append(" (0x").
24725
7bb1f687a852 8033334: Make sure that scope depth information is maintained in the RecompilableScriptFunctionDatas, to avoid unnecessary slow proto linkage when doing on demand compilation
lagergren
parents: 24720
diff changeset
   624
            append(indent(Integer.toHexString(flags), 4)).
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   625
            append(") ").
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   626
            append(getClass().getSimpleName()).
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   627
            append(" {").
31548
d158ec7e1e30 8130663: 6 fields can be static fields in Global class
sundar
parents: 29834
diff changeset
   628
            append(indent(type(t), 5)).
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   629
            append('}');
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   630
16224
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   631
        if (slot != -1) {
24725
7bb1f687a852 8033334: Make sure that scope depth information is maintained in the RecompilableScriptFunctionDatas, to avoid unnecessary slow proto linkage when doing on demand compilation
lagergren
parents: 24720
diff changeset
   632
            sb.append(" [").
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   633
               append("slot=").
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   634
               append(slot).
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   635
               append(']');
16224
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   636
        }
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   637
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   638
        return sb.toString();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   639
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   640
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   641
    /**
27307
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   642
     * Get the current type of this property. If you are running with object fields enabled,
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   643
     * this will always be Object.class. See the value representation explanation in
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   644
     * {@link Property#getSetter(Class, PropertyMap)} and {@link ObjectClassGenerator}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   645
     * for more information.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   646
     *
27307
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   647
     * <p>Note that for user accessor properties, this returns the type of the last observed
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   648
     * value passed to or returned by a user accessor. Use {@link #getLocalType()} to always get
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   649
     * the type of the actual value stored in the property slot.</p>
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   650
     *
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   651
     * @return current type of property, null means undefined
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   652
     */
27307
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   653
    public final Class<?> getType() {
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   654
        return type;
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   655
    }
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   656
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   657
    /**
27307
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   658
     * Set the type of this property.
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   659
     * @param type new type
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   660
     */
27307
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   661
    public final void setType(final Class<?> type) {
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   662
        assert type != boolean.class : "no boolean storage support yet - fix this";
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   663
        this.type = type == null ? null : type.isPrimitive() ? type : Object.class;
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   664
    }
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   665
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   666
    /**
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   667
     * Get the type of the value in the local property slot. This returns the same as
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   668
     * {@link #getType()} for normal properties, but always returns {@code Object.class}
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   669
     * for {@link UserAccessorProperty}s as their local type is a pair of accessor references.
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   670
     *
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   671
     * @return the local property type
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   672
     */
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   673
    protected Class<?> getLocalType() {
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   674
        return getType();
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   675
    }
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   676
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   677
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   678
     * Check whether this Property can ever change its type. The default is false, and if
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   679
     * you are not running with dual fields, the type is always object and can never change
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   680
     * @return true if this property can change types
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   681
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   682
    public boolean canChangeType() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   683
        return false;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   684
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   685
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   686
    /**
21685
ff0187bbe5c0 8027700: function redeclaration checks missing for declaration binding instantiation
sundar
parents: 19105
diff changeset
   687
     * Check whether this property represents a function declaration.
ff0187bbe5c0 8027700: function redeclaration checks missing for declaration binding instantiation
sundar
parents: 19105
diff changeset
   688
     * @return whether this property is a function declaration or not.
ff0187bbe5c0 8027700: function redeclaration checks missing for declaration binding instantiation
sundar
parents: 19105
diff changeset
   689
     */
ff0187bbe5c0 8027700: function redeclaration checks missing for declaration binding instantiation
sundar
parents: 19105
diff changeset
   690
    public boolean isFunctionDeclaration() {
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   691
        return (flags & IS_FUNCTION_DECLARATION) != 0;
21685
ff0187bbe5c0 8027700: function redeclaration checks missing for declaration binding instantiation
sundar
parents: 19105
diff changeset
   692
    }
27814
96427359f4fe 8057691: Nashorn: let & const declarations are not shared between scripts
hannesw
parents: 27307
diff changeset
   693
96427359f4fe 8057691: Nashorn: let & const declarations are not shared between scripts
hannesw
parents: 27307
diff changeset
   694
    /**
96427359f4fe 8057691: Nashorn: let & const declarations are not shared between scripts
hannesw
parents: 27307
diff changeset
   695
     * Is this a property defined by ES6 let or const?
96427359f4fe 8057691: Nashorn: let & const declarations are not shared between scripts
hannesw
parents: 27307
diff changeset
   696
     * @return true if this property represents a lexical binding.
96427359f4fe 8057691: Nashorn: let & const declarations are not shared between scripts
hannesw
parents: 27307
diff changeset
   697
     */
96427359f4fe 8057691: Nashorn: let & const declarations are not shared between scripts
hannesw
parents: 27307
diff changeset
   698
    public boolean isLexicalBinding() {
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   699
        return (flags & IS_LEXICAL_BINDING) != 0;
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   700
    }
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   701
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   702
    /**
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   703
     * Does this property support dual fields for both primitive and object values?
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   704
     * @return true if supports dual fields
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   705
     */
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   706
    public boolean hasDualFields() {
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   707
        return (flags & DUAL_FIELDS) != 0;
27814
96427359f4fe 8057691: Nashorn: let & const declarations are not shared between scripts
hannesw
parents: 27307
diff changeset
   708
    }
36023
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   709
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   710
    /**
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   711
     * Is this an accessor property as defined in ES5 8.6.1?
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   712
     * @return true if this is an accessor property
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   713
     */
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   714
    public boolean isAccessorProperty() {
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   715
        return (flags & IS_ACCESSOR_PROPERTY) != 0;
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   716
    }
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   717
}