jdk.nashorn.internal.codegen.ObjectClassGenerator Java Examples

The following examples show how to use jdk.nashorn.internal.codegen.ObjectClassGenerator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: TencentKona-8   Author: Tencent   File: JSONParser.java    License: GNU General Public License v2.0 6 votes vote down vote up
private Object createObject(final PropertyMap propertyMap, final List<Object> values, 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;
}
 
Example #2
Source Project: jdk8u60   Author: chenghanpeng   File: JSONParser.java    License: GNU General Public License v2.0 6 votes vote down vote up
private Object createObject(final PropertyMap propertyMap, final List<Object> values, 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;
}
 
Example #3
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: JSONParser.java    License: GNU General Public License v2.0 6 votes vote down vote up
private Object createObject(final PropertyMap propertyMap, final List<Object> values, 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;
}
 
Example #4
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: JSONParser.java    License: GNU General Public License v2.0 6 votes vote down vote up
private Object createObject(final PropertyMap propertyMap, final List<Object> values, 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;
}
 
Example #5
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: JSONParser.java    License: GNU General Public License v2.0 6 votes vote down vote up
private Object createObject(final PropertyMap propertyMap, final List<Object> values, 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;
}
 
Example #6
Source Project: hottub   Author: dsrg-uoft   File: JSONParser.java    License: GNU General Public License v2.0 6 votes vote down vote up
private Object createObject(final PropertyMap propertyMap, final List<Object> values, 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;
}
 
Example #7
Source Project: jdk8u_nashorn   Author: JetBrains   File: JSONParser.java    License: GNU General Public License v2.0 6 votes vote down vote up
private Object createObject(final PropertyMap propertyMap, final List<Object> values, 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;
}
 
Example #8
Source Project: TencentKona-8   Author: Tencent   File: StructureLoader.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generate a layout class.
 * @param name       Name of class.
 * @param descriptor Layout descriptor.
 * @return Generated class.
 */
private Class<?> generateClass(final String name, final String descriptor, final boolean dualFields) {
    final Context context = Context.getContextTrusted();

    final byte[] code = new ObjectClassGenerator(context, dualFields).generate(descriptor);
    return defineClass(name, code, 0, code.length, new ProtectionDomain(null, getPermissions(null)));
}
 
Example #9
Source Project: TencentKona-8   Author: Tencent   File: AllocationStrategy.java    License: GNU General Public License v2.0 5 votes vote down vote up
private String getAllocatorClassName() {
    if (allocatorClassName == null) {
        // These classes get loaded, so an interned variant of their name is most likely around anyway.
        allocatorClassName = Compiler.binaryName(ObjectClassGenerator.getClassName(fieldCount, dualFields)).intern();
    }
    return allocatorClassName;
}
 
Example #10
Source Project: jdk8u60   Author: chenghanpeng   File: StructureLoader.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generate a layout class.
 * @param name       Name of class.
 * @param descriptor Layout descriptor.
 * @return Generated class.
 */
private Class<?> generateClass(final String name, final String descriptor, final boolean dualFields) {
    final Context context = Context.getContextTrusted();

    final byte[] code = new ObjectClassGenerator(context, dualFields).generate(descriptor);
    return defineClass(name, code, 0, code.length, new ProtectionDomain(null, getPermissions(null)));
}
 
Example #11
Source Project: jdk8u60   Author: chenghanpeng   File: AllocationStrategy.java    License: GNU General Public License v2.0 5 votes vote down vote up
private String getAllocatorClassName() {
    if (allocatorClassName == null) {
        // These classes get loaded, so an interned variant of their name is most likely around anyway.
        allocatorClassName = Compiler.binaryName(ObjectClassGenerator.getClassName(fieldCount, dualFields)).intern();
    }
    return allocatorClassName;
}
 
Example #12
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: StructureLoader.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generate a layout class.
 * @param name       Name of class.
 * @param descriptor Layout descriptor.
 * @return Generated class.
 */
private Class<?> generateClass(final String name, final String descriptor, final boolean dualFields) {
    final Context context = Context.getContextTrusted();

    final byte[] code = new ObjectClassGenerator(context, dualFields).generate(descriptor);
    return defineClass(name, code, 0, code.length, new ProtectionDomain(null, getPermissions(null)));
}
 
Example #13
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: AllocationStrategy.java    License: GNU General Public License v2.0 5 votes vote down vote up
private String getAllocatorClassName() {
    if (allocatorClassName == null) {
        // These classes get loaded, so an interned variant of their name is most likely around anyway.
        allocatorClassName = Compiler.binaryName(ObjectClassGenerator.getClassName(fieldCount, dualFields)).intern();
    }
    return allocatorClassName;
}
 
Example #14
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: StructureLoader.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generate a layout class.
 * @param name       Name of class.
 * @param descriptor Layout descriptor.
 * @return Generated class.
 */
