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

Print this page

        

@@ -53,31 +53,15 @@
     // 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);
+        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,11 +74,11 @@
     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);
+        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,11 +92,11 @@
     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);
+        super(name, methodHandle, getMap(isStrict(flags)), scope, specs, flags);
         init(global);
     }
 
     /**
      * Constructor called by Global.newScriptFunction (runtime).

@@ -126,11 +110,11 @@
     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);
+        super(data, getMap(data.isStrict()), scope);
         init(global);
     }
 
     /**
      * Constructor called by (compiler) generated code for {@link ScriptObject}s.

@@ -146,11 +130,11 @@
      * 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);
+        super(data, boundfunctionmap$, null);
         init(global);
     }
 
     static {
         final ArrayList<Property> properties = new ArrayList<>(3);

@@ -174,12 +158,12 @@
     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 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,16 +173,12 @@
     // 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);
+            super("", GlobalFunctions.ANONYMOUS, anonmap$, null);
         }
     }
 
     static ScriptFunctionImpl newAnonymousFunction(final Global global) {
         return new AnonymousFunction(global);