changeset 383:5ec4762d9df0

Merge
author sundar
date Thu, 27 Jun 2013 13:47:20 +0530
parents b4e2bccf9598 (current diff) f9c855b828fe (diff)
children 90864d892593
files
diffstat 83 files changed, 1014 insertions(+), 304 deletions(-) [+]
line wrap: on
line diff
--- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java	Thu Jun 27 13:47:20 2013 +0530
@@ -166,11 +166,11 @@
         mi.putStatic(className, MAP_FIELD_NAME, MAP_DESC);
         mi.loadClass(className);
         mi.invokeStatic(MAP_TYPE, MAP_NEWMAP, MAP_NEWMAP_DESC);
-        mi.storeLocal(0);
+        // stack: PropertyMap
     }
 
     static void emitStaticInitSuffix(final MethodGenerator mi, final String className) {
-        mi.loadLocal(0);
+        // stack: PropertyMap
         mi.putStatic(className, MAP_FIELD_NAME, MAP_DESC);
         mi.returnVoid();
         mi.computeMaxs();
@@ -278,7 +278,7 @@
 
     static void linkerAddGetterSetter(final MethodGenerator mi, final String className, final MemberInfo memInfo) {
         final String propertyName = memInfo.getName();
-        mi.loadLocal(0);
+        // stack: PropertyMap
         mi.loadLiteral(propertyName);
         // setup flags
         mi.push(memInfo.getAttributes());
@@ -293,12 +293,12 @@
             mi.visitLdcInsn(new Handle(H_INVOKEVIRTUAL, className, javaName, setterDesc(memInfo)));
         }
         mi.invokeStatic(LOOKUP_TYPE, LOOKUP_NEWPROPERTY, LOOKUP_NEWPROPERTY_DESC);
-        mi.storeLocal(0);
+        // stack: PropertyMap
     }
 
     static void linkerAddGetterSetter(final MethodGenerator mi, final String className, final MemberInfo getter, final MemberInfo setter) {
         final String propertyName = getter.getName();
-        mi.loadLocal(0);
+        // stack: PropertyMap
         mi.loadLiteral(propertyName);
         // setup flags
         mi.push(getter.getAttributes());
@@ -313,7 +313,7 @@
                     setter.getJavaName(), setter.getJavaDesc()));
         }
         mi.invokeStatic(LOOKUP_TYPE, LOOKUP_NEWPROPERTY, LOOKUP_NEWPROPERTY_DESC);
