8019157: Avoid calling ScriptObject.setProto() if possible

Reviewed-by: jlaskey, sundar
This commit is contained in:
Hannes Wallnöfer 2013-06-26 15:40:52 +02:00
parent e628bb4979
commit 70383eb20a
52 changed files with 275 additions and 94 deletions

View File

@ -166,11 +166,11 @@ public class ClassGenerator {
mi.putStatic(className, MAP_FIELD_NAME, MAP_DESC); mi.putStatic(className, MAP_FIELD_NAME, MAP_DESC);
mi.loadClass(className); mi.loadClass(className);
mi.invokeStatic(MAP_TYPE, MAP_NEWMAP, MAP_NEWMAP_DESC); mi.invokeStatic(MAP_TYPE, MAP_NEWMAP, MAP_NEWMAP_DESC);
mi.storeLocal(0); // stack: PropertyMap
} }
static void emitStaticInitSuffix(final MethodGenerator mi, final String className) { static void emitStaticInitSuffix(final MethodGenerator mi, final String className) {
mi.loadLocal(0); // stack: PropertyMap
mi.putStatic(className, MAP_FIELD_NAME, MAP_DESC); mi.putStatic(className, MAP_FIELD_NAME, MAP_DESC);
mi.returnVoid(); mi.returnVoid();
mi.computeMaxs(); mi.computeMaxs();
@ -278,7 +278,7 @@ public class ClassGenerator {
static void linkerAddGetterSetter(final MethodGenerator mi, final String className, final MemberInfo memInfo) { static void linkerAddGetterSetter(final MethodGenerator mi, final String className, final MemberInfo memInfo) {
final String propertyName = memInfo.getName(); final String propertyName = memInfo.getName();
mi.loadLocal(0); // stack: PropertyMap
mi.loadLiteral(propertyName); mi.loadLiteral(propertyName);
// setup flags // setup flags
mi.push(memInfo.getAttributes()); mi.push(memInfo.getAttributes());
@ -293,12 +293,12 @@ public class ClassGenerator {
mi.visitLdcInsn(new Handle(H_INVOKEVIRTUAL, className, javaName, setterDesc(memInfo))); mi.visitLdcInsn(new Handle(H_INVOKEVIRTUAL, className, javaName, setterDesc(memInfo)));
} }
mi.invokeStatic(LOOKUP_TYPE, LOOKUP_NEWPROPERTY, LOOKUP_NEWPROPERTY_DESC); 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) { static void linkerAddGetterSetter(final MethodGenerator mi, final String className, final MemberInfo getter, final MemberInfo setter) {
final String propertyName = getter.getName(); final String propertyName = getter.getName();
mi.loadLocal(0); // stack: PropertyMap
mi.loadLiteral(propertyName); mi.loadLiteral(propertyName);
// setup flags // setup flags
mi.push(getter.getAttributes()); mi.push(getter.getAttributes());
@ -313,7 +313,7 @@ public class ClassGenerator {
setter.getJavaName(), setter.getJavaDesc())); setter.getJavaName(), setter.getJavaDesc()));
} }
mi.invokeStatic(LOOKUP_TYPE, LOOKUP_NEWPROPERTY, LOOKUP_NEWPROPERTY_DESC); mi.invokeStatic(LOOKUP_TYPE, LOOKUP_NEWPROPERTY, LOOKUP_NEWPROPERTY_DESC);
mi.storeLocal(0); // stack: PropertyMap
} }
static ScriptClassInfo getScriptClassInfo(final String fileName) throws IOException { static ScriptClassInfo getScriptClassInfo(final String fileName) throws IOException {

View File

@ -159,10 +159,14 @@ public class ScriptClassInstrumentor extends ClassVisitor {
public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc) { public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc) {
if (isConstructor && opcode == INVOKESPECIAL && if (isConstructor && opcode == INVOKESPECIAL &&
INIT.equals(name) && SCRIPTOBJECT_TYPE.equals(owner)) { INIT.equals(name) && SCRIPTOBJECT_TYPE.equals(owner)) {
super.visitFieldInsn(GETSTATIC, scriptClassInfo.getJavaName(),
MAP_FIELD_NAME, MAP_DESC); // replace call to empty super-constructor with one passing PropertyMap argument
super.visitMethodInsn(INVOKESPECIAL, SCRIPTOBJECT_TYPE, INIT, if (DEFAULT_INIT_DESC.equals(desc)) {
SCRIPTOBJECT_INIT_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) { if (memberCount > 0) {
// initialize @Property fields if needed // initialize @Property fields if needed
@ -223,7 +227,7 @@ public class ScriptClassInstrumentor extends ClassVisitor {
ClassGenerator.addSetter(cv, className, memInfo); ClassGenerator.addSetter(cv, className, memInfo);
} }
} }
ClassGenerator.addMapField(this); // omit addMapField() since instance classes already define a static PropertyMap field
} }
void emitGettersSetters() { void emitGettersSetters() {

View File

@ -165,7 +165,8 @@ public class ClassEmitter implements Emitter {
/** /**
* Constructor from the compiler * Constructor from the compiler
* *
* @param compiler Compiler * @param env Script environment
* @param sourceName Source name
* @param unitClassName Compile unit class name. * @param unitClassName Compile unit class name.
* @param strictMode Should we generate this method in strict mode * @param strictMode Should we generate this method in strict mode
*/ */

View File

@ -244,7 +244,7 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
/** /**
* Check if this symbol can be accessed directly with a putfield or getfield or dynamic load * 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 * @return true if fast scope
*/ */
private boolean isFastScope(final Symbol symbol) { private boolean isFastScope(final Symbol symbol) {

View File

@ -245,9 +245,9 @@ public final class Compiler {
/** /**
* Constructor * Constructor
* *
* @param env script environment
* @param installer code installer * @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 * @param strict should this compilation use strict mode semantics
*/ */
//TODO support an array of FunctionNodes for batch lazy compilation //TODO support an array of FunctionNodes for batch lazy compilation

View File

@ -34,6 +34,7 @@ import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyDescriptor; import jdk.nashorn.internal.runtime.PropertyDescriptor;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.ScriptFunction;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.ScriptRuntime; import jdk.nashorn.internal.runtime.ScriptRuntime;
@ -63,16 +64,19 @@ public final class AccessorPropertyDescriptor extends ScriptObject implements Pr
@Property @Property
public Object set; public Object set;
// initialized by nasgen
private static PropertyMap $nasgenmap$;
AccessorPropertyDescriptor() { AccessorPropertyDescriptor() {
this(false, false, UNDEFINED, UNDEFINED); this(false, false, UNDEFINED, UNDEFINED);
} }
AccessorPropertyDescriptor(final boolean configurable, final boolean enumerable, final Object get, final Object set) { AccessorPropertyDescriptor(final boolean configurable, final boolean enumerable, final Object get, final Object set) {
super(Global.objectPrototype(), $nasgenmap$);
this.configurable = configurable; this.configurable = configurable;
this.enumerable = enumerable; this.enumerable = enumerable;
this.get = get; this.get = get;
this.set = set; this.set = set;
setProto(Global.objectPrototype());
} }
@Override @Override

View File

@ -29,6 +29,7 @@ import jdk.nashorn.internal.objects.annotations.Attribute;
import jdk.nashorn.internal.objects.annotations.Getter; import jdk.nashorn.internal.objects.annotations.Getter;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.ScriptRuntime; import jdk.nashorn.internal.runtime.ScriptRuntime;
import jdk.nashorn.internal.runtime.arrays.ArrayData; import jdk.nashorn.internal.runtime.arrays.ArrayData;
@ -38,6 +39,9 @@ import static jdk.nashorn.internal.runtime.ECMAErrors.rangeError;
@ScriptClass("ArrayBufferView") @ScriptClass("ArrayBufferView")
abstract class ArrayBufferView extends ScriptObject { abstract class ArrayBufferView extends ScriptObject {
// initialized by nasgen
private static PropertyMap $nasgenmap$;
ArrayBufferView(final NativeArrayBuffer buffer, final int byteOffset, final int elementLength) { ArrayBufferView(final NativeArrayBuffer buffer, final int byteOffset, final int elementLength) {
checkConstructorArgs(buffer, byteOffset, elementLength); checkConstructorArgs(buffer, byteOffset, elementLength);
this.setProto(getPrototype()); this.setProto(getPrototype());

View File

@ -33,6 +33,7 @@ import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyDescriptor; import jdk.nashorn.internal.runtime.PropertyDescriptor;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.ScriptFunction;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
@ -61,16 +62,19 @@ public final class DataPropertyDescriptor extends ScriptObject implements Proper
@Property @Property
public Object value; public Object value;
// initialized by nasgen
private static PropertyMap $nasgenmap$;
DataPropertyDescriptor() { DataPropertyDescriptor() {
this(false, false, false, UNDEFINED); this(false, false, false, UNDEFINED);
} }
DataPropertyDescriptor(final boolean configurable, final boolean enumerable, final boolean writable, final Object value) { DataPropertyDescriptor(final boolean configurable, final boolean enumerable, final boolean writable, final Object value) {
super(Global.objectPrototype(), $nasgenmap$);
this.configurable = configurable; this.configurable = configurable;
this.enumerable = enumerable; this.enumerable = enumerable;
this.writable = writable; this.writable = writable;
this.value = value; this.value = value;
setProto(Global.objectPrototype());
} }

View File

@ -30,6 +30,7 @@ import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyDescriptor; import jdk.nashorn.internal.runtime.PropertyDescriptor;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.ScriptFunction;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.ScriptRuntime; import jdk.nashorn.internal.runtime.ScriptRuntime;
@ -51,14 +52,17 @@ public final class GenericPropertyDescriptor extends ScriptObject implements Pro
@Property @Property
public Object enumerable; public Object enumerable;
// initialized by nasgen
private static PropertyMap $nasgenmap$;
GenericPropertyDescriptor() { GenericPropertyDescriptor() {
this(false, false); this(false, false);
} }
GenericPropertyDescriptor(final boolean configurable, final boolean enumerable) { GenericPropertyDescriptor(final boolean configurable, final boolean enumerable) {
super(Global.objectPrototype(), $nasgenmap$);
this.configurable = configurable; this.configurable = configurable;
this.enumerable = enumerable; this.enumerable = enumerable;
setProto(Global.objectPrototype());
} }
@Override @Override

View File

@ -53,8 +53,10 @@ import jdk.nashorn.internal.runtime.GlobalFunctions;
import jdk.nashorn.internal.runtime.GlobalObject; import jdk.nashorn.internal.runtime.GlobalObject;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.NativeJavaPackage; import jdk.nashorn.internal.runtime.NativeJavaPackage;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptEnvironment; import jdk.nashorn.internal.runtime.ScriptEnvironment;
import jdk.nashorn.internal.runtime.PropertyDescriptor; 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.regexp.RegExpResult;
import jdk.nashorn.internal.runtime.Scope; import jdk.nashorn.internal.runtime.Scope;
import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.ScriptFunction;
@ -379,6 +381,9 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
private final Context context; private final Context context;
// initialized by nasgen
private static PropertyMap $nasgenmap$;
/** /**
* Constructor * Constructor
* *
@ -484,7 +489,7 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
@Override @Override
public ScriptObject newObject() { public ScriptObject newObject() {
return newEmptyInstance(); return new JO(getObjectPrototype());
} }
@Override @Override
@ -1242,7 +1247,17 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
* @return the new array * @return the new array
*/ */
public static NativeArray allocate(final Object[] initial) { 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 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
* @return the new array * @return the new array
*/ */
public static NativeArray allocate(final double[] initial) { public static NativeArray allocate(final double[] initial) {
return new NativeArray(initial); return new NativeArray(ArrayData.allocate(initial));
} }
/** /**
@ -1262,7 +1277,7 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
* @return the new array * @return the new array
*/ */
public static NativeArray allocate(final long[] initial) { public static NativeArray allocate(final long[] initial) {
return new NativeArray(initial); return new NativeArray(ArrayData.allocate(initial));
} }
/** /**
@ -1272,7 +1287,7 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
* @return the new array * @return the new array
*/ */
public static NativeArray allocate(final int[] initial) { public static NativeArray allocate(final int[] initial) {
return new NativeArray(initial); return new NativeArray(ArrayData.allocate(initial));
} }
/** /**
@ -1329,9 +1344,7 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
* @return New empty object. * @return New empty object.
*/ */
public static ScriptObject newEmptyInstance() { public static ScriptObject newEmptyInstance() {
final ScriptObject sobj = new JO(); return Global.instance().newObject();
sobj.setProto(objectPrototype());
return sobj;
} }
/** /**
@ -1545,7 +1558,7 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
addOwnProperty("echo", Attribute.NOT_ENUMERABLE, value); addOwnProperty("echo", Attribute.NOT_ENUMERABLE, value);
// Nashorn extension: global.$OPTIONS (scripting-mode-only) // Nashorn extension: global.$OPTIONS (scripting-mode-only)
final ScriptObject options = newEmptyInstance(); final ScriptObject options = newObject();
final ScriptEnvironment scriptEnv = context.getEnv(); final ScriptEnvironment scriptEnv = context.getEnv();
copyOptions(options, scriptEnv); copyOptions(options, scriptEnv);
addOwnProperty("$OPTIONS", Attribute.NOT_ENUMERABLE, options); addOwnProperty("$OPTIONS", Attribute.NOT_ENUMERABLE, options);
@ -1554,7 +1567,7 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
if (System.getSecurityManager() == null) { if (System.getSecurityManager() == null) {
// do not fill $ENV if we have a security manager around // do not fill $ENV if we have a security manager around
// Retrieve current state of ENV variables. // Retrieve current state of ENV variables.
final ScriptObject env = newEmptyInstance(); final ScriptObject env = newObject();
env.putAll(System.getenv()); env.putAll(System.getenv());
addOwnProperty(ScriptingFunctions.ENV_NAME, Attribute.NOT_ENUMERABLE, env); addOwnProperty(ScriptingFunctions.ENV_NAME, Attribute.NOT_ENUMERABLE, env);
} else { } else {

View File

@ -61,13 +61,13 @@ public final class NativeArguments extends ScriptObject {
private static final MethodHandle G$CALLEE = findOwnMH("G$callee", Object.class, Object.class); 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 MethodHandle S$CALLEE = findOwnMH("S$callee", void.class, Object.class, Object.class);
private static final PropertyMap nasgenmap$; private static final PropertyMap map$;
static { static {
PropertyMap map = PropertyMap.newMap(NativeArguments.class); PropertyMap map = PropertyMap.newMap(NativeArguments.class);
map = Lookup.newProperty(map, "length", Property.NOT_ENUMERABLE, G$LENGTH, S$LENGTH); map = Lookup.newProperty(map, "length", Property.NOT_ENUMERABLE, G$LENGTH, S$LENGTH);
map = Lookup.newProperty(map, "callee", Property.NOT_ENUMERABLE, G$CALLEE, S$CALLEE); map = Lookup.newProperty(map, "callee", Property.NOT_ENUMERABLE, G$CALLEE, S$CALLEE);
nasgenmap$ = map; map$ = map;
} }
private Object length; private Object length;
@ -76,8 +76,8 @@ public final class NativeArguments extends ScriptObject {
// This is lazily initialized - only when delete is invoked at all // This is lazily initialized - only when delete is invoked at all
private BitSet deleted; private BitSet deleted;
NativeArguments(final Object[] arguments, final Object callee, final int numParams) { NativeArguments(final ScriptObject proto, final Object[] arguments, final Object callee, final int numParams) {
super(nasgenmap$); super(proto, map$);
setIsArguments(); setIsArguments();
setArray(ArrayData.allocate(arguments)); setArray(ArrayData.allocate(arguments));
@ -102,9 +102,6 @@ public final class NativeArguments extends ScriptObject {
} }
System.arraycopy(arguments, 0, newValues, 0, Math.min(newValues.length, arguments.length)); System.arraycopy(arguments, 0, newValues, 0, Math.min(newValues.length, arguments.length));
this.namedArgs = ArrayData.allocate(newValues); this.namedArgs = ArrayData.allocate(newValues);
// set Object.prototype as __proto__
this.setProto(Global.objectPrototype());
} }
@Override @Override
@ -553,7 +550,8 @@ public final class NativeArguments extends ScriptObject {
public static ScriptObject allocate(final Object[] arguments, final ScriptFunction callee, final int numParams) { 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. // Strict functions won't always have a callee for arguments, and will pass null instead.
final boolean isStrict = callee == null || callee.isStrict(); 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);
} }
/** /**

View File

@ -50,6 +50,7 @@ import jdk.nashorn.internal.objects.annotations.SpecializedConstructor;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyDescriptor; import jdk.nashorn.internal.runtime.PropertyDescriptor;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.ScriptFunction;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.ScriptRuntime; import jdk.nashorn.internal.runtime.ScriptRuntime;
@ -82,6 +83,8 @@ public final class NativeArray extends ScriptObject {
private static final InvokeByName TO_LOCALE_STRING = new InvokeByName("toLocaleString", ScriptObject.class, String.class); private static final InvokeByName TO_LOCALE_STRING = new InvokeByName("toLocaleString", ScriptObject.class, String.class);
// initialized by nasgen
private static PropertyMap $nasgenmap$;
/* /*
* Constructors. * Constructors.
@ -126,8 +129,8 @@ public final class NativeArray extends ScriptObject {
this.setArray(arrayData); this.setArray(arrayData);
} }
private NativeArray(final ArrayData arrayData) { NativeArray(final ArrayData arrayData) {
setProto(Global.instance().getArrayPrototype()); super(Global.instance().getArrayPrototype(), $nasgenmap$);
this.setArray(arrayData); this.setArray(arrayData);
this.setIsArray(); this.setIsArray();
} }

View File

@ -32,6 +32,7 @@ import jdk.nashorn.internal.objects.annotations.Function;
import jdk.nashorn.internal.objects.annotations.Getter; import jdk.nashorn.internal.objects.annotations.Getter;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.ScriptRuntime; import jdk.nashorn.internal.runtime.ScriptRuntime;
@ -39,6 +40,9 @@ import jdk.nashorn.internal.runtime.ScriptRuntime;
final class NativeArrayBuffer extends ScriptObject { final class NativeArrayBuffer extends ScriptObject {
private final byte[] buffer; private final byte[] buffer;
// initialized by nasgen
private static PropertyMap $nasgenmap$;
@Constructor(arity = 1) @Constructor(arity = 1)
public static Object constructor(final boolean newObj, final Object self, final Object... args) { public static Object constructor(final boolean newObj, final Object self, final Object... args) {
if (args.length == 0) { if (args.length == 0) {
@ -49,8 +53,8 @@ final class NativeArrayBuffer extends ScriptObject {
} }
protected NativeArrayBuffer(final byte[] byteArray) { protected NativeArrayBuffer(final byte[] byteArray) {
super(Global.instance().getArrayBufferPrototype(), $nasgenmap$);
this.buffer = byteArray; this.buffer = byteArray;
this.setProto(Global.instance().getArrayBufferPrototype());
} }
protected NativeArrayBuffer(final int byteLength) { protected NativeArrayBuffer(final int byteLength) {

View File

@ -37,6 +37,7 @@ import jdk.nashorn.internal.objects.annotations.Constructor;
import jdk.nashorn.internal.objects.annotations.Function; import jdk.nashorn.internal.objects.annotations.Function;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.ScriptRuntime; import jdk.nashorn.internal.runtime.ScriptRuntime;
import jdk.nashorn.internal.lookup.MethodHandleFactory; import jdk.nashorn.internal.lookup.MethodHandleFactory;
@ -52,13 +53,16 @@ public final class NativeBoolean extends ScriptObject {
final static MethodHandle WRAPFILTER = findWrapFilter(); final static MethodHandle WRAPFILTER = findWrapFilter();
// initialized by nasgen
private static PropertyMap $nasgenmap$;
NativeBoolean(final boolean value) { NativeBoolean(final boolean value) {
this(value, Global.instance().getBooleanPrototype()); this(value, Global.instance().getBooleanPrototype());
} }
private NativeBoolean(final boolean value, final ScriptObject proto) { private NativeBoolean(final boolean value, final ScriptObject proto) {
super(proto, $nasgenmap$);
this.value = value; this.value = value;
this.setProto(proto);
} }
@Override @Override

View File

@ -42,6 +42,7 @@ import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.parser.DateParser; import jdk.nashorn.internal.parser.DateParser;
import jdk.nashorn.internal.runtime.ConsString; import jdk.nashorn.internal.runtime.ConsString;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptEnvironment; import jdk.nashorn.internal.runtime.ScriptEnvironment;
import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.ScriptFunction;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
@ -100,16 +101,19 @@ public final class NativeDate extends ScriptObject {
private double time; private double time;
private final TimeZone timezone; private final TimeZone timezone;
// initialized by nasgen
private static PropertyMap $nasgenmap$;
NativeDate() { NativeDate() {
this(System.currentTimeMillis()); this(System.currentTimeMillis());
} }
NativeDate(final double time) { NativeDate(final double time) {
super(Global.instance().getDatePrototype(), $nasgenmap$);
final ScriptEnvironment env = Global.getEnv(); final ScriptEnvironment env = Global.getEnv();
this.time = time; this.time = time;
this.timezone = env._timezone; this.timezone = env._timezone;
this.setProto(Global.instance().getDatePrototype());
} }
@Override @Override

View File

@ -47,8 +47,12 @@ import jdk.nashorn.internal.runtime.linker.LinkerCallSite;
*/ */
@ScriptClass("Debug") @ScriptClass("Debug")
public final class NativeDebug extends ScriptObject { public final class NativeDebug extends ScriptObject {
// initialized by nasgen
private static PropertyMap $nasgenmap$;
NativeDebug() { NativeDebug() {
this.setProto(Global.objectPrototype()); super(Global.objectPrototype(), $nasgenmap$);
} }
@Override @Override
@ -187,7 +191,7 @@ public final class NativeDebug extends ScriptObject {
out.println("Scope count " + ScriptObject.getScopeCount()); out.println("Scope count " + ScriptObject.getScopeCount());
out.println("ScriptObject listeners added " + PropertyListenerManager.getListenersAdded()); out.println("ScriptObject listeners added " + PropertyListenerManager.getListenersAdded());
out.println("ScriptObject listeners removed " + PropertyListenerManager.getListenersRemoved()); 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 invokes " + ScriptFunction.getInvokes());
out.println("ScriptFunction allocations " + ScriptFunction.getAllocations()); out.println("ScriptFunction allocations " + ScriptFunction.getAllocations());
out.println("PropertyMap count " + PropertyMap.getCount()); out.println("PropertyMap count " + PropertyMap.getCount());

View File

@ -43,6 +43,7 @@ import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.ECMAErrors; import jdk.nashorn.internal.runtime.ECMAErrors;
import jdk.nashorn.internal.runtime.ECMAException; import jdk.nashorn.internal.runtime.ECMAException;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.ScriptRuntime; import jdk.nashorn.internal.runtime.ScriptRuntime;
@ -86,8 +87,11 @@ public final class NativeError extends ScriptObject {
@Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE)
public Object message; public Object message;
// initialized by nasgen
private static PropertyMap $nasgenmap$;
NativeError(final Object msg) { NativeError(final Object msg) {
this.setProto(Global.instance().getErrorPrototype()); super(Global.instance().getErrorPrototype(), $nasgenmap$);
if (msg != UNDEFINED) { if (msg != UNDEFINED) {
this.instMessage = JSType.toString(msg); this.instMessage = JSType.toString(msg);
} else { } else {

View File

@ -33,6 +33,7 @@ import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
/** /**
@ -52,10 +53,13 @@ public final class NativeEvalError extends ScriptObject {
/** ECMA 15.1.1.1 message property */ /** ECMA 15.1.1.1 message property */
@Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) @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) { NativeEvalError(final Object msg) {
this.setProto(Global.instance().getEvalErrorPrototype()); super(Global.instance().getEvalErrorPrototype(), $nasgenmap$);
if (msg != UNDEFINED) { if (msg != UNDEFINED) {
this.instMessage = JSType.toString(msg); this.instMessage = JSType.toString(msg);
} else { } else {

View File

@ -32,6 +32,7 @@ import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.arrays.ArrayData; import jdk.nashorn.internal.runtime.arrays.ArrayData;
@ -46,6 +47,9 @@ public final class NativeFloat32Array extends ArrayBufferView {
@Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
public static final int BYTES_PER_ELEMENT = 4; 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) { private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
@Override @Override
public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) { public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {

View File

@ -32,6 +32,7 @@ import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.arrays.ArrayData; import jdk.nashorn.internal.runtime.arrays.ArrayData;
@ -46,6 +47,9 @@ public final class NativeFloat64Array extends ArrayBufferView {
@Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
public static final int BYTES_PER_ELEMENT = 8; 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) { private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
@Override @Override
public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) { public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {

View File

@ -38,6 +38,7 @@ import jdk.nashorn.internal.parser.Parser;
import jdk.nashorn.internal.runtime.Context; import jdk.nashorn.internal.runtime.Context;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.ParserException; import jdk.nashorn.internal.runtime.ParserException;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.ScriptFunction;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.ScriptRuntime; import jdk.nashorn.internal.runtime.ScriptRuntime;
@ -52,6 +53,10 @@ import jdk.nashorn.internal.runtime.Source;
*/ */
@ScriptClass("Function") @ScriptClass("Function")
public final class NativeFunction { public final class NativeFunction {
// initialized by nasgen
private static PropertyMap $nasgenmap$;
// do *not* create me! // do *not* create me!
private NativeFunction() { private NativeFunction() {
} }

View File

@ -31,6 +31,7 @@ import jdk.nashorn.internal.objects.annotations.Function;
import jdk.nashorn.internal.objects.annotations.Property; import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.arrays.ArrayData; import jdk.nashorn.internal.runtime.arrays.ArrayData;
@ -39,6 +40,10 @@ import jdk.nashorn.internal.runtime.arrays.ArrayData;
*/ */
@ScriptClass("Int16Array") @ScriptClass("Int16Array")
public final class NativeInt16Array extends ArrayBufferView { public final class NativeInt16Array extends ArrayBufferView {
// initialized by nasgen
private static PropertyMap $nasgenmap$;
/** /**
* The size in bytes of each element in the array. * The size in bytes of each element in the array.
*/ */

View File

@ -31,6 +31,7 @@ import jdk.nashorn.internal.objects.annotations.Function;
import jdk.nashorn.internal.objects.annotations.Property; import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.arrays.ArrayData; import jdk.nashorn.internal.runtime.arrays.ArrayData;
@ -45,6 +46,9 @@ public final class NativeInt32Array extends ArrayBufferView {
@Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
public static final int BYTES_PER_ELEMENT = 4; 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) { private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
@Override @Override
public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) { public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {

View File

@ -31,6 +31,7 @@ import jdk.nashorn.internal.objects.annotations.Function;
import jdk.nashorn.internal.objects.annotations.Property; import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.arrays.ArrayData; import jdk.nashorn.internal.runtime.arrays.ArrayData;
@ -45,6 +46,9 @@ public final class NativeInt8Array extends ArrayBufferView {
@Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
public static final int BYTES_PER_ELEMENT = 1; 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) { private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
@Override @Override
public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) { public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {

View File

@ -42,6 +42,7 @@ import jdk.nashorn.internal.objects.annotations.Constructor;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.runtime.FindProperty; import jdk.nashorn.internal.runtime.FindProperty;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.ScriptFunction;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.ScriptRuntime; import jdk.nashorn.internal.runtime.ScriptRuntime;
@ -142,9 +143,12 @@ public final class NativeJSAdapter extends ScriptObject {
private static final MethodHandle IS_JSADAPTOR = findOwnMH("isJSAdaptor", boolean.class, Object.class, Object.class, MethodHandle.class, Object.class, ScriptFunction.class); 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) { NativeJSAdapter(final ScriptObject proto, final Object overrides, final ScriptObject adaptee) {
super(proto, $nasgenmap$);
this.adaptee = wrapAdaptee(adaptee); this.adaptee = wrapAdaptee(adaptee);
this.setProto(proto);
if (overrides instanceof ScriptObject) { if (overrides instanceof ScriptObject) {
this.overrides = true; this.overrides = true;
final ScriptObject sobj = (ScriptObject)overrides; final ScriptObject sobj = (ScriptObject)overrides;

View File

@ -42,6 +42,7 @@ import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.ConsString; import jdk.nashorn.internal.runtime.ConsString;
import jdk.nashorn.internal.runtime.JSONFunctions; import jdk.nashorn.internal.runtime.JSONFunctions;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.ScriptFunction;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.arrays.ArrayLikeIterator; import jdk.nashorn.internal.runtime.arrays.ArrayLikeIterator;
@ -58,9 +59,11 @@ public final class NativeJSON extends ScriptObject {
private static final MethodHandle REPLACER_INVOKER = Bootstrap.createDynamicInvoker("dyn:call", Object.class, private static final MethodHandle REPLACER_INVOKER = Bootstrap.createDynamicInvoker("dyn:call", Object.class,
ScriptFunction.class, ScriptObject.class, Object.class, Object.class); ScriptFunction.class, ScriptObject.class, Object.class, Object.class);
// initialized by nasgen
private static PropertyMap $nasgenmap$;
NativeJSON() { NativeJSON() {
this.setProto(Global.objectPrototype()); super(Global.objectPrototype(), $nasgenmap$);
} }
/** /**

View File

@ -40,6 +40,7 @@ import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.ListAdapter; import jdk.nashorn.internal.runtime.ListAdapter;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.linker.JavaAdapterFactory; import jdk.nashorn.internal.runtime.linker.JavaAdapterFactory;
@ -52,6 +53,9 @@ import jdk.nashorn.internal.runtime.linker.JavaAdapterFactory;
@ScriptClass("Java") @ScriptClass("Java")
public final class NativeJava { public final class NativeJava {
// initialized by nasgen
private static PropertyMap $nasgenmap$;
private NativeJava() { private NativeJava() {
} }

View File

@ -34,6 +34,7 @@ import jdk.nashorn.internal.objects.annotations.Constructor;
import jdk.nashorn.internal.objects.annotations.Function; import jdk.nashorn.internal.objects.annotations.Function;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.runtime.NativeJavaPackage; import jdk.nashorn.internal.runtime.NativeJavaPackage;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
/** /**
@ -55,9 +56,12 @@ import jdk.nashorn.internal.runtime.ScriptObject;
public final class NativeJavaImporter extends ScriptObject { public final class NativeJavaImporter extends ScriptObject {
private final Object[] args; private final Object[] args;
// initialized by nasgen
private static PropertyMap $nasgenmap$;
NativeJavaImporter(final Object[] args) { NativeJavaImporter(final Object[] args) {
super(Global.instance().getJavaImporterPrototype(), $nasgenmap$);
this.args = args; this.args = args;
this.setProto(Global.instance().getJavaImporterPrototype());
} }
@Override @Override

View File

@ -32,6 +32,7 @@ import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.SpecializedFunction; import jdk.nashorn.internal.objects.annotations.SpecializedFunction;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
/** /**
@ -41,8 +42,11 @@ import jdk.nashorn.internal.runtime.ScriptObject;
@ScriptClass("Math") @ScriptClass("Math")
public final class NativeMath extends ScriptObject { public final class NativeMath extends ScriptObject {
// initialized by nasgen
private static PropertyMap $nasgenmap$;
NativeMath() { NativeMath() {
this.setProto(Global.objectPrototype()); super(Global.objectPrototype(), $nasgenmap$);
} }
/** ECMA 15.8.1.1 - E, always a double constant. Not writable or configurable */ /** ECMA 15.8.1.1 - E, always a double constant. Not writable or configurable */

View File

@ -45,6 +45,7 @@ import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.ScriptRuntime; import jdk.nashorn.internal.runtime.ScriptRuntime;
import jdk.nashorn.internal.lookup.MethodHandleFactory; import jdk.nashorn.internal.lookup.MethodHandleFactory;
@ -83,15 +84,18 @@ public final class NativeNumber extends ScriptObject {
private final boolean isInt; private final boolean isInt;
private final boolean isLong; private final boolean isLong;
// initialized by nasgen
private static PropertyMap $nasgenmap$;
NativeNumber(final double value) { NativeNumber(final double value) {
this(value, Global.instance().getNumberPrototype()); this(value, Global.instance().getNumberPrototype());
} }
private NativeNumber(final double value, final ScriptObject proto) { private NativeNumber(final double value, final ScriptObject proto) {
super(proto, $nasgenmap$);
this.value = value; this.value = value;
this.isInt = isRepresentableAsInt(value); this.isInt = isRepresentableAsInt(value);
this.isLong = isRepresentableAsLong(value); this.isLong = isRepresentableAsLong(value);
this.setProto(proto);
} }
@Override @Override

View File

@ -36,6 +36,7 @@ import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.ECMAException; import jdk.nashorn.internal.runtime.ECMAException;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.ScriptFunction;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.ScriptRuntime; import jdk.nashorn.internal.runtime.ScriptRuntime;
@ -53,6 +54,9 @@ import jdk.nashorn.internal.runtime.linker.InvokeByName;
public final class NativeObject { public final class NativeObject {
private static final InvokeByName TO_STRING = new InvokeByName("toString", ScriptObject.class); private static final InvokeByName TO_STRING = new InvokeByName("toString", ScriptObject.class);
// initialized by nasgen
private static PropertyMap $nasgenmap$;
private NativeObject() { private NativeObject() {
} }

View File

@ -33,6 +33,7 @@ import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
/** /**
@ -54,8 +55,11 @@ public final class NativeRangeError extends ScriptObject {
@Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE)
public Object message; public Object message;
// initialized by nasgen
private static PropertyMap $nasgenmap$;
NativeRangeError(final Object msg) { NativeRangeError(final Object msg) {
setProto(Global.instance().getRangeErrorPrototype()); super(Global.instance().getRangeErrorPrototype(), $nasgenmap$);
if (msg != UNDEFINED) { if (msg != UNDEFINED) {
this.instMessage = JSType.toString(msg); this.instMessage = JSType.toString(msg);
} else { } else {

View File

@ -33,6 +33,7 @@ import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
/** /**
@ -54,8 +55,11 @@ public final class NativeReferenceError extends ScriptObject {
@Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE)
public Object message; public Object message;
// initialized by nasgen
private static PropertyMap $nasgenmap$;
NativeReferenceError(final Object msg) { NativeReferenceError(final Object msg) {
this.setProto(Global.instance().getReferenceErrorPrototype()); super(Global.instance().getReferenceErrorPrototype(), $nasgenmap$);
if (msg != UNDEFINED) { if (msg != UNDEFINED) {
this.instMessage = JSType.toString(msg); this.instMessage = JSType.toString(msg);
} else { } else {

View File

@ -43,6 +43,7 @@ import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.BitVector; import jdk.nashorn.internal.runtime.BitVector;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.ParserException; 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.RegExp;
import jdk.nashorn.internal.runtime.regexp.RegExpFactory; import jdk.nashorn.internal.runtime.regexp.RegExpFactory;
import jdk.nashorn.internal.runtime.regexp.RegExpResult; import jdk.nashorn.internal.runtime.regexp.RegExpResult;
@ -66,6 +67,9 @@ public final class NativeRegExp extends ScriptObject {
// Reference to global object needed to support static RegExp properties // Reference to global object needed to support static RegExp properties
private Global globalObject; private Global globalObject;
// initialized by nasgen
private static PropertyMap $nasgenmap$;
NativeRegExp(final String input, final String flagString) { NativeRegExp(final String input, final String flagString) {
try { try {
this.regexp = RegExpFactory.create(input, flagString); this.regexp = RegExpFactory.create(input, flagString);

View File

@ -31,6 +31,7 @@ import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Setter; import jdk.nashorn.internal.objects.annotations.Setter;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.regexp.RegExpResult; import jdk.nashorn.internal.runtime.regexp.RegExpResult;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.arrays.ArrayData; import jdk.nashorn.internal.runtime.arrays.ArrayData;
@ -49,8 +50,11 @@ public final class NativeRegExpExecResult extends ScriptObject {
@Property @Property
public Object input; public Object input;
// initialized by nasgen
private static PropertyMap $nasgenmap$;
NativeRegExpExecResult(final RegExpResult result) { NativeRegExpExecResult(final RegExpResult result) {
setProto(Global.instance().getArrayPrototype()); super(Global.instance().getArrayPrototype(), $nasgenmap$);
setIsArray(); setIsArray();
this.setArray(ArrayData.allocate(result.getGroups().clone())); this.setArray(ArrayData.allocate(result.getGroups().clone()));
this.index = result.getIndex(); this.index = result.getIndex();

View File

@ -51,7 +51,7 @@ public final class NativeStrictArguments extends ScriptObject {
private static final MethodHandle S$LENGTH = findOwnMH("S$length", void.class, Object.class, Object.class); private static final MethodHandle S$LENGTH = findOwnMH("S$length", void.class, Object.class, Object.class);
// property map for strict mode arguments object // property map for strict mode arguments object
private static final PropertyMap nasgenmap$; private static final PropertyMap map$;
static { static {
PropertyMap map = PropertyMap.newMap(NativeStrictArguments.class); PropertyMap map = PropertyMap.newMap(NativeStrictArguments.class);
@ -61,14 +61,14 @@ public final class NativeStrictArguments extends ScriptObject {
final int flags = Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE; final int flags = Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE;
map = map.addProperty(map.newUserAccessors("caller", flags)); map = map.addProperty(map.newUserAccessors("caller", flags));
map = map.addProperty(map.newUserAccessors("callee", flags)); map = map.addProperty(map.newUserAccessors("callee", flags));
nasgenmap$ = map; map$ = map;
} }
private Object length; private Object length;
private final Object[] namedArgs; private final Object[] namedArgs;
NativeStrictArguments(final Object[] values, final int numParams) { NativeStrictArguments(final ScriptObject proto, final Object[] values, final int numParams) {
super(nasgenmap$); super(proto, map$);
setIsArguments(); setIsArguments();
final ScriptFunction func = ScriptFunctionImpl.getTypeErrorThrower(); final ScriptFunction func = ScriptFunctionImpl.getTypeErrorThrower();
@ -86,8 +86,6 @@ public final class NativeStrictArguments extends ScriptObject {
Arrays.fill(namedArgs, UNDEFINED); Arrays.fill(namedArgs, UNDEFINED);
} }
System.arraycopy(values, 0, namedArgs, 0, Math.min(namedArgs.length, values.length)); System.arraycopy(values, 0, namedArgs, 0, Math.min(namedArgs.length, values.length));
this.setProto(Global.objectPrototype());
} }
@Override @Override

View File

@ -52,6 +52,7 @@ import jdk.nashorn.internal.objects.annotations.SpecializedFunction;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.ConsString; import jdk.nashorn.internal.runtime.ConsString;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.ScriptFunction;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.ScriptRuntime; import jdk.nashorn.internal.runtime.ScriptRuntime;
@ -70,14 +71,17 @@ public final class NativeString extends ScriptObject {
static final MethodHandle WRAPFILTER = findWrapFilter(); static final MethodHandle WRAPFILTER = findWrapFilter();
// initialized by nasgen
private static PropertyMap $nasgenmap$;
NativeString(final CharSequence value) { NativeString(final CharSequence value) {
this(value, Global.instance().getStringPrototype()); this(value, Global.instance().getStringPrototype());
} }
private NativeString(final CharSequence value, final ScriptObject proto) { private NativeString(final CharSequence value, final ScriptObject proto) {
super(proto, $nasgenmap$);
assert value instanceof String || value instanceof ConsString; assert value instanceof String || value instanceof ConsString;
this.value = value; this.value = value;
this.setProto(proto);
} }
@Override @Override

View File

@ -33,6 +33,7 @@ import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
/** /**
@ -54,8 +55,11 @@ public final class NativeSyntaxError extends ScriptObject {
@Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE)
public Object message; public Object message;
// initialized by nasgen
private static PropertyMap $nasgenmap$;
NativeSyntaxError(final Object msg) { NativeSyntaxError(final Object msg) {
this.setProto(Global.instance().getSyntaxErrorPrototype()); super(Global.instance().getSyntaxErrorPrototype(), $nasgenmap$);
if (msg != UNDEFINED) { if (msg != UNDEFINED) {
this.instMessage = JSType.toString(msg); this.instMessage = JSType.toString(msg);
} else { } else {

View File

@ -33,6 +33,7 @@ import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
/** /**
@ -54,8 +55,11 @@ public final class NativeTypeError extends ScriptObject {
@Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE)
public Object message; public Object message;
// initialized by nasgen
private static PropertyMap $nasgenmap$;
NativeTypeError(final Object msg) { NativeTypeError(final Object msg) {
this.setProto(Global.instance().getTypeErrorPrototype()); super(Global.instance().getTypeErrorPrototype(), $nasgenmap$);
if (msg != UNDEFINED) { if (msg != UNDEFINED) {
this.instMessage = JSType.toString(msg); this.instMessage = JSType.toString(msg);
} else { } else {

View File

@ -33,6 +33,7 @@ import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
/** /**
@ -53,8 +54,11 @@ public final class NativeURIError extends ScriptObject {
@Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE)
public Object message; public Object message;
// initialized by nasgen
private static PropertyMap $nasgenmap$;
NativeURIError(final Object msg) { NativeURIError(final Object msg) {
this.setProto(Global.instance().getURIErrorPrototype()); super(Global.instance().getURIErrorPrototype(), $nasgenmap$);
if (msg != UNDEFINED) { if (msg != UNDEFINED) {
this.instMessage = JSType.toString(msg); this.instMessage = JSType.toString(msg);
} else { } else {

View File

@ -31,6 +31,7 @@ import jdk.nashorn.internal.objects.annotations.Function;
import jdk.nashorn.internal.objects.annotations.Property; import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.arrays.ArrayData; import jdk.nashorn.internal.runtime.arrays.ArrayData;
@ -45,6 +46,9 @@ public final class NativeUint16Array extends ArrayBufferView {
@Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
public static final int BYTES_PER_ELEMENT = 2; 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) { private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
@Override @Override
public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) { public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {

View File

@ -32,6 +32,7 @@ import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.arrays.ArrayData; import jdk.nashorn.internal.runtime.arrays.ArrayData;
@ -46,6 +47,9 @@ public final class NativeUint32Array extends ArrayBufferView {
@Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
public static final int BYTES_PER_ELEMENT = 4; 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) { private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
@Override @Override
public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteBegin, final int length) { public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteBegin, final int length) {

View File

@ -31,6 +31,7 @@ import jdk.nashorn.internal.objects.annotations.Function;
import jdk.nashorn.internal.objects.annotations.Property; import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.arrays.ArrayData; import jdk.nashorn.internal.runtime.arrays.ArrayData;
@ -45,6 +46,9 @@ public final class NativeUint8Array extends ArrayBufferView {
@Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
public static final int BYTES_PER_ELEMENT = 1; 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) { private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
@Override @Override
public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) { public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {

View File

@ -32,6 +32,7 @@ import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Where; import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.arrays.ArrayData; import jdk.nashorn.internal.runtime.arrays.ArrayData;
@ -46,6 +47,9 @@ public final class NativeUint8ClampedArray extends ArrayBufferView {
@Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR) @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE, where = Where.CONSTRUCTOR)
public static final int BYTES_PER_ELEMENT = 1; 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) { private static final Factory FACTORY = new Factory(BYTES_PER_ELEMENT) {
@Override @Override
public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) { public ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int length) {

View File

@ -44,7 +44,7 @@ import jdk.nashorn.internal.lookup.MethodHandleFactory;
* *
*/ */
public class PrototypeObject extends ScriptObject { public class PrototypeObject extends ScriptObject {
private static final PropertyMap nasgenmap$; private static final PropertyMap map$;
private Object constructor; private Object constructor;
@ -54,11 +54,11 @@ public class PrototypeObject extends ScriptObject {
static { static {
PropertyMap map = PropertyMap.newMap(PrototypeObject.class); PropertyMap map = PropertyMap.newMap(PrototypeObject.class);
map = Lookup.newProperty(map, "constructor", Property.NOT_ENUMERABLE, GET_CONSTRUCTOR, SET_CONSTRUCTOR); map = Lookup.newProperty(map, "constructor", Property.NOT_ENUMERABLE, GET_CONSTRUCTOR, SET_CONSTRUCTOR);
nasgenmap$ = map; map$ = map;
} }
PrototypeObject() { PrototypeObject() {
this(nasgenmap$); this(map$);
} }
/** /**
@ -67,12 +67,12 @@ public class PrototypeObject extends ScriptObject {
* @param map property map * @param map property map
*/ */
public PrototypeObject(final PropertyMap map) { public PrototypeObject(final PropertyMap map) {
super(map != nasgenmap$ ? map.addAll(nasgenmap$) : nasgenmap$); super(map != map$ ? map.addAll(map$) : map$);
setProto(Global.objectPrototype()); setProto(Global.objectPrototype());
} }
PrototypeObject(final ScriptFunction func) { PrototypeObject(final ScriptFunction func) {
this(); this(map$);
this.constructor = func; this.constructor = func;
} }

View File

@ -51,7 +51,7 @@ public class ScriptFunctionImpl extends ScriptFunction {
// property map for bound functions // property map for bound functions
private static final PropertyMap boundfunctionmap$; private static final PropertyMap boundfunctionmap$;
// property map for non-strict, non-bound functions. // 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 // Marker object for lazily initialized prototype object
private static final Object LAZY_PROTOTYPE = new Object(); private static final Object LAZY_PROTOTYPE = new Object();
@ -65,7 +65,7 @@ public class ScriptFunctionImpl extends ScriptFunction {
* @param specs specialized versions of this method, if available, null otherwise * @param specs specialized versions of this method, if available, null otherwise
*/ */
ScriptFunctionImpl(final String name, final MethodHandle invokeHandle, final MethodHandle[] specs) { 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(); init();
} }
@ -79,7 +79,7 @@ public class ScriptFunctionImpl extends ScriptFunction {
* @param specs specialized versions of this method, if available, null otherwise * @param specs specialized versions of this method, if available, null otherwise
*/ */
ScriptFunctionImpl(final String name, final MethodHandle invokeHandle, final PropertyMap map, final MethodHandle[] specs) { 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(); init();
} }
@ -124,8 +124,8 @@ public class ScriptFunctionImpl extends ScriptFunction {
map = Lookup.newProperty(map, "prototype", Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE, G$PROTOTYPE, S$PROTOTYPE); 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, "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); map = Lookup.newProperty(map, "name", Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE | Property.NOT_WRITABLE, G$NAME, null);
nasgenmap$ = map; map$ = map;
strictmodemap$ = createStrictModeMap(nasgenmap$); strictmodemap$ = createStrictModeMap(map$);
boundfunctionmap$ = createBoundFunctionMap(strictmodemap$); boundfunctionmap$ = createBoundFunctionMap(strictmodemap$);
} }
@ -165,7 +165,7 @@ public class ScriptFunctionImpl extends ScriptFunction {
// Choose the map based on strict mode! // Choose the map based on strict mode!
private static PropertyMap getMap(final boolean strict) { private static PropertyMap getMap(final boolean strict) {
return strict ? strictmodemap$ : nasgenmap$; return strict ? strictmodemap$ : map$;
} }
private static PropertyMap createBoundFunctionMap(final PropertyMap strictModeMap) { private static PropertyMap createBoundFunctionMap(final PropertyMap strictModeMap) {

View File

@ -101,13 +101,7 @@ public final class Context {
/** Is Context global debug mode enabled ? */ /** Is Context global debug mode enabled ? */
public static final boolean DEBUG = Options.getBooleanProperty("nashorn.debug"); public static final boolean DEBUG = Options.getBooleanProperty("nashorn.debug");
private static final ThreadLocal<ScriptObject> currentGlobal = private static final ThreadLocal<ScriptObject> currentGlobal = new ThreadLocal<>();
new ThreadLocal<ScriptObject>() {
@Override
protected ScriptObject initialValue() {
return null;
}
};
/** /**
* Get the current global scope * Get the current global scope

View File

@ -54,9 +54,8 @@ public class FunctionScope extends ScriptObject implements Scope {
* @param arguments arguments * @param arguments arguments
*/ */
public FunctionScope(final PropertyMap map, final ScriptObject callerScope, final Object arguments) { public FunctionScope(final PropertyMap map, final ScriptObject callerScope, final Object arguments) {
super(map); super(callerScope, map);
this.arguments = arguments; this.arguments = arguments;
setProto(callerScope);
setIsScope(); setIsScope();
} }
@ -67,9 +66,8 @@ public class FunctionScope extends ScriptObject implements Scope {
* @param callerScope caller scope * @param callerScope caller scope
*/ */
public FunctionScope(final PropertyMap map, final ScriptObject callerScope) { public FunctionScope(final PropertyMap map, final ScriptObject callerScope) {
super(map); super(callerScope, map);
this.arguments = null; this.arguments = null;
setProto(callerScope);
setIsScope(); setIsScope();
} }

View File

@ -25,6 +25,8 @@
package jdk.nashorn.internal.runtime; package jdk.nashorn.internal.runtime;
import jdk.nashorn.internal.scripts.JO;
import static jdk.nashorn.internal.runtime.PropertyHashMap.EMPTY_HASHMAP; import static jdk.nashorn.internal.runtime.PropertyHashMap.EMPTY_HASHMAP;
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
@ -166,7 +168,7 @@ public final class PropertyMap implements Iterable<Object>, PropertyListener {
*/ */
public static PropertyMap newMap(final Class<?> structure, final Collection<Property> properties, final int fieldCount, final int fieldMaximum) { 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. // Reduce the number of empty maps in the context.
if (structure == jdk.nashorn.internal.scripts.JO.class) { if (structure == JO.class) {
return EMPTY_MAP; return EMPTY_MAP;
} }

View File

@ -170,13 +170,30 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr
} }
this.arrayData = ArrayData.EMPTY_ARRAY; this.arrayData = ArrayData.EMPTY_ARRAY;
this.setMap(map == null ? PropertyMap.newMap(getClass()) : map);
if (map == null) {
this.setMap(PropertyMap.newMap(getClass()));
return;
} }
this.setMap(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.arrayData = ArrayData.EMPTY_ARRAY;
this.setMap(map == null ? PropertyMap.newMap(getClass()) : map);
this.proto = proto;
if (proto != null) {
proto.setIsPrototype();
}
} }
/** /**

View File

@ -32,11 +32,14 @@ import jdk.nashorn.internal.runtime.ScriptObject;
* Empty object class. * Empty object class.
*/ */
public class JO extends ScriptObject { public class JO extends ScriptObject {
private static final PropertyMap map$ = PropertyMap.newMap(JO.class);
/** /**
* Constructor * Constructor
*/ */
public JO() { public JO() {
super(PropertyMap.newMap(JO.class)); super(map$);
} }
/** /**
@ -48,6 +51,15 @@ public class JO extends ScriptObject {
super(map); super(map);
} }
/**
* 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. * Used by FunctionObjectCreator. A method handle of this method is passed to the ScriptFunction constructor.
* *