src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Property.java
author darcy
Fri, 27 Sep 2019 08:57:25 -0700
changeset 58379 8511c662083b
parent 47216 71c04702a3d5
permissions -rw-r--r--
8231557: Suppress warnings on non-serializable instance fields in jdk.scripting.nashorn module Reviewed-by: jlaskey
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     1
/*
58379
8511c662083b 8231557: Suppress warnings on non-serializable instance fields in jdk.scripting.nashorn module
darcy
parents: 47216
diff changeset
     2
 * Copyright (c) 2010, 2019, 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. */
58379
8511c662083b 8231557: Suppress warnings on non-serializable instance fields in jdk.scripting.nashorn module
darcy
parents: 47216
diff changeset
   106
    @SuppressWarnings("serial") // Not statically typed as Serializable
33690
46a1bc24cf2c 8141702: Add support for Symbol property keys
hannesw
parents: 31548
diff changeset
   107
    private final Object key;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   108
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   109
    /** Property flags. */
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   110
    private int flags;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   111
17513
b9a691fc1df5 8006220: Simplify PropertyMaps
jlaskey
parents: 16240
diff changeset
   112
    /** Property field number or spill slot. */
16224
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   113
    private final int slot;
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   114
27307
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   115
    /**
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   116
     * 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
   117
     * 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
   118
     * 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
   119
     */
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   120
    private Class<?> type;
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   121
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
   122
    /** 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
   123
    protected transient SwitchPoint builtinSwitchPoint;
24738
be2026c9717c 8039746: Transform applies to calls wherever possible, for ScriptFunctions and JSObjects.
lagergren
parents: 24727
diff changeset
   124
23767
7c0614b75e23 8038638: Persistent store for compiled scripts
hannesw
parents: 23372
diff changeset
   125
    private static final long serialVersionUID = 2099814273074501176L;
7c0614b75e23 8038638: Persistent store for compiled scripts
hannesw
parents: 23372
diff changeset
   126
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   127
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   128
     * Constructor
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   129
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   130
     * @param key   property key
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   131
     * @param flags property flags
16224
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   132
     * @param slot  property field number or spill slot
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   133
     */
