jdk.nashorn.internal.runtime.PropertyMap的实例源码

项目:Openjsharp    文件NativeDebug.java   
/**
 * Dump all Nashorn debug mode counters. Calling this may be better if
 * you want to print all counters. This way you can avoid too many callsites
 * due to counter access itself!!
 * @param self self reference
 * @return undefined
 */
@Function(attributes = Attribute.NOT_ENUMERABLE,where = Where.CONSTRUCTOR)
public static Object dumpCounters(final Object self) {
    final PrintWriter out = Context.getCurrentErr();

    out.println("ScriptObject count " + ScriptObject.getCount());
    out.println("Scope count " + ScriptObject.getScopeCount());
    out.println("ScriptObject listeners added " + PropertyListeners.getListenersAdded());
    out.println("ScriptObject listeners removed " + PropertyListeners.getListenersRemoved());
    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());
    out.println("PropertyMap cloned " + PropertyMap.getClonedCount());
    out.println("PropertyMap history hit " + PropertyMap.getHistoryHit());
    out.println("PropertyMap proto invalidations " + PropertyMap.getProtoInvalidations());
    out.println("PropertyMap proto history hit " + PropertyMap.getProtoHistoryHit());
    out.println("PropertyMap setProtoNewMapCount " + PropertyMap.getSetProtoNewMapCount());
    out.println("Callsite count " + LinkerCallSite.getCount());
    out.println("Callsite misses " + LinkerCallSite.getMissCount());
    out.println("Callsite misses by site at " + LinkerCallSite.getMissSamplingPercentage() + "%");

    LinkerCallSite.getMissCounts(out);

    return UNDEFINED;
}
项目:Openjsharp    文件NativeStrictArguments.java   
NativeStrictArguments(final Object[] values,final int numParams,final ScriptObject proto,final PropertyMap map) {
    super(proto,map);
    setIsArguments();

    final ScriptFunction func = Global.instance().getTypeErrorThrower();
    // We have to fill user accessor functions late as these are stored
    // in this object rather than in the PropertyMap of this object.
    final int flags = Property.NOT_ENUMERABLE | Property.NOT_CONfigURABLE;
    initUserAccessors("caller",flags,func,func);
    initUserAccessors("callee",func);

    setArray(ArrayData.allocate(values));
    this.length = values.length;

    // extend/truncate named arg array as needed and copy values
    this.namedArgs = new Object[numParams];
    if (numParams > values.length) {
        Arrays.fill(namedArgs,UNDEFINED);
    }
    System.arraycopy(values,namedArgs,Math.min(namedArgs.length,values.length));
}
项目:Openjsharp    文件MapCreator.java   
/**
 * Constructs a property map based on a set of fields.
 *
 * @param hasArguments  does the created object have an "arguments" property
 * @param fieldCount    Number of fields in use.
 * @param fieldMaximum  Number of fields available.
 * @param evalCode      is this property map created for 'eval' code?
 * @return New map populated with accessor properties.
 */
