52 import java.lang.invoke.MethodType;
53 import java.util.EnumSet;
54 import java.util.Iterator;
55 import java.util.LinkedList;
56 import java.util.List;
57 import jdk.nashorn.internal.codegen.ClassEmitter.Flag;
58 import jdk.nashorn.internal.codegen.types.Type;
59 import jdk.nashorn.internal.runtime.AccessorProperty;
60 import jdk.nashorn.internal.runtime.AllocationStrategy;
61 import jdk.nashorn.internal.runtime.Context;
62 import jdk.nashorn.internal.runtime.FunctionScope;
63 import jdk.nashorn.internal.runtime.JSType;
64 import jdk.nashorn.internal.runtime.PropertyMap;
65 import jdk.nashorn.internal.runtime.ScriptEnvironment;
66 import jdk.nashorn.internal.runtime.ScriptObject;
67 import jdk.nashorn.internal.runtime.Undefined;
68 import jdk.nashorn.internal.runtime.UnwarrantedOptimismException;
69 import jdk.nashorn.internal.runtime.logging.DebugLogger;
70 import jdk.nashorn.internal.runtime.logging.Loggable;
71 import jdk.nashorn.internal.runtime.logging.Logger;
72 import jdk.nashorn.internal.runtime.options.Options;
73
74 /**
75 * Generates the ScriptObject subclass structure with fields for a user objects.
76 */
77 @Logger(name="fields")
78 public final class ObjectClassGenerator implements Loggable {
79
80 /**
81 * Type guard to make sure we don't unnecessarily explode field storages. Rather unbox e.g.
82 * a java.lang.Number than blow up the field. Gradually, optimistic types should create almost
83 * no boxed types
84 */
85 private static final MethodHandle IS_TYPE_GUARD = findOwnMH("isType", boolean.class, Class.class, Object.class);
86
87 /**
88 * Marker for scope parameters
89 */
90 private static final String SCOPE_MARKER = "P";
91
92 /**
|
52 import java.lang.invoke.MethodType;
53 import java.util.EnumSet;
54 import java.util.Iterator;
55 import java.util.LinkedList;
56 import java.util.List;
57 import jdk.nashorn.internal.codegen.ClassEmitter.Flag;
58 import jdk.nashorn.internal.codegen.types.Type;
59 import jdk.nashorn.internal.runtime.AccessorProperty;
60 import jdk.nashorn.internal.runtime.AllocationStrategy;
61 import jdk.nashorn.internal.runtime.Context;
62 import jdk.nashorn.internal.runtime.FunctionScope;
63 import jdk.nashorn.internal.runtime.JSType;
64 import jdk.nashorn.internal.runtime.PropertyMap;
65 import jdk.nashorn.internal.runtime.ScriptEnvironment;
66 import jdk.nashorn.internal.runtime.ScriptObject;
67 import jdk.nashorn.internal.runtime.Undefined;
68 import jdk.nashorn.internal.runtime.UnwarrantedOptimismException;
69 import jdk.nashorn.internal.runtime.logging.DebugLogger;
70 import jdk.nashorn.internal.runtime.logging.Loggable;
71 import jdk.nashorn.internal.runtime.logging.Logger;
72
73 /**
74 * Generates the ScriptObject subclass structure with fields for a user objects.
75 */
76 @Logger(name="fields")
77 public final class ObjectClassGenerator implements Loggable {
78
79 /**
80 * Type guard to make sure we don't unnecessarily explode field storages. Rather unbox e.g.
81 * a java.lang.Number than blow up the field. Gradually, optimistic types should create almost
82 * no boxed types
83 */
84 private static final MethodHandle IS_TYPE_GUARD = findOwnMH("isType", boolean.class, Class.class, Object.class);
85
86 /**
87 * Marker for scope parameters
88 */
89 private static final String SCOPE_MARKER = "P";
90
91 /**
|