private Class<?> generateClass(final String name, final String descriptor, final boolean dualFields) {
    final Context context = Context.getContextTrusted();

    final byte[] code = new ObjectClassGenerator(context, dualFields).generate(descriptor);
    return defineClass(name, code, 0, code.length, new ProtectionDomain(null, getPermissions(null)));
}
 
Example #15
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: AllocationStrategy.java    License: GNU General Public License v2.0 5 votes vote down vote up
private String getAllocatorClassName() {
    if (allocatorClassName == null) {
        // These classes get loaded, so an interned variant of their name is most likely around anyway.
        allocatorClassName = Compiler.binaryName(ObjectClassGenerator.getClassName(fieldCount, dualFields)).intern();
    }
    return allocatorClassName;
}
 
Example #16
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: ScriptObject.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static GuardedInvocation findMegaMorphicSetMethod(final CallSiteDescriptor desc, final String name) {
    Context.getContextTrusted().getLogger(ObjectClassGenerator.class).warning("Megamorphic setter: ", desc, " ", name);
    final MethodType        type = desc.getMethodType().insertParameterTypes(1, Object.class);
    //never bother with ClassCastExceptionGuard for megamorphic callsites
    final GuardedInvocation inv = findSetIndexMethod(desc, false, type);
    return inv.replaceMethods(MH.insertArguments(inv.getInvocation(), 1, name), inv.getGuard());
}
 
Example #17
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: StructureLoader.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generate a layout class.
 * @param name       Name of class.
 * @param descriptor Layout descriptor.
 * @return Generated class.
 */
private Class<?> generateClass(final String name, final String descriptor, final boolean dualFields) {
    final Context context = Context.getContextTrusted();

    final byte[] code = new ObjectClassGenerator(context, dualFields).generate(descriptor);
    return defineClass(name, code, 0, code.length, new ProtectionDomain(null, getPermissions(null)));
}
 
Example #18
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: AllocationStrategy.java    License: GNU General Public License v2.0 5 votes vote down vote up
private String getAllocatorClassName() {
    if (allocatorClassName == null) {
        // These classes get loaded, so an interned variant of their name is most likely around anyway.
        allocatorClassName = Compiler.binaryName(ObjectClassGenerator.getClassName(fieldCount, dualFields)).intern();
    }
    return allocatorClassName;
}
 
Example #19
Source Project: hottub   Author: dsrg-uoft   File: StructureLoader.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generate a layout class.
 * @param name       Name of class.
 * @param descriptor Layout descriptor.
 * @return Generated class.
 */
private Class<?> generateClass(final String name, final String descriptor, final boolean dualFields) {
    final Context context = Context.getContextTrusted();

    final byte[] code = new ObjectClassGenerator(context, dualFields).generate(descriptor);
    return defineClass(name, code, 0, code.length, new ProtectionDomain(null, getPermissions(null)));
}
 
Example #20
Source Project: hottub   Author: dsrg-uoft   File: AllocationStrategy.java    License: GNU General Public License v2.0 5 votes vote down vote up
private String getAllocatorClassName() {
    if (allocatorClassName == null) {
        // These classes get loaded, so an interned variant of their name is most likely around anyway.
        allocatorClassName = Compiler.binaryName(ObjectClassGenerator.getClassName(fieldCount, dualFields)).intern();
    }
    return allocatorClassName;
}
 
Example #21
Source Project: openjdk-8-source   Author: keerath   File: AccessorProperty.java    License: GNU General Public License v2.0 5 votes vote down vote up
public GettersSetters(Class<?> structure) {
    final int fieldCount = ObjectClassGenerator.getFieldCount(structure);
    getters = new MethodHandle[fieldCount];
    setters = new MethodHandle[fieldCount];
    for(int i = 0; i < fieldCount; ++i) {
        final String fieldName = ObjectClassGenerator.getFieldName(i, Type.OBJECT);
        getters[i] = MH.asType(MH.getter(lookup, structure, fieldName, Type.OBJECT.getTypeClass()), Lookup.GET_OBJECT_TYPE);
        setters[i] = MH.asType(MH.setter(lookup, structure, fieldName, Type.OBJECT.getTypeClass()), Lookup.SET_OBJECT_TYPE);
    }
}
 
Example #22
Source Project: openjdk-8-source   Author: keerath   File: StructureLoader.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generate a layout class.
 * @param name       Name of class.
 * @param descriptor Layout descriptor.
 * @return Generated class.
 */
private Class<?> generateClass(final String name, final String descriptor) {
    final Context context = Context.getContextTrusted();

    final byte[] code = new ObjectClassGenerator(context).generate(descriptor);
    return defineClass(name, code, 0, code.length, new ProtectionDomain(null, getPermissions(null)));
}
 