PropertyMap makeFieldMap(final boolean hasArguments,final int fieldCount,final int fieldMaximum,final boolean evalCode) {
    final List<Property> properties = new ArrayList<>();
    assert tuples != null;

    for (final MapTuple<T> tuple : tuples) {
        final String   key         = tuple.key;
        final Symbol   symbol      = tuple.symbol;
        final Class<?> initialType = tuple.getValueType();

        if (symbol != null && !isValidArrayIndex(getArrayIndex(key))) {
            final int      flags    = getPropertyFlags(symbol,hasArguments,evalCode);
            final Property property = new AccessorProperty(
                    key,structure,symbol.getFieldindex(),initialType);
            properties.add(property);
        }
    }

    return PropertyMap.newMap(properties,structure.getName(),fieldCount,fieldMaximum,0);
}
项目:Openjsharp    文件MapCreator.java   
PropertyMap makeSpillMap(final boolean hasArguments) {
    final List<Property> properties = new ArrayList<>();
    int spillIndex = 0;
    assert tuples != null;

    for (final MapTuple<T> tuple : tuples) {
        final String key    = tuple.key;
        final Symbol symbol = tuple.symbol;

        //Todo initial type is object here no matter what. Is that right?
        if (symbol != null && !isValidArrayIndex(getArrayIndex(key))) {
            final int flags = getPropertyFlags(symbol,false);
            properties.add(
                    new SpillProperty(
                            key,spillIndex++));
        }
    }

    return PropertyMap.newMap(properties,spillIndex);
}
项目:Openjsharp    文件CodeGenerator.java   
private void loadConstant(final Object object,final CompileUnit compileUnit,final MethodEmitter methodEmitter) {
    final String       unitClassName = compileUnit.getUnitClassName();
    final ClassEmitter classEmitter  = compileUnit.getClassEmitter();
    final int          index         = compiler.getConstantData().add(object);
    final Class<?>     cls           = object.getClass();

    if (cls == PropertyMap.class) {
        methodEmitter.load(index);
        methodEmitter.invokestatic(unitClassName,GET_MAP.symbolName(),methodDescriptor(PropertyMap.class,int.class));
        classEmitter.needGetConstantMethod(PropertyMap.class);
    } else if (cls.isArray()) {
        methodEmitter.load(index);
        final String methodName = ClassEmitter.getArrayMethodName(cls);
        methodEmitter.invokestatic(unitClassName,methodName,methodDescriptor(cls,int.class));
        classEmitter.needGetConstantMethod(cls);
    } else {
        methodEmitter.loadConstants().load(index).arrayload();
        if (object instanceof ArrayData) {
            // avoid cast to non-public ArrayData subclass
            methodEmitter.checkcast(ArrayData.class);
            methodEmitter.invoke(virtualCallNoLookup(ArrayData.class,"copy",ArrayData.class));
        } else if (cls != Object.class) {
            methodEmitter.checkcast(cls);
        }
    }
}
项目:openjdk-jdk10    文件JSONParser.java   
private PropertyMap addobjectProperty(final PropertyMap propertyMap,final List<Object> values,final String id,final Object value) {
    final Property oldProperty = propertyMap.findProperty(id);
    final PropertyMap newMap;
    final Class<?> type;
    final int flags;
    if (dualFields) {
        type = getType(value);
        flags = Property.DUAL_FIELDS;
    } else {
        type = Object.class;
        flags = 0;
    }

    if (oldProperty != null) {
        values.set(oldProperty.getSlot(),value);
        newMap = propertyMap.replaceProperty(oldProperty,new SpillProperty(id,oldProperty.getSlot(),type));;
    } else {
        values.add(value);
        newMap = propertyMap.addProperty(new SpillProperty(id,propertyMap.size(),type));
    }

    return newMap;
}
项目:openjdk-jdk10    文件JSONParser.java   
private Object createObject(final PropertyMap propertyMap,final ArrayData arrayData) {
    final long[] primitiveSpill = dualFields ? new long[values.size()] : null;
    final Object[] objectSpill = new Object[values.size()];

    for (final Property property : propertyMap.getProperties()) {
        if (!dualFields || property.getType() == Object.class) {
            objectSpill[property.getSlot()] = values.get(property.getSlot());
        } else {
            primitiveSpill[property.getSlot()] = ObjectClassGenerator.pack((Number) values.get(property.getSlot()));
        }
    }

    final ScriptObject object = dualFields ?
            new JD(propertyMap,primitiveSpill,objectSpill) : new JO(propertyMap,null,objectSpill);
    object.setinitialProto(global.getobjectPrototype());
    object.setArray(arrayData);
    return object;
}
项目:openjdk-jdk10    文件NativeDebug.java   
/**
 * Dump all Nashorn debug mode counters. Calling this may be better if
 * you want to print all counters. This way you can avoid too many callsites
 * due to counter access itself!!
 * @param self self reference
 * @return undefined
 */
@Function(attributes = Attribute.NOT_ENUMERABLE,where = Where.CONSTRUCTOR)
public static Object dumpCounters(final Object self) {
    final PrintWriter out = Context.getCurrentErr();

    out.println("ScriptObject count " + ScriptObject.getCount());
    out.println("Scope count " + Scope.getScopeCount());
    out.println("ScriptObject listeners added " + PropertyListeners.getListenersAdded());
    out.println("ScriptObject listeners removed " + PropertyListeners.getListenersRemoved());
    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());
    out.println("PropertyMap cloned " + PropertyMap.getClonedCount());
    out.println("PropertyMap history hit " + PropertyMap.getHistoryHit());
    out.println("PropertyMap proto invalidations " + PropertyMap.getProtoInvalidations());
    out.println("PropertyMap proto history hit " + PropertyMap.getProtoHistoryHit());
    out.println("PropertyMap setProtoNewMapCount " + PropertyMap.getSetProtoNewMapCount());
    out.println("Callsite count " + LinkerCallSite.getCount());
    out.println("Callsite misses " + LinkerCallSite.getMissCount());
    out.println("Callsite misses by site at " + LinkerCallSite.getMissSamplingPercentage() + "%");

    LinkerCallSite.getMissCounts(out);

    return UNDEFINED;
}
项目:openjdk-jdk10    文件NativeStrictArguments.java   
NativeStrictArguments(final Object[] values,values.length));
}
项目:openjdk-jdk10    文件MapCreator.java   
/**
 * Constructs a property map based on a set of fields.
 *
 * @param hasArguments  does the created object have an "arguments" property
 * @param fieldCount    Number of fields in use.
 * @param fieldMaximum  Number of fields available.
 * @param evalCode      is this property map created for 'eval' code?
 * @return New map populated with accessor properties.
 */