33690
46a1bc24cf2c 8141702: Add support for Symbol property keys
hannesw
parents: 31548
diff changeset
   134
    Property(final Object key, final int flags, final int slot) {
16224
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   135
        assert key != null;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   136
        this.key   = key;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   137
        this.flags = flags;
16224
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   138
        this.slot  = slot;
16147
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
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   142
     * Copy constructor
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   143
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   144
     * @param property source property
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   145
     */
24727
attila
parents: 24725 23372
diff changeset
   146
    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
   147
        this.key                = property.key;
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   148
        this.slot               = property.slot;
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   149
        this.builtinSwitchPoint = property.builtinSwitchPoint;
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   150
        this.flags              = flags;
16147
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
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   154
     * Copy function
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   155
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   156
     * @return cloned property
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   157
     */
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   158
    public abstract Property copy();
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   159
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   160
    /**
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   161
     * Copy function
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   162
     *
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   163
     * @param  newType new type
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   164
     * @return cloned property with new type
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   165
     */
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   166
    public abstract Property copy(final Class<?> newType);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   167
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   168
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   169
     * Property flag utility method for {@link PropertyDescriptor}s. Given two property descriptors,
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   170
     * return the result of merging their flags.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   171
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   172
     * @param oldDesc  first property descriptor
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   173
     * @param newDesc  second property descriptor
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   174
     * @return merged flags.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   175
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   176
    static int mergeFlags(final PropertyDescriptor oldDesc, final PropertyDescriptor newDesc) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   177
        int     propFlags = 0;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   178
        boolean value;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   179
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   180
        value = newDesc.has(CONFIGURABLE) ? newDesc.isConfigurable() : oldDesc.isConfigurable();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   181
        if (!value) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   182
            propFlags |= NOT_CONFIGURABLE;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   183
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   184
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   185
        value = newDesc.has(ENUMERABLE) ? newDesc.isEnumerable() : oldDesc.isEnumerable();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   186
        if (!value) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   187
            propFlags |= NOT_ENUMERABLE;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   188
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   189
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   190
        value = newDesc.has(WRITABLE) ? newDesc.isWritable() : oldDesc.isWritable();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   191
        if (!value) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   192
            propFlags |= NOT_WRITABLE;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   193
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   194
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   195
        return propFlags;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   196
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   197
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   198
    /**
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
   199
     * 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
   200
     * 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
   201
     * 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
   202
     * @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
   203
     */
26768
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   204
    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
   205
        this.builtinSwitchPoint = sp;
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
    /**
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   209
     * 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
   210
     * 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
   211
     * @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
   212
     */
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   213
    public final SwitchPoint getBuiltinSwitchPoint() {
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   214
        return builtinSwitchPoint;
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
    /**
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   218
     * 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
   219
     * 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
   220
     * @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
   221
     */
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   222
    public boolean isBuiltin() {
751b0f427090 8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents: 26646
diff changeset
   223
        return builtinSwitchPoint != null && !builtinSwitchPoint.hasBeenInvalidated();
24738
be2026c9717c 8039746: Transform applies to calls wherever possible, for ScriptFunctions and JSObjects.
lagergren
parents: 24727
diff changeset
   224
    }
be2026c9717c 8039746: Transform applies to calls wherever possible, for ScriptFunctions and JSObjects.
lagergren
parents: 24727
diff changeset
   225
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   226
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   227
     * Property flag utility method for {@link PropertyDescriptor}. Get the property flags
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   228
     * conforming to any Property using this PropertyDescriptor
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   229
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   230
     * @param desc property descriptor
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   231
     * @return flags for properties that conform to property descriptor
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   232
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   233
    static int toFlags(final PropertyDescriptor desc) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   234
        int propFlags = 0;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   235
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   236
        if (!desc.isConfigurable()) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   237
            propFlags |= NOT_CONFIGURABLE;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   238
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   239
        if (!desc.isEnumerable()) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   240
            propFlags |= NOT_ENUMERABLE;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   241
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   242
        if (!desc.isWritable()) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   243
            propFlags |= NOT_WRITABLE;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   244
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   245
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   246
        return propFlags;
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
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   250
     * 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
   251
     * @param obj object containing getter
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   252
     * @return true if getter function exists, false is default
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   253
     */
18617
f6fe338f62c3 8008458: Strict functions dont share property map
jlaskey
parents: 18615
diff changeset
   254
    public boolean hasGetterFunction(final ScriptObject obj) {
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   255
        return false;
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
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   259
     * 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
   260
     * @param obj object containing setter
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   261
     * @return true if getter function exists, false is default
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   262
     */
18617
f6fe338f62c3 8008458: Strict functions dont share property map
jlaskey
parents: 18615
diff changeset
   263
    public boolean hasSetterFunction(final ScriptObject obj) {
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   264
        return false;
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
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   268
     * Check whether this property is writable (see ECMA 8.6.1)
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   269
     * @return true if writable
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   270
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   271
    public boolean isWritable() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   272
        return (flags & NOT_WRITABLE) == 0;
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
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   276
     * Check whether this property is writable (see ECMA 8.6.1)
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   277
     * @return true if configurable
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   278
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   279
    public boolean isConfigurable() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   280
        return (flags & NOT_CONFIGURABLE) == 0;
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
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   284
     * Check whether this property is enumerable (see ECMA 8.6.1)
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   285
     * @return true if enumerable
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   286
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   287
    public boolean isEnumerable() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   288
        return (flags & NOT_ENUMERABLE) == 0;
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
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   292
     * Check whether this property is used as a function parameter
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   293
     * @return true if parameter
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   294
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   295
    public boolean isParameter() {
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   296
        return (flags & IS_PARAMETER) != 0;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   297
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   298
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   299
    /**
16224
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   300
     * Check whether this property is in an object with arguments field
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   301
     * @return true if has arguments
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   302
     */
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   303
    public boolean hasArguments() {
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   304
        return (flags & HAS_ARGUMENTS) != 0;
16224
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
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   307
    /**
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   308
     * Check whether this is a spill property, i.e. one that will not
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   309
     * be stored in a specially generated field in the property class.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   310
     * The spill pool is maintained separately, as a growing Object array
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   311
     * in the {@link ScriptObject}.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   312
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   313
     * @return true if spill property
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   314
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   315
    public boolean isSpill() {
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   316
        return false;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   317
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   318
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   319
    /**
23372
09707b3e5fb0 8021350: Share script classes between threads/globals within context
hannesw
parents: 21685
diff changeset
   320
     * 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
   321
     * 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
   322
     *
09707b3e5fb0 8021350: Share script classes between threads/globals within context
hannesw
parents: 21685
diff changeset
   323
     * @return true if this is a bound property
09707b3e5fb0 8021350: Share script classes between threads/globals within context
hannesw
parents: 21685
diff changeset
   324
     */
09707b3e5fb0 8021350: Share script classes between threads/globals within context
hannesw
parents: 21685
diff changeset
   325
    public boolean isBound() {
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   326
        return (flags & IS_BOUND) != 0;
23372
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
09707b3e5fb0 8021350: Share script classes between threads/globals within context
hannesw
parents: 21685
diff changeset
   329
    /**
26377
028dad61662f 8051889: Implement block scoping in symbol assignment and scope computation
hannesw
parents: 26068
diff changeset
   330
     * 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
   331
     *
028dad61662f 8051889: Implement block scoping in symbol assignment and scope computation
hannesw
parents: 26068
diff changeset
   332
     * @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
   333
     */
028dad61662f 8051889: Implement block scoping in symbol assignment and scope computation
hannesw
parents: 26068
diff changeset
   334
    public boolean needsDeclaration() {
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   335
        return (flags & NEEDS_DECLARATION) != 0;
26377
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
028dad61662f 8051889: Implement block scoping in symbol assignment and scope computation
hannesw
parents: 26068
diff changeset
   338
    /**
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   339
     * Add more property flags to the property. Properties are immutable here,
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   340
     * so any property change that results in a larger flag set results in the
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   341
     * property being cloned. Use only the return value
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   342
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   343
     * @param propertyFlags flags to be OR:ed to the existing property flags
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   344
     * @return new property if property set was changed, {@code this} otherwise
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   345
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   346
    public Property addFlags(final int propertyFlags) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   347
        if ((this.flags & propertyFlags) != propertyFlags) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   348
            final Property cloned = this.copy();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   349
            cloned.flags |= propertyFlags;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   350
            return cloned;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   351
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   352
        return this;
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
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   356
     * Get the flags for this property
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   357
     * @return property flags
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   358
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   359
    public int getFlags() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   360
        return flags;
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
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   364
     * Remove property flags from the property. Properties are immutable here,
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   365
     * so any property change that results in a smaller flag set results in the
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   366
     * property being cloned. Use only the return value
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   367
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   368
     * @param propertyFlags flags to be subtracted from the existing property flags
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   369
     * @return new property if property set was changed, {@code this} otherwise
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   370
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   371
    public Property removeFlags(final int propertyFlags) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   372
        if ((this.flags & propertyFlags) != 0) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   373
            final Property cloned = this.copy();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   374
            cloned.flags &= ~propertyFlags;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   375
            return cloned;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   376
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   377
        return this;
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
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   381
     * Reset the property for this property. Properties are immutable here,
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   382
     * so any property change that results in a different flag sets results in the
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   383
     * property being cloned. Use only the return value
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   384
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   385
     * @param propertyFlags flags that are replacing from the existing property flags
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   386
     * @return new property if property set was changed, {@code this} otherwise
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   387
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   388
    public Property setFlags(final int propertyFlags) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   389
        if (this.flags != propertyFlags) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   390
            final Property cloned = this.copy();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   391
            cloned.flags &= ~MODIFY_MASK;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   392
            cloned.flags |= propertyFlags & MODIFY_MASK;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   393
            return cloned;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   394
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   395
        return this;
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
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   399
     * Abstract method for retrieving the getter for the property. We do not know
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   400
     * anything about the internal representation when we request the getter, we only
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   401
     * know that the getter will return the property as the given type.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   402
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   403
     * @param type getter return value type
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   404
     * @return a getter for this property as {@code type}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   405
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   406
    public abstract MethodHandle getGetter(final Class<?> type);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   407
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   408
    /**
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   409
     * 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
   410
     * @param type          type
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   411
     * @param programPoint  program point
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   412
     * @return getter
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   413
     */
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   414
    public abstract MethodHandle getOptimisticGetter(final Class<?> type, final int programPoint);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   415
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   416
    /**
23767
7c0614b75e23 8038638: Persistent store for compiled scripts
hannesw
parents: 23372
diff changeset
   417
     * Hook to initialize method handles after deserialization.
7c0614b75e23 8038638: Persistent store for compiled scripts
hannesw
parents: 23372
diff changeset
   418
     *
7c0614b75e23 8038638: Persistent store for compiled scripts
hannesw
parents: 23372
diff changeset
   419
     * @param structure the structure class
7c0614b75e23 8038638: Persistent store for compiled scripts
hannesw
parents: 23372
diff changeset
   420
     */
7c0614b75e23 8038638: Persistent store for compiled scripts
hannesw
parents: 23372
diff changeset
   421
    abstract void initMethodHandles(final Class<?> structure);
7c0614b75e23 8038638: Persistent store for compiled scripts
hannesw
parents: 23372
diff changeset
   422
7c0614b75e23 8038638: Persistent store for compiled scripts
hannesw
parents: 23372
diff changeset
   423
    /**
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   424
     * Get the key for this property. This key is an ordinary string. The "name".
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   425
     * @return key for property
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   426
     */
33690
46a1bc24cf2c 8141702: Add support for Symbol property keys
hannesw
parents: 31548
diff changeset
   427
    public Object getKey() {
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   428
        return key;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   429
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   430
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   431
    /**
17513
b9a691fc1df5 8006220: Simplify PropertyMaps
jlaskey
parents: 16240
diff changeset
   432
     * Get the field number or spill slot
b9a691fc1df5 8006220: Simplify PropertyMaps
jlaskey
parents: 16240
diff changeset
   433
     * @return number/slot, -1 if none exists
b9a691fc1df5 8006220: Simplify PropertyMaps
jlaskey
parents: 16240
diff changeset
   434
     */
b9a691fc1df5 8006220: Simplify PropertyMaps
jlaskey
parents: 16240
diff changeset
   435
    public int getSlot() {
b9a691fc1df5 8006220: Simplify PropertyMaps
jlaskey
parents: 16240
diff changeset
   436
        return slot;
b9a691fc1df5 8006220: Simplify PropertyMaps
jlaskey
parents: 16240
diff changeset
   437
    }
b9a691fc1df5 8006220: Simplify PropertyMaps
jlaskey
parents: 16240
diff changeset
   438
b9a691fc1df5 8006220: Simplify PropertyMaps
jlaskey
parents: 16240
diff changeset
   439
    /**
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   440
     * 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
   441
     * getter MethodHandle for spill and user accessor properties.
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   442
     *
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   443
     * @param self the this object
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   444
     * @param owner the owner of the property
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   445
     * @return  the property value
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   446
     */
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   447
    public abstract int getIntValue(final ScriptObject self, final ScriptObject owner);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   448
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   449
    /**
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   450
     * 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
   451
     * getter MethodHandle for spill and user accessor properties.
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   452
     *
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   453
     * @param self the this object
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   454
     * @param owner the owner of the property
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   455
     * @return  the property value
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   456
     */
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   457
    public abstract double getDoubleValue(final ScriptObject self, final ScriptObject owner);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   458
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   459
    /**
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   460
     * 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
   461
     * getter MethodHandle for spill and user accessor properties.
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   462
     *
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   463
     * @param self the this object
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   464
     * @param owner the owner of the property
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   465
     * @return  the property value
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   466
     */
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   467
    public abstract Object getObjectValue(final ScriptObject self, final ScriptObject owner);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   468
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   469
    /**
17770
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   470
     * 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
   471
     * setter MethodHandle for spill and user accessor properties.
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   472
     *
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   473
     * @param self the this object
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   474
     * @param owner the owner object
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   475
     * @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
   476
     * @param strict is this a strict setter?
17770
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   477
     */
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   478
    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
   479
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   480
    /**
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   481
     * 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
   482
     * setter MethodHandle for spill and user accessor properties.
17770
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   483
     *
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   484
     * @param self the this object
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   485
     * @param owner the owner object
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   486
     * @param value the new property value
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   487
     * @param strict is this a strict setter?
17770
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   488
     */
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   489
    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
   490
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   491
    /**
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   492
     * 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
   493
     * setter MethodHandle for spill and user accessor properties.
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   494
     *
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   495
     * @param self the this object
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   496
     * @param owner the owner object
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   497
     * @param value the new property value
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   498
     * @param strict is this a strict setter?
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   499
     */
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   500
    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
   501
3c8602ec5565 8011630: JSON parsing performance issue
hannesw
parents: 17513
diff changeset
   502
    /**
36023
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   503
     * 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
   504
     * 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
   505
     * {@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
   506
     * a given object.
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   507
     *
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   508
     * @return true if a native setter handle exists
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   509
     */
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   510
    public abstract boolean hasNativeSetter();
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   511
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   512
    /**
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   513
     * Abstract method for retrieving the setter for the property. We do not know
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   514
     * anything about the internal representation when we request the setter, we only
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   515
     * know that the setter will take the property as a parameter of the given type.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   516
     * <p>
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   517
     * Note that we have to pass the current property map from which we retrieved
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   518
     * the property here. This is necessary for map guards if, e.g. the internal
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   519
     * representation of the field, and consequently also the setter, changes. Then
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   520
     * we automatically get a map guard that relinks the call site so that the
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   521
     * older setter will never be used again.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   522
     * <p>
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   523
     * see {@link ObjectClassGenerator#createSetter(Class, Class, MethodHandle, MethodHandle)}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   524
     * 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
   525
     * are running with {@code -Dnashorn.fields.objects=true}, the setters
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   526
     * will currently never change, as all properties are represented as Object field,
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   527
     * the Object fields are Initialized to {@code ScriptRuntime.UNDEFINED} and primitives are
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   528
     * boxed/unboxed upon every access, which is not necessarily optimal
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   529
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   530
     * @param type setter parameter type
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   531
     * @param currentMap current property map for property
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   532
     * @return a getter for this property as {@code type}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   533
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   534
    public abstract MethodHandle getSetter(final Class<?> type, final PropertyMap currentMap);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   535
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   536
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   537
     * Get the user defined getter function if one exists. Only {@link UserAccessorProperty} instances
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   538
     * can have user defined getters
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   539
     * @param obj the script object
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   540
     * @return user defined getter function, or {@code null} if none exists
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   541
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   542
    public ScriptFunction getGetterFunction(final ScriptObject obj) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   543
        return null;
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
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   547
     * Get the user defined setter function if one exists. Only {@link UserAccessorProperty} instances
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   548
     * can have user defined getters
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   549
     * @param obj the script object
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   550
     * @return user defined getter function, or {@code null} if none exists
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   551
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   552
    public ScriptFunction getSetterFunction(final ScriptObject obj) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   553
        return null;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   554
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   555
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   556
    @Override
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   557
    public int hashCode() {
31548
d158ec7e1e30 8130663: 6 fields can be static fields in Global class
sundar
parents: 29834
diff changeset
   558
        final Class<?> t = getLocalType();
d158ec7e1e30 8130663: 6 fields can be static fields in Global class
sundar
parents: 29834
diff changeset
   559
        return Objects.hashCode(this.key) ^ flags ^ getSlot() ^ (t == null ? 0 : t.hashCode());
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   560
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   561
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   562
    @Override
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   563
    public boolean equals(final Object other) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   564
        if (this == other) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   565
            return true;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   566
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   567
16224
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   568
        if (other == null || this.getClass() != other.getClass()) {
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   569
            return false;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   570
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   571
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   572
        final Property otherProperty = (Property)other;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   573
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   574
        return equalsWithoutType(otherProperty) &&
27307
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   575
                getLocalType() == otherProperty.getLocalType();
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   576
    }
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   577
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   578
    boolean equalsWithoutType(final Property otherProperty) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   579
        return getFlags() == otherProperty.getFlags() &&
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   580
                getSlot() == otherProperty.getSlot() &&
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   581
                getKey().equals(otherProperty.getKey());
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   582
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   583
31548
d158ec7e1e30 8130663: 6 fields can be static fields in Global class
sundar
parents: 29834
diff changeset
   584
    private static String type(final Class<?> type) {
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   585
        if (type == null) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   586
            return "undef";
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   587
        } else if (type == int.class) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   588
            return "i";
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   589
        } else if (type == double.class) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   590
            return "d";
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   591
        } else {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   592
            return "o";
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
    /**
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   597
     * Short toString version
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   598
     * @return short toString
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   599
     */
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   600
    public final String toStringShort() {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   601
        final StringBuilder sb   = new StringBuilder();
31548
d158ec7e1e30 8130663: 6 fields can be static fields in Global class
sundar
parents: 29834
diff changeset
   602
        final Class<?>      t = getLocalType();
d158ec7e1e30 8130663: 6 fields can be static fields in Global class
sundar
parents: 29834
diff changeset
   603
        sb.append(getKey()).append(" (").append(type(t)).append(')');
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   604
        return sb.toString();
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   605
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   606
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
   607
    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
   608
        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
   609
        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
   610
        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
   611
            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
   612
        }
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
        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
   614
     }
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
   615
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   616
    @Override
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   617
    public String toString() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   618
        final StringBuilder sb   = new StringBuilder();
31548
d158ec7e1e30 8130663: 6 fields can be static fields in Global class
sundar
parents: 29834
diff changeset
   619
        final Class<?>      t = getLocalType();
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   620
33690
46a1bc24cf2c 8141702: Add support for Symbol property keys
hannesw
parents: 31548
diff changeset
   621
        sb.append(indent(getKey().toString(), 20)).
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   622
            append(" id=").
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   623
            append(Debug.id(this)).
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   624
            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
   625
            append(indent(Integer.toHexString(flags), 4)).
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   626
            append(") ").
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   627
            append(getClass().getSimpleName()).
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   628
            append(" {").
31548
d158ec7e1e30 8130663: 6 fields can be static fields in Global class
sundar
parents: 29834
diff changeset
   629
            append(indent(type(t), 5)).
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   630
            append('}');
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   631
16224
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   632
        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
   633
            sb.append(" [").
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   634
               append("slot=").
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   635
               append(slot).
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   636
               append(']');
16224
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   637
        }
0c49ad4e3b55 8006222: Move slot from SpillProperty to Property
jlaskey
parents: 16151
diff changeset
   638
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   639
        return sb.toString();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   640
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   641
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   642
    /**
27307
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   643
     * 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
   644
     * this will always be Object.class. See the value representation explanation in
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   645
     * {@link Property#getSetter(Class, PropertyMap)} and {@link ObjectClassGenerator}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   646
     * for more information.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   647
     *
27307
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   648
     * <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
   649
     * 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
   650
     * 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
   651
     *
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   652
     * @return current type of property, null means undefined
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   653
     */
27307
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   654
    public final Class<?> getType() {
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   655
        return type;
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   656
    }
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   657
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   658
    /**
27307
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   659
     * Set the type of this property.
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   660
     * @param type new type
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21685
diff changeset
   661
     */
27307
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   662
    public final void setType(final Class<?> type) {
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   663
        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
   664
        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
   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
    /**
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   668
     * 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
   669
     * {@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
   670
     * 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
   671
     *
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   672
     * @return the local property type
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   673
     */
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   674
    protected Class<?> getLocalType() {
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   675
        return getType();
62ed492cbe63 8062401: User accessors require boxing and do not support optimistic types
hannesw
parents: 26768
diff changeset
   676
    }
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   677
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   678
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   679
     * Check whether this Property can ever change its type. The default is false, and if
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   680
     * 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
   681
     * @return true if this property can change types
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   682
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   683
    public boolean canChangeType() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   684
        return false;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   685
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   686
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   687
    /**
21685
ff0187bbe5c0 8027700: function redeclaration checks missing for declaration binding instantiation
sundar
parents: 19105
diff changeset
   688
     * Check whether this property represents a function declaration.
ff0187bbe5c0 8027700: function redeclaration checks missing for declaration binding instantiation
sundar
parents: 19105
diff changeset
   689
     * @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
   690
     */
ff0187bbe5c0 8027700: function redeclaration checks missing for declaration binding instantiation
sundar
parents: 19105
diff changeset
   691
    public boolean isFunctionDeclaration() {
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   692
        return (flags & IS_FUNCTION_DECLARATION) != 0;
21685
ff0187bbe5c0 8027700: function redeclaration checks missing for declaration binding instantiation
sundar
parents: 19105
diff changeset
   693
    }
27814
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
    /**
96427359f4fe 8057691: Nashorn: let & const declarations are not shared between scripts
hannesw
parents: 27307
diff changeset
   696
     * 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
   697
     * @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
   698
     */
96427359f4fe 8057691: Nashorn: let & const declarations are not shared between scripts
hannesw
parents: 27307
diff changeset
   699
    public boolean isLexicalBinding() {
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   700
        return (flags & IS_LEXICAL_BINDING) != 0;
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
    /**
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   704
     * 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
   705
     * @return true if supports dual fields
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   706
     */
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   707
    public boolean hasDualFields() {
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27814
diff changeset
   708
        return (flags & DUAL_FIELDS) != 0;
27814
96427359f4fe 8057691: Nashorn: let & const declarations are not shared between scripts
hannesw
parents: 27307
diff changeset
   709
    }
36023
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
    /**
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   712
     * Is this an accessor property as defined in ES5 8.6.1?
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   713
     * @return true if this is an accessor property
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   714
     */
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   715
    public boolean isAccessorProperty() {
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   716
        return (flags & IS_ACCESSOR_PROPERTY) != 0;
528cc67f1289 8147558: Add support for ES6 collections
hannesw
parents: 34732
diff changeset
   717
    }
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   718
}