8019157: Avoid calling ScriptObject.setProto() if possible
Reviewed-by: jlaskey, sundar
--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInstrumentor.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInstrumentor.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/codegen/ClassEmitter.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/codegen/ClassEmitter.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java Wed Jun 26 15:40:52 2013 +0200
@@ -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) {
--- a/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/AccessorPropertyDescriptor.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/AccessorPropertyDescriptor.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/ArrayBufferView.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/ArrayBufferView.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/DataPropertyDescriptor.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/DataPropertyDescriptor.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/Global.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/Global.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeArguments.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeArguments.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeArray.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeArray.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeBoolean.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeBoolean.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeError.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeError.java Wed Jun 26 15:40:52 2013 +0200
@@ -43,6 +43,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 +87,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 {
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeEvalError.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeEvalError.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeFloat32Array.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeFloat32Array.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeFloat64Array.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeFloat64Array.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeFunction.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeFunction.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeInt16Array.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeInt16Array.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeInt32Array.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeInt32Array.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeInt8Array.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeInt8Array.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeJSAdapter.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeJSAdapter.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeJSON.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeJSON.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeJava.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeJava.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeJavaImporter.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeJavaImporter.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeMath.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeMath.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeNumber.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeNumber.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeRangeError.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeRangeError.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeReferenceError.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeReferenceError.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeRegExp.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeRegExp.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeRegExpExecResult.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeRegExpExecResult.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeStrictArguments.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeStrictArguments.java Wed Jun 26 15:40:52 2013 +0200
@@ -51,7 +51,7 @@
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);
@@ -61,14 +61,14 @@
final int flags = Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE;
map = map.addProperty(map.newUserAccessors("caller", flags));
map = map.addProperty(map.newUserAccessors("callee", flags));
- nasgenmap$ = map;
+ 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();
@@ -86,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/nashorn/src/jdk/nashorn/internal/objects/NativeString.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeString.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeSyntaxError.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeSyntaxError.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeTypeError.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeTypeError.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeURIError.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeURIError.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeUint16Array.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeUint16Array.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeUint32Array.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeUint32Array.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeUint8Array.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeUint8Array.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/PrototypeObject.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/PrototypeObject.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java Wed Jun 26 15:40:52 2013 +0200
@@ -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$);
}
@@ -165,7 +165,7 @@
// 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) {
--- a/nashorn/src/jdk/nashorn/internal/runtime/Context.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/Context.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/runtime/FunctionScope.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/FunctionScope.java Wed Jun 26 15:40:52 2013 +0200
@@ -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/nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java Wed Jun 26 15:40:52 2013 +0200
@@ -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;
}
--- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java Wed Jun 26 15:40:52 2013 +0200
@@ -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();
+ }
}
/**
--- a/nashorn/src/jdk/nashorn/internal/scripts/JO.java Wed Jun 26 08:36:53 2013 -0300
+++ b/nashorn/src/jdk/nashorn/internal/scripts/JO.java Wed Jun 26 15:40:52 2013 +0200
@@ -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