PropertyMap makeFieldMap(final boolean hasArguments,final boolean dualFields,final boolean evalCode) {
    final List<Property> properties = new ArrayList<>();
    assert tuples != null;

    for (final MapTuple<T> tuple : tuples) {
        final String   key         = tuple.key;
        final Symbol   symbol      = tuple.symbol;
        final Class<?> initialType = dualFields ? tuple.getValueType() : Object.class;

        if (symbol != null && !isValidArrayIndex(getArrayIndex(key))) {
            final int      flags    = getPropertyFlags(symbol,evalCode,dualFields);
            final Property property = new AccessorProperty(
                    key,0);
}
项目:openjdk-jdk10    文件MapCreator.java   
PropertyMap makeSpillMap(final boolean hasArguments,final boolean dualFields) {
    final List<Property> properties = new ArrayList<>();
    int spillIndex = 0;
    assert tuples != null;

    for (final MapTuple<T> tuple : tuples) {
        final String key    = tuple.key;
        final Symbol symbol = tuple.symbol;
        final Class<?> initialType = dualFields ? tuple.getValueType() : Object.class;

        if (symbol != null && !isValidArrayIndex(getArrayIndex(key))) {
            final int flags = getPropertyFlags(symbol,false,dualFields);
            properties.add(
                    new SpillProperty(
                            key,spillIndex++,initialType));
        }
    }

    return PropertyMap.newMap(properties,spillIndex);
}
项目:openjdk-jdk10    文件CodeGenerator.java   
private void loadConstant(final Object object,int.class));
        classEmitter.needGetConstantMethod(cls);
    } else {
        methodEmitter.loadConstants().load(index).arrayload();
        if (object instanceof ArrayData) {
            methodEmitter.checkcast(ArrayData.class);
            methodEmitter.invoke(virtualCallNoLookup(ArrayData.class,ArrayData.class));
        } else if (cls != Object.class) {
            methodEmitter.checkcast(cls);
        }
    }
}
项目:Openjsharp    文件NativeJSAdapter.java   
NativeJSAdapter(final Object overrides,final ScriptObject adaptee,map);
    this.adaptee = wrapAdaptee(adaptee);
    if (overrides instanceof ScriptObject) {
        this.overrides = true;
        final ScriptObject sobj = (ScriptObject)overrides;
        this.addBoundProperties(sobj);
    } else {
        this.overrides = false;
    }
}
项目:Openjsharp    文件NativeArguments.java   
NativeArguments(final Object[] arguments,final Object callee,map);
    setIsArguments();
    setArray(ArrayData.allocate(arguments));
    this.length = arguments.length;
    this.callee = callee;
    this.numMapped = Math.min(numParams,arguments.length);
    this.numParams = numParams;
}
项目:Openjsharp    文件Global.java   
private static PropertyMap checkAndGetMap(final Context context) {
    // security check first
    final SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        sm.checkPermission(new RuntimePermission(Context.NASHORN_CREATE_GLOBAL));
    }

    // null check on context
    context.getClass();

    return $nasgenmap$;
}
项目:Openjsharp    文件ScriptFunctionImpl.java   
private static PropertyMap createStrictModeMap(final PropertyMap map) {
    final int flags = Property.NOT_ENUMERABLE | Property.NOT_CONfigURABLE;
    PropertyMap newMap = map;
    // Need to add properties directly to map since slots are assigned speculatively by newUserAccessors.
    newMap = newMap.addPropertyNoHistory(map.newUserAccessors("arguments",flags));
    newMap = newMap.addPropertyNoHistory(map.newUserAccessors("caller",flags));
    return newMap;
}
项目:Openjsharp    文件NativeDate.java   
private NativeDate(final double time,map);
    final ScriptEnvironment env = Global.getEnv();

    this.time = time;
    this.timezone = env._timezone;
}
项目:Openjsharp    文件NativeReferenceError.java   
@SuppressWarnings("LeakingThisInConstructor")
private NativeReferenceError(final Object msg,map);
    if (msg != UNDEFINED) {
        this.instMessage = JSType.toString(msg);
    } else {
        this.delete(NativeError.MESSAGE,false);
    }
    NativeError.initException(this);
}
项目:Openjsharp    文件NativeevalError.java   
@SuppressWarnings("LeakingThisInConstructor")
private NativeevalError(final Object msg,false);
    }
    NativeError.initException(this);
}
项目:Openjsharp    文件ObjectClassGenerator.java   
private static MethodEmitter newInitWithSpillArraysMethod(final ClassEmitter classEmitter,final Class<?> superClass) {
    final MethodEmitter init = classEmitter.init(PropertyMap.class,long[].class,Object[].class);
    init.begin();
    init.load(Type.OBJECT,JAVA_THIS.slot());
    init.load(Type.OBJECT,INIT_MAP.slot());
    init.load(Type.LONG_ARRAY,2);
    init.load(Type.OBJECT_ARRAY,3);
    init.invoke(constructorNoLookup(superClass,PropertyMap.class,Object[].class));

    return init;
}
项目:Openjsharp    文件ObjectClassGenerator.java   
/**
 * Allocate and initialize a new <init> method for scopes.
 * @param classEmitter  Open class emitter.
 * @return Open method emitter.
 */
