src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SpillProperty.java
author hannesw
Wed, 21 Mar 2018 16:55:34 +0100
changeset 49275 c639a6b33c5c
parent 47216 71c04702a3d5
permissions -rw-r--r--
8199869: Missing copyright headers in nashorn source code Reviewed-by: sundar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
     1
/*
45033
0a226c99bb5a 8179889: Fix typographic errors in copyright headers
ihse
parents: 33690
diff changeset
     2
 * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
     4
 *
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    10
 *
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    15
 * accompanied this code).
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    16
 *
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    20
 *
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    23
 * questions.
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    24
 */
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    25
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    26
package jdk.nashorn.internal.runtime;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    27
24769
attila
parents: 24738
diff changeset
    28
import static jdk.nashorn.internal.lookup.Lookup.MH;
attila
parents: 24738
diff changeset
    29
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    30
import java.lang.invoke.MethodHandle;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    31
import java.lang.invoke.MethodHandles;
24720
75f8388b79df 8035836: Array performance improvements
lagergren
parents: 24719
diff changeset
    32
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    33
/**
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    34
 * Spill property
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    35
 */
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    36
public class SpillProperty extends AccessorProperty {
24769
attila
parents: 24738
diff changeset
    37
    private static final long serialVersionUID = 3028496245198669460L;
attila
parents: 24738
diff changeset
    38
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    39
    private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    40
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    41
    private static final MethodHandle PARRAY_GETTER = MH.asType(MH.getter(LOOKUP, ScriptObject.class, "primitiveSpill",  long[].class), MH.type(long[].class, Object.class));
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    42
    private static final MethodHandle OARRAY_GETTER = MH.asType(MH.getter(LOOKUP, ScriptObject.class, "objectSpill",  Object[].class), MH.type(Object[].class, Object.class));
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    43
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    44
    private static final MethodHandle OBJECT_GETTER    = MH.filterArguments(MH.arrayElementGetter(Object[].class), 0, OARRAY_GETTER);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    45
    private static final MethodHandle PRIMITIVE_GETTER = MH.filterArguments(MH.arrayElementGetter(long[].class), 0, PARRAY_GETTER);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    46
    private static final MethodHandle OBJECT_SETTER    = MH.filterArguments(MH.arrayElementSetter(Object[].class), 0, OARRAY_GETTER);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    47
    private static final MethodHandle PRIMITIVE_SETTER = MH.filterArguments(MH.arrayElementSetter(long[].class), 0, PARRAY_GETTER);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    48
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    49
    private static class Accessors {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    50
        private MethodHandle objectGetter;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    51
        private MethodHandle objectSetter;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    52
        private MethodHandle primitiveGetter;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    53
        private MethodHandle primitiveSetter;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    54
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    55
        private final int slot;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    56
        private final MethodHandle ensureSpillSize;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    57
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    58
        private static Accessors ACCESSOR_CACHE[] = new Accessors[512];
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    59
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    60
        //private static final Map<Integer, Reference<Accessors>> ACCESSOR_CACHE = Collections.synchronizedMap(new WeakHashMap<Integer, Reference<Accessors>>());
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    61
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    62
        Accessors(final int slot) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    63
            assert slot >= 0;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    64
            this.slot = slot;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    65
            this.ensureSpillSize = MH.asType(MH.insertArguments(ScriptObject.ENSURE_SPILL_SIZE, 1, slot), MH.type(Object.class, Object.class));
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    66
        }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    67
24738
be2026c9717c 8039746: Transform applies to calls wherever possible, for ScriptFunctions and JSObjects.
lagergren
parents: 24720
diff changeset
    68
        private static void ensure(final int slot) {
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    69
            int len = ACCESSOR_CACHE.length;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    70
            if (slot >= len) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    71
                do {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    72
                    len *= 2;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    73
                } while (slot >= len);
24738
be2026c9717c 8039746: Transform applies to calls wherever possible, for ScriptFunctions and JSObjects.
lagergren
parents: 24720
diff changeset
    74
                final Accessors newCache[] = new Accessors[len];
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    75
                System.arraycopy(ACCESSOR_CACHE, 0, newCache, 0, ACCESSOR_CACHE.length);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    76
                ACCESSOR_CACHE = newCache;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    77
            }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    78
        }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    79
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    80
        static MethodHandle getCached(final int slot, final boolean isPrimitive, final boolean isGetter) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    81
            //Reference<Accessors> ref = ACCESSOR_CACHE.get(slot);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    82
            ensure(slot);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    83
            Accessors acc = ACCESSOR_CACHE[slot];
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    84
            if (acc == null) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    85
                acc = new Accessors(slot);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    86
                ACCESSOR_CACHE[slot] = acc;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    87
            }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    88
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    89
            return acc.getOrCreate(isPrimitive, isGetter);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    90
        }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    91
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    92
        private static MethodHandle primordial(final boolean isPrimitive, final boolean isGetter) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    93
            if (isPrimitive) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    94
                return isGetter ? PRIMITIVE_GETTER : PRIMITIVE_SETTER;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    95
            }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    96
            return isGetter ? OBJECT_GETTER : OBJECT_SETTER;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    97
        }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    98
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
    99
        MethodHandle getOrCreate(final boolean isPrimitive, final boolean isGetter) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   100
            MethodHandle accessor;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   101
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   102
            accessor = getInner(isPrimitive, isGetter);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   103
            if (accessor != null) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   104
                return accessor;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   105
            }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   106
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   107
            accessor = primordial(isPrimitive, isGetter);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   108
            accessor = MH.insertArguments(accessor, 1, slot);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   109
            if (!isGetter) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   110
                accessor = MH.filterArguments(accessor, 0, ensureSpillSize);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   111
            }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   112
            setInner(isPrimitive, isGetter, accessor);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   113
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   114
            return accessor;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   115
        }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   116
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   117
        void setInner(final boolean isPrimitive, final boolean isGetter, final MethodHandle mh) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   118
            if (isPrimitive) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   119
                if (isGetter) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   120
                    primitiveGetter = mh;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   121
                } else {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   122
                    primitiveSetter = mh;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   123
                }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   124
            } else {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   125
                if (isGetter) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   126
                    objectGetter = mh;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   127
                } else {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   128
                    objectSetter = mh;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   129
                }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   130
            }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   131
        }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   132
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   133
        MethodHandle getInner(final boolean isPrimitive, final boolean isGetter) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   134
            if (isPrimitive) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   135
                return isGetter ? primitiveGetter : primitiveSetter;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   136
            }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   137
            return isGetter ? objectGetter : objectSetter;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   138
        }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   139
    }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   140
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 29405
diff changeset
   141
    private static MethodHandle primitiveGetter(final int slot, final int flags) {
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 29405
diff changeset
   142
        return (flags & DUAL_FIELDS) == DUAL_FIELDS ? Accessors.getCached(slot, true, true) : null;
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   143
    }
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 29405
diff changeset
   144
    private static MethodHandle primitiveSetter(final int slot, final int flags) {
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 29405
diff changeset
   145
        return (flags & DUAL_FIELDS) == DUAL_FIELDS ? Accessors.getCached(slot, true, false) : null;
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   146
    }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   147
    private static MethodHandle objectGetter(final int slot) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   148
        return Accessors.getCached(slot, false, true);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   149
    }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   150
    private static MethodHandle objectSetter(final int slot) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   151
        return Accessors.getCached(slot, false, false);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   152
    }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   153
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   154
    /**
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   155
     * Constructor for spill properties. Array getters and setters will be created on demand.
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   156
     *
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   157
     * @param key    the property key
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   158
     * @param flags  the property flags
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   159
     * @param slot   spill slot
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   160
     */
