Mon, 17 Mar 2014 18:02:00 +0530
8037400: Remove getInitialMap getters and GlobalObject interface
Reviewed-by: lagergren, jlaskey, attila
1.1 --- a/make/build.xml Thu Mar 13 15:58:24 2014 +0530 1.2 +++ b/make/build.xml Mon Mar 17 18:02:00 2014 +0530 1.3 @@ -122,6 +122,7 @@ 1.4 <compilerarg value="-Xlint:unchecked"/> 1.5 <compilerarg value="-Xlint:deprecation"/> 1.6 <compilerarg value="-XDignore.symbol.file"/> 1.7 + <compilerarg value="-Xdiags:verbose"/> 1.8 </javac> 1.9 <copy todir="${build.classes.dir}/META-INF/services"> 1.10 <fileset dir="${meta.inf.dir}/services/"/> 1.11 @@ -240,6 +241,7 @@ 1.12 <compilerarg value="-J-Djava.ext.dirs="/> 1.13 <compilerarg value="-Xlint:unchecked"/> 1.14 <compilerarg value="-Xlint:deprecation"/> 1.15 + <compilerarg value="-Xdiags:verbose"/> 1.16 </javac> 1.17 1.18 <copy todir="${build.test.classes.dir}/META-INF/services">
2.1 --- a/src/jdk/nashorn/api/scripting/NashornScriptEngine.java Thu Mar 13 15:58:24 2014 +0530 2.2 +++ b/src/jdk/nashorn/api/scripting/NashornScriptEngine.java Mon Mar 17 18:02:00 2014 +0530 2.3 @@ -57,9 +57,9 @@ 2.4 import javax.script.ScriptEngineFactory; 2.5 import javax.script.ScriptException; 2.6 import javax.script.SimpleBindings; 2.7 +import jdk.nashorn.internal.objects.Global; 2.8 import jdk.nashorn.internal.runtime.Context; 2.9 import jdk.nashorn.internal.runtime.ErrorManager; 2.10 -import jdk.nashorn.internal.runtime.GlobalObject; 2.11 import jdk.nashorn.internal.runtime.Property; 2.12 import jdk.nashorn.internal.runtime.ScriptFunction; 2.13 import jdk.nashorn.internal.runtime.ScriptObject; 2.14 @@ -99,7 +99,7 @@ 2.15 private final boolean _global_per_engine; 2.16 // This is the initial default Nashorn global object. 2.17 // This is used as "shared" global if above option is true. 2.18 - private final ScriptObject global; 2.19 + private final Global global; 2.20 // initialized bit late to be made 'final'. 2.21 // Property object for "context" property of global object. 2.22 private volatile Property contextProperty; 2.23 @@ -264,7 +264,7 @@ 2.24 public Object __noSuchProperty__(final Object self, final ScriptContext ctxt, final String name) { 2.25 if (ctxt != null) { 2.26 final int scope = ctxt.getAttributesScope(name); 2.27 - final ScriptObject ctxtGlobal = getNashornGlobalFrom(ctxt); 2.28 + final Global ctxtGlobal = getNashornGlobalFrom(ctxt); 2.29 if (scope != -1) { 2.30 return ScriptObjectMirror.unwrap(ctxt.getAttribute(name, scope), ctxtGlobal); 2.31 } 2.32 @@ -317,7 +317,7 @@ 2.33 } 2.34 2.35 ScriptObject realSelf = null; 2.36 - ScriptObject realGlobal = null; 2.37 + Global realGlobal = null; 2.38 if(thiz == null) { 2.39 // making interface out of global functions 2.40 realSelf = realGlobal = getNashornGlobalFrom(context); 2.41 @@ -346,7 +346,7 @@ 2.42 } 2.43 2.44 try { 2.45 - final ScriptObject oldGlobal = Context.getGlobal(); 2.46 + final Global oldGlobal = Context.getGlobal(); 2.47 final boolean globalChanged = (oldGlobal != realGlobal); 2.48 try { 2.49 if (globalChanged) { 2.50 @@ -371,7 +371,7 @@ 2.51 } 2.52 2.53 // Retrieve nashorn Global object for a given ScriptContext object 2.54 - private ScriptObject getNashornGlobalFrom(final ScriptContext ctxt) { 2.55 + private Global getNashornGlobalFrom(final ScriptContext ctxt) { 2.56 if (_global_per_engine) { 2.57 // shared single global object for all ENGINE_SCOPE Bindings 2.58 return global; 2.59 @@ -380,18 +380,18 @@ 2.60 final Bindings bindings = ctxt.getBindings(ScriptContext.ENGINE_SCOPE); 2.61 // is this Nashorn's own Bindings implementation? 2.62 if (bindings instanceof ScriptObjectMirror) { 2.63 - final ScriptObject sobj = globalFromMirror((ScriptObjectMirror)bindings); 2.64 - if (sobj != null) { 2.65 - return sobj; 2.66 + final Global glob = globalFromMirror((ScriptObjectMirror)bindings); 2.67 + if (glob != null) { 2.68 + return glob; 2.69 } 2.70 } 2.71 2.72 // Arbitrary user Bindings implementation. Look for NASHORN_GLOBAL in it! 2.73 Object scope = bindings.get(NASHORN_GLOBAL); 2.74 if (scope instanceof ScriptObjectMirror) { 2.75 - final ScriptObject sobj = globalFromMirror((ScriptObjectMirror)scope); 2.76 - if (sobj != null) { 2.77 - return sobj; 2.78 + final Global glob = globalFromMirror((ScriptObjectMirror)scope); 2.79 + if (glob != null) { 2.80 + return glob; 2.81 } 2.82 } 2.83 2.84 @@ -399,14 +399,14 @@ 2.85 // Create new global instance mirror and associate with the Bindings. 2.86 final ScriptObjectMirror mirror = createGlobalMirror(ctxt); 2.87 bindings.put(NASHORN_GLOBAL, mirror); 2.88 - return mirror.getScriptObject(); 2.89 + return mirror.getHomeGlobal(); 2.90 } 2.91 2.92 // Retrieve nashorn Global object from a given ScriptObjectMirror 2.93 - private ScriptObject globalFromMirror(final ScriptObjectMirror mirror) { 2.94 + private Global globalFromMirror(final ScriptObjectMirror mirror) { 2.95 ScriptObject sobj = mirror.getScriptObject(); 2.96 - if (sobj instanceof GlobalObject && isOfContext(sobj, nashornContext)) { 2.97 - return sobj; 2.98 + if (sobj instanceof Global && isOfContext((Global)sobj, nashornContext)) { 2.99 + return (Global)sobj; 2.100 } 2.101 2.102 return null; 2.103 @@ -414,15 +414,15 @@ 2.104 2.105 // Create a new ScriptObjectMirror wrapping a newly created Nashorn Global object 2.106 private ScriptObjectMirror createGlobalMirror(final ScriptContext ctxt) { 2.107 - final ScriptObject newGlobal = createNashornGlobal(ctxt); 2.108 + final Global newGlobal = createNashornGlobal(ctxt); 2.109 return new ScriptObjectMirror(newGlobal, newGlobal); 2.110 } 2.111 2.112 // Create a new Nashorn Global object 2.113 - private ScriptObject createNashornGlobal(final ScriptContext ctxt) { 2.114 - final ScriptObject newGlobal = AccessController.doPrivileged(new PrivilegedAction<ScriptObject>() { 2.115 + private Global createNashornGlobal(final ScriptContext ctxt) { 2.116 + final Global newGlobal = AccessController.doPrivileged(new PrivilegedAction<Global>() { 2.117 @Override 2.118 - public ScriptObject run() { 2.119 + public Global run() { 2.120 try { 2.121 return nashornContext.newGlobal(); 2.122 } catch (final RuntimeException e) { 2.123 @@ -460,7 +460,7 @@ 2.124 } 2.125 2.126 // scripts should see "context" and "engine" as variables in the given global object 2.127 - private void setContextVariables(final ScriptObject ctxtGlobal, final ScriptContext ctxt) { 2.128 + private void setContextVariables(final Global ctxtGlobal, final ScriptContext ctxt) { 2.129 // set "context" global variable via contextProperty - because this 2.130 // property is non-writable 2.131 contextProperty.setObjectValue(ctxtGlobal, ctxtGlobal, ctxt, false); 2.132 @@ -470,7 +470,7 @@ 2.133 } 2.134 // if no arguments passed, expose it 2.135 if (! (args instanceof ScriptObject)) { 2.136 - args = ((GlobalObject)ctxtGlobal).wrapAsObject(args); 2.137 + args = ctxtGlobal.wrapAsObject(args); 2.138 ctxtGlobal.set("arguments", args, false); 2.139 } 2.140 } 2.141 @@ -478,7 +478,7 @@ 2.142 private Object invokeImpl(final Object selfObject, final String name, final Object... args) throws ScriptException, NoSuchMethodException { 2.143 name.getClass(); // null check 2.144 2.145 - ScriptObject invokeGlobal = null; 2.146 + Global invokeGlobal = null; 2.147 ScriptObjectMirror selfMirror = null; 2.148 if (selfObject instanceof ScriptObjectMirror) { 2.149 selfMirror = (ScriptObjectMirror)selfObject; 2.150 @@ -489,7 +489,7 @@ 2.151 } else if (selfObject instanceof ScriptObject) { 2.152 // invokeMethod called from script code - in which case we may get 'naked' ScriptObject 2.153 // Wrap it with oldGlobal to make a ScriptObjectMirror for the same. 2.154 - final ScriptObject oldGlobal = Context.getGlobal(); 2.155 + final Global oldGlobal = Context.getGlobal(); 2.156 invokeGlobal = oldGlobal; 2.157 if (oldGlobal == null) { 2.158 throw new IllegalArgumentException(getMessage("no.current.nashorn.global")); 2.159 @@ -502,7 +502,7 @@ 2.160 selfMirror = (ScriptObjectMirror)ScriptObjectMirror.wrap(selfObject, oldGlobal); 2.161 } else if (selfObject == null) { 2.162 // selfObject is null => global function call 2.163 - final ScriptObject ctxtGlobal = getNashornGlobalFrom(context); 2.164 + final Global ctxtGlobal = getNashornGlobalFrom(context); 2.165 invokeGlobal = ctxtGlobal; 2.166 selfMirror = (ScriptObjectMirror)ScriptObjectMirror.wrap(ctxtGlobal, ctxtGlobal); 2.167 } 2.168 @@ -532,11 +532,11 @@ 2.169 return evalImpl(script, ctxt, getNashornGlobalFrom(ctxt)); 2.170 } 2.171 2.172 - private Object evalImpl(final ScriptFunction script, final ScriptContext ctxt, final ScriptObject ctxtGlobal) throws ScriptException { 2.173 + private Object evalImpl(final ScriptFunction script, final ScriptContext ctxt, final Global ctxtGlobal) throws ScriptException { 2.174 if (script == null) { 2.175 return null; 2.176 } 2.177 - final ScriptObject oldGlobal = Context.getGlobal(); 2.178 + final Global oldGlobal = Context.getGlobal(); 2.179 final boolean globalChanged = (oldGlobal != ctxtGlobal); 2.180 try { 2.181 if (globalChanged) { 2.182 @@ -558,7 +558,7 @@ 2.183 } 2.184 } 2.185 2.186 - private static void throwAsScriptException(final Exception e, final ScriptObject global) throws ScriptException { 2.187 + private static void throwAsScriptException(final Exception e, final Global global) throws ScriptException { 2.188 if (e instanceof ScriptException) { 2.189 throw (ScriptException)e; 2.190 } else if (e instanceof NashornException) { 2.191 @@ -582,7 +582,7 @@ 2.192 return new CompiledScript() { 2.193 @Override 2.194 public Object eval(final ScriptContext ctxt) throws ScriptException { 2.195 - final ScriptObject globalObject = getNashornGlobalFrom(ctxt); 2.196 + final Global globalObject = getNashornGlobalFrom(ctxt); 2.197 // Are we running the script in the correct global? 2.198 if (func.getScope() == globalObject) { 2.199 return evalImpl(func, ctxt, globalObject); 2.200 @@ -602,8 +602,8 @@ 2.201 return compileImpl(source, getNashornGlobalFrom(ctxt)); 2.202 } 2.203 2.204 - private ScriptFunction compileImpl(final Source source, final ScriptObject newGlobal) throws ScriptException { 2.205 - final ScriptObject oldGlobal = Context.getGlobal(); 2.206 + private ScriptFunction compileImpl(final Source source, final Global newGlobal) throws ScriptException { 2.207 + final Global oldGlobal = Context.getGlobal(); 2.208 final boolean globalChanged = (oldGlobal != newGlobal); 2.209 try { 2.210 if (globalChanged) { 2.211 @@ -641,8 +641,7 @@ 2.212 return true; 2.213 } 2.214 2.215 - private static boolean isOfContext(final ScriptObject global, final Context context) { 2.216 - assert global instanceof GlobalObject: "Not a Global object"; 2.217 - return ((GlobalObject)global).isOfContext(context); 2.218 + private static boolean isOfContext(final Global global, final Context context) { 2.219 + return global.isOfContext(context); 2.220 } 2.221 }
3.1 --- a/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java Thu Mar 13 15:58:24 2014 +0530 3.2 +++ b/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java Mon Mar 17 18:02:00 2014 +0530 3.3 @@ -42,10 +42,10 @@ 3.4 import java.util.Set; 3.5 import java.util.concurrent.Callable; 3.6 import javax.script.Bindings; 3.7 +import jdk.nashorn.internal.objects.Global; 3.8 import jdk.nashorn.internal.runtime.arrays.ArrayData; 3.9 import jdk.nashorn.internal.runtime.ConsString; 3.10 import jdk.nashorn.internal.runtime.Context; 3.11 -import jdk.nashorn.internal.runtime.GlobalObject; 3.12 import jdk.nashorn.internal.runtime.JSType; 3.13 import jdk.nashorn.internal.runtime.ScriptFunction; 3.14 import jdk.nashorn.internal.runtime.ScriptObject; 3.15 @@ -64,7 +64,7 @@ 3.16 private static final AccessControlContext GET_CONTEXT_ACC_CTXT = getContextAccCtxt(); 3.17 3.18 private final ScriptObject sobj; 3.19 - private final ScriptObject global; 3.20 + private final Global global; 3.21 private final boolean strict; 3.22 3.23 @Override 3.24 @@ -95,7 +95,7 @@ 3.25 3.26 @Override 3.27 public Object call(final Object thiz, final Object... args) { 3.28 - final ScriptObject oldGlobal = Context.getGlobal(); 3.29 + final Global oldGlobal = Context.getGlobal(); 3.30 final boolean globalChanged = (oldGlobal != global); 3.31 3.32 try { 3.33 @@ -125,7 +125,7 @@ 3.34 3.35 @Override 3.36 public Object newObject(final Object... args) { 3.37 - final ScriptObject oldGlobal = Context.getGlobal(); 3.38 + final Global oldGlobal = Context.getGlobal(); 3.39 final boolean globalChanged = (oldGlobal != global); 3.40 3.41 try { 3.42 @@ -171,7 +171,7 @@ 3.43 3.44 public Object callMember(final String functionName, final Object... args) { 3.45 functionName.getClass(); // null check 3.46 - final ScriptObject oldGlobal = Context.getGlobal(); 3.47 + final Global oldGlobal = Context.getGlobal(); 3.48 final boolean globalChanged = (oldGlobal != global); 3.49 3.50 try { 3.51 @@ -642,7 +642,7 @@ 3.52 */ 3.53 public static Object wrap(final Object obj, final Object homeGlobal) { 3.54 if(obj instanceof ScriptObject) { 3.55 - return homeGlobal instanceof ScriptObject ? new ScriptObjectMirror((ScriptObject)obj, (ScriptObject)homeGlobal) : obj; 3.56 + return homeGlobal instanceof Global ? new ScriptObjectMirror((ScriptObject)obj, (Global)homeGlobal) : obj; 3.57 } 3.58 if(obj instanceof ConsString) { 3.59 return obj.toString(); 3.60 @@ -710,13 +710,13 @@ 3.61 3.62 // package-privates below this. 3.63 3.64 - ScriptObjectMirror(final ScriptObject sobj, final ScriptObject global) { 3.65 + ScriptObjectMirror(final ScriptObject sobj, final Global global) { 3.66 assert sobj != null : "ScriptObjectMirror on null!"; 3.67 - assert global instanceof GlobalObject : "global is not a GlobalObject"; 3.68 + assert global != null : "home Global is null"; 3.69 3.70 this.sobj = sobj; 3.71 this.global = global; 3.72 - this.strict = ((GlobalObject)global).isStrictContext(); 3.73 + this.strict = global.isStrictContext(); 3.74 } 3.75 3.76 // accessors for script engine 3.77 @@ -724,7 +724,7 @@ 3.78 return sobj; 3.79 } 3.80 3.81 - ScriptObject getHomeGlobal() { 3.82 + Global getHomeGlobal() { 3.83 return global; 3.84 } 3.85 3.86 @@ -734,7 +734,7 @@ 3.87 3.88 // internals only below this. 3.89 private <V> V inGlobal(final Callable<V> callable) { 3.90 - final ScriptObject oldGlobal = Context.getGlobal(); 3.91 + final Global oldGlobal = Context.getGlobal(); 3.92 final boolean globalChanged = (oldGlobal != global); 3.93 if (globalChanged) { 3.94 Context.setGlobal(global);
4.1 --- a/src/jdk/nashorn/internal/objects/AccessorPropertyDescriptor.java Thu Mar 13 15:58:24 2014 +0530 4.2 +++ b/src/jdk/nashorn/internal/objects/AccessorPropertyDescriptor.java Mon Mar 17 18:02:00 2014 +0530 4.3 @@ -67,12 +67,8 @@ 4.4 // initialized by nasgen 4.5 private static PropertyMap $nasgenmap$; 4.6 4.7 - static PropertyMap getInitialMap() { 4.8 - return $nasgenmap$; 4.9 - } 4.10 - 4.11 AccessorPropertyDescriptor(final boolean configurable, final boolean enumerable, final Object get, final Object set, final Global global) { 4.12 - super(global.getObjectPrototype(), getInitialMap()); 4.13 + super(global.getObjectPrototype(), $nasgenmap$); 4.14 this.configurable = configurable; 4.15 this.enumerable = enumerable; 4.16 this.get = get;
5.1 --- a/src/jdk/nashorn/internal/objects/ArrayBufferView.java Thu Mar 13 15:58:24 2014 +0530 5.2 +++ b/src/jdk/nashorn/internal/objects/ArrayBufferView.java Mon Mar 17 18:02:00 2014 +0530 5.3 @@ -42,12 +42,8 @@ 5.4 // initialized by nasgen 5.5 private static PropertyMap $nasgenmap$; 5.6 5.7 - static PropertyMap getInitialMap() { 5.8 - return $nasgenmap$; 5.9 - } 5.10 - 5.11 private ArrayBufferView(final NativeArrayBuffer buffer, final int byteOffset, final int elementLength, final Global global) { 5.12 - super(getInitialMap()); 5.13 + super($nasgenmap$); 5.14 checkConstructorArgs(buffer, byteOffset, elementLength); 5.15 this.setProto(getPrototype(global)); 5.16 this.setArray(factory().createArrayData(buffer, byteOffset, elementLength));
6.1 --- a/src/jdk/nashorn/internal/objects/DataPropertyDescriptor.java Thu Mar 13 15:58:24 2014 +0530 6.2 +++ b/src/jdk/nashorn/internal/objects/DataPropertyDescriptor.java Mon Mar 17 18:02:00 2014 +0530 6.3 @@ -64,12 +64,8 @@ 6.4 // initialized by nasgen 6.5 private static PropertyMap $nasgenmap$; 6.6 6.7 - static PropertyMap getInitialMap() { 6.8 - return $nasgenmap$; 6.9 - } 6.10 - 6.11 DataPropertyDescriptor(final boolean configurable, final boolean enumerable, final boolean writable, final Object value, final Global global) { 6.12 - super(global.getObjectPrototype(), getInitialMap()); 6.13 + super(global.getObjectPrototype(), $nasgenmap$); 6.14 this.configurable = configurable; 6.15 this.enumerable = enumerable; 6.16 this.writable = writable;
7.1 --- a/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java Thu Mar 13 15:58:24 2014 +0530 7.2 +++ b/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java Mon Mar 17 18:02:00 2014 +0530 7.3 @@ -55,12 +55,8 @@ 7.4 // initialized by nasgen 7.5 private static PropertyMap $nasgenmap$; 7.6 7.7 - static PropertyMap getInitialMap() { 7.8 - return $nasgenmap$; 7.9 - } 7.10 - 7.11 GenericPropertyDescriptor(final boolean configurable, final boolean enumerable, final Global global) { 7.12 - super(global.getObjectPrototype(), getInitialMap()); 7.13 + super(global.getObjectPrototype(), $nasgenmap$); 7.14 this.configurable = configurable; 7.15 this.enumerable = enumerable; 7.16 }
8.1 --- a/src/jdk/nashorn/internal/objects/Global.java Thu Mar 13 15:58:24 2014 +0530 8.2 +++ b/src/jdk/nashorn/internal/objects/Global.java Mon Mar 17 18:02:00 2014 +0530 8.3 @@ -48,7 +48,6 @@ 8.4 import jdk.nashorn.internal.runtime.ConsString; 8.5 import jdk.nashorn.internal.runtime.Context; 8.6 import jdk.nashorn.internal.runtime.GlobalFunctions; 8.7 -import jdk.nashorn.internal.runtime.GlobalObject; 8.8 import jdk.nashorn.internal.runtime.JSType; 8.9 import jdk.nashorn.internal.runtime.NativeJavaPackage; 8.10 import jdk.nashorn.internal.runtime.PropertyDescriptor; 8.11 @@ -70,7 +69,7 @@ 8.12 * Representation of global scope. 8.13 */ 8.14 @ScriptClass("Global") 8.15 -public final class Global extends ScriptObject implements GlobalObject, Scope { 8.16 +public final class Global extends ScriptObject implements Scope { 8.17 private final InvokeByName TO_STRING = new InvokeByName("toString", ScriptObject.class); 8.18 private final InvokeByName VALUE_OF = new InvokeByName("valueOf", ScriptObject.class); 8.19 8.20 @@ -433,11 +432,9 @@ 8.21 * @return the global singleton 8.22 */ 8.23 public static Global instance() { 8.24 - ScriptObject global = Context.getGlobal(); 8.25 - if (! (global instanceof Global)) { 8.26 - throw new IllegalStateException("no current global instance"); 8.27 - } 8.28 - return (Global)global; 8.29 + Global global = Context.getGlobal(); 8.30 + global.getClass(); // null check 8.31 + return global; 8.32 } 8.33 8.34 /** 8.35 @@ -458,19 +455,30 @@ 8.36 return instance().getContext(); 8.37 } 8.38 8.39 - // GlobalObject interface implementation 8.40 + // Runtime interface to Global 8.41 8.42 - @Override 8.43 + /** 8.44 + * Is this global of the given Context? 8.45 + * @param ctxt the context 8.46 + * @return true if this global belongs to the given Context 8.47 + */ 8.48 public boolean isOfContext(final Context ctxt) { 8.49 return this.context == ctxt; 8.50 } 8.51 8.52 - @Override 8.53 + /** 8.54 + * Does this global belong to a strict Context? 8.55 + * @return true if this global belongs to a strict Context 8.56 + */ 8.57 public boolean isStrictContext() { 8.58 return context.getEnv()._strict; 8.59 } 8.60 8.61 - @Override 8.62 + /** 8.63 + * Initialize standard builtin objects like "Object", "Array", "Function" etc. 8.64 + * as well as our extension builtin objects like "Java", "JSAdapter" as properties 8.65 + * of the global scope object. 8.66 + */ 8.67 public void initBuiltinObjects() { 8.68 if (this.builtinObject != null) { 8.69 // already initialized, just return 8.70 @@ -480,12 +488,26 @@ 8.71 init(); 8.72 } 8.73 8.74 - @Override 8.75 + /** 8.76 + * Create a new ScriptFunction object 8.77 + * 8.78 + * @param name function name 8.79 + * @param handle invocation handle for function 8.80 + * @param scope the scope 8.81 + * @param strict are we in strict mode 8.82 + * 8.83 + * @return new script function 8.84 + */ 8.85 public ScriptFunction newScriptFunction(final String name, final MethodHandle handle, final ScriptObject scope, final boolean strict) { 8.86 return new ScriptFunctionImpl(name, handle, scope, null, strict ? ScriptFunctionData.IS_STRICT_CONSTRUCTOR : ScriptFunctionData.IS_CONSTRUCTOR); 8.87 } 8.88 8.89 - @Override 8.90 + /** 8.91 + * Wrap a Java object as corresponding script object 8.92 + * 8.93 + * @param obj object to wrap 8.94 + * @return wrapped object 8.95 + */ 8.96 public Object wrapAsObject(final Object obj) { 8.97 if (obj instanceof Boolean) { 8.98 return new NativeBoolean((Boolean)obj, this); 8.99 @@ -507,7 +529,14 @@ 8.100 } 8.101 } 8.102 8.103 - @Override 8.104 + /** 8.105 + * Lookup helper for JS primitive types 8.106 + * 8.107 + * @param request the link request for the dynamic call site. 8.108 + * @param self self reference 8.109 + * 8.110 + * @return guarded invocation 8.111 + */ 8.112 public GuardedInvocation primitiveLookup(final LinkRequest request, final Object self) { 8.113 if (self instanceof String || self instanceof ConsString) { 8.114 return NativeString.lookupPrimitive(request, self); 8.115 @@ -519,12 +548,23 @@ 8.116 throw new IllegalArgumentException("Unsupported primitive: " + self); 8.117 } 8.118 8.119 - @Override 8.120 + /** 8.121 + * Create a new empty script object 8.122 + * 8.123 + * @return the new ScriptObject 8.124 + */ 8.125 public ScriptObject newObject() { 8.126 return new JO(getObjectPrototype(), JO.getInitialMap()); 8.127 } 8.128 8.129 - @Override 8.130 + /** 8.131 + * Default value of given type 8.132 + * 8.133 + * @param sobj script object 8.134 + * @param typeHint type hint 8.135 + * 8.136 + * @return default value 8.137 + */ 8.138 public Object getDefaultValue(final ScriptObject sobj, final Class<?> typeHint) { 8.139 // When the [[DefaultValue]] internal method of O is called with no hint, 8.140 // then it behaves as if the hint were Number, unless O is a Date object 8.141 @@ -584,7 +624,12 @@ 8.142 return UNDEFINED; 8.143 } 8.144 8.145 - @Override 8.146 + /** 8.147 + * Is the given ScriptObject an ECMAScript Error object? 8.148 + * 8.149 + * @param sobj the object being checked 8.150 + * @return true if sobj is an Error object 8.151 + */ 8.152 public boolean isError(final ScriptObject sobj) { 8.153 final ScriptObject errorProto = getErrorPrototype(); 8.154 ScriptObject proto = sobj.getProto(); 8.155 @@ -597,52 +642,108 @@ 8.156 return false; 8.157 } 8.158 8.159 - @Override 8.160 + /** 8.161 + * Create a new ECMAScript Error object. 8.162 + * 8.163 + * @param msg error message 8.164 + * @return newly created Error object 8.165 + */ 8.166 public ScriptObject newError(final String msg) { 8.167 return new NativeError(msg, this); 8.168 } 8.169 8.170 - @Override 8.171 + /** 8.172 + * Create a new ECMAScript EvalError object. 8.173 + * 8.174 + * @param msg error message 8.175 + * @return newly created EvalError object 8.176 + */ 8.177 public ScriptObject newEvalError(final String msg) { 8.178 return new NativeEvalError(msg, this); 8.179 } 8.180 8.181 - @Override 8.182 + /** 8.183 + * Create a new ECMAScript RangeError object. 8.184 + * 8.185 + * @param msg error message 8.186 + * @return newly created RangeError object 8.187 + */ 8.188 public ScriptObject newRangeError(final String msg) { 8.189 return new NativeRangeError(msg, this); 8.190 } 8.191 8.192 - @Override 8.193 + /** 8.194 + * Create a new ECMAScript ReferenceError object. 8.195 + * 8.196 + * @param msg error message 8.197 + * @return newly created ReferenceError object 8.198 + */ 8.199 public ScriptObject newReferenceError(final String msg) { 8.200 return new NativeReferenceError(msg, this); 8.201 } 8.202 8.203 - @Override 8.204 + /** 8.205 + * Create a new ECMAScript SyntaxError object. 8.206 + * 8.207 + * @param msg error message 8.208 + * @return newly created SyntaxError object 8.209 + */ 8.210 public ScriptObject newSyntaxError(final String msg) { 8.211 return new NativeSyntaxError(msg, this); 8.212 } 8.213 8.214 - @Override 8.215 + /** 8.216 + * Create a new ECMAScript TypeError object. 8.217 + * 8.218 + * @param msg error message 8.219 + * @return newly created TypeError object 8.220 + */ 8.221 public ScriptObject newTypeError(final String msg) { 8.222 return new NativeTypeError(msg, this); 8.223 } 8.224 8.225 - @Override 8.226 + /** 8.227 + * Create a new ECMAScript URIError object. 8.228 + * 8.229 + * @param msg error message 8.230 + * @return newly created URIError object 8.231 + */ 8.232 public ScriptObject newURIError(final String msg) { 8.233 return new NativeURIError(msg, this); 8.234 } 8.235 8.236 - @Override 8.237 + /** 8.238 + * Create a new ECMAScript GenericDescriptor object. 8.239 + * 8.240 + * @param configurable is the property configurable? 8.241 + * @param enumerable is the property enumerable? 8.242 + * @return newly created GenericDescriptor object 8.243 + */ 8.244 public PropertyDescriptor newGenericDescriptor(final boolean configurable, final boolean enumerable) { 8.245 return new GenericPropertyDescriptor(configurable, enumerable, this); 8.246 } 8.247 8.248 - @Override 8.249 + /** 8.250 + * Create a new ECMAScript DatePropertyDescriptor object. 8.251 + * 8.252 + * @param value of the data property 8.253 + * @param configurable is the property configurable? 8.254 + * @param enumerable is the property enumerable? 8.255 + * @return newly created DataPropertyDescriptor object 8.256 + */ 8.257 public PropertyDescriptor newDataDescriptor(final Object value, final boolean configurable, final boolean enumerable, final boolean writable) { 8.258 return new DataPropertyDescriptor(configurable, enumerable, writable, value, this); 8.259 } 8.260 8.261 - @Override 8.262 + /** 8.263 + * Create a new ECMAScript AccessorPropertyDescriptor object. 8.264 + * 8.265 + * @param get getter function of the user accessor property 8.266 + * @param set setter function of the user accessor property 8.267 + * @param configurable is the property configurable? 8.268 + * @param enumerable is the property enumerable? 8.269 + * @return newly created AccessorPropertyDescriptor object 8.270 + */ 8.271 public PropertyDescriptor newAccessorDescriptor(final Object get, final Object set, final boolean configurable, final boolean enumerable) { 8.272 final AccessorPropertyDescriptor desc = new AccessorPropertyDescriptor(configurable, enumerable, get == null ? UNDEFINED : get, set == null ? UNDEFINED : set, this); 8.273 8.274 @@ -675,14 +776,25 @@ 8.275 8.276 private final Map<Object, InvokeByName> namedInvokers = new ConcurrentHashMap<>(); 8.277 8.278 - @Override 8.279 + 8.280 + /** 8.281 + * Get cached InvokeByName object for the given key 8.282 + * @param key key to be associated with InvokeByName object 8.283 + * @param creator if InvokeByName is absent 'creator' is called to make one (lazy init) 8.284 + * @return InvokeByName object associated with the key. 8.285 + */ 8.286 public InvokeByName getInvokeByName(final Object key, final Callable<InvokeByName> creator) { 8.287 return getLazilyCreatedValue(key, creator, namedInvokers); 8.288 } 8.289 8.290 private final Map<Object, MethodHandle> dynamicInvokers = new ConcurrentHashMap<>(); 8.291 8.292 - @Override 8.293 + /** 8.294 + * Get cached dynamic method handle for the given key 8.295 + * @param key key to be associated with dynamic method handle 8.296 + * @param creator if method handle is absent 'creator' is called to make one (lazy init) 8.297 + * @return dynamic method handle associated with the key. 8.298 + */ 8.299 public MethodHandle getDynamicInvoker(final Object key, final Callable<MethodHandle> creator) { 8.300 return getLazilyCreatedValue(key, creator, dynamicInvokers); 8.301 }
9.1 --- a/src/jdk/nashorn/internal/objects/NativeArray.java Thu Mar 13 15:58:24 2014 +0530 9.2 +++ b/src/jdk/nashorn/internal/objects/NativeArray.java Mon Mar 17 18:02:00 2014 +0530 9.3 @@ -156,10 +156,6 @@ 9.4 // initialized by nasgen 9.5 private static PropertyMap $nasgenmap$; 9.6 9.7 - static PropertyMap getInitialMap() { 9.8 - return $nasgenmap$; 9.9 - } 9.10 - 9.11 /* 9.12 * Constructors. 9.13 */ 9.14 @@ -208,7 +204,7 @@ 9.15 } 9.16 9.17 NativeArray(final ArrayData arrayData, final Global global) { 9.18 - super(global.getArrayPrototype(), getInitialMap()); 9.19 + super(global.getArrayPrototype(), $nasgenmap$); 9.20 this.setArray(arrayData); 9.21 this.setIsArray(); 9.22 }
10.1 --- a/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java Thu Mar 13 15:58:24 2014 +0530 10.2 +++ b/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java Mon Mar 17 18:02:00 2014 +0530 10.3 @@ -44,10 +44,6 @@ 10.4 // initialized by nasgen 10.5 private static PropertyMap $nasgenmap$; 10.6 10.7 - static PropertyMap getInitialMap() { 10.8 - return $nasgenmap$; 10.9 - } 10.10 - 10.11 @Constructor(arity = 1) 10.12 public static Object constructor(final boolean newObj, final Object self, final Object... args) { 10.13 if (args.length == 0) { 10.14 @@ -58,7 +54,7 @@ 10.15 } 10.16 10.17 protected NativeArrayBuffer(final byte[] byteArray, final Global global) { 10.18 - super(global.getArrayBufferPrototype(), getInitialMap()); 10.19 + super(global.getArrayBufferPrototype(), $nasgenmap$); 10.20 this.buffer = byteArray; 10.21 } 10.22
11.1 --- a/src/jdk/nashorn/internal/objects/NativeBoolean.java Thu Mar 13 15:58:24 2014 +0530 11.2 +++ b/src/jdk/nashorn/internal/objects/NativeBoolean.java Mon Mar 17 18:02:00 2014 +0530 11.3 @@ -59,17 +59,13 @@ 11.4 // initialized by nasgen 11.5 private static PropertyMap $nasgenmap$; 11.6 11.7 - static PropertyMap getInitialMap() { 11.8 - return $nasgenmap$; 11.9 - } 11.10 - 11.11 private NativeBoolean(final boolean value, final ScriptObject proto, final PropertyMap map) { 11.12 super(proto, map); 11.13 this.value = value; 11.14 } 11.15 11.16 NativeBoolean(final boolean flag, final Global global) { 11.17 - this(flag, global.getBooleanPrototype(), getInitialMap()); 11.18 + this(flag, global.getBooleanPrototype(), $nasgenmap$); 11.19 } 11.20 11.21 NativeBoolean(final boolean flag) {
12.1 --- a/src/jdk/nashorn/internal/objects/NativeDate.java Thu Mar 13 15:58:24 2014 +0530 12.2 +++ b/src/jdk/nashorn/internal/objects/NativeDate.java Mon Mar 17 18:02:00 2014 +0530 12.3 @@ -114,10 +114,6 @@ 12.4 // initialized by nasgen 12.5 private static PropertyMap $nasgenmap$; 12.6 12.7 - static PropertyMap getInitialMap() { 12.8 - return $nasgenmap$; 12.9 - } 12.10 - 12.11 private NativeDate(final double time, final ScriptObject proto, final PropertyMap map) { 12.12 super(proto, map); 12.13 final ScriptEnvironment env = Global.getEnv(); 12.14 @@ -127,7 +123,7 @@ 12.15 } 12.16 12.17 NativeDate(final double time, final Global global) { 12.18 - this(time, global.getDatePrototype(), getInitialMap()); 12.19 + this(time, global.getDatePrototype(), $nasgenmap$); 12.20 } 12.21 12.22 private NativeDate (final double time) {
13.1 --- a/src/jdk/nashorn/internal/objects/NativeError.java Thu Mar 13 15:58:24 2014 +0530 13.2 +++ b/src/jdk/nashorn/internal/objects/NativeError.java Mon Mar 17 18:02:00 2014 +0530 13.3 @@ -92,10 +92,6 @@ 13.4 // initialized by nasgen 13.5 private static PropertyMap $nasgenmap$; 13.6 13.7 - static PropertyMap getInitialMap() { 13.8 - return $nasgenmap$; 13.9 - } 13.10 - 13.11 @SuppressWarnings("LeakingThisInConstructor") 13.12 private NativeError(final Object msg, final ScriptObject proto, final PropertyMap map) { 13.13 super(proto, map); 13.14 @@ -108,7 +104,7 @@ 13.15 } 13.16 13.17 NativeError(final Object msg, final Global global) { 13.18 - this(msg, global.getErrorPrototype(), getInitialMap()); 13.19 + this(msg, global.getErrorPrototype(), $nasgenmap$); 13.20 } 13.21 13.22 private NativeError(final Object msg) {
14.1 --- a/src/jdk/nashorn/internal/objects/NativeEvalError.java Thu Mar 13 15:58:24 2014 +0530 14.2 +++ b/src/jdk/nashorn/internal/objects/NativeEvalError.java Mon Mar 17 18:02:00 2014 +0530 14.3 @@ -62,10 +62,6 @@ 14.4 // initialized by nasgen 14.5 private static PropertyMap $nasgenmap$; 14.6 14.7 - static PropertyMap getInitialMap() { 14.8 - return $nasgenmap$; 14.9 - } 14.10 - 14.11 @SuppressWarnings("LeakingThisInConstructor") 14.12 private NativeEvalError(final Object msg, final ScriptObject proto, final PropertyMap map) { 14.13 super(proto, map); 14.14 @@ -78,7 +74,7 @@ 14.15 } 14.16 14.17 NativeEvalError(final Object msg, final Global global) { 14.18 - this(msg, global.getEvalErrorPrototype(), getInitialMap()); 14.19 + this(msg, global.getEvalErrorPrototype(), $nasgenmap$); 14.20 } 14.21 14.22 private NativeEvalError(final Object msg) {
15.1 --- a/src/jdk/nashorn/internal/objects/NativeJSAdapter.java Thu Mar 13 15:58:24 2014 +0530 15.2 +++ b/src/jdk/nashorn/internal/objects/NativeJSAdapter.java Mon Mar 17 18:02:00 2014 +0530 15.3 @@ -146,10 +146,6 @@ 15.4 // initialized by nasgen 15.5 private static PropertyMap $nasgenmap$; 15.6 15.7 - static PropertyMap getInitialMap() { 15.8 - return $nasgenmap$; 15.9 - } 15.10 - 15.11 NativeJSAdapter(final Object overrides, final ScriptObject adaptee, final ScriptObject proto, final PropertyMap map) { 15.12 super(proto, map); 15.13 this.adaptee = wrapAdaptee(adaptee); 15.14 @@ -577,7 +573,7 @@ 15.15 proto = global.getJSAdapterPrototype(); 15.16 } 15.17 15.18 - return new NativeJSAdapter(overrides, (ScriptObject)adaptee, (ScriptObject)proto, getInitialMap()); 15.19 + return new NativeJSAdapter(overrides, (ScriptObject)adaptee, (ScriptObject)proto, $nasgenmap$); 15.20 } 15.21 15.22 @Override
16.1 --- a/src/jdk/nashorn/internal/objects/NativeJavaImporter.java Thu Mar 13 15:58:24 2014 +0530 16.2 +++ b/src/jdk/nashorn/internal/objects/NativeJavaImporter.java Mon Mar 17 18:02:00 2014 +0530 16.3 @@ -60,17 +60,13 @@ 16.4 // initialized by nasgen 16.5 private static PropertyMap $nasgenmap$; 16.6 16.7 - static PropertyMap getInitialMap() { 16.8 - return $nasgenmap$; 16.9 - } 16.10 - 16.11 private NativeJavaImporter(final Object[] args, final ScriptObject proto, final PropertyMap map) { 16.12 super(proto, map); 16.13 this.args = args; 16.14 } 16.15 16.16 private NativeJavaImporter(final Object[] args, final Global global) { 16.17 - this(args, global.getJavaImporterPrototype(), getInitialMap()); 16.18 + this(args, global.getJavaImporterPrototype(), $nasgenmap$); 16.19 } 16.20 16.21 private NativeJavaImporter(final Object[] args) {
17.1 --- a/src/jdk/nashorn/internal/objects/NativeNumber.java Thu Mar 13 15:58:24 2014 +0530 17.2 +++ b/src/jdk/nashorn/internal/objects/NativeNumber.java Mon Mar 17 18:02:00 2014 +0530 17.3 @@ -90,10 +90,6 @@ 17.4 // initialized by nasgen 17.5 private static PropertyMap $nasgenmap$; 17.6 17.7 - static PropertyMap getInitialMap() { 17.8 - return $nasgenmap$; 17.9 - } 17.10 - 17.11 private NativeNumber(final double value, final ScriptObject proto, final PropertyMap map) { 17.12 super(proto, map); 17.13 this.value = value; 17.14 @@ -102,7 +98,7 @@ 17.15 } 17.16 17.17 NativeNumber(final double value, final Global global) { 17.18 - this(value, global.getNumberPrototype(), getInitialMap()); 17.19 + this(value, global.getNumberPrototype(), $nasgenmap$); 17.20 } 17.21 17.22 private NativeNumber(final double value) {
18.1 --- a/src/jdk/nashorn/internal/objects/NativeRangeError.java Thu Mar 13 15:58:24 2014 +0530 18.2 +++ b/src/jdk/nashorn/internal/objects/NativeRangeError.java Mon Mar 17 18:02:00 2014 +0530 18.3 @@ -62,10 +62,6 @@ 18.4 // initialized by nasgen 18.5 private static PropertyMap $nasgenmap$; 18.6 18.7 - static PropertyMap getInitialMap() { 18.8 - return $nasgenmap$; 18.9 - } 18.10 - 18.11 @SuppressWarnings("LeakingThisInConstructor") 18.12 private NativeRangeError(final Object msg, final ScriptObject proto, final PropertyMap map) { 18.13 super(proto, map); 18.14 @@ -78,7 +74,7 @@ 18.15 } 18.16 18.17 NativeRangeError(final Object msg, final Global global) { 18.18 - this(msg, global.getRangeErrorPrototype(), getInitialMap()); 18.19 + this(msg, global.getRangeErrorPrototype(), $nasgenmap$); 18.20 } 18.21 18.22 private NativeRangeError(final Object msg) {
19.1 --- a/src/jdk/nashorn/internal/objects/NativeReferenceError.java Thu Mar 13 15:58:24 2014 +0530 19.2 +++ b/src/jdk/nashorn/internal/objects/NativeReferenceError.java Mon Mar 17 18:02:00 2014 +0530 19.3 @@ -62,10 +62,6 @@ 19.4 // initialized by nasgen 19.5 private static PropertyMap $nasgenmap$; 19.6 19.7 - static PropertyMap getInitialMap() { 19.8 - return $nasgenmap$; 19.9 - } 19.10 - 19.11 @SuppressWarnings("LeakingThisInConstructor") 19.12 private NativeReferenceError(final Object msg, final ScriptObject proto, final PropertyMap map) { 19.13 super(proto, map); 19.14 @@ -78,7 +74,7 @@ 19.15 } 19.16 19.17 NativeReferenceError(final Object msg, final Global global) { 19.18 - this(msg, global.getReferenceErrorPrototype(), getInitialMap()); 19.19 + this(msg, global.getReferenceErrorPrototype(), $nasgenmap$); 19.20 } 19.21 19.22 private NativeReferenceError(final Object msg) {
20.1 --- a/src/jdk/nashorn/internal/objects/NativeRegExp.java Thu Mar 13 15:58:24 2014 +0530 20.2 +++ b/src/jdk/nashorn/internal/objects/NativeRegExp.java Mon Mar 17 18:02:00 2014 +0530 20.3 @@ -70,12 +70,8 @@ 20.4 // initialized by nasgen 20.5 private static PropertyMap $nasgenmap$; 20.6 20.7 - static PropertyMap getInitialMap() { 20.8 - return $nasgenmap$; 20.9 - } 20.10 - 20.11 private NativeRegExp(final Global global) { 20.12 - super(global.getRegExpPrototype(), getInitialMap()); 20.13 + super(global.getRegExpPrototype(), $nasgenmap$); 20.14 this.globalObject = global; 20.15 } 20.16
21.1 --- a/src/jdk/nashorn/internal/objects/NativeRegExpExecResult.java Thu Mar 13 15:58:24 2014 +0530 21.2 +++ b/src/jdk/nashorn/internal/objects/NativeRegExpExecResult.java Mon Mar 17 18:02:00 2014 +0530 21.3 @@ -53,12 +53,8 @@ 21.4 // initialized by nasgen 21.5 private static PropertyMap $nasgenmap$; 21.6 21.7 - static PropertyMap getInitialMap() { 21.8 - return $nasgenmap$; 21.9 - } 21.10 - 21.11 NativeRegExpExecResult(final RegExpResult result, final Global global) { 21.12 - super(global.getArrayPrototype(), getInitialMap()); 21.13 + super(global.getArrayPrototype(), $nasgenmap$); 21.14 setIsArray(); 21.15 this.setArray(ArrayData.allocate(result.getGroups().clone())); 21.16 this.index = result.getIndex();
22.1 --- a/src/jdk/nashorn/internal/objects/NativeString.java Thu Mar 13 15:58:24 2014 +0530 22.2 +++ b/src/jdk/nashorn/internal/objects/NativeString.java Mon Mar 17 18:02:00 2014 +0530 22.3 @@ -78,16 +78,12 @@ 22.4 // initialized by nasgen 22.5 private static PropertyMap $nasgenmap$; 22.6 22.7 - static PropertyMap getInitialMap() { 22.8 - return $nasgenmap$; 22.9 - } 22.10 - 22.11 private NativeString(final CharSequence value) { 22.12 this(value, Global.instance()); 22.13 } 22.14 22.15 NativeString(final CharSequence value, final Global global) { 22.16 - this(value, global.getStringPrototype(), getInitialMap()); 22.17 + this(value, global.getStringPrototype(), $nasgenmap$); 22.18 } 22.19 22.20 private NativeString(final CharSequence value, final ScriptObject proto, final PropertyMap map) {
23.1 --- a/src/jdk/nashorn/internal/objects/NativeSyntaxError.java Thu Mar 13 15:58:24 2014 +0530 23.2 +++ b/src/jdk/nashorn/internal/objects/NativeSyntaxError.java Mon Mar 17 18:02:00 2014 +0530 23.3 @@ -62,13 +62,9 @@ 23.4 // initialized by nasgen 23.5 private static PropertyMap $nasgenmap$; 23.6 23.7 - static PropertyMap getInitialMap() { 23.8 - return $nasgenmap$; 23.9 - } 23.10 - 23.11 @SuppressWarnings("LeakingThisInConstructor") 23.12 NativeSyntaxError(final Object msg, final Global global) { 23.13 - super(global.getSyntaxErrorPrototype(), getInitialMap()); 23.14 + super(global.getSyntaxErrorPrototype(), $nasgenmap$); 23.15 if (msg != UNDEFINED) { 23.16 this.instMessage = JSType.toString(msg); 23.17 } else {
24.1 --- a/src/jdk/nashorn/internal/objects/NativeTypeError.java Thu Mar 13 15:58:24 2014 +0530 24.2 +++ b/src/jdk/nashorn/internal/objects/NativeTypeError.java Mon Mar 17 18:02:00 2014 +0530 24.3 @@ -62,13 +62,9 @@ 24.4 // initialized by nasgen 24.5 private static PropertyMap $nasgenmap$; 24.6 24.7 - static PropertyMap getInitialMap() { 24.8 - return $nasgenmap$; 24.9 - } 24.10 - 24.11 @SuppressWarnings("LeakingThisInConstructor") 24.12 NativeTypeError(final Object msg, final Global global) { 24.13 - super(global.getTypeErrorPrototype(), getInitialMap()); 24.14 + super(global.getTypeErrorPrototype(), $nasgenmap$); 24.15 if (msg != UNDEFINED) { 24.16 this.instMessage = JSType.toString(msg); 24.17 } else {
25.1 --- a/src/jdk/nashorn/internal/objects/NativeURIError.java Thu Mar 13 15:58:24 2014 +0530 25.2 +++ b/src/jdk/nashorn/internal/objects/NativeURIError.java Mon Mar 17 18:02:00 2014 +0530 25.3 @@ -61,13 +61,9 @@ 25.4 // initialized by nasgen 25.5 private static PropertyMap $nasgenmap$; 25.6 25.7 - static PropertyMap getInitialMap() { 25.8 - return $nasgenmap$; 25.9 - } 25.10 - 25.11 @SuppressWarnings("LeakingThisInConstructor") 25.12 NativeURIError(final Object msg, final Global global) { 25.13 - super(global.getURIErrorPrototype(), getInitialMap()); 25.14 + super(global.getURIErrorPrototype(), $nasgenmap$); 25.15 if (msg != UNDEFINED) { 25.16 this.instMessage = JSType.toString(msg); 25.17 } else {
26.1 --- a/src/jdk/nashorn/internal/objects/PrototypeObject.java Thu Mar 13 15:58:24 2014 +0530 26.2 +++ b/src/jdk/nashorn/internal/objects/PrototypeObject.java Mon Mar 17 18:02:00 2014 +0530 26.3 @@ -57,10 +57,6 @@ 26.4 map$ = PropertyMap.newMap(properties); 26.5 } 26.6 26.7 - static PropertyMap getInitialMap() { 26.8 - return map$; 26.9 - } 26.10 - 26.11 private PrototypeObject(final Global global, final PropertyMap map) { 26.12 super(global.getObjectPrototype(), map != map$? map.addAll(map$) : map$); 26.13 }
27.1 --- a/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java Thu Mar 13 15:58:24 2014 +0530 27.2 +++ b/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java Mon Mar 17 18:02:00 2014 +0530 27.3 @@ -55,27 +55,11 @@ 27.4 // property map for non-strict, non-bound functions. 27.5 private static final PropertyMap map$; 27.6 27.7 - static PropertyMap getInitialMap() { 27.8 - return map$; 27.9 - } 27.10 - 27.11 - static PropertyMap getInitialAnonymousMap() { 27.12 - return AnonymousFunction.getInitialMap(); 27.13 - } 27.14 - 27.15 - static PropertyMap getInitialStrictMap() { 27.16 - return strictmodemap$; 27.17 - } 27.18 - 27.19 - static PropertyMap getInitialBoundMap() { 27.20 - return boundfunctionmap$; 27.21 - } 27.22 - 27.23 // Marker object for lazily initialized prototype object 27.24 private static final Object LAZY_PROTOTYPE = new Object(); 27.25 27.26 private ScriptFunctionImpl(final String name, final MethodHandle invokeHandle, final MethodHandle[] specs, final Global global) { 27.27 - super(name, invokeHandle, getInitialMap(), null, specs, ScriptFunctionData.IS_BUILTIN_CONSTRUCTOR); 27.28 + super(name, invokeHandle, map$, null, specs, ScriptFunctionData.IS_BUILTIN_CONSTRUCTOR); 27.29 init(global); 27.30 } 27.31 27.32 @@ -92,7 +76,7 @@ 27.33 } 27.34 27.35 private ScriptFunctionImpl(final String name, final MethodHandle invokeHandle, final PropertyMap map, final MethodHandle[] specs, final Global global) { 27.36 - super(name, invokeHandle, map.addAll(getInitialMap()), null, specs, ScriptFunctionData.IS_BUILTIN_CONSTRUCTOR); 27.37 + super(name, invokeHandle, map.addAll(map$), null, specs, ScriptFunctionData.IS_BUILTIN_CONSTRUCTOR); 27.38 init(global); 27.39 } 27.40 27.41 @@ -110,7 +94,7 @@ 27.42 } 27.43 27.44 private ScriptFunctionImpl(final String name, final MethodHandle methodHandle, final ScriptObject scope, final MethodHandle[] specs, final int flags, final Global global) { 27.45 - super(name, methodHandle, getMap(global, isStrict(flags)), scope, specs, flags); 27.46 + super(name, methodHandle, getMap(isStrict(flags)), scope, specs, flags); 27.47 init(global); 27.48 } 27.49 27.50 @@ -128,7 +112,7 @@ 27.51 } 27.52 27.53 private ScriptFunctionImpl(final RecompilableScriptFunctionData data, final ScriptObject scope, final Global global) { 27.54 - super(data, getMap(global, data.isStrict()), scope); 27.55 + super(data, getMap(data.isStrict()), scope); 27.56 init(global); 27.57 } 27.58 27.59 @@ -148,7 +132,7 @@ 27.60 * @param global the global object 27.61 */ 27.62 ScriptFunctionImpl(final ScriptFunctionData data, final Global global) { 27.63 - super(data, getInitialBoundMap(), null); 27.64 + super(data, boundfunctionmap$, null); 27.65 init(global); 27.66 } 27.67 27.68 @@ -176,8 +160,8 @@ 27.69 } 27.70 27.71 // Choose the map based on strict mode! 27.72 - private static PropertyMap getMap(final Global global, final boolean strict) { 27.73 - return strict ? getInitialStrictMap() : getInitialMap(); 27.74 + private static PropertyMap getMap(final boolean strict) { 27.75 + return strict ? strictmodemap$ : map$; 27.76 } 27.77 27.78 private static PropertyMap createBoundFunctionMap(final PropertyMap strictModeMap) { 27.79 @@ -191,12 +175,8 @@ 27.80 private static class AnonymousFunction extends ScriptFunctionImpl { 27.81 private static final PropertyMap anonmap$ = PropertyMap.newMap(); 27.82 27.83 - static PropertyMap getInitialMap() { 27.84 - return anonmap$; 27.85 - } 27.86 - 27.87 AnonymousFunction(final Global global) { 27.88 - super("", GlobalFunctions.ANONYMOUS, getInitialAnonymousMap(), null); 27.89 + super("", GlobalFunctions.ANONYMOUS, anonmap$, null); 27.90 } 27.91 } 27.92
28.1 --- a/src/jdk/nashorn/internal/runtime/Context.java Thu Mar 13 15:58:24 2014 +0530 28.2 +++ b/src/jdk/nashorn/internal/runtime/Context.java Mon Mar 17 18:02:00 2014 +0530 28.3 @@ -157,7 +157,7 @@ 28.4 /** Is Context global debug mode enabled ? */ 28.5 public static final boolean DEBUG = Options.getBooleanProperty("nashorn.debug"); 28.6 28.7 - private static final ThreadLocal<ScriptObject> currentGlobal = new ThreadLocal<>(); 28.8 + private static final ThreadLocal<Global> currentGlobal = new ThreadLocal<>(); 28.9 28.10 // class cache 28.11 private ClassCache classCache; 28.12 @@ -166,10 +166,10 @@ 28.13 * Get the current global scope 28.14 * @return the current global scope 28.15 */ 28.16 - public static ScriptObject getGlobal() { 28.17 + public static Global getGlobal() { 28.18 // This class in a package.access protected package. 28.19 // Trusted code only can call this method. 28.20 - return getGlobalTrusted(); 28.21 + return currentGlobal.get(); 28.22 } 28.23 28.24 /** 28.25 @@ -178,10 +178,19 @@ 28.26 */ 28.27 public static void setGlobal(final ScriptObject global) { 28.28 if (global != null && !(global instanceof Global)) { 28.29 - throw new IllegalArgumentException("global is not an instance of Global!"); 28.30 + throw new IllegalArgumentException("not a global!"); 28.31 } 28.32 + setGlobal((Global)global); 28.33 + } 28.34 28.35 - setGlobalTrusted(global); 28.36 + /** 28.37 + * Set the current global scope 28.38 + * @param global the global scope 28.39 + */ 28.40 + public static void setGlobal(final Global global) { 28.41 + // This class in a package.access protected package. 28.42 + // Trusted code only can call this method. 28.43 + currentGlobal.set(global); 28.44 } 28.45 28.46 /** 28.47 @@ -202,7 +211,7 @@ 28.48 * @return error writer of the current context 28.49 */ 28.50 public static PrintWriter getCurrentErr() { 28.51 - final ScriptObject global = getGlobalTrusted(); 28.52 + final ScriptObject global = getGlobal(); 28.53 return (global != null)? global.getContext().getErr() : new PrintWriter(System.err); 28.54 } 28.55 28.56 @@ -407,7 +416,7 @@ 28.57 * @return the property map of the current global scope 28.58 */ 28.59 public static PropertyMap getGlobalMap() { 28.60 - return Context.getGlobalTrusted().getMap(); 28.61 + return Context.getGlobal().getMap(); 28.62 } 28.63 28.64 /** 28.65 @@ -437,7 +446,7 @@ 28.66 final String file = (location == UNDEFINED || location == null) ? "<eval>" : location.toString(); 28.67 final Source source = new Source(file, string); 28.68 final boolean directEval = location != UNDEFINED; // is this direct 'eval' call or indirectly invoked eval? 28.69 - final ScriptObject global = Context.getGlobalTrusted(); 28.70 + final Global global = Context.getGlobal(); 28.71 28.72 ScriptObject scope = initialScope; 28.73 28.74 @@ -469,7 +478,7 @@ 28.75 // in the caller's environment. A new environment is created! 28.76 if (strictFlag) { 28.77 // Create a new scope object 28.78 - final ScriptObject strictEvalScope = ((GlobalObject)global).newObject(); 28.79 + final ScriptObject strictEvalScope = global.newObject(); 28.80 28.81 // bless it as a "scope" 28.82 strictEvalScope.setIsScope(); 28.83 @@ -594,10 +603,10 @@ 28.84 * @throws IOException if source cannot be found or loaded 28.85 */ 28.86 public Object loadWithNewGlobal(final Object from, final Object...args) throws IOException { 28.87 - final ScriptObject oldGlobal = getGlobalTrusted(); 28.88 - final ScriptObject newGlobal = AccessController.doPrivileged(new PrivilegedAction<ScriptObject>() { 28.89 + final Global oldGlobal = getGlobal(); 28.90 + final Global newGlobal = AccessController.doPrivileged(new PrivilegedAction<Global>() { 28.91 @Override 28.92 - public ScriptObject run() { 28.93 + public Global run() { 28.94 try { 28.95 return newGlobal(); 28.96 } catch (final RuntimeException e) { 28.97 @@ -610,17 +619,17 @@ 28.98 }, CREATE_GLOBAL_ACC_CTXT); 28.99 // initialize newly created Global instance 28.100 initGlobal(newGlobal); 28.101 - setGlobalTrusted(newGlobal); 28.102 + setGlobal(newGlobal); 28.103 28.104 final Object[] wrapped = args == null? ScriptRuntime.EMPTY_ARRAY : ScriptObjectMirror.wrapArray(args, oldGlobal); 28.105 - newGlobal.put("arguments", ((GlobalObject)newGlobal).wrapAsObject(wrapped), env._strict); 28.106 + newGlobal.put("arguments", newGlobal.wrapAsObject(wrapped), env._strict); 28.107 28.108 try { 28.109 // wrap objects from newGlobal's world as mirrors - but if result 28.110 // is from oldGlobal's world, unwrap it! 28.111 return ScriptObjectMirror.unwrap(ScriptObjectMirror.wrap(load(newGlobal, from), newGlobal), oldGlobal); 28.112 } finally { 28.113 - setGlobalTrusted(oldGlobal); 28.114 + setGlobal(oldGlobal); 28.115 } 28.116 } 28.117 28.118 @@ -795,7 +804,7 @@ 28.119 * 28.120 * @return the initialized global scope object. 28.121 */ 28.122 - public ScriptObject createGlobal() { 28.123 + public Global createGlobal() { 28.124 return initGlobal(newGlobal()); 28.125 } 28.126 28.127 @@ -803,7 +812,7 @@ 28.128 * Create a new uninitialized global scope object 28.129 * @return the global script object 28.130 */ 28.131 - public ScriptObject newGlobal() { 28.132 + public Global newGlobal() { 28.133 return new Global(this); 28.134 } 28.135 28.136 @@ -813,20 +822,16 @@ 28.137 * @param global the global 28.138 * @return the initialized global scope object. 28.139 */ 28.140 - public ScriptObject initGlobal(final ScriptObject global) { 28.141 - if (! (global instanceof GlobalObject)) { 28.142 - throw new IllegalArgumentException("not a global object!"); 28.143 - } 28.144 - 28.145 + public Global initGlobal(final Global global) { 28.146 // Need only minimal global object, if we are just compiling. 28.147 if (!env._compile_only) { 28.148 - final ScriptObject oldGlobal = Context.getGlobalTrusted(); 28.149 + final Global oldGlobal = Context.getGlobal(); 28.150 try { 28.151 - Context.setGlobalTrusted(global); 28.152 + Context.setGlobal(global); 28.153 // initialize global scope with builtin global objects 28.154 - ((GlobalObject)global).initBuiltinObjects(); 28.155 + global.initBuiltinObjects(); 28.156 } finally { 28.157 - Context.setGlobalTrusted(oldGlobal); 28.158 + Context.setGlobal(oldGlobal); 28.159 } 28.160 } 28.161 28.162 @@ -834,30 +839,15 @@ 28.163 } 28.164 28.165 /** 28.166 - * Trusted variants - package-private 28.167 + * Trusted variant - package-private 28.168 */ 28.169 28.170 /** 28.171 - * Return the current global scope 28.172 - * @return current global scope 28.173 - */ 28.174 - static ScriptObject getGlobalTrusted() { 28.175 - return currentGlobal.get(); 28.176 - } 28.177 - 28.178 - /** 28.179 - * Set the current global scope 28.180 - */ 28.181 - static void setGlobalTrusted(ScriptObject global) { 28.182 - currentGlobal.set(global); 28.183 - } 28.184 - 28.185 - /** 28.186 * Return the current global's context 28.187 * @return current global's context 28.188 */ 28.189 static Context getContextTrusted() { 28.190 - return Context.getGlobalTrusted().getContext(); 28.191 + return ((ScriptObject)Context.getGlobal()).getContext(); 28.192 } 28.193 28.194 /** 28.195 @@ -926,7 +916,7 @@ 28.196 } 28.197 28.198 // Package as a JavaScript function and pass function back to shell. 28.199 - return ((GlobalObject)Context.getGlobalTrusted()).newScriptFunction(RUN_SCRIPT.symbolName(), runMethodHandle, scope, strict); 28.200 + return Context.getGlobal().newScriptFunction(RUN_SCRIPT.symbolName(), runMethodHandle, scope, strict); 28.201 } 28.202 28.203 private ScriptFunction compileScript(final Source source, final ScriptObject scope, final ErrorManager errMan) {
29.1 --- a/src/jdk/nashorn/internal/runtime/DebuggerSupport.java Thu Mar 13 15:58:24 2014 +0530 29.2 +++ b/src/jdk/nashorn/internal/runtime/DebuggerSupport.java Mon Mar 17 18:02:00 2014 +0530 29.3 @@ -75,7 +75,7 @@ 29.4 * @return context global. 29.5 */ 29.6 static Object getGlobal() { 29.7 - return Context.getGlobalTrusted(); 29.8 + return Context.getGlobal(); 29.9 } 29.10 29.11 /** 29.12 @@ -87,7 +87,7 @@ 29.13 * @return Result of eval as string, or, an exception or null depending on returnException. 29.14 */ 29.15 static Object eval(final ScriptObject scope, final Object self, final String string, final boolean returnException) { 29.16 - final ScriptObject global = Context.getGlobalTrusted(); 29.17 + final ScriptObject global = Context.getGlobal(); 29.18 final ScriptObject initialScope = scope != null ? scope : global; 29.19 final Object callThis = self != null ? self : global; 29.20 final Context context = global.getContext();
30.1 --- a/src/jdk/nashorn/internal/runtime/ECMAErrors.java Thu Mar 13 15:58:24 2014 +0530 30.2 +++ b/src/jdk/nashorn/internal/runtime/ECMAErrors.java Mon Mar 17 18:02:00 2014 +0530 30.3 @@ -31,6 +31,7 @@ 30.4 import jdk.nashorn.api.scripting.NashornException; 30.5 import jdk.nashorn.internal.scripts.JS; 30.6 import jdk.nashorn.internal.codegen.CompilerConstants; 30.7 +import jdk.nashorn.internal.objects.Global; 30.8 30.9 /** 30.10 * Helper class to throw various standard "ECMA error" exceptions such as Error, ReferenceError, TypeError etc. 30.11 @@ -66,7 +67,7 @@ 30.12 * @return the resulting {@link ECMAException} 30.13 */ 30.14 public static ECMAException asEcmaException(final ParserException e) { 30.15 - return asEcmaException(Context.getGlobalTrusted(), e); 30.16 + return asEcmaException(Context.getGlobal(), e); 30.17 } 30.18 30.19 /** 30.20 @@ -78,11 +79,11 @@ 30.21 * 30.22 * @return the resulting {@link ECMAException} 30.23 */ 30.24 - public static ECMAException asEcmaException(final ScriptObject global, final ParserException e) { 30.25 + public static ECMAException asEcmaException(final Global global, final ParserException e) { 30.26 final JSErrorType errorType = e.getErrorType(); 30.27 assert errorType != null : "error type for " + e + " was null"; 30.28 30.29 - final GlobalObject globalObj = (GlobalObject)global; 30.30 + final Global globalObj = global; 30.31 final String msg = e.getMessage(); 30.32 30.33 // translate to ECMAScript Error object using error type 30.34 @@ -116,7 +117,7 @@ 30.35 * @return the resulting {@link ECMAException} 30.36 */ 30.37 public static ECMAException syntaxError(final String msgId, final String... args) { 30.38 - return syntaxError(Context.getGlobalTrusted(), msgId, args); 30.39 + return syntaxError(Context.getGlobal(), msgId, args); 30.40 } 30.41 30.42 /** 30.43 @@ -128,7 +129,7 @@ 30.44 * 30.45 * @return the resulting {@link ECMAException} 30.46 */ 30.47 - public static ECMAException syntaxError(final ScriptObject global, final String msgId, final String... args) { 30.48 + public static ECMAException syntaxError(final Global global, final String msgId, final String... args) { 30.49 return syntaxError(global, null, msgId, args); 30.50 } 30.51 30.52 @@ -142,7 +143,7 @@ 30.53 * @return the resulting {@link ECMAException} 30.54 */ 30.55 public static ECMAException syntaxError(final Throwable cause, final String msgId, final String... args) { 30.56 - return syntaxError(Context.getGlobalTrusted(), cause, msgId, args); 30.57 + return syntaxError(Context.getGlobal(), cause, msgId, args); 30.58 } 30.59 30.60 /** 30.61 @@ -155,9 +156,9 @@ 30.62 * 30.63 * @return the resulting {@link ECMAException} 30.64 */ 30.65 - public static ECMAException syntaxError(final ScriptObject global, final Throwable cause, final String msgId, final String... args) { 30.66 + public static ECMAException syntaxError(final Global global, final Throwable cause, final String msgId, final String... args) { 30.67 final String msg = getMessage("syntax.error." + msgId, args); 30.68 - return error(((GlobalObject)global).newSyntaxError(msg), cause); 30.69 + return error(global.newSyntaxError(msg), cause); 30.70 } 30.71 30.72 /** 30.73 @@ -169,7 +170,7 @@ 30.74 * @return the resulting {@link ECMAException} 30.75 */ 30.76 public static ECMAException typeError(final String msgId, final String... args) { 30.77 - return typeError(Context.getGlobalTrusted(), msgId, args); 30.78 + return typeError(Context.getGlobal(), msgId, args); 30.79 } 30.80 30.81 /** 30.82 @@ -181,7 +182,7 @@ 30.83 * 30.84 * @return the resulting {@link ECMAException} 30.85 */ 30.86 - public static ECMAException typeError(final ScriptObject global, final String msgId, final String... args) { 30.87 + public static ECMAException typeError(final Global global, final String msgId, final String... args) { 30.88 return typeError(global, null, msgId, args); 30.89 } 30.90 30.91 @@ -195,7 +196,7 @@ 30.92 * @return the resulting {@link ECMAException} 30.93 */ 30.94 public static ECMAException typeError(final Throwable cause, final String msgId, final String... args) { 30.95 - return typeError(Context.getGlobalTrusted(), cause, msgId, args); 30.96 + return typeError(Context.getGlobal(), cause, msgId, args); 30.97 } 30.98 30.99 /** 30.100 @@ -208,9 +209,9 @@ 30.101 * 30.102 * @return the resulting {@link ECMAException} 30.103 */ 30.104 - public static ECMAException typeError(final ScriptObject global, final Throwable cause, final String msgId, final String... args) { 30.105 + public static ECMAException typeError(final Global global, final Throwable cause, final String msgId, final String... args) { 30.106 final String msg = getMessage("type.error." + msgId, args); 30.107 - return error(((GlobalObject)global).newTypeError(msg), cause); 30.108 + return error(global.newTypeError(msg), cause); 30.109 } 30.110 30.111 /** 30.112 @@ -222,7 +223,7 @@ 30.113 * @return the resulting {@link ECMAException} 30.114 */ 30.115 public static ECMAException rangeError(final String msgId, final String... args) { 30.116 - return rangeError(Context.getGlobalTrusted(), msgId, args); 30.117 + return rangeError(Context.getGlobal(), msgId, args); 30.118 } 30.119 30.120 /** 30.121 @@ -234,7 +235,7 @@ 30.122 * 30.123 * @return the resulting {@link ECMAException} 30.124 */ 30.125 - public static ECMAException rangeError(final ScriptObject global, final String msgId, final String... args) { 30.126 + public static ECMAException rangeError(final Global global, final String msgId, final String... args) { 30.127 return rangeError(global, null, msgId, args); 30.128 } 30.129 30.130 @@ -248,7 +249,7 @@ 30.131 * @return the resulting {@link ECMAException} 30.132 */ 30.133 public static ECMAException rangeError(final Throwable cause, final String msgId, final String... args) { 30.134 - return rangeError(Context.getGlobalTrusted(), cause, msgId, args); 30.135 + return rangeError(Context.getGlobal(), cause, msgId, args); 30.136 } 30.137 30.138 /** 30.139 @@ -261,9 +262,9 @@ 30.140 * 30.141 * @return the resulting {@link ECMAException} 30.142 */ 30.143 - public static ECMAException rangeError(final ScriptObject global, final Throwable cause, final String msgId, final String... args) { 30.144 + public static ECMAException rangeError(final Global global, final Throwable cause, final String msgId, final String... args) { 30.145 final String msg = getMessage("range.error." + msgId, args); 30.146 - return error(((GlobalObject)global).newRangeError(msg), cause); 30.147 + return error(global.newRangeError(msg), cause); 30.148 } 30.149 30.150 /** 30.151 @@ -275,7 +276,7 @@ 30.152 * @return the resulting {@link ECMAException} 30.153 */ 30.154 public static ECMAException referenceError(final String msgId, final String... args) { 30.155 - return referenceError(Context.getGlobalTrusted(), msgId, args); 30.156 + return referenceError(Context.getGlobal(), msgId, args); 30.157 } 30.158 30.159 /** 30.160 @@ -287,7 +288,7 @@ 30.161 * 30.162 * @return the resulting {@link ECMAException} 30.163 */ 30.164 - public static ECMAException referenceError(final ScriptObject global, final String msgId, final String... args) { 30.165 + public static ECMAException referenceError(final Global global, final String msgId, final String... args) { 30.166 return referenceError(global, null, msgId, args); 30.167 } 30.168 30.169 @@ -301,7 +302,7 @@ 30.170 * @return the resulting {@link ECMAException} 30.171 */ 30.172 public static ECMAException referenceError(final Throwable cause, final String msgId, final String... args) { 30.173 - return referenceError(Context.getGlobalTrusted(), cause, msgId, args); 30.174 + return referenceError(Context.getGlobal(), cause, msgId, args); 30.175 } 30.176 30.177 /** 30.178 @@ -314,9 +315,9 @@ 30.179 * 30.180 * @return the resulting {@link ECMAException} 30.181 */ 30.182 - public static ECMAException referenceError(final ScriptObject global, final Throwable cause, final String msgId, final String... args) { 30.183 + public static ECMAException referenceError(final Global global, final Throwable cause, final String msgId, final String... args) { 30.184 final String msg = getMessage("reference.error." + msgId, args); 30.185 - return error(((GlobalObject)global).newReferenceError(msg), cause); 30.186 + return error(global.newReferenceError(msg), cause); 30.187 } 30.188 30.189 /** 30.190 @@ -328,7 +329,7 @@ 30.191 * @return the resulting {@link ECMAException} 30.192 */ 30.193 public static ECMAException uriError(final String msgId, final String... args) { 30.194 - return uriError(Context.getGlobalTrusted(), msgId, args); 30.195 + return uriError(Context.getGlobal(), msgId, args); 30.196 } 30.197 30.198 /** 30.199 @@ -340,7 +341,7 @@ 30.200 * 30.201 * @return the resulting {@link ECMAException} 30.202 */ 30.203 - public static ECMAException uriError(final ScriptObject global, final String msgId, final String... args) { 30.204 + public static ECMAException uriError(final Global global, final String msgId, final String... args) { 30.205 return uriError(global, null, msgId, args); 30.206 } 30.207 30.208 @@ -354,7 +355,7 @@ 30.209 * @return the resulting {@link ECMAException} 30.210 */ 30.211 public static ECMAException uriError(final Throwable cause, final String msgId, final String... args) { 30.212 - return uriError(Context.getGlobalTrusted(), cause, msgId, args); 30.213 + return uriError(Context.getGlobal(), cause, msgId, args); 30.214 } 30.215 30.216 /** 30.217 @@ -367,9 +368,9 @@ 30.218 * 30.219 * @return the resulting {@link ECMAException} 30.220 */ 30.221 - public static ECMAException uriError(final ScriptObject global, final Throwable cause, final String msgId, final String... args) { 30.222 + public static ECMAException uriError(final Global global, final Throwable cause, final String msgId, final String... args) { 30.223 final String msg = getMessage("uri.error." + msgId, args); 30.224 - return error(((GlobalObject)global).newURIError(msg), cause); 30.225 + return error(global.newURIError(msg), cause); 30.226 } 30.227 30.228 /**
31.1 --- a/src/jdk/nashorn/internal/runtime/GlobalObject.java Thu Mar 13 15:58:24 2014 +0530 31.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 31.3 @@ -1,228 +0,0 @@ 31.4 -/* 31.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 31.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 31.7 - * 31.8 - * This code is free software; you can redistribute it and/or modify it 31.9 - * under the terms of the GNU General Public License version 2 only, as 31.10 - * published by the Free Software Foundation. Oracle designates this 31.11 - * particular file as subject to the "Classpath" exception as provided 31.12 - * by Oracle in the LICENSE file that accompanied this code. 31.13 - * 31.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 31.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 31.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 31.17 - * version 2 for more details (a copy is included in the LICENSE file that 31.18 - * accompanied this code). 31.19 - * 31.20 - * You should have received a copy of the GNU General Public License version 31.21 - * 2 along with this work; if not, write to the Free Software Foundation, 31.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 31.23 - * 31.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 31.25 - * or visit www.oracle.com if you need additional information or have any 31.26 - * questions. 31.27 - */ 31.28 - 31.29 -package jdk.nashorn.internal.runtime; 31.30 - 31.31 -import java.lang.invoke.MethodHandle; 31.32 -import java.util.concurrent.Callable; 31.33 -import jdk.internal.dynalink.linker.GuardedInvocation; 31.34 -import jdk.internal.dynalink.linker.LinkRequest; 31.35 -import jdk.nashorn.internal.runtime.linker.InvokeByName; 31.36 - 31.37 -/** 31.38 - * Runtime interface to the global scope objects. 31.39 - */ 31.40 - 31.41 -public interface GlobalObject { 31.42 - /** 31.43 - * Is this global of the given Context? 31.44 - * @param ctxt the context 31.45 - * @return true if this global belongs to the given Context 31.46 - */ 31.47 - public boolean isOfContext(final Context ctxt); 31.48 - 31.49 - /** 31.50 - * Does this global belong to a strict Context? 31.51 - * @return true if this global belongs to a strict Context 31.52 - */ 31.53 - public boolean isStrictContext(); 31.54 - 31.55 - /** 31.56 - * Initialize standard builtin objects like "Object", "Array", "Function" etc. 31.57 - * as well as our extension builtin objects like "Java", "JSAdapter" as properties 31.58 - * of the global scope object. 31.59 - */ 31.60 - public void initBuiltinObjects(); 31.61 - 31.62 - /** 31.63 - * Wrapper for {@link jdk.nashorn.internal.objects.Global#newScriptFunction(String, MethodHandle, ScriptObject, boolean)} 31.64 - * 31.65 - * @param name function name 31.66 - * @param handle invocation handle for function 31.67 - * @param scope the scope 31.68 - * @param strict are we in strict mode 31.69 - * 31.70 - * @return new script function 31.71 - */ 31.72 - public ScriptFunction newScriptFunction(String name, MethodHandle handle, ScriptObject scope, boolean strict); 31.73 - 31.74 - /** 31.75 - * Wrapper for {@link jdk.nashorn.internal.objects.Global#wrapAsObject(Object)} 31.76 - * 31.77 - * @param obj object to wrap 31.78 - * @return wrapped object 31.79 - */ 31.80 - public Object wrapAsObject(Object obj); 31.81 - 31.82 - 31.83 - /** 31.84 - * Wrapper for {@link jdk.nashorn.internal.objects.Global#primitiveLookup(LinkRequest, Object)} 31.85 - * 31.86 - * @param request the link request for the dynamic call site. 31.87 - * @param self self reference 31.88 - * 31.89 - * @return guarded invocation 31.90 - */ 31.91 - public GuardedInvocation primitiveLookup(LinkRequest request, Object self); 31.92 - 31.93 - 31.94 - /** 31.95 - * Wrapper for {@link jdk.nashorn.internal.objects.Global#newObject()} 31.96 - * 31.97 - * @return the new ScriptObject 31.98 - */ 31.99 - public ScriptObject newObject(); 31.100 - 31.101 - /** 31.102 - * Wrapper for {@link jdk.nashorn.internal.objects.Global#isError(ScriptObject)} 31.103 - * 31.104 - * @param sobj to check if it is an error object 31.105 - * @return true if error object 31.106 - */ 31.107 - public boolean isError(ScriptObject sobj); 31.108 - 31.109 - /** 31.110 - * Wrapper for {@link jdk.nashorn.internal.objects.Global#newError(String)} 31.111 - * 31.112 - * @param msg the error message 31.113 - * 31.114 - * @return the new ScriptObject representing the error 31.115 - */ 31.116 - public ScriptObject newError(String msg); 31.117 - 31.118 - /** 31.119 - * Wrapper for {@link jdk.nashorn.internal.objects.Global#newEvalError(String)} 31.120 - * 31.121 - * @param msg the error message 31.122 - * 31.123 - * @return the new ScriptObject representing the eval error 31.124 - */ 31.125 - public ScriptObject newEvalError(String msg); 31.126 - 31.127 - /** 31.128 - * Wrapper for {@link jdk.nashorn.internal.objects.Global#newRangeError(String)} 31.129 - * 31.130 - * @param msg the error message 31.131 - * 31.132 - * @return the new ScriptObject representing the range error 31.133 - */ 31.134 - public ScriptObject newRangeError(String msg); 31.135 - 31.136 - /** 31.137 - * Wrapper for {@link jdk.nashorn.internal.objects.Global#newReferenceError(String)} 31.138 - * 31.139 - * @param msg the error message 31.140 - * 31.141 - * @return the new ScriptObject representing the reference error 31.142 - */ 31.143 - public ScriptObject newReferenceError(String msg); 31.144 - 31.145 - /** 31.146 - * Wrapper for {@link jdk.nashorn.internal.objects.Global#newSyntaxError(String)} 31.147 - * 31.148 - * @param msg the error message 31.149 - * 31.150 - * @return the new ScriptObject representing the syntax error 31.151 - */ 31.152 - public ScriptObject newSyntaxError(String msg); 31.153 - 31.154 - /** 31.155 - * Wrapper for {@link jdk.nashorn.internal.objects.Global#newTypeError(String)} 31.156 - * 31.157 - * @param msg the error message 31.158 - * 31.159 - * @return the new ScriptObject representing the type error 31.160 - */ 31.161 - public ScriptObject newTypeError(String msg); 31.162 - 31.163 - /** 31.164 - * Wrapper for {@link jdk.nashorn.internal.objects.Global#newURIError(String)} 31.165 - * 31.166 - * @param msg the error message 31.167 - * 31.168 - * @return the new ScriptObject representing the URI error 31.169 - */ 31.170 - public ScriptObject newURIError(String msg); 31.171 - 31.172 - /** 31.173 - * Wrapper for {@link jdk.nashorn.internal.objects.Global#newGenericDescriptor(boolean, boolean)} 31.174 - * 31.175 - * @param configurable is the described property configurable 31.176 - * @param enumerable is the described property enumerable 31.177 - * 31.178 - * @return property descriptor 31.179 - */ 31.180 - public PropertyDescriptor newGenericDescriptor(boolean configurable, boolean enumerable); 31.181 - 31.182 - /** 31.183 - * Wrapper for {@link jdk.nashorn.internal.objects.Global#newDataDescriptor(Object, boolean, boolean, boolean)} 31.184 - * 31.185 - * @param value data value 31.186 - * @param configurable is the described property configurable 31.187 - * @param enumerable is the described property enumerable 31.188 - * @param writable is the described property writable 31.189 - * 31.190 - * @return property descriptor 31.191 - */ 31.192 - public PropertyDescriptor newDataDescriptor(Object value, boolean configurable, boolean enumerable, boolean writable); 31.193 - 31.194 - /** 31.195 - * Wrapper for {@link jdk.nashorn.internal.objects.Global#newAccessorDescriptor(Object, Object, boolean, boolean)} 31.196 - * 31.197 - * @param get property getter, or null if none 31.198 - * @param set property setter, or null if none 31.199 - * @param configurable is the described property configurable 31.200 - * @param enumerable is the described property enumerable 31.201 - * 31.202 - * @return property descriptor 31.203 - */ 31.204 - public PropertyDescriptor newAccessorDescriptor(Object get, Object set, boolean configurable, boolean enumerable); 31.205 - 31.206 - /** 31.207 - * Wrapper for {@link jdk.nashorn.internal.objects.Global#getDefaultValue(ScriptObject, Class)} 31.208 - * 31.209 - * @param sobj script object 31.210 - * @param typeHint type hint 31.211 - * 31.212 - * @return default value 31.213 - */ 31.214 - public Object getDefaultValue(ScriptObject sobj, Class<?> typeHint); 31.215 - 31.216 - /** 31.217 - * Get cached InvokeByName object for the given key 31.218 - * @param key key to be associated with InvokeByName object 31.219 - * @param creator if InvokeByName is absent 'creator' is called to make one (lazy init) 31.220 - * @return InvokeByName object associated with the key. 31.221 - */ 31.222 - public InvokeByName getInvokeByName(final Object key, final Callable<InvokeByName> creator); 31.223 - 31.224 - /** 31.225 - * Get cached dynamic method handle for the given key 31.226 - * @param key key to be associated with dynamic method handle 31.227 - * @param creator if method handle is absent 'creator' is called to make one (lazy init) 31.228 - * @return dynamic method handle associated with the key. 31.229 - */ 31.230 - public MethodHandle getDynamicInvoker(final Object key, final Callable<MethodHandle> creator); 31.231 -}
32.1 --- a/src/jdk/nashorn/internal/runtime/JSONFunctions.java Thu Mar 13 15:58:24 2014 +0530 32.2 +++ b/src/jdk/nashorn/internal/runtime/JSONFunctions.java Mon Mar 17 18:02:00 2014 +0530 32.3 @@ -33,6 +33,7 @@ 32.4 import jdk.nashorn.internal.ir.ObjectNode; 32.5 import jdk.nashorn.internal.ir.PropertyNode; 32.6 import jdk.nashorn.internal.ir.UnaryNode; 32.7 +import jdk.nashorn.internal.objects.Global; 32.8 import jdk.nashorn.internal.parser.JSONParser; 32.9 import jdk.nashorn.internal.parser.TokenType; 32.10 import jdk.nashorn.internal.runtime.arrays.ArrayIndex; 32.11 @@ -47,7 +48,7 @@ 32.12 private static final Object REVIVER_INVOKER = new Object(); 32.13 32.14 private static MethodHandle getREVIVER_INVOKER() { 32.15 - return ((GlobalObject)Context.getGlobal()).getDynamicInvoker(REVIVER_INVOKER, 32.16 + return Context.getGlobal().getDynamicInvoker(REVIVER_INVOKER, 32.17 new Callable<MethodHandle>() { 32.18 @Override 32.19 public MethodHandle call() { 32.20 @@ -88,7 +89,7 @@ 32.21 throw ECMAErrors.syntaxError(e, "invalid.json", e.getMessage()); 32.22 } 32.23 32.24 - final ScriptObject global = Context.getGlobalTrusted(); 32.25 + final Global global = Context.getGlobal(); 32.26 Object unfiltered = convertNode(global, node); 32.27 return applyReviver(global, unfiltered, reviver); 32.28 } 32.29 @@ -98,10 +99,10 @@ 32.30 // parse helpers 32.31 32.32 // apply 'reviver' function if available 32.33 - private static Object applyReviver(final ScriptObject global, final Object unfiltered, final Object reviver) { 32.34 + private static Object applyReviver(final Global global, final Object unfiltered, final Object reviver) { 32.35 if (reviver instanceof ScriptFunction) { 32.36 - assert global instanceof GlobalObject; 32.37 - final ScriptObject root = ((GlobalObject)global).newObject(); 32.38 + assert global instanceof Global; 32.39 + final ScriptObject root = global.newObject(); 32.40 root.addOwnProperty("", Property.WRITABLE_ENUMERABLE_CONFIGURABLE, unfiltered); 32.41 return walk(root, "", (ScriptFunction)reviver); 32.42 } 32.43 @@ -138,8 +139,8 @@ 32.44 } 32.45 32.46 // Converts IR node to runtime value 32.47 - private static Object convertNode(final ScriptObject global, final Node node) { 32.48 - assert global instanceof GlobalObject; 32.49 + private static Object convertNode(final Global global, final Node node) { 32.50 + assert global instanceof Global; 32.51 32.52 if (node instanceof LiteralNode) { 32.53 // check for array literal 32.54 @@ -157,7 +158,7 @@ 32.55 for (final Node elem : elements) { 32.56 values[index++] = JSType.toNumber(convertNode(global, elem)); 32.57 } 32.58 - return ((GlobalObject)global).wrapAsObject(values); 32.59 + return global.wrapAsObject(values); 32.60 } 32.61 32.62 final Object[] values = new Object[elements.length]; 32.63 @@ -167,14 +168,14 @@ 32.64 values[index++] = convertNode(global, elem); 32.65 } 32.66 32.67 - return ((GlobalObject)global).wrapAsObject(values); 32.68 + return global.wrapAsObject(values); 32.69 } 32.70 32.71 return ((LiteralNode<?>)node).getValue(); 32.72 32.73 } else if (node instanceof ObjectNode) { 32.74 final ObjectNode objNode = (ObjectNode) node; 32.75 - final ScriptObject object = ((GlobalObject)global).newObject(); 32.76 + final ScriptObject object = global.newObject(); 32.77 32.78 for (final PropertyNode pNode: objNode.getElements()) { 32.79 final Node valueNode = pNode.getValue();
33.1 --- a/src/jdk/nashorn/internal/runtime/JSType.java Thu Mar 13 15:58:24 2014 +0530 33.2 +++ b/src/jdk/nashorn/internal/runtime/JSType.java Mon Mar 17 18:02:00 2014 +0530 33.3 @@ -36,6 +36,7 @@ 33.4 import jdk.internal.dynalink.beans.StaticClass; 33.5 import jdk.nashorn.api.scripting.JSObject; 33.6 import jdk.nashorn.internal.codegen.CompilerConstants.Call; 33.7 +import jdk.nashorn.internal.objects.Global; 33.8 import jdk.nashorn.internal.parser.Lexer; 33.9 import jdk.nashorn.internal.runtime.arrays.ArrayLikeIterator; 33.10 import jdk.nashorn.internal.runtime.linker.Bootstrap; 33.11 @@ -852,7 +853,7 @@ 33.12 * @return the wrapped object 33.13 */ 33.14 public static Object toScriptObject(final Object obj) { 33.15 - return toScriptObject(Context.getGlobalTrusted(), obj); 33.16 + return toScriptObject(Context.getGlobal(), obj); 33.17 } 33.18 33.19 /** 33.20 @@ -865,7 +866,7 @@ 33.21 * 33.22 * @return the wrapped object 33.23 */ 33.24 - public static Object toScriptObject(final ScriptObject global, final Object obj) { 33.25 + public static Object toScriptObject(final Global global, final Object obj) { 33.26 if (nullOrUndefined(obj)) { 33.27 throw typeError(global, "not.an.object", ScriptRuntime.safeToString(obj)); 33.28 } 33.29 @@ -874,7 +875,7 @@ 33.30 return obj; 33.31 } 33.32 33.33 - return ((GlobalObject)global).wrapAsObject(obj); 33.34 + return global.wrapAsObject(obj); 33.35 } 33.36 33.37 /** 33.38 @@ -984,7 +985,7 @@ 33.39 if (obj instanceof ScriptObject) { 33.40 if (safe) { 33.41 final ScriptObject sobj = (ScriptObject)obj; 33.42 - final GlobalObject gobj = (GlobalObject)Context.getGlobalTrusted(); 33.43 + final Global gobj = Context.getGlobal(); 33.44 return gobj.isError(sobj) ? 33.45 ECMAException.safeToString(sobj) : 33.46 sobj.safeToString();
34.1 --- a/src/jdk/nashorn/internal/runtime/ListAdapter.java Thu Mar 13 15:58:24 2014 +0530 34.2 +++ b/src/jdk/nashorn/internal/runtime/ListAdapter.java Mon Mar 17 18:02:00 2014 +0530 34.3 @@ -34,6 +34,7 @@ 34.4 import java.util.concurrent.Callable; 34.5 import jdk.nashorn.api.scripting.JSObject; 34.6 import jdk.nashorn.api.scripting.ScriptObjectMirror; 34.7 +import jdk.nashorn.internal.objects.Global; 34.8 import jdk.nashorn.internal.runtime.linker.Bootstrap; 34.9 import jdk.nashorn.internal.runtime.linker.InvokeByName; 34.10 34.11 @@ -54,7 +55,7 @@ 34.12 // These add to the back and front of the list 34.13 private static final Object PUSH = new Object(); 34.14 private static InvokeByName getPUSH() { 34.15 - return ((GlobalObject)Context.getGlobal()).getInvokeByName(PUSH, 34.16 + return Context.getGlobal().getInvokeByName(PUSH, 34.17 new Callable<InvokeByName>() { 34.18 @Override 34.19 public InvokeByName call() { 34.20 @@ -65,7 +66,7 @@ 34.21 34.22 private static final Object UNSHIFT = new Object(); 34.23 private static InvokeByName getUNSHIFT() { 34.24 - return ((GlobalObject)Context.getGlobal()).getInvokeByName(UNSHIFT, 34.25 + return Context.getGlobal().getInvokeByName(UNSHIFT, 34.26 new Callable<InvokeByName>() { 34.27 @Override 34.28 public InvokeByName call() { 34.29 @@ -77,7 +78,7 @@ 34.30 // These remove from the back and front of the list 34.31 private static final Object POP = new Object(); 34.32 private static InvokeByName getPOP() { 34.33 - return ((GlobalObject)Context.getGlobal()).getInvokeByName(POP, 34.34 + return Context.getGlobal().getInvokeByName(POP, 34.35 new Callable<InvokeByName>() { 34.36 @Override 34.37 public InvokeByName call() { 34.38 @@ -88,7 +89,7 @@ 34.39 34.40 private static final Object SHIFT = new Object(); 34.41 private static InvokeByName getSHIFT() { 34.42 - return ((GlobalObject)Context.getGlobal()).getInvokeByName(SHIFT, 34.43 + return Context.getGlobal().getInvokeByName(SHIFT, 34.44 new Callable<InvokeByName>() { 34.45 @Override 34.46 public InvokeByName call() { 34.47 @@ -100,7 +101,7 @@ 34.48 // These insert and remove in the middle of the list 34.49 private static final Object SPLICE_ADD = new Object(); 34.50 private static InvokeByName getSPLICE_ADD() { 34.51 - return ((GlobalObject)Context.getGlobal()).getInvokeByName(SPLICE_ADD, 34.52 + return Context.getGlobal().getInvokeByName(SPLICE_ADD, 34.53 new Callable<InvokeByName>() { 34.54 @Override 34.55 public InvokeByName call() { 34.56 @@ -111,7 +112,7 @@ 34.57 34.58 private static final Object SPLICE_REMOVE = new Object(); 34.59 private static InvokeByName getSPLICE_REMOVE() { 34.60 - return ((GlobalObject)Context.getGlobal()).getInvokeByName(SPLICE_REMOVE, 34.61 + return Context.getGlobal().getInvokeByName(SPLICE_REMOVE, 34.62 new Callable<InvokeByName>() { 34.63 @Override 34.64 public InvokeByName call() {
35.1 --- a/src/jdk/nashorn/internal/runtime/NativeJavaPackage.java Thu Mar 13 15:58:24 2014 +0530 35.2 +++ b/src/jdk/nashorn/internal/runtime/NativeJavaPackage.java Mon Mar 17 18:02:00 2014 +0530 35.3 @@ -35,7 +35,6 @@ 35.4 import jdk.internal.dynalink.support.Guards; 35.5 import jdk.nashorn.internal.lookup.MethodHandleFactory; 35.6 import jdk.nashorn.internal.lookup.MethodHandleFunctionality; 35.7 -import jdk.nashorn.internal.objects.NativeJava; 35.8 import jdk.nashorn.internal.objects.annotations.Attribute; 35.9 import jdk.nashorn.internal.objects.annotations.Function; 35.10 35.11 @@ -52,7 +51,7 @@ 35.12 * var ArrayList = java.util.ArrayList 35.13 * var list = new ArrayList 35.14 * </pre> 35.15 - * You can also use {@link NativeJava#type(Object, Object)} to access Java classes. These two statements are mostly 35.16 + * You can also use {@link jdk.nashorn.internal.objects.NativeJava#type(Object, Object)} to access Java classes. These two statements are mostly 35.17 * equivalent: 35.18 * <pre> 35.19 * var listType1 = java.util.ArrayList
36.1 --- a/src/jdk/nashorn/internal/runtime/ParserException.java Thu Mar 13 15:58:24 2014 +0530 36.2 +++ b/src/jdk/nashorn/internal/runtime/ParserException.java Mon Mar 17 18:02:00 2014 +0530 36.3 @@ -26,6 +26,7 @@ 36.4 package jdk.nashorn.internal.runtime; 36.5 36.6 import jdk.nashorn.api.scripting.NashornException; 36.7 +import jdk.nashorn.internal.objects.Global; 36.8 import jdk.nashorn.internal.parser.Token; 36.9 36.10 /** 36.11 @@ -110,7 +111,7 @@ 36.12 * Throw this {@code ParserException} as one of the 7 native JavaScript errors 36.13 * @param global global scope object 36.14 */ 36.15 - public void throwAsEcmaException(final ScriptObject global) { 36.16 + public void throwAsEcmaException(final Global global) { 36.17 throw ECMAErrors.asEcmaException(global, this); 36.18 } 36.19 }
37.1 --- a/src/jdk/nashorn/internal/runtime/ScriptFunction.java Thu Mar 13 15:58:24 2014 +0530 37.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptFunction.java Mon Mar 17 18:02:00 2014 +0530 37.3 @@ -38,6 +38,7 @@ 37.4 import jdk.internal.dynalink.linker.LinkRequest; 37.5 import jdk.nashorn.internal.codegen.CompilerConstants.Call; 37.6 import jdk.nashorn.internal.lookup.MethodHandleFactory; 37.7 +import jdk.nashorn.internal.objects.Global; 37.8 import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor; 37.9 import jdk.nashorn.internal.runtime.linker.NashornGuards; 37.10 37.11 @@ -475,14 +476,14 @@ 37.12 if (obj instanceof ScriptObject || !ScriptFunctionData.isPrimitiveThis(obj)) { 37.13 return obj; 37.14 } 37.15 - return ((GlobalObject)Context.getGlobalTrusted()).wrapAsObject(obj); 37.16 + return Context.getGlobal().wrapAsObject(obj); 37.17 } 37.18 37.19 37.20 @SuppressWarnings("unused") 37.21 private static Object globalFilter(final Object object) { 37.22 // replace whatever we get with the current global object 37.23 - return Context.getGlobalTrusted(); 37.24 + return Context.getGlobal(); 37.25 } 37.26 37.27 /**
38.1 --- a/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java Thu Mar 13 15:58:24 2014 +0530 38.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java Mon Mar 17 18:02:00 2014 +0530 38.3 @@ -32,6 +32,7 @@ 38.4 import java.lang.invoke.MethodHandle; 38.5 import java.lang.invoke.MethodHandles; 38.6 import java.lang.invoke.MethodType; 38.7 +import jdk.nashorn.internal.objects.Global; 38.8 import jdk.nashorn.internal.runtime.linker.JavaAdapterFactory; 38.9 38.10 /** 38.11 @@ -372,11 +373,11 @@ 38.12 private Object convertThisObject(final Object thiz) { 38.13 if (!(thiz instanceof ScriptObject) && needsWrappedThis()) { 38.14 if (JSType.nullOrUndefined(thiz)) { 38.15 - return Context.getGlobalTrusted(); 38.16 + return Context.getGlobal(); 38.17 } 38.18 38.19 if (isPrimitiveThis(thiz)) { 38.20 - return ((GlobalObject)Context.getGlobalTrusted()).wrapAsObject(thiz); 38.21 + return Context.getGlobal().wrapAsObject(thiz); 38.22 } 38.23 } 38.24
39.1 --- a/src/jdk/nashorn/internal/runtime/ScriptObject.java Thu Mar 13 15:58:24 2014 +0530 39.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java Mon Mar 17 18:02:00 2014 +0530 39.3 @@ -325,18 +325,18 @@ 39.4 * @return property descriptor 39.5 */ 39.6 public final PropertyDescriptor toPropertyDescriptor() { 39.7 - final GlobalObject global = (GlobalObject) Context.getGlobalTrusted(); 39.8 + final Global global = Context.getGlobal(); 39.9 39.10 final PropertyDescriptor desc; 39.11 if (isDataDescriptor()) { 39.12 if (has(SET) || has(GET)) { 39.13 - throw typeError((ScriptObject)global, "inconsistent.property.descriptor"); 39.14 + throw typeError(global, "inconsistent.property.descriptor"); 39.15 } 39.16 39.17 desc = global.newDataDescriptor(UNDEFINED, false, false, false); 39.18 } else if (isAccessorDescriptor()) { 39.19 if (has(VALUE) || has(WRITABLE)) { 39.20 - throw typeError((ScriptObject)global, "inconsistent.property.descriptor"); 39.21 + throw typeError(global, "inconsistent.property.descriptor"); 39.22 } 39.23 39.24 desc = global.newAccessorDescriptor(UNDEFINED, UNDEFINED, false, false); 39.25 @@ -355,7 +355,7 @@ 39.26 * 39.27 * @return property descriptor 39.28 */ 39.29 - public static PropertyDescriptor toPropertyDescriptor(final ScriptObject global, final Object obj) { 39.30 + public static PropertyDescriptor toPropertyDescriptor(final Global global, final Object obj) { 39.31 if (obj instanceof ScriptObject) { 39.32 return ((ScriptObject)obj).toPropertyDescriptor(); 39.33 } 39.34 @@ -374,7 +374,7 @@ 39.35 public Object getOwnPropertyDescriptor(final String key) { 39.36 final Property property = getMap().findProperty(key); 39.37 39.38 - final GlobalObject global = (GlobalObject)Context.getGlobalTrusted(); 39.39 + final Global global = Context.getGlobal(); 39.40 39.41 if (property != null) { 39.42 final ScriptFunction get = property.getGetterFunction(this); 39.43 @@ -439,7 +439,7 @@ 39.44 * @return true if property was successfully defined 39.45 */ 39.46 public boolean defineOwnProperty(final String key, final Object propertyDesc, final boolean reject) { 39.47 - final ScriptObject global = Context.getGlobalTrusted(); 39.48 + final Global global = Context.getGlobal(); 39.49 final PropertyDescriptor desc = toPropertyDescriptor(global, propertyDesc); 39.50 final Object current = getOwnPropertyDescriptor(key); 39.51 final String name = JSType.toString(key); 39.52 @@ -637,7 +637,7 @@ 39.53 final int propFlags = Property.toFlags(pdesc); 39.54 39.55 if (pdesc.type() == PropertyDescriptor.GENERIC) { 39.56 - final GlobalObject global = (GlobalObject) Context.getGlobalTrusted(); 39.57 + final Global global = Context.getGlobal(); 39.58 final PropertyDescriptor dDesc = global.newDataDescriptor(UNDEFINED, false, false, false); 39.59 39.60 dDesc.fillFrom((ScriptObject)pdesc); 39.61 @@ -1150,7 +1150,7 @@ 39.62 } 39.63 setProto((ScriptObject)newProto); 39.64 } else { 39.65 - final ScriptObject global = Context.getGlobalTrusted(); 39.66 + final Global global = Context.getGlobal(); 39.67 final Object newProtoObject = JSType.toScriptObject(global, newProto); 39.68 39.69 if (newProtoObject instanceof ScriptObject) { 39.70 @@ -1240,11 +1240,11 @@ 39.71 * @return the default value 39.72 */ 39.73 public Object getDefaultValue(final Class<?> typeHint) { 39.74 - // We delegate to GlobalObject, as the implementation uses dynamic call sites to invoke object's "toString" and 39.75 + // We delegate to Global, as the implementation uses dynamic call sites to invoke object's "toString" and 39.76 // "valueOf" methods, and in order to avoid those call sites from becoming megamorphic when multiple contexts 39.77 // are being executed in a long-running program, we move the code and their associated dynamic call sites 39.78 // (Global.TO_STRING and Global.VALUE_OF) into per-context code. 39.79 - return ((GlobalObject)Context.getGlobalTrusted()).getDefaultValue(this, typeHint); 39.80 + return Context.getGlobal().getDefaultValue(this, typeHint); 39.81 } 39.82 39.83 /**
40.1 --- a/src/jdk/nashorn/internal/runtime/ScriptRuntime.java Thu Mar 13 15:58:24 2014 +0530 40.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptRuntime.java Mon Mar 17 18:02:00 2014 +0530 40.3 @@ -474,7 +474,7 @@ 40.4 * @return {@link WithObject} that is the new scope 40.5 */ 40.6 public static ScriptObject openWith(final ScriptObject scope, final Object expression) { 40.7 - final ScriptObject global = Context.getGlobalTrusted(); 40.8 + final Global global = Context.getGlobal(); 40.9 if (expression == UNDEFINED) { 40.10 throw typeError(global, "cant.apply.with.to.undefined"); 40.11 } else if (expression == null) {
41.1 --- a/src/jdk/nashorn/internal/runtime/SetMethodCreator.java Thu Mar 13 15:58:24 2014 +0530 41.2 +++ b/src/jdk/nashorn/internal/runtime/SetMethodCreator.java Mon Mar 17 18:02:00 2014 +0530 41.3 @@ -148,7 +148,7 @@ 41.4 } 41.5 41.6 private SetMethod createGlobalPropertySetter() { 41.7 - final ScriptObject global = Context.getGlobalTrusted(); 41.8 + final ScriptObject global = Context.getGlobal(); 41.9 return new SetMethod(MH.filterArguments(global.addSpill(getName()), 0, ScriptObject.GLOBALFILTER), null); 41.10 } 41.11
42.1 --- a/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java Thu Mar 13 15:58:24 2014 +0530 42.2 +++ b/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java Mon Mar 17 18:02:00 2014 +0530 42.3 @@ -34,6 +34,7 @@ 42.4 import jdk.nashorn.internal.runtime.linker.Bootstrap; 42.5 42.6 import static jdk.nashorn.internal.codegen.CompilerConstants.staticCall; 42.7 +import jdk.nashorn.internal.objects.Global; 42.8 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; 42.9 import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED; 42.10 42.11 @@ -73,7 +74,7 @@ 42.12 42.13 private static MethodHandle getINVOKE_UA_GETTER() { 42.14 42.15 - return ((GlobalObject)Context.getGlobal()).getDynamicInvoker(INVOKE_UA_GETTER, 42.16 + return Context.getGlobal().getDynamicInvoker(INVOKE_UA_GETTER, 42.17 new Callable<MethodHandle>() { 42.18 @Override 42.19 public MethodHandle call() { 42.20 @@ -86,7 +87,7 @@ 42.21 /** Dynamic invoker for setter */ 42.22 private static Object INVOKE_UA_SETTER = new Object(); 42.23 private static MethodHandle getINVOKE_UA_SETTER() { 42.24 - return ((GlobalObject)Context.getGlobal()).getDynamicInvoker(INVOKE_UA_SETTER, 42.25 + return Context.getGlobal().getDynamicInvoker(INVOKE_UA_SETTER, 42.26 new Callable<MethodHandle>() { 42.27 @Override 42.28 public MethodHandle call() {
43.1 --- a/src/jdk/nashorn/internal/runtime/arrays/ArrayData.java Thu Mar 13 15:58:24 2014 +0530 43.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/ArrayData.java Mon Mar 17 18:02:00 2014 +0530 43.3 @@ -27,7 +27,7 @@ 43.4 43.5 import java.lang.invoke.MethodHandle; 43.6 import java.nio.ByteBuffer; 43.7 -import jdk.nashorn.internal.runtime.GlobalObject; 43.8 +import jdk.nashorn.internal.objects.Global; 43.9 import jdk.nashorn.internal.runtime.JSType; 43.10 import jdk.nashorn.internal.runtime.PropertyDescriptor; 43.11 43.12 @@ -399,7 +399,7 @@ 43.13 * 43.14 * @return property descriptor for element 43.15 */ 43.16 - public PropertyDescriptor getDescriptor(final GlobalObject global, final int index) { 43.17 + public PropertyDescriptor getDescriptor(final Global global, final int index) { 43.18 return global.newDataDescriptor(getObject(index), true, true, true); 43.19 } 43.20
44.1 --- a/src/jdk/nashorn/internal/runtime/arrays/ByteBufferArrayData.java Thu Mar 13 15:58:24 2014 +0530 44.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/ByteBufferArrayData.java Mon Mar 17 18:02:00 2014 +0530 44.3 @@ -27,7 +27,7 @@ 44.4 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; 44.5 44.6 import java.nio.ByteBuffer; 44.7 -import jdk.nashorn.internal.runtime.GlobalObject; 44.8 +import jdk.nashorn.internal.objects.Global; 44.9 import jdk.nashorn.internal.runtime.PropertyDescriptor; 44.10 import jdk.nashorn.internal.runtime.ScriptRuntime; 44.11 44.12 @@ -60,7 +60,8 @@ 44.13 * 44.14 * @return property descriptor for element 44.15 */ 44.16 - public PropertyDescriptor getDescriptor(final GlobalObject global, final int index) { 44.17 + @Override 44.18 + public PropertyDescriptor getDescriptor(final Global global, final int index) { 44.19 // make the index properties not configurable 44.20 return global.newDataDescriptor(getObject(index), false, true, true); 44.21 }
45.1 --- a/src/jdk/nashorn/internal/runtime/arrays/FrozenArrayFilter.java Thu Mar 13 15:58:24 2014 +0530 45.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/FrozenArrayFilter.java Mon Mar 17 18:02:00 2014 +0530 45.3 @@ -25,9 +25,9 @@ 45.4 45.5 package jdk.nashorn.internal.runtime.arrays; 45.6 45.7 +import jdk.nashorn.internal.objects.Global; 45.8 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; 45.9 45.10 -import jdk.nashorn.internal.runtime.GlobalObject; 45.11 import jdk.nashorn.internal.runtime.PropertyDescriptor; 45.12 45.13 /** 45.14 @@ -44,7 +44,7 @@ 45.15 } 45.16 45.17 @Override 45.18 - public PropertyDescriptor getDescriptor(final GlobalObject global, final int index) { 45.19 + public PropertyDescriptor getDescriptor(final Global global, final int index) { 45.20 return global.newDataDescriptor(getObject(index), false, true, false); 45.21 } 45.22
46.1 --- a/src/jdk/nashorn/internal/runtime/arrays/SealedArrayFilter.java Thu Mar 13 15:58:24 2014 +0530 46.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/SealedArrayFilter.java Mon Mar 17 18:02:00 2014 +0530 46.3 @@ -25,9 +25,9 @@ 46.4 46.5 package jdk.nashorn.internal.runtime.arrays; 46.6 46.7 +import jdk.nashorn.internal.objects.Global; 46.8 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; 46.9 46.10 -import jdk.nashorn.internal.runtime.GlobalObject; 46.11 import jdk.nashorn.internal.runtime.PropertyDescriptor; 46.12 46.13 /** 46.14 @@ -62,7 +62,7 @@ 46.15 } 46.16 46.17 @Override 46.18 - public PropertyDescriptor getDescriptor(final GlobalObject global, final int index) { 46.19 + public PropertyDescriptor getDescriptor(final Global global, final int index) { 46.20 return global.newDataDescriptor(getObject(index), false, true, true); 46.21 } 46.22 }
47.1 --- a/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java Thu Mar 13 15:58:24 2014 +0530 47.2 +++ b/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java Mon Mar 17 18:02:00 2014 +0530 47.3 @@ -64,6 +64,7 @@ 47.4 import jdk.internal.org.objectweb.asm.Opcodes; 47.5 import jdk.internal.org.objectweb.asm.Type; 47.6 import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; 47.7 +import jdk.nashorn.internal.objects.Global; 47.8 import jdk.nashorn.internal.runtime.Context; 47.9 import jdk.nashorn.internal.runtime.ScriptFunction; 47.10 import jdk.nashorn.internal.runtime.ScriptObject; 47.11 @@ -134,6 +135,7 @@ 47.12 static final Type CONTEXT_TYPE = Type.getType(Context.class); 47.13 static final Type OBJECT_TYPE = Type.getType(Object.class); 47.14 static final Type SCRIPT_OBJECT_TYPE = Type.getType(ScriptObject.class); 47.15 + static final Type GLOBAL_TYPE = Type.getType(Global.class); 47.16 47.17 static final String CONTEXT_TYPE_NAME = CONTEXT_TYPE.getInternalName(); 47.18 static final String OBJECT_TYPE_NAME = OBJECT_TYPE.getInternalName(); 47.19 @@ -143,8 +145,10 @@ 47.20 static final String GLOBAL_FIELD_NAME = "global"; 47.21 47.22 static final String SCRIPT_OBJECT_TYPE_DESCRIPTOR = SCRIPT_OBJECT_TYPE.getDescriptor(); 47.23 + static final String GLOBAL_TYPE_DESCRIPTOR = GLOBAL_TYPE.getDescriptor(); 47.24 47.25 - static final String SET_GLOBAL_METHOD_DESCRIPTOR = Type.getMethodDescriptor(Type.VOID_TYPE, SCRIPT_OBJECT_TYPE); 47.26 + 47.27 + static final String SET_GLOBAL_METHOD_DESCRIPTOR = Type.getMethodDescriptor(Type.VOID_TYPE, GLOBAL_TYPE); 47.28 static final String VOID_NOARG_METHOD_DESCRIPTOR = Type.getMethodDescriptor(Type.VOID_TYPE); 47.29 47.30 private static final Type SCRIPT_FUNCTION_TYPE = Type.getType(ScriptFunction.class); 47.31 @@ -167,7 +171,7 @@ 47.32 private static final String UNSUPPORTED_OPERATION_TYPE_NAME = UNSUPPORTED_OPERATION_TYPE.getInternalName(); 47.33 47.34 private static final String METHOD_HANDLE_TYPE_DESCRIPTOR = METHOD_HANDLE_TYPE.getDescriptor(); 47.35 - private static final String GET_GLOBAL_METHOD_DESCRIPTOR = Type.getMethodDescriptor(SCRIPT_OBJECT_TYPE); 47.36 + private static final String GET_GLOBAL_METHOD_DESCRIPTOR = Type.getMethodDescriptor(GLOBAL_TYPE); 47.37 private static final String GET_CLASS_METHOD_DESCRIPTOR = Type.getMethodDescriptor(Type.getType(Class.class)); 47.38 47.39 // Package used when the adapter can't be defined in the adaptee's package (either because it's sealed, or because 47.40 @@ -259,7 +263,7 @@ 47.41 } 47.42 47.43 private void generateGlobalFields() { 47.44 - cw.visitField(ACC_PRIVATE | ACC_FINAL | (classOverride ? ACC_STATIC : 0), GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR, null, null).visitEnd(); 47.45 + cw.visitField(ACC_PRIVATE | ACC_FINAL | (classOverride ? ACC_STATIC : 0), GLOBAL_FIELD_NAME, GLOBAL_TYPE_DESCRIPTOR, null, null).visitEnd(); 47.46 usedFieldNames.add(GLOBAL_FIELD_NAME); 47.47 } 47.48 47.49 @@ -363,7 +367,7 @@ 47.50 } 47.51 // Assign "global = Context.getGlobal()" 47.52 invokeGetGlobalWithNullCheck(mv); 47.53 - mv.putstatic(generatedClassName, GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR); 47.54 + mv.putstatic(generatedClassName, GLOBAL_FIELD_NAME, GLOBAL_TYPE_DESCRIPTOR); 47.55 47.56 endInitMethod(mv); 47.57 } 47.58 @@ -508,7 +512,7 @@ 47.59 // Assign "this.global = Context.getGlobal()" 47.60 mv.visitVarInsn(ALOAD, 0); 47.61 invokeGetGlobalWithNullCheck(mv); 47.62 - mv.putfield(generatedClassName, GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR); 47.63 + mv.putfield(generatedClassName, GLOBAL_FIELD_NAME, GLOBAL_TYPE_DESCRIPTOR); 47.64 47.65 endInitMethod(mv); 47.66 } 47.67 @@ -652,10 +656,10 @@ 47.68 // Load the creatingGlobal object 47.69 if(classOverride) { 47.70 // If class handle is defined, load the static defining global 47.71 - mv.getstatic(generatedClassName, GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR); 47.72 + mv.getstatic(generatedClassName, GLOBAL_FIELD_NAME, GLOBAL_TYPE_DESCRIPTOR); 47.73 } else { 47.74 mv.visitVarInsn(ALOAD, 0); 47.75 - mv.getfield(generatedClassName, GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR); 47.76 + mv.getfield(generatedClassName, GLOBAL_FIELD_NAME, GLOBAL_TYPE_DESCRIPTOR); 47.77 } 47.78 // stack: [creatingGlobal, handle] 47.79 final Label setupGlobal = new Label(); 47.80 @@ -674,7 +678,7 @@ 47.81 // stack: [creatingGlobal, creatingGlobal, handle] 47.82 47.83 // Emit code for switching to the creating global 47.84 - // ScriptObject currentGlobal = Context.getGlobal(); 47.85 + // Global currentGlobal = Context.getGlobal(); 47.86 invokeGetGlobal(mv); 47.87 mv.dup(); 47.88 47.89 @@ -744,7 +748,7 @@ 47.90 final Label methodEnd = new Label(); 47.91 mv.visitLabel(methodEnd); 47.92 47.93 - mv.visitLocalVariable("currentGlobal", SCRIPT_OBJECT_TYPE_DESCRIPTOR, null, setupGlobal, methodEnd, currentGlobalVar); 47.94 + mv.visitLocalVariable("currentGlobal", GLOBAL_TYPE_DESCRIPTOR, null, setupGlobal, methodEnd, currentGlobalVar); 47.95 mv.visitLocalVariable("globalsDiffer", Type.INT_TYPE.getDescriptor(), null, setupGlobal, methodEnd, globalsDifferVar); 47.96 47.97 if(throwableDeclared) {
48.1 --- a/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java Thu Mar 13 15:58:24 2014 +0530 48.2 +++ b/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java Mon Mar 17 18:02:00 2014 +0530 48.3 @@ -48,7 +48,6 @@ 48.4 import java.util.concurrent.ConcurrentHashMap; 48.5 import jdk.internal.dynalink.beans.StaticClass; 48.6 import jdk.internal.dynalink.support.LinkRequestImpl; 48.7 -import jdk.nashorn.internal.objects.NativeJava; 48.8 import jdk.nashorn.internal.runtime.Context; 48.9 import jdk.nashorn.internal.runtime.ECMAException; 48.10 import jdk.nashorn.internal.runtime.ScriptFunction; 48.11 @@ -68,8 +67,8 @@ 48.12 * generate the adapter class itself; see its documentation for details about the generated class. 48.13 * </p><p> 48.14 * You normally don't use this class directly, but rather either create adapters from script using 48.15 - * {@link NativeJava#extend(Object, Object...)}, using the {@code new} operator on abstract classes and interfaces (see 48.16 - * {@link NativeJava#type(Object, Object)}), or implicitly when passing script functions to Java methods expecting SAM 48.17 + * {@link jdk.nashorn.internal.objects.NativeJava#extend(Object, Object...)}, using the {@code new} operator on abstract classes and interfaces (see 48.18 + * {@link jdk.nashorn.internal.objects.NativeJava#type(Object, Object)}), or implicitly when passing script functions to Java methods expecting SAM 48.19 * types. 48.20 * </p> 48.21 */ 48.22 @@ -337,6 +336,7 @@ 48.23 private static ProtectionDomain createMinimalPermissionDomain() { 48.24 // Generated classes need to have at least the permission to access Nashorn runtime and runtime.linker packages. 48.25 final Permissions permissions = new Permissions(); 48.26 + permissions.add(new RuntimePermission("accessClassInPackage.jdk.nashorn.internal.objects")); 48.27 permissions.add(new RuntimePermission("accessClassInPackage.jdk.nashorn.internal.runtime")); 48.28 permissions.add(new RuntimePermission("accessClassInPackage.jdk.nashorn.internal.runtime.linker")); 48.29 return new ProtectionDomain(new CodeSource(null, (CodeSigner[])null), permissions);
49.1 --- a/src/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java Thu Mar 13 15:58:24 2014 +0530 49.2 +++ b/src/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java Mon Mar 17 18:02:00 2014 +0530 49.3 @@ -37,9 +37,9 @@ 49.4 import jdk.internal.dynalink.linker.LinkerServices; 49.5 import jdk.internal.dynalink.linker.TypeBasedGuardingDynamicLinker; 49.6 import jdk.internal.dynalink.support.TypeUtilities; 49.7 +import jdk.nashorn.internal.objects.Global; 49.8 import jdk.nashorn.internal.runtime.ConsString; 49.9 import jdk.nashorn.internal.runtime.Context; 49.10 -import jdk.nashorn.internal.runtime.GlobalObject; 49.11 49.12 /** 49.13 * Internal linker for String, Boolean, and Number objects, only ever used by Nashorn engine and not exposed to other 49.14 @@ -62,7 +62,7 @@ 49.15 final LinkRequest request = origRequest.withoutRuntimeContext(); // Nashorn has no runtime context 49.16 49.17 final Object self = request.getReceiver(); 49.18 - final GlobalObject global = (GlobalObject) Context.getGlobal(); 49.19 + final Global global = Context.getGlobal(); 49.20 final NashornCallSiteDescriptor desc = (NashornCallSiteDescriptor) request.getCallSiteDescriptor(); 49.21 49.22 return Bootstrap.asType(global.primitiveLookup(request, self), linkerServices, desc);
50.1 --- a/src/jdk/nashorn/tools/Shell.java Thu Mar 13 15:58:24 2014 +0530 50.2 +++ b/src/jdk/nashorn/tools/Shell.java Mon Mar 17 18:02:00 2014 +0530 50.3 @@ -42,6 +42,7 @@ 50.4 import jdk.nashorn.internal.ir.FunctionNode; 50.5 import jdk.nashorn.internal.ir.debug.ASTWriter; 50.6 import jdk.nashorn.internal.ir.debug.PrintVisitor; 50.7 +import jdk.nashorn.internal.objects.Global; 50.8 import jdk.nashorn.internal.parser.Parser; 50.9 import jdk.nashorn.internal.runtime.Context; 50.10 import jdk.nashorn.internal.runtime.ErrorManager; 50.11 @@ -148,7 +149,7 @@ 50.12 return COMMANDLINE_ERROR; 50.13 } 50.14 50.15 - final ScriptObject global = context.createGlobal(); 50.16 + final Global global = context.createGlobal(); 50.17 final ScriptEnvironment env = context.getEnv(); 50.18 final List<String> files = env.getFiles(); 50.19 if (files.isEmpty()) { 50.20 @@ -231,8 +232,8 @@ 50.21 * @return error code 50.22 * @throws IOException when any script file read results in I/O error 50.23 */ 50.24 - private static int compileScripts(final Context context, final ScriptObject global, final List<String> files) throws IOException { 50.25 - final ScriptObject oldGlobal = Context.getGlobal(); 50.26 + private static int compileScripts(final Context context, final Global global, final List<String> files) throws IOException { 50.27 + final Global oldGlobal = Context.getGlobal(); 50.28 final boolean globalChanged = (oldGlobal != global); 50.29 final ScriptEnvironment env = context.getEnv(); 50.30 try { 50.31 @@ -281,8 +282,8 @@ 50.32 * @return error code 50.33 * @throws IOException when any script file read results in I/O error 50.34 */ 50.35 - private int runScripts(final Context context, final ScriptObject global, final List<String> files) throws IOException { 50.36 - final ScriptObject oldGlobal = Context.getGlobal(); 50.37 + private int runScripts(final Context context, final Global global, final List<String> files) throws IOException { 50.38 + final Global oldGlobal = Context.getGlobal(); 50.39 final boolean globalChanged = (oldGlobal != global); 50.40 try { 50.41 if (globalChanged) { 50.42 @@ -339,8 +340,8 @@ 50.43 * @return error code 50.44 * @throws IOException when any script file read results in I/O error 50.45 */ 50.46 - private static int runFXScripts(final Context context, final ScriptObject global, final List<String> files) throws IOException { 50.47 - final ScriptObject oldGlobal = Context.getGlobal(); 50.48 + private static int runFXScripts(final Context context, final Global global, final List<String> files) throws IOException { 50.49 + final Global oldGlobal = Context.getGlobal(); 50.50 final boolean globalChanged = (oldGlobal != global); 50.51 try { 50.52 if (globalChanged) { 50.53 @@ -389,11 +390,11 @@ 50.54 * @return return code 50.55 */ 50.56 @SuppressWarnings("resource") 50.57 - private static int readEvalPrint(final Context context, final ScriptObject global) { 50.58 + private static int readEvalPrint(final Context context, final Global global) { 50.59 final String prompt = bundle.getString("shell.prompt"); 50.60 final BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); 50.61 final PrintWriter err = context.getErr(); 50.62 - final ScriptObject oldGlobal = Context.getGlobal(); 50.63 + final Global oldGlobal = Context.getGlobal(); 50.64 final boolean globalChanged = (oldGlobal != global); 50.65 final ScriptEnvironment env = context.getEnv(); 50.66
51.1 --- a/test/src/jdk/nashorn/internal/codegen/CompilerTest.java Thu Mar 13 15:58:24 2014 +0530 51.2 +++ b/test/src/jdk/nashorn/internal/codegen/CompilerTest.java Mon Mar 17 18:02:00 2014 +0530 51.3 @@ -28,6 +28,7 @@ 51.4 import java.io.File; 51.5 import java.io.PrintWriter; 51.6 import java.io.StringWriter; 51.7 +import jdk.nashorn.internal.objects.Global; 51.8 import jdk.nashorn.internal.runtime.Context; 51.9 import jdk.nashorn.internal.runtime.ErrorManager; 51.10 import jdk.nashorn.internal.runtime.ScriptFunction; 51.11 @@ -58,7 +59,7 @@ 51.12 } 51.13 51.14 private Context context; 51.15 - private ScriptObject global; 51.16 + private Global global; 51.17 51.18 @BeforeClass 51.19 public void setupTest() { 51.20 @@ -146,7 +147,7 @@ 51.21 log("Begin compiling " + file.getAbsolutePath()); 51.22 } 51.23 51.24 - final ScriptObject oldGlobal = Context.getGlobal(); 51.25 + final Global oldGlobal = Context.getGlobal(); 51.26 final boolean globalChanged = (oldGlobal != global); 51.27 51.28 try {
52.1 --- a/test/src/jdk/nashorn/internal/performance/PerformanceWrapper.java Thu Mar 13 15:58:24 2014 +0530 52.2 +++ b/test/src/jdk/nashorn/internal/performance/PerformanceWrapper.java Mon Mar 17 18:02:00 2014 +0530 52.3 @@ -31,9 +31,9 @@ 52.4 import java.util.concurrent.Future; 52.5 import java.util.concurrent.TimeUnit; 52.6 import java.util.concurrent.TimeoutException; 52.7 +import jdk.nashorn.internal.objects.Global; 52.8 import jdk.nashorn.internal.runtime.Context; 52.9 import jdk.nashorn.internal.runtime.ScriptFunction; 52.10 -import jdk.nashorn.internal.runtime.ScriptObject; 52.11 import jdk.nashorn.internal.runtime.ScriptRuntime; 52.12 52.13 /** 52.14 @@ -89,7 +89,7 @@ 52.15 @Override 52.16 protected Object apply(final ScriptFunction target, final Object self) { 52.17 if (_runsPerIteration == 0 && _numberOfIterations == 0) { 52.18 - final ScriptObject global = jdk.nashorn.internal.runtime.Context.getGlobal(); 52.19 + final Global global = jdk.nashorn.internal.runtime.Context.getGlobal(); 52.20 final ScriptFunction _target = target; 52.21 final Object _self = self; 52.22
53.1 --- a/test/src/jdk/nashorn/internal/runtime/ContextTest.java Thu Mar 13 15:58:24 2014 +0530 53.2 +++ b/test/src/jdk/nashorn/internal/runtime/ContextTest.java Mon Mar 17 18:02:00 2014 +0530 53.3 @@ -29,6 +29,7 @@ 53.4 import static org.testng.Assert.assertTrue; 53.5 53.6 import java.util.Map; 53.7 +import jdk.nashorn.internal.objects.Global; 53.8 import jdk.nashorn.internal.runtime.options.Options; 53.9 import org.testng.annotations.Test; 53.10 53.11 @@ -45,7 +46,7 @@ 53.12 final Options options = new Options(""); 53.13 final ErrorManager errors = new ErrorManager(); 53.14 final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader()); 53.15 - final ScriptObject oldGlobal = Context.getGlobal(); 53.16 + final Global oldGlobal = Context.getGlobal(); 53.17 Context.setGlobal(cx.createGlobal()); 53.18 try { 53.19 String code = "22 + 10"; 53.20 @@ -65,7 +66,7 @@ 53.21 final ErrorManager errors = new ErrorManager(); 53.22 final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader()); 53.23 final boolean strict = cx.getEnv()._strict; 53.24 - final ScriptObject oldGlobal = Context.getGlobal(); 53.25 + final Global oldGlobal = Context.getGlobal(); 53.26 Context.setGlobal(cx.createGlobal()); 53.27 53.28 try {
54.1 --- a/test/src/jdk/nashorn/internal/test/framework/SharedContextEvaluator.java Thu Mar 13 15:58:24 2014 +0530 54.2 +++ b/test/src/jdk/nashorn/internal/test/framework/SharedContextEvaluator.java Mon Mar 17 18:02:00 2014 +0530 54.3 @@ -34,10 +34,10 @@ 54.4 import java.io.OutputStream; 54.5 import java.io.PrintWriter; 54.6 import jdk.nashorn.api.scripting.NashornException; 54.7 +import jdk.nashorn.internal.objects.Global; 54.8 import jdk.nashorn.internal.runtime.Context; 54.9 import jdk.nashorn.internal.runtime.ErrorManager; 54.10 import jdk.nashorn.internal.runtime.ScriptFunction; 54.11 -import jdk.nashorn.internal.runtime.ScriptObject; 54.12 import jdk.nashorn.internal.runtime.ScriptRuntime; 54.13 import jdk.nashorn.internal.runtime.Source; 54.14 import jdk.nashorn.internal.runtime.options.Options; 54.15 @@ -110,12 +110,12 @@ 54.16 54.17 @Override 54.18 public int run(final OutputStream out, final OutputStream err, final String[] args) throws IOException { 54.19 - final ScriptObject oldGlobal = Context.getGlobal(); 54.20 + final Global oldGlobal = Context.getGlobal(); 54.21 try { 54.22 ctxOut.setDelegatee(out); 54.23 ctxErr.setDelegatee(err); 54.24 final ErrorManager errors = context.getErrorManager(); 54.25 - final ScriptObject global = context.createGlobal(); 54.26 + final Global global = context.createGlobal(); 54.27 Context.setGlobal(global); 54.28 54.29 // For each file on the command line.