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 File: JSONParser.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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 File: JSONParser.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
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 File: JSONParser.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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 File: JSONParser.java From hottub with GNU General Public License v2.0 | 6 votes |
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 File: JSONParser.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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 File: JSONParser.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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 File: JSONParser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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 File: AllocationStrategy.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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 #9
Source File: StructureLoader.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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 #10
Source File: StructureLoader.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * 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 File: AllocationStrategy.java From hottub with GNU General Public License v2.0 | 5 votes |
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 File: AccessorProperty.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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 #13
Source File: StructureLoader.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * 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 #14
Source File: StructureLoader.java From nashorn with GNU General Public License v2.0 | 5 votes |
/** * 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 #15
Source File: AccessorProperty.java From nashorn with GNU General Public License v2.0 | 5 votes |
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 #16
Source File: AllocationStrategy.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
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 #17
Source File: StructureLoader.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
/** * 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 File: AccessorProperty.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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 #19
Source File: StructureLoader.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * 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 #20
Source File: ScriptObject.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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 #21
Source File: IdentNode.java From nashorn with GNU General Public License v2.0 | 5 votes |
@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 #22
Source File: AllocationStrategy.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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 #23
Source File: StructureLoader.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * 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 #24
Source File: StructureLoader.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * 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 #25
Source File: AllocationStrategy.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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 #26
Source File: StructureLoader.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * 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 #27
Source File: AllocationStrategy.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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 #28
Source File: AllocationStrategy.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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 #29
Source File: StructureLoader.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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 #30
Source File: NumberType.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@Override public Type loadUndefined(final MethodVisitor method) { method.visitLdcInsn(ObjectClassGenerator.UNDEFINED_DOUBLE); return NUMBER; }