33690
46a1bc24cf2c 8141702: Add support for Symbol property keys
hannesw
parents: 29834
diff changeset
   161
    public SpillProperty(final Object key, final int flags, final int slot) {
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 29405
diff changeset
   162
        super(key, flags, slot, primitiveGetter(slot, flags), primitiveSetter(slot, flags), objectGetter(slot), objectSetter(slot));
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   163
    }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   164
29405
e4f80bdb9141 8074545: Undefined object values in object literals with spill properties
hannesw
parents: 27307
diff changeset
   165
    /**
e4f80bdb9141 8074545: Undefined object values in object literals with spill properties
hannesw
parents: 27307
diff changeset
   166
     * Constructor for spill properties with an initial type.
e4f80bdb9141 8074545: Undefined object values in object literals with spill properties
hannesw
parents: 27307
diff changeset
   167
     * @param key         the property key
e4f80bdb9141 8074545: Undefined object values in object literals with spill properties
hannesw
parents: 27307
diff changeset
   168
     * @param flags       the property flags
e4f80bdb9141 8074545: Undefined object values in object literals with spill properties
hannesw
parents: 27307
diff changeset
   169
     * @param slot        spill slot
e4f80bdb9141 8074545: Undefined object values in object literals with spill properties
hannesw
parents: 27307
diff changeset
   170
     * @param initialType initial type
e4f80bdb9141 8074545: Undefined object values in object literals with spill properties
hannesw
parents: 27307
diff changeset
   171
     */
