8019157: Avoid calling ScriptObject.setProto() if possible
Reviewed-by: jlaskey, sundar
This commit is contained in:
parent
e628bb4979
commit
70383eb20a
@ -166,11 +166,11 @@ public class ClassGenerator {
|
||||
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 @@ public class ClassGenerator {
|
||||
|
||||
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 @@ public class ClassGenerator {
|
||||
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 @@ public class ClassGenerator {
|
||||
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 {
|
||||
|
@ -159,10 +159,14 @@ public class ScriptClassInstrumentor extends ClassVisitor {
|
||||
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 @@ public class ScriptClassInstrumentor extends ClassVisitor {
|
||||
ClassGenerator.addSetter(cv, className, memInfo);
|
||||
}
|
||||
}
|
||||
ClassGenerator.addMapField(this);
|
||||
// omit addMapField() since instance classes already define a static PropertyMap field
|
||||
}
|
||||
|
||||
void emitGettersSetters() {
|
||||
|
@ -165,7 +165,8 @@ public class ClassEmitter implements Emitter {
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
@ -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
|
||||
*
|
||||
* @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) {
|
||||
|
@ -245,9 +245,9 @@ public final class Compiler {
|
||||
/**
|
||||
* 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
|
||||
|
@ -82,13 +82,13 @@ public final class ObjectClassGenerator {
|
||||
* 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
|
||||
|
@ -34,6 +34,7 @@ import jdk.nashorn.internal.objects.annotations.Property;
|
||||
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 @@ public final class AccessorPropertyDescriptor extends ScriptObject implements Pr
|
||||
@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
|
||||
|
@ -29,6 +29,7 @@ import jdk.nashorn.internal.objects.annotations.Attribute;
|
||||
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 @@ import static jdk.nashorn.internal.runtime.ECMAErrors.rangeError;
|
||||
@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());
|
||||
|
@ -33,6 +33,7 @@ import jdk.nashorn.internal.objects.annotations.Property;
|
||||
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 @@ public final class DataPropertyDescriptor extends ScriptObject implements Proper
|
||||
@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());
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,6 +30,7 @@ import jdk.nashorn.internal.objects.annotations.Property;
|
||||
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 @@ public final class GenericPropertyDescriptor extends ScriptObject implements Pro
|
||||
@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
|
||||
|
@ -53,8 +53,10 @@ import jdk.nashorn.internal.runtime.GlobalFunctions;
|
||||
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 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
|
||||
|
||||
private final Context context;
|
||||
|
||||
// initialized by nasgen
|
||||
private static PropertyMap $nasgenmap$;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -484,7 +489,7 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
|
||||
|
||||
@Override
|
||||
public ScriptObject newObject() {
|
||||
return newEmptyInstance();
|
||||
return new JO(getObjectPrototype());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1242,7 +1247,17 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
|
||||
* @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 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
|
||||
* @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 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
|
||||
* @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 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
|
||||
* @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 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
|
||||
* @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 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
|
||||
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 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
|
||||
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 {
|
||||
|
@ -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 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 @@ public final class NativeArguments extends ScriptObject {
|
||||
// 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 @@ public final class NativeArguments extends ScriptObject {
|
||||
}
|
||||
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 final class NativeArguments extends ScriptObject {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,6 +50,7 @@ import jdk.nashorn.internal.objects.annotations.SpecializedConstructor;
|
||||
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 @@ public final class NativeArray extends ScriptObject {
|
||||
|
||||
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 @@ public final class NativeArray extends ScriptObject {
|
||||
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();
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import jdk.nashorn.internal.objects.annotations.Function;
|
||||
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 @@ import jdk.nashorn.internal.runtime.ScriptRuntime;
|
||||
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 @@ final class NativeArrayBuffer extends ScriptObject {
|
||||
}
|
||||
|
||||
protected NativeArrayBuffer(final byte[] byteArray) {
|
||||
super(Global.instance().getArrayBufferPrototype(), $nasgenmap$);
|
||||
this.buffer = byteArray;
|
||||
this.setProto(Global.instance().getArrayBufferPrototype());
|
||||
}
|
||||
|
||||
protected NativeArrayBuffer(final int byteLength) {
|
||||
|
@ -37,6 +37,7 @@ import jdk.nashorn.internal.objects.annotations.Constructor;
|
||||
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 @@ public final class NativeBoolean extends ScriptObject {
|
||||
|
||||
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
|
||||
|
@ -42,6 +42,7 @@ import jdk.nashorn.internal.objects.annotations.Where;
|
||||
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 @@ public final class NativeDate extends ScriptObject {
|
||||
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
|
||||
|
@ -47,8 +47,12 @@ import jdk.nashorn.internal.runtime.linker.LinkerCallSite;
|
||||
*/
|
||||
@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 @@ public final class NativeDebug extends ScriptObject {
|
||||
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());
|
||||
|
@ -43,6 +43,7 @@ import jdk.nashorn.internal.objects.annotations.Where;
|
||||
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 @@ public final class NativeError extends ScriptObject {
|
||||
@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 {
|
||||
|
@ -33,6 +33,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.JSType;
|
||||
import jdk.nashorn.internal.runtime.PropertyMap;
|
||||
import jdk.nashorn.internal.runtime.ScriptObject;
|
||||
|
||||
/**
|
||||
@ -52,10 +53,13 @@ public final class NativeEvalError extends ScriptObject {
|
||||
|
||||
/** ECMA 15.1.1.1 message property */
|
||||
@Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE)
|
||||
|
||||
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 {
|
||||
|
@ -32,6 +32,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.JSType;
|
||||
import jdk.nashorn.internal.runtime.PropertyMap;
|
||||
import jdk.nashorn.internal.runtime.ScriptObject;
|
||||
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)
|
||||
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) {
|
||||
|
@ -32,6 +32,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.JSType;
|
||||
import jdk.nashorn.internal.runtime.PropertyMap;
|
||||
import jdk.nashorn.internal.runtime.ScriptObject;
|
||||
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)
|
||||
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) {
|
||||
|
@ -38,6 +38,7 @@ import jdk.nashorn.internal.parser.Parser;
|
||||
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 @@ import jdk.nashorn.internal.runtime.Source;
|
||||
*/
|
||||
@ScriptClass("Function")
|
||||
public final class NativeFunction {
|
||||
|
||||
// initialized by nasgen
|
||||
private static PropertyMap $nasgenmap$;
|
||||
|
||||
// do *not* create me!
|
||||
private NativeFunction() {
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import jdk.nashorn.internal.objects.annotations.Function;
|
||||
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 @@ import jdk.nashorn.internal.runtime.arrays.ArrayData;
|
||||
*/
|
||||
@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.
|
||||
*/
|
||||
|
@ -31,6 +31,7 @@ import jdk.nashorn.internal.objects.annotations.Function;
|
||||
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 @@ public final class NativeInt32Array extends ArrayBufferView {
|
||||
@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) {
|
||||
|
@ -31,6 +31,7 @@ import jdk.nashorn.internal.objects.annotations.Function;
|
||||
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 @@ public final class NativeInt8Array extends ArrayBufferView {
|
||||
@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) {
|
||||
|
@ -42,6 +42,7 @@ import jdk.nashorn.internal.objects.annotations.Constructor;
|
||||
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 @@ 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);
|
||||
|
||||
// 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;
|
||||
|
@ -42,6 +42,7 @@ import jdk.nashorn.internal.objects.annotations.Where;
|
||||
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 @@ public final class NativeJSON extends ScriptObject {
|
||||
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$);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,6 +40,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.ListAdapter;
|
||||
import jdk.nashorn.internal.runtime.PropertyMap;
|
||||
import jdk.nashorn.internal.runtime.ScriptObject;
|
||||
import jdk.nashorn.internal.runtime.linker.JavaAdapterFactory;
|
||||
|
||||
@ -52,6 +53,9 @@ import jdk.nashorn.internal.runtime.linker.JavaAdapterFactory;
|
||||
@ScriptClass("Java")
|
||||
public final class NativeJava {
|
||||
|
||||
// initialized by nasgen
|
||||
private static PropertyMap $nasgenmap$;
|
||||
|
||||
private NativeJava() {
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ import jdk.nashorn.internal.objects.annotations.Constructor;
|
||||
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 @@ import jdk.nashorn.internal.runtime.ScriptObject;
|
||||
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
|
||||
|
@ -32,6 +32,7 @@ import jdk.nashorn.internal.objects.annotations.ScriptClass;
|
||||
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 @@ import jdk.nashorn.internal.runtime.ScriptObject;
|
||||
@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 */
|
||||
|
@ -45,6 +45,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.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 @@ public final class NativeNumber extends ScriptObject {
|
||||
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
|
||||
|
@ -36,6 +36,7 @@ import jdk.nashorn.internal.objects.annotations.ScriptClass;
|
||||
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 @@ import jdk.nashorn.internal.runtime.linker.InvokeByName;
|
||||
public final class NativeObject {
|
||||
private static final InvokeByName TO_STRING = new InvokeByName("toString", ScriptObject.class);
|
||||
|
||||
// initialized by nasgen
|
||||
private static PropertyMap $nasgenmap$;
|
||||
|
||||
private NativeObject() {
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,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.JSType;
|
||||
import jdk.nashorn.internal.runtime.PropertyMap;
|
||||
import jdk.nashorn.internal.runtime.ScriptObject;
|
||||
|
||||
/**
|
||||
@ -54,8 +55,11 @@ public final class NativeRangeError extends ScriptObject {
|
||||
@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 {
|
||||
|
@ -33,6 +33,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.JSType;
|
||||
import jdk.nashorn.internal.runtime.PropertyMap;
|
||||
import jdk.nashorn.internal.runtime.ScriptObject;
|
||||
|
||||
/**
|
||||
@ -54,8 +55,11 @@ public final class NativeReferenceError extends ScriptObject {
|
||||
@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 {
|
||||
|
@ -43,6 +43,7 @@ import jdk.nashorn.internal.objects.annotations.Where;
|
||||
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 @@ public final class NativeRegExp extends ScriptObject {
|
||||
// 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);
|
||||
|
@ -31,6 +31,7 @@ import jdk.nashorn.internal.objects.annotations.Property;
|
||||
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 @@ public final class NativeRegExpExecResult extends ScriptObject {
|
||||
@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();
|
||||
|
@ -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);
|
||||
|
||||
// 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 @@ public final class NativeStrictArguments extends ScriptObject {
|
||||
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 @@ public final class NativeStrictArguments extends ScriptObject {
|
||||
Arrays.fill(namedArgs, UNDEFINED);
|
||||
}
|
||||
System.arraycopy(values, 0, namedArgs, 0, Math.min(namedArgs.length, values.length));
|
||||
|
||||
this.setProto(Global.objectPrototype());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,6 +52,7 @@ import jdk.nashorn.internal.objects.annotations.SpecializedFunction;
|
||||
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 @@ public final class NativeString extends ScriptObject {
|
||||
|
||||
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
|
||||
|
@ -33,6 +33,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.JSType;
|
||||
import jdk.nashorn.internal.runtime.PropertyMap;
|
||||
import jdk.nashorn.internal.runtime.ScriptObject;
|
||||
|
||||
/**
|
||||
@ -54,8 +55,11 @@ public final class NativeSyntaxError extends ScriptObject {
|
||||
@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 {
|
||||
|
@ -33,6 +33,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.JSType;
|
||||
import jdk.nashorn.internal.runtime.PropertyMap;
|
||||
import jdk.nashorn.internal.runtime.ScriptObject;
|
||||
|
||||
/**
|
||||
@ -54,8 +55,11 @@ public final class NativeTypeError extends ScriptObject {
|
||||
@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 {
|
||||
|
@ -33,6 +33,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.JSType;
|
||||
import jdk.nashorn.internal.runtime.PropertyMap;
|
||||
import jdk.nashorn.internal.runtime.ScriptObject;
|
||||
|
||||
/**
|
||||
@ -53,8 +54,11 @@ public final class NativeURIError extends ScriptObject {
|
||||
@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 {
|
||||
|
@ -31,6 +31,7 @@ import jdk.nashorn.internal.objects.annotations.Function;
|
||||
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 @@ public final class NativeUint16Array extends ArrayBufferView {
|
||||
@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) {
|
||||
|
@ -32,6 +32,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.JSType;
|
||||
import jdk.nashorn.internal.runtime.PropertyMap;
|
||||
import jdk.nashorn.internal.runtime.ScriptObject;
|
||||
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)
|
||||
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) {
|
||||
|
@ -31,6 +31,7 @@ import jdk.nashorn.internal.objects.annotations.Function;
|
||||
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 @@ public final class NativeUint8Array extends ArrayBufferView {
|
||||
@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) {
|
||||
|
@ -32,6 +32,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.JSType;
|
||||
import jdk.nashorn.internal.runtime.PropertyMap;
|
||||
import jdk.nashorn.internal.runtime.ScriptObject;
|
||||
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)
|
||||
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) {
|
||||
|
@ -44,7 +44,7 @@ import jdk.nashorn.internal.lookup.MethodHandleFactory;
|
||||
*
|
||||
*/
|
||||
public class PrototypeObject extends ScriptObject {
|
||||
private static final PropertyMap nasgenmap$;
|
||||
private static final PropertyMap map$;
|
||||
|
||||
private Object constructor;
|
||||
|
||||
@ -54,11 +54,11 @@ public class PrototypeObject extends ScriptObject {
|
||||
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 @@ public class PrototypeObject extends ScriptObject {
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class ScriptFunctionImpl extends ScriptFunction {
|
||||
// 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 @@ public class ScriptFunctionImpl extends ScriptFunction {
|
||||
* @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 @@ public class ScriptFunctionImpl extends ScriptFunction {
|
||||
* @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 @@ public class ScriptFunctionImpl extends ScriptFunction {
|
||||
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 @@ public class ScriptFunctionImpl extends ScriptFunction {
|
||||
|
||||
// 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) {
|
||||
|
@ -101,13 +101,7 @@ public final class Context {
|
||||
/** 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
|
||||
|
@ -54,9 +54,8 @@ public class FunctionScope extends ScriptObject implements Scope {
|
||||
* @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 @@ public class FunctionScope extends ScriptObject implements Scope {
|
||||
* @param callerScope caller scope
|
||||
*/
|
||||
public FunctionScope(final PropertyMap map, final ScriptObject callerScope) {
|
||||
super(map);
|
||||
super(callerScope, map);
|
||||
this.arguments = null;
|
||||
setProto(callerScope);
|
||||
setIsScope();
|
||||
}
|
||||
|
||||
|
@ -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 final class PropertyMap implements Iterable<Object>, PropertyListener {
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -170,13 +170,30 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr
|
||||
}
|
||||
|
||||
this.arrayData = ArrayData.EMPTY_ARRAY;
|
||||
this.setMap(map == null ? PropertyMap.newMap(getClass()) : map);
|
||||
}
|
||||
|
||||
if (map == null) {
|
||||
this.setMap(PropertyMap.newMap(getClass()));
|
||||
return;
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,11 +32,14 @@ import jdk.nashorn.internal.runtime.ScriptObject;
|
||||
* 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$);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -48,6 +51,15 @@ public class JO extends ScriptObject {
|
||||
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.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user