nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SpillObjectCreator.java
author hannesw
Sat, 19 Sep 2015 16:04:28 +0200
changeset 32781 d8f34ffbbc7a
parent 30390 357f9a3f9394
child 33690 46a1bc24cf2c
permissions -rw-r--r--
8135190: Method code too large in Babel browser.js script Reviewed-by: attila, sundar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18852
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
     1
/*
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
     2
 * Copyright (c) 2010-2013, Oracle and/or its affiliates. All rights reserved.
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
     4
 *
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    10
 *
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    15
 * accompanied this code).
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    16
 *
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    20
 *
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    23
 * questions.
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    24
 */
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    25
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    26
package jdk.nashorn.internal.codegen;
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    27
18867
bc91e3fcc5ba 8013925: Remove symbol fields from nodes that don't need them
attila
parents: 18852
diff changeset
    28
import static jdk.nashorn.internal.codegen.CompilerConstants.constructorNoLookup;
19236
73d242d205f9 8020132: Big object literal with numerical keys exceeds method size
hannesw
parents: 19097
diff changeset
    29
import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCallNoLookup;
24738
be2026c9717c 8039746: Transform applies to calls wherever possible, for ScriptFunctions and JSObjects.
lagergren
parents: 24733
diff changeset
    30
19236
73d242d205f9 8020132: Big object literal with numerical keys exceeds method size
hannesw
parents: 19097
diff changeset
    31
import java.util.LinkedHashSet;
18867
bc91e3fcc5ba 8013925: Remove symbol fields from nodes that don't need them
attila
parents: 18852
diff changeset
    32
import java.util.List;
19236
73d242d205f9 8020132: Big object literal with numerical keys exceeds method size
hannesw
parents: 19097
diff changeset
    33
import java.util.Set;
24751
ccbd9cd3f720 8042118: Separate types from symbols
attila
parents: 24738
diff changeset
    34
import jdk.nashorn.internal.codegen.types.Type;
18867
bc91e3fcc5ba 8013925: Remove symbol fields from nodes that don't need them
attila
parents: 18852
diff changeset
    35
import jdk.nashorn.internal.ir.Expression;
18852
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    36
import jdk.nashorn.internal.ir.LiteralNode;
24733
1e825be55fd1 8027043: Turn global accesses into MethodHandle.constant, with one chance of reassignment, e.g. x = value occuring once in the global scope is ok, twice is not.
lagergren
parents: 24719
diff changeset
    37
import jdk.nashorn.internal.runtime.JSType;
18852
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    38
import jdk.nashorn.internal.runtime.Property;
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    39
import jdk.nashorn.internal.runtime.PropertyMap;
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    40
import jdk.nashorn.internal.runtime.ScriptObject;
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    41
import jdk.nashorn.internal.runtime.ScriptRuntime;
19236
73d242d205f9 8020132: Big object literal with numerical keys exceeds method size
hannesw
parents: 19097
diff changeset
    42
import jdk.nashorn.internal.runtime.arrays.ArrayData;
73d242d205f9 8020132: Big object literal with numerical keys exceeds method size
hannesw
parents: 19097
diff changeset
    43
import jdk.nashorn.internal.runtime.arrays.ArrayIndex;
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27307
diff changeset
    44
import jdk.nashorn.internal.scripts.JD;
18852
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    45
import jdk.nashorn.internal.scripts.JO;
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    46
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    47
/**
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    48
 * An object creator that uses spill properties.
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    49
 */
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    50
public final class SpillObjectCreator extends ObjectCreator<Expression> {
18852
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    51
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    52
    /**
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    53
     * Constructor
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    54
     *
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    55
     * @param codegen  code generator
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    56
     * @param tuples   tuples for key, symbol, value
18852
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    57
     */
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    58
    SpillObjectCreator(final CodeGenerator codegen, final List<MapTuple<Expression>> tuples) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    59
        super(codegen, tuples, false, false);
18852
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    60
        makeMap();
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    61
    }
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    62
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    63
    @Override