e4f80bdb9141 8074545: Undefined object values in object literals with spill properties
hannesw
parents: 27307
diff changeset
   172
    public SpillProperty(final String key, final int flags, final int slot, final Class<?> initialType) {
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   173
        this(key, flags, slot);
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 29405
diff changeset
   174
        setType(hasDualFields() ? initialType : Object.class);
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   175
    }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   176
33690
46a1bc24cf2c 8141702: Add support for Symbol property keys
hannesw
parents: 29834
diff changeset
   177
    SpillProperty(final Object key, final int flags, final int slot, final ScriptObject owner, final Object initialValue) {
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   178
        this(key, flags, slot);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   179
        setInitialValue(owner, initialValue);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   180
    }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   181
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   182
    /**
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   183
     * Copy constructor
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   184
     * @param property other property
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   185
     */
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   186
    protected SpillProperty(final SpillProperty property) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   187
        super(property);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   188
    }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   189
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   190
    /**
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   191
     * Copy constructor
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   192
     * @param newType new type
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   193
     * @param property other property
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   194
     */
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   195
    protected SpillProperty(final SpillProperty property, final Class<?> newType) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   196
        super(property, newType);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   197
    }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   198
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   199
    @Override
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   200
    public Property copy() {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   201
        return new SpillProperty(this);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   202
    }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   203
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   204
    @Override
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   205
    public Property copy(final Class<?> newType) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   206
        return new SpillProperty(this, newType);
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   207
    }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   208
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   209
    @Override
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   210
    public boolean isSpill() {
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   211
        return true;
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   212
    }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   213
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   214
    @Override
26067
b32ccc3a76c9 8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents: 26060
diff changeset
   215
    void initMethodHandles(final Class<?> structure) {
26055
fe8be844ba50 8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents: 24769
diff changeset
   216
        final int slot  = getSlot();
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 29405
diff changeset
   217
        primitiveGetter = primitiveGetter(slot, getFlags());
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 29405
diff changeset
   218
        primitiveSetter = primitiveSetter(slot, getFlags());
26055
fe8be844ba50 8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents: 24769
diff changeset
   219
        objectGetter    = objectGetter(slot);
fe8be844ba50 8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents: 24769
diff changeset
   220
        objectSetter    = objectSetter(slot);
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   221
    }
f726e9d67629 8035820: Optimistic recompilation
attila
parents:
diff changeset
   222
}