Example #23
Source Project: openjdk-8   Author: bpupadhyaya   File: AccessorProperty.java    License: GNU General Public License v2.0 5 votes vote down vote up
public GettersSetters(Class<?> structure) {
    final int fieldCount = ObjectClassGenerator.getFieldCount(structure);
    getters = new MethodHandle[fieldCount];
    setters = new MethodHandle[fieldCount];
    for(int i = 0; i < fieldCount; ++i) {
        final String fieldName = ObjectClassGenerator.getFieldName(i, Type.OBJECT);
        getters[i] = MH.asType(MH.getter(lookup, structure, fieldName, Type.OBJECT.getTypeClass()), Lookup.GET_OBJECT_TYPE);
        setters[i] = MH.asType(MH.setter(lookup, structure, fieldName, Type.OBJECT.getTypeClass()), Lookup.SET_OBJECT_TYPE);
    }
}
 
Example #24
Source Project: openjdk-8   Author: bpupadhyaya   File: StructureLoader.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generate a layout class.
 * @param name       Name of class.
 * @param descriptor Layout descriptor.
 * @return Generated class.
 */
private Class<?> generateClass(final String name, final String descriptor) {
    final Context context = Context.getContextTrusted();

    final byte[] code = new ObjectClassGenerator(context).generate(descriptor);
    return defineClass(name, code, 0, code.length, new ProtectionDomain(null, getPermissions(null)));
}
 
Example #25
Source Project: jdk8u_nashorn   Author: JetBrains   File: StructureLoader.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generate a layout class.
 * @param name       Name of class.
 * @param descriptor Layout descriptor.
 * @return Generated class.
 */
private Class<?> generateClass(final String name, final String descriptor, final boolean dualFields) {
    final Context context = Context.getContextTrusted();

    final byte[] code = new ObjectClassGenerator(context, dualFields).generate(descriptor);
    return defineClass(name, code, 0, code.length, new ProtectionDomain(null, getPermissions(null)));
}
 
Example #26
Source Project: jdk8u_nashorn   Author: JetBrains   File: AllocationStrategy.java    License: GNU General Public License v2.0 5 votes vote down vote up
private String getAllocatorClassName() {
    if (allocatorClassName == null) {
        // These classes get loaded, so an interned variant of their name is most likely around anyway.
        allocatorClassName = Compiler.binaryName(ObjectClassGenerator.getClassName(fieldCount, dualFields)).intern();
    }
    return allocatorClassName;
}
 
Example #27
Source Project: nashorn   Author: ynsn   File: AccessorProperty.java    License: GNU General Public License v2.0 5 votes vote down vote up
public GettersSetters(Class<?> structure) {
    final int fieldCount = ObjectClassGenerator.getFieldCount(structure);
    getters = new MethodHandle[fieldCount];
    setters = new MethodHandle[fieldCount];
    for(int i = 0; i < fieldCount; ++i) {
        final String fieldName = ObjectClassGenerator.getFieldName(i, Type.OBJECT);
        getters[i] = MH.asType(MH.getter(lookup, structure, fieldName, Type.OBJECT.getTypeClass()), Lookup.GET_OBJECT_TYPE);
        setters[i] = MH.asType(MH.setter(lookup, structure, fieldName, Type.OBJECT.getTypeClass()), Lookup.SET_OBJECT_TYPE);
    }
}
 
Example #28
Source Project: nashorn   Author: ynsn   File: StructureLoader.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generate a layout class.
 * @param name       Name of class.
 * @param descriptor Layout descriptor.
 * @return Generated class.
 */
private Class<?> generateClass(final String name, final String descriptor) {
    final Context context = Context.getContextTrusted();

    final byte[] code = new ObjectClassGenerator(context).generate(descriptor);
    return defineClass(name, code, 0, code.length, new ProtectionDomain(null, getPermissions(null)));
}
 
Example #29
Source Project: nashorn   Author: ynsn   File: IdentNode.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public IdentNode setType(final TemporarySymbols ts, final LexicalContext lc, final Type type) {
    // do NOT, repeat NOT touch the symbol here. it might be a local variable or whatever. This is the override if it isn't
    if (this.callSiteType == type) {
        return this;
    }
    if (DEBUG_FIELDS && getSymbol() != null && !Type.areEquivalent(getSymbol().getSymbolType(), type)) {
        ObjectClassGenerator.LOG.info(getClass().getName(), " ", this, " => ", type, " instead of ", getType());
    }

    return new IdentNode(this, name, type, flags);
}
 
Example #30
Source Project: TencentKona-8   Author: Tencent   File: ScriptObject.java    License: GNU General Public License v2.0 4 votes vote down vote up
private static GuardedInvocation findMegaMorphicGetMethod(final CallSiteDescriptor desc, final String name, final boolean isMethod) {
    Context.getContextTrusted().getLogger(ObjectClassGenerator.class).warning("Megamorphic getter: " + desc + " " + name + " " +isMethod);
    final MethodHandle invoker = MH.insertArguments(MEGAMORPHIC_GET, 1, name, isMethod, NashornCallSiteDescriptor.isScope(desc));
    final MethodHandle guard   = getScriptObjectGuard(desc.getMethodType(), true);
    return new GuardedInvocation(invoker, guard);
}