private static MethodEmitter newInitScopeMethod(final ClassEmitter classEmitter) {
    final MethodEmitter init = classEmitter.init(PropertyMap.class,ScriptObject.class);
    init.begin();
    init.load(Type.OBJECT,INIT_MAP.slot());
    init.load(Type.OBJECT,INIT_ScopE.slot());
    init.invoke(constructorNoLookup(FunctionScope.class,ScriptObject.class));

    return init;
}
项目:Openjsharp    文件ObjectClassGenerator.java   
/**
 * Allocate and initialize a new <init> method for scopes with arguments.
 * @param classEmitter  Open class emitter.
 * @return Open method emitter.
 */
private static MethodEmitter newInitScopeWithArgumentsMethod(final ClassEmitter classEmitter) {
    final MethodEmitter init = classEmitter.init(PropertyMap.class,ScriptObject.class,INIT_ScopE.slot());
    init.load(Type.OBJECT,INIT_ARGUMENTS.slot());
    init.invoke(constructorNoLookup(FunctionScope.class,ScriptObject.class));

    return init;
}
项目:Openjsharp    文件ObjectClassGenerator.java   
/**
 * Add an empty <init> method to the JavaScript class.
 *
 * @param classEmitter Open class emitter.
 * @param className    Name of JavaScript class.
 */
private static void newEmptyInit(final String className,final ClassEmitter classEmitter) {
    final MethodEmitter emptyInit = classEmitter.init();
    emptyInit.begin();
    emptyInit.load(Type.OBJECT,JAVA_THIS.slot());
    emptyInit.loadNull();
    emptyInit.invoke(constructorNoLookup(className,PropertyMap.class));
    emptyInit.returnVoid();
    emptyInit.end();
}
项目:Openjsharp    文件ObjectClassGenerator.java   
/**
 * Add an empty <init> method to the JavaScript class.
 *
 * @param classEmitter Open class emitter.
 * @param className    Name of JavaScript class.
 */