-        mi.storeLocal(0);
+        // stack: PropertyMap
     }
 
     static ScriptClassInfo getScriptClassInfo(final String fileName) throws IOException {
--- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInstrumentor.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInstrumentor.java	Thu Jun 27 13:47:20 2013 +0530
@@ -159,10 +159,14 @@
             public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc) {
                 if (isConstructor && opcode == INVOKESPECIAL &&
                         INIT.equals(name) && SCRIPTOBJECT_TYPE.equals(owner)) {
-                    super.visitFieldInsn(GETSTATIC, scriptClassInfo.getJavaName(),
-                            MAP_FIELD_NAME, MAP_DESC);
-                    super.visitMethodInsn(INVOKESPECIAL, SCRIPTOBJECT_TYPE, INIT,
-                            SCRIPTOBJECT_INIT_DESC);
+
+                    // replace call to empty super-constructor with one passing PropertyMap argument
+                    if (DEFAULT_INIT_DESC.equals(desc)) {
+                        super.visitFieldInsn(GETSTATIC, scriptClassInfo.getJavaName(), MAP_FIELD_NAME, MAP_DESC);
+                        super.visitMethodInsn(INVOKESPECIAL, SCRIPTOBJECT_TYPE, INIT, SCRIPTOBJECT_INIT_DESC);
+                    } else {
+                        super.visitMethodInsn(opcode, owner, name, desc);
+                    }
 
                     if (memberCount > 0) {
                         // initialize @Property fields if needed
@@ -223,7 +227,7 @@
                 ClassGenerator.addSetter(cv, className, memInfo);
             }
         }
-        ClassGenerator.addMapField(this);
+        // omit addMapField() since instance classes already define a static PropertyMap field
     }
 
     void emitGettersSetters() {
--- a/docs/JavaScriptingProgrammersGuide.html	Fri Jun 21 17:33:05 2013 +0530
+++ b/docs/JavaScriptingProgrammersGuide.html	Thu Jun 27 13:47:20 2013 +0530
@@ -227,6 +227,16 @@
 it. Note that the syntax to access Java objects, methods and fields
 is dependent on the scripting language. JavaScript supports the
 most "natural" Java-like syntax.</p>
+<p>
+Nashorn script engine pre-defines two global variables named "context"
+and "engine". The "context" variable is of type javax.script.ScriptContext
+and refers to the current ScriptContext instance passed to script engine's
+eval method. The "engine" variable is of type javax.script.ScriptEngine and
+refers to the current nashorn script engine instance evaluating the script.
+Both of these variables are non-writable, non-enumerable and non-configurable
+- which implies script code can not write overwrite the value, for..loop iteration
+on global object will not iterate these variables and these variables can not be
+deleted by script.
 <pre><code>
 // <a href="source/ScriptVars.java">ScriptVars.java</a>
 
--- a/src/jdk/nashorn/api/scripting/JSObject.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/api/scripting/JSObject.java	Thu Jun 27 13:47:20 2013 +0530
@@ -30,13 +30,23 @@
  */
 public abstract class JSObject {
     /**
-     * Call a JavaScript method
+     * Call a JavaScript function
      *
-     * @param methodName name of method
+     * @param functionName name of function
      * @param args arguments to method
      * @return result of call
      */
-    public abstract Object call(String methodName, Object args[]);
+    public abstract Object call(String functionName, Object... args);
+
+    /**
+     * Call a JavaScript method as a constructor. This is equivalent to
+     * calling new obj.Method(arg1, arg2...) in JavaScript.
+     *
+     * @param functionName name of function
+     * @param args arguments to method
+     * @return result of constructor call
+     */
+    public abstract Object newObject(String functionName, Object... args);
 
     /**
      * Evaluate a JavaScript expression
--- a/src/jdk/nashorn/api/scripting/NashornException.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/api/scripting/NashornException.java	Thu Jun 27 13:47:20 2013 +0530
@@ -25,6 +25,9 @@
 
 package jdk.nashorn.api.scripting;
 
+import java.util.ArrayList;
+import java.util.List;
+import jdk.nashorn.internal.codegen.CompilerConstants;
 import jdk.nashorn.internal.runtime.ECMAErrors;
 
 /**
@@ -136,4 +139,52 @@
         return column;
     }
 
+    /**
+     * Returns array javascript stack frames from the given exception object.
+     *
+     * @param exception exception from which stack frames are retrieved and filtered
+     * @return array of javascript stack frames
+     */
+    public static StackTraceElement[] getScriptFrames(final Throwable exception) {
+        final StackTraceElement[] frames = ((Throwable)exception).getStackTrace();
+        final List<StackTraceElement> filtered = new ArrayList<>();
+        for (final StackTraceElement st : frames) {
+            if (ECMAErrors.isScriptFrame(st)) {
+                final String className = "<" + st.getFileName() + ">";
+                String methodName = st.getMethodName();
+                if (methodName.equals(CompilerConstants.RUN_SCRIPT.symbolName())) {
+                    methodName = "<program>";
+                }
+                filtered.add(new StackTraceElement(className, methodName,
+                        st.getFileName(), st.getLineNumber()));
+            }
+        }
+        return filtered.toArray(new StackTraceElement[filtered.size()]);
+    }
+
+    /**
+     * Return a formatted script stack trace string with frames information separated by '\n'
+     *
+     * @param exception exception for which script stack string is returned
+     * @return formatted stack trace string
+     */
+    public static String getScriptStackString(final Throwable exception) {
+        final StringBuilder buf = new StringBuilder();
+        final StackTraceElement[] frames = getScriptFrames((Throwable)exception);
+        for (final StackTraceElement st : frames) {
+            buf.append(st.getMethodName());
+            buf.append(" @ ");
+            buf.append(st.getFileName());
+            buf.append(':');
+            buf.append(st.getLineNumber());
+            buf.append('\n');
+        }
+        final int len = buf.length();
+        // remove trailing '\n'
+        if (len > 0) {
+            assert buf.charAt(len - 1) == '\n';
+            buf.deleteCharAt(len - 1);
+        }
+        return buf.toString();
+    }
 }
--- a/src/jdk/nashorn/api/scripting/NashornScriptEngine.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/api/scripting/NashornScriptEngine.java	Thu Jun 27 13:47:20 2013 +0530
@@ -71,6 +71,9 @@
     private final ScriptEngineFactory factory;
     private final Context             nashornContext;
     private final ScriptObject        global;
+    // initialized bit late to be made 'final'. Property object for "context"
+    // property of global object
+    private Property                  contextProperty;
 
     // default options passed to Nashorn Options object
     private static final String[] DEFAULT_OPTIONS = new String[] { "-scripting", "-doe" };
@@ -281,13 +284,16 @@
 
         nashornContext.initGlobal(newGlobal);
 
+        final int NON_ENUMERABLE_CONSTANT = Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE | Property.NOT_WRITABLE;
         // current ScriptContext exposed as "context"
-        newGlobal.addOwnProperty("context", Property.NOT_ENUMERABLE, UNDEFINED);
+        // "context" is non-writable from script - but script engine still
+        // needs to set it and so save the context Property object
+        contextProperty = newGlobal.addOwnProperty("context", NON_ENUMERABLE_CONSTANT, UNDEFINED);
         // current ScriptEngine instance exposed as "engine". We added @SuppressWarnings("LeakingThisInConstructor") as
         // NetBeans identifies this assignment as such a leak - this is a false positive as we're setting this property
         // in the Global of a Context we just created - both the Context and the Global were just created and can not be
         // seen from another thread outside of this constructor.
-        newGlobal.addOwnProperty("engine", Property.NOT_ENUMERABLE, this);
+        newGlobal.addOwnProperty("engine", NON_ENUMERABLE_CONSTANT, this);
         // global script arguments with undefined value
         newGlobal.addOwnProperty("arguments", Property.NOT_ENUMERABLE, UNDEFINED);
         // file name default is null
@@ -322,9 +328,10 @@
 
     // scripts should see "context" and "engine" as variables
     private void setContextVariables(final ScriptContext ctxt) {
-        ctxt.setAttribute("context", ctxt, ScriptContext.ENGINE_SCOPE);
         final ScriptObject ctxtGlobal = getNashornGlobalFrom(ctxt);
-        ctxtGlobal.set("context", ctxt, false);
+        // set "context" global variable via contextProperty - because this
+        // property is non-writable
+        contextProperty.setObjectValue(ctxtGlobal, ctxtGlobal, ctxt, false);
         Object args = ScriptObjectMirror.unwrap(ctxt.getAttribute("arguments"), ctxtGlobal);
         if (args == null || args == UNDEFINED) {
             args = ScriptRuntime.EMPTY_ARRAY;
--- a/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java	Thu Jun 27 13:47:20 2013 +0530
@@ -102,7 +102,7 @@
 
     // JSObject methods
     @Override
-    public Object call(final String methodName, final Object args[]) {
+    public Object call(final String functionName, final Object... args) {
         final ScriptObject oldGlobal = NashornScriptEngine.getNashornGlobal();
         final boolean globalChanged = (oldGlobal != global);
 
@@ -111,9 +111,9 @@
                 NashornScriptEngine.setNashornGlobal(global);
             }
 
-            final Object val = sobj.get(methodName);
+            final Object val = functionName == null? sobj : sobj.get(functionName);
             if (! (val instanceof ScriptFunction)) {
-                throw new RuntimeException("No such method: " + methodName);
+                throw new RuntimeException("No such function " + ((functionName != null)? functionName : ""));
             }
 
             final Object[] modArgs = globalChanged? wrapArray(args, oldGlobal) : args;
@@ -130,6 +130,34 @@
     }
 
     @Override
+    public Object newObject(final String functionName, final Object... args) {
+        final ScriptObject oldGlobal = NashornScriptEngine.getNashornGlobal();
+        final boolean globalChanged = (oldGlobal != global);
+
+        try {
+            if (globalChanged) {
+                NashornScriptEngine.setNashornGlobal(global);
+            }
+
+            final Object val = functionName == null? sobj : sobj.get(functionName);
+            if (! (val instanceof ScriptFunction)) {
+                throw new RuntimeException("not a constructor " + ((functionName != null)? functionName : ""));
+            }
+
+            final Object[] modArgs = globalChanged? wrapArray(args, oldGlobal) : args;
+            return wrap(ScriptRuntime.checkAndConstruct((ScriptFunction)val, unwrapArray(modArgs, global)), global);
+        } catch (final RuntimeException | Error e) {
+            throw e;
+        } catch (final Throwable t) {
+            throw new RuntimeException(t);
+        } finally {
+            if (globalChanged) {
+                NashornScriptEngine.setNashornGlobal(oldGlobal);
+            }
+        }
+    }
+
+    @Override
     public Object eval(final String s) {
         return inGlobal(new Callable<Object>() {
             @Override
--- a/src/jdk/nashorn/internal/codegen/ClassEmitter.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/codegen/ClassEmitter.java	Thu Jun 27 13:47:20 2013 +0530
@@ -165,7 +165,8 @@
     /**
      * Constructor from the compiler
      *
-     * @param compiler      Compiler
+     * @param env           Script environment
+     * @param sourceName    Source name
      * @param unitClassName Compile unit class name.
      * @param strictMode    Should we generate this method in strict mode
      */
--- a/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Thu Jun 27 13:47:20 2013 +0530
@@ -244,7 +244,7 @@
     /**
      * Check if this symbol can be accessed directly with a putfield or getfield or dynamic load
      *
-     * @param function function to check for fast scope
+     * @param symbol symbol to check for fast scope
      * @return true if fast scope
      */
     private boolean isFastScope(final Symbol symbol) {
@@ -1016,6 +1016,8 @@
         assert lc.hasCompileUnits();
 
         method = lc.pushMethodEmitter(unit.getClassEmitter().method(functionNode));
+        // new method - reset last line number
+        lastLineNumber = -1;
         // Mark end for variable tables.
         method.begin();
 
@@ -1093,7 +1095,7 @@
     private void lineNumber(final Statement statement) {
         final int lineNumber = statement.getLineNumber();
         if (lineNumber != lastLineNumber) {
-            method.lineNumber(statement.getLineNumber());
+            method.lineNumber(lineNumber);
         }
         lastLineNumber = lineNumber;
     }
--- a/src/jdk/nashorn/internal/codegen/Compiler.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/codegen/Compiler.java	Thu Jun 27 13:47:20 2013 +0530
@@ -245,9 +245,9 @@
     /**
      * Constructor
      *
+     * @param env          script environment
      * @param installer    code installer
-     * @param functionNode function node (in any available {@link CompilationState}) to compile
-     * @param sequence     {@link Compiler#CompilationSequence} of {@link CompilationPhase}s to apply as this compilation
+     * @param sequence     {@link Compiler.CompilationSequence} of {@link CompilationPhase}s to apply as this compilation
      * @param strict       should this compilation use strict mode semantics
      */
     //TODO support an array of FunctionNodes for batch lazy compilation
--- a/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java	Thu Jun 27 13:47:20 2013 +0530
@@ -82,13 +82,13 @@
      * Debug field logger
      * Should we print debugging information for fields when they are generated and getters/setters are called?
      */
-    public static final DebugLogger LOG          = new DebugLogger("fields", "nashorn.fields.debug");
+    public static final DebugLogger LOG = new DebugLogger("fields", "nashorn.fields.debug");
 
     /**
      * is field debugging enabled. Several modules in codegen and properties use this, hence
      * public access.
      */
-    public static final boolean     DEBUG_FIELDS = LOG.isEnabled();
+    public static final boolean DEBUG_FIELDS = LOG.isEnabled();
 
     /**
      * Should the runtime only use java.lang.Object slots for fields? If this is false, the representation
--- a/src/jdk/nashorn/internal/objects/AccessorPropertyDescriptor.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/AccessorPropertyDescriptor.java	Thu Jun 27 13:47:20 2013 +0530
@@ -34,6 +34,7 @@
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.runtime.JSType;
 import jdk.nashorn.internal.runtime.PropertyDescriptor;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptFunction;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.ScriptRuntime;
@@ -63,16 +64,19 @@
     @Property
     public Object set;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     AccessorPropertyDescriptor() {
         this(false, false, UNDEFINED, UNDEFINED);
     }
 
     AccessorPropertyDescriptor(final boolean configurable, final boolean enumerable, final Object get, final Object set) {
+        super(Global.objectPrototype(), $nasgenmap$);
         this.configurable = configurable;
         this.enumerable   = enumerable;
         this.get          = get;
         this.set          = set;
-        setProto(Global.objectPrototype());
     }
 
     @Override
--- a/src/jdk/nashorn/internal/objects/ArrayBufferView.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/ArrayBufferView.java	Thu Jun 27 13:47:20 2013 +0530
@@ -29,6 +29,7 @@
 import jdk.nashorn.internal.objects.annotations.Getter;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.ScriptRuntime;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
@@ -38,6 +39,9 @@
 @ScriptClass("ArrayBufferView")
 abstract class ArrayBufferView extends ScriptObject {
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     ArrayBufferView(final NativeArrayBuffer buffer, final int byteOffset, final int elementLength) {
         checkConstructorArgs(buffer, byteOffset, elementLength);
         this.setProto(getPrototype());
--- a/src/jdk/nashorn/internal/objects/DataPropertyDescriptor.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/DataPropertyDescriptor.java	Thu Jun 27 13:47:20 2013 +0530
@@ -33,6 +33,7 @@
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.runtime.JSType;
 import jdk.nashorn.internal.runtime.PropertyDescriptor;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptFunction;
 import jdk.nashorn.internal.runtime.ScriptObject;
 
@@ -61,16 +62,19 @@
     @Property
     public Object value;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     DataPropertyDescriptor() {
         this(false, false, false, UNDEFINED);
     }
 
     DataPropertyDescriptor(final boolean configurable, final boolean enumerable, final boolean writable, final Object value) {
+        super(Global.objectPrototype(), $nasgenmap$);
         this.configurable = configurable;
         this.enumerable   = enumerable;
         this.writable     = writable;
         this.value        = value;
-        setProto(Global.objectPrototype());
     }
 
 
--- a/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java	Thu Jun 27 13:47:20 2013 +0530
@@ -30,6 +30,7 @@
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.runtime.JSType;
 import jdk.nashorn.internal.runtime.PropertyDescriptor;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptFunction;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.ScriptRuntime;
@@ -51,14 +52,17 @@
     @Property
     public Object enumerable;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     GenericPropertyDescriptor() {
         this(false, false);
     }
 
     GenericPropertyDescriptor(final boolean configurable, final boolean enumerable) {
+        super(Global.objectPrototype(), $nasgenmap$);
         this.configurable = configurable;
         this.enumerable   = enumerable;
-        setProto(Global.objectPrototype());
     }
 
     @Override
--- a/src/jdk/nashorn/internal/objects/Global.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/Global.java	Thu Jun 27 13:47:20 2013 +0530
@@ -53,8 +53,10 @@
 import jdk.nashorn.internal.runtime.GlobalObject;
 import jdk.nashorn.internal.runtime.JSType;
 import jdk.nashorn.internal.runtime.NativeJavaPackage;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptEnvironment;
 import jdk.nashorn.internal.runtime.PropertyDescriptor;
+import jdk.nashorn.internal.runtime.arrays.ArrayData;
 import jdk.nashorn.internal.runtime.regexp.RegExpResult;
 import jdk.nashorn.internal.runtime.Scope;
 import jdk.nashorn.internal.runtime.ScriptFunction;
@@ -379,6 +381,9 @@
 
     private final Context context;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     /**
      * Constructor
      *
@@ -484,7 +489,7 @@
 
     @Override
     public ScriptObject newObject() {
-        return newEmptyInstance();
+        return new JO(getObjectPrototype());
     }
 
     @Override
@@ -1242,7 +1247,17 @@
      * @return the new array
      */
     public static NativeArray allocate(final Object[] initial) {
-        return new NativeArray(initial);
+        ArrayData arrayData = ArrayData.allocate(initial);
+
+        for (int index = 0; index < initial.length; index++) {
+            final Object value = initial[index];
+
+            if (value == ScriptRuntime.EMPTY) {
+                arrayData = arrayData.delete(index);
+            }
+        }
+
+        return new NativeArray(arrayData);
     }
 
     /**
@@ -1252,7 +1267,7 @@
      * @return the new array
      */
     public static NativeArray allocate(final double[] initial) {
-        return new NativeArray(initial);
+        return new NativeArray(ArrayData.allocate(initial));
     }
 
     /**
@@ -1262,7 +1277,7 @@
      * @return the new array
      */
     public static NativeArray allocate(final long[] initial) {
-        return new NativeArray(initial);
+        return new NativeArray(ArrayData.allocate(initial));
     }
 
     /**
@@ -1272,7 +1287,7 @@
      * @return the new array
      */
     public static NativeArray allocate(final int[] initial) {
-        return new NativeArray(initial);
+        return new NativeArray(ArrayData.allocate(initial));
     }
 
     /**
@@ -1329,9 +1344,7 @@
      * @return New empty object.
      */
     public static ScriptObject newEmptyInstance() {
-        final ScriptObject sobj = new JO();
-        sobj.setProto(objectPrototype());
-        return sobj;
+        return Global.instance().newObject();
     }
 
     /**
@@ -1545,7 +1558,7 @@
         addOwnProperty("echo", Attribute.NOT_ENUMERABLE, value);
 
         // Nashorn extension: global.$OPTIONS (scripting-mode-only)
-        final ScriptObject options = newEmptyInstance();
+        final ScriptObject options = newObject();
         final ScriptEnvironment scriptEnv = context.getEnv();
         copyOptions(options, scriptEnv);
         addOwnProperty("$OPTIONS", Attribute.NOT_ENUMERABLE, options);
@@ -1554,7 +1567,7 @@
         if (System.getSecurityManager() == null) {
             // do not fill $ENV if we have a security manager around
             // Retrieve current state of ENV variables.
-            final ScriptObject env = newEmptyInstance();
+            final ScriptObject env = newObject();
             env.putAll(System.getenv());
             addOwnProperty(ScriptingFunctions.ENV_NAME, Attribute.NOT_ENUMERABLE, env);
         } else {
--- a/src/jdk/nashorn/internal/objects/NativeArguments.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeArguments.java	Thu Jun 27 13:47:20 2013 +0530
@@ -61,13 +61,13 @@
     private static final MethodHandle G$CALLEE = findOwnMH("G$callee", Object.class, Object.class);
     private static final MethodHandle S$CALLEE = findOwnMH("S$callee", void.class, Object.class, Object.class);
 
-    private static final PropertyMap nasgenmap$;
+    private static final PropertyMap map$;
 
     static {
         PropertyMap map = PropertyMap.newMap(NativeArguments.class);
         map = Lookup.newProperty(map, "length", Property.NOT_ENUMERABLE, G$LENGTH, S$LENGTH);
         map = Lookup.newProperty(map, "callee", Property.NOT_ENUMERABLE, G$CALLEE, S$CALLEE);
-        nasgenmap$ = map;
+        map$ = map;
     }
 
     private Object length;
@@ -76,8 +76,8 @@
     // This is lazily initialized - only when delete is invoked at all
     private BitSet deleted;
 
-    NativeArguments(final Object[] arguments, final Object callee, final int numParams) {
-        super(nasgenmap$);
+    NativeArguments(final ScriptObject proto, final Object[] arguments, final Object callee, final int numParams) {
+        super(proto, map$);
         setIsArguments();
 
         setArray(ArrayData.allocate(arguments));
@@ -102,9 +102,6 @@
         }
         System.arraycopy(arguments, 0, newValues, 0, Math.min(newValues.length, arguments.length));
         this.namedArgs = ArrayData.allocate(newValues);
-
-        // set Object.prototype as __proto__
-        this.setProto(Global.objectPrototype());
     }
 
     @Override
@@ -553,7 +550,8 @@
     public static ScriptObject allocate(final Object[] arguments, final ScriptFunction callee, final int numParams) {
         // Strict functions won't always have a callee for arguments, and will pass null instead.
         final boolean isStrict = callee == null || callee.isStrict();
-        return isStrict ? new NativeStrictArguments(arguments, numParams) : new NativeArguments(arguments, callee, numParams);
+        final ScriptObject proto = Global.objectPrototype();
+        return isStrict ? new NativeStrictArguments(proto, arguments, numParams) : new NativeArguments(proto, arguments, callee, numParams);
     }
 
     /**
--- a/src/jdk/nashorn/internal/objects/NativeArray.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeArray.java	Thu Jun 27 13:47:20 2013 +0530
@@ -50,6 +50,7 @@
 import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.JSType;
 import jdk.nashorn.internal.runtime.PropertyDescriptor;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptFunction;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.ScriptRuntime;
@@ -82,6 +83,8 @@
 
     private static final InvokeByName TO_LOCALE_STRING = new InvokeByName("toLocaleString", ScriptObject.class, String.class);
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
 
     /*
      * Constructors.
@@ -126,8 +129,8 @@
         this.setArray(arrayData);
     }
 
-    private NativeArray(final ArrayData arrayData) {
-        setProto(Global.instance().getArrayPrototype());
+    NativeArray(final ArrayData arrayData) {
+        super(Global.instance().getArrayPrototype(), $nasgenmap$);
         this.setArray(arrayData);
         this.setIsArray();
     }
--- a/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java	Thu Jun 27 13:47:20 2013 +0530
@@ -32,6 +32,7 @@
 import jdk.nashorn.internal.objects.annotations.Getter;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.ScriptRuntime;
 
@@ -39,6 +40,9 @@
 final class NativeArrayBuffer extends ScriptObject {
     private final byte[] buffer;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     @Constructor(arity = 1)
     public static Object constructor(final boolean newObj, final Object self, final Object... args) {
         if (args.length == 0) {
@@ -49,8 +53,8 @@
     }
 
     protected NativeArrayBuffer(final byte[] byteArray) {
+        super(Global.instance().getArrayBufferPrototype(), $nasgenmap$);
         this.buffer = byteArray;
-        this.setProto(Global.instance().getArrayBufferPrototype());
     }
 
     protected NativeArrayBuffer(final int byteLength) {
--- a/src/jdk/nashorn/internal/objects/NativeBoolean.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeBoolean.java	Thu Jun 27 13:47:20 2013 +0530
@@ -37,6 +37,7 @@
 import jdk.nashorn.internal.objects.annotations.Function;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.ScriptRuntime;
 import jdk.nashorn.internal.lookup.MethodHandleFactory;
@@ -52,13 +53,16 @@
 
     final static MethodHandle WRAPFILTER = findWrapFilter();
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     NativeBoolean(final boolean value) {
         this(value, Global.instance().getBooleanPrototype());
     }
 
     private NativeBoolean(final boolean value, final ScriptObject proto) {
+        super(proto, $nasgenmap$);
         this.value = value;
-        this.setProto(proto);
     }
 
     @Override
--- a/src/jdk/nashorn/internal/objects/NativeDate.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeDate.java	Thu Jun 27 13:47:20 2013 +0530
@@ -42,6 +42,7 @@
 import jdk.nashorn.internal.parser.DateParser;
 import jdk.nashorn.internal.runtime.ConsString;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptEnvironment;
 import jdk.nashorn.internal.runtime.ScriptFunction;
 import jdk.nashorn.internal.runtime.ScriptObject;
@@ -100,16 +101,19 @@
     private double time;
     private final TimeZone timezone;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     NativeDate() {
         this(System.currentTimeMillis());
     }
 
     NativeDate(final double time) {
+        super(Global.instance().getDatePrototype(), $nasgenmap$);
         final ScriptEnvironment env = Global.getEnv();
 
         this.time = time;
         this.timezone = env._timezone;
-        this.setProto(Global.instance().getDatePrototype());
     }
 
     @Override
--- a/src/jdk/nashorn/internal/objects/NativeDebug.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeDebug.java	Thu Jun 27 13:47:20 2013 +0530
@@ -47,8 +47,12 @@
  */
 @ScriptClass("Debug")
 public final class NativeDebug extends ScriptObject {
+
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     NativeDebug() {
-        this.setProto(Global.objectPrototype());
+        super(Global.objectPrototype(), $nasgenmap$);
     }
 
     @Override
@@ -187,7 +191,7 @@
         out.println("Scope count " + ScriptObject.getScopeCount());
         out.println("ScriptObject listeners added " + PropertyListenerManager.getListenersAdded());
         out.println("ScriptObject listeners removed " + PropertyListenerManager.getListenersRemoved());
-        out.println("ScriptFunction count " + ScriptObject.getCount());
+        out.println("ScriptFunction constructor calls " + ScriptFunction.getConstructorCount());
         out.println("ScriptFunction invokes " + ScriptFunction.getInvokes());
         out.println("ScriptFunction allocations " + ScriptFunction.getAllocations());
         out.println("PropertyMap count " + PropertyMap.getCount());
--- a/src/jdk/nashorn/internal/objects/NativeError.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeError.java	Thu Jun 27 13:47:20 2013 +0530
@@ -32,6 +32,7 @@
 import java.lang.invoke.MethodHandles;
 import java.util.ArrayList;
 import java.util.List;
+import jdk.nashorn.api.scripting.NashornException;
 import jdk.nashorn.internal.codegen.CompilerConstants;
 import jdk.nashorn.internal.lookup.MethodHandleFactory;
 import jdk.nashorn.internal.objects.annotations.Attribute;
@@ -43,6 +44,7 @@
 import jdk.nashorn.internal.runtime.ECMAErrors;
 import jdk.nashorn.internal.runtime.ECMAException;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.ScriptRuntime;
 
@@ -86,8 +88,11 @@
     @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE)
     public Object message;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     NativeError(final Object msg) {
-        this.setProto(Global.instance().getErrorPrototype());
+        super(Global.instance().getErrorPrototype(), $nasgenmap$);
         if (msg != UNDEFINED) {
             this.instMessage = JSType.toString(msg);
         } else {
@@ -115,6 +120,20 @@
     }
 
     /**
+     * Nashorn extension: Error.captureStackTrace. Capture stack trace at the point of call into the Error object provided.
+     *
+     * @param self self reference
+     */
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
+    public static Object captureStackTrace(final Object self, final Object errorObj) {
+        Global.checkObject(errorObj);
+        final ScriptObject sobj = (ScriptObject)errorObj;
+        final ECMAException exp = new ECMAException(sobj, null);
+        sobj.set("stack", NashornException.getScriptStackString(exp), false);
+        return UNDEFINED;
+    }
+
+    /**
      * Nashorn extension: Error.dumpStack
      * dumps the stack of the current thread.
      *
@@ -144,6 +163,30 @@
     }
 
     /**
+     * Nashorn extension: Error.prototype.getStackTrace()
+     * "stack" property is an array typed value containing {@link StackTraceElement}
+     * objects of JavaScript stack frames.
+     *
+     * @param self  self reference
+     *
+     * @return      stack trace as a script array.
+     */
+    @Function(attributes = Attribute.NOT_ENUMERABLE)
+    public static Object getStackTrace(final Object self) {
+        Global.checkObject(self);
+        final ScriptObject sobj = (ScriptObject)self;
+        final Object exception = ECMAException.getException(sobj);
+        Object[] res;
+        if (exception instanceof Throwable) {
+            res = NashornException.getScriptFrames((Throwable)exception);
+        } else {
+            res = ScriptRuntime.EMPTY_ARRAY;
+        }
+
+        return new NativeArray(res);
+    }
+
+    /**
      * Nashorn extension: Error.prototype.lineNumber
      *
      * @param self self reference
@@ -229,8 +272,8 @@
 
     /**
      * Nashorn extension: Error.prototype.stack
-     * "stack" property is an array typed value containing {@link StackTraceElement}
-     * objects of JavaScript stack frames.
+     * "stack" property is a string typed value containing JavaScript stack frames.
+     * Each frame information is separated bv "\n" character.
      *
      * @param self  self reference
      *
@@ -244,27 +287,11 @@
         }
 
         final Object exception = ECMAException.getException(sobj);
-        Object[] res;
         if (exception instanceof Throwable) {
-            final StackTraceElement[] frames = ((Throwable)exception).getStackTrace();
-            final List<StackTraceElement> filtered = new ArrayList<>();
-            for (final StackTraceElement st : frames) {
-                if (ECMAErrors.isScriptFrame(st)) {
-                    final String className = "<" + st.getFileName() + ">";
-                    String methodName = st.getMethodName();
-                    if (methodName.equals(CompilerConstants.RUN_SCRIPT.symbolName())) {
-                        methodName = "<program>";
-                    }
-                    filtered.add(new StackTraceElement(className, methodName,
-                            st.getFileName(), st.getLineNumber()));
-                }
-            }
-            res = filtered.toArray();
+            return NashornException.getScriptStackString((Throwable)exception);
         } else {
-            res = ScriptRuntime.EMPTY_ARRAY;
+            return "";
         }
-
-        return new NativeArray(res);
     }
 
     /**
--- a/src/jdk/nashorn/internal/objects/NativeEvalError.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeEvalError.java	Thu Jun 27 13:47:20 2013 +0530
@@ -33,6 +33,7 @@
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 
 /**
@@ -52,10 +53,13 @@
 
     /** ECMA 15.1.1.1 message property */
     @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE)
+    public Object message;
 
-    public Object message;
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     NativeEvalError(final Object msg) {
-        this.setProto(Global.instance().getEvalErrorPrototype());
+        super(Global.instance().getEvalErrorPrototype(), $nasgenmap$);
         if (msg != UNDEFINED) {
             this.instMessage = JSType.toString(msg);
         } else {
--- a/src/jdk/nashorn/internal/objects/NativeFloat32Array.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeFloat32Array.java	Thu Jun 27 13:47:20 2013 +0530
@@ -32,6 +32,7 @@
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
 
@@ -46,6 +47,9 @@
     @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
     public static final int BYTES_PER_ELEMENT = 4;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
         @Override
         public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
--- a/src/jdk/nashorn/internal/objects/NativeFloat64Array.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeFloat64Array.java	Thu Jun 27 13:47:20 2013 +0530
@@ -32,6 +32,7 @@
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
 
@@ -46,6 +47,9 @@
     @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
     public static final int BYTES_PER_ELEMENT = 8;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
         @Override
         public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
--- a/src/jdk/nashorn/internal/objects/NativeFunction.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeFunction.java	Thu Jun 27 13:47:20 2013 +0530
@@ -38,6 +38,7 @@
 import jdk.nashorn.internal.runtime.Context;
 import jdk.nashorn.internal.runtime.JSType;
 import jdk.nashorn.internal.runtime.ParserException;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptFunction;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.ScriptRuntime;
@@ -52,6 +53,10 @@
  */
 @ScriptClass("Function")
 public final class NativeFunction {
+
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     // do *not* create me!
     private NativeFunction() {
     }
--- a/src/jdk/nashorn/internal/objects/NativeInt16Array.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeInt16Array.java	Thu Jun 27 13:47:20 2013 +0530
@@ -31,6 +31,7 @@
 import jdk.nashorn.internal.objects.annotations.Property;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.objects.annotations.Where;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
 
@@ -39,6 +40,10 @@
  */
 @ScriptClass("Int16Array")
 public final class NativeInt16Array extends ArrayBufferView {
+
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     /**
      * The size in bytes of each element in the array.
      */
--- a/src/jdk/nashorn/internal/objects/NativeInt32Array.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeInt32Array.java	Thu Jun 27 13:47:20 2013 +0530
@@ -31,6 +31,7 @@
 import jdk.nashorn.internal.objects.annotations.Property;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.objects.annotations.Where;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
 
@@ -45,6 +46,9 @@
     @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
     public static final int BYTES_PER_ELEMENT = 4;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
         @Override
         public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
--- a/src/jdk/nashorn/internal/objects/NativeInt8Array.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeInt8Array.java	Thu Jun 27 13:47:20 2013 +0530
@@ -31,6 +31,7 @@
 import jdk.nashorn.internal.objects.annotations.Property;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.objects.annotations.Where;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
 
@@ -45,6 +46,9 @@
     @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
     public static final int BYTES_PER_ELEMENT = 1;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
         @Override
         public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
--- a/src/jdk/nashorn/internal/objects/NativeJSAdapter.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeJSAdapter.java	Thu Jun 27 13:47:20 2013 +0530
@@ -42,6 +42,7 @@
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.runtime.FindProperty;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptFunction;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.ScriptRuntime;
@@ -142,9 +143,12 @@
 
     private static final MethodHandle IS_JSADAPTOR = findOwnMH("isJSAdaptor", boolean.class, Object.class, Object.class, MethodHandle.class, Object.class, ScriptFunction.class);
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     NativeJSAdapter(final ScriptObject proto, final Object overrides, final ScriptObject adaptee) {
+        super(proto, $nasgenmap$);
         this.adaptee = wrapAdaptee(adaptee);
-        this.setProto(proto);
         if (overrides instanceof ScriptObject) {
             this.overrides = true;
             final ScriptObject sobj = (ScriptObject)overrides;
--- a/src/jdk/nashorn/internal/objects/NativeJSON.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeJSON.java	Thu Jun 27 13:47:20 2013 +0530
@@ -42,6 +42,7 @@
 import jdk.nashorn.internal.runtime.ConsString;
 import jdk.nashorn.internal.runtime.JSONFunctions;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptFunction;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayLikeIterator;
@@ -58,9 +59,11 @@
     private static final MethodHandle REPLACER_INVOKER = Bootstrap.createDynamicInvoker("dyn:call", Object.class,
             ScriptFunction.class, ScriptObject.class, Object.class, Object.class);
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
 
     NativeJSON() {
-        this.setProto(Global.objectPrototype());
+        super(Global.objectPrototype(), $nasgenmap$);
     }
 
     /**
--- a/src/jdk/nashorn/internal/objects/NativeJava.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeJava.java	Thu Jun 27 13:47:20 2013 +0530
@@ -40,6 +40,7 @@
 import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.JSType;
 import jdk.nashorn.internal.runtime.ListAdapter;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.linker.JavaAdapterFactory;
 
@@ -52,6 +53,9 @@
 @ScriptClass("Java")
 public final class NativeJava {
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     private NativeJava() {
     }
 
--- a/src/jdk/nashorn/internal/objects/NativeJavaImporter.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeJavaImporter.java	Thu Jun 27 13:47:20 2013 +0530
@@ -34,6 +34,7 @@
 import jdk.nashorn.internal.objects.annotations.Function;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.runtime.NativeJavaPackage;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 
 /**
@@ -55,9 +56,12 @@
 public final class NativeJavaImporter extends ScriptObject {
     private final Object[] args;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     NativeJavaImporter(final Object[] args) {
+        super(Global.instance().getJavaImporterPrototype(), $nasgenmap$);
         this.args = args;
-        this.setProto(Global.instance().getJavaImporterPrototype());
     }
 
     @Override
--- a/src/jdk/nashorn/internal/objects/NativeMath.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeMath.java	Thu Jun 27 13:47:20 2013 +0530
@@ -32,6 +32,7 @@
 import jdk.nashorn.internal.objects.annotations.SpecializedFunction;
 import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 
 /**
@@ -41,8 +42,11 @@
 @ScriptClass("Math")
 public final class NativeMath extends ScriptObject {
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     NativeMath() {
-        this.setProto(Global.objectPrototype());
+        super(Global.objectPrototype(), $nasgenmap$);
     }
 
     /** ECMA 15.8.1.1 - E, always a double constant. Not writable or configurable */
--- a/src/jdk/nashorn/internal/objects/NativeNumber.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeNumber.java	Thu Jun 27 13:47:20 2013 +0530
@@ -45,6 +45,7 @@
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.ScriptRuntime;
 import jdk.nashorn.internal.lookup.MethodHandleFactory;
@@ -83,15 +84,18 @@
     private final boolean isInt;
     private final boolean isLong;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     NativeNumber(final double value) {
         this(value, Global.instance().getNumberPrototype());
     }
 
     private NativeNumber(final double value, final ScriptObject proto) {
+        super(proto, $nasgenmap$);
         this.value = value;
         this.isInt  = isRepresentableAsInt(value);
         this.isLong = isRepresentableAsLong(value);
-        this.setProto(proto);
     }
 
     @Override
--- a/src/jdk/nashorn/internal/objects/NativeObject.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeObject.java	Thu Jun 27 13:47:20 2013 +0530
@@ -36,6 +36,7 @@
 import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.ECMAException;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptFunction;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.ScriptRuntime;
@@ -53,6 +54,9 @@
 public final class NativeObject {
     private static final InvokeByName TO_STRING = new InvokeByName("toString", ScriptObject.class);
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     private NativeObject() {
     }
 
--- a/src/jdk/nashorn/internal/objects/NativeRangeError.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeRangeError.java	Thu Jun 27 13:47:20 2013 +0530
@@ -33,6 +33,7 @@
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 
 /**
@@ -54,8 +55,11 @@
     @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE)
     public Object message;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     NativeRangeError(final Object msg) {
-        setProto(Global.instance().getRangeErrorPrototype());
+        super(Global.instance().getRangeErrorPrototype(), $nasgenmap$);
         if (msg != UNDEFINED) {
             this.instMessage = JSType.toString(msg);
         } else {
--- a/src/jdk/nashorn/internal/objects/NativeReferenceError.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeReferenceError.java	Thu Jun 27 13:47:20 2013 +0530
@@ -33,6 +33,7 @@
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 
 /**
@@ -54,8 +55,11 @@
     @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE)
     public Object message;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     NativeReferenceError(final Object msg) {
-        this.setProto(Global.instance().getReferenceErrorPrototype());
+        super(Global.instance().getReferenceErrorPrototype(), $nasgenmap$);
         if (msg != UNDEFINED) {
             this.instMessage = JSType.toString(msg);
         } else {
--- a/src/jdk/nashorn/internal/objects/NativeRegExp.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeRegExp.java	Thu Jun 27 13:47:20 2013 +0530
@@ -43,6 +43,7 @@
 import jdk.nashorn.internal.runtime.BitVector;
 import jdk.nashorn.internal.runtime.JSType;
 import jdk.nashorn.internal.runtime.ParserException;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.regexp.RegExp;
 import jdk.nashorn.internal.runtime.regexp.RegExpFactory;
 import jdk.nashorn.internal.runtime.regexp.RegExpResult;
@@ -66,6 +67,9 @@
     // Reference to global object needed to support static RegExp properties
     private Global globalObject;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     NativeRegExp(final String input, final String flagString) {
         try {
             this.regexp = RegExpFactory.create(input, flagString);
--- a/src/jdk/nashorn/internal/objects/NativeRegExpExecResult.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeRegExpExecResult.java	Thu Jun 27 13:47:20 2013 +0530
@@ -31,6 +31,7 @@
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.objects.annotations.Setter;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.regexp.RegExpResult;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
@@ -49,8 +50,11 @@
     @Property
     public Object input;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     NativeRegExpExecResult(final RegExpResult result) {
-        setProto(Global.instance().getArrayPrototype());
+        super(Global.instance().getArrayPrototype(), $nasgenmap$);
         setIsArray();
         this.setArray(ArrayData.allocate(result.getGroups().clone()));
         this.index = result.getIndex();
--- a/src/jdk/nashorn/internal/objects/NativeStrictArguments.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeStrictArguments.java	Thu Jun 27 13:47:20 2013 +0530
@@ -51,22 +51,24 @@
     private static final MethodHandle S$LENGTH = findOwnMH("S$length", void.class, Object.class, Object.class);
 
     // property map for strict mode arguments object
-    private static final PropertyMap nasgenmap$;
+    private static final PropertyMap map$;
 
     static {
         PropertyMap map = PropertyMap.newMap(NativeStrictArguments.class);
         map = Lookup.newProperty(map, "length", Property.NOT_ENUMERABLE, G$LENGTH, S$LENGTH);
         // In strict mode, the caller and callee properties should throw TypeError
-        map = ScriptFunctionImpl.newThrowerProperty(map, "caller");
-        map = ScriptFunctionImpl.newThrowerProperty(map, "callee");
-        nasgenmap$ = map;
+        // Need to add properties directly to map since slots are assigned speculatively by newUserAccessors.
+        final int flags = Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE;
+        map = map.addProperty(map.newUserAccessors("caller", flags));
+        map = map.addProperty(map.newUserAccessors("callee", flags));
+        map$ = map;
     }
 
     private Object   length;
     private final Object[] namedArgs;
 
-    NativeStrictArguments(final Object[] values, final int numParams) {
-        super(nasgenmap$);
+    NativeStrictArguments(final ScriptObject proto, final Object[] values, final int numParams) {
+        super(proto, map$);
         setIsArguments();
 
         final ScriptFunction func = ScriptFunctionImpl.getTypeErrorThrower();
@@ -84,8 +86,6 @@
             Arrays.fill(namedArgs, UNDEFINED);
         }
         System.arraycopy(values, 0, namedArgs, 0, Math.min(namedArgs.length, values.length));
-
-        this.setProto(Global.objectPrototype());
     }
 
     @Override
--- a/src/jdk/nashorn/internal/objects/NativeString.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeString.java	Thu Jun 27 13:47:20 2013 +0530
@@ -52,6 +52,7 @@
 import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.ConsString;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptFunction;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.ScriptRuntime;
@@ -70,14 +71,17 @@
 
     static final MethodHandle WRAPFILTER = findWrapFilter();
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     NativeString(final CharSequence value) {
         this(value, Global.instance().getStringPrototype());
     }
 
     private NativeString(final CharSequence value, final ScriptObject proto) {
+        super(proto, $nasgenmap$);
         assert value instanceof String || value instanceof ConsString;
         this.value = value;
-        this.setProto(proto);
     }
 
     @Override
--- a/src/jdk/nashorn/internal/objects/NativeSyntaxError.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeSyntaxError.java	Thu Jun 27 13:47:20 2013 +0530
@@ -33,6 +33,7 @@
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 
 /**
@@ -54,8 +55,11 @@
     @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE)
     public Object message;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     NativeSyntaxError(final Object msg) {
-        this.setProto(Global.instance().getSyntaxErrorPrototype());
+        super(Global.instance().getSyntaxErrorPrototype(), $nasgenmap$);
         if (msg != UNDEFINED) {
             this.instMessage = JSType.toString(msg);
         } else {
--- a/src/jdk/nashorn/internal/objects/NativeTypeError.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeTypeError.java	Thu Jun 27 13:47:20 2013 +0530
@@ -33,6 +33,7 @@
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 
 /**
@@ -54,8 +55,11 @@
     @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE)
     public Object message;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     NativeTypeError(final Object msg) {
-        this.setProto(Global.instance().getTypeErrorPrototype());
+        super(Global.instance().getTypeErrorPrototype(), $nasgenmap$);
         if (msg != UNDEFINED) {
             this.instMessage = JSType.toString(msg);
         } else {
--- a/src/jdk/nashorn/internal/objects/NativeURIError.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeURIError.java	Thu Jun 27 13:47:20 2013 +0530
@@ -33,6 +33,7 @@
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 
 /**
@@ -53,8 +54,11 @@
     @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE)
     public Object message;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     NativeURIError(final Object msg) {
-        this.setProto(Global.instance().getURIErrorPrototype());
+        super(Global.instance().getURIErrorPrototype(), $nasgenmap$);
         if (msg != UNDEFINED) {
             this.instMessage = JSType.toString(msg);
         } else {
--- a/src/jdk/nashorn/internal/objects/NativeUint16Array.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeUint16Array.java	Thu Jun 27 13:47:20 2013 +0530
@@ -31,6 +31,7 @@
 import jdk.nashorn.internal.objects.annotations.Property;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.objects.annotations.Where;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
 
@@ -45,6 +46,9 @@
     @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
     public static final int BYTES_PER_ELEMENT = 2;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
         @Override
         public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
--- a/src/jdk/nashorn/internal/objects/NativeUint32Array.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeUint32Array.java	Thu Jun 27 13:47:20 2013 +0530
@@ -32,6 +32,7 @@
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
 
@@ -46,6 +47,9 @@
     @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
     public static final int BYTES_PER_ELEMENT = 4;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
         @Override
         public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteBegin, final int length) {
--- a/src/jdk/nashorn/internal/objects/NativeUint8Array.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeUint8Array.java	Thu Jun 27 13:47:20 2013 +0530
@@ -31,6 +31,7 @@
 import jdk.nashorn.internal.objects.annotations.Property;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.objects.annotations.Where;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
 
@@ -45,6 +46,9 @@
     @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
     public static final int BYTES_PER_ELEMENT = 1;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
         @Override
         public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
--- a/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java	Thu Jun 27 13:47:20 2013 +0530
@@ -32,6 +32,7 @@
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
 import jdk.nashorn.internal.objects.annotations.Where;
 import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.PropertyMap;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
 
@@ -46,6 +47,9 @@
     @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
     public static final int BYTES_PER_ELEMENT = 1;
 
+    // initialized by nasgen
+    private static PropertyMap $nasgenmap$;
+
     private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
         @Override
         public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
--- a/src/jdk/nashorn/internal/objects/PrototypeObject.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/PrototypeObject.java	Thu Jun 27 13:47:20 2013 +0530
@@ -44,7 +44,7 @@
  *
  */
 public class PrototypeObject extends ScriptObject {
-    private static final PropertyMap nasgenmap$;
+    private static final PropertyMap map$;
 
     private Object constructor;
 
@@ -54,11 +54,11 @@
     static {
         PropertyMap map = PropertyMap.newMap(PrototypeObject.class);
         map = Lookup.newProperty(map, "constructor", Property.NOT_ENUMERABLE, GET_CONSTRUCTOR, SET_CONSTRUCTOR);
-        nasgenmap$ = map;
+        map$ = map;
     }
 
     PrototypeObject() {
-        this(nasgenmap$);
+        this(map$);
     }
 
     /**
@@ -67,12 +67,12 @@
      * @param map property map
      */
     public PrototypeObject(final PropertyMap map) {
-        super(map != nasgenmap$ ? map.addAll(nasgenmap$) : nasgenmap$);
+        super(map != map$ ? map.addAll(map$) : map$);
         setProto(Global.objectPrototype());
     }
 
     PrototypeObject(final ScriptFunction func) {
-        this();
+        this(map$);
         this.constructor = func;
     }
 
--- a/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java	Thu Jun 27 13:47:20 2013 +0530
@@ -51,7 +51,7 @@
     // property map for bound functions
     private static final PropertyMap boundfunctionmap$;
     // property map for non-strict, non-bound functions.
-    private static final PropertyMap nasgenmap$;
+    private static final PropertyMap map$;
 
     // Marker object for lazily initialized prototype object
     private static final Object LAZY_PROTOTYPE = new Object();
@@ -65,7 +65,7 @@
      * @param specs specialized versions of this method, if available, null otherwise
      */
     ScriptFunctionImpl(final String name, final MethodHandle invokeHandle, final MethodHandle[] specs) {
-        super(name, invokeHandle, nasgenmap$, null, specs, false, true, true);
+        super(name, invokeHandle, map$, null, specs, false, true, true);
         init();
     }
 
@@ -79,7 +79,7 @@
      * @param specs specialized versions of this method, if available, null otherwise
      */
     ScriptFunctionImpl(final String name, final MethodHandle invokeHandle, final PropertyMap map, final MethodHandle[] specs) {
-        super(name, invokeHandle, map.addAll(nasgenmap$), null, specs, false, true, true);
+        super(name, invokeHandle, map.addAll(map$), null, specs, false, true, true);
         init();
     }
 
@@ -124,8 +124,8 @@
         map = Lookup.newProperty(map, "prototype", Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE, G$PROTOTYPE, S$PROTOTYPE);
         map = Lookup.newProperty(map, "length",    Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE | Property.NOT_WRITABLE, G$LENGTH, null);
         map = Lookup.newProperty(map, "name",      Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE | Property.NOT_WRITABLE, G$NAME, null);
-        nasgenmap$ = map;
-        strictmodemap$ = createStrictModeMap(nasgenmap$);
+        map$ = map;
+        strictmodemap$ = createStrictModeMap(map$);
         boundfunctionmap$ = createBoundFunctionMap(strictmodemap$);
     }
 
@@ -149,19 +149,17 @@
         return typeErrorThrower;
     }
 
-    // add a new property that throws TypeError on get as well as set
-    static synchronized PropertyMap newThrowerProperty(final PropertyMap map, final String name) {
-        return map.newProperty(name, Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE, -1,
-                Lookup.TYPE_ERROR_THROWER_GETTER, Lookup.TYPE_ERROR_THROWER_SETTER);
-    }
-
-    private static PropertyMap createStrictModeMap(final PropertyMap functionMap) {
-        return newThrowerProperty(newThrowerProperty(functionMap, "arguments"), "caller");
+    private static PropertyMap createStrictModeMap(PropertyMap map) {
+        final int flags = Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE;
+        // Need to add properties directly to map since slots are assigned speculatively by newUserAccessors.
+        map = map.addProperty(map.newUserAccessors("arguments", flags));
+        map = map.addProperty(map.newUserAccessors("caller", flags));
+        return map;
     }
 
     // Choose the map based on strict mode!
     private static PropertyMap getMap(final boolean strict) {
-        return strict ? strictmodemap$ : nasgenmap$;
+        return strict ? strictmodemap$ : map$;
     }
 
     private static PropertyMap createBoundFunctionMap(final PropertyMap strictModeMap) {
@@ -260,12 +258,15 @@
         this.setProto(Global.instance().getFunctionPrototype());
         this.prototype = LAZY_PROTOTYPE;
 
-        if (isStrict()) {
-            final ScriptFunction func = getTypeErrorThrower();
-            // We have to fill user accessor functions late as these are stored
-            // in this object rather than in the PropertyMap of this object.
-            setUserAccessors("arguments", func, func);
-            setUserAccessors("caller", func, func);
+        // We have to fill user accessor functions late as these are stored
+        // in this object rather than in the PropertyMap of this object.
+
+        if (findProperty("arguments", true) != null) {
+            setUserAccessors("arguments", getTypeErrorThrower(), getTypeErrorThrower());
+        }
+
+        if (findProperty("caller", true) != null) {
+            setUserAccessors("caller", getTypeErrorThrower(), getTypeErrorThrower());
         }
     }
 }
--- a/src/jdk/nashorn/internal/runtime/AccessorProperty.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/AccessorProperty.java	Thu Jun 27 13:47:20 2013 +0530
@@ -288,7 +288,7 @@
     }
 
     @Override
-    protected void setObjectValue(final ScriptObject self, final ScriptObject owner, final Object value, final boolean strict)  {
+    public void setObjectValue(final ScriptObject self, final ScriptObject owner, final Object value, final boolean strict)  {
         if (isSpill()) {
             self.spill[getSlot()] = value;
         } else {
@@ -303,7 +303,7 @@
     }
 
     @Override
-    protected Object getObjectValue(final ScriptObject self, final ScriptObject owner) {
+    public Object getObjectValue(final ScriptObject self, final ScriptObject owner) {
         if (isSpill()) {
             return self.spill[getSlot()];
         }
--- a/src/jdk/nashorn/internal/runtime/Context.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/Context.java	Thu Jun 27 13:47:20 2013 +0530
@@ -101,13 +101,7 @@
     /** Is Context global debug mode enabled ? */
     public static final boolean DEBUG = Options.getBooleanProperty("nashorn.debug");
 
-    private static final ThreadLocal<ScriptObject> currentGlobal =
-        new ThreadLocal<ScriptObject>() {
-            @Override
-            protected ScriptObject initialValue() {
-                 return null;
-            }
-        };
+    private static final ThreadLocal<ScriptObject> currentGlobal = new ThreadLocal<>();
 
     /**
      * Get the current global scope
--- a/src/jdk/nashorn/internal/runtime/ECMAException.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/ECMAException.java	Thu Jun 27 13:47:20 2013 +0530
@@ -51,7 +51,7 @@
     /** Field handle to the{@link ECMAException#thrown} field, so that it can be accessed from generated code */
     public static final FieldAccess THROWN = virtualField(ECMAException.class, "thrown", Object.class);
 
-    private static final String EXCEPTION_PROPERTY = "nashornException";
+    public static final String EXCEPTION_PROPERTY = "nashornException";
 
     /** Object thrown. */
     public final Object thrown;
--- a/src/jdk/nashorn/internal/runtime/FindProperty.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/FindProperty.java	Thu Jun 27 13:47:20 2013 +0530
@@ -89,7 +89,7 @@
         MethodHandle setter = property.getSetter(type, getOwner().getMap());
         if (property instanceof UserAccessorProperty) {
             final UserAccessorProperty uc = (UserAccessorProperty) property;
-            setter = MH.insertArguments(setter, 0, (isInherited() ? getOwner() : null),
+            setter = MH.insertArguments(setter, 0, isInherited() ? getOwner() : null,
                     uc.getSetterSlot(), strict? property.getKey() : null);
         }
 
@@ -109,7 +109,7 @@
      * @return appropriate receiver
      */
     public ScriptObject getGetterReceiver() {
-        return property != null && property.hasGetterFunction() ? self : prototype;
+        return property != null && property.hasGetterFunction(prototype) ? self : prototype;
     }
 
    /**
@@ -117,7 +117,7 @@
      * @return appropriate receiver
      */
     public ScriptObject getSetterReceiver() {
-        return property != null && property.hasSetterFunction() ? self : prototype;
+        return property != null && property.hasSetterFunction(prototype) ? self : prototype;
     }
 
     /**
--- a/src/jdk/nashorn/internal/runtime/FunctionScope.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/FunctionScope.java	Thu Jun 27 13:47:20 2013 +0530
@@ -54,9 +54,8 @@
      * @param arguments   arguments
      */
     public FunctionScope(final PropertyMap map, final ScriptObject callerScope, final Object arguments) {
-        super(map);
+        super(callerScope, map);
         this.arguments = arguments;
-        setProto(callerScope);
         setIsScope();
     }
 
@@ -67,9 +66,8 @@
      * @param callerScope caller scope
      */
     public FunctionScope(final PropertyMap map, final ScriptObject callerScope) {
-        super(map);
+        super(callerScope, map);
         this.arguments = null;
-        setProto(callerScope);
         setIsScope();
     }
 
--- a/src/jdk/nashorn/internal/runtime/Property.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/Property.java	Thu Jun 27 13:47:20 2013 +0530
@@ -180,17 +180,19 @@
 
     /**
      * Check whether this property has a user defined getter function. See {@link UserAccessorProperty}
+     * @param obj object containing getter
      * @return true if getter function exists, false is default
      */
-    public boolean hasGetterFunction() {
+    public boolean hasGetterFunction(final ScriptObject obj) {
         return false;
     }
 
     /**
      * Check whether this property has a user defined setter function. See {@link UserAccessorProperty}
+     * @param obj object containing setter
      * @return true if getter function exists, false is default
      */
-    public boolean hasSetterFunction() {
+    public boolean hasSetterFunction(final ScriptObject obj) {
         return false;
     }
 
@@ -363,7 +365,7 @@
      * @param value the new property value
      * @param strict is this a strict setter?
      */
-    protected abstract void setObjectValue(ScriptObject self, ScriptObject owner, Object value, boolean strict);
+    public abstract void setObjectValue(ScriptObject self, ScriptObject owner, Object value, boolean strict);
 
     /**
      * Set the Object value of this property from {@code owner}. This allows to bypass creation of the
@@ -373,7 +375,7 @@
      * @param owner the owner object
      * @return  the property value
      */
-    protected abstract Object getObjectValue(ScriptObject self, ScriptObject owner);
+    public abstract Object getObjectValue(ScriptObject self, ScriptObject owner);
 
     /**
      * Abstract method for retrieving the setter for the property. We do not know
--- a/src/jdk/nashorn/internal/runtime/PropertyMap.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/PropertyMap.java	Thu Jun 27 13:47:20 2013 +0530
@@ -25,6 +25,8 @@
 
 package jdk.nashorn.internal.runtime;
 
+import jdk.nashorn.internal.scripts.JO;
+
 import static jdk.nashorn.internal.runtime.PropertyHashMap.EMPTY_HASHMAP;
 
 import java.lang.invoke.MethodHandle;
@@ -166,7 +168,7 @@
      */
     public static PropertyMap newMap(final Class<?> structure, final Collection<Property> properties, final int fieldCount, final int fieldMaximum) {
         // Reduce the number of empty maps in the context.
-        if (structure == jdk.nashorn.internal.scripts.JO.class) {
+        if (structure == JO.class) {
             return EMPTY_MAP;
         }
 
@@ -302,7 +304,7 @@
      *
      * @return New {@link PropertyMap} with {@link Property} added.
      */
-    PropertyMap addProperty(final Property property) {
+    public PropertyMap addProperty(final Property property) {
         PropertyMap newMap = checkHistory(property);
 
         if (newMap == null) {
@@ -383,6 +385,21 @@
         return newMap;
     }
 
+    /*
+     * Make a new UserAccessorProperty property. getter and setter functions are stored in
+     * this ScriptObject and slot values are used in property object. Note that slots
+     * are assigned speculatively and should be added to map before adding other
+     * properties.
+     */
+    public UserAccessorProperty newUserAccessors(final String key, final int propertyFlags) {
+        int oldSpillLength = spillLength;
+
+        final int getterSlot = oldSpillLength++;
+        final int setterSlot = oldSpillLength++;
+
+        return new UserAccessorProperty(key, propertyFlags, getterSlot, setterSlot);
+    }
+
     /**
      * Find a property in the map.
      *
--- a/src/jdk/nashorn/internal/runtime/ScriptFunction.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/ScriptFunction.java	Thu Jun 27 13:47:20 2013 +0530
@@ -203,6 +203,16 @@
     }
 
     /**
+     * Execute this script function as a constructor.
+     * @param arguments  Call arguments.
+     * @return Newly constructed result.
+     * @throws Throwable if there is an exception/error with the invocation or thrown from it
+     */
+    Object construct(final Object... arguments) throws Throwable {
+        return data.construct(this, arguments);
+    }
+
+    /**
      * Allocate function. Called from generated {@link ScriptObject} code
      * for allocation as a factory method
      *
--- a/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java	Thu Jun 27 13:47:20 2013 +0530
@@ -216,6 +216,12 @@
         return composeGenericMethod(code.mostGeneric().getInvoker());
     }
 
+    final MethodHandle getGenericConstructor() {
+        ensureCodeGenerated();
+        ensureConstructor(code.mostGeneric());
+        return composeGenericMethod(code.mostGeneric().getConstructor());
+    }
+
     private CompiledFunction getBest(final MethodType callSiteType) {
         ensureCodeGenerated();
         return code.best(callSiteType);
@@ -535,10 +541,74 @@
         }
     }
 
+    Object construct(final ScriptFunction fn, final Object... arguments) throws Throwable {
+        final MethodHandle mh = getGenericConstructor();
+
+        final Object[]     args       = arguments == null ? ScriptRuntime.EMPTY_ARRAY : arguments;
+
+        if (isVarArg(mh)) {
+            if (needsCallee(mh)) {
+                return mh.invokeExact(fn, args);
+            }
+            return mh.invokeExact(args);
+        }
+
+        final int paramCount = mh.type().parameterCount();
+        if (needsCallee(mh)) {
+            switch (paramCount) {
+            case 1:
+                return mh.invokeExact(fn);
+            case 2:
+                return mh.invokeExact(fn, getArg(args, 0));
+            case 3:
+                return mh.invokeExact(fn, getArg(args, 0), getArg(args, 1));
+            case 4:
+                return mh.invokeExact(fn, getArg(args, 0), getArg(args, 1), getArg(args, 2));
+            default:
+                return mh.invokeWithArguments(withArguments(fn, paramCount, args));
+            }
+        }
+
+        switch (paramCount) {
+        case 0:
+            return mh.invokeExact();
+        case 1:
+            return mh.invokeExact(getArg(args, 0));
+        case 2:
+            return mh.invokeExact(getArg(args, 0), getArg(args, 1));
+        case 3:
+            return mh.invokeExact(getArg(args, 0), getArg(args, 1), getArg(args, 2));
+        default:
+            return mh.invokeWithArguments(withArguments(null, paramCount, args));
+        }
+    }
+
     private static Object getArg(final Object[] args, final int i) {
         return i < args.length ? args[i] : UNDEFINED;
     }
 
+    private static Object[] withArguments(final ScriptFunction fn, final int argCount, final Object[] args) {
+        final Object[] finalArgs = new Object[argCount];
+
+        int nextArg = 0;
+        if (fn != null) {
+            //needs callee
+            finalArgs[nextArg++] = fn;
+        }
+
+        // Don't add more args that there is argCount in the handle (including self and callee).
+        for (int i = 0; i < args.length && nextArg < argCount;) {
+            finalArgs[nextArg++] = args[i++];
+        }
+
+        // If we have fewer args than argCount, pad with undefined.
+        while (nextArg < argCount) {
+            finalArgs[nextArg++] = UNDEFINED;
+        }
+
+        return finalArgs;
+    }
+
     private static Object[] withArguments(final ScriptFunction fn, final Object self, final int argCount, final Object[] args) {
         final Object[] finalArgs = new Object[argCount];
 
--- a/src/jdk/nashorn/internal/runtime/ScriptObject.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java	Thu Jun 27 13:47:20 2013 +0530
@@ -170,13 +170,30 @@
         }
 
         this.arrayData = ArrayData.EMPTY_ARRAY;
-
-        if (map == null) {
-            this.setMap(PropertyMap.newMap(getClass()));
-            return;
+        this.setMap(map == null ? PropertyMap.newMap(getClass()) : map);
+    }
+
+    /**
+     * Constructor that directly sets the prototype to {@code proto} and property map to
+     * {@code map} without invalidating the map as calling {@link #setProto(ScriptObject)}
+     * would do. This should only be used for objects that are always constructed with the
+     * same combination of prototype and property map.
+     *
+     * @param proto the prototype object
+     * @param map intial {@link PropertyMap}
+     */
+    protected ScriptObject(final ScriptObject proto, final PropertyMap map) {
+        if (Context.DEBUG) {
+            ScriptObject.count++;
         }
 
-        this.setMap(map);
+        this.arrayData = ArrayData.EMPTY_ARRAY;
+        this.setMap(map == null ? PropertyMap.newMap(getClass()) : map);
+        this.proto = proto;
+
+        if (proto != null) {
+            proto.setIsPrototype();
+        }
     }
 
     /**
@@ -777,30 +794,18 @@
     public final Property modifyOwnProperty(final Property oldProperty, final int propertyFlags, final ScriptFunction getter, final ScriptFunction setter) {
         Property newProperty;
         if (oldProperty instanceof UserAccessorProperty) {
-            // re-use the slots of the old user accessor property.
             final UserAccessorProperty uc = (UserAccessorProperty) oldProperty;
-
-            int getterSlot = uc.getGetterSlot();
-            // clear the old getter and set the new getter
+            final int getterSlot = uc.getGetterSlot();
+            final int setterSlot = uc.getSetterSlot();
             setSpill(getterSlot, getter);
-            // if getter function is null, flag the slot to be negative (less by 1)
-            if (getter == null) {
-                getterSlot = -getterSlot - 1;
-            }
-
-            int setterSlot = uc.getSetterSlot();
-            // clear the old setter and set the new setter
             setSpill(setterSlot, setter);
-            // if setter function is null, flag the slot to be negative (less by 1)
-            if (setter == null) {
-                setterSlot = -setterSlot - 1;
+
+            // if just flipping getter and setter with new functions, no need to change property or map
+            if (uc.flags == propertyFlags) {
+                return oldProperty;
             }
 
             newProperty = new UserAccessorProperty(oldProperty.getKey(), propertyFlags, getterSlot, setterSlot);
-            // if just flipping getter and setter with new functions, no need to change property or map
-            if (oldProperty.equals(newProperty)) {
-                return oldProperty;
-            }
         } else {
             // erase old property value and create new user accessor property
             erasePropertyValue(oldProperty);
@@ -862,12 +867,10 @@
      */
     public final void setUserAccessors(final String key, final ScriptFunction getter, final ScriptFunction setter) {
         final Property oldProperty = getMap().findProperty(key);
-        if (oldProperty != null) {
-            final UserAccessorProperty newProperty = newUserAccessors(oldProperty.getKey(), oldProperty.getFlags(), getter, setter);
-            modifyOwnProperty(oldProperty, newProperty);
+        if (oldProperty instanceof UserAccessorProperty) {
+            modifyOwnProperty(oldProperty, oldProperty.getFlags(), getter, setter);
         } else {
-            final UserAccessorProperty newProperty = newUserAccessors(key, 0, getter, setter);
-            addOwnProperty(newProperty);
+            addOwnProperty(newUserAccessors(key, oldProperty != null ? oldProperty.getFlags() : 0, getter, setter));
         }
     }
 
@@ -1712,7 +1715,7 @@
 
             final ScriptObject prototype = find.getOwner();
 
-            if (!property.hasGetterFunction()) {
+            if (!property.hasGetterFunction(prototype)) {
                 methodHandle = bindTo(methodHandle, prototype);
             }
             return new GuardedInvocation(methodHandle, getMap().getProtoGetSwitchPoint(proto, name), guard);
@@ -3144,49 +3147,30 @@
      * Make a new UserAccessorProperty property. getter and setter functions are stored in
      * this ScriptObject and slot values are used in property object.
      */
-    private UserAccessorProperty newUserAccessors(final String key, final int propertyFlags, final ScriptFunction getter, final ScriptFunction setter) {
-        int oldSpillLength = getMap().getSpillLength();
-
-        int getterSlot = oldSpillLength++;
-        setSpill(getterSlot, getter);
-        // if getter function is null, flag the slot to be negative (less by 1)
-        if (getter == null) {
-            getterSlot = -getterSlot - 1;
-        }
-
-        int setterSlot = oldSpillLength++;
-
-        setSpill(setterSlot, setter);
-        // if setter function is null, flag the slot to be negative (less by 1)
-        if (setter == null) {
-            setterSlot = -setterSlot - 1;
-        }
-
-        return new UserAccessorProperty(key, propertyFlags, getterSlot, setterSlot);
+    protected final UserAccessorProperty newUserAccessors(final String key, final int propertyFlags, final ScriptFunction getter, final ScriptFunction setter) {
+        final UserAccessorProperty property = getMap().newUserAccessors(key, propertyFlags);
+        setSpill(property.getGetterSlot(), getter);
+        setSpill(property.getSetterSlot(), setter);
+
+        return property;
     }
 
-    private void setSpill(final int slot, final Object value) {
-        if (slot >= 0) {
-            final int index = slot;
-            if (spill == null) {
-                // create new spill.
-                spill = new Object[Math.max(index + 1, SPILL_RATE)];
-            } else if (index >= spill.length) {
-                // grow spill as needed
-                final Object[] newSpill = new Object[index + 1];
-                System.arraycopy(spill, 0, newSpill, 0, spill.length);
-                spill = newSpill;
-            }
-
-            spill[index] = value;
+    protected final void setSpill(final int slot, final Object value) {
+        if (spill == null) {
+            // create new spill.
+            spill = new Object[Math.max(slot + 1, SPILL_RATE)];
+        } else if (slot >= spill.length) {
+            // grow spill as needed
+            final Object[] newSpill = new Object[slot + 1];
+            System.arraycopy(spill, 0, newSpill, 0, spill.length);
+            spill = newSpill;
         }
+
+        spill[slot] = value;
     }
 
-    // user accessors are either stored in spill array slots
-    // get the accessor value using slot number. Note that slot is spill array index.
-    Object getSpill(final int slot) {
-        final int index = slot;
-        return (index < 0 || (index >= spill.length)) ? null : spill[index];
+    protected Object getSpill(final int slot) {
+        return spill != null && slot < spill.length ? spill[slot] : null;
     }
 
     private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
--- a/src/jdk/nashorn/internal/runtime/ScriptRuntime.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/ScriptRuntime.java	Thu Jun 27 13:47:20 2013 +0530
@@ -361,6 +361,47 @@
     }
 
     /**
+     * Check that the target function is associated with current Context.
+     * And also make sure that 'self', if ScriptObject, is from current context.
+     *
+     * Call a function as a constructor given args.
+     *
+     * @param target ScriptFunction object.
+     * @param args   Call arguments.
+     * @return Constructor call result.
+     */
+    public static Object checkAndConstruct(final ScriptFunction target, final Object... args) {
+        final ScriptObject global = Context.getGlobalTrusted();
+        if (! (global instanceof GlobalObject)) {
+            throw new IllegalStateException("No current global set");
+        }
+
+        if (target.getContext() != global.getContext()) {
+            throw new IllegalArgumentException("'target' function is not from current Context");
+        }
+
+        // all in order - call real 'construct'
+        return construct(target, args);
+    }
+
+    /*
+     * Call a script function as a constructor with given args.
+     *
+     * @param target ScriptFunction object.
+     * @param args   Call arguments.
+     * @return Constructor call result.
+     */
+    public static Object construct(final ScriptFunction target, final Object... args) {
+        try {
+            return target.construct(args);
+        } catch (final RuntimeException | Error e) {
+            throw e;
+        } catch (final Throwable t) {
+            throw new RuntimeException(t);
+        }
+    }
+
+    /**
      * Generic implementation of ECMA 9.12 - SameValue algorithm
      *
      * @param x first value to compare
--- a/src/jdk/nashorn/internal/runtime/SetMethodCreator.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/SetMethodCreator.java	Thu Jun 27 13:47:20 2013 +0530
@@ -151,9 +151,10 @@
         assert methodHandle != null;
         assert property     != null;
 
+        final ScriptObject prototype = find.getOwner();
         final MethodHandle boundHandle;
-        if (!property.hasSetterFunction() && find.isInherited()) {
-            boundHandle = ScriptObject.bindTo(methodHandle, find.getOwner());
+        if (!property.hasSetterFunction(prototype) && find.isInherited()) {
+            boundHandle = ScriptObject.bindTo(methodHandle, prototype);
         } else {
             boundHandle = methodHandle;
         }
--- a/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java	Thu Jun 27 13:47:20 2013 +0530
@@ -96,19 +96,19 @@
     }
 
     /**
-     * Return getter slot for this UserAccessorProperty. Slots start with first embed field.
+     * Return getter spill slot for this UserAccessorProperty.
      * @return getter slot
      */
     public int getGetterSlot() {
-        return getterSlot < 0 ? -getterSlot - 1 : getterSlot;
+        return getterSlot;
     }
 
     /**
-     * Return setter slot for this UserAccessorProperty. Slots start with first embed field.
+     * Return setter spill slot for this UserAccessorProperty.
      * @return setter slot
      */
     public int getSetterSlot() {
-        return setterSlot < 0 ? -setterSlot - 1 : setterSlot;
+        return setterSlot;
     }
 
     @Override
@@ -124,7 +124,7 @@
 
         final UserAccessorProperty uc = (UserAccessorProperty) other;
         return getterSlot == uc.getterSlot && setterSlot == uc.setterSlot;
-     }
+    }
 
     @Override
     public int hashCode() {
@@ -136,34 +136,26 @@
      */
     @Override
     public int getSpillCount() {
-        // calculate how many spill array slots used by this propery.
-        int count = 0;
-        if (getGetterSlot() >= 0) {
-            count++;
-        }
-        if (getSetterSlot() >= 0) {
-            count++;
-        }
-        return count;
+        return 2;
     }
 
     @Override
-    public boolean hasGetterFunction() {
-        return getterSlot > -1;
+    public boolean hasGetterFunction(final ScriptObject obj) {
+        return obj.getSpill(getterSlot) != null;
     }
 
     @Override
-    public boolean hasSetterFunction() {
-        return setterSlot > -1;
+    public boolean hasSetterFunction(final ScriptObject obj) {
+        return obj.getSpill(setterSlot) != null;
     }
 
     @Override
-    protected Object getObjectValue(final ScriptObject self, final ScriptObject owner) {
+    public Object getObjectValue(final ScriptObject self, final ScriptObject owner) {
         return userAccessorGetter(owner, getGetterSlot(), self);
     }
 
     @Override
-    protected void setObjectValue(final ScriptObject self, final ScriptObject owner, final Object value, final boolean strict) {
+    public void setObjectValue(final ScriptObject self, final ScriptObject owner, final Object value, final boolean strict) {
         userAccessorSetter(owner, getSetterSlot(), strict ? getKey() : null, self, value);
     }
 
--- a/src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java	Thu Jun 27 13:47:20 2013 +0530
@@ -45,44 +45,14 @@
  * as ScriptObjects from other Nashorn contexts.
  */
 final class JSObjectLinker implements TypeBasedGuardingDynamicLinker {
-   /**
-     * Instances of this class are used to represent a method member of a JSObject
-     */
-    private static final class JSObjectMethod {
-        // The name of the JSObject method property
-        private final String name;
-
-        JSObjectMethod(final String name) {
-            this.name = name;
-        }
-
-        String getName() {
-            return name;
-        }
-
-        static GuardedInvocation lookup(final CallSiteDescriptor desc) {
-            final String operator = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0);
-            switch (operator) {
-                case "call": {
-                    // collect everything except the first two - JSObjectMethod instance and the actual 'self'
-                    final int paramCount = desc.getMethodType().parameterCount();
-                    final MethodHandle caller = MH.asCollector(JSOBJECTMETHOD_CALL, Object[].class, paramCount - 2);
-                    return new GuardedInvocation(caller, null, IS_JSOBJECTMETHOD_GUARD);
-                }
-                default:
-                    return null;
-            }
-        }
-    }
-
     @Override
     public boolean canLinkType(final Class<?> type) {
         return canLinkTypeStatic(type);
     }
 
     static boolean canLinkTypeStatic(final Class<?> type) {
-        // can link JSObject and JSObjectMethod
-        return JSObject.class.isAssignableFrom(type) || JSObjectMethod.class.isAssignableFrom(type);
+        // can link JSObject
+        return JSObject.class.isAssignableFrom(type);
     }
 
     @Override
@@ -99,8 +69,6 @@
         final GuardedInvocation inv;
         if (self instanceof JSObject) {
             inv = lookup(desc);
-        } else if (self instanceof JSObjectMethod) {
-            inv = JSObjectMethod.lookup(desc);
         } else {
             throw new AssertionError(); // Should never reach here.
         }
@@ -115,7 +83,7 @@
             case "getProp":
             case "getElem":
             case "getMethod":
-                return c > 2 ? findGetMethod(desc, operator) : findGetIndexMethod();
+                return c > 2 ? findGetMethod(desc) : findGetIndexMethod();
             case "setProp":
             case "setElem":
                 return c > 2 ? findSetMethod(desc) : findSetIndexMethod();
@@ -123,15 +91,14 @@
             case "callMethod":
                 return findCallMethod(desc, operator);
             case "new":
+                return findNewMethod(desc);
             default:
                 return null;
         }
     }
 
-    private static GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final String operator) {
-        // if "getMethod" then return JSObjectMethod object - which just holds the name of the method
-        // subsequently, link on dyn:call for JSObjectMethod will actually call that method
-        final MethodHandle getter = MH.insertArguments("getMethod".equals(operator)? JSOBJECT_GETMETHOD : JSOBJECT_GET, 1, desc.getNameToken(2));
+    private static GuardedInvocation findGetMethod(final CallSiteDescriptor desc) {
+        final MethodHandle getter = MH.insertArguments(JSOBJECT_GET, 1, desc.getNameToken(2));
         return new GuardedInvocation(getter, null, IS_JSOBJECT_GUARD);
     }
 
@@ -156,9 +123,9 @@
         return new GuardedInvocation(func, null, IS_JSOBJECT_GUARD);
     }
 
-    @SuppressWarnings("unused")
-    private static boolean isJSObjectMethod(final Object self) {
-        return self instanceof JSObjectMethod;
+    private static GuardedInvocation findNewMethod(final CallSiteDescriptor desc) {
+        MethodHandle func = MH.asCollector(JSOBJECT_NEW, Object[].class, desc.getMethodType().parameterCount() - 1);
+        return new GuardedInvocation(func, null, IS_JSOBJECT_GUARD);
     }
 
     @SuppressWarnings("unused")
@@ -166,12 +133,6 @@
         return self instanceof JSObject;
     }
 
-
-    @SuppressWarnings("unused")
-    private static Object getMethod(final Object jsobj, final Object key) {
-        return new JSObjectMethod(Objects.toString(key));
-    }
-
     @SuppressWarnings("unused")
     private static Object get(final Object jsobj, final Object key) {
         if (key instanceof String) {
@@ -200,11 +161,8 @@
     }
 
     @SuppressWarnings("unused")
-    private static Object jsObjectMethodCall(final Object jsObjMethod, final Object jsobj, final Object... args) {
-        // we have JSObjectMethod, JSObject and args. Get method name from JSObjectMethod instance
-        final String methodName = ((JSObjectMethod)jsObjMethod).getName();
-        // call the method on JSObject
-        return ((JSObject)jsobj).call(methodName, args);
+    private static Object newObject(final Object jsobj, final Object... args) {
+        return ((JSObject)jsobj).newObject(null, args);
     }
 
     private static int getIndex(final Number n) {
@@ -214,13 +172,11 @@
 
     private static final MethodHandleFunctionality MH = MethodHandleFactory.getFunctionality();
 
-    private static final MethodHandle IS_JSOBJECTMETHOD_GUARD = findOwnMH("isJSObjectMethod", boolean.class, Object.class);
     private static final MethodHandle IS_JSOBJECT_GUARD = findOwnMH("isJSObject", boolean.class, Object.class);
-    private static final MethodHandle JSOBJECT_GETMETHOD = findOwnMH("getMethod", Object.class, Object.class, Object.class);
     private static final MethodHandle JSOBJECT_GET = findOwnMH("get", Object.class, Object.class, Object.class);
     private static final MethodHandle JSOBJECT_PUT = findOwnMH("put", Void.TYPE, Object.class, Object.class, Object.class);
     private static final MethodHandle JSOBJECT_CALL = findOwnMH("call", Object.class, Object.class, Object.class, Object[].class);
-    private static final MethodHandle JSOBJECTMETHOD_CALL = findOwnMH("jsObjectMethodCall", Object.class, Object.class, Object.class, Object[].class);
+    private static final MethodHandle JSOBJECT_NEW = findOwnMH("newObject", Object.class, Object.class, Object[].class);
 
     private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
         final Class<?>   own = JSObjectLinker.class;
--- a/src/jdk/nashorn/internal/scripts/JO.java	Fri Jun 21 17:33:05 2013 +0530
+++ b/src/jdk/nashorn/internal/scripts/JO.java	Thu Jun 27 13:47:20 2013 +0530
@@ -32,11 +32,14 @@
  * Empty object class.
  */
 public class JO extends ScriptObject {
+
+    private static final PropertyMap map$ = PropertyMap.newMap(JO.class);
+
     /**
      * Constructor
      */
     public JO() {
-        super(PropertyMap.newMap(JO.class));
+        super(map$);
     }
 
     /**
@@ -49,6 +52,15 @@
     }
 
     /**
+     * Constructor given an initial prototype using the default property map
+     *
+     * @param proto the prototype object
+     */
+    public JO(final ScriptObject proto) {
+        super(proto, map$);
+    }
+
+    /**
      * Used by FunctionObjectCreator. A method handle of this method is passed to the ScriptFunction constructor.
      *
      * @param map  the property map to use for allocatorMap
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8010732.js	Thu Jun 27 13:47:20 2013 +0530
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8010732: BigDecimal, BigInteger and Long handling in nashorn
+ *
+ * @test
+ * @run
+ */
+
+var x = new java.math.BigDecimal(1111.5);
+var y = new java.math.BigDecimal(2222.5);
+
+print(x);
+print(y);
+
+print(x + y);
+print(x - y);
+print(x * y);
+print(x / y);
+print(Math.sin(x));
+
+print(x.toString());
+print(y.toString());
+print(x.class);
+print(y.class);
+print(x.doubleValue() + y.doubleValue());
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8010732.js.EXPECTED	Thu Jun 27 13:47:20 2013 +0530
@@ -0,0 +1,12 @@
+1111.5
+2222.5
+3334
+-1111
+2470308.75
+0.5001124859392576
+-0.5841231854504038
+1111.5
+2222.5
+class java.math.BigDecimal
+class java.math.BigDecimal
+3334
--- a/test/script/basic/JDK-8012164.js	Fri Jun 21 17:33:05 2013 +0530
+++ b/test/script/basic/JDK-8012164.js	Thu Jun 27 13:47:20 2013 +0530
@@ -37,8 +37,9 @@
   try {
       throw new Error('foo');
   } catch (e) {
-      for (i in e.stack) {
-          printFrame(e.stack[i]);
+      var frames = e.getStackTrace();
+      for (i in frames) {
+          printFrame(frames[i]);
       }
   }
 }
--- a/test/script/basic/JDK-8012164.js.EXPECTED	Fri Jun 21 17:33:05 2013 +0530
+++ b/test/script/basic/JDK-8012164.js.EXPECTED	Thu Jun 27 13:47:20 2013 +0530
@@ -1,3 +1,3 @@
 <test/script/basic/JDK-8012164.js>.error(test/script/basic/JDK-8012164.js:38)
 <test/script/basic/JDK-8012164.js>.func(test/script/basic/JDK-8012164.js:33)
-<test/script/basic/JDK-8012164.js>.<program>(test/script/basic/JDK-8012164.js:46)
+<test/script/basic/JDK-8012164.js>.<program>(test/script/basic/JDK-8012164.js:47)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8014781.js	Thu Jun 27 13:47:20 2013 +0530
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8014781: support Error.captureStackTrace
+ *
+ * @test
+ * @run
+ */
+
+function MyError() {
+    Error.captureStackTrace(this);
+}
+
+function func() {
+    return new MyError();
+}
+
+var e = func();
+print(e.stack.replace(/\\/g, '/'));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8014781.js.EXPECTED	Thu Jun 27 13:47:20 2013 +0530
@@ -0,0 +1,3 @@
+MyError @ test/script/basic/JDK-8014781.js:32
+func @ test/script/basic/JDK-8014781.js:36
+<program> @ test/script/basic/JDK-8014781.js:39
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8015959.js	Thu Jun 27 13:47:20 2013 +0530
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8015959: Can't call foreign constructor
+ *
+ * @test
+ * @run
+ */
+
+function check(global) {
+    var obj = new global.Point(344, 12);
+    print("obj.x " + obj.x);
+    print("obj.y " + obj.y);
+    print("obj instanceof global.Point? " + (obj instanceof global.Point))
+
+    var P = global.Point;
+    var p = new P(343, 54);
+    print("p.x " + p.x);
+    print("p.y " + p.y);
+    print("p instanceof P? " + (p instanceof P))
+}
+
+print("check with loadWithNewGlobal");
+check(loadWithNewGlobal({
+   name: "myscript",
+   script: "function Point(x, y) { this.x = x; this.y = y }; this"
+}));
+
+print("check with script engine");
+var m = new javax.script.ScriptEngineManager();
+var e = m.getEngineByName('nashorn');
+check(e.eval("function Point(x, y) { this.x = x; this.y = y }; this"));
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8015959.js.EXPECTED	Thu Jun 27 13:47:20 2013 +0530
@@ -0,0 +1,14 @@
+check with loadWithNewGlobal
+obj.x 344
+obj.y 12
+obj instanceof global.Point? true
+p.x 343
+p.y 54
+p instanceof P? true
+check with script engine
+obj.x 344
+obj.y 12
+obj instanceof global.Point? true
+p.x 343
+p.y 54
+p instanceof P? true
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8015969.js	Thu Jun 27 13:47:20 2013 +0530
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223
+ *
+ * @test
+ * @option -scripting
+ * @run
+ */
+
+var m = new javax.script.ScriptEngineManager();
+var e = m.getEngineByName("nashorn");
+
+e.eval(<<EOF
+
+'use strict';
+
+try {
+    context = 444;
+    print("FAILED!! context write should have thrown error");
+} catch (e) {
+    if (! (e instanceof TypeError)) {
+        print("TypeError expected but got " + e);
+    }
+}
+
+try {
+    engine = "hello";
+    print("FAILED!! engine write should have thrown error");
+} catch (e) {
+    if (! (e instanceof TypeError)) {
+        print("TypeError expected but got " + e);
+    }
+}
+
+try {
+    delete context;
+    print("FAILED!! context delete should have thrown error");
+} catch (e) {
+    if (! (e instanceof SyntaxError)) {
+        print("SyntaxError expected but got " + e);
+    }
+}
+
+try {
+    delete engine;
+    print("FAILED!! engine delete should have thrown error");
+} catch (e) {
+    if (! (e instanceof SyntaxError)) {
+        print("SyntaxError expected but got " + e);
+    }
+}
+
+EOF);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8017950.js	Thu Jun 27 13:47:20 2013 +0530
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8017950: error.stack should be a string rather than an array
+ *
+ * @test
+ * @run
+ */
+
+function func() {
+    try {
+        throw new Error();
+    } catch (e){
+        print(e.stack.replace(/\\/g, '/'))
+    }
+}
+
+function f() { 
+    func()
+}
+
+function g() {
+    f()
+}
+
+g()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8017950.js.EXPECTED	Thu Jun 27 13:47:20 2013 +0530
@@ -0,0 +1,4 @@
+func @ test/script/basic/JDK-8017950.js:33
+f @ test/script/basic/JDK-8017950.js:40
+g @ test/script/basic/JDK-8017950.js:44
+<program> @ test/script/basic/JDK-8017950.js:47
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8019226.js	Thu Jun 27 13:47:20 2013 +0530
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8019226: line number not generated for first statement if it is on the same function declaration line 
+ *
+ * @test
+ * @run
+ */
+
+function func1() { func2() }
+
+function func2() { throw new Error() }
+
+try {
+    func1()
+} catch (e) {
+    print(e.stack.replace(/\\/g, '/'))
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8019226.js.EXPECTED	Thu Jun 27 13:47:20 2013 +0530
@@ -0,0 +1,3 @@
+func2 @ test/script/basic/JDK-8019226.js:33
+func1 @ test/script/basic/JDK-8019226.js:31
+<program> @ test/script/basic/JDK-8019226.js:36
--- a/test/script/basic/NASHORN-109.js	Fri Jun 21 17:33:05 2013 +0530
+++ b/test/script/basic/NASHORN-109.js	Thu Jun 27 13:47:20 2013 +0530
@@ -33,8 +33,9 @@
         throw new Error("error");
     }
 } catch (e) {
-    for (i in e.stack) { 
-        print(e.stack[i].methodName + ' ' + e.stack[i].lineNumber);
+    var frames = e.getStackTrace();
+    for (i in frames) {
+        print(frames[i].methodName + ' ' + frames[i].lineNumber);
     }
 }
 
--- a/test/script/basic/NASHORN-296.js	Fri Jun 21 17:33:05 2013 +0530
+++ b/test/script/basic/NASHORN-296.js	Thu Jun 27 13:47:20 2013 +0530
@@ -33,7 +33,7 @@
         load({ script: 'throw new Error()', name: name });
     } catch(e) {
         // normalize windows path separator to URL style
-        var actual = e.stack[0].fileName;
+        var actual = e.getStackTrace()[0].fileName;
         if (actual !== name) {
             fail("expected file name to be " + name +
                  ", actually got file name " + actual);
@@ -48,6 +48,6 @@
 try {
     throw new Error();
 } catch (e) {
-    test(e.stack[0].fileName.substring(6));
+    test(e.getStackTrace()[0].fileName.substring(6));
 }
 
--- a/test/script/basic/errorstack.js	Fri Jun 21 17:33:05 2013 +0530
+++ b/test/script/basic/errorstack.js	Thu Jun 27 13:47:20 2013 +0530
@@ -22,7 +22,7 @@
  */
 
 /**
- * "stack" property of Error objects. (nashorn extension).
+ * "getStackTrace()" method of Error objects. (nashorn extension).
  *
  * @test
  * @run
@@ -43,9 +43,9 @@
 try {
     func1();
 } catch (e) {
-    // "stack" is java.lang.StackTraceElement object
-    for (i in e.stack) {
-        print(e.stack[i].methodName + " : " + e.stack[i].lineNumber);
+    var frames = e.getStackTrace();
+    for (i in frames) {
+        print(frames[i].methodName + " : " + frames[i].lineNumber);
     }
 }