32781
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
    64
    public void createObject(final MethodEmitter method) {
18852
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    65
        assert !isScope() : "spill scope objects are not currently supported";
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    66
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    67
        final int          length        = tuples.size();
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27307
diff changeset
    68
        final boolean      dualFields    = codegen.useDualFields();
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27307
diff changeset
    69
        final int          spillLength   = ScriptObject.spillAllocationLength(length);
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27307
diff changeset
    70
        final long[]       jpresetValues = dualFields ? new long[spillLength] : null;
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27307
diff changeset
    71
        final Object[]     opresetValues = new Object[spillLength];
32781
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
    72
        final Class<?>     objectClass   = getAllocatorClass();
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    73
        ArrayData          arrayData     = ArrayData.allocate(ScriptRuntime.EMPTY_ARRAY);
18852
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    74
19236
73d242d205f9 8020132: Big object literal with numerical keys exceeds method size
hannesw
parents: 19097
diff changeset
    75
        // Compute constant property values
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    76
        int pos = 0;
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    77
        for (final MapTuple<Expression> tuple : tuples) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    78
            final String     key   = tuple.key;
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    79
            final Expression value = tuple.value;
18852
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
    80
24738
be2026c9717c 8039746: Transform applies to calls wherever possible, for ScriptFunctions and JSObjects.
lagergren
parents: 24733
diff changeset
    81
            //this is a nop of tuple.key isn't e.g. "apply" or another special name
be2026c9717c 8039746: Transform applies to calls wherever possible, for ScriptFunctions and JSObjects.
lagergren
parents: 24733
diff changeset
    82
            method.invalidateSpecialName(tuple.key);
be2026c9717c 8039746: Transform applies to calls wherever possible, for ScriptFunctions and JSObjects.
lagergren
parents: 24733
diff changeset
    83
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    84
            if (value != null) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    85
                final Object constantValue = LiteralNode.objectAsConstant(value);
32781
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
    86
                if (constantValue != LiteralNode.POSTSET_MARKER) {
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    87
                    final Property property = propertyMap.findProperty(key);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    88
                    if (property != null) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    89
                        // normal property key
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27307
diff changeset
    90
                        property.setType(dualFields ? JSType.unboxedFieldType(constantValue) : Object.class);
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    91
                        final int slot = property.getSlot();
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27307
diff changeset
    92
                        if (dualFields && constantValue instanceof Number) {
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    93
                            jpresetValues[slot] = ObjectClassGenerator.pack((Number)constantValue);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    94
                        } else {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    95
                            opresetValues[slot] = constantValue;
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    96
                        }
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    97
                    } else {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    98
                        // array index key
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
    99
                        final long oldLength = arrayData.length();
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   100
                        final int  index     = ArrayIndex.getArrayIndex(key);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   101
                        final long longIndex = ArrayIndex.toLongIndex(index);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   102
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   103
                        assert ArrayIndex.isValidArrayIndex(index);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   104
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   105
                        if (longIndex >= oldLength) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   106
                            arrayData = arrayData.ensure(longIndex);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   107
                        }
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   108
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   109
                        //avoid blowing up the array if we can
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   110
                        if (constantValue instanceof Integer) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   111
                            arrayData = arrayData.set(index, ((Integer)constantValue).intValue(), false);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   112
                        } else if (constantValue instanceof Long) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   113
                            arrayData = arrayData.set(index, ((Long)constantValue).longValue(), false);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   114
                        } else if (constantValue instanceof Double) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   115
                            arrayData = arrayData.set(index, ((Double)constantValue).doubleValue(), false);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   116
                        } else {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   117
                            arrayData = arrayData.set(index, constantValue, false);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   118
                        }
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   119
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   120
                        if (longIndex > oldLength) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   121
                            arrayData = arrayData.delete(oldLength, longIndex - 1);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   122
                        }
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   123
                    }
19236
73d242d205f9 8020132: Big object literal with numerical keys exceeds method size
hannesw
parents: 19097
diff changeset
   124
                }
18852
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
   125
            }
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   126
            pos++;
18852
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
   127
        }
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
   128
19236
73d242d205f9 8020132: Big object literal with numerical keys exceeds method size
hannesw
parents: 19097
diff changeset
   129
        // create object and invoke constructor
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27307
diff changeset
   130
        method._new(objectClass).dup();
18852
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
   131
        codegen.loadConstant(propertyMap);
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   132
30388
3a270ce8e030 8078049: Nashorn crashes when attempting to start TypeScript compiler
hannesw
parents: 29834
diff changeset
   133
        // load primitive value spill array
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27307
diff changeset
   134
        if (dualFields) {
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27307
diff changeset
   135
            codegen.loadConstant(jpresetValues);
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27307
diff changeset
   136
        } else {
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27307
diff changeset
   137
            method.loadNull();
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   138
        }
30388
3a270ce8e030 8078049: Nashorn crashes when attempting to start TypeScript compiler
hannesw
parents: 29834
diff changeset
   139
        // load object value spill array
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   140
        codegen.loadConstant(opresetValues);
19236
73d242d205f9 8020132: Big object literal with numerical keys exceeds method size
hannesw
parents: 19097
diff changeset
   141
30388
3a270ce8e030 8078049: Nashorn crashes when attempting to start TypeScript compiler
hannesw
parents: 29834
diff changeset
   142
        // instantiate the script object with spill objects
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27307
diff changeset
   143
        method.invoke(constructorNoLookup(objectClass, PropertyMap.class, long[].class, Object[].class));
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   144
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   145
        // Set prefix array data if any
