src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java

Print this page

        

*** 53,83 **** // property map for bound functions private static final PropertyMap boundfunctionmap$; // property map for non-strict, non-bound functions. private static final PropertyMap map$; - static PropertyMap getInitialMap() { - return map$; - } - - static PropertyMap getInitialAnonymousMap() { - return AnonymousFunction.getInitialMap(); - } - - static PropertyMap getInitialStrictMap() { - return strictmodemap$; - } - - static PropertyMap getInitialBoundMap() { - return boundfunctionmap$; - } - // Marker object for lazily initialized prototype object private static final Object LAZY_PROTOTYPE = new Object(); private ScriptFunctionImpl(final String name, final MethodHandle invokeHandle, final MethodHandle[] specs, final Global global) { ! super(name, invokeHandle, getInitialMap(), null, specs, ScriptFunctionData.IS_BUILTIN_CONSTRUCTOR); init(global); } /** * Constructor called by Nasgen generated code, no membercount, use the default map. --- 53,67 ---- // property map for bound functions private static final PropertyMap boundfunctionmap$; // property map for non-strict, non-bound functions. private static final PropertyMap map$; // Marker object for lazily initialized prototype object private static final Object LAZY_PROTOTYPE = new Object(); private ScriptFunctionImpl(final String name, final MethodHandle invokeHandle, final MethodHandle[] specs, final Global global) { ! super(name, invokeHandle, map$, null, specs, ScriptFunctionData.IS_BUILTIN_CONSTRUCTOR); init(global); } /** * Constructor called by Nasgen generated code, no membercount, use the default map.
*** 90,100 **** ScriptFunctionImpl(final String name, final MethodHandle invokeHandle, final MethodHandle[] specs) { this(name, invokeHandle, specs, Global.instance()); } private ScriptFunctionImpl(final String name, final MethodHandle invokeHandle, final PropertyMap map, final MethodHandle[] specs, final Global global) { ! super(name, invokeHandle, map.addAll(getInitialMap()), null, specs, ScriptFunctionData.IS_BUILTIN_CONSTRUCTOR); init(global); } /** * Constructor called by Nasgen generated code, no membercount, use the map passed as argument. --- 74,84 ---- ScriptFunctionImpl(final String name, final MethodHandle invokeHandle, final MethodHandle[] specs) { this(name, invokeHandle, specs, Global.instance()); } private ScriptFunctionImpl(final String name, final MethodHandle invokeHandle, final PropertyMap map, final MethodHandle[] specs, final Global global) { ! super(name, invokeHandle, map.addAll(map$), null, specs, ScriptFunctionData.IS_BUILTIN_CONSTRUCTOR); init(global); } /** * Constructor called by Nasgen generated code, no membercount, use the map passed as argument.
*** 108,118 **** ScriptFunctionImpl(final String name, final MethodHandle invokeHandle, final PropertyMap map, final MethodHandle[] specs) { this(name, invokeHandle, map, specs, Global.instance()); } private ScriptFunctionImpl(final String name, final MethodHandle methodHandle, final ScriptObject scope, final MethodHandle[] specs, final int flags, final Global global) { ! super(name, methodHandle, getMap(global, isStrict(flags)), scope, specs, flags); init(global); } /** * Constructor called by Global.newScriptFunction (runtime). --- 92,102 ---- ScriptFunctionImpl(final String name, final MethodHandle invokeHandle, final PropertyMap map, final MethodHandle[] specs) { this(name, invokeHandle, map, specs, Global.instance()); } private ScriptFunctionImpl(final String name, final MethodHandle methodHandle, final ScriptObject scope, final MethodHandle[] specs, final int flags, final Global global) { ! super(name, methodHandle, getMap(isStrict(flags)), scope, specs, flags); init(global); } /** * Constructor called by Global.newScriptFunction (runtime).
*** 126,136 **** ScriptFunctionImpl(final String name, final MethodHandle methodHandle, final ScriptObject scope, final MethodHandle[] specs, final int flags) { this(name, methodHandle, scope, specs, flags, Global.instance()); } private ScriptFunctionImpl(final RecompilableScriptFunctionData data, final ScriptObject scope, final Global global) { ! super(data, getMap(global, data.isStrict()), scope); init(global); } /** * Constructor called by (compiler) generated code for {@link ScriptObject}s. --- 110,120 ---- ScriptFunctionImpl(final String name, final MethodHandle methodHandle, final ScriptObject scope, final MethodHandle[] specs, final int flags) { this(name, methodHandle, scope, specs, flags, Global.instance()); } private ScriptFunctionImpl(final RecompilableScriptFunctionData data, final ScriptObject scope, final Global global) { ! super(data, getMap(data.isStrict()), scope); init(global); } /** * Constructor called by (compiler) generated code for {@link ScriptObject}s.
*** 146,156 **** * Only invoked internally from {@link BoundScriptFunctionImpl} constructor. * @param data the script function data for the bound function. * @param global the global object */ ScriptFunctionImpl(final ScriptFunctionData data, final Global global) { ! super(data, getInitialBoundMap(), null); init(global); } static { final ArrayList<Property> properties = new ArrayList<>(3); --- 130,140 ---- * Only invoked internally from {@link BoundScriptFunctionImpl} constructor. * @param data the script function data for the bound function. * @param global the global object */ ScriptFunctionImpl(final ScriptFunctionData data, final Global global) { ! super(data, boundfunctionmap$, null); init(global); } static { final ArrayList<Property> properties = new ArrayList<>(3);
*** 174,185 **** private static boolean isStrict(final int flags) { return (flags & ScriptFunctionData.IS_STRICT) != 0; } // Choose the map based on strict mode! ! private static PropertyMap getMap(final Global global, final boolean strict) { ! return strict ? getInitialStrictMap() : getInitialMap(); } private static PropertyMap createBoundFunctionMap(final PropertyMap strictModeMap) { // Bound function map is same as strict function map, but additionally lacks the "prototype" property, see // ECMAScript 5.1 section 15.3.4.5 --- 158,169 ---- private static boolean isStrict(final int flags) { return (flags & ScriptFunctionData.IS_STRICT) != 0; } // Choose the map based on strict mode! ! private static PropertyMap getMap(final boolean strict) { ! return strict ? strictmodemap$ : map$; } private static PropertyMap createBoundFunctionMap(final PropertyMap strictModeMap) { // Bound function map is same as strict function map, but additionally lacks the "prototype" property, see // ECMAScript 5.1 section 15.3.4.5
*** 189,204 **** // Instance of this class is used as global anonymous function which // serves as Function.prototype object. private static class AnonymousFunction extends ScriptFunctionImpl { private static final PropertyMap anonmap$ = PropertyMap.newMap(); - static PropertyMap getInitialMap() { - return anonmap$; - } - AnonymousFunction(final Global global) { ! super("", GlobalFunctions.ANONYMOUS, getInitialAnonymousMap(), null); } } static ScriptFunctionImpl newAnonymousFunction(final Global global) { return new AnonymousFunction(global); --- 173,184 ---- // Instance of this class is used as global anonymous function which // serves as Function.prototype object. private static class AnonymousFunction extends ScriptFunctionImpl { private static final PropertyMap anonmap$ = PropertyMap.newMap(); AnonymousFunction(final Global global) { ! super("", GlobalFunctions.ANONYMOUS, anonmap$, null); } } static ScriptFunctionImpl newAnonymousFunction(final Global global) { return new AnonymousFunction(global);