Fri, 05 Jul 2013 14:38:04 +0530
8019947: inherited property invalidation does not work with two globals in same context
Reviewed-by: jlaskey, lagergren, hannesw, attila
1.1 --- a/make/build-nasgen.xml Thu Jul 04 17:28:04 2013 +0200 1.2 +++ b/make/build-nasgen.xml Fri Jul 05 14:38:04 2013 +0530 1.3 @@ -42,11 +42,6 @@ 1.4 <arg value="jdk.nashorn.internal.objects"/> 1.5 <arg value="${basedir}/build/classes"/> 1.6 </java> 1.7 - 1.8 - <move todir="${basedir}/build/classes/jdk/nashorn/internal/objects"> 1.9 - <fileset dir="${basedir}/build/classes/jdk/nashorn/internal/objects"/> 1.10 - <mapper type="glob" from="*.class" to="*.clazz"/> 1.11 - </move> 1.12 </target> 1.13 1.14 <target name="run-nasgen-eclipse"> 1.15 @@ -66,7 +61,6 @@ 1.16 <fileset dir="${basedir}/build/eclipse/.nasgentmp/jdk/nashorn/internal/objects"> 1.17 <include name="*.class"/> 1.18 </fileset> 1.19 - <mapper type="glob" from="*.class" to="*.clazz"/> 1.20 </move> 1.21 1.22 <delete includeemptydirs="true"><fileset dir="${basedir}/build/eclipse/.nasgentmp" includes="**"/></delete> 1.23 @@ -75,7 +69,6 @@ 1.24 <fileset dir="${basedir}/build/eclipse/jdk/nashorn/internal/objects"> 1.25 <include name="**/*.class"/> 1.26 </fileset> 1.27 - <mapper type="glob" from="*.class" to="*.clazz"/> 1.28 </copy> 1.29 </target> 1.30
2.1 --- a/make/build.xml Thu Jul 04 17:28:04 2013 +0200 2.2 +++ b/make/build.xml Fri Jul 05 14:38:04 2013 +0530 2.3 @@ -100,7 +100,8 @@ 2.4 target="${javac.target}" 2.5 debug="${javac.debug}" 2.6 encoding="${javac.encoding}" 2.7 - includeantruntime="false"> 2.8 + includeantruntime="false" fork="true"> 2.9 + <compilerarg value="-J-Djava.ext.dirs="/> 2.10 <compilerarg value="-Xlint:unchecked"/> 2.11 <compilerarg value="-Xlint:deprecation"/> 2.12 <compilerarg value="-XDignore.symbol.file"/>
3.1 --- a/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java Thu Jul 04 17:28:04 2013 +0200 3.2 +++ b/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java Fri Jul 05 14:38:04 2013 +0530 3.3 @@ -308,9 +308,9 @@ 3.4 public void putAll(final Map<? extends String, ? extends Object> map) { 3.5 final ScriptObject oldGlobal = NashornScriptEngine.getNashornGlobal(); 3.6 final boolean globalChanged = (oldGlobal != global); 3.7 - final boolean strict = sobj.isStrictContext(); 3.8 inGlobal(new Callable<Object>() { 3.9 @Override public Object call() { 3.10 + final boolean strict = global.isStrictContext(); 3.11 for (final Map.Entry<? extends String, ? extends Object> entry : map.entrySet()) { 3.12 final Object value = entry.getValue(); 3.13 final Object modValue = globalChanged? wrap(value, oldGlobal) : value;
4.1 --- a/src/jdk/nashorn/internal/codegen/CodeGenerator.java Thu Jul 04 17:28:04 2013 +0200 4.2 +++ b/src/jdk/nashorn/internal/codegen/CodeGenerator.java Fri Jul 05 14:38:04 2013 +0530 4.3 @@ -109,6 +109,8 @@ 4.4 import jdk.nashorn.internal.ir.debug.ASTWriter; 4.5 import jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor; 4.6 import jdk.nashorn.internal.ir.visitor.NodeVisitor; 4.7 +import jdk.nashorn.internal.objects.Global; 4.8 +import jdk.nashorn.internal.objects.ScriptFunctionImpl; 4.9 import jdk.nashorn.internal.parser.Lexer.RegexToken; 4.10 import jdk.nashorn.internal.parser.TokenType; 4.11 import jdk.nashorn.internal.runtime.Context; 4.12 @@ -148,11 +150,9 @@ 4.13 */ 4.14 final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContext> { 4.15 4.16 - /** Name of the Global object, cannot be referred to as .class, @see CodeGenerator */ 4.17 - private static final String GLOBAL_OBJECT = Compiler.OBJECTS_PACKAGE + '/' + "Global"; 4.18 - 4.19 - /** Name of the ScriptFunctionImpl, cannot be referred to as .class @see FunctionObjectCreator */ 4.20 - private static final String SCRIPTFUNCTION_IMPL_OBJECT = Compiler.OBJECTS_PACKAGE + '/' + "ScriptFunctionImpl"; 4.21 + private static final String GLOBAL_OBJECT = Type.getInternalName(Global.class); 4.22 + 4.23 + private static final String SCRIPTFUNCTION_IMPL_OBJECT = Type.getInternalName(ScriptFunctionImpl.class); 4.24 4.25 /** Constant data & installation. The only reason the compiler keeps this is because it is assigned 4.26 * by reflection in class installation */ 4.27 @@ -3203,11 +3203,7 @@ 4.28 }.makeObject(method); 4.29 } 4.30 4.31 - /* 4.32 - * Globals are special. We cannot refer to any Global (or NativeObject) class by .class, as they are different 4.33 - * for different contexts. As far as I can tell, the only NativeObject that we need to deal with like this 4.34 - * is from the code pipeline is Global 4.35 - */ 4.36 + // calls on Global class. 4.37 private MethodEmitter globalInstance() { 4.38 return method.invokestatic(GLOBAL_OBJECT, "instance", "()L" + GLOBAL_OBJECT + ';'); 4.39 }
5.1 --- a/src/jdk/nashorn/internal/objects/AccessorPropertyDescriptor.java Thu Jul 04 17:28:04 2013 +0200 5.2 +++ b/src/jdk/nashorn/internal/objects/AccessorPropertyDescriptor.java Fri Jul 05 14:38:04 2013 +0530 5.3 @@ -67,12 +67,12 @@ 5.4 // initialized by nasgen 5.5 private static PropertyMap $nasgenmap$; 5.6 5.7 - AccessorPropertyDescriptor() { 5.8 - this(false, false, UNDEFINED, UNDEFINED); 5.9 + static PropertyMap getInitialMap() { 5.10 + return $nasgenmap$; 5.11 } 5.12 5.13 - AccessorPropertyDescriptor(final boolean configurable, final boolean enumerable, final Object get, final Object set) { 5.14 - super(Global.objectPrototype(), $nasgenmap$); 5.15 + AccessorPropertyDescriptor(final boolean configurable, final boolean enumerable, final Object get, final Object set, final Global global) { 5.16 + super(global.getObjectPrototype(), global.getAccessorPropertyDescriptorMap()); 5.17 this.configurable = configurable; 5.18 this.enumerable = enumerable; 5.19 this.get = get;
6.1 --- a/src/jdk/nashorn/internal/objects/ArrayBufferView.java Thu Jul 04 17:28:04 2013 +0200 6.2 +++ b/src/jdk/nashorn/internal/objects/ArrayBufferView.java Fri Jul 05 14:38:04 2013 +0530 6.3 @@ -40,12 +40,17 @@ 6.4 abstract class ArrayBufferView extends ScriptObject { 6.5 6.6 // initialized by nasgen 6.7 - @SuppressWarnings("unused") 6.8 private static PropertyMap $nasgenmap$; 6.9 6.10 + static PropertyMap getInitialMap() { 6.11 + return $nasgenmap$; 6.12 + } 6.13 + 6.14 ArrayBufferView(final NativeArrayBuffer buffer, final int byteOffset, final int elementLength) { 6.15 checkConstructorArgs(buffer, byteOffset, elementLength); 6.16 - this.setProto(getPrototype()); 6.17 + final Global global = Global.instance(); 6.18 + this.setMap(global.getArrayBufferViewMap()); 6.19 + this.setProto(getPrototype(global)); 6.20 this.setArray(factory().createArrayData(buffer, byteOffset, elementLength)); 6.21 } 6.22 6.23 @@ -283,7 +288,7 @@ 6.24 6.25 protected abstract Factory factory(); 6.26 6.27 - protected abstract ScriptObject getPrototype(); 6.28 + protected abstract ScriptObject getPrototype(final Global global); 6.29 6.30 protected boolean isFloatArray() { 6.31 return false;
7.1 --- a/src/jdk/nashorn/internal/objects/BoundScriptFunctionImpl.java Thu Jul 04 17:28:04 2013 +0200 7.2 +++ b/src/jdk/nashorn/internal/objects/BoundScriptFunctionImpl.java Fri Jul 05 14:38:04 2013 +0530 7.3 @@ -39,7 +39,7 @@ 7.4 private final ScriptFunction targetFunction; 7.5 7.6 BoundScriptFunctionImpl(ScriptFunctionData data, ScriptFunction targetFunction) { 7.7 - super(data); 7.8 + super(data, Global.instance()); 7.9 setPrototype(ScriptRuntime.UNDEFINED); 7.10 this.targetFunction = targetFunction; 7.11 }
8.1 --- a/src/jdk/nashorn/internal/objects/DataPropertyDescriptor.java Thu Jul 04 17:28:04 2013 +0200 8.2 +++ b/src/jdk/nashorn/internal/objects/DataPropertyDescriptor.java Fri Jul 05 14:38:04 2013 +0530 8.3 @@ -25,7 +25,6 @@ 8.4 8.5 package jdk.nashorn.internal.objects; 8.6 8.7 -import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED; 8.8 import static jdk.nashorn.internal.runtime.ScriptRuntime.sameValue; 8.9 8.10 import java.util.Objects; 8.11 @@ -65,12 +64,12 @@ 8.12 // initialized by nasgen 8.13 private static PropertyMap $nasgenmap$; 8.14 8.15 - DataPropertyDescriptor() { 8.16 - this(false, false, false, UNDEFINED); 8.17 + static PropertyMap getInitialMap() { 8.18 + return $nasgenmap$; 8.19 } 8.20 8.21 - DataPropertyDescriptor(final boolean configurable, final boolean enumerable, final boolean writable, final Object value) { 8.22 - super(Global.objectPrototype(), $nasgenmap$); 8.23 + DataPropertyDescriptor(final boolean configurable, final boolean enumerable, final boolean writable, final Object value, final Global global) { 8.24 + super(global.getObjectPrototype(), global.getDataPropertyDescriptorMap()); 8.25 this.configurable = configurable; 8.26 this.enumerable = enumerable; 8.27 this.writable = writable;
9.1 --- a/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java Thu Jul 04 17:28:04 2013 +0200 9.2 +++ b/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java Fri Jul 05 14:38:04 2013 +0530 9.3 @@ -55,12 +55,12 @@ 9.4 // initialized by nasgen 9.5 private static PropertyMap $nasgenmap$; 9.6 9.7 - GenericPropertyDescriptor() { 9.8 - this(false, false); 9.9 + static PropertyMap getInitialMap() { 9.10 + return $nasgenmap$; 9.11 } 9.12 9.13 - GenericPropertyDescriptor(final boolean configurable, final boolean enumerable) { 9.14 - super(Global.objectPrototype(), $nasgenmap$); 9.15 + GenericPropertyDescriptor(final boolean configurable, final boolean enumerable, final Global global) { 9.16 + super(global.getObjectPrototype(), global.getGenericPropertyDescriptorMap()); 9.17 this.configurable = configurable; 9.18 this.enumerable = enumerable; 9.19 }
10.1 --- a/src/jdk/nashorn/internal/objects/Global.java Thu Jul 04 17:28:04 2013 +0200 10.2 +++ b/src/jdk/nashorn/internal/objects/Global.java Fri Jul 05 14:38:04 2013 +0530 10.3 @@ -363,6 +363,35 @@ 10.4 private ScriptObject builtinFloat32Array; 10.5 private ScriptObject builtinFloat64Array; 10.6 10.7 + private PropertyMap accessorPropertyDescriptorMap; 10.8 + private PropertyMap arrayBufferViewMap; 10.9 + private PropertyMap dataPropertyDescriptorMap; 10.10 + private PropertyMap genericPropertyDescriptorMap; 10.11 + private PropertyMap nativeArgumentsMap; 10.12 + private PropertyMap nativeArrayMap; 10.13 + private PropertyMap nativeArrayBufferMap; 10.14 + private PropertyMap nativeBooleanMap; 10.15 + private PropertyMap nativeDateMap; 10.16 + private PropertyMap nativeErrorMap; 10.17 + private PropertyMap nativeEvalErrorMap; 10.18 + private PropertyMap nativeJSAdapterMap; 10.19 + private PropertyMap nativeJavaImporterMap; 10.20 + private PropertyMap nativeNumberMap; 10.21 + private PropertyMap nativeRangeErrorMap; 10.22 + private PropertyMap nativeReferenceErrorMap; 10.23 + private PropertyMap nativeRegExpMap; 10.24 + private PropertyMap nativeRegExpExecResultMap; 10.25 + private PropertyMap nativeStrictArgumentsMap; 10.26 + private PropertyMap nativeStringMap; 10.27 + private PropertyMap nativeSyntaxErrorMap; 10.28 + private PropertyMap nativeTypeErrorMap; 10.29 + private PropertyMap nativeURIErrorMap; 10.30 + private PropertyMap prototypeObjectMap; 10.31 + private PropertyMap objectMap; 10.32 + private PropertyMap functionMap; 10.33 + private PropertyMap strictFunctionMap; 10.34 + private PropertyMap boundFunctionMap; 10.35 + 10.36 // Flag to indicate that a split method issued a return statement 10.37 private int splitState = -1; 10.38 10.39 @@ -379,8 +408,6 @@ 10.40 private static final MethodHandle LOADWITHNEWGLOBAL = findOwnMH("loadWithNewGlobal", Object.class, Object.class, Object[].class); 10.41 private static final MethodHandle EXIT = findOwnMH("exit", Object.class, Object.class, Object.class); 10.42 10.43 - private final Context context; 10.44 - 10.45 // initialized by nasgen 10.46 @SuppressWarnings("unused") 10.47 private static PropertyMap $nasgenmap$; 10.48 @@ -391,7 +418,7 @@ 10.49 * @param context the context 10.50 */ 10.51 public Global(final Context context) { 10.52 - this.context = context; 10.53 + this.setContext(context); 10.54 this.setIsScope(); 10.55 /* 10.56 * Duplicate global's map and use it. This way the initial Map filled 10.57 @@ -425,7 +452,7 @@ 10.58 * @return the script environment 10.59 */ 10.60 static ScriptEnvironment getEnv() { 10.61 - return instance().context.getEnv(); 10.62 + return instance().getContext().getEnv(); 10.63 } 10.64 10.65 /** 10.66 @@ -434,7 +461,7 @@ 10.67 * @return the context 10.68 */ 10.69 static Context getThisContext() { 10.70 - return instance().context; 10.71 + return instance().getContext(); 10.72 } 10.73 10.74 // GlobalObject interface implementation 10.75 @@ -457,11 +484,11 @@ 10.76 @Override 10.77 public Object wrapAsObject(final Object obj) { 10.78 if (obj instanceof Boolean) { 10.79 - return new NativeBoolean((Boolean)obj); 10.80 + return new NativeBoolean((Boolean)obj, this); 10.81 } else if (obj instanceof Number) { 10.82 - return new NativeNumber(((Number)obj).doubleValue()); 10.83 + return new NativeNumber(((Number)obj).doubleValue(), this); 10.84 } else if (obj instanceof String || obj instanceof ConsString) { 10.85 - return new NativeString((CharSequence)obj); 10.86 + return new NativeString((CharSequence)obj, this); 10.87 } else if (obj instanceof Object[]) { // extension 10.88 return new NativeArray((Object[])obj); 10.89 } else if (obj instanceof double[]) { // extension 10.90 @@ -490,7 +517,7 @@ 10.91 10.92 @Override 10.93 public ScriptObject newObject() { 10.94 - return new JO(getObjectPrototype()); 10.95 + return new JO(getObjectPrototype(), getObjectMap()); 10.96 } 10.97 10.98 @Override 10.99 @@ -567,52 +594,52 @@ 10.100 10.101 @Override 10.102 public ScriptObject newError(final String msg) { 10.103 - return new NativeError(msg); 10.104 + return new NativeError(msg, this); 10.105 } 10.106 10.107 @Override 10.108 public ScriptObject newEvalError(final String msg) { 10.109 - return new NativeEvalError(msg); 10.110 + return new NativeEvalError(msg, this); 10.111 } 10.112 10.113 @Override 10.114 public ScriptObject newRangeError(final String msg) { 10.115 - return new NativeRangeError(msg); 10.116 + return new NativeRangeError(msg, this); 10.117 } 10.118 10.119 @Override 10.120 public ScriptObject newReferenceError(final String msg) { 10.121 - return new NativeReferenceError(msg); 10.122 + return new NativeReferenceError(msg, this); 10.123 } 10.124 10.125 @Override 10.126 public ScriptObject newSyntaxError(final String msg) { 10.127 - return new NativeSyntaxError(msg); 10.128 + return new NativeSyntaxError(msg, this); 10.129 } 10.130 10.131 @Override 10.132 public ScriptObject newTypeError(final String msg) { 10.133 - return new NativeTypeError(msg); 10.134 + return new NativeTypeError(msg, this); 10.135 } 10.136 10.137 @Override 10.138 public ScriptObject newURIError(final String msg) { 10.139 - return new NativeURIError(msg); 10.140 + return new NativeURIError(msg, this); 10.141 } 10.142 10.143 @Override 10.144 public PropertyDescriptor newGenericDescriptor(final boolean configurable, final boolean enumerable) { 10.145 - return new GenericPropertyDescriptor(configurable, enumerable); 10.146 + return new GenericPropertyDescriptor(configurable, enumerable, this); 10.147 } 10.148 10.149 @Override 10.150 public PropertyDescriptor newDataDescriptor(final Object value, final boolean configurable, final boolean enumerable, final boolean writable) { 10.151 - return new DataPropertyDescriptor(configurable, enumerable, writable, value); 10.152 + return new DataPropertyDescriptor(configurable, enumerable, writable, value, this); 10.153 } 10.154 10.155 @Override 10.156 public PropertyDescriptor newAccessorDescriptor(final Object get, final Object set, final boolean configurable, final boolean enumerable) { 10.157 - final AccessorPropertyDescriptor desc = new AccessorPropertyDescriptor(configurable, enumerable, get == null ? UNDEFINED : get, set == null ? UNDEFINED : set); 10.158 + final AccessorPropertyDescriptor desc = new AccessorPropertyDescriptor(configurable, enumerable, get == null ? UNDEFINED : get, set == null ? UNDEFINED : set, this); 10.159 10.160 if (get == null) { 10.161 desc.delete(PropertyDescriptor.GET, false); 10.162 @@ -701,7 +728,7 @@ 10.163 final Global global = Global.instance(); 10.164 final ScriptObject scope = (self instanceof ScriptObject) ? (ScriptObject)self : global; 10.165 10.166 - return global.context.eval(scope, str.toString(), callThis, location, Boolean.TRUE.equals(strict)); 10.167 + return global.getContext().eval(scope, str.toString(), callThis, location, Boolean.TRUE.equals(strict)); 10.168 } 10.169 10.170 /** 10.171 @@ -741,7 +768,7 @@ 10.172 public static Object load(final Object self, final Object source) throws IOException { 10.173 final Global global = Global.instance(); 10.174 final ScriptObject scope = (self instanceof ScriptObject) ? (ScriptObject)self : global; 10.175 - return global.context.load(scope, source); 10.176 + return global.getContext().load(scope, source); 10.177 } 10.178 10.179 /** 10.180 @@ -761,7 +788,7 @@ 10.181 final Object from = hasArgs ? args[0] : UNDEFINED; 10.182 final Object[] arguments = hasArgs ? Arrays.copyOfRange(args, 1, length) : args; 10.183 10.184 - return global.context.loadWithNewGlobal(from, arguments); 10.185 + return global.getContext().loadWithNewGlobal(from, arguments); 10.186 } 10.187 10.188 /** 10.189 @@ -777,6 +804,7 @@ 10.190 return UNDEFINED; 10.191 } 10.192 10.193 + // builtin prototype accessors 10.194 ScriptObject getFunctionPrototype() { 10.195 return ScriptFunction.getPrototype(builtinFunction); 10.196 } 10.197 @@ -885,11 +913,123 @@ 10.198 return ScriptFunction.getPrototype(builtinFloat64Array); 10.199 } 10.200 10.201 + // Builtin PropertyMap accessors 10.202 + PropertyMap getAccessorPropertyDescriptorMap() { 10.203 + return accessorPropertyDescriptorMap; 10.204 + } 10.205 + 10.206 + PropertyMap getArrayBufferViewMap() { 10.207 + return arrayBufferViewMap; 10.208 + } 10.209 + 10.210 + PropertyMap getDataPropertyDescriptorMap() { 10.211 + return dataPropertyDescriptorMap; 10.212 + } 10.213 + 10.214 + PropertyMap getGenericPropertyDescriptorMap() { 10.215 + return genericPropertyDescriptorMap; 10.216 + } 10.217 + 10.218 + PropertyMap getArgumentsMap() { 10.219 + return nativeArgumentsMap; 10.220 + } 10.221 + 10.222 + PropertyMap getArrayMap() { 10.223 + return nativeArrayMap; 10.224 + } 10.225 + 10.226 + PropertyMap getArrayBufferMap() { 10.227 + return nativeArrayBufferMap; 10.228 + } 10.229 + 10.230 + PropertyMap getBooleanMap() { 10.231 + return nativeBooleanMap; 10.232 + } 10.233 + 10.234 + PropertyMap getDateMap() { 10.235 + return nativeDateMap; 10.236 + } 10.237 + 10.238 + PropertyMap getErrorMap() { 10.239 + return nativeErrorMap; 10.240 + } 10.241 + 10.242 + PropertyMap getEvalErrorMap() { 10.243 + return nativeEvalErrorMap; 10.244 + } 10.245 + 10.246 + PropertyMap getJSAdapterMap() { 10.247 + return nativeJSAdapterMap; 10.248 + } 10.249 + 10.250 + PropertyMap getJavaImporterMap() { 10.251 + return nativeJavaImporterMap; 10.252 + } 10.253 + 10.254 + PropertyMap getNumberMap() { 10.255 + return nativeNumberMap; 10.256 + } 10.257 + 10.258 + PropertyMap getRangeErrorMap() { 10.259 + return nativeRangeErrorMap; 10.260 + } 10.261 + 10.262 + PropertyMap getReferenceErrorMap() { 10.263 + return nativeReferenceErrorMap; 10.264 + } 10.265 + 10.266 + PropertyMap getRegExpMap() { 10.267 + return nativeRegExpMap; 10.268 + } 10.269 + 10.270 + PropertyMap getRegExpExecResultMap() { 10.271 + return nativeRegExpExecResultMap; 10.272 + } 10.273 + 10.274 + PropertyMap getStrictArgumentsMap() { 10.275 + return nativeStrictArgumentsMap; 10.276 + } 10.277 + 10.278 + PropertyMap getStringMap() { 10.279 + return nativeStringMap; 10.280 + } 10.281 + 10.282 + PropertyMap getSyntaxErrorMap() { 10.283 + return nativeSyntaxErrorMap; 10.284 + } 10.285 + 10.286 + PropertyMap getTypeErrorMap() { 10.287 + return nativeTypeErrorMap; 10.288 + } 10.289 + 10.290 + PropertyMap getURIErrorMap() { 10.291 + return nativeURIErrorMap; 10.292 + } 10.293 + 10.294 + PropertyMap getPrototypeObjectMap() { 10.295 + return prototypeObjectMap; 10.296 + } 10.297 + 10.298 + PropertyMap getObjectMap() { 10.299 + return objectMap; 10.300 + } 10.301 + 10.302 + PropertyMap getFunctionMap() { 10.303 + return functionMap; 10.304 + } 10.305 + 10.306 + PropertyMap getStrictFunctionMap() { 10.307 + return strictFunctionMap; 10.308 + } 10.309 + 10.310 + PropertyMap getBoundFunctionMap() { 10.311 + return boundFunctionMap; 10.312 + } 10.313 + 10.314 private ScriptFunction getBuiltinArray() { 10.315 return builtinArray; 10.316 } 10.317 10.318 - 10.319 /** 10.320 * Called from compiled script code to test if builtin has been overridden 10.321 * 10.322 @@ -1395,7 +1535,11 @@ 10.323 private void init() { 10.324 assert Context.getGlobal() == this : "this global is not set as current"; 10.325 10.326 - final ScriptEnvironment env = context.getEnv(); 10.327 + final ScriptEnvironment env = getContext().getEnv(); 10.328 + 10.329 + // duplicate PropertyMaps of Native* classes 10.330 + copyInitialMaps(); 10.331 + 10.332 // initialize Function and Object constructor 10.333 initFunctionAndObject(); 10.334 10.335 @@ -1441,10 +1585,10 @@ 10.336 final ScriptObject arrayPrototype = getArrayPrototype(); 10.337 arrayPrototype.addOwnProperty("length", Attribute.NOT_ENUMERABLE|Attribute.NOT_CONFIGURABLE, 0.0); 10.338 10.339 - this.DEFAULT_DATE = new NativeDate(Double.NaN); 10.340 + this.DEFAULT_DATE = new NativeDate(Double.NaN, this); 10.341 10.342 // initialize default regexp object 10.343 - this.DEFAULT_REGEXP = new NativeRegExp("(?:)"); 10.344 + this.DEFAULT_REGEXP = new NativeRegExp("(?:)", this); 10.345 10.346 // RegExp.prototype should behave like a RegExp object. So copy the 10.347 // properties. 10.348 @@ -1560,7 +1704,7 @@ 10.349 10.350 // Nashorn extension: global.$OPTIONS (scripting-mode-only) 10.351 final ScriptObject options = newObject(); 10.352 - final ScriptEnvironment scriptEnv = context.getEnv(); 10.353 + final ScriptEnvironment scriptEnv = getContext().getEnv(); 10.354 copyOptions(options, scriptEnv); 10.355 addOwnProperty("$OPTIONS", Attribute.NOT_ENUMERABLE, options); 10.356 10.357 @@ -1713,6 +1857,37 @@ 10.358 } 10.359 } 10.360 10.361 + private void copyInitialMaps() { 10.362 + this.accessorPropertyDescriptorMap = AccessorPropertyDescriptor.getInitialMap().duplicate(); 10.363 + this.arrayBufferViewMap = ArrayBufferView.getInitialMap().duplicate(); 10.364 + this.dataPropertyDescriptorMap = DataPropertyDescriptor.getInitialMap().duplicate(); 10.365 + this.genericPropertyDescriptorMap = GenericPropertyDescriptor.getInitialMap().duplicate(); 10.366 + this.nativeArgumentsMap = NativeArguments.getInitialMap().duplicate(); 10.367 + this.nativeArrayMap = NativeArray.getInitialMap().duplicate(); 10.368 + this.nativeArrayBufferMap = NativeArrayBuffer.getInitialMap().duplicate(); 10.369 + this.nativeBooleanMap = NativeBoolean.getInitialMap().duplicate(); 10.370 + this.nativeDateMap = NativeDate.getInitialMap().duplicate(); 10.371 + this.nativeErrorMap = NativeError.getInitialMap().duplicate(); 10.372 + this.nativeEvalErrorMap = NativeEvalError.getInitialMap().duplicate(); 10.373 + this.nativeJSAdapterMap = NativeJSAdapter.getInitialMap().duplicate(); 10.374 + this.nativeJavaImporterMap = NativeJavaImporter.getInitialMap().duplicate(); 10.375 + this.nativeNumberMap = NativeNumber.getInitialMap().duplicate(); 10.376 + this.nativeRangeErrorMap = NativeRangeError.getInitialMap().duplicate(); 10.377 + this.nativeReferenceErrorMap = NativeReferenceError.getInitialMap().duplicate(); 10.378 + this.nativeRegExpMap = NativeRegExp.getInitialMap().duplicate(); 10.379 + this.nativeRegExpExecResultMap = NativeRegExpExecResult.getInitialMap().duplicate(); 10.380 + this.nativeStrictArgumentsMap = NativeStrictArguments.getInitialMap().duplicate(); 10.381 + this.nativeStringMap = NativeString.getInitialMap().duplicate(); 10.382 + this.nativeSyntaxErrorMap = NativeSyntaxError.getInitialMap().duplicate(); 10.383 + this.nativeTypeErrorMap = NativeTypeError.getInitialMap().duplicate(); 10.384 + this.nativeURIErrorMap = NativeURIError.getInitialMap().duplicate(); 10.385 + this.prototypeObjectMap = PrototypeObject.getInitialMap().duplicate(); 10.386 + this.objectMap = JO.getInitialMap().duplicate(); 10.387 + this.functionMap = ScriptFunctionImpl.getInitialMap(); 10.388 + this.strictFunctionMap = ScriptFunctionImpl.getInitialStrictMap().duplicate(); 10.389 + this.boundFunctionMap = ScriptFunctionImpl.getInitialBoundMap().duplicate(); 10.390 + } 10.391 + 10.392 // Function and Object constructors are inter-dependent. Also, 10.393 // Function.prototype 10.394 // functions are not properly initialized. We fix the references here. 10.395 @@ -1793,13 +1968,8 @@ 10.396 } 10.397 } 10.398 10.399 - 10.400 private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) { 10.401 - try { 10.402 - return MethodHandles.lookup().findStatic(Global.class, name, MH.type(rtype, types)); 10.403 - } catch (final NoSuchMethodException | IllegalAccessException e) { 10.404 - throw new MethodHandleFactory.LookupException(e); 10.405 - } 10.406 + return MH.findStatic(MethodHandles.lookup(), Global.class, name, MH.type(rtype, types)); 10.407 } 10.408 10.409 RegExpResult getLastRegExpResult() {
11.1 --- a/src/jdk/nashorn/internal/objects/NativeArguments.java Thu Jul 04 17:28:04 2013 +0200 11.2 +++ b/src/jdk/nashorn/internal/objects/NativeArguments.java Fri Jul 05 14:38:04 2013 +0530 11.3 @@ -70,14 +70,18 @@ 11.4 map$ = map; 11.5 } 11.6 11.7 + static PropertyMap getInitialMap() { 11.8 + return map$; 11.9 + } 11.10 + 11.11 private Object length; 11.12 private Object callee; 11.13 private ArrayData namedArgs; 11.14 // This is lazily initialized - only when delete is invoked at all 11.15 private BitSet deleted; 11.16 11.17 - NativeArguments(final ScriptObject proto, final Object[] arguments, final Object callee, final int numParams) { 11.18 - super(proto, map$); 11.19 + NativeArguments(final Object[] arguments, final Object callee, final int numParams, final ScriptObject proto, final PropertyMap map) { 11.20 + super(proto, map); 11.21 setIsArguments(); 11.22 11.23 setArray(ArrayData.allocate(arguments)); 11.24 @@ -550,8 +554,13 @@ 11.25 public static ScriptObject allocate(final Object[] arguments, final ScriptFunction callee, final int numParams) { 11.26 // Strict functions won't always have a callee for arguments, and will pass null instead. 11.27 final boolean isStrict = callee == null || callee.isStrict(); 11.28 - final ScriptObject proto = Global.objectPrototype(); 11.29 - return isStrict ? new NativeStrictArguments(proto, arguments, numParams) : new NativeArguments(proto, arguments, callee, numParams); 11.30 + final Global global = Global.instance(); 11.31 + final ScriptObject proto = global.getObjectPrototype(); 11.32 + if (isStrict) { 11.33 + return new NativeStrictArguments(arguments, numParams, proto, global.getStrictArgumentsMap()); 11.34 + } else { 11.35 + return new NativeArguments(arguments, callee, numParams, proto, global.getArgumentsMap()); 11.36 + } 11.37 } 11.38 11.39 /** 11.40 @@ -623,11 +632,6 @@ 11.41 } 11.42 11.43 private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) { 11.44 - try { 11.45 - return MethodHandles.lookup().findStatic(NativeArguments.class, name, MH.type(rtype, types)); 11.46 - } catch (final NoSuchMethodException | IllegalAccessException e) { 11.47 - throw new MethodHandleFactory.LookupException(e); 11.48 - } 11.49 + return MH.findStatic(MethodHandles.lookup(), NativeArguments.class, name, MH.type(rtype, types)); 11.50 } 11.51 - 11.52 }
12.1 --- a/src/jdk/nashorn/internal/objects/NativeArray.java Thu Jul 04 17:28:04 2013 +0200 12.2 +++ b/src/jdk/nashorn/internal/objects/NativeArray.java Fri Jul 05 14:38:04 2013 +0530 12.3 @@ -86,6 +86,10 @@ 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 /* 12.12 * Constructors. 12.13 */ 12.14 @@ -130,7 +134,11 @@ 12.15 } 12.16 12.17 NativeArray(final ArrayData arrayData) { 12.18 - super(Global.instance().getArrayPrototype(), $nasgenmap$); 12.19 + this(arrayData, Global.instance()); 12.20 + } 12.21 + 12.22 + NativeArray(final ArrayData arrayData, final Global global) { 12.23 + super(global.getArrayPrototype(), global.getArrayMap()); 12.24 this.setArray(arrayData); 12.25 this.setIsArray(); 12.26 }
13.1 --- a/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java Thu Jul 04 17:28:04 2013 +0200 13.2 +++ b/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java Fri Jul 05 14:38:04 2013 +0530 13.3 @@ -43,6 +43,10 @@ 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 @Constructor(arity = 1) 13.12 public static Object constructor(final boolean newObj, final Object self, final Object... args) { 13.13 if (args.length == 0) { 13.14 @@ -52,9 +56,13 @@ 13.15 return new NativeArrayBuffer(JSType.toInt32(args[0])); 13.16 } 13.17 13.18 + protected NativeArrayBuffer(final byte[] byteArray, final Global global) { 13.19 + super(global.getArrayBufferPrototype(), global.getArrayBufferMap()); 13.20 + this.buffer = byteArray; 13.21 + } 13.22 + 13.23 protected NativeArrayBuffer(final byte[] byteArray) { 13.24 - super(Global.instance().getArrayBufferPrototype(), $nasgenmap$); 13.25 - this.buffer = byteArray; 13.26 + this(byteArray, Global.instance()); 13.27 } 13.28 13.29 protected NativeArrayBuffer(final int byteLength) {
14.1 --- a/src/jdk/nashorn/internal/objects/NativeBoolean.java Thu Jul 04 17:28:04 2013 +0200 14.2 +++ b/src/jdk/nashorn/internal/objects/NativeBoolean.java Fri Jul 05 14:38:04 2013 +0530 14.3 @@ -56,15 +56,23 @@ 14.4 // initialized by nasgen 14.5 private static PropertyMap $nasgenmap$; 14.6 14.7 - NativeBoolean(final boolean value) { 14.8 - this(value, Global.instance().getBooleanPrototype()); 14.9 + static PropertyMap getInitialMap() { 14.10 + return $nasgenmap$; 14.11 } 14.12 14.13 - private NativeBoolean(final boolean value, final ScriptObject proto) { 14.14 - super(proto, $nasgenmap$); 14.15 + private NativeBoolean(final boolean value, final ScriptObject proto, final PropertyMap map) { 14.16 + super(proto, map); 14.17 this.value = value; 14.18 } 14.19 14.20 + NativeBoolean(final boolean flag, final Global global) { 14.21 + this(flag, global.getBooleanPrototype(), global.getBooleanMap()); 14.22 + } 14.23 + 14.24 + NativeBoolean(final boolean flag) { 14.25 + this(flag, Global.instance()); 14.26 + } 14.27 + 14.28 @Override 14.29 public String safeToString() { 14.30 return "[Boolean " + toString() + "]"; 14.31 @@ -131,11 +139,7 @@ 14.32 final boolean flag = JSType.toBoolean(value); 14.33 14.34 if (newObj) { 14.35 - final ScriptObject proto = (self instanceof ScriptObject) ? 14.36 - ((ScriptObject)self).getProto() : 14.37 - Global.instance().getBooleanPrototype(); 14.38 - 14.39 - return new NativeBoolean(flag, proto); 14.40 + return new NativeBoolean(flag); 14.41 } 14.42 14.43 return flag; 14.44 @@ -176,10 +180,6 @@ 14.45 } 14.46 14.47 private static MethodHandle findWrapFilter() { 14.48 - try { 14.49 - return MethodHandles.lookup().findStatic(NativeBoolean.class, "wrapFilter", MH.type(NativeBoolean.class, Object.class)); 14.50 - } catch (NoSuchMethodException | IllegalAccessException e) { 14.51 - throw new MethodHandleFactory.LookupException(e); 14.52 - } 14.53 + return MH.findStatic(MethodHandles.lookup(), NativeBoolean.class, "wrapFilter", MH.type(NativeBoolean.class, Object.class)); 14.54 } 14.55 }
15.1 --- a/src/jdk/nashorn/internal/objects/NativeDate.java Thu Jul 04 17:28:04 2013 +0200 15.2 +++ b/src/jdk/nashorn/internal/objects/NativeDate.java Fri Jul 05 14:38:04 2013 +0530 15.3 @@ -104,18 +104,30 @@ 15.4 // initialized by nasgen 15.5 private static PropertyMap $nasgenmap$; 15.6 15.7 - NativeDate() { 15.8 - this(System.currentTimeMillis()); 15.9 + static PropertyMap getInitialMap() { 15.10 + return $nasgenmap$; 15.11 } 15.12 15.13 - NativeDate(final double time) { 15.14 - super(Global.instance().getDatePrototype(), $nasgenmap$); 15.15 + private NativeDate(final double time, final ScriptObject proto, final PropertyMap map) { 15.16 + super(proto, map); 15.17 final ScriptEnvironment env = Global.getEnv(); 15.18 15.19 this.time = time; 15.20 this.timezone = env._timezone; 15.21 } 15.22 15.23 + NativeDate(final double time, final Global global) { 15.24 + this(time, global.getDatePrototype(), global.getDateMap()); 15.25 + } 15.26 + 15.27 + private NativeDate (final double time) { 15.28 + this(time, Global.instance()); 15.29 + } 15.30 + 15.31 + private NativeDate() { 15.32 + this(System.currentTimeMillis()); 15.33 + } 15.34 + 15.35 @Override 15.36 public String getClassName() { 15.37 return "Date"; 15.38 @@ -153,6 +165,10 @@ 15.39 */ 15.40 @Constructor(arity = 7) 15.41 public static Object construct(final boolean isNew, final Object self, final Object... args) { 15.42 + if (! isNew) { 15.43 + return toStringImpl(new NativeDate(), FORMAT_DATE_TIME); 15.44 + } 15.45 + 15.46 NativeDate result; 15.47 switch (args.length) { 15.48 case 0: 15.49 @@ -182,7 +198,7 @@ 15.50 break; 15.51 } 15.52 15.53 - return isNew ? result : toStringImpl(new NativeDate(), FORMAT_DATE_TIME); 15.54 + return result; 15.55 } 15.56 15.57 @Override
16.1 --- a/src/jdk/nashorn/internal/objects/NativeDebug.java Thu Jul 04 17:28:04 2013 +0200 16.2 +++ b/src/jdk/nashorn/internal/objects/NativeDebug.java Fri Jul 05 14:38:04 2013 +0530 16.3 @@ -51,8 +51,9 @@ 16.4 // initialized by nasgen 16.5 private static PropertyMap $nasgenmap$; 16.6 16.7 - NativeDebug() { 16.8 - super(Global.objectPrototype(), $nasgenmap$); 16.9 + private NativeDebug() { 16.10 + // don't create me! 16.11 + throw new UnsupportedOperationException(); 16.12 } 16.13 16.14 @Override
17.1 --- a/src/jdk/nashorn/internal/objects/NativeError.java Thu Jul 04 17:28:04 2013 +0200 17.2 +++ b/src/jdk/nashorn/internal/objects/NativeError.java Fri Jul 05 14:38:04 2013 +0530 17.3 @@ -87,8 +87,12 @@ 17.4 // initialized by nasgen 17.5 private static PropertyMap $nasgenmap$; 17.6 17.7 - NativeError(final Object msg) { 17.8 - super(Global.instance().getErrorPrototype(), $nasgenmap$); 17.9 + static PropertyMap getInitialMap() { 17.10 + return $nasgenmap$; 17.11 + } 17.12 + 17.13 + private NativeError(final Object msg, final ScriptObject proto, final PropertyMap map) { 17.14 + super(proto, map); 17.15 if (msg != UNDEFINED) { 17.16 this.instMessage = JSType.toString(msg); 17.17 } else { 17.18 @@ -96,6 +100,14 @@ 17.19 } 17.20 } 17.21 17.22 + NativeError(final Object msg, final Global global) { 17.23 + this(msg, global.getErrorPrototype(), global.getErrorMap()); 17.24 + } 17.25 + 17.26 + private NativeError(final Object msg) { 17.27 + this(msg, Global.instance()); 17.28 + } 17.29 + 17.30 @Override 17.31 public String getClassName() { 17.32 return "Error"; 17.33 @@ -354,11 +366,7 @@ 17.34 } 17.35 17.36 private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) { 17.37 - try { 17.38 - return MethodHandles.lookup().findStatic(NativeError.class, name, MH.type(rtype, types)); 17.39 - } catch (final NoSuchMethodException | IllegalAccessException e) { 17.40 - throw new MethodHandleFactory.LookupException(e); 17.41 - } 17.42 + return MH.findStatic(MethodHandles.lookup(), NativeError.class, name, MH.type(rtype, types)); 17.43 } 17.44 17.45 private static String getScriptStackString(final ScriptObject sobj, final Throwable exp) {
18.1 --- a/src/jdk/nashorn/internal/objects/NativeEvalError.java Thu Jul 04 17:28:04 2013 +0200 18.2 +++ b/src/jdk/nashorn/internal/objects/NativeEvalError.java Fri Jul 05 14:38:04 2013 +0530 18.3 @@ -58,8 +58,12 @@ 18.4 // initialized by nasgen 18.5 private static PropertyMap $nasgenmap$; 18.6 18.7 - NativeEvalError(final Object msg) { 18.8 - super(Global.instance().getEvalErrorPrototype(), $nasgenmap$); 18.9 + static PropertyMap getInitialMap() { 18.10 + return $nasgenmap$; 18.11 + } 18.12 + 18.13 + private NativeEvalError(final Object msg, final ScriptObject proto, final PropertyMap map) { 18.14 + super(proto, map); 18.15 if (msg != UNDEFINED) { 18.16 this.instMessage = JSType.toString(msg); 18.17 } else { 18.18 @@ -67,12 +71,19 @@ 18.19 } 18.20 } 18.21 18.22 + NativeEvalError(final Object msg, final Global global) { 18.23 + this(msg, global.getEvalErrorPrototype(), global.getEvalErrorMap()); 18.24 + } 18.25 + 18.26 + private NativeEvalError(final Object msg) { 18.27 + this(msg, Global.instance()); 18.28 + } 18.29 + 18.30 @Override 18.31 public String getClassName() { 18.32 return "Error"; 18.33 } 18.34 18.35 - 18.36 /** 18.37 * ECMA 15.11.6.1 EvalError 18.38 *
19.1 --- a/src/jdk/nashorn/internal/objects/NativeFloat32Array.java Thu Jul 04 17:28:04 2013 +0200 19.2 +++ b/src/jdk/nashorn/internal/objects/NativeFloat32Array.java Fri Jul 05 14:38:04 2013 +0530 19.3 @@ -192,7 +192,7 @@ 19.4 } 19.5 19.6 @Override 19.7 - protected ScriptObject getPrototype() { 19.8 - return Global.instance().getFloat32ArrayPrototype(); 19.9 + protected ScriptObject getPrototype(final Global global) { 19.10 + return global.getFloat32ArrayPrototype(); 19.11 } 19.12 }
20.1 --- a/src/jdk/nashorn/internal/objects/NativeFloat64Array.java Thu Jul 04 17:28:04 2013 +0200 20.2 +++ b/src/jdk/nashorn/internal/objects/NativeFloat64Array.java Fri Jul 05 14:38:04 2013 +0530 20.3 @@ -202,7 +202,7 @@ 20.4 } 20.5 20.6 @Override 20.7 - protected ScriptObject getPrototype() { 20.8 - return Global.instance().getFloat64ArrayPrototype(); 20.9 + protected ScriptObject getPrototype(final Global global) { 20.10 + return global.getFloat64ArrayPrototype(); 20.11 } 20.12 }
21.1 --- a/src/jdk/nashorn/internal/objects/NativeFunction.java Thu Jul 04 17:28:04 2013 +0200 21.2 +++ b/src/jdk/nashorn/internal/objects/NativeFunction.java Fri Jul 05 14:38:04 2013 +0530 21.3 @@ -61,6 +61,7 @@ 21.4 21.5 // do *not* create me! 21.6 private NativeFunction() { 21.7 + throw new UnsupportedOperationException(); 21.8 } 21.9 21.10 /**
22.1 --- a/src/jdk/nashorn/internal/objects/NativeInt16Array.java Thu Jul 04 17:28:04 2013 +0200 22.2 +++ b/src/jdk/nashorn/internal/objects/NativeInt16Array.java Fri Jul 05 14:38:04 2013 +0530 22.3 @@ -151,7 +151,7 @@ 22.4 } 22.5 22.6 @Override 22.7 - protected ScriptObject getPrototype() { 22.8 - return Global.instance().getInt16ArrayPrototype(); 22.9 + protected ScriptObject getPrototype(final Global global) { 22.10 + return global.getInt16ArrayPrototype(); 22.11 } 22.12 }
23.1 --- a/src/jdk/nashorn/internal/objects/NativeInt32Array.java Thu Jul 04 17:28:04 2013 +0200 23.2 +++ b/src/jdk/nashorn/internal/objects/NativeInt32Array.java Fri Jul 05 14:38:04 2013 +0530 23.3 @@ -154,7 +154,7 @@ 23.4 } 23.5 23.6 @Override 23.7 - protected ScriptObject getPrototype() { 23.8 - return Global.instance().getInt32ArrayPrototype(); 23.9 + protected ScriptObject getPrototype(final Global global) { 23.10 + return global.getInt32ArrayPrototype(); 23.11 } 23.12 }
24.1 --- a/src/jdk/nashorn/internal/objects/NativeInt8Array.java Thu Jul 04 17:28:04 2013 +0200 24.2 +++ b/src/jdk/nashorn/internal/objects/NativeInt8Array.java Fri Jul 05 14:38:04 2013 +0530 24.3 @@ -144,7 +144,7 @@ 24.4 } 24.5 24.6 @Override 24.7 - protected ScriptObject getPrototype() { 24.8 - return Global.instance().getInt8ArrayPrototype(); 24.9 + protected ScriptObject getPrototype(final Global global) { 24.10 + return global.getInt8ArrayPrototype(); 24.11 } 24.12 }
25.1 --- a/src/jdk/nashorn/internal/objects/NativeJSAdapter.java Thu Jul 04 17:28:04 2013 +0200 25.2 +++ b/src/jdk/nashorn/internal/objects/NativeJSAdapter.java Fri Jul 05 14:38:04 2013 +0530 25.3 @@ -49,6 +49,7 @@ 25.4 import jdk.nashorn.internal.runtime.arrays.ArrayLikeIterator; 25.5 import jdk.nashorn.internal.lookup.Lookup; 25.6 import jdk.nashorn.internal.lookup.MethodHandleFactory; 25.7 +import jdk.nashorn.internal.scripts.JO; 25.8 25.9 /** 25.10 * This class is the implementation of the Nashorn-specific global object named {@code JSAdapter}. It can be 25.11 @@ -146,8 +147,12 @@ 25.12 // initialized by nasgen 25.13 private static PropertyMap $nasgenmap$; 25.14 25.15 - NativeJSAdapter(final ScriptObject proto, final Object overrides, final ScriptObject adaptee) { 25.16 - super(proto, $nasgenmap$); 25.17 + static PropertyMap getInitialMap() { 25.18 + return $nasgenmap$; 25.19 + } 25.20 + 25.21 + NativeJSAdapter(final Object overrides, final ScriptObject adaptee, final ScriptObject proto, final PropertyMap map) { 25.22 + super(proto, map); 25.23 this.adaptee = wrapAdaptee(adaptee); 25.24 if (overrides instanceof ScriptObject) { 25.25 this.overrides = true; 25.26 @@ -159,9 +164,7 @@ 25.27 } 25.28 25.29 private static ScriptObject wrapAdaptee(final ScriptObject adaptee) { 25.30 - final ScriptObject sobj = new jdk.nashorn.internal.scripts.JO(); 25.31 - sobj.setProto(adaptee); 25.32 - return sobj; 25.33 + return new JO(adaptee, Global.instance().getObjectMap()); 25.34 } 25.35 25.36 @Override 25.37 @@ -570,11 +573,12 @@ 25.38 throw typeError("not.an.object", ScriptRuntime.safeToString(adaptee)); 25.39 } 25.40 25.41 + final Global global = Global.instance(); 25.42 if (proto != null && !(proto instanceof ScriptObject)) { 25.43 - proto = Global.instance().getJSAdapterPrototype(); 25.44 + proto = global.getJSAdapterPrototype(); 25.45 } 25.46 25.47 - return new NativeJSAdapter((ScriptObject)proto, overrides, (ScriptObject)adaptee); 25.48 + return new NativeJSAdapter(overrides, (ScriptObject)adaptee, (ScriptObject)proto, global.getJSAdapterMap()); 25.49 } 25.50 25.51 @Override 25.52 @@ -736,10 +740,6 @@ 25.53 } 25.54 25.55 private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) { 25.56 - try { 25.57 - return MethodHandles.lookup().findStatic(NativeJSAdapter.class, name, MH.type(rtype, types)); 25.58 - } catch (final NoSuchMethodException | IllegalAccessException e) { 25.59 - throw new MethodHandleFactory.LookupException(e); 25.60 - } 25.61 + return MH.findStatic(MethodHandles.lookup(), NativeJSAdapter.class, name, MH.type(rtype, types)); 25.62 } 25.63 }
26.1 --- a/src/jdk/nashorn/internal/objects/NativeJSON.java Thu Jul 04 17:28:04 2013 +0200 26.2 +++ b/src/jdk/nashorn/internal/objects/NativeJSON.java Fri Jul 05 14:38:04 2013 +0530 26.3 @@ -62,8 +62,9 @@ 26.4 // initialized by nasgen 26.5 private static PropertyMap $nasgenmap$; 26.6 26.7 - NativeJSON() { 26.8 - super(Global.objectPrototype(), $nasgenmap$); 26.9 + private NativeJSON() { 26.10 + // don't create me!! 26.11 + throw new UnsupportedOperationException(); 26.12 } 26.13 26.14 /**
27.1 --- a/src/jdk/nashorn/internal/objects/NativeJava.java Thu Jul 04 17:28:04 2013 +0200 27.2 +++ b/src/jdk/nashorn/internal/objects/NativeJava.java Fri Jul 05 14:38:04 2013 +0530 27.3 @@ -60,6 +60,8 @@ 27.4 private static PropertyMap $nasgenmap$; 27.5 27.6 private NativeJava() { 27.7 + // don't create me 27.8 + throw new UnsupportedOperationException(); 27.9 } 27.10 27.11 /**
28.1 --- a/src/jdk/nashorn/internal/objects/NativeJavaImporter.java Thu Jul 04 17:28:04 2013 +0200 28.2 +++ b/src/jdk/nashorn/internal/objects/NativeJavaImporter.java Fri Jul 05 14:38:04 2013 +0530 28.3 @@ -59,11 +59,23 @@ 28.4 // initialized by nasgen 28.5 private static PropertyMap $nasgenmap$; 28.6 28.7 - NativeJavaImporter(final Object[] args) { 28.8 - super(Global.instance().getJavaImporterPrototype(), $nasgenmap$); 28.9 + static PropertyMap getInitialMap() { 28.10 + return $nasgenmap$; 28.11 + } 28.12 + 28.13 + private NativeJavaImporter(final Object[] args, final ScriptObject proto, final PropertyMap map) { 28.14 + super(proto, map); 28.15 this.args = args; 28.16 } 28.17 28.18 + private NativeJavaImporter(final Object[] args, final Global global) { 28.19 + this(args, global.getJavaImporterPrototype(), global.getJavaImporterMap()); 28.20 + } 28.21 + 28.22 + private NativeJavaImporter(final Object[] args) { 28.23 + this(args, Global.instance()); 28.24 + } 28.25 + 28.26 @Override 28.27 public String getClassName() { 28.28 return "JavaImporter";
29.1 --- a/src/jdk/nashorn/internal/objects/NativeMath.java Thu Jul 04 17:28:04 2013 +0200 29.2 +++ b/src/jdk/nashorn/internal/objects/NativeMath.java Fri Jul 05 14:38:04 2013 +0530 29.3 @@ -45,8 +45,9 @@ 29.4 // initialized by nasgen 29.5 private static PropertyMap $nasgenmap$; 29.6 29.7 - NativeMath() { 29.8 - super(Global.objectPrototype(), $nasgenmap$); 29.9 + private NativeMath() { 29.10 + // don't create me! 29.11 + throw new UnsupportedOperationException(); 29.12 } 29.13 29.14 /** ECMA 15.8.1.1 - E, always a double constant. Not writable or configurable */
30.1 --- a/src/jdk/nashorn/internal/objects/NativeNumber.java Thu Jul 04 17:28:04 2013 +0200 30.2 +++ b/src/jdk/nashorn/internal/objects/NativeNumber.java Fri Jul 05 14:38:04 2013 +0530 30.3 @@ -87,17 +87,26 @@ 30.4 // initialized by nasgen 30.5 private static PropertyMap $nasgenmap$; 30.6 30.7 - NativeNumber(final double value) { 30.8 - this(value, Global.instance().getNumberPrototype()); 30.9 + static PropertyMap getInitialMap() { 30.10 + return $nasgenmap$; 30.11 } 30.12 30.13 - private NativeNumber(final double value, final ScriptObject proto) { 30.14 - super(proto, $nasgenmap$); 30.15 + private NativeNumber(final double value, final ScriptObject proto, final PropertyMap map) { 30.16 + super(proto, map); 30.17 this.value = value; 30.18 this.isInt = isRepresentableAsInt(value); 30.19 this.isLong = isRepresentableAsLong(value); 30.20 } 30.21 30.22 + NativeNumber(final double value, final Global global) { 30.23 + this(value, global.getNumberPrototype(), global.getNumberMap()); 30.24 + } 30.25 + 30.26 + private NativeNumber(final double value) { 30.27 + this(value, Global.instance()); 30.28 + } 30.29 + 30.30 + 30.31 @Override 30.32 public String safeToString() { 30.33 return "[Number " + toString() + "]"; 30.34 @@ -165,16 +174,7 @@ 30.35 public static Object constructor(final boolean newObj, final Object self, final Object... args) { 30.36 final double num = (args.length > 0) ? JSType.toNumber(args[0]) : 0.0; 30.37 30.38 - if (newObj) { 30.39 - final ScriptObject proto = 30.40 - (self instanceof ScriptObject) ? 30.41 - ((ScriptObject)self).getProto() : 30.42 - Global.instance().getNumberPrototype(); 30.43 - 30.44 - return new NativeNumber(num, proto); 30.45 - } 30.46 - 30.47 - return num; 30.48 + return newObj? new NativeNumber(num) : num; 30.49 } 30.50 30.51 /** 30.52 @@ -380,10 +380,6 @@ 30.53 } 30.54 30.55 private static MethodHandle findWrapFilter() { 30.56 - try { 30.57 - return MethodHandles.lookup().findStatic(NativeNumber.class, "wrapFilter", MH.type(NativeNumber.class, Object.class)); 30.58 - } catch (final NoSuchMethodException | IllegalAccessException e) { 30.59 - throw new MethodHandleFactory.LookupException(e); 30.60 - } 30.61 + return MH.findStatic(MethodHandles.lookup(), NativeNumber.class, "wrapFilter", MH.type(NativeNumber.class, Object.class)); 30.62 } 30.63 }
31.1 --- a/src/jdk/nashorn/internal/objects/NativeObject.java Thu Jul 04 17:28:04 2013 +0200 31.2 +++ b/src/jdk/nashorn/internal/objects/NativeObject.java Fri Jul 05 14:38:04 2013 +0530 31.3 @@ -58,6 +58,8 @@ 31.4 private static PropertyMap $nasgenmap$; 31.5 31.6 private NativeObject() { 31.7 + // don't create me! 31.8 + throw new UnsupportedOperationException(); 31.9 } 31.10 31.11 private static ECMAException notAnObject(final Object obj) {
32.1 --- a/src/jdk/nashorn/internal/objects/NativeRangeError.java Thu Jul 04 17:28:04 2013 +0200 32.2 +++ b/src/jdk/nashorn/internal/objects/NativeRangeError.java Fri Jul 05 14:38:04 2013 +0530 32.3 @@ -58,8 +58,12 @@ 32.4 // initialized by nasgen 32.5 private static PropertyMap $nasgenmap$; 32.6 32.7 - NativeRangeError(final Object msg) { 32.8 - super(Global.instance().getRangeErrorPrototype(), $nasgenmap$); 32.9 + static PropertyMap getInitialMap() { 32.10 + return $nasgenmap$; 32.11 + } 32.12 + 32.13 + private NativeRangeError(final Object msg, final ScriptObject proto, final PropertyMap map) { 32.14 + super(proto, map); 32.15 if (msg != UNDEFINED) { 32.16 this.instMessage = JSType.toString(msg); 32.17 } else { 32.18 @@ -67,6 +71,14 @@ 32.19 } 32.20 } 32.21 32.22 + NativeRangeError(final Object msg, final Global global) { 32.23 + this(msg, global.getRangeErrorPrototype(), global.getRangeErrorMap()); 32.24 + } 32.25 + 32.26 + private NativeRangeError(final Object msg) { 32.27 + this(msg, Global.instance()); 32.28 + } 32.29 + 32.30 @Override 32.31 public String getClassName() { 32.32 return "Error";
33.1 --- a/src/jdk/nashorn/internal/objects/NativeReferenceError.java Thu Jul 04 17:28:04 2013 +0200 33.2 +++ b/src/jdk/nashorn/internal/objects/NativeReferenceError.java Fri Jul 05 14:38:04 2013 +0530 33.3 @@ -58,8 +58,12 @@ 33.4 // initialized by nasgen 33.5 private static PropertyMap $nasgenmap$; 33.6 33.7 - NativeReferenceError(final Object msg) { 33.8 - super(Global.instance().getReferenceErrorPrototype(), $nasgenmap$); 33.9 + static PropertyMap getInitialMap() { 33.10 + return $nasgenmap$; 33.11 + } 33.12 + 33.13 + private NativeReferenceError(final Object msg, final ScriptObject proto, final PropertyMap map) { 33.14 + super(proto, map); 33.15 if (msg != UNDEFINED) { 33.16 this.instMessage = JSType.toString(msg); 33.17 } else { 33.18 @@ -67,6 +71,14 @@ 33.19 } 33.20 } 33.21 33.22 + NativeReferenceError(final Object msg, final Global global) { 33.23 + this(msg, global.getReferenceErrorPrototype(), global.getReferenceErrorMap()); 33.24 + } 33.25 + 33.26 + private NativeReferenceError(final Object msg) { 33.27 + this(msg, Global.instance()); 33.28 + } 33.29 + 33.30 @Override 33.31 public String getClassName() { 33.32 return "Error";
34.1 --- a/src/jdk/nashorn/internal/objects/NativeRegExp.java Thu Jul 04 17:28:04 2013 +0200 34.2 +++ b/src/jdk/nashorn/internal/objects/NativeRegExp.java Fri Jul 05 14:38:04 2013 +0530 34.3 @@ -71,7 +71,17 @@ 34.4 @SuppressWarnings("unused") 34.5 private static PropertyMap $nasgenmap$; 34.6 34.7 - NativeRegExp(final String input, final String flagString) { 34.8 + static PropertyMap getInitialMap() { 34.9 + return $nasgenmap$; 34.10 + } 34.11 + 34.12 + private NativeRegExp(final Global global) { 34.13 + super(global.getRegExpPrototype(), global.getRegExpMap()); 34.14 + this.globalObject = global; 34.15 + } 34.16 + 34.17 + NativeRegExp(final String input, final String flagString, final Global global) { 34.18 + this(global); 34.19 try { 34.20 this.regexp = RegExpFactory.create(input, flagString); 34.21 } catch (final ParserException e) { 34.22 @@ -81,17 +91,24 @@ 34.23 } 34.24 34.25 this.setLastIndex(0); 34.26 - init(); 34.27 + } 34.28 + 34.29 + NativeRegExp(final String input, final String flagString) { 34.30 + this(input, flagString, Global.instance()); 34.31 + } 34.32 + 34.33 + NativeRegExp(final String string, final Global global) { 34.34 + this(string, "", global); 34.35 } 34.36 34.37 NativeRegExp(final String string) { 34.38 - this(string, ""); 34.39 + this(string, Global.instance()); 34.40 } 34.41 34.42 NativeRegExp(final NativeRegExp regExp) { 34.43 + this(Global.instance()); 34.44 this.lastIndex = regExp.getLastIndexObject(); 34.45 this.regexp = regExp.getRegExp(); 34.46 - init(); 34.47 } 34.48 34.49 @Override 34.50 @@ -615,7 +632,7 @@ 34.51 return null; 34.52 } 34.53 34.54 - return new NativeRegExpExecResult(match); 34.55 + return new NativeRegExpExecResult(match, globalObject); 34.56 } 34.57 34.58 /** 34.59 @@ -886,12 +903,6 @@ 34.60 this.lastIndex = JSType.toObject(lastIndex); 34.61 } 34.62 34.63 - private void init() { 34.64 - // Keep reference to global object to support "static" properties of RegExp 34.65 - this.globalObject = Global.instance(); 34.66 - this.setProto(globalObject.getRegExpPrototype()); 34.67 - } 34.68 - 34.69 private static NativeRegExp checkRegExp(final Object self) { 34.70 Global.checkObjectCoercible(self); 34.71 if (self instanceof NativeRegExp) {
35.1 --- a/src/jdk/nashorn/internal/objects/NativeRegExpExecResult.java Thu Jul 04 17:28:04 2013 +0200 35.2 +++ b/src/jdk/nashorn/internal/objects/NativeRegExpExecResult.java Fri Jul 05 14:38:04 2013 +0530 35.3 @@ -53,8 +53,12 @@ 35.4 // initialized by nasgen 35.5 private static PropertyMap $nasgenmap$; 35.6 35.7 - NativeRegExpExecResult(final RegExpResult result) { 35.8 - super(Global.instance().getArrayPrototype(), $nasgenmap$); 35.9 + static PropertyMap getInitialMap() { 35.10 + return $nasgenmap$; 35.11 + } 35.12 + 35.13 + NativeRegExpExecResult(final RegExpResult result, final Global global) { 35.14 + super(global.getArrayPrototype(), global.getRegExpExecResultMap()); 35.15 setIsArray(); 35.16 this.setArray(ArrayData.allocate(result.getGroups().clone())); 35.17 this.index = result.getIndex();
36.1 --- a/src/jdk/nashorn/internal/objects/NativeStrictArguments.java Thu Jul 04 17:28:04 2013 +0200 36.2 +++ b/src/jdk/nashorn/internal/objects/NativeStrictArguments.java Fri Jul 05 14:38:04 2013 +0530 36.3 @@ -64,11 +64,15 @@ 36.4 map$ = map; 36.5 } 36.6 36.7 + static PropertyMap getInitialMap() { 36.8 + return map$; 36.9 + } 36.10 + 36.11 private Object length; 36.12 private final Object[] namedArgs; 36.13 36.14 - NativeStrictArguments(final ScriptObject proto, final Object[] values, final int numParams) { 36.15 - super(proto, map$); 36.16 + NativeStrictArguments(final Object[] values, final int numParams,final ScriptObject proto, final PropertyMap map) { 36.17 + super(proto, map); 36.18 setIsArguments(); 36.19 36.20 final ScriptFunction func = ScriptFunctionImpl.getTypeErrorThrower(); 36.21 @@ -143,10 +147,6 @@ 36.22 } 36.23 36.24 private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) { 36.25 - try { 36.26 - return MethodHandles.lookup().findStatic(NativeStrictArguments.class, name, MH.type(rtype, types)); 36.27 - } catch (final NoSuchMethodException | IllegalAccessException e) { 36.28 - throw new MethodHandleFactory.LookupException(e); 36.29 - } 36.30 + return MH.findStatic(MethodHandles.lookup(), NativeStrictArguments.class, name, MH.type(rtype, types)); 36.31 } 36.32 }
37.1 --- a/src/jdk/nashorn/internal/objects/NativeString.java Thu Jul 04 17:28:04 2013 +0200 37.2 +++ b/src/jdk/nashorn/internal/objects/NativeString.java Fri Jul 05 14:38:04 2013 +0530 37.3 @@ -41,7 +41,7 @@ 37.4 import jdk.internal.dynalink.CallSiteDescriptor; 37.5 import jdk.internal.dynalink.linker.GuardedInvocation; 37.6 import jdk.internal.dynalink.linker.LinkRequest; 37.7 -import jdk.nashorn.internal.lookup.MethodHandleFactory; 37.8 +import jdk.nashorn.internal.lookup.MethodHandleFactory.LookupException; 37.9 import jdk.nashorn.internal.objects.annotations.Attribute; 37.10 import jdk.nashorn.internal.objects.annotations.Constructor; 37.11 import jdk.nashorn.internal.objects.annotations.Function; 37.12 @@ -74,12 +74,20 @@ 37.13 // initialized by nasgen 37.14 private static PropertyMap $nasgenmap$; 37.15 37.16 - NativeString(final CharSequence value) { 37.17 - this(value, Global.instance().getStringPrototype()); 37.18 + static PropertyMap getInitialMap() { 37.19 + return $nasgenmap$; 37.20 } 37.21 37.22 - private NativeString(final CharSequence value, final ScriptObject proto) { 37.23 - super(proto, $nasgenmap$); 37.24 + private NativeString(final CharSequence value) { 37.25 + this(value, Global.instance()); 37.26 + } 37.27 + 37.28 + NativeString(final CharSequence value, final Global global) { 37.29 + this(value, global.getStringPrototype(), global.getStringMap()); 37.30 + } 37.31 + 37.32 + private NativeString(final CharSequence value, final ScriptObject proto, final PropertyMap map) { 37.33 + super(proto, map); 37.34 assert value instanceof String || value instanceof ConsString; 37.35 this.value = value; 37.36 } 37.37 @@ -147,9 +155,9 @@ 37.38 37.39 if (returnType == Object.class && (self instanceof String || self instanceof ConsString)) { 37.40 try { 37.41 - MethodHandle mh = MethodHandles.lookup().findStatic(NativeString.class, "get", desc.getMethodType()); 37.42 + MethodHandle mh = MH.findStatic(MethodHandles.lookup(), NativeString.class, "get", desc.getMethodType()); 37.43 return new GuardedInvocation(mh, NashornGuards.getInstanceOf2Guard(String.class, ConsString.class)); 37.44 - } catch (final NoSuchMethodException | IllegalAccessException e) { 37.45 + } catch (final LookupException e) { 37.46 // Shouldn't happen. Fall back to super 37.47 } 37.48 } 37.49 @@ -1065,10 +1073,7 @@ 37.50 } 37.51 37.52 private static Object newObj(final Object self, final CharSequence str) { 37.53 - if (self instanceof ScriptObject) { 37.54 - return new NativeString(str, ((ScriptObject)self).getProto()); 37.55 - } 37.56 - return new NativeString(str, Global.instance().getStringPrototype()); 37.57 + return new NativeString(str); 37.58 } 37.59 37.60 /** 37.61 @@ -1202,10 +1207,6 @@ 37.62 } 37.63 37.64 private static MethodHandle findWrapFilter() { 37.65 - try { 37.66 - return MethodHandles.lookup().findStatic(NativeString.class, "wrapFilter", MH.type(NativeString.class, Object.class)); 37.67 - } catch (final NoSuchMethodException | IllegalAccessException e) { 37.68 - throw new MethodHandleFactory.LookupException(e); 37.69 - } 37.70 + return MH.findStatic(MethodHandles.lookup(), NativeString.class, "wrapFilter", MH.type(NativeString.class, Object.class)); 37.71 } 37.72 }
38.1 --- a/src/jdk/nashorn/internal/objects/NativeSyntaxError.java Thu Jul 04 17:28:04 2013 +0200 38.2 +++ b/src/jdk/nashorn/internal/objects/NativeSyntaxError.java Fri Jul 05 14:38:04 2013 +0530 38.3 @@ -58,8 +58,12 @@ 38.4 // initialized by nasgen 38.5 private static PropertyMap $nasgenmap$; 38.6 38.7 - NativeSyntaxError(final Object msg) { 38.8 - super(Global.instance().getSyntaxErrorPrototype(), $nasgenmap$); 38.9 + static PropertyMap getInitialMap() { 38.10 + return $nasgenmap$; 38.11 + } 38.12 + 38.13 + NativeSyntaxError(final Object msg, final Global global) { 38.14 + super(global.getSyntaxErrorPrototype(), global.getSyntaxErrorMap()); 38.15 if (msg != UNDEFINED) { 38.16 this.instMessage = JSType.toString(msg); 38.17 } else { 38.18 @@ -67,6 +71,10 @@ 38.19 } 38.20 } 38.21 38.22 + private NativeSyntaxError(final Object msg) { 38.23 + this(msg, Global.instance()); 38.24 + } 38.25 + 38.26 @Override 38.27 public String getClassName() { 38.28 return "Error";
39.1 --- a/src/jdk/nashorn/internal/objects/NativeTypeError.java Thu Jul 04 17:28:04 2013 +0200 39.2 +++ b/src/jdk/nashorn/internal/objects/NativeTypeError.java Fri Jul 05 14:38:04 2013 +0530 39.3 @@ -58,8 +58,12 @@ 39.4 // initialized by nasgen 39.5 private static PropertyMap $nasgenmap$; 39.6 39.7 - NativeTypeError(final Object msg) { 39.8 - super(Global.instance().getTypeErrorPrototype(), $nasgenmap$); 39.9 + static PropertyMap getInitialMap() { 39.10 + return $nasgenmap$; 39.11 + } 39.12 + 39.13 + NativeTypeError(final Object msg, final Global global) { 39.14 + super(global.getTypeErrorPrototype(), global.getTypeErrorMap()); 39.15 if (msg != UNDEFINED) { 39.16 this.instMessage = JSType.toString(msg); 39.17 } else { 39.18 @@ -67,6 +71,10 @@ 39.19 } 39.20 } 39.21 39.22 + private NativeTypeError(final Object msg) { 39.23 + this(msg, Global.instance()); 39.24 + } 39.25 + 39.26 @Override 39.27 public String getClassName() { 39.28 return "Error";
40.1 --- a/src/jdk/nashorn/internal/objects/NativeURIError.java Thu Jul 04 17:28:04 2013 +0200 40.2 +++ b/src/jdk/nashorn/internal/objects/NativeURIError.java Fri Jul 05 14:38:04 2013 +0530 40.3 @@ -57,8 +57,12 @@ 40.4 // initialized by nasgen 40.5 private static PropertyMap $nasgenmap$; 40.6 40.7 - NativeURIError(final Object msg) { 40.8 - super(Global.instance().getURIErrorPrototype(), $nasgenmap$); 40.9 + static PropertyMap getInitialMap() { 40.10 + return $nasgenmap$; 40.11 + } 40.12 + 40.13 + NativeURIError(final Object msg, final Global global) { 40.14 + super(global.getURIErrorPrototype(), global.getURIErrorMap()); 40.15 if (msg != UNDEFINED) { 40.16 this.instMessage = JSType.toString(msg); 40.17 } else { 40.18 @@ -66,6 +70,10 @@ 40.19 } 40.20 } 40.21 40.22 + private NativeURIError(final Object msg) { 40.23 + this(msg, Global.instance()); 40.24 + } 40.25 + 40.26 @Override 40.27 public String getClassName() { 40.28 return "Error";
41.1 --- a/src/jdk/nashorn/internal/objects/NativeUint16Array.java Thu Jul 04 17:28:04 2013 +0200 41.2 +++ b/src/jdk/nashorn/internal/objects/NativeUint16Array.java Fri Jul 05 14:38:04 2013 +0530 41.3 @@ -150,7 +150,7 @@ 41.4 } 41.5 41.6 @Override 41.7 - protected ScriptObject getPrototype() { 41.8 - return Global.instance().getUint16ArrayPrototype(); 41.9 + protected ScriptObject getPrototype(final Global global) { 41.10 + return global.getUint16ArrayPrototype(); 41.11 } 41.12 }
42.1 --- a/src/jdk/nashorn/internal/objects/NativeUint32Array.java Thu Jul 04 17:28:04 2013 +0200 42.2 +++ b/src/jdk/nashorn/internal/objects/NativeUint32Array.java Fri Jul 05 14:38:04 2013 +0530 42.3 @@ -169,7 +169,7 @@ 42.4 } 42.5 42.6 @Override 42.7 - protected ScriptObject getPrototype() { 42.8 - return Global.instance().getUint32ArrayPrototype(); 42.9 + protected ScriptObject getPrototype(final Global global) { 42.10 + return global.getUint32ArrayPrototype(); 42.11 } 42.12 }
43.1 --- a/src/jdk/nashorn/internal/objects/NativeUint8Array.java Thu Jul 04 17:28:04 2013 +0200 43.2 +++ b/src/jdk/nashorn/internal/objects/NativeUint8Array.java Fri Jul 05 14:38:04 2013 +0530 43.3 @@ -143,7 +143,7 @@ 43.4 } 43.5 43.6 @Override 43.7 - protected ScriptObject getPrototype() { 43.8 - return Global.instance().getUint8ArrayPrototype(); 43.9 + protected ScriptObject getPrototype(final Global global) { 43.10 + return global.getUint8ArrayPrototype(); 43.11 } 43.12 }
44.1 --- a/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java Thu Jul 04 17:28:04 2013 +0200 44.2 +++ b/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java Fri Jul 05 14:38:04 2013 +0530 44.3 @@ -160,7 +160,7 @@ 44.4 } 44.5 44.6 @Override 44.7 - protected ScriptObject getPrototype() { 44.8 - return Global.instance().getUint8ClampedArrayPrototype(); 44.9 + protected ScriptObject getPrototype(final Global global) { 44.10 + return global.getUint8ClampedArrayPrototype(); 44.11 } 44.12 }
45.1 --- a/src/jdk/nashorn/internal/objects/PrototypeObject.java Thu Jul 04 17:28:04 2013 +0200 45.2 +++ b/src/jdk/nashorn/internal/objects/PrototypeObject.java Fri Jul 05 14:38:04 2013 +0530 45.3 @@ -57,8 +57,17 @@ 45.4 map$ = map; 45.5 } 45.6 45.7 + static PropertyMap getInitialMap() { 45.8 + return map$; 45.9 + } 45.10 + 45.11 + private PrototypeObject(final Global global, final PropertyMap map) { 45.12 + super(map != map$? map.addAll(global.getPrototypeObjectMap()) : global.getPrototypeObjectMap()); 45.13 + setProto(global.getObjectPrototype()); 45.14 + } 45.15 + 45.16 PrototypeObject() { 45.17 - this(map$); 45.18 + this(Global.instance(), map$); 45.19 } 45.20 45.21 /** 45.22 @@ -67,12 +76,11 @@ 45.23 * @param map property map 45.24 */ 45.25 public PrototypeObject(final PropertyMap map) { 45.26 - super(map != map$ ? map.addAll(map$) : map$); 45.27 - setProto(Global.objectPrototype()); 45.28 + this(Global.instance(), map); 45.29 } 45.30 45.31 PrototypeObject(final ScriptFunction func) { 45.32 - this(map$); 45.33 + this(Global.instance(), map$); 45.34 this.constructor = func; 45.35 } 45.36 45.37 @@ -107,10 +115,6 @@ 45.38 } 45.39 45.40 private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) { 45.41 - try { 45.42 - return MethodHandles.lookup().findStatic(PrototypeObject.class, name, MH.type(rtype, types)); 45.43 - } catch (final NoSuchMethodException | IllegalAccessException e) { 45.44 - throw new MethodHandleFactory.LookupException(e); 45.45 - } 45.46 + return MH.findStatic(MethodHandles.lookup(), PrototypeObject.class, name, MH.type(rtype, types)); 45.47 } 45.48 }
46.1 --- a/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java Thu Jul 04 17:28:04 2013 +0200 46.2 +++ b/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java Fri Jul 05 14:38:04 2013 +0530 46.3 @@ -53,9 +53,26 @@ 46.4 // property map for non-strict, non-bound functions. 46.5 private static final PropertyMap map$; 46.6 46.7 + static PropertyMap getInitialMap() { 46.8 + return map$; 46.9 + } 46.10 + 46.11 + static PropertyMap getInitialStrictMap() { 46.12 + return strictmodemap$; 46.13 + } 46.14 + 46.15 + static PropertyMap getInitialBoundMap() { 46.16 + return boundfunctionmap$; 46.17 + } 46.18 + 46.19 // Marker object for lazily initialized prototype object 46.20 private static final Object LAZY_PROTOTYPE = new Object(); 46.21 46.22 + private ScriptFunctionImpl(final String name, final MethodHandle invokeHandle, final MethodHandle[] specs, final Global global) { 46.23 + super(name, invokeHandle, global.getFunctionMap(), null, specs, false, true, true); 46.24 + init(global); 46.25 + } 46.26 + 46.27 /** 46.28 * Constructor called by Nasgen generated code, no membercount, use the default map. 46.29 * Creates builtin functions only. 46.30 @@ -65,8 +82,12 @@ 46.31 * @param specs specialized versions of this method, if available, null otherwise 46.32 */ 46.33 ScriptFunctionImpl(final String name, final MethodHandle invokeHandle, final MethodHandle[] specs) { 46.34 - super(name, invokeHandle, map$, null, specs, false, true, true); 46.35 - init(); 46.36 + this(name, invokeHandle, specs, Global.instance()); 46.37 + } 46.38 + 46.39 + private ScriptFunctionImpl(final String name, final MethodHandle invokeHandle, final PropertyMap map, final MethodHandle[] specs, final Global global) { 46.40 + super(name, invokeHandle, map.addAll(global.getFunctionMap()), null, specs, false, true, true); 46.41 + init(global); 46.42 } 46.43 46.44 /** 46.45 @@ -79,8 +100,12 @@ 46.46 * @param specs specialized versions of this method, if available, null otherwise 46.47 */ 46.48 ScriptFunctionImpl(final String name, final MethodHandle invokeHandle, final PropertyMap map, final MethodHandle[] specs) { 46.49 - super(name, invokeHandle, map.addAll(map$), null, specs, false, true, true); 46.50 - init(); 46.51 + this(name, invokeHandle, map, specs, Global.instance()); 46.52 + } 46.53 + 46.54 + private ScriptFunctionImpl(final String name, final MethodHandle methodHandle, final ScriptObject scope, final MethodHandle[] specs, final boolean isStrict, final boolean isBuiltin, final boolean isConstructor, final Global global) { 46.55 + super(name, methodHandle, getMap(global, isStrict), scope, specs, isStrict, isBuiltin, isConstructor); 46.56 + init(global); 46.57 } 46.58 46.59 /** 46.60 @@ -95,8 +120,12 @@ 46.61 * @param isConstructor can the function be used as a constructor (most can; some built-ins are restricted). 46.62 */ 46.63 ScriptFunctionImpl(final String name, final MethodHandle methodHandle, final ScriptObject scope, final MethodHandle[] specs, final boolean isStrict, final boolean isBuiltin, final boolean isConstructor) { 46.64 - super(name, methodHandle, getMap(isStrict), scope, specs, isStrict, isBuiltin, isConstructor); 46.65 - init(); 46.66 + this(name, methodHandle, scope, specs, isStrict, isBuiltin, isConstructor, Global.instance()); 46.67 + } 46.68 + 46.69 + private ScriptFunctionImpl(final RecompilableScriptFunctionData data, final ScriptObject scope, final Global global) { 46.70 + super(data, getMap(global, data.isStrict()), scope); 46.71 + init(global); 46.72 } 46.73 46.74 /** 46.75 @@ -106,17 +135,17 @@ 46.76 * @param scope scope object 46.77 */ 46.78 public ScriptFunctionImpl(final RecompilableScriptFunctionData data, final ScriptObject scope) { 46.79 - super(data, getMap(data.isStrict()), scope); 46.80 - init(); 46.81 + this(data, scope, Global.instance()); 46.82 } 46.83 46.84 /** 46.85 * Only invoked internally from {@link BoundScriptFunctionImpl} constructor. 46.86 * @param data the script function data for the bound function. 46.87 + * @param global the global object 46.88 */ 46.89 - ScriptFunctionImpl(final ScriptFunctionData data) { 46.90 - super(data, boundfunctionmap$, null); 46.91 - init(); 46.92 + ScriptFunctionImpl(final ScriptFunctionData data, final Global global) { 46.93 + super(data, global.getBoundFunctionMap(), null); 46.94 + init(global); 46.95 } 46.96 46.97 static { 46.98 @@ -159,8 +188,8 @@ 46.99 } 46.100 46.101 // Choose the map based on strict mode! 46.102 - private static PropertyMap getMap(final boolean strict) { 46.103 - return strict ? strictmodemap$ : map$; 46.104 + private static PropertyMap getMap(final Global global, final boolean strict) { 46.105 + return strict ? global.getStrictFunctionMap() : global.getFunctionMap(); 46.106 } 46.107 46.108 private static PropertyMap createBoundFunctionMap(final PropertyMap strictModeMap) { 46.109 @@ -255,8 +284,8 @@ 46.110 } 46.111 46.112 // Internals below.. 46.113 - private void init() { 46.114 - this.setProto(Global.instance().getFunctionPrototype()); 46.115 + private void init(final Global global) { 46.116 + this.setProto(global.getFunctionPrototype()); 46.117 this.prototype = LAZY_PROTOTYPE; 46.118 46.119 // We have to fill user accessor functions late as these are stored
47.1 --- a/src/jdk/nashorn/internal/runtime/Context.java Thu Jul 04 17:28:04 2013 +0200 47.2 +++ b/src/jdk/nashorn/internal/runtime/Context.java Fri Jul 05 14:38:04 2013 +0530 47.3 @@ -36,7 +36,6 @@ 47.4 import java.io.PrintWriter; 47.5 import java.lang.invoke.MethodHandle; 47.6 import java.lang.invoke.MethodHandles; 47.7 -import java.lang.reflect.Constructor; 47.8 import java.net.MalformedURLException; 47.9 import java.net.URL; 47.10 import java.security.AccessControlContext; 47.11 @@ -55,6 +54,7 @@ 47.12 import jdk.nashorn.internal.ir.FunctionNode; 47.13 import jdk.nashorn.internal.ir.debug.ASTWriter; 47.14 import jdk.nashorn.internal.ir.debug.PrintVisitor; 47.15 +import jdk.nashorn.internal.objects.Global; 47.16 import jdk.nashorn.internal.parser.Parser; 47.17 import jdk.nashorn.internal.runtime.options.Options; 47.18 47.19 @@ -123,8 +123,8 @@ 47.20 sm.checkPermission(new RuntimePermission("nashorn.setGlobal")); 47.21 } 47.22 47.23 - if (global != null && !(global instanceof GlobalObject)) { 47.24 - throw new IllegalArgumentException("global does not implement GlobalObject!"); 47.25 + if (global != null && !(global instanceof Global)) { 47.26 + throw new IllegalArgumentException("global is not an instance of Global!"); 47.27 } 47.28 47.29 setGlobalTrusted(global); 47.30 @@ -257,8 +257,7 @@ 47.31 new PrivilegedAction<ClassLoader>() { 47.32 @Override 47.33 public ClassLoader run() { 47.34 - final StructureLoader structureLoader = new StructureLoader(sharedLoader, Context.this); 47.35 - return new ScriptLoader(structureLoader, Context.this); 47.36 + return new ScriptLoader(sharedLoader, Context.this); 47.37 } 47.38 }); 47.39 this.errors = errors; 47.40 @@ -817,25 +816,12 @@ 47.41 new PrivilegedAction<ScriptLoader>() { 47.42 @Override 47.43 public ScriptLoader run() { 47.44 - // Generated code won't refer to any class generated by context 47.45 - // script loader and so parent loader can be the structure 47.46 - // loader -- which is parent of the context script loader. 47.47 - return new ScriptLoader((StructureLoader)scriptLoader.getParent(), Context.this); 47.48 + return new ScriptLoader(sharedLoader, Context.this); 47.49 } 47.50 }); 47.51 } 47.52 47.53 private ScriptObject newGlobalTrusted() { 47.54 - try { 47.55 - final Class<?> clazz = Class.forName("jdk.nashorn.internal.objects.Global", true, scriptLoader); 47.56 - final Constructor<?> cstr = clazz.getConstructor(Context.class); 47.57 - return (ScriptObject) cstr.newInstance(this); 47.58 - } catch (final Exception e) { 47.59 - printStackTrace(e); 47.60 - if (e instanceof RuntimeException) { 47.61 - throw (RuntimeException)e; 47.62 - } 47.63 - throw new RuntimeException(e); 47.64 - } 47.65 + return new Global(this); 47.66 } 47.67 }
48.1 --- a/src/jdk/nashorn/internal/runtime/GlobalFunctions.java Thu Jul 04 17:28:04 2013 +0200 48.2 +++ b/src/jdk/nashorn/internal/runtime/GlobalFunctions.java Fri Jul 05 14:38:04 2013 +0530 48.3 @@ -34,9 +34,6 @@ 48.4 48.5 /** 48.6 * Utilities used by Global class. 48.7 - * 48.8 - * These are actual implementation methods for functions exposed by global 48.9 - * scope. The code lives here to share the code across the contexts. 48.10 */ 48.11 public final class GlobalFunctions { 48.12
49.1 --- a/src/jdk/nashorn/internal/runtime/GlobalObject.java Thu Jul 04 17:28:04 2013 +0200 49.2 +++ b/src/jdk/nashorn/internal/runtime/GlobalObject.java Fri Jul 05 14:38:04 2013 +0530 49.3 @@ -30,14 +30,7 @@ 49.4 import jdk.internal.dynalink.linker.LinkRequest; 49.5 49.6 /** 49.7 - * Runtime interface to the global scope of the current context. 49.8 - * NOTE: never access {@code jdk.nashorn.internal.objects.Global} class directly 49.9 - * from runtime/parser/codegen/ir etc. Always go through this interface. 49.10 - * <p> 49.11 - * The reason for this is that all objects in the @{code jdk.nashorn.internal.objects.*} package 49.12 - * are different per Context and loaded separately by each Context class loader. Attempting 49.13 - * to directly refer to an object in this package from the rest of the runtime 49.14 - * will lead to {@code ClassNotFoundException} thrown upon link time 49.15 + * Runtime interface to the global scope objects. 49.16 */ 49.17 49.18 public interface GlobalObject {
50.1 --- a/src/jdk/nashorn/internal/runtime/ScriptObject.java Thu Jul 04 17:28:04 2013 +0200 50.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java Fri Jul 05 14:38:04 2013 +0530 50.3 @@ -1027,6 +1027,15 @@ 50.4 } 50.5 50.6 /** 50.7 + * Set the current context. 50.8 + * @param ctx context instance to set 50.9 + */ 50.10 + protected final void setContext(final Context ctx) { 50.11 + ctx.getClass(); 50.12 + this.context = ctx; 50.13 + } 50.14 + 50.15 + /** 50.16 * Return the map of an object. 50.17 * @return PropertyMap object. 50.18 */
51.1 --- a/src/jdk/nashorn/internal/runtime/StructureLoader.java Thu Jul 04 17:28:04 2013 +0200 51.2 +++ b/src/jdk/nashorn/internal/runtime/StructureLoader.java Fri Jul 05 14:38:04 2013 +0530 51.3 @@ -25,30 +25,19 @@ 51.4 51.5 package jdk.nashorn.internal.runtime; 51.6 51.7 -import static jdk.nashorn.internal.codegen.Compiler.OBJECTS_PACKAGE; 51.8 import static jdk.nashorn.internal.codegen.Compiler.SCRIPTS_PACKAGE; 51.9 import static jdk.nashorn.internal.codegen.Compiler.binaryName; 51.10 import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_PREFIX; 51.11 51.12 -import java.io.IOException; 51.13 -import java.io.InputStream; 51.14 -import java.net.URL; 51.15 -import java.security.AccessController; 51.16 -import java.security.CodeSigner; 51.17 -import java.security.CodeSource; 51.18 -import java.security.PrivilegedActionException; 51.19 -import java.security.PrivilegedExceptionAction; 51.20 import java.security.ProtectionDomain; 51.21 import jdk.nashorn.internal.codegen.ObjectClassGenerator; 51.22 51.23 /** 51.24 - * Responsible for on the fly construction of structure classes as well 51.25 - * as loading jdk.nashorn.internal.objects.* classes. 51.26 + * Responsible for on the fly construction of structure classes. 51.27 * 51.28 */ 51.29 final class StructureLoader extends NashornLoader { 51.30 private static final String JS_OBJECT_PREFIX_EXTERNAL = binaryName(SCRIPTS_PACKAGE) + '.' + JS_OBJECT_PREFIX.symbolName(); 51.31 - private static final String OBJECTS_PACKAGE_EXTERNAL = binaryName(OBJECTS_PACKAGE); 51.32 51.33 /** 51.34 * Constructor. 51.35 @@ -68,45 +57,9 @@ 51.36 return loadedClass; 51.37 } 51.38 51.39 - if (name.startsWith(binaryName(OBJECTS_PACKAGE_EXTERNAL))) { 51.40 - try { 51.41 - return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() { 51.42 - @Override 51.43 - public Class<?> run() throws ClassNotFoundException { 51.44 - final String source = name.replace('.','/') + ".clazz"; 51.45 - final URL url = getResource(source); 51.46 - try (final InputStream is = getResourceAsStream(source)) { 51.47 - if (is == null) { 51.48 - throw new ClassNotFoundException(name); 51.49 - } 51.50 - 51.51 - byte[] code; 51.52 - try { 51.53 - code = Source.readBytes(is); 51.54 - } catch (final IOException e) { 51.55 - Context.printStackTrace(e); 51.56 - throw new ClassNotFoundException(name, e); 51.57 - } 51.58 - 51.59 - final Class<?> cl = defineClass(name, code, 0, code.length, new CodeSource(url, (CodeSigner[])null)); 51.60 - if (resolve) { 51.61 - resolveClass(cl); 51.62 - } 51.63 - return cl; 51.64 - } catch (final IOException e) { 51.65 - throw new RuntimeException(e); 51.66 - } 51.67 - } 51.68 - }); 51.69 - } catch (final PrivilegedActionException e) { 51.70 - throw new ClassNotFoundException(name, e); 51.71 - } 51.72 - } 51.73 - 51.74 return super.loadClassTrusted(name, resolve); 51.75 } 51.76 51.77 - 51.78 @Override 51.79 protected Class<?> findClass(final String name) throws ClassNotFoundException { 51.80 if (name.startsWith(JS_OBJECT_PREFIX_EXTERNAL)) {
52.1 --- a/src/jdk/nashorn/internal/scripts/JO.java Thu Jul 04 17:28:04 2013 +0200 52.2 +++ b/src/jdk/nashorn/internal/scripts/JO.java Fri Jul 05 14:38:04 2013 +0530 52.3 @@ -36,10 +36,11 @@ 52.4 private static final PropertyMap map$ = PropertyMap.newMap(JO.class); 52.5 52.6 /** 52.7 - * Constructor 52.8 + * Returns the initial property map to be used. 52.9 + * @return the initial property map. 52.10 */ 52.11 - public JO() { 52.12 - super(map$); 52.13 + public static PropertyMap getInitialMap() { 52.14 + return map$; 52.15 } 52.16 52.17 /** 52.18 @@ -52,16 +53,17 @@ 52.19 } 52.20 52.21 /** 52.22 - * Constructor given an initial prototype using the default property map 52.23 + * Constructor given an initial prototype and an initial property map. 52.24 * 52.25 * @param proto the prototype object 52.26 + * @param map the property map 52.27 */ 52.28 - public JO(final ScriptObject proto) { 52.29 - super(proto, map$); 52.30 + public JO(final ScriptObject proto, final PropertyMap map) { 52.31 + super(proto, map); 52.32 } 52.33 52.34 /** 52.35 - * Used by FunctionObjectCreator. A method handle of this method is passed to the ScriptFunction constructor. 52.36 + * A method handle of this method is passed to the ScriptFunction constructor. 52.37 * 52.38 * @param map the property map to use for allocatorMap 52.39 *
53.1 --- a/src/jdk/nashorn/tools/Shell.java Thu Jul 04 17:28:04 2013 +0200 53.2 +++ b/src/jdk/nashorn/tools/Shell.java Fri Jul 05 14:38:04 2013 +0530 53.3 @@ -47,6 +47,7 @@ 53.4 import jdk.nashorn.internal.parser.Parser; 53.5 import jdk.nashorn.internal.runtime.Context; 53.6 import jdk.nashorn.internal.runtime.ErrorManager; 53.7 +import jdk.nashorn.internal.runtime.JSType; 53.8 import jdk.nashorn.internal.runtime.Property; 53.9 import jdk.nashorn.internal.runtime.ScriptEnvironment; 53.10 import jdk.nashorn.internal.runtime.ScriptFunction; 53.11 @@ -446,7 +447,7 @@ 53.12 } 53.13 53.14 if (res != null && res != ScriptRuntime.UNDEFINED) { 53.15 - err.println(ScriptRuntime.safeToString(res)); 53.16 + err.println(JSType.toString(res)); 53.17 } 53.18 } 53.19 } finally {
54.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 54.2 +++ b/test/script/basic/JDK-8019947.js Fri Jul 05 14:38:04 2013 +0530 54.3 @@ -0,0 +1,68 @@ 54.4 +/* 54.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 54.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 54.7 + * 54.8 + * This code is free software; you can redistribute it and/or modify it 54.9 + * under the terms of the GNU General Public License version 2 only, as 54.10 + * published by the Free Software Foundation. 54.11 + * 54.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 54.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 54.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 54.15 + * version 2 for more details (a copy is included in the LICENSE file that 54.16 + * accompanied this code). 54.17 + * 54.18 + * You should have received a copy of the GNU General Public License version 54.19 + * 2 along with this work; if not, write to the Free Software Foundation, 54.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 54.21 + * 54.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 54.23 + * or visit www.oracle.com if you need additional information or have any 54.24 + * questions. 54.25 + */ 54.26 + 54.27 +/** 54.28 + * JDK-8019947: inherited property invalidation does not work with two globals in same context 54.29 + * 54.30 + * @test 54.31 + * @option -scripting 54.32 + * @run 54.33 + */ 54.34 + 54.35 +function func(arr) { 54.36 + try { 54.37 + print(arr.toString()); 54.38 + } catch (e) { 54.39 + print(e.stack); 54.40 + } 54.41 +} 54.42 + 54.43 +var arr = ["hello", "world"] 54.44 + 54.45 +func(arr); 54.46 + 54.47 +var global = loadWithNewGlobal({ 54.48 + name: "t", 54.49 + script: <<EOF 54.50 + 54.51 + 54.52 +function func(arr) { 54.53 + try { 54.54 + print(arr.toString()); 54.55 + } catch (e) { 54.56 + print(e.stack); 54.57 + } 54.58 +} 54.59 + 54.60 +var arr = [1, 2, 3]; 54.61 + 54.62 +func(arr); 54.63 + 54.64 +delete Array.prototype.toString; 54.65 + 54.66 +// Object.prototype.toString should be visible 54.67 +// after Array.prototype.toString is deleted. 54.68 +func(arr); 54.69 +this; 54.70 +EOF 54.71 +});
55.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 55.2 +++ b/test/script/basic/JDK-8019947.js.EXPECTED Fri Jul 05 14:38:04 2013 +0530 55.3 @@ -0,0 +1,3 @@ 55.4 +hello,world 55.5 +1,2,3 55.6 +[object Array]