private static void newAllocate(final String className,final ClassEmitter classEmitter) {
    final MethodEmitter allocate = classEmitter.method(EnumSet.of(Flag.PUBLIC,Flag.STATIC),ALLOCATE.symbolName(),PropertyMap.class);
    allocate.begin();
    allocate._new(className,Type.typeFor(ScriptObject.class));
    allocate.dup();
    allocate.load(Type.typeFor(PropertyMap.class),0);
    allocate.invoke(constructorNoLookup(className,PropertyMap.class));
    allocate._return();
    allocate.end();
}
项目:openjdk-jdk10    文件NativeError.java   
@SuppressWarnings("LeakingThisInConstructor")
private NativeError(final Object msg,false);
    }
    initException(this);
}
项目:openjdk-jdk10    文件NativeJSAdapter.java   
NativeJSAdapter(final Object overrides,map);
    this.adaptee = wrapAdaptee(adaptee);
    if (overrides instanceof ScriptObject) {
        this.overrides = true;
        final ScriptObject sobj = (ScriptObject)overrides;
        this.addBoundProperties(sobj);
    } else {
        this.overrides = false;
    }
}
项目:openjdk-jdk10    文件NativeArguments.java   
NativeArguments(final Object[] arguments,arguments.length);
    this.numParams = numParams;
}
项目:openjdk-jdk10    文件Global.java   
private static PropertyMap checkAndGetMap(final Context context) {
    // security check first
    final SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        sm.checkPermission(new RuntimePermission(Context.NASHORN_CREATE_GLOBAL));
    }

    Objects.requireNonNull(context);

    return $nasgenmap$;
}
项目:openjdk-jdk10    文件NativeDate.java   
private NativeDate(final double time,map);
    final ScriptEnvironment env = Global.getEnv();

    this.time = time;
    this.timezone = env._timezone;
}
项目:openjdk-jdk10    文件NativeReferenceError.java   
@SuppressWarnings("LeakingThisInConstructor")
private NativeReferenceError(final Object msg,false);
    }
    NativeError.initException(this);
}
项目:openjdk-jdk10    文件NativeRangeError.java   
@SuppressWarnings("LeakingThisInConstructor")
private NativeRangeError(final Object msg,false);
    }
    NativeError.initException(this);
}
项目:openjdk-jdk10    文件NativeevalError.java   
@SuppressWarnings("LeakingThisInConstructor")
private NativeevalError(final Object msg,false);
    }
    NativeError.initException(this);
}
项目:openjdk-jdk10    文件SpillObjectCreator.java   
@Override
protected PropertyMap makeMap() {
    assert propertyMap == null : "property map already initialized";
    final Class<? extends ScriptObject> clazz = getAllocatorClass();
    propertyMap = new MapCreator<>(clazz,tuples).makeSpillMap(false,codegen.useDualFields());
    return propertyMap;
}
项目:openjdk-jdk10    文件ConstantData.java   
@Override
public boolean equals(final Object other) {
    if (!(other instanceof PropertyMapWrapper)) {
        return false;
    }
    final PropertyMap otherMap = ((PropertyMapWrapper) other).propertyMap;
    return propertyMap == otherMap
            || (Arrays.equals(propertyMap.getProperties(),otherMap.getProperties())
                && Objects.equals(propertyMap.getClassName(),otherMap.getClassName()));
}
项目:openjdk-jdk10    文件ObjectClassGenerator.java   
/**
 * Allocate and initialize a new <init> method.
 *
 * @param classEmitter  Open class emitter.
 *
 * @return Open method emitter.
 */
private static MethodEmitter newInitMethod(final ClassEmitter classEmitter) {
    final MethodEmitter init = classEmitter.init(PropertyMap.class);
    init.begin();
    init.load(Type.OBJECT,INIT_MAP.slot());
    init.invoke(constructorNoLookup(ScriptObject.class,PropertyMap.class));

    return init;
}
项目:openjdk-jdk10    文件ObjectClassGenerator.java   
private static MethodEmitter newInitWithSpillArraysMethod(final ClassEmitter classEmitter,Object[].class));

    return init;
}
项目:openjdk-jdk10    文件ObjectClassGenerator.java   
/**
 * Allocate and initialize a new <init> method for scopes.
 * @param classEmitter  Open class emitter.
 * @return Open method emitter.
 */
private static MethodEmitter newInitScopeMethod(final ClassEmitter classEmitter) {
    final MethodEmitter init = classEmitter.init(PropertyMap.class,ScriptObject.class));

    return init;
}
项目:openjdk-jdk10    文件ObjectClassGenerator.java   
/**
 * Allocate and initialize a new <init> method for scopes with arguments.
 * @param classEmitter  Open class emitter.
 * @return Open method emitter.
 */
private static MethodEmitter newInitScopeWithArgumentsMethod(final ClassEmitter classEmitter) {
    final MethodEmitter init = classEmitter.init(PropertyMap.class,ScriptObject.class));

    return init;
}
项目:openjdk-jdk10    文件ObjectClassGenerator.java   
/**
 * Add an empty <init> method to the JavaScript class.
 *
 * @param classEmitter Open class emitter.
 * @param className    Name of JavaScript class.
 */
private static void newEmptyInit(final String className,PropertyMap.class));
    emptyInit.returnVoid();
    emptyInit.end();
}
项目:openjdk-jdk10    文件ObjectClassGenerator.java   
/**
 * Add an empty <init> method to the JavaScript class.
 *
 * @param classEmitter Open class emitter.
 * @param className    Name of JavaScript class.
 */
private static void newAllocate(final String className,PropertyMap.class));
    allocate._return();
    allocate.end();
}

相关文章

买水果
比较全面的redis工具类
gson 反序列化到多态子类
java 版本的 mb_strwidth
JAVA 反转字符串的最快方法,大概比StringBuffer.reverse()性...
com.google.gson.internal.bind.ArrayTypeAdapter的实例源码...