19236
73d242d205f9 8020132: Big object literal with numerical keys exceeds method size
hannesw
parents: 19097
diff changeset
   146
        if (arrayData.length() > 0) {
73d242d205f9 8020132: Big object literal with numerical keys exceeds method size
hannesw
parents: 19097
diff changeset
   147
            method.dup();
73d242d205f9 8020132: Big object literal with numerical keys exceeds method size
hannesw
parents: 19097
diff changeset
   148
            codegen.loadConstant(arrayData);
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   149
            method.invoke(virtualCallNoLookup(ScriptObject.class, "setArray", void.class, ArrayData.class));
19236
73d242d205f9 8020132: Big object literal with numerical keys exceeds method size
hannesw
parents: 19097
diff changeset
   150
        }
32781
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
   151
    }
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
   152
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
   153
    @Override
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
   154
    public void populateRange(final MethodEmitter method, final Type objectType, final int objectSlot, final int start, final int end) {
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
   155
        final int  callSiteFlags = codegen.getCallSiteFlags();
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
   156
        method.load(objectType, objectSlot);
18852
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
   157
30388
3a270ce8e030 8078049: Nashorn crashes when attempting to start TypeScript compiler
hannesw
parents: 29834
diff changeset
   158
        // set postfix values
32781
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
   159
        for (int i = start; i < end; i++) {
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27307
diff changeset
   160
            final MapTuple<Expression> tuple = tuples.get(i);
32781
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
   161
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
   162
            if (LiteralNode.isConstant(tuple.value)) {
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
   163
                continue;
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
   164
            }
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
   165
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27307
diff changeset
   166
            final Property property = propertyMap.findProperty(tuple.key);
32781
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
   167
19236
73d242d205f9 8020132: Big object literal with numerical keys exceeds method size
hannesw
parents: 19097
diff changeset
   168
            if (property == null) {
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   169
                final int index = ArrayIndex.getArrayIndex(tuple.key);
19236
73d242d205f9 8020132: Big object literal with numerical keys exceeds method size
hannesw
parents: 19097
diff changeset
   170
                assert ArrayIndex.isValidArrayIndex(index);
18852
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
   171
                method.dup();
19236
73d242d205f9 8020132: Big object literal with numerical keys exceeds method size
hannesw
parents: 19097
diff changeset
   172
                method.load(ArrayIndex.toLongIndex(index));
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   173
                loadTuple(method, tuple);
19236
73d242d205f9 8020132: Big object literal with numerical keys exceeds method size
hannesw
parents: 19097
diff changeset
   174
                method.dynamicSetIndex(callSiteFlags);
30388
3a270ce8e030 8078049: Nashorn crashes when attempting to start TypeScript compiler
hannesw
parents: 29834
diff changeset
   175
            } else {
3a270ce8e030 8078049: Nashorn crashes when attempting to start TypeScript compiler
hannesw
parents: 29834
diff changeset
   176
                method.dup();
3a270ce8e030 8078049: Nashorn crashes when attempting to start TypeScript compiler
hannesw
parents: 29834
diff changeset
   177
                loadTuple(method, tuple);
3a270ce8e030 8078049: Nashorn crashes when attempting to start TypeScript compiler
hannesw
parents: 29834
diff changeset
   178
                method.dynamicSet(property.getKey(), codegen.getCallSiteFlags(), false);
18852
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
   179
            }
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
   180
        }
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
   181
    }
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
   182
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
   183
    @Override
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
   184
    protected PropertyMap makeMap() {
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
   185
        assert propertyMap == null : "property map already initialized";
32781
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
   186
        final Class<? extends ScriptObject> clazz = getAllocatorClass();
29834
f678f348c947 8067215: Disable dual fields when not using optimistic types
hannesw
parents: 27307
diff changeset
   187
        propertyMap = new MapCreator<>(clazz, tuples).makeSpillMap(false, codegen.useDualFields());
18852
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
   188
        return propertyMap;
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
   189
    }
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   190
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   191
    @Override
24751
ccbd9cd3f720 8042118: Separate types from symbols
attila
parents: 24738
diff changeset
   192
    protected void loadValue(final Expression expr, final Type type) {
ccbd9cd3f720 8042118: Separate types from symbols
attila
parents: 24738
diff changeset
   193
        codegen.loadExpressionAsType(expr, type);
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 21449
diff changeset
   194
    }
32781
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
   195
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
   196
    @Override
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
   197
    protected Class<? extends ScriptObject> getAllocatorClass() {
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
   198
        return codegen.useDualFields() ? JD.class : JO.class;
d8f34ffbbc7a 8135190: Method code too large in Babel browser.js script
hannesw
parents: 30390
diff changeset
   199
    }
18852
604c1d681b6f 8017084: Use spill properties for large object literals
hannesw
parents:
diff changeset
   200
}