Thu, 27 Jun 2013 13:47:20 +0530
Merge
1.1 --- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java Fri Jun 21 17:33:05 2013 +0530 1.2 +++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java Thu Jun 27 13:47:20 2013 +0530 1.3 @@ -166,11 +166,11 @@ 1.4 mi.putStatic(className, MAP_FIELD_NAME, MAP_DESC); 1.5 mi.loadClass(className); 1.6 mi.invokeStatic(MAP_TYPE, MAP_NEWMAP, MAP_NEWMAP_DESC); 1.7 - mi.storeLocal(0); 1.8 + // stack: PropertyMap 1.9 } 1.10 1.11 static void emitStaticInitSuffix(final MethodGenerator mi, final String className) { 1.12 - mi.loadLocal(0); 1.13 + // stack: PropertyMap 1.14 mi.putStatic(className, MAP_FIELD_NAME, MAP_DESC); 1.15 mi.returnVoid(); 1.16 mi.computeMaxs(); 1.17 @@ -278,7 +278,7 @@ 1.18 1.19 static void linkerAddGetterSetter(final MethodGenerator mi, final String className, final MemberInfo memInfo) { 1.20 final String propertyName = memInfo.getName(); 1.21 - mi.loadLocal(0); 1.22 + // stack: PropertyMap 1.23 mi.loadLiteral(propertyName); 1.24 // setup flags 1.25 mi.push(memInfo.getAttributes()); 1.26 @@ -293,12 +293,12 @@ 1.27 mi.visitLdcInsn(new Handle(H_INVOKEVIRTUAL, className, javaName, setterDesc(memInfo))); 1.28 } 1.29 mi.invokeStatic(LOOKUP_TYPE, LOOKUP_NEWPROPERTY, LOOKUP_NEWPROPERTY_DESC); 1.30 - mi.storeLocal(0); 1.31 + // stack: PropertyMap 1.32 } 1.33 1.34 static void linkerAddGetterSetter(final MethodGenerator mi, final String className, final MemberInfo getter, final MemberInfo setter) { 1.35 final String propertyName = getter.getName(); 1.36 - mi.loadLocal(0); 1.37 + // stack: PropertyMap 1.38 mi.loadLiteral(propertyName); 1.39 // setup flags 1.40 mi.push(getter.getAttributes()); 1.41 @@ -313,7 +313,7 @@ 1.42 setter.getJavaName(), setter.getJavaDesc())); 1.43 } 1.44 mi.invokeStatic(LOOKUP_TYPE, LOOKUP_NEWPROPERTY, LOOKUP_NEWPROPERTY_DESC); 1.45 - mi.storeLocal(0); 1.46 + // stack: PropertyMap 1.47 } 1.48 1.49 static ScriptClassInfo getScriptClassInfo(final String fileName) throws IOException {
2.1 --- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInstrumentor.java Fri Jun 21 17:33:05 2013 +0530 2.2 +++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInstrumentor.java Thu Jun 27 13:47:20 2013 +0530 2.3 @@ -159,10 +159,14 @@ 2.4 public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc) { 2.5 if (isConstructor && opcode == INVOKESPECIAL && 2.6 INIT.equals(name) && SCRIPTOBJECT_TYPE.equals(owner)) { 2.7 - super.visitFieldInsn(GETSTATIC, scriptClassInfo.getJavaName(), 2.8 - MAP_FIELD_NAME, MAP_DESC); 2.9 - super.visitMethodInsn(INVOKESPECIAL, SCRIPTOBJECT_TYPE, INIT, 2.10 - SCRIPTOBJECT_INIT_DESC); 2.11 + 2.12 + // replace call to empty super-constructor with one passing PropertyMap argument 2.13 + if (DEFAULT_INIT_DESC.equals(desc)) { 2.14 + super.visitFieldInsn(GETSTATIC, scriptClassInfo.getJavaName(), MAP_FIELD_NAME, MAP_DESC); 2.15 + super.visitMethodInsn(INVOKESPECIAL, SCRIPTOBJECT_TYPE, INIT, SCRIPTOBJECT_INIT_DESC); 2.16 + } else { 2.17 + super.visitMethodInsn(opcode, owner, name, desc); 2.18 + } 2.19 2.20 if (memberCount > 0) { 2.21 // initialize @Property fields if needed 2.22 @@ -223,7 +227,7 @@ 2.23 ClassGenerator.addSetter(cv, className, memInfo); 2.24 } 2.25 } 2.26 - ClassGenerator.addMapField(this); 2.27 + // omit addMapField() since instance classes already define a static PropertyMap field 2.28 } 2.29 2.30 void emitGettersSetters() {
3.1 --- a/docs/JavaScriptingProgrammersGuide.html Fri Jun 21 17:33:05 2013 +0530 3.2 +++ b/docs/JavaScriptingProgrammersGuide.html Thu Jun 27 13:47:20 2013 +0530 3.3 @@ -227,6 +227,16 @@ 3.4 it. Note that the syntax to access Java objects, methods and fields 3.5 is dependent on the scripting language. JavaScript supports the 3.6 most "natural" Java-like syntax.</p> 3.7 +<p> 3.8 +Nashorn script engine pre-defines two global variables named "context" 3.9 +and "engine". The "context" variable is of type javax.script.ScriptContext 3.10 +and refers to the current ScriptContext instance passed to script engine's 3.11 +eval method. The "engine" variable is of type javax.script.ScriptEngine and 3.12 +refers to the current nashorn script engine instance evaluating the script. 3.13 +Both of these variables are non-writable, non-enumerable and non-configurable 3.14 +- which implies script code can not write overwrite the value, for..loop iteration 3.15 +on global object will not iterate these variables and these variables can not be 3.16 +deleted by script. 3.17 <pre><code> 3.18 // <a href="source/ScriptVars.java">ScriptVars.java</a> 3.19
4.1 --- a/src/jdk/nashorn/api/scripting/JSObject.java Fri Jun 21 17:33:05 2013 +0530 4.2 +++ b/src/jdk/nashorn/api/scripting/JSObject.java Thu Jun 27 13:47:20 2013 +0530 4.3 @@ -30,13 +30,23 @@ 4.4 */ 4.5 public abstract class JSObject { 4.6 /** 4.7 - * Call a JavaScript method 4.8 + * Call a JavaScript function 4.9 * 4.10 - * @param methodName name of method 4.11 + * @param functionName name of function 4.12 * @param args arguments to method 4.13 * @return result of call 4.14 */ 4.15 - public abstract Object call(String methodName, Object args[]); 4.16 + public abstract Object call(String functionName, Object... args); 4.17 + 4.18 + /** 4.19 + * Call a JavaScript method as a constructor. This is equivalent to 4.20 + * calling new obj.Method(arg1, arg2...) in JavaScript. 4.21 + * 4.22 + * @param functionName name of function 4.23 + * @param args arguments to method 4.24 + * @return result of constructor call 4.25 + */ 4.26 + public abstract Object newObject(String functionName, Object... args); 4.27 4.28 /** 4.29 * Evaluate a JavaScript expression
5.1 --- a/src/jdk/nashorn/api/scripting/NashornException.java Fri Jun 21 17:33:05 2013 +0530 5.2 +++ b/src/jdk/nashorn/api/scripting/NashornException.java Thu Jun 27 13:47:20 2013 +0530 5.3 @@ -25,6 +25,9 @@ 5.4 5.5 package jdk.nashorn.api.scripting; 5.6 5.7 +import java.util.ArrayList; 5.8 +import java.util.List; 5.9 +import jdk.nashorn.internal.codegen.CompilerConstants; 5.10 import jdk.nashorn.internal.runtime.ECMAErrors; 5.11 5.12 /** 5.13 @@ -136,4 +139,52 @@ 5.14 return column; 5.15 } 5.16 5.17 + /** 5.18 + * Returns array javascript stack frames from the given exception object. 5.19 + * 5.20 + * @param exception exception from which stack frames are retrieved and filtered 5.21 + * @return array of javascript stack frames 5.22 + */ 5.23 + public static StackTraceElement[] getScriptFrames(final Throwable exception) { 5.24 + final StackTraceElement[] frames = ((Throwable)exception).getStackTrace(); 5.25 + final List<StackTraceElement> filtered = new ArrayList<>(); 5.26 + for (final StackTraceElement st : frames) { 5.27 + if (ECMAErrors.isScriptFrame(st)) { 5.28 + final String className = "<" + st.getFileName() + ">"; 5.29 + String methodName = st.getMethodName(); 5.30 + if (methodName.equals(CompilerConstants.RUN_SCRIPT.symbolName())) { 5.31 + methodName = "<program>"; 5.32 + } 5.33 + filtered.add(new StackTraceElement(className, methodName, 5.34 + st.getFileName(), st.getLineNumber())); 5.35 + } 5.36 + } 5.37 + return filtered.toArray(new StackTraceElement[filtered.size()]); 5.38 + } 5.39 + 5.40 + /** 5.41 + * Return a formatted script stack trace string with frames information separated by '\n' 5.42 + * 5.43 + * @param exception exception for which script stack string is returned 5.44 + * @return formatted stack trace string 5.45 + */ 5.46 + public static String getScriptStackString(final Throwable exception) { 5.47 + final StringBuilder buf = new StringBuilder(); 5.48 + final StackTraceElement[] frames = getScriptFrames((Throwable)exception); 5.49 + for (final StackTraceElement st : frames) { 5.50 + buf.append(st.getMethodName()); 5.51 + buf.append(" @ "); 5.52 + buf.append(st.getFileName()); 5.53 + buf.append(':'); 5.54 + buf.append(st.getLineNumber()); 5.55 + buf.append('\n'); 5.56 + } 5.57 + final int len = buf.length(); 5.58 + // remove trailing '\n' 5.59 + if (len > 0) { 5.60 + assert buf.charAt(len - 1) == '\n'; 5.61 + buf.deleteCharAt(len - 1); 5.62 + } 5.63 + return buf.toString(); 5.64 + } 5.65 }
6.1 --- a/src/jdk/nashorn/api/scripting/NashornScriptEngine.java Fri Jun 21 17:33:05 2013 +0530 6.2 +++ b/src/jdk/nashorn/api/scripting/NashornScriptEngine.java Thu Jun 27 13:47:20 2013 +0530 6.3 @@ -71,6 +71,9 @@ 6.4 private final ScriptEngineFactory factory; 6.5 private final Context nashornContext; 6.6 private final ScriptObject global; 6.7 + // initialized bit late to be made 'final'. Property object for "context" 6.8 + // property of global object 6.9 + private Property contextProperty; 6.10 6.11 // default options passed to Nashorn Options object 6.12 private static final String[] DEFAULT_OPTIONS = new String[] { "-scripting", "-doe" }; 6.13 @@ -281,13 +284,16 @@ 6.14 6.15 nashornContext.initGlobal(newGlobal); 6.16 6.17 + final int NON_ENUMERABLE_CONSTANT = Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE | Property.NOT_WRITABLE; 6.18 // current ScriptContext exposed as "context" 6.19 - newGlobal.addOwnProperty("context", Property.NOT_ENUMERABLE, UNDEFINED); 6.20 + // "context" is non-writable from script - but script engine still 6.21 + // needs to set it and so save the context Property object 6.22 + contextProperty = newGlobal.addOwnProperty("context", NON_ENUMERABLE_CONSTANT, UNDEFINED); 6.23 // current ScriptEngine instance exposed as "engine". We added @SuppressWarnings("LeakingThisInConstructor") as 6.24 // NetBeans identifies this assignment as such a leak - this is a false positive as we're setting this property 6.25 // in the Global of a Context we just created - both the Context and the Global were just created and can not be 6.26 // seen from another thread outside of this constructor. 6.27 - newGlobal.addOwnProperty("engine", Property.NOT_ENUMERABLE, this); 6.28 + newGlobal.addOwnProperty("engine", NON_ENUMERABLE_CONSTANT, this); 6.29 // global script arguments with undefined value 6.30 newGlobal.addOwnProperty("arguments", Property.NOT_ENUMERABLE, UNDEFINED); 6.31 // file name default is null 6.32 @@ -322,9 +328,10 @@ 6.33 6.34 // scripts should see "context" and "engine" as variables 6.35 private void setContextVariables(final ScriptContext ctxt) { 6.36 - ctxt.setAttribute("context", ctxt, ScriptContext.ENGINE_SCOPE); 6.37 final ScriptObject ctxtGlobal = getNashornGlobalFrom(ctxt); 6.38 - ctxtGlobal.set("context", ctxt, false); 6.39 + // set "context" global variable via contextProperty - because this 6.40 + // property is non-writable 6.41 + contextProperty.setObjectValue(ctxtGlobal, ctxtGlobal, ctxt, false); 6.42 Object args = ScriptObjectMirror.unwrap(ctxt.getAttribute("arguments"), ctxtGlobal); 6.43 if (args == null || args == UNDEFINED) { 6.44 args = ScriptRuntime.EMPTY_ARRAY;
7.1 --- a/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java Fri Jun 21 17:33:05 2013 +0530 7.2 +++ b/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java Thu Jun 27 13:47:20 2013 +0530 7.3 @@ -102,7 +102,7 @@ 7.4 7.5 // JSObject methods 7.6 @Override 7.7 - public Object call(final String methodName, final Object args[]) { 7.8 + public Object call(final String functionName, final Object... args) { 7.9 final ScriptObject oldGlobal = NashornScriptEngine.getNashornGlobal(); 7.10 final boolean globalChanged = (oldGlobal != global); 7.11 7.12 @@ -111,9 +111,9 @@ 7.13 NashornScriptEngine.setNashornGlobal(global); 7.14 } 7.15 7.16 - final Object val = sobj.get(methodName); 7.17 + final Object val = functionName == null? sobj : sobj.get(functionName); 7.18 if (! (val instanceof ScriptFunction)) { 7.19 - throw new RuntimeException("No such method: " + methodName); 7.20 + throw new RuntimeException("No such function " + ((functionName != null)? functionName : "")); 7.21 } 7.22 7.23 final Object[] modArgs = globalChanged? wrapArray(args, oldGlobal) : args; 7.24 @@ -130,6 +130,34 @@ 7.25 } 7.26 7.27 @Override 7.28 + public Object newObject(final String functionName, final Object... args) { 7.29 + final ScriptObject oldGlobal = NashornScriptEngine.getNashornGlobal(); 7.30 + final boolean globalChanged = (oldGlobal != global); 7.31 + 7.32 + try { 7.33 + if (globalChanged) { 7.34 + NashornScriptEngine.setNashornGlobal(global); 7.35 + } 7.36 + 7.37 + final Object val = functionName == null? sobj : sobj.get(functionName); 7.38 + if (! (val instanceof ScriptFunction)) { 7.39 + throw new RuntimeException("not a constructor " + ((functionName != null)? functionName : "")); 7.40 + } 7.41 + 7.42 + final Object[] modArgs = globalChanged? wrapArray(args, oldGlobal) : args; 7.43 + return wrap(ScriptRuntime.checkAndConstruct((ScriptFunction)val, unwrapArray(modArgs, global)), global); 7.44 + } catch (final RuntimeException | Error e) { 7.45 + throw e; 7.46 + } catch (final Throwable t) { 7.47 + throw new RuntimeException(t); 7.48 + } finally { 7.49 + if (globalChanged) { 7.50 + NashornScriptEngine.setNashornGlobal(oldGlobal); 7.51 + } 7.52 + } 7.53 + } 7.54 + 7.55 + @Override 7.56 public Object eval(final String s) { 7.57 return inGlobal(new Callable<Object>() { 7.58 @Override
8.1 --- a/src/jdk/nashorn/internal/codegen/ClassEmitter.java Fri Jun 21 17:33:05 2013 +0530 8.2 +++ b/src/jdk/nashorn/internal/codegen/ClassEmitter.java Thu Jun 27 13:47:20 2013 +0530 8.3 @@ -165,7 +165,8 @@ 8.4 /** 8.5 * Constructor from the compiler 8.6 * 8.7 - * @param compiler Compiler 8.8 + * @param env Script environment 8.9 + * @param sourceName Source name 8.10 * @param unitClassName Compile unit class name. 8.11 * @param strictMode Should we generate this method in strict mode 8.12 */
9.1 --- a/src/jdk/nashorn/internal/codegen/CodeGenerator.java Fri Jun 21 17:33:05 2013 +0530 9.2 +++ b/src/jdk/nashorn/internal/codegen/CodeGenerator.java Thu Jun 27 13:47:20 2013 +0530 9.3 @@ -244,7 +244,7 @@ 9.4 /** 9.5 * Check if this symbol can be accessed directly with a putfield or getfield or dynamic load 9.6 * 9.7 - * @param function function to check for fast scope 9.8 + * @param symbol symbol to check for fast scope 9.9 * @return true if fast scope 9.10 */ 9.11 private boolean isFastScope(final Symbol symbol) { 9.12 @@ -1016,6 +1016,8 @@ 9.13 assert lc.hasCompileUnits(); 9.14 9.15 method = lc.pushMethodEmitter(unit.getClassEmitter().method(functionNode)); 9.16 + // new method - reset last line number 9.17 + lastLineNumber = -1; 9.18 // Mark end for variable tables. 9.19 method.begin(); 9.20 9.21 @@ -1093,7 +1095,7 @@ 9.22 private void lineNumber(final Statement statement) { 9.23 final int lineNumber = statement.getLineNumber(); 9.24 if (lineNumber != lastLineNumber) { 9.25 - method.lineNumber(statement.getLineNumber()); 9.26 + method.lineNumber(lineNumber); 9.27 } 9.28 lastLineNumber = lineNumber; 9.29 }
10.1 --- a/src/jdk/nashorn/internal/codegen/Compiler.java Fri Jun 21 17:33:05 2013 +0530 10.2 +++ b/src/jdk/nashorn/internal/codegen/Compiler.java Thu Jun 27 13:47:20 2013 +0530 10.3 @@ -245,9 +245,9 @@ 10.4 /** 10.5 * Constructor 10.6 * 10.7 + * @param env script environment 10.8 * @param installer code installer 10.9 - * @param functionNode function node (in any available {@link CompilationState}) to compile 10.10 - * @param sequence {@link Compiler#CompilationSequence} of {@link CompilationPhase}s to apply as this compilation 10.11 + * @param sequence {@link Compiler.CompilationSequence} of {@link CompilationPhase}s to apply as this compilation 10.12 * @param strict should this compilation use strict mode semantics 10.13 */ 10.14 //TODO support an array of FunctionNodes for batch lazy compilation
11.1 --- a/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java Fri Jun 21 17:33:05 2013 +0530 11.2 +++ b/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java Thu Jun 27 13:47:20 2013 +0530 11.3 @@ -82,13 +82,13 @@ 11.4 * Debug field logger 11.5 * Should we print debugging information for fields when they are generated and getters/setters are called? 11.6 */ 11.7 - public static final DebugLogger LOG = new DebugLogger("fields", "nashorn.fields.debug"); 11.8 + public static final DebugLogger LOG = new DebugLogger("fields", "nashorn.fields.debug"); 11.9 11.10 /** 11.11 * is field debugging enabled. Several modules in codegen and properties use this, hence 11.12 * public access. 11.13 */ 11.14 - public static final boolean DEBUG_FIELDS = LOG.isEnabled(); 11.15 + public static final boolean DEBUG_FIELDS = LOG.isEnabled(); 11.16 11.17 /** 11.18 * Should the runtime only use java.lang.Object slots for fields? If this is false, the representation
12.1 --- a/src/jdk/nashorn/internal/objects/AccessorPropertyDescriptor.java Fri Jun 21 17:33:05 2013 +0530 12.2 +++ b/src/jdk/nashorn/internal/objects/AccessorPropertyDescriptor.java Thu Jun 27 13:47:20 2013 +0530 12.3 @@ -34,6 +34,7 @@ 12.4 import jdk.nashorn.internal.objects.annotations.ScriptClass; 12.5 import jdk.nashorn.internal.runtime.JSType; 12.6 import jdk.nashorn.internal.runtime.PropertyDescriptor; 12.7 +import jdk.nashorn.internal.runtime.PropertyMap; 12.8 import jdk.nashorn.internal.runtime.ScriptFunction; 12.9 import jdk.nashorn.internal.runtime.ScriptObject; 12.10 import jdk.nashorn.internal.runtime.ScriptRuntime; 12.11 @@ -63,16 +64,19 @@ 12.12 @Property 12.13 public Object set; 12.14 12.15 + // initialized by nasgen 12.16 + private static PropertyMap $nasgenmap$; 12.17 + 12.18 AccessorPropertyDescriptor() { 12.19 this(false, false, UNDEFINED, UNDEFINED); 12.20 } 12.21 12.22 AccessorPropertyDescriptor(final boolean configurable, final boolean enumerable, final Object get, final Object set) { 12.23 + super(Global.objectPrototype(), $nasgenmap$); 12.24 this.configurable = configurable; 12.25 this.enumerable = enumerable; 12.26 this.get = get; 12.27 this.set = set; 12.28 - setProto(Global.objectPrototype()); 12.29 } 12.30 12.31 @Override
13.1 --- a/src/jdk/nashorn/internal/objects/ArrayBufferView.java Fri Jun 21 17:33:05 2013 +0530 13.2 +++ b/src/jdk/nashorn/internal/objects/ArrayBufferView.java Thu Jun 27 13:47:20 2013 +0530 13.3 @@ -29,6 +29,7 @@ 13.4 import jdk.nashorn.internal.objects.annotations.Getter; 13.5 import jdk.nashorn.internal.objects.annotations.ScriptClass; 13.6 import jdk.nashorn.internal.runtime.JSType; 13.7 +import jdk.nashorn.internal.runtime.PropertyMap; 13.8 import jdk.nashorn.internal.runtime.ScriptObject; 13.9 import jdk.nashorn.internal.runtime.ScriptRuntime; 13.10 import jdk.nashorn.internal.runtime.arrays.ArrayData; 13.11 @@ -38,6 +39,9 @@ 13.12 @ScriptClass("ArrayBufferView") 13.13 abstract class ArrayBufferView extends ScriptObject { 13.14 13.15 + // initialized by nasgen 13.16 + private static PropertyMap $nasgenmap$; 13.17 + 13.18 ArrayBufferView(final NativeArrayBuffer buffer, final int byteOffset, final int elementLength) { 13.19 checkConstructorArgs(buffer, byteOffset, elementLength); 13.20 this.setProto(getPrototype());
14.1 --- a/src/jdk/nashorn/internal/objects/DataPropertyDescriptor.java Fri Jun 21 17:33:05 2013 +0530 14.2 +++ b/src/jdk/nashorn/internal/objects/DataPropertyDescriptor.java Thu Jun 27 13:47:20 2013 +0530 14.3 @@ -33,6 +33,7 @@ 14.4 import jdk.nashorn.internal.objects.annotations.ScriptClass; 14.5 import jdk.nashorn.internal.runtime.JSType; 14.6 import jdk.nashorn.internal.runtime.PropertyDescriptor; 14.7 +import jdk.nashorn.internal.runtime.PropertyMap; 14.8 import jdk.nashorn.internal.runtime.ScriptFunction; 14.9 import jdk.nashorn.internal.runtime.ScriptObject; 14.10 14.11 @@ -61,16 +62,19 @@ 14.12 @Property 14.13 public Object value; 14.14 14.15 + // initialized by nasgen 14.16 + private static PropertyMap $nasgenmap$; 14.17 + 14.18 DataPropertyDescriptor() { 14.19 this(false, false, false, UNDEFINED); 14.20 } 14.21 14.22 DataPropertyDescriptor(final boolean configurable, final boolean enumerable, final boolean writable, final Object value) { 14.23 + super(Global.objectPrototype(), $nasgenmap$); 14.24 this.configurable = configurable; 14.25 this.enumerable = enumerable; 14.26 this.writable = writable; 14.27 this.value = value; 14.28 - setProto(Global.objectPrototype()); 14.29 } 14.30 14.31
15.1 --- a/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java Fri Jun 21 17:33:05 2013 +0530 15.2 +++ b/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java Thu Jun 27 13:47:20 2013 +0530 15.3 @@ -30,6 +30,7 @@ 15.4 import jdk.nashorn.internal.objects.annotations.ScriptClass; 15.5 import jdk.nashorn.internal.runtime.JSType; 15.6 import jdk.nashorn.internal.runtime.PropertyDescriptor; 15.7 +import jdk.nashorn.internal.runtime.PropertyMap; 15.8 import jdk.nashorn.internal.runtime.ScriptFunction; 15.9 import jdk.nashorn.internal.runtime.ScriptObject; 15.10 import jdk.nashorn.internal.runtime.ScriptRuntime; 15.11 @@ -51,14 +52,17 @@ 15.12 @Property 15.13 public Object enumerable; 15.14 15.15 + // initialized by nasgen 15.16 + private static PropertyMap $nasgenmap$; 15.17 + 15.18 GenericPropertyDescriptor() { 15.19 this(false, false); 15.20 } 15.21 15.22 GenericPropertyDescriptor(final boolean configurable, final boolean enumerable) { 15.23 + super(Global.objectPrototype(), $nasgenmap$); 15.24 this.configurable = configurable; 15.25 this.enumerable = enumerable; 15.26 - setProto(Global.objectPrototype()); 15.27 } 15.28 15.29 @Override
16.1 --- a/src/jdk/nashorn/internal/objects/Global.java Fri Jun 21 17:33:05 2013 +0530 16.2 +++ b/src/jdk/nashorn/internal/objects/Global.java Thu Jun 27 13:47:20 2013 +0530 16.3 @@ -53,8 +53,10 @@ 16.4 import jdk.nashorn.internal.runtime.GlobalObject; 16.5 import jdk.nashorn.internal.runtime.JSType; 16.6 import jdk.nashorn.internal.runtime.NativeJavaPackage; 16.7 +import jdk.nashorn.internal.runtime.PropertyMap; 16.8 import jdk.nashorn.internal.runtime.ScriptEnvironment; 16.9 import jdk.nashorn.internal.runtime.PropertyDescriptor; 16.10 +import jdk.nashorn.internal.runtime.arrays.ArrayData; 16.11 import jdk.nashorn.internal.runtime.regexp.RegExpResult; 16.12 import jdk.nashorn.internal.runtime.Scope; 16.13 import jdk.nashorn.internal.runtime.ScriptFunction; 16.14 @@ -379,6 +381,9 @@ 16.15 16.16 private final Context context; 16.17 16.18 + // initialized by nasgen 16.19 + private static PropertyMap $nasgenmap$; 16.20 + 16.21 /** 16.22 * Constructor 16.23 * 16.24 @@ -484,7 +489,7 @@ 16.25 16.26 @Override 16.27 public ScriptObject newObject() { 16.28 - return newEmptyInstance(); 16.29 + return new JO(getObjectPrototype()); 16.30 } 16.31 16.32 @Override 16.33 @@ -1242,7 +1247,17 @@ 16.34 * @return the new array 16.35 */ 16.36 public static NativeArray allocate(final Object[] initial) { 16.37 - return new NativeArray(initial); 16.38 + ArrayData arrayData = ArrayData.allocate(initial); 16.39 + 16.40 + for (int index = 0; index < initial.length; index++) { 16.41 + final Object value = initial[index]; 16.42 + 16.43 + if (value == ScriptRuntime.EMPTY) { 16.44 + arrayData = arrayData.delete(index); 16.45 + } 16.46 + } 16.47 + 16.48 + return new NativeArray(arrayData); 16.49 } 16.50 16.51 /** 16.52 @@ -1252,7 +1267,7 @@ 16.53 * @return the new array 16.54 */ 16.55 public static NativeArray allocate(final double[] initial) { 16.56 - return new NativeArray(initial); 16.57 + return new NativeArray(ArrayData.allocate(initial)); 16.58 } 16.59 16.60 /** 16.61 @@ -1262,7 +1277,7 @@ 16.62 * @return the new array 16.63 */ 16.64 public static NativeArray allocate(final long[] initial) { 16.65 - return new NativeArray(initial); 16.66 + return new NativeArray(ArrayData.allocate(initial)); 16.67 } 16.68 16.69 /** 16.70 @@ -1272,7 +1287,7 @@ 16.71 * @return the new array 16.72 */ 16.73 public static NativeArray allocate(final int[] initial) { 16.74 - return new NativeArray(initial); 16.75 + return new NativeArray(ArrayData.allocate(initial)); 16.76 } 16.77 16.78 /** 16.79 @@ -1329,9 +1344,7 @@ 16.80 * @return New empty object. 16.81 */ 16.82 public static ScriptObject newEmptyInstance() { 16.83 - final ScriptObject sobj = new JO(); 16.84 - sobj.setProto(objectPrototype()); 16.85 - return sobj; 16.86 + return Global.instance().newObject(); 16.87 } 16.88 16.89 /** 16.90 @@ -1545,7 +1558,7 @@ 16.91 addOwnProperty("echo", Attribute.NOT_ENUMERABLE, value); 16.92 16.93 // Nashorn extension: global.$OPTIONS (scripting-mode-only) 16.94 - final ScriptObject options = newEmptyInstance(); 16.95 + final ScriptObject options = newObject(); 16.96 final ScriptEnvironment scriptEnv = context.getEnv(); 16.97 copyOptions(options, scriptEnv); 16.98 addOwnProperty("$OPTIONS", Attribute.NOT_ENUMERABLE, options); 16.99 @@ -1554,7 +1567,7 @@ 16.100 if (System.getSecurityManager() == null) { 16.101 // do not fill $ENV if we have a security manager around 16.102 // Retrieve current state of ENV variables. 16.103 - final ScriptObject env = newEmptyInstance(); 16.104 + final ScriptObject env = newObject(); 16.105 env.putAll(System.getenv()); 16.106 addOwnProperty(ScriptingFunctions.ENV_NAME, Attribute.NOT_ENUMERABLE, env); 16.107 } else {
17.1 --- a/src/jdk/nashorn/internal/objects/NativeArguments.java Fri Jun 21 17:33:05 2013 +0530 17.2 +++ b/src/jdk/nashorn/internal/objects/NativeArguments.java Thu Jun 27 13:47:20 2013 +0530 17.3 @@ -61,13 +61,13 @@ 17.4 private static final MethodHandle G$CALLEE = findOwnMH("G$callee", Object.class, Object.class); 17.5 private static final MethodHandle S$CALLEE = findOwnMH("S$callee", void.class, Object.class, Object.class); 17.6 17.7 - private static final PropertyMap nasgenmap$; 17.8 + private static final PropertyMap map$; 17.9 17.10 static { 17.11 PropertyMap map = PropertyMap.newMap(NativeArguments.class); 17.12 map = Lookup.newProperty(map, "length", Property.NOT_ENUMERABLE, G$LENGTH, S$LENGTH); 17.13 map = Lookup.newProperty(map, "callee", Property.NOT_ENUMERABLE, G$CALLEE, S$CALLEE); 17.14 - nasgenmap$ = map; 17.15 + map$ = map; 17.16 } 17.17 17.18 private Object length; 17.19 @@ -76,8 +76,8 @@ 17.20 // This is lazily initialized - only when delete is invoked at all 17.21 private BitSet deleted; 17.22 17.23 - NativeArguments(final Object[] arguments, final Object callee, final int numParams) { 17.24 - super(nasgenmap$); 17.25 + NativeArguments(final ScriptObject proto, final Object[] arguments, final Object callee, final int numParams) { 17.26 + super(proto, map$); 17.27 setIsArguments(); 17.28 17.29 setArray(ArrayData.allocate(arguments)); 17.30 @@ -102,9 +102,6 @@ 17.31 } 17.32 System.arraycopy(arguments, 0, newValues, 0, Math.min(newValues.length, arguments.length)); 17.33 this.namedArgs = ArrayData.allocate(newValues); 17.34 - 17.35 - // set Object.prototype as __proto__ 17.36 - this.setProto(Global.objectPrototype()); 17.37 } 17.38 17.39 @Override 17.40 @@ -553,7 +550,8 @@ 17.41 public static ScriptObject allocate(final Object[] arguments, final ScriptFunction callee, final int numParams) { 17.42 // Strict functions won't always have a callee for arguments, and will pass null instead. 17.43 final boolean isStrict = callee == null || callee.isStrict(); 17.44 - return isStrict ? new NativeStrictArguments(arguments, numParams) : new NativeArguments(arguments, callee, numParams); 17.45 + final ScriptObject proto = Global.objectPrototype(); 17.46 + return isStrict ? new NativeStrictArguments(proto, arguments, numParams) : new NativeArguments(proto, arguments, callee, numParams); 17.47 } 17.48 17.49 /**
18.1 --- a/src/jdk/nashorn/internal/objects/NativeArray.java Fri Jun 21 17:33:05 2013 +0530 18.2 +++ b/src/jdk/nashorn/internal/objects/NativeArray.java Thu Jun 27 13:47:20 2013 +0530 18.3 @@ -50,6 +50,7 @@ 18.4 import jdk.nashorn.internal.objects.annotations.Where; 18.5 import jdk.nashorn.internal.runtime.JSType; 18.6 import jdk.nashorn.internal.runtime.PropertyDescriptor; 18.7 +import jdk.nashorn.internal.runtime.PropertyMap; 18.8 import jdk.nashorn.internal.runtime.ScriptFunction; 18.9 import jdk.nashorn.internal.runtime.ScriptObject; 18.10 import jdk.nashorn.internal.runtime.ScriptRuntime; 18.11 @@ -82,6 +83,8 @@ 18.12 18.13 private static final InvokeByName TO_LOCALE_STRING = new InvokeByName("toLocaleString", ScriptObject.class, String.class); 18.14 18.15 + // initialized by nasgen 18.16 + private static PropertyMap $nasgenmap$; 18.17 18.18 /* 18.19 * Constructors. 18.20 @@ -126,8 +129,8 @@ 18.21 this.setArray(arrayData); 18.22 } 18.23 18.24 - private NativeArray(final ArrayData arrayData) { 18.25 - setProto(Global.instance().getArrayPrototype()); 18.26 + NativeArray(final ArrayData arrayData) { 18.27 + super(Global.instance().getArrayPrototype(), $nasgenmap$); 18.28 this.setArray(arrayData); 18.29 this.setIsArray(); 18.30 }
19.1 --- a/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java Fri Jun 21 17:33:05 2013 +0530 19.2 +++ b/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java Thu Jun 27 13:47:20 2013 +0530 19.3 @@ -32,6 +32,7 @@ 19.4 import jdk.nashorn.internal.objects.annotations.Getter; 19.5 import jdk.nashorn.internal.objects.annotations.ScriptClass; 19.6 import jdk.nashorn.internal.runtime.JSType; 19.7 +import jdk.nashorn.internal.runtime.PropertyMap; 19.8 import jdk.nashorn.internal.runtime.ScriptObject; 19.9 import jdk.nashorn.internal.runtime.ScriptRuntime; 19.10 19.11 @@ -39,6 +40,9 @@ 19.12 final class NativeArrayBuffer extends ScriptObject { 19.13 private final byte[] buffer; 19.14 19.15 + // initialized by nasgen 19.16 + private static PropertyMap $nasgenmap$; 19.17 + 19.18 @Constructor(arity = 1) 19.19 public static Object constructor(final boolean newObj, final Object self, final Object... args) { 19.20 if (args.length == 0) { 19.21 @@ -49,8 +53,8 @@ 19.22 } 19.23 19.24 protected NativeArrayBuffer(final byte[] byteArray) { 19.25 + super(Global.instance().getArrayBufferPrototype(), $nasgenmap$); 19.26 this.buffer = byteArray; 19.27 - this.setProto(Global.instance().getArrayBufferPrototype()); 19.28 } 19.29 19.30 protected NativeArrayBuffer(final int byteLength) {
20.1 --- a/src/jdk/nashorn/internal/objects/NativeBoolean.java Fri Jun 21 17:33:05 2013 +0530 20.2 +++ b/src/jdk/nashorn/internal/objects/NativeBoolean.java Thu Jun 27 13:47:20 2013 +0530 20.3 @@ -37,6 +37,7 @@ 20.4 import jdk.nashorn.internal.objects.annotations.Function; 20.5 import jdk.nashorn.internal.objects.annotations.ScriptClass; 20.6 import jdk.nashorn.internal.runtime.JSType; 20.7 +import jdk.nashorn.internal.runtime.PropertyMap; 20.8 import jdk.nashorn.internal.runtime.ScriptObject; 20.9 import jdk.nashorn.internal.runtime.ScriptRuntime; 20.10 import jdk.nashorn.internal.lookup.MethodHandleFactory; 20.11 @@ -52,13 +53,16 @@ 20.12 20.13 final static MethodHandle WRAPFILTER = findWrapFilter(); 20.14 20.15 + // initialized by nasgen 20.16 + private static PropertyMap $nasgenmap$; 20.17 + 20.18 NativeBoolean(final boolean value) { 20.19 this(value, Global.instance().getBooleanPrototype()); 20.20 } 20.21 20.22 private NativeBoolean(final boolean value, final ScriptObject proto) { 20.23 + super(proto, $nasgenmap$); 20.24 this.value = value; 20.25 - this.setProto(proto); 20.26 } 20.27 20.28 @Override
21.1 --- a/src/jdk/nashorn/internal/objects/NativeDate.java Fri Jun 21 17:33:05 2013 +0530 21.2 +++ b/src/jdk/nashorn/internal/objects/NativeDate.java Thu Jun 27 13:47:20 2013 +0530 21.3 @@ -42,6 +42,7 @@ 21.4 import jdk.nashorn.internal.parser.DateParser; 21.5 import jdk.nashorn.internal.runtime.ConsString; 21.6 import jdk.nashorn.internal.runtime.JSType; 21.7 +import jdk.nashorn.internal.runtime.PropertyMap; 21.8 import jdk.nashorn.internal.runtime.ScriptEnvironment; 21.9 import jdk.nashorn.internal.runtime.ScriptFunction; 21.10 import jdk.nashorn.internal.runtime.ScriptObject; 21.11 @@ -100,16 +101,19 @@ 21.12 private double time; 21.13 private final TimeZone timezone; 21.14 21.15 + // initialized by nasgen 21.16 + private static PropertyMap $nasgenmap$; 21.17 + 21.18 NativeDate() { 21.19 this(System.currentTimeMillis()); 21.20 } 21.21 21.22 NativeDate(final double time) { 21.23 + super(Global.instance().getDatePrototype(), $nasgenmap$); 21.24 final ScriptEnvironment env = Global.getEnv(); 21.25 21.26 this.time = time; 21.27 this.timezone = env._timezone; 21.28 - this.setProto(Global.instance().getDatePrototype()); 21.29 } 21.30 21.31 @Override
22.1 --- a/src/jdk/nashorn/internal/objects/NativeDebug.java Fri Jun 21 17:33:05 2013 +0530 22.2 +++ b/src/jdk/nashorn/internal/objects/NativeDebug.java Thu Jun 27 13:47:20 2013 +0530 22.3 @@ -47,8 +47,12 @@ 22.4 */ 22.5 @ScriptClass("Debug") 22.6 public final class NativeDebug extends ScriptObject { 22.7 + 22.8 + // initialized by nasgen 22.9 + private static PropertyMap $nasgenmap$; 22.10 + 22.11 NativeDebug() { 22.12 - this.setProto(Global.objectPrototype()); 22.13 + super(Global.objectPrototype(), $nasgenmap$); 22.14 } 22.15 22.16 @Override 22.17 @@ -187,7 +191,7 @@ 22.18 out.println("Scope count " + ScriptObject.getScopeCount()); 22.19 out.println("ScriptObject listeners added " + PropertyListenerManager.getListenersAdded()); 22.20 out.println("ScriptObject listeners removed " + PropertyListenerManager.getListenersRemoved()); 22.21 - out.println("ScriptFunction count " + ScriptObject.getCount()); 22.22 + out.println("ScriptFunction constructor calls " + ScriptFunction.getConstructorCount()); 22.23 out.println("ScriptFunction invokes " + ScriptFunction.getInvokes()); 22.24 out.println("ScriptFunction allocations " + ScriptFunction.getAllocations()); 22.25 out.println("PropertyMap count " + PropertyMap.getCount());
23.1 --- a/src/jdk/nashorn/internal/objects/NativeError.java Fri Jun 21 17:33:05 2013 +0530 23.2 +++ b/src/jdk/nashorn/internal/objects/NativeError.java Thu Jun 27 13:47:20 2013 +0530 23.3 @@ -32,6 +32,7 @@ 23.4 import java.lang.invoke.MethodHandles; 23.5 import java.util.ArrayList; 23.6 import java.util.List; 23.7 +import jdk.nashorn.api.scripting.NashornException; 23.8 import jdk.nashorn.internal.codegen.CompilerConstants; 23.9 import jdk.nashorn.internal.lookup.MethodHandleFactory; 23.10 import jdk.nashorn.internal.objects.annotations.Attribute; 23.11 @@ -43,6 +44,7 @@ 23.12 import jdk.nashorn.internal.runtime.ECMAErrors; 23.13 import jdk.nashorn.internal.runtime.ECMAException; 23.14 import jdk.nashorn.internal.runtime.JSType; 23.15 +import jdk.nashorn.internal.runtime.PropertyMap; 23.16 import jdk.nashorn.internal.runtime.ScriptObject; 23.17 import jdk.nashorn.internal.runtime.ScriptRuntime; 23.18 23.19 @@ -86,8 +88,11 @@ 23.20 @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) 23.21 public Object message; 23.22 23.23 + // initialized by nasgen 23.24 + private static PropertyMap $nasgenmap$; 23.25 + 23.26 NativeError(final Object msg) { 23.27 - this.setProto(Global.instance().getErrorPrototype()); 23.28 + super(Global.instance().getErrorPrototype(), $nasgenmap$); 23.29 if (msg != UNDEFINED) { 23.30 this.instMessage = JSType.toString(msg); 23.31 } else { 23.32 @@ -115,6 +120,20 @@ 23.33 } 23.34 23.35 /** 23.36 + * Nashorn extension: Error.captureStackTrace. Capture stack trace at the point of call into the Error object provided. 23.37 + * 23.38 + * @param self self reference 23.39 + */ 23.40 + @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) 23.41 + public static Object captureStackTrace(final Object self, final Object errorObj) { 23.42 + Global.checkObject(errorObj); 23.43 + final ScriptObject sobj = (ScriptObject)errorObj; 23.44 + final ECMAException exp = new ECMAException(sobj, null); 23.45 + sobj.set("stack", NashornException.getScriptStackString(exp), false); 23.46 + return UNDEFINED; 23.47 + } 23.48 + 23.49 + /** 23.50 * Nashorn extension: Error.dumpStack 23.51 * dumps the stack of the current thread. 23.52 * 23.53 @@ -144,6 +163,30 @@ 23.54 } 23.55 23.56 /** 23.57 + * Nashorn extension: Error.prototype.getStackTrace() 23.58 + * "stack" property is an array typed value containing {@link StackTraceElement} 23.59 + * objects of JavaScript stack frames. 23.60 + * 23.61 + * @param self self reference 23.62 + * 23.63 + * @return stack trace as a script array. 23.64 + */ 23.65 + @Function(attributes = Attribute.NOT_ENUMERABLE) 23.66 + public static Object getStackTrace(final Object self) { 23.67 + Global.checkObject(self); 23.68 + final ScriptObject sobj = (ScriptObject)self; 23.69 + final Object exception = ECMAException.getException(sobj); 23.70 + Object[] res; 23.71 + if (exception instanceof Throwable) { 23.72 + res = NashornException.getScriptFrames((Throwable)exception); 23.73 + } else { 23.74 + res = ScriptRuntime.EMPTY_ARRAY; 23.75 + } 23.76 + 23.77 + return new NativeArray(res); 23.78 + } 23.79 + 23.80 + /** 23.81 * Nashorn extension: Error.prototype.lineNumber 23.82 * 23.83 * @param self self reference 23.84 @@ -229,8 +272,8 @@ 23.85 23.86 /** 23.87 * Nashorn extension: Error.prototype.stack 23.88 - * "stack" property is an array typed value containing {@link StackTraceElement} 23.89 - * objects of JavaScript stack frames. 23.90 + * "stack" property is a string typed value containing JavaScript stack frames. 23.91 + * Each frame information is separated bv "\n" character. 23.92 * 23.93 * @param self self reference 23.94 * 23.95 @@ -244,27 +287,11 @@ 23.96 } 23.97 23.98 final Object exception = ECMAException.getException(sobj); 23.99 - Object[] res; 23.100 if (exception instanceof Throwable) { 23.101 - final StackTraceElement[] frames = ((Throwable)exception).getStackTrace(); 23.102 - final List<StackTraceElement> filtered = new ArrayList<>(); 23.103 - for (final StackTraceElement st : frames) { 23.104 - if (ECMAErrors.isScriptFrame(st)) { 23.105 - final String className = "<" + st.getFileName() + ">"; 23.106 - String methodName = st.getMethodName(); 23.107 - if (methodName.equals(CompilerConstants.RUN_SCRIPT.symbolName())) { 23.108 - methodName = "<program>"; 23.109 - } 23.110 - filtered.add(new StackTraceElement(className, methodName, 23.111 - st.getFileName(), st.getLineNumber())); 23.112 - } 23.113 - } 23.114 - res = filtered.toArray(); 23.115 + return NashornException.getScriptStackString((Throwable)exception); 23.116 } else { 23.117 - res = ScriptRuntime.EMPTY_ARRAY; 23.118 + return ""; 23.119 } 23.120 - 23.121 - return new NativeArray(res); 23.122 } 23.123 23.124 /**
24.1 --- a/src/jdk/nashorn/internal/objects/NativeEvalError.java Fri Jun 21 17:33:05 2013 +0530 24.2 +++ b/src/jdk/nashorn/internal/objects/NativeEvalError.java Thu Jun 27 13:47:20 2013 +0530 24.3 @@ -33,6 +33,7 @@ 24.4 import jdk.nashorn.internal.objects.annotations.ScriptClass; 24.5 import jdk.nashorn.internal.objects.annotations.Where; 24.6 import jdk.nashorn.internal.runtime.JSType; 24.7 +import jdk.nashorn.internal.runtime.PropertyMap; 24.8 import jdk.nashorn.internal.runtime.ScriptObject; 24.9 24.10 /** 24.11 @@ -52,10 +53,13 @@ 24.12 24.13 /** ECMA 15.1.1.1 message property */ 24.14 @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) 24.15 + public Object message; 24.16 24.17 - public Object message; 24.18 + // initialized by nasgen 24.19 + private static PropertyMap $nasgenmap$; 24.20 + 24.21 NativeEvalError(final Object msg) { 24.22 - this.setProto(Global.instance().getEvalErrorPrototype()); 24.23 + super(Global.instance().getEvalErrorPrototype(), $nasgenmap$); 24.24 if (msg != UNDEFINED) { 24.25 this.instMessage = JSType.toString(msg); 24.26 } else {
25.1 --- a/src/jdk/nashorn/internal/objects/NativeFloat32Array.java Fri Jun 21 17:33:05 2013 +0530 25.2 +++ b/src/jdk/nashorn/internal/objects/NativeFloat32Array.java Thu Jun 27 13:47:20 2013 +0530 25.3 @@ -32,6 +32,7 @@ 25.4 import jdk.nashorn.internal.objects.annotations.ScriptClass; 25.5 import jdk.nashorn.internal.objects.annotations.Where; 25.6 import jdk.nashorn.internal.runtime.JSType; 25.7 +import jdk.nashorn.internal.runtime.PropertyMap; 25.8 import jdk.nashorn.internal.runtime.ScriptObject; 25.9 import jdk.nashorn.internal.runtime.arrays.ArrayData; 25.10 25.11 @@ -46,6 +47,9 @@ 25.12 @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) 25.13 public static final int BYTES_PER_ELEMENT = 4; 25.14 25.15 + // initialized by nasgen 25.16 + private static PropertyMap $nasgenmap$; 25.17 + 25.18 private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) { 25.19 @Override 25.20 public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
26.1 --- a/src/jdk/nashorn/internal/objects/NativeFloat64Array.java Fri Jun 21 17:33:05 2013 +0530 26.2 +++ b/src/jdk/nashorn/internal/objects/NativeFloat64Array.java Thu Jun 27 13:47:20 2013 +0530 26.3 @@ -32,6 +32,7 @@ 26.4 import jdk.nashorn.internal.objects.annotations.ScriptClass; 26.5 import jdk.nashorn.internal.objects.annotations.Where; 26.6 import jdk.nashorn.internal.runtime.JSType; 26.7 +import jdk.nashorn.internal.runtime.PropertyMap; 26.8 import jdk.nashorn.internal.runtime.ScriptObject; 26.9 import jdk.nashorn.internal.runtime.arrays.ArrayData; 26.10 26.11 @@ -46,6 +47,9 @@ 26.12 @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) 26.13 public static final int BYTES_PER_ELEMENT = 8; 26.14 26.15 + // initialized by nasgen 26.16 + private static PropertyMap $nasgenmap$; 26.17 + 26.18 private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) { 26.19 @Override 26.20 public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
27.1 --- a/src/jdk/nashorn/internal/objects/NativeFunction.java Fri Jun 21 17:33:05 2013 +0530 27.2 +++ b/src/jdk/nashorn/internal/objects/NativeFunction.java Thu Jun 27 13:47:20 2013 +0530 27.3 @@ -38,6 +38,7 @@ 27.4 import jdk.nashorn.internal.runtime.Context; 27.5 import jdk.nashorn.internal.runtime.JSType; 27.6 import jdk.nashorn.internal.runtime.ParserException; 27.7 +import jdk.nashorn.internal.runtime.PropertyMap; 27.8 import jdk.nashorn.internal.runtime.ScriptFunction; 27.9 import jdk.nashorn.internal.runtime.ScriptObject; 27.10 import jdk.nashorn.internal.runtime.ScriptRuntime; 27.11 @@ -52,6 +53,10 @@ 27.12 */ 27.13 @ScriptClass("Function") 27.14 public final class NativeFunction { 27.15 + 27.16 + // initialized by nasgen 27.17 + private static PropertyMap $nasgenmap$; 27.18 + 27.19 // do *not* create me! 27.20 private NativeFunction() { 27.21 }
28.1 --- a/src/jdk/nashorn/internal/objects/NativeInt16Array.java Fri Jun 21 17:33:05 2013 +0530 28.2 +++ b/src/jdk/nashorn/internal/objects/NativeInt16Array.java Thu Jun 27 13:47:20 2013 +0530 28.3 @@ -31,6 +31,7 @@ 28.4 import jdk.nashorn.internal.objects.annotations.Property; 28.5 import jdk.nashorn.internal.objects.annotations.ScriptClass; 28.6 import jdk.nashorn.internal.objects.annotations.Where; 28.7 +import jdk.nashorn.internal.runtime.PropertyMap; 28.8 import jdk.nashorn.internal.runtime.ScriptObject; 28.9 import jdk.nashorn.internal.runtime.arrays.ArrayData; 28.10 28.11 @@ -39,6 +40,10 @@ 28.12 */ 28.13 @ScriptClass("Int16Array") 28.14 public final class NativeInt16Array extends ArrayBufferView { 28.15 + 28.16 + // initialized by nasgen 28.17 + private static PropertyMap $nasgenmap$; 28.18 + 28.19 /** 28.20 * The size in bytes of each element in the array. 28.21 */
29.1 --- a/src/jdk/nashorn/internal/objects/NativeInt32Array.java Fri Jun 21 17:33:05 2013 +0530 29.2 +++ b/src/jdk/nashorn/internal/objects/NativeInt32Array.java Thu Jun 27 13:47:20 2013 +0530 29.3 @@ -31,6 +31,7 @@ 29.4 import jdk.nashorn.internal.objects.annotations.Property; 29.5 import jdk.nashorn.internal.objects.annotations.ScriptClass; 29.6 import jdk.nashorn.internal.objects.annotations.Where; 29.7 +import jdk.nashorn.internal.runtime.PropertyMap; 29.8 import jdk.nashorn.internal.runtime.ScriptObject; 29.9 import jdk.nashorn.internal.runtime.arrays.ArrayData; 29.10 29.11 @@ -45,6 +46,9 @@ 29.12 @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) 29.13 public static final int BYTES_PER_ELEMENT = 4; 29.14 29.15 + // initialized by nasgen 29.16 + private static PropertyMap $nasgenmap$; 29.17 + 29.18 private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) { 29.19 @Override 29.20 public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
30.1 --- a/src/jdk/nashorn/internal/objects/NativeInt8Array.java Fri Jun 21 17:33:05 2013 +0530 30.2 +++ b/src/jdk/nashorn/internal/objects/NativeInt8Array.java Thu Jun 27 13:47:20 2013 +0530 30.3 @@ -31,6 +31,7 @@ 30.4 import jdk.nashorn.internal.objects.annotations.Property; 30.5 import jdk.nashorn.internal.objects.annotations.ScriptClass; 30.6 import jdk.nashorn.internal.objects.annotations.Where; 30.7 +import jdk.nashorn.internal.runtime.PropertyMap; 30.8 import jdk.nashorn.internal.runtime.ScriptObject; 30.9 import jdk.nashorn.internal.runtime.arrays.ArrayData; 30.10 30.11 @@ -45,6 +46,9 @@ 30.12 @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) 30.13 public static final int BYTES_PER_ELEMENT = 1; 30.14 30.15 + // initialized by nasgen 30.16 + private static PropertyMap $nasgenmap$; 30.17 + 30.18 private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) { 30.19 @Override 30.20 public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
31.1 --- a/src/jdk/nashorn/internal/objects/NativeJSAdapter.java Fri Jun 21 17:33:05 2013 +0530 31.2 +++ b/src/jdk/nashorn/internal/objects/NativeJSAdapter.java Thu Jun 27 13:47:20 2013 +0530 31.3 @@ -42,6 +42,7 @@ 31.4 import jdk.nashorn.internal.objects.annotations.ScriptClass; 31.5 import jdk.nashorn.internal.runtime.FindProperty; 31.6 import jdk.nashorn.internal.runtime.JSType; 31.7 +import jdk.nashorn.internal.runtime.PropertyMap; 31.8 import jdk.nashorn.internal.runtime.ScriptFunction; 31.9 import jdk.nashorn.internal.runtime.ScriptObject; 31.10 import jdk.nashorn.internal.runtime.ScriptRuntime; 31.11 @@ -142,9 +143,12 @@ 31.12 31.13 private static final MethodHandle IS_JSADAPTOR = findOwnMH("isJSAdaptor", boolean.class, Object.class, Object.class, MethodHandle.class, Object.class, ScriptFunction.class); 31.14 31.15 + // initialized by nasgen 31.16 + private static PropertyMap $nasgenmap$; 31.17 + 31.18 NativeJSAdapter(final ScriptObject proto, final Object overrides, final ScriptObject adaptee) { 31.19 + super(proto, $nasgenmap$); 31.20 this.adaptee = wrapAdaptee(adaptee); 31.21 - this.setProto(proto); 31.22 if (overrides instanceof ScriptObject) { 31.23 this.overrides = true; 31.24 final ScriptObject sobj = (ScriptObject)overrides;
32.1 --- a/src/jdk/nashorn/internal/objects/NativeJSON.java Fri Jun 21 17:33:05 2013 +0530 32.2 +++ b/src/jdk/nashorn/internal/objects/NativeJSON.java Thu Jun 27 13:47:20 2013 +0530 32.3 @@ -42,6 +42,7 @@ 32.4 import jdk.nashorn.internal.runtime.ConsString; 32.5 import jdk.nashorn.internal.runtime.JSONFunctions; 32.6 import jdk.nashorn.internal.runtime.JSType; 32.7 +import jdk.nashorn.internal.runtime.PropertyMap; 32.8 import jdk.nashorn.internal.runtime.ScriptFunction; 32.9 import jdk.nashorn.internal.runtime.ScriptObject; 32.10 import jdk.nashorn.internal.runtime.arrays.ArrayLikeIterator; 32.11 @@ -58,9 +59,11 @@ 32.12 private static final MethodHandle REPLACER_INVOKER = Bootstrap.createDynamicInvoker("dyn:call", Object.class, 32.13 ScriptFunction.class, ScriptObject.class, Object.class, Object.class); 32.14 32.15 + // initialized by nasgen 32.16 + private static PropertyMap $nasgenmap$; 32.17 32.18 NativeJSON() { 32.19 - this.setProto(Global.objectPrototype()); 32.20 + super(Global.objectPrototype(), $nasgenmap$); 32.21 } 32.22 32.23 /**
33.1 --- a/src/jdk/nashorn/internal/objects/NativeJava.java Fri Jun 21 17:33:05 2013 +0530 33.2 +++ b/src/jdk/nashorn/internal/objects/NativeJava.java Thu Jun 27 13:47:20 2013 +0530 33.3 @@ -40,6 +40,7 @@ 33.4 import jdk.nashorn.internal.objects.annotations.Where; 33.5 import jdk.nashorn.internal.runtime.JSType; 33.6 import jdk.nashorn.internal.runtime.ListAdapter; 33.7 +import jdk.nashorn.internal.runtime.PropertyMap; 33.8 import jdk.nashorn.internal.runtime.ScriptObject; 33.9 import jdk.nashorn.internal.runtime.linker.JavaAdapterFactory; 33.10 33.11 @@ -52,6 +53,9 @@ 33.12 @ScriptClass("Java") 33.13 public final class NativeJava { 33.14 33.15 + // initialized by nasgen 33.16 + private static PropertyMap $nasgenmap$; 33.17 + 33.18 private NativeJava() { 33.19 } 33.20
34.1 --- a/src/jdk/nashorn/internal/objects/NativeJavaImporter.java Fri Jun 21 17:33:05 2013 +0530 34.2 +++ b/src/jdk/nashorn/internal/objects/NativeJavaImporter.java Thu Jun 27 13:47:20 2013 +0530 34.3 @@ -34,6 +34,7 @@ 34.4 import jdk.nashorn.internal.objects.annotations.Function; 34.5 import jdk.nashorn.internal.objects.annotations.ScriptClass; 34.6 import jdk.nashorn.internal.runtime.NativeJavaPackage; 34.7 +import jdk.nashorn.internal.runtime.PropertyMap; 34.8 import jdk.nashorn.internal.runtime.ScriptObject; 34.9 34.10 /** 34.11 @@ -55,9 +56,12 @@ 34.12 public final class NativeJavaImporter extends ScriptObject { 34.13 private final Object[] args; 34.14 34.15 + // initialized by nasgen 34.16 + private static PropertyMap $nasgenmap$; 34.17 + 34.18 NativeJavaImporter(final Object[] args) { 34.19 + super(Global.instance().getJavaImporterPrototype(), $nasgenmap$); 34.20 this.args = args; 34.21 - this.setProto(Global.instance().getJavaImporterPrototype()); 34.22 } 34.23 34.24 @Override
35.1 --- a/src/jdk/nashorn/internal/objects/NativeMath.java Fri Jun 21 17:33:05 2013 +0530 35.2 +++ b/src/jdk/nashorn/internal/objects/NativeMath.java Thu Jun 27 13:47:20 2013 +0530 35.3 @@ -32,6 +32,7 @@ 35.4 import jdk.nashorn.internal.objects.annotations.SpecializedFunction; 35.5 import jdk.nashorn.internal.objects.annotations.Where; 35.6 import jdk.nashorn.internal.runtime.JSType; 35.7 +import jdk.nashorn.internal.runtime.PropertyMap; 35.8 import jdk.nashorn.internal.runtime.ScriptObject; 35.9 35.10 /** 35.11 @@ -41,8 +42,11 @@ 35.12 @ScriptClass("Math") 35.13 public final class NativeMath extends ScriptObject { 35.14 35.15 + // initialized by nasgen 35.16 + private static PropertyMap $nasgenmap$; 35.17 + 35.18 NativeMath() { 35.19 - this.setProto(Global.objectPrototype()); 35.20 + super(Global.objectPrototype(), $nasgenmap$); 35.21 } 35.22 35.23 /** ECMA 15.8.1.1 - E, always a double constant. Not writable or configurable */
36.1 --- a/src/jdk/nashorn/internal/objects/NativeNumber.java Fri Jun 21 17:33:05 2013 +0530 36.2 +++ b/src/jdk/nashorn/internal/objects/NativeNumber.java Thu Jun 27 13:47:20 2013 +0530 36.3 @@ -45,6 +45,7 @@ 36.4 import jdk.nashorn.internal.objects.annotations.ScriptClass; 36.5 import jdk.nashorn.internal.objects.annotations.Where; 36.6 import jdk.nashorn.internal.runtime.JSType; 36.7 +import jdk.nashorn.internal.runtime.PropertyMap; 36.8 import jdk.nashorn.internal.runtime.ScriptObject; 36.9 import jdk.nashorn.internal.runtime.ScriptRuntime; 36.10 import jdk.nashorn.internal.lookup.MethodHandleFactory; 36.11 @@ -83,15 +84,18 @@ 36.12 private final boolean isInt; 36.13 private final boolean isLong; 36.14 36.15 + // initialized by nasgen 36.16 + private static PropertyMap $nasgenmap$; 36.17 + 36.18 NativeNumber(final double value) { 36.19 this(value, Global.instance().getNumberPrototype()); 36.20 } 36.21 36.22 private NativeNumber(final double value, final ScriptObject proto) { 36.23 + super(proto, $nasgenmap$); 36.24 this.value = value; 36.25 this.isInt = isRepresentableAsInt(value); 36.26 this.isLong = isRepresentableAsLong(value); 36.27 - this.setProto(proto); 36.28 } 36.29 36.30 @Override
37.1 --- a/src/jdk/nashorn/internal/objects/NativeObject.java Fri Jun 21 17:33:05 2013 +0530 37.2 +++ b/src/jdk/nashorn/internal/objects/NativeObject.java Thu Jun 27 13:47:20 2013 +0530 37.3 @@ -36,6 +36,7 @@ 37.4 import jdk.nashorn.internal.objects.annotations.Where; 37.5 import jdk.nashorn.internal.runtime.ECMAException; 37.6 import jdk.nashorn.internal.runtime.JSType; 37.7 +import jdk.nashorn.internal.runtime.PropertyMap; 37.8 import jdk.nashorn.internal.runtime.ScriptFunction; 37.9 import jdk.nashorn.internal.runtime.ScriptObject; 37.10 import jdk.nashorn.internal.runtime.ScriptRuntime; 37.11 @@ -53,6 +54,9 @@ 37.12 public final class NativeObject { 37.13 private static final InvokeByName TO_STRING = new InvokeByName("toString", ScriptObject.class); 37.14 37.15 + // initialized by nasgen 37.16 + private static PropertyMap $nasgenmap$; 37.17 + 37.18 private NativeObject() { 37.19 } 37.20
38.1 --- a/src/jdk/nashorn/internal/objects/NativeRangeError.java Fri Jun 21 17:33:05 2013 +0530 38.2 +++ b/src/jdk/nashorn/internal/objects/NativeRangeError.java Thu Jun 27 13:47:20 2013 +0530 38.3 @@ -33,6 +33,7 @@ 38.4 import jdk.nashorn.internal.objects.annotations.ScriptClass; 38.5 import jdk.nashorn.internal.objects.annotations.Where; 38.6 import jdk.nashorn.internal.runtime.JSType; 38.7 +import jdk.nashorn.internal.runtime.PropertyMap; 38.8 import jdk.nashorn.internal.runtime.ScriptObject; 38.9 38.10 /** 38.11 @@ -54,8 +55,11 @@ 38.12 @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) 38.13 public Object message; 38.14 38.15 + // initialized by nasgen 38.16 + private static PropertyMap $nasgenmap$; 38.17 + 38.18 NativeRangeError(final Object msg) { 38.19 - setProto(Global.instance().getRangeErrorPrototype()); 38.20 + super(Global.instance().getRangeErrorPrototype(), $nasgenmap$); 38.21 if (msg != UNDEFINED) { 38.22 this.instMessage = JSType.toString(msg); 38.23 } else {
39.1 --- a/src/jdk/nashorn/internal/objects/NativeReferenceError.java Fri Jun 21 17:33:05 2013 +0530 39.2 +++ b/src/jdk/nashorn/internal/objects/NativeReferenceError.java Thu Jun 27 13:47:20 2013 +0530 39.3 @@ -33,6 +33,7 @@ 39.4 import jdk.nashorn.internal.objects.annotations.ScriptClass; 39.5 import jdk.nashorn.internal.objects.annotations.Where; 39.6 import jdk.nashorn.internal.runtime.JSType; 39.7 +import jdk.nashorn.internal.runtime.PropertyMap; 39.8 import jdk.nashorn.internal.runtime.ScriptObject; 39.9 39.10 /** 39.11 @@ -54,8 +55,11 @@ 39.12 @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) 39.13 public Object message; 39.14 39.15 + // initialized by nasgen 39.16 + private static PropertyMap $nasgenmap$; 39.17 + 39.18 NativeReferenceError(final Object msg) { 39.19 - this.setProto(Global.instance().getReferenceErrorPrototype()); 39.20 + super(Global.instance().getReferenceErrorPrototype(), $nasgenmap$); 39.21 if (msg != UNDEFINED) { 39.22 this.instMessage = JSType.toString(msg); 39.23 } else {
40.1 --- a/src/jdk/nashorn/internal/objects/NativeRegExp.java Fri Jun 21 17:33:05 2013 +0530 40.2 +++ b/src/jdk/nashorn/internal/objects/NativeRegExp.java Thu Jun 27 13:47:20 2013 +0530 40.3 @@ -43,6 +43,7 @@ 40.4 import jdk.nashorn.internal.runtime.BitVector; 40.5 import jdk.nashorn.internal.runtime.JSType; 40.6 import jdk.nashorn.internal.runtime.ParserException; 40.7 +import jdk.nashorn.internal.runtime.PropertyMap; 40.8 import jdk.nashorn.internal.runtime.regexp.RegExp; 40.9 import jdk.nashorn.internal.runtime.regexp.RegExpFactory; 40.10 import jdk.nashorn.internal.runtime.regexp.RegExpResult; 40.11 @@ -66,6 +67,9 @@ 40.12 // Reference to global object needed to support static RegExp properties 40.13 private Global globalObject; 40.14 40.15 + // initialized by nasgen 40.16 + private static PropertyMap $nasgenmap$; 40.17 + 40.18 NativeRegExp(final String input, final String flagString) { 40.19 try { 40.20 this.regexp = RegExpFactory.create(input, flagString);
41.1 --- a/src/jdk/nashorn/internal/objects/NativeRegExpExecResult.java Fri Jun 21 17:33:05 2013 +0530 41.2 +++ b/src/jdk/nashorn/internal/objects/NativeRegExpExecResult.java Thu Jun 27 13:47:20 2013 +0530 41.3 @@ -31,6 +31,7 @@ 41.4 import jdk.nashorn.internal.objects.annotations.ScriptClass; 41.5 import jdk.nashorn.internal.objects.annotations.Setter; 41.6 import jdk.nashorn.internal.runtime.JSType; 41.7 +import jdk.nashorn.internal.runtime.PropertyMap; 41.8 import jdk.nashorn.internal.runtime.regexp.RegExpResult; 41.9 import jdk.nashorn.internal.runtime.ScriptObject; 41.10 import jdk.nashorn.internal.runtime.arrays.ArrayData; 41.11 @@ -49,8 +50,11 @@ 41.12 @Property 41.13 public Object input; 41.14 41.15 + // initialized by nasgen 41.16 + private static PropertyMap $nasgenmap$; 41.17 + 41.18 NativeRegExpExecResult(final RegExpResult result) { 41.19 - setProto(Global.instance().getArrayPrototype()); 41.20 + super(Global.instance().getArrayPrototype(), $nasgenmap$); 41.21 setIsArray(); 41.22 this.setArray(ArrayData.allocate(result.getGroups().clone())); 41.23 this.index = result.getIndex();
42.1 --- a/src/jdk/nashorn/internal/objects/NativeStrictArguments.java Fri Jun 21 17:33:05 2013 +0530 42.2 +++ b/src/jdk/nashorn/internal/objects/NativeStrictArguments.java Thu Jun 27 13:47:20 2013 +0530 42.3 @@ -51,22 +51,24 @@ 42.4 private static final MethodHandle S$LENGTH = findOwnMH("S$length", void.class, Object.class, Object.class); 42.5 42.6 // property map for strict mode arguments object 42.7 - private static final PropertyMap nasgenmap$; 42.8 + private static final PropertyMap map$; 42.9 42.10 static { 42.11 PropertyMap map = PropertyMap.newMap(NativeStrictArguments.class); 42.12 map = Lookup.newProperty(map, "length", Property.NOT_ENUMERABLE, G$LENGTH, S$LENGTH); 42.13 // In strict mode, the caller and callee properties should throw TypeError 42.14 - map = ScriptFunctionImpl.newThrowerProperty(map, "caller"); 42.15 - map = ScriptFunctionImpl.newThrowerProperty(map, "callee"); 42.16 - nasgenmap$ = map; 42.17 + // Need to add properties directly to map since slots are assigned speculatively by newUserAccessors. 42.18 + final int flags = Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE; 42.19 + map = map.addProperty(map.newUserAccessors("caller", flags)); 42.20 + map = map.addProperty(map.newUserAccessors("callee", flags)); 42.21 + map$ = map; 42.22 } 42.23 42.24 private Object length; 42.25 private final Object[] namedArgs; 42.26 42.27 - NativeStrictArguments(final Object[] values, final int numParams) { 42.28 - super(nasgenmap$); 42.29 + NativeStrictArguments(final ScriptObject proto, final Object[] values, final int numParams) { 42.30 + super(proto, map$); 42.31 setIsArguments(); 42.32 42.33 final ScriptFunction func = ScriptFunctionImpl.getTypeErrorThrower(); 42.34 @@ -84,8 +86,6 @@ 42.35 Arrays.fill(namedArgs, UNDEFINED); 42.36 } 42.37 System.arraycopy(values, 0, namedArgs, 0, Math.min(namedArgs.length, values.length)); 42.38 - 42.39 - this.setProto(Global.objectPrototype()); 42.40 } 42.41 42.42 @Override
43.1 --- a/src/jdk/nashorn/internal/objects/NativeString.java Fri Jun 21 17:33:05 2013 +0530 43.2 +++ b/src/jdk/nashorn/internal/objects/NativeString.java Thu Jun 27 13:47:20 2013 +0530 43.3 @@ -52,6 +52,7 @@ 43.4 import jdk.nashorn.internal.objects.annotations.Where; 43.5 import jdk.nashorn.internal.runtime.ConsString; 43.6 import jdk.nashorn.internal.runtime.JSType; 43.7 +import jdk.nashorn.internal.runtime.PropertyMap; 43.8 import jdk.nashorn.internal.runtime.ScriptFunction; 43.9 import jdk.nashorn.internal.runtime.ScriptObject; 43.10 import jdk.nashorn.internal.runtime.ScriptRuntime; 43.11 @@ -70,14 +71,17 @@ 43.12 43.13 static final MethodHandle WRAPFILTER = findWrapFilter(); 43.14 43.15 + // initialized by nasgen 43.16 + private static PropertyMap $nasgenmap$; 43.17 + 43.18 NativeString(final CharSequence value) { 43.19 this(value, Global.instance().getStringPrototype()); 43.20 } 43.21 43.22 private NativeString(final CharSequence value, final ScriptObject proto) { 43.23 + super(proto, $nasgenmap$); 43.24 assert value instanceof String || value instanceof ConsString; 43.25 this.value = value; 43.26 - this.setProto(proto); 43.27 } 43.28 43.29 @Override
44.1 --- a/src/jdk/nashorn/internal/objects/NativeSyntaxError.java Fri Jun 21 17:33:05 2013 +0530 44.2 +++ b/src/jdk/nashorn/internal/objects/NativeSyntaxError.java Thu Jun 27 13:47:20 2013 +0530 44.3 @@ -33,6 +33,7 @@ 44.4 import jdk.nashorn.internal.objects.annotations.ScriptClass; 44.5 import jdk.nashorn.internal.objects.annotations.Where; 44.6 import jdk.nashorn.internal.runtime.JSType; 44.7 +import jdk.nashorn.internal.runtime.PropertyMap; 44.8 import jdk.nashorn.internal.runtime.ScriptObject; 44.9 44.10 /** 44.11 @@ -54,8 +55,11 @@ 44.12 @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) 44.13 public Object message; 44.14 44.15 + // initialized by nasgen 44.16 + private static PropertyMap $nasgenmap$; 44.17 + 44.18 NativeSyntaxError(final Object msg) { 44.19 - this.setProto(Global.instance().getSyntaxErrorPrototype()); 44.20 + super(Global.instance().getSyntaxErrorPrototype(), $nasgenmap$); 44.21 if (msg != UNDEFINED) { 44.22 this.instMessage = JSType.toString(msg); 44.23 } else {
45.1 --- a/src/jdk/nashorn/internal/objects/NativeTypeError.java Fri Jun 21 17:33:05 2013 +0530 45.2 +++ b/src/jdk/nashorn/internal/objects/NativeTypeError.java Thu Jun 27 13:47:20 2013 +0530 45.3 @@ -33,6 +33,7 @@ 45.4 import jdk.nashorn.internal.objects.annotations.ScriptClass; 45.5 import jdk.nashorn.internal.objects.annotations.Where; 45.6 import jdk.nashorn.internal.runtime.JSType; 45.7 +import jdk.nashorn.internal.runtime.PropertyMap; 45.8 import jdk.nashorn.internal.runtime.ScriptObject; 45.9 45.10 /** 45.11 @@ -54,8 +55,11 @@ 45.12 @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) 45.13 public Object message; 45.14 45.15 + // initialized by nasgen 45.16 + private static PropertyMap $nasgenmap$; 45.17 + 45.18 NativeTypeError(final Object msg) { 45.19 - this.setProto(Global.instance().getTypeErrorPrototype()); 45.20 + super(Global.instance().getTypeErrorPrototype(), $nasgenmap$); 45.21 if (msg != UNDEFINED) { 45.22 this.instMessage = JSType.toString(msg); 45.23 } else {
46.1 --- a/src/jdk/nashorn/internal/objects/NativeURIError.java Fri Jun 21 17:33:05 2013 +0530 46.2 +++ b/src/jdk/nashorn/internal/objects/NativeURIError.java Thu Jun 27 13:47:20 2013 +0530 46.3 @@ -33,6 +33,7 @@ 46.4 import jdk.nashorn.internal.objects.annotations.ScriptClass; 46.5 import jdk.nashorn.internal.objects.annotations.Where; 46.6 import jdk.nashorn.internal.runtime.JSType; 46.7 +import jdk.nashorn.internal.runtime.PropertyMap; 46.8 import jdk.nashorn.internal.runtime.ScriptObject; 46.9 46.10 /** 46.11 @@ -53,8 +54,11 @@ 46.12 @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) 46.13 public Object message; 46.14 46.15 + // initialized by nasgen 46.16 + private static PropertyMap $nasgenmap$; 46.17 + 46.18 NativeURIError(final Object msg) { 46.19 - this.setProto(Global.instance().getURIErrorPrototype()); 46.20 + super(Global.instance().getURIErrorPrototype(), $nasgenmap$); 46.21 if (msg != UNDEFINED) { 46.22 this.instMessage = JSType.toString(msg); 46.23 } else {
47.1 --- a/src/jdk/nashorn/internal/objects/NativeUint16Array.java Fri Jun 21 17:33:05 2013 +0530 47.2 +++ b/src/jdk/nashorn/internal/objects/NativeUint16Array.java Thu Jun 27 13:47:20 2013 +0530 47.3 @@ -31,6 +31,7 @@ 47.4 import jdk.nashorn.internal.objects.annotations.Property; 47.5 import jdk.nashorn.internal.objects.annotations.ScriptClass; 47.6 import jdk.nashorn.internal.objects.annotations.Where; 47.7 +import jdk.nashorn.internal.runtime.PropertyMap; 47.8 import jdk.nashorn.internal.runtime.ScriptObject; 47.9 import jdk.nashorn.internal.runtime.arrays.ArrayData; 47.10 47.11 @@ -45,6 +46,9 @@ 47.12 @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) 47.13 public static final int BYTES_PER_ELEMENT = 2; 47.14 47.15 + // initialized by nasgen 47.16 + private static PropertyMap $nasgenmap$; 47.17 + 47.18 private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) { 47.19 @Override 47.20 public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
48.1 --- a/src/jdk/nashorn/internal/objects/NativeUint32Array.java Fri Jun 21 17:33:05 2013 +0530 48.2 +++ b/src/jdk/nashorn/internal/objects/NativeUint32Array.java Thu Jun 27 13:47:20 2013 +0530 48.3 @@ -32,6 +32,7 @@ 48.4 import jdk.nashorn.internal.objects.annotations.ScriptClass; 48.5 import jdk.nashorn.internal.objects.annotations.Where; 48.6 import jdk.nashorn.internal.runtime.JSType; 48.7 +import jdk.nashorn.internal.runtime.PropertyMap; 48.8 import jdk.nashorn.internal.runtime.ScriptObject; 48.9 import jdk.nashorn.internal.runtime.arrays.ArrayData; 48.10 48.11 @@ -46,6 +47,9 @@ 48.12 @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) 48.13 public static final int BYTES_PER_ELEMENT = 4; 48.14 48.15 + // initialized by nasgen 48.16 + private static PropertyMap $nasgenmap$; 48.17 + 48.18 private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) { 48.19 @Override 48.20 public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteBegin, final int length) {
49.1 --- a/src/jdk/nashorn/internal/objects/NativeUint8Array.java Fri Jun 21 17:33:05 2013 +0530 49.2 +++ b/src/jdk/nashorn/internal/objects/NativeUint8Array.java Thu Jun 27 13:47:20 2013 +0530 49.3 @@ -31,6 +31,7 @@ 49.4 import jdk.nashorn.internal.objects.annotations.Property; 49.5 import jdk.nashorn.internal.objects.annotations.ScriptClass; 49.6 import jdk.nashorn.internal.objects.annotations.Where; 49.7 +import jdk.nashorn.internal.runtime.PropertyMap; 49.8 import jdk.nashorn.internal.runtime.ScriptObject; 49.9 import jdk.nashorn.internal.runtime.arrays.ArrayData; 49.10 49.11 @@ -45,6 +46,9 @@ 49.12 @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) 49.13 public static final int BYTES_PER_ELEMENT = 1; 49.14 49.15 + // initialized by nasgen 49.16 + private static PropertyMap $nasgenmap$; 49.17 + 49.18 private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) { 49.19 @Override 49.20 public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
50.1 --- a/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java Fri Jun 21 17:33:05 2013 +0530 50.2 +++ b/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java Thu Jun 27 13:47:20 2013 +0530 50.3 @@ -32,6 +32,7 @@ 50.4 import jdk.nashorn.internal.objects.annotations.ScriptClass; 50.5 import jdk.nashorn.internal.objects.annotations.Where; 50.6 import jdk.nashorn.internal.runtime.JSType; 50.7 +import jdk.nashorn.internal.runtime.PropertyMap; 50.8 import jdk.nashorn.internal.runtime.ScriptObject; 50.9 import jdk.nashorn.internal.runtime.arrays.ArrayData; 50.10 50.11 @@ -46,6 +47,9 @@ 50.12 @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) 50.13 public static final int BYTES_PER_ELEMENT = 1; 50.14 50.15 + // initialized by nasgen 50.16 + private static PropertyMap $nasgenmap$; 50.17 + 50.18 private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) { 50.19 @Override 50.20 public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
51.1 --- a/src/jdk/nashorn/internal/objects/PrototypeObject.java Fri Jun 21 17:33:05 2013 +0530 51.2 +++ b/src/jdk/nashorn/internal/objects/PrototypeObject.java Thu Jun 27 13:47:20 2013 +0530 51.3 @@ -44,7 +44,7 @@ 51.4 * 51.5 */ 51.6 public class PrototypeObject extends ScriptObject { 51.7 - private static final PropertyMap nasgenmap$; 51.8 + private static final PropertyMap map$; 51.9 51.10 private Object constructor; 51.11 51.12 @@ -54,11 +54,11 @@ 51.13 static { 51.14 PropertyMap map = PropertyMap.newMap(PrototypeObject.class); 51.15 map = Lookup.newProperty(map, "constructor", Property.NOT_ENUMERABLE, GET_CONSTRUCTOR, SET_CONSTRUCTOR); 51.16 - nasgenmap$ = map; 51.17 + map$ = map; 51.18 } 51.19 51.20 PrototypeObject() { 51.21 - this(nasgenmap$); 51.22 + this(map$); 51.23 } 51.24 51.25 /** 51.26 @@ -67,12 +67,12 @@ 51.27 * @param map property map 51.28 */ 51.29 public PrototypeObject(final PropertyMap map) { 51.30 - super(map != nasgenmap$ ? map.addAll(nasgenmap$) : nasgenmap$); 51.31 + super(map != map$ ? map.addAll(map$) : map$); 51.32 setProto(Global.objectPrototype()); 51.33 } 51.34 51.35 PrototypeObject(final ScriptFunction func) { 51.36 - this(); 51.37 + this(map$); 51.38 this.constructor = func; 51.39 } 51.40
52.1 --- a/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java Fri Jun 21 17:33:05 2013 +0530 52.2 +++ b/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java Thu Jun 27 13:47:20 2013 +0530 52.3 @@ -51,7 +51,7 @@ 52.4 // property map for bound functions 52.5 private static final PropertyMap boundfunctionmap$; 52.6 // property map for non-strict, non-bound functions. 52.7 - private static final PropertyMap nasgenmap$; 52.8 + private static final PropertyMap map$; 52.9 52.10 // Marker object for lazily initialized prototype object 52.11 private static final Object LAZY_PROTOTYPE = new Object(); 52.12 @@ -65,7 +65,7 @@ 52.13 * @param specs specialized versions of this method, if available, null otherwise 52.14 */ 52.15 ScriptFunctionImpl(final String name, final MethodHandle invokeHandle, final MethodHandle[] specs) { 52.16 - super(name, invokeHandle, nasgenmap$, null, specs, false, true, true); 52.17 + super(name, invokeHandle, map$, null, specs, false, true, true); 52.18 init(); 52.19 } 52.20 52.21 @@ -79,7 +79,7 @@ 52.22 * @param specs specialized versions of this method, if available, null otherwise 52.23 */ 52.24 ScriptFunctionImpl(final String name, final MethodHandle invokeHandle, final PropertyMap map, final MethodHandle[] specs) { 52.25 - super(name, invokeHandle, map.addAll(nasgenmap$), null, specs, false, true, true); 52.26 + super(name, invokeHandle, map.addAll(map$), null, specs, false, true, true); 52.27 init(); 52.28 } 52.29 52.30 @@ -124,8 +124,8 @@ 52.31 map = Lookup.newProperty(map, "prototype", Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE, G$PROTOTYPE, S$PROTOTYPE); 52.32 map = Lookup.newProperty(map, "length", Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE | Property.NOT_WRITABLE, G$LENGTH, null); 52.33 map = Lookup.newProperty(map, "name", Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE | Property.NOT_WRITABLE, G$NAME, null); 52.34 - nasgenmap$ = map; 52.35 - strictmodemap$ = createStrictModeMap(nasgenmap$); 52.36 + map$ = map; 52.37 + strictmodemap$ = createStrictModeMap(map$); 52.38 boundfunctionmap$ = createBoundFunctionMap(strictmodemap$); 52.39 } 52.40 52.41 @@ -149,19 +149,17 @@ 52.42 return typeErrorThrower; 52.43 } 52.44 52.45 - // add a new property that throws TypeError on get as well as set 52.46 - static synchronized PropertyMap newThrowerProperty(final PropertyMap map, final String name) { 52.47 - return map.newProperty(name, Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE, -1, 52.48 - Lookup.TYPE_ERROR_THROWER_GETTER, Lookup.TYPE_ERROR_THROWER_SETTER); 52.49 - } 52.50 - 52.51 - private static PropertyMap createStrictModeMap(final PropertyMap functionMap) { 52.52 - return newThrowerProperty(newThrowerProperty(functionMap, "arguments"), "caller"); 52.53 + private static PropertyMap createStrictModeMap(PropertyMap map) { 52.54 + final int flags = Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE; 52.55 + // Need to add properties directly to map since slots are assigned speculatively by newUserAccessors. 52.56 + map = map.addProperty(map.newUserAccessors("arguments", flags)); 52.57 + map = map.addProperty(map.newUserAccessors("caller", flags)); 52.58 + return map; 52.59 } 52.60 52.61 // Choose the map based on strict mode! 52.62 private static PropertyMap getMap(final boolean strict) { 52.63 - return strict ? strictmodemap$ : nasgenmap$; 52.64 + return strict ? strictmodemap$ : map$; 52.65 } 52.66 52.67 private static PropertyMap createBoundFunctionMap(final PropertyMap strictModeMap) { 52.68 @@ -260,12 +258,15 @@ 52.69 this.setProto(Global.instance().getFunctionPrototype()); 52.70 this.prototype = LAZY_PROTOTYPE; 52.71 52.72 - if (isStrict()) { 52.73 - final ScriptFunction func = getTypeErrorThrower(); 52.74 - // We have to fill user accessor functions late as these are stored 52.75 - // in this object rather than in the PropertyMap of this object. 52.76 - setUserAccessors("arguments", func, func); 52.77 - setUserAccessors("caller", func, func); 52.78 + // We have to fill user accessor functions late as these are stored 52.79 + // in this object rather than in the PropertyMap of this object. 52.80 + 52.81 + if (findProperty("arguments", true) != null) { 52.82 + setUserAccessors("arguments", getTypeErrorThrower(), getTypeErrorThrower()); 52.83 + } 52.84 + 52.85 + if (findProperty("caller", true) != null) { 52.86 + setUserAccessors("caller", getTypeErrorThrower(), getTypeErrorThrower()); 52.87 } 52.88 } 52.89 }
53.1 --- a/src/jdk/nashorn/internal/runtime/AccessorProperty.java Fri Jun 21 17:33:05 2013 +0530 53.2 +++ b/src/jdk/nashorn/internal/runtime/AccessorProperty.java Thu Jun 27 13:47:20 2013 +0530 53.3 @@ -288,7 +288,7 @@ 53.4 } 53.5 53.6 @Override 53.7 - protected void setObjectValue(final ScriptObject self, final ScriptObject owner, final Object value, final boolean strict) { 53.8 + public void setObjectValue(final ScriptObject self, final ScriptObject owner, final Object value, final boolean strict) { 53.9 if (isSpill()) { 53.10 self.spill[getSlot()] = value; 53.11 } else { 53.12 @@ -303,7 +303,7 @@ 53.13 } 53.14 53.15 @Override 53.16 - protected Object getObjectValue(final ScriptObject self, final ScriptObject owner) { 53.17 + public Object getObjectValue(final ScriptObject self, final ScriptObject owner) { 53.18 if (isSpill()) { 53.19 return self.spill[getSlot()]; 53.20 }
54.1 --- a/src/jdk/nashorn/internal/runtime/Context.java Fri Jun 21 17:33:05 2013 +0530 54.2 +++ b/src/jdk/nashorn/internal/runtime/Context.java Thu Jun 27 13:47:20 2013 +0530 54.3 @@ -101,13 +101,7 @@ 54.4 /** Is Context global debug mode enabled ? */ 54.5 public static final boolean DEBUG = Options.getBooleanProperty("nashorn.debug"); 54.6 54.7 - private static final ThreadLocal<ScriptObject> currentGlobal = 54.8 - new ThreadLocal<ScriptObject>() { 54.9 - @Override 54.10 - protected ScriptObject initialValue() { 54.11 - return null; 54.12 - } 54.13 - }; 54.14 + private static final ThreadLocal<ScriptObject> currentGlobal = new ThreadLocal<>(); 54.15 54.16 /** 54.17 * Get the current global scope
55.1 --- a/src/jdk/nashorn/internal/runtime/ECMAException.java Fri Jun 21 17:33:05 2013 +0530 55.2 +++ b/src/jdk/nashorn/internal/runtime/ECMAException.java Thu Jun 27 13:47:20 2013 +0530 55.3 @@ -51,7 +51,7 @@ 55.4 /** Field handle to the{@link ECMAException#thrown} field, so that it can be accessed from generated code */ 55.5 public static final FieldAccess THROWN = virtualField(ECMAException.class, "thrown", Object.class); 55.6 55.7 - private static final String EXCEPTION_PROPERTY = "nashornException"; 55.8 + public static final String EXCEPTION_PROPERTY = "nashornException"; 55.9 55.10 /** Object thrown. */ 55.11 public final Object thrown;
56.1 --- a/src/jdk/nashorn/internal/runtime/FindProperty.java Fri Jun 21 17:33:05 2013 +0530 56.2 +++ b/src/jdk/nashorn/internal/runtime/FindProperty.java Thu Jun 27 13:47:20 2013 +0530 56.3 @@ -89,7 +89,7 @@ 56.4 MethodHandle setter = property.getSetter(type, getOwner().getMap()); 56.5 if (property instanceof UserAccessorProperty) { 56.6 final UserAccessorProperty uc = (UserAccessorProperty) property; 56.7 - setter = MH.insertArguments(setter, 0, (isInherited() ? getOwner() : null), 56.8 + setter = MH.insertArguments(setter, 0, isInherited() ? getOwner() : null, 56.9 uc.getSetterSlot(), strict? property.getKey() : null); 56.10 } 56.11 56.12 @@ -109,7 +109,7 @@ 56.13 * @return appropriate receiver 56.14 */ 56.15 public ScriptObject getGetterReceiver() { 56.16 - return property != null && property.hasGetterFunction() ? self : prototype; 56.17 + return property != null && property.hasGetterFunction(prototype) ? self : prototype; 56.18 } 56.19 56.20 /** 56.21 @@ -117,7 +117,7 @@ 56.22 * @return appropriate receiver 56.23 */ 56.24 public ScriptObject getSetterReceiver() { 56.25 - return property != null && property.hasSetterFunction() ? self : prototype; 56.26 + return property != null && property.hasSetterFunction(prototype) ? self : prototype; 56.27 } 56.28 56.29 /**
57.1 --- a/src/jdk/nashorn/internal/runtime/FunctionScope.java Fri Jun 21 17:33:05 2013 +0530 57.2 +++ b/src/jdk/nashorn/internal/runtime/FunctionScope.java Thu Jun 27 13:47:20 2013 +0530 57.3 @@ -54,9 +54,8 @@ 57.4 * @param arguments arguments 57.5 */ 57.6 public FunctionScope(final PropertyMap map, final ScriptObject callerScope, final Object arguments) { 57.7 - super(map); 57.8 + super(callerScope, map); 57.9 this.arguments = arguments; 57.10 - setProto(callerScope); 57.11 setIsScope(); 57.12 } 57.13 57.14 @@ -67,9 +66,8 @@ 57.15 * @param callerScope caller scope 57.16 */ 57.17 public FunctionScope(final PropertyMap map, final ScriptObject callerScope) { 57.18 - super(map); 57.19 + super(callerScope, map); 57.20 this.arguments = null; 57.21 - setProto(callerScope); 57.22 setIsScope(); 57.23 } 57.24
58.1 --- a/src/jdk/nashorn/internal/runtime/Property.java Fri Jun 21 17:33:05 2013 +0530 58.2 +++ b/src/jdk/nashorn/internal/runtime/Property.java Thu Jun 27 13:47:20 2013 +0530 58.3 @@ -180,17 +180,19 @@ 58.4 58.5 /** 58.6 * Check whether this property has a user defined getter function. See {@link UserAccessorProperty} 58.7 + * @param obj object containing getter 58.8 * @return true if getter function exists, false is default 58.9 */ 58.10 - public boolean hasGetterFunction() { 58.11 + public boolean hasGetterFunction(final ScriptObject obj) { 58.12 return false; 58.13 } 58.14 58.15 /** 58.16 * Check whether this property has a user defined setter function. See {@link UserAccessorProperty} 58.17 + * @param obj object containing setter 58.18 * @return true if getter function exists, false is default 58.19 */ 58.20 - public boolean hasSetterFunction() { 58.21 + public boolean hasSetterFunction(final ScriptObject obj) { 58.22 return false; 58.23 } 58.24 58.25 @@ -363,7 +365,7 @@ 58.26 * @param value the new property value 58.27 * @param strict is this a strict setter? 58.28 */ 58.29 - protected abstract void setObjectValue(ScriptObject self, ScriptObject owner, Object value, boolean strict); 58.30 + public abstract void setObjectValue(ScriptObject self, ScriptObject owner, Object value, boolean strict); 58.31 58.32 /** 58.33 * Set the Object value of this property from {@code owner}. This allows to bypass creation of the 58.34 @@ -373,7 +375,7 @@ 58.35 * @param owner the owner object 58.36 * @return the property value 58.37 */ 58.38 - protected abstract Object getObjectValue(ScriptObject self, ScriptObject owner); 58.39 + public abstract Object getObjectValue(ScriptObject self, ScriptObject owner); 58.40 58.41 /** 58.42 * Abstract method for retrieving the setter for the property. We do not know
59.1 --- a/src/jdk/nashorn/internal/runtime/PropertyMap.java Fri Jun 21 17:33:05 2013 +0530 59.2 +++ b/src/jdk/nashorn/internal/runtime/PropertyMap.java Thu Jun 27 13:47:20 2013 +0530 59.3 @@ -25,6 +25,8 @@ 59.4 59.5 package jdk.nashorn.internal.runtime; 59.6 59.7 +import jdk.nashorn.internal.scripts.JO; 59.8 + 59.9 import static jdk.nashorn.internal.runtime.PropertyHashMap.EMPTY_HASHMAP; 59.10 59.11 import java.lang.invoke.MethodHandle; 59.12 @@ -166,7 +168,7 @@ 59.13 */ 59.14 public static PropertyMap newMap(final Class<?> structure, final Collection<Property> properties, final int fieldCount, final int fieldMaximum) { 59.15 // Reduce the number of empty maps in the context. 59.16 - if (structure == jdk.nashorn.internal.scripts.JO.class) { 59.17 + if (structure == JO.class) { 59.18 return EMPTY_MAP; 59.19 } 59.20 59.21 @@ -302,7 +304,7 @@ 59.22 * 59.23 * @return New {@link PropertyMap} with {@link Property} added. 59.24 */ 59.25 - PropertyMap addProperty(final Property property) { 59.26 + public PropertyMap addProperty(final Property property) { 59.27 PropertyMap newMap = checkHistory(property); 59.28 59.29 if (newMap == null) { 59.30 @@ -383,6 +385,21 @@ 59.31 return newMap; 59.32 } 59.33 59.34 + /* 59.35 + * Make a new UserAccessorProperty property. getter and setter functions are stored in 59.36 + * this ScriptObject and slot values are used in property object. Note that slots 59.37 + * are assigned speculatively and should be added to map before adding other 59.38 + * properties. 59.39 + */ 59.40 + public UserAccessorProperty newUserAccessors(final String key, final int propertyFlags) { 59.41 + int oldSpillLength = spillLength; 59.42 + 59.43 + final int getterSlot = oldSpillLength++; 59.44 + final int setterSlot = oldSpillLength++; 59.45 + 59.46 + return new UserAccessorProperty(key, propertyFlags, getterSlot, setterSlot); 59.47 + } 59.48 + 59.49 /** 59.50 * Find a property in the map. 59.51 *
60.1 --- a/src/jdk/nashorn/internal/runtime/ScriptFunction.java Fri Jun 21 17:33:05 2013 +0530 60.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptFunction.java Thu Jun 27 13:47:20 2013 +0530 60.3 @@ -203,6 +203,16 @@ 60.4 } 60.5 60.6 /** 60.7 + * Execute this script function as a constructor. 60.8 + * @param arguments Call arguments. 60.9 + * @return Newly constructed result. 60.10 + * @throws Throwable if there is an exception/error with the invocation or thrown from it 60.11 + */ 60.12 + Object construct(final Object... arguments) throws Throwable { 60.13 + return data.construct(this, arguments); 60.14 + } 60.15 + 60.16 + /** 60.17 * Allocate function. Called from generated {@link ScriptObject} code 60.18 * for allocation as a factory method 60.19 *
61.1 --- a/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java Fri Jun 21 17:33:05 2013 +0530 61.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java Thu Jun 27 13:47:20 2013 +0530 61.3 @@ -216,6 +216,12 @@ 61.4 return composeGenericMethod(code.mostGeneric().getInvoker()); 61.5 } 61.6 61.7 + final MethodHandle getGenericConstructor() { 61.8 + ensureCodeGenerated(); 61.9 + ensureConstructor(code.mostGeneric()); 61.10 + return composeGenericMethod(code.mostGeneric().getConstructor()); 61.11 + } 61.12 + 61.13 private CompiledFunction getBest(final MethodType callSiteType) { 61.14 ensureCodeGenerated(); 61.15 return code.best(callSiteType); 61.16 @@ -535,10 +541,74 @@ 61.17 } 61.18 } 61.19 61.20 + Object construct(final ScriptFunction fn, final Object... arguments) throws Throwable { 61.21 + final MethodHandle mh = getGenericConstructor(); 61.22 + 61.23 + final Object[] args = arguments == null ? ScriptRuntime.EMPTY_ARRAY : arguments; 61.24 + 61.25 + if (isVarArg(mh)) { 61.26 + if (needsCallee(mh)) { 61.27 + return mh.invokeExact(fn, args); 61.28 + } 61.29 + return mh.invokeExact(args); 61.30 + } 61.31 + 61.32 + final int paramCount = mh.type().parameterCount(); 61.33 + if (needsCallee(mh)) { 61.34 + switch (paramCount) { 61.35 + case 1: 61.36 + return mh.invokeExact(fn); 61.37 + case 2: 61.38 + return mh.invokeExact(fn, getArg(args, 0)); 61.39 + case 3: 61.40 + return mh.invokeExact(fn, getArg(args, 0), getArg(args, 1)); 61.41 + case 4: 61.42 + return mh.invokeExact(fn, getArg(args, 0), getArg(args, 1), getArg(args, 2)); 61.43 + default: 61.44 + return mh.invokeWithArguments(withArguments(fn, paramCount, args)); 61.45 + } 61.46 + } 61.47 + 61.48 + switch (paramCount) { 61.49 + case 0: 61.50 + return mh.invokeExact(); 61.51 + case 1: 61.52 + return mh.invokeExact(getArg(args, 0)); 61.53 + case 2: 61.54 + return mh.invokeExact(getArg(args, 0), getArg(args, 1)); 61.55 + case 3: 61.56 + return mh.invokeExact(getArg(args, 0), getArg(args, 1), getArg(args, 2)); 61.57 + default: 61.58 + return mh.invokeWithArguments(withArguments(null, paramCount, args)); 61.59 + } 61.60 + } 61.61 + 61.62 private static Object getArg(final Object[] args, final int i) { 61.63 return i < args.length ? args[i] : UNDEFINED; 61.64 } 61.65 61.66 + private static Object[] withArguments(final ScriptFunction fn, final int argCount, final Object[] args) { 61.67 + final Object[] finalArgs = new Object[argCount]; 61.68 + 61.69 + int nextArg = 0; 61.70 + if (fn != null) { 61.71 + //needs callee 61.72 + finalArgs[nextArg++] = fn; 61.73 + } 61.74 + 61.75 + // Don't add more args that there is argCount in the handle (including self and callee). 61.76 + for (int i = 0; i < args.length && nextArg < argCount;) { 61.77 + finalArgs[nextArg++] = args[i++]; 61.78 + } 61.79 + 61.80 + // If we have fewer args than argCount, pad with undefined. 61.81 + while (nextArg < argCount) { 61.82 + finalArgs[nextArg++] = UNDEFINED; 61.83 + } 61.84 + 61.85 + return finalArgs; 61.86 + } 61.87 + 61.88 private static Object[] withArguments(final ScriptFunction fn, final Object self, final int argCount, final Object[] args) { 61.89 final Object[] finalArgs = new Object[argCount]; 61.90
62.1 --- a/src/jdk/nashorn/internal/runtime/ScriptObject.java Fri Jun 21 17:33:05 2013 +0530 62.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java Thu Jun 27 13:47:20 2013 +0530 62.3 @@ -170,13 +170,30 @@ 62.4 } 62.5 62.6 this.arrayData = ArrayData.EMPTY_ARRAY; 62.7 - 62.8 - if (map == null) { 62.9 - this.setMap(PropertyMap.newMap(getClass())); 62.10 - return; 62.11 + this.setMap(map == null ? PropertyMap.newMap(getClass()) : map); 62.12 + } 62.13 + 62.14 + /** 62.15 + * Constructor that directly sets the prototype to {@code proto} and property map to 62.16 + * {@code map} without invalidating the map as calling {@link #setProto(ScriptObject)} 62.17 + * would do. This should only be used for objects that are always constructed with the 62.18 + * same combination of prototype and property map. 62.19 + * 62.20 + * @param proto the prototype object 62.21 + * @param map intial {@link PropertyMap} 62.22 + */ 62.23 + protected ScriptObject(final ScriptObject proto, final PropertyMap map) { 62.24 + if (Context.DEBUG) { 62.25 + ScriptObject.count++; 62.26 } 62.27 62.28 - this.setMap(map); 62.29 + this.arrayData = ArrayData.EMPTY_ARRAY; 62.30 + this.setMap(map == null ? PropertyMap.newMap(getClass()) : map); 62.31 + this.proto = proto; 62.32 + 62.33 + if (proto != null) { 62.34 + proto.setIsPrototype(); 62.35 + } 62.36 } 62.37 62.38 /** 62.39 @@ -777,30 +794,18 @@ 62.40 public final Property modifyOwnProperty(final Property oldProperty, final int propertyFlags, final ScriptFunction getter, final ScriptFunction setter) { 62.41 Property newProperty; 62.42 if (oldProperty instanceof UserAccessorProperty) { 62.43 - // re-use the slots of the old user accessor property. 62.44 final UserAccessorProperty uc = (UserAccessorProperty) oldProperty; 62.45 - 62.46 - int getterSlot = uc.getGetterSlot(); 62.47 - // clear the old getter and set the new getter 62.48 + final int getterSlot = uc.getGetterSlot(); 62.49 + final int setterSlot = uc.getSetterSlot(); 62.50 setSpill(getterSlot, getter); 62.51 - // if getter function is null, flag the slot to be negative (less by 1) 62.52 - if (getter == null) { 62.53 - getterSlot = -getterSlot - 1; 62.54 - } 62.55 - 62.56 - int setterSlot = uc.getSetterSlot(); 62.57 - // clear the old setter and set the new setter 62.58 setSpill(setterSlot, setter); 62.59 - // if setter function is null, flag the slot to be negative (less by 1) 62.60 - if (setter == null) { 62.61 - setterSlot = -setterSlot - 1; 62.62 - } 62.63 - 62.64 - newProperty = new UserAccessorProperty(oldProperty.getKey(), propertyFlags, getterSlot, setterSlot); 62.65 + 62.66 // if just flipping getter and setter with new functions, no need to change property or map 62.67 - if (oldProperty.equals(newProperty)) { 62.68 + if (uc.flags == propertyFlags) { 62.69 return oldProperty; 62.70 } 62.71 + 62.72 + newProperty = new UserAccessorProperty(oldProperty.getKey(), propertyFlags, getterSlot, setterSlot); 62.73 } else { 62.74 // erase old property value and create new user accessor property 62.75 erasePropertyValue(oldProperty); 62.76 @@ -862,12 +867,10 @@ 62.77 */ 62.78 public final void setUserAccessors(final String key, final ScriptFunction getter, final ScriptFunction setter) { 62.79 final Property oldProperty = getMap().findProperty(key); 62.80 - if (oldProperty != null) { 62.81 - final UserAccessorProperty newProperty = newUserAccessors(oldProperty.getKey(), oldProperty.getFlags(), getter, setter); 62.82 - modifyOwnProperty(oldProperty, newProperty); 62.83 + if (oldProperty instanceof UserAccessorProperty) { 62.84 + modifyOwnProperty(oldProperty, oldProperty.getFlags(), getter, setter); 62.85 } else { 62.86 - final UserAccessorProperty newProperty = newUserAccessors(key, 0, getter, setter); 62.87 - addOwnProperty(newProperty); 62.88 + addOwnProperty(newUserAccessors(key, oldProperty != null ? oldProperty.getFlags() : 0, getter, setter)); 62.89 } 62.90 } 62.91 62.92 @@ -1712,7 +1715,7 @@ 62.93 62.94 final ScriptObject prototype = find.getOwner(); 62.95 62.96 - if (!property.hasGetterFunction()) { 62.97 + if (!property.hasGetterFunction(prototype)) { 62.98 methodHandle = bindTo(methodHandle, prototype); 62.99 } 62.100 return new GuardedInvocation(methodHandle, getMap().getProtoGetSwitchPoint(proto, name), guard); 62.101 @@ -3144,49 +3147,30 @@ 62.102 * Make a new UserAccessorProperty property. getter and setter functions are stored in 62.103 * this ScriptObject and slot values are used in property object. 62.104 */ 62.105 - private UserAccessorProperty newUserAccessors(final String key, final int propertyFlags, final ScriptFunction getter, final ScriptFunction setter) { 62.106 - int oldSpillLength = getMap().getSpillLength(); 62.107 - 62.108 - int getterSlot = oldSpillLength++; 62.109 - setSpill(getterSlot, getter); 62.110 - // if getter function is null, flag the slot to be negative (less by 1) 62.111 - if (getter == null) { 62.112 - getterSlot = -getterSlot - 1; 62.113 + protected final UserAccessorProperty newUserAccessors(final String key, final int propertyFlags, final ScriptFunction getter, final ScriptFunction setter) { 62.114 + final UserAccessorProperty property = getMap().newUserAccessors(key, propertyFlags); 62.115 + setSpill(property.getGetterSlot(), getter); 62.116 + setSpill(property.getSetterSlot(), setter); 62.117 + 62.118 + return property; 62.119 + } 62.120 + 62.121 + protected final void setSpill(final int slot, final Object value) { 62.122 + if (spill == null) { 62.123 + // create new spill. 62.124 + spill = new Object[Math.max(slot + 1, SPILL_RATE)]; 62.125 + } else if (slot >= spill.length) { 62.126 + // grow spill as needed 62.127 + final Object[] newSpill = new Object[slot + 1]; 62.128 + System.arraycopy(spill, 0, newSpill, 0, spill.length); 62.129 + spill = newSpill; 62.130 } 62.131 62.132 - int setterSlot = oldSpillLength++; 62.133 - 62.134 - setSpill(setterSlot, setter); 62.135 - // if setter function is null, flag the slot to be negative (less by 1) 62.136 - if (setter == null) { 62.137 - setterSlot = -setterSlot - 1; 62.138 - } 62.139 - 62.140 - return new UserAccessorProperty(key, propertyFlags, getterSlot, setterSlot); 62.141 + spill[slot] = value; 62.142 } 62.143 62.144 - private void setSpill(final int slot, final Object value) { 62.145 - if (slot >= 0) { 62.146 - final int index = slot; 62.147 - if (spill == null) { 62.148 - // create new spill. 62.149 - spill = new Object[Math.max(index + 1, SPILL_RATE)]; 62.150 - } else if (index >= spill.length) { 62.151 - // grow spill as needed 62.152 - final Object[] newSpill = new Object[index + 1]; 62.153 - System.arraycopy(spill, 0, newSpill, 0, spill.length); 62.154 - spill = newSpill; 62.155 - } 62.156 - 62.157 - spill[index] = value; 62.158 - } 62.159 - } 62.160 - 62.161 - // user accessors are either stored in spill array slots 62.162 - // get the accessor value using slot number. Note that slot is spill array index. 62.163 - Object getSpill(final int slot) { 62.164 - final int index = slot; 62.165 - return (index < 0 || (index >= spill.length)) ? null : spill[index]; 62.166 + protected Object getSpill(final int slot) { 62.167 + return spill != null && slot < spill.length ? spill[slot] : null; 62.168 } 62.169 62.170 private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
63.1 --- a/src/jdk/nashorn/internal/runtime/ScriptRuntime.java Fri Jun 21 17:33:05 2013 +0530 63.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptRuntime.java Thu Jun 27 13:47:20 2013 +0530 63.3 @@ -361,6 +361,47 @@ 63.4 } 63.5 63.6 /** 63.7 + * Check that the target function is associated with current Context. 63.8 + * And also make sure that 'self', if ScriptObject, is from current context. 63.9 + * 63.10 + * Call a function as a constructor given args. 63.11 + * 63.12 + * @param target ScriptFunction object. 63.13 + * @param args Call arguments. 63.14 + * @return Constructor call result. 63.15 + */ 63.16 + public static Object checkAndConstruct(final ScriptFunction target, final Object... args) { 63.17 + final ScriptObject global = Context.getGlobalTrusted(); 63.18 + if (! (global instanceof GlobalObject)) { 63.19 + throw new IllegalStateException("No current global set"); 63.20 + } 63.21 + 63.22 + if (target.getContext() != global.getContext()) { 63.23 + throw new IllegalArgumentException("'target' function is not from current Context"); 63.24 + } 63.25 + 63.26 + // all in order - call real 'construct' 63.27 + return construct(target, args); 63.28 + } 63.29 + 63.30 + /* 63.31 + * Call a script function as a constructor with given args. 63.32 + * 63.33 + * @param target ScriptFunction object. 63.34 + * @param args Call arguments. 63.35 + * @return Constructor call result. 63.36 + */ 63.37 + public static Object construct(final ScriptFunction target, final Object... args) { 63.38 + try { 63.39 + return target.construct(args); 63.40 + } catch (final RuntimeException | Error e) { 63.41 + throw e; 63.42 + } catch (final Throwable t) { 63.43 + throw new RuntimeException(t); 63.44 + } 63.45 + } 63.46 + 63.47 + /** 63.48 * Generic implementation of ECMA 9.12 - SameValue algorithm 63.49 * 63.50 * @param x first value to compare
64.1 --- a/src/jdk/nashorn/internal/runtime/SetMethodCreator.java Fri Jun 21 17:33:05 2013 +0530 64.2 +++ b/src/jdk/nashorn/internal/runtime/SetMethodCreator.java Thu Jun 27 13:47:20 2013 +0530 64.3 @@ -151,9 +151,10 @@ 64.4 assert methodHandle != null; 64.5 assert property != null; 64.6 64.7 + final ScriptObject prototype = find.getOwner(); 64.8 final MethodHandle boundHandle; 64.9 - if (!property.hasSetterFunction() && find.isInherited()) { 64.10 - boundHandle = ScriptObject.bindTo(methodHandle, find.getOwner()); 64.11 + if (!property.hasSetterFunction(prototype) && find.isInherited()) { 64.12 + boundHandle = ScriptObject.bindTo(methodHandle, prototype); 64.13 } else { 64.14 boundHandle = methodHandle; 64.15 }
65.1 --- a/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java Fri Jun 21 17:33:05 2013 +0530 65.2 +++ b/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java Thu Jun 27 13:47:20 2013 +0530 65.3 @@ -96,19 +96,19 @@ 65.4 } 65.5 65.6 /** 65.7 - * Return getter slot for this UserAccessorProperty. Slots start with first embed field. 65.8 + * Return getter spill slot for this UserAccessorProperty. 65.9 * @return getter slot 65.10 */ 65.11 public int getGetterSlot() { 65.12 - return getterSlot < 0 ? -getterSlot - 1 : getterSlot; 65.13 + return getterSlot; 65.14 } 65.15 65.16 /** 65.17 - * Return setter slot for this UserAccessorProperty. Slots start with first embed field. 65.18 + * Return setter spill slot for this UserAccessorProperty. 65.19 * @return setter slot 65.20 */ 65.21 public int getSetterSlot() { 65.22 - return setterSlot < 0 ? -setterSlot - 1 : setterSlot; 65.23 + return setterSlot; 65.24 } 65.25 65.26 @Override 65.27 @@ -124,7 +124,7 @@ 65.28 65.29 final UserAccessorProperty uc = (UserAccessorProperty) other; 65.30 return getterSlot == uc.getterSlot && setterSlot == uc.setterSlot; 65.31 - } 65.32 + } 65.33 65.34 @Override 65.35 public int hashCode() { 65.36 @@ -136,34 +136,26 @@ 65.37 */ 65.38 @Override 65.39 public int getSpillCount() { 65.40 - // calculate how many spill array slots used by this propery. 65.41 - int count = 0; 65.42 - if (getGetterSlot() >= 0) { 65.43 - count++; 65.44 - } 65.45 - if (getSetterSlot() >= 0) { 65.46 - count++; 65.47 - } 65.48 - return count; 65.49 + return 2; 65.50 } 65.51 65.52 @Override 65.53 - public boolean hasGetterFunction() { 65.54 - return getterSlot > -1; 65.55 + public boolean hasGetterFunction(final ScriptObject obj) { 65.56 + return obj.getSpill(getterSlot) != null; 65.57 } 65.58 65.59 @Override 65.60 - public boolean hasSetterFunction() { 65.61 - return setterSlot > -1; 65.62 + public boolean hasSetterFunction(final ScriptObject obj) { 65.63 + return obj.getSpill(setterSlot) != null; 65.64 } 65.65 65.66 @Override 65.67 - protected Object getObjectValue(final ScriptObject self, final ScriptObject owner) { 65.68 + public Object getObjectValue(final ScriptObject self, final ScriptObject owner) { 65.69 return userAccessorGetter(owner, getGetterSlot(), self); 65.70 } 65.71 65.72 @Override 65.73 - protected void setObjectValue(final ScriptObject self, final ScriptObject owner, final Object value, final boolean strict) { 65.74 + public void setObjectValue(final ScriptObject self, final ScriptObject owner, final Object value, final boolean strict) { 65.75 userAccessorSetter(owner, getSetterSlot(), strict ? getKey() : null, self, value); 65.76 } 65.77
66.1 --- a/src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java Fri Jun 21 17:33:05 2013 +0530 66.2 +++ b/src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java Thu Jun 27 13:47:20 2013 +0530 66.3 @@ -45,44 +45,14 @@ 66.4 * as ScriptObjects from other Nashorn contexts. 66.5 */ 66.6 final class JSObjectLinker implements TypeBasedGuardingDynamicLinker { 66.7 - /** 66.8 - * Instances of this class are used to represent a method member of a JSObject 66.9 - */ 66.10 - private static final class JSObjectMethod { 66.11 - // The name of the JSObject method property 66.12 - private final String name; 66.13 - 66.14 - JSObjectMethod(final String name) { 66.15 - this.name = name; 66.16 - } 66.17 - 66.18 - String getName() { 66.19 - return name; 66.20 - } 66.21 - 66.22 - static GuardedInvocation lookup(final CallSiteDescriptor desc) { 66.23 - final String operator = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0); 66.24 - switch (operator) { 66.25 - case "call": { 66.26 - // collect everything except the first two - JSObjectMethod instance and the actual 'self' 66.27 - final int paramCount = desc.getMethodType().parameterCount(); 66.28 - final MethodHandle caller = MH.asCollector(JSOBJECTMETHOD_CALL, Object[].class, paramCount - 2); 66.29 - return new GuardedInvocation(caller, null, IS_JSOBJECTMETHOD_GUARD); 66.30 - } 66.31 - default: 66.32 - return null; 66.33 - } 66.34 - } 66.35 - } 66.36 - 66.37 @Override 66.38 public boolean canLinkType(final Class<?> type) { 66.39 return canLinkTypeStatic(type); 66.40 } 66.41 66.42 static boolean canLinkTypeStatic(final Class<?> type) { 66.43 - // can link JSObject and JSObjectMethod 66.44 - return JSObject.class.isAssignableFrom(type) || JSObjectMethod.class.isAssignableFrom(type); 66.45 + // can link JSObject 66.46 + return JSObject.class.isAssignableFrom(type); 66.47 } 66.48 66.49 @Override 66.50 @@ -99,8 +69,6 @@ 66.51 final GuardedInvocation inv; 66.52 if (self instanceof JSObject) { 66.53 inv = lookup(desc); 66.54 - } else if (self instanceof JSObjectMethod) { 66.55 - inv = JSObjectMethod.lookup(desc); 66.56 } else { 66.57 throw new AssertionError(); // Should never reach here. 66.58 } 66.59 @@ -115,7 +83,7 @@ 66.60 case "getProp": 66.61 case "getElem": 66.62 case "getMethod": 66.63 - return c > 2 ? findGetMethod(desc, operator) : findGetIndexMethod(); 66.64 + return c > 2 ? findGetMethod(desc) : findGetIndexMethod(); 66.65 case "setProp": 66.66 case "setElem": 66.67 return c > 2 ? findSetMethod(desc) : findSetIndexMethod(); 66.68 @@ -123,15 +91,14 @@ 66.69 case "callMethod": 66.70 return findCallMethod(desc, operator); 66.71 case "new": 66.72 + return findNewMethod(desc); 66.73 default: 66.74 return null; 66.75 } 66.76 } 66.77 66.78 - private static GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final String operator) { 66.79 - // if "getMethod" then return JSObjectMethod object - which just holds the name of the method 66.80 - // subsequently, link on dyn:call for JSObjectMethod will actually call that method 66.81 - final MethodHandle getter = MH.insertArguments("getMethod".equals(operator)? JSOBJECT_GETMETHOD : JSOBJECT_GET, 1, desc.getNameToken(2)); 66.82 + private static GuardedInvocation findGetMethod(final CallSiteDescriptor desc) { 66.83 + final MethodHandle getter = MH.insertArguments(JSOBJECT_GET, 1, desc.getNameToken(2)); 66.84 return new GuardedInvocation(getter, null, IS_JSOBJECT_GUARD); 66.85 } 66.86 66.87 @@ -156,9 +123,9 @@ 66.88 return new GuardedInvocation(func, null, IS_JSOBJECT_GUARD); 66.89 } 66.90 66.91 - @SuppressWarnings("unused") 66.92 - private static boolean isJSObjectMethod(final Object self) { 66.93 - return self instanceof JSObjectMethod; 66.94 + private static GuardedInvocation findNewMethod(final CallSiteDescriptor desc) { 66.95 + MethodHandle func = MH.asCollector(JSOBJECT_NEW, Object[].class, desc.getMethodType().parameterCount() - 1); 66.96 + return new GuardedInvocation(func, null, IS_JSOBJECT_GUARD); 66.97 } 66.98 66.99 @SuppressWarnings("unused") 66.100 @@ -166,12 +133,6 @@ 66.101 return self instanceof JSObject; 66.102 } 66.103 66.104 - 66.105 - @SuppressWarnings("unused") 66.106 - private static Object getMethod(final Object jsobj, final Object key) { 66.107 - return new JSObjectMethod(Objects.toString(key)); 66.108 - } 66.109 - 66.110 @SuppressWarnings("unused") 66.111 private static Object get(final Object jsobj, final Object key) { 66.112 if (key instanceof String) { 66.113 @@ -200,11 +161,8 @@ 66.114 } 66.115 66.116 @SuppressWarnings("unused") 66.117 - private static Object jsObjectMethodCall(final Object jsObjMethod, final Object jsobj, final Object... args) { 66.118 - // we have JSObjectMethod, JSObject and args. Get method name from JSObjectMethod instance 66.119 - final String methodName = ((JSObjectMethod)jsObjMethod).getName(); 66.120 - // call the method on JSObject 66.121 - return ((JSObject)jsobj).call(methodName, args); 66.122 + private static Object newObject(final Object jsobj, final Object... args) { 66.123 + return ((JSObject)jsobj).newObject(null, args); 66.124 } 66.125 66.126 private static int getIndex(final Number n) { 66.127 @@ -214,13 +172,11 @@ 66.128 66.129 private static final MethodHandleFunctionality MH = MethodHandleFactory.getFunctionality(); 66.130 66.131 - private static final MethodHandle IS_JSOBJECTMETHOD_GUARD = findOwnMH("isJSObjectMethod", boolean.class, Object.class); 66.132 private static final MethodHandle IS_JSOBJECT_GUARD = findOwnMH("isJSObject", boolean.class, Object.class); 66.133 - private static final MethodHandle JSOBJECT_GETMETHOD = findOwnMH("getMethod", Object.class, Object.class, Object.class); 66.134 private static final MethodHandle JSOBJECT_GET = findOwnMH("get", Object.class, Object.class, Object.class); 66.135 private static final MethodHandle JSOBJECT_PUT = findOwnMH("put", Void.TYPE, Object.class, Object.class, Object.class); 66.136 private static final MethodHandle JSOBJECT_CALL = findOwnMH("call", Object.class, Object.class, Object.class, Object[].class); 66.137 - private static final MethodHandle JSOBJECTMETHOD_CALL = findOwnMH("jsObjectMethodCall", Object.class, Object.class, Object.class, Object[].class); 66.138 + private static final MethodHandle JSOBJECT_NEW = findOwnMH("newObject", Object.class, Object.class, Object[].class); 66.139 66.140 private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) { 66.141 final Class<?> own = JSObjectLinker.class;
67.1 --- a/src/jdk/nashorn/internal/scripts/JO.java Fri Jun 21 17:33:05 2013 +0530 67.2 +++ b/src/jdk/nashorn/internal/scripts/JO.java Thu Jun 27 13:47:20 2013 +0530 67.3 @@ -32,11 +32,14 @@ 67.4 * Empty object class. 67.5 */ 67.6 public class JO extends ScriptObject { 67.7 + 67.8 + private static final PropertyMap map$ = PropertyMap.newMap(JO.class); 67.9 + 67.10 /** 67.11 * Constructor 67.12 */ 67.13 public JO() { 67.14 - super(PropertyMap.newMap(JO.class)); 67.15 + super(map$); 67.16 } 67.17 67.18 /** 67.19 @@ -49,6 +52,15 @@ 67.20 } 67.21 67.22 /** 67.23 + * Constructor given an initial prototype using the default property map 67.24 + * 67.25 + * @param proto the prototype object 67.26 + */ 67.27 + public JO(final ScriptObject proto) { 67.28 + super(proto, map$); 67.29 + } 67.30 + 67.31 + /** 67.32 * Used by FunctionObjectCreator. A method handle of this method is passed to the ScriptFunction constructor. 67.33 * 67.34 * @param map the property map to use for allocatorMap
68.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 68.2 +++ b/test/script/basic/JDK-8010732.js Thu Jun 27 13:47:20 2013 +0530 68.3 @@ -0,0 +1,48 @@ 68.4 +/* 68.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 68.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 68.7 + * 68.8 + * This code is free software; you can redistribute it and/or modify it 68.9 + * under the terms of the GNU General Public License version 2 only, as 68.10 + * published by the Free Software Foundation. 68.11 + * 68.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 68.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 68.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 68.15 + * version 2 for more details (a copy is included in the LICENSE file that 68.16 + * accompanied this code). 68.17 + * 68.18 + * You should have received a copy of the GNU General Public License version 68.19 + * 2 along with this work; if not, write to the Free Software Foundation, 68.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 68.21 + * 68.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 68.23 + * or visit www.oracle.com if you need additional information or have any 68.24 + * questions. 68.25 + */ 68.26 + 68.27 +/** 68.28 + * JDK-8010732: BigDecimal, BigInteger and Long handling in nashorn 68.29 + * 68.30 + * @test 68.31 + * @run 68.32 + */ 68.33 + 68.34 +var x = new java.math.BigDecimal(1111.5); 68.35 +var y = new java.math.BigDecimal(2222.5); 68.36 + 68.37 +print(x); 68.38 +print(y); 68.39 + 68.40 +print(x + y); 68.41 +print(x - y); 68.42 +print(x * y); 68.43 +print(x / y); 68.44 +print(Math.sin(x)); 68.45 + 68.46 +print(x.toString()); 68.47 +print(y.toString()); 68.48 +print(x.class); 68.49 +print(y.class); 68.50 +print(x.doubleValue() + y.doubleValue()); 68.51 +
69.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 69.2 +++ b/test/script/basic/JDK-8010732.js.EXPECTED Thu Jun 27 13:47:20 2013 +0530 69.3 @@ -0,0 +1,12 @@ 69.4 +1111.5 69.5 +2222.5 69.6 +3334 69.7 +-1111 69.8 +2470308.75 69.9 +0.5001124859392576 69.10 +-0.5841231854504038 69.11 +1111.5 69.12 +2222.5 69.13 +class java.math.BigDecimal 69.14 +class java.math.BigDecimal 69.15 +3334
70.1 --- a/test/script/basic/JDK-8012164.js Fri Jun 21 17:33:05 2013 +0530 70.2 +++ b/test/script/basic/JDK-8012164.js Thu Jun 27 13:47:20 2013 +0530 70.3 @@ -37,8 +37,9 @@ 70.4 try { 70.5 throw new Error('foo'); 70.6 } catch (e) { 70.7 - for (i in e.stack) { 70.8 - printFrame(e.stack[i]); 70.9 + var frames = e.getStackTrace(); 70.10 + for (i in frames) { 70.11 + printFrame(frames[i]); 70.12 } 70.13 } 70.14 }
71.1 --- a/test/script/basic/JDK-8012164.js.EXPECTED Fri Jun 21 17:33:05 2013 +0530 71.2 +++ b/test/script/basic/JDK-8012164.js.EXPECTED Thu Jun 27 13:47:20 2013 +0530 71.3 @@ -1,3 +1,3 @@ 71.4 <test/script/basic/JDK-8012164.js>.error(test/script/basic/JDK-8012164.js:38) 71.5 <test/script/basic/JDK-8012164.js>.func(test/script/basic/JDK-8012164.js:33) 71.6 -<test/script/basic/JDK-8012164.js>.<program>(test/script/basic/JDK-8012164.js:46) 71.7 +<test/script/basic/JDK-8012164.js>.<program>(test/script/basic/JDK-8012164.js:47)
72.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 72.2 +++ b/test/script/basic/JDK-8014781.js Thu Jun 27 13:47:20 2013 +0530 72.3 @@ -0,0 +1,40 @@ 72.4 +/* 72.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 72.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 72.7 + * 72.8 + * This code is free software; you can redistribute it and/or modify it 72.9 + * under the terms of the GNU General Public License version 2 only, as 72.10 + * published by the Free Software Foundation. 72.11 + * 72.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 72.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 72.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 72.15 + * version 2 for more details (a copy is included in the LICENSE file that 72.16 + * accompanied this code). 72.17 + * 72.18 + * You should have received a copy of the GNU General Public License version 72.19 + * 2 along with this work; if not, write to the Free Software Foundation, 72.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 72.21 + * 72.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 72.23 + * or visit www.oracle.com if you need additional information or have any 72.24 + * questions. 72.25 + */ 72.26 + 72.27 +/** 72.28 + * JDK-8014781: support Error.captureStackTrace 72.29 + * 72.30 + * @test 72.31 + * @run 72.32 + */ 72.33 + 72.34 +function MyError() { 72.35 + Error.captureStackTrace(this); 72.36 +} 72.37 + 72.38 +function func() { 72.39 + return new MyError(); 72.40 +} 72.41 + 72.42 +var e = func(); 72.43 +print(e.stack.replace(/\\/g, '/'));
73.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 73.2 +++ b/test/script/basic/JDK-8014781.js.EXPECTED Thu Jun 27 13:47:20 2013 +0530 73.3 @@ -0,0 +1,3 @@ 73.4 +MyError @ test/script/basic/JDK-8014781.js:32 73.5 +func @ test/script/basic/JDK-8014781.js:36 73.6 +<program> @ test/script/basic/JDK-8014781.js:39
74.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 74.2 +++ b/test/script/basic/JDK-8015959.js Thu Jun 27 13:47:20 2013 +0530 74.3 @@ -0,0 +1,54 @@ 74.4 +/* 74.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 74.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 74.7 + * 74.8 + * This code is free software; you can redistribute it and/or modify it 74.9 + * under the terms of the GNU General Public License version 2 only, as 74.10 + * published by the Free Software Foundation. 74.11 + * 74.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 74.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 74.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 74.15 + * version 2 for more details (a copy is included in the LICENSE file that 74.16 + * accompanied this code). 74.17 + * 74.18 + * You should have received a copy of the GNU General Public License version 74.19 + * 2 along with this work; if not, write to the Free Software Foundation, 74.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 74.21 + * 74.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 74.23 + * or visit www.oracle.com if you need additional information or have any 74.24 + * questions. 74.25 + */ 74.26 + 74.27 +/** 74.28 + * JDK-8015959: Can't call foreign constructor 74.29 + * 74.30 + * @test 74.31 + * @run 74.32 + */ 74.33 + 74.34 +function check(global) { 74.35 + var obj = new global.Point(344, 12); 74.36 + print("obj.x " + obj.x); 74.37 + print("obj.y " + obj.y); 74.38 + print("obj instanceof global.Point? " + (obj instanceof global.Point)) 74.39 + 74.40 + var P = global.Point; 74.41 + var p = new P(343, 54); 74.42 + print("p.x " + p.x); 74.43 + print("p.y " + p.y); 74.44 + print("p instanceof P? " + (p instanceof P)) 74.45 +} 74.46 + 74.47 +print("check with loadWithNewGlobal"); 74.48 +check(loadWithNewGlobal({ 74.49 + name: "myscript", 74.50 + script: "function Point(x, y) { this.x = x; this.y = y }; this" 74.51 +})); 74.52 + 74.53 +print("check with script engine"); 74.54 +var m = new javax.script.ScriptEngineManager(); 74.55 +var e = m.getEngineByName('nashorn'); 74.56 +check(e.eval("function Point(x, y) { this.x = x; this.y = y }; this")); 74.57 +
75.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 75.2 +++ b/test/script/basic/JDK-8015959.js.EXPECTED Thu Jun 27 13:47:20 2013 +0530 75.3 @@ -0,0 +1,14 @@ 75.4 +check with loadWithNewGlobal 75.5 +obj.x 344 75.6 +obj.y 12 75.7 +obj instanceof global.Point? true 75.8 +p.x 343 75.9 +p.y 54 75.10 +p instanceof P? true 75.11 +check with script engine 75.12 +obj.x 344 75.13 +obj.y 12 75.14 +obj instanceof global.Point? true 75.15 +p.x 343 75.16 +p.y 54 75.17 +p instanceof P? true
76.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 76.2 +++ b/test/script/basic/JDK-8015969.js Thu Jun 27 13:47:20 2013 +0530 76.3 @@ -0,0 +1,75 @@ 76.4 +/* 76.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 76.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 76.7 + * 76.8 + * This code is free software; you can redistribute it and/or modify it 76.9 + * under the terms of the GNU General Public License version 2 only, as 76.10 + * published by the Free Software Foundation. 76.11 + * 76.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 76.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 76.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 76.15 + * version 2 for more details (a copy is included in the LICENSE file that 76.16 + * accompanied this code). 76.17 + * 76.18 + * You should have received a copy of the GNU General Public License version 76.19 + * 2 along with this work; if not, write to the Free Software Foundation, 76.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 76.21 + * 76.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 76.23 + * or visit www.oracle.com if you need additional information or have any 76.24 + * questions. 76.25 + */ 76.26 + 76.27 +/** 76.28 + * JDK-8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223 76.29 + * 76.30 + * @test 76.31 + * @option -scripting 76.32 + * @run 76.33 + */ 76.34 + 76.35 +var m = new javax.script.ScriptEngineManager(); 76.36 +var e = m.getEngineByName("nashorn"); 76.37 + 76.38 +e.eval(<<EOF 76.39 + 76.40 +'use strict'; 76.41 + 76.42 +try { 76.43 + context = 444; 76.44 + print("FAILED!! context write should have thrown error"); 76.45 +} catch (e) { 76.46 + if (! (e instanceof TypeError)) { 76.47 + print("TypeError expected but got " + e); 76.48 + } 76.49 +} 76.50 + 76.51 +try { 76.52 + engine = "hello"; 76.53 + print("FAILED!! engine write should have thrown error"); 76.54 +} catch (e) { 76.55 + if (! (e instanceof TypeError)) { 76.56 + print("TypeError expected but got " + e); 76.57 + } 76.58 +} 76.59 + 76.60 +try { 76.61 + delete context; 76.62 + print("FAILED!! context delete should have thrown error"); 76.63 +} catch (e) { 76.64 + if (! (e instanceof SyntaxError)) { 76.65 + print("SyntaxError expected but got " + e); 76.66 + } 76.67 +} 76.68 + 76.69 +try { 76.70 + delete engine; 76.71 + print("FAILED!! engine delete should have thrown error"); 76.72 +} catch (e) { 76.73 + if (! (e instanceof SyntaxError)) { 76.74 + print("SyntaxError expected but got " + e); 76.75 + } 76.76 +} 76.77 + 76.78 +EOF);
77.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 77.2 +++ b/test/script/basic/JDK-8017950.js Thu Jun 27 13:47:20 2013 +0530 77.3 @@ -0,0 +1,47 @@ 77.4 +/* 77.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 77.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 77.7 + * 77.8 + * This code is free software; you can redistribute it and/or modify it 77.9 + * under the terms of the GNU General Public License version 2 only, as 77.10 + * published by the Free Software Foundation. 77.11 + * 77.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 77.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 77.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 77.15 + * version 2 for more details (a copy is included in the LICENSE file that 77.16 + * accompanied this code). 77.17 + * 77.18 + * You should have received a copy of the GNU General Public License version 77.19 + * 2 along with this work; if not, write to the Free Software Foundation, 77.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 77.21 + * 77.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 77.23 + * or visit www.oracle.com if you need additional information or have any 77.24 + * questions. 77.25 + */ 77.26 + 77.27 +/** 77.28 + * JDK-8017950: error.stack should be a string rather than an array 77.29 + * 77.30 + * @test 77.31 + * @run 77.32 + */ 77.33 + 77.34 +function func() { 77.35 + try { 77.36 + throw new Error(); 77.37 + } catch (e){ 77.38 + print(e.stack.replace(/\\/g, '/')) 77.39 + } 77.40 +} 77.41 + 77.42 +function f() { 77.43 + func() 77.44 +} 77.45 + 77.46 +function g() { 77.47 + f() 77.48 +} 77.49 + 77.50 +g()
78.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 78.2 +++ b/test/script/basic/JDK-8017950.js.EXPECTED Thu Jun 27 13:47:20 2013 +0530 78.3 @@ -0,0 +1,4 @@ 78.4 +func @ test/script/basic/JDK-8017950.js:33 78.5 +f @ test/script/basic/JDK-8017950.js:40 78.6 +g @ test/script/basic/JDK-8017950.js:44 78.7 +<program> @ test/script/basic/JDK-8017950.js:47
79.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 79.2 +++ b/test/script/basic/JDK-8019226.js Thu Jun 27 13:47:20 2013 +0530 79.3 @@ -0,0 +1,39 @@ 79.4 +/* 79.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 79.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 79.7 + * 79.8 + * This code is free software; you can redistribute it and/or modify it 79.9 + * under the terms of the GNU General Public License version 2 only, as 79.10 + * published by the Free Software Foundation. 79.11 + * 79.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 79.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 79.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 79.15 + * version 2 for more details (a copy is included in the LICENSE file that 79.16 + * accompanied this code). 79.17 + * 79.18 + * You should have received a copy of the GNU General Public License version 79.19 + * 2 along with this work; if not, write to the Free Software Foundation, 79.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 79.21 + * 79.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 79.23 + * or visit www.oracle.com if you need additional information or have any 79.24 + * questions. 79.25 + */ 79.26 + 79.27 +/** 79.28 + * JDK-8019226: line number not generated for first statement if it is on the same function declaration line 79.29 + * 79.30 + * @test 79.31 + * @run 79.32 + */ 79.33 + 79.34 +function func1() { func2() } 79.35 + 79.36 +function func2() { throw new Error() } 79.37 + 79.38 +try { 79.39 + func1() 79.40 +} catch (e) { 79.41 + print(e.stack.replace(/\\/g, '/')) 79.42 +}
80.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 80.2 +++ b/test/script/basic/JDK-8019226.js.EXPECTED Thu Jun 27 13:47:20 2013 +0530 80.3 @@ -0,0 +1,3 @@ 80.4 +func2 @ test/script/basic/JDK-8019226.js:33 80.5 +func1 @ test/script/basic/JDK-8019226.js:31 80.6 +<program> @ test/script/basic/JDK-8019226.js:36
81.1 --- a/test/script/basic/NASHORN-109.js Fri Jun 21 17:33:05 2013 +0530 81.2 +++ b/test/script/basic/NASHORN-109.js Thu Jun 27 13:47:20 2013 +0530 81.3 @@ -33,8 +33,9 @@ 81.4 throw new Error("error"); 81.5 } 81.6 } catch (e) { 81.7 - for (i in e.stack) { 81.8 - print(e.stack[i].methodName + ' ' + e.stack[i].lineNumber); 81.9 + var frames = e.getStackTrace(); 81.10 + for (i in frames) { 81.11 + print(frames[i].methodName + ' ' + frames[i].lineNumber); 81.12 } 81.13 } 81.14
82.1 --- a/test/script/basic/NASHORN-296.js Fri Jun 21 17:33:05 2013 +0530 82.2 +++ b/test/script/basic/NASHORN-296.js Thu Jun 27 13:47:20 2013 +0530 82.3 @@ -33,7 +33,7 @@ 82.4 load({ script: 'throw new Error()', name: name }); 82.5 } catch(e) { 82.6 // normalize windows path separator to URL style 82.7 - var actual = e.stack[0].fileName; 82.8 + var actual = e.getStackTrace()[0].fileName; 82.9 if (actual !== name) { 82.10 fail("expected file name to be " + name + 82.11 ", actually got file name " + actual); 82.12 @@ -48,6 +48,6 @@ 82.13 try { 82.14 throw new Error(); 82.15 } catch (e) { 82.16 - test(e.stack[0].fileName.substring(6)); 82.17 + test(e.getStackTrace()[0].fileName.substring(6)); 82.18 } 82.19
83.1 --- a/test/script/basic/errorstack.js Fri Jun 21 17:33:05 2013 +0530 83.2 +++ b/test/script/basic/errorstack.js Thu Jun 27 13:47:20 2013 +0530 83.3 @@ -22,7 +22,7 @@ 83.4 */ 83.5 83.6 /** 83.7 - * "stack" property of Error objects. (nashorn extension). 83.8 + * "getStackTrace()" method of Error objects. (nashorn extension). 83.9 * 83.10 * @test 83.11 * @run 83.12 @@ -43,9 +43,9 @@ 83.13 try { 83.14 func1(); 83.15 } catch (e) { 83.16 - // "stack" is java.lang.StackTraceElement object 83.17 - for (i in e.stack) { 83.18 - print(e.stack[i].methodName + " : " + e.stack[i].lineNumber); 83.19 + var frames = e.getStackTrace(); 83.20 + for (i in frames) { 83.21 + print(frames[i].methodName + " : " + frames[i].lineNumber); 83.22 } 83.23 } 83.24