8008239: Unpublicized parts of the code generator package that were only package internal.

Fri, 15 Feb 2013 09:44:15 +0100

author
lagergren
date
Fri, 15 Feb 2013 09:44:15 +0100
changeset 96
e478708faa22
parent 95
36065e5ea3d1
child 97
757a49aaad02

8008239: Unpublicized parts of the code generator package that were only package internal.
Reviewed-by: hannesw, attila

src/jdk/nashorn/internal/codegen/BranchOptimizer.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/ClassEmitter.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/CodeGenerator.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/CompilationPhase.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/CompilerConstants.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/Condition.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/FieldObjectCreator.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/FunctionSignature.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/Label.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/MapCreator.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/MethodEmitter.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/ObjectCreator.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/SharedScopeCall.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/Splitter.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/objects/FieldObjectCreator.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/objects/MapCreator.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/objects/ObjectClassGenerator.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/objects/ObjectCreator.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/objects/ObjectMapCreator.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/types/BooleanType.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/types/IntType.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/types/LongType.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/codegen/types/NumberType.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/AccessNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/BaseNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/Block.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/BreakNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/BreakableNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/CallNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/CaseNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/CatchNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/ContinueNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/IdentNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/IndexNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/LabelNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/LineNumberNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/ObjectNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/ReturnNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/SplitNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/SwitchNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/ThrowNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/TryNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/UnaryNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/WhileNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/ir/WithNode.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/NativeRegExp.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/AccessorProperty.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/Context.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/ECMAException.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/FindProperty.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/Property.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/Scope.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/ScriptObject.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/ScriptRuntime.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/SetMethodCreator.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/StructureLoader.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/jdk/nashorn/internal/codegen/BranchOptimizer.java	Fri Feb 15 09:18:05 2013 +0100
     1.2 +++ b/src/jdk/nashorn/internal/codegen/BranchOptimizer.java	Fri Feb 15 09:44:15 2013 +0100
     1.3 @@ -25,14 +25,14 @@
     1.4  
     1.5  package jdk.nashorn.internal.codegen;
     1.6  
     1.7 -import static jdk.nashorn.internal.codegen.MethodEmitter.Condition.EQ;
     1.8 -import static jdk.nashorn.internal.codegen.MethodEmitter.Condition.GE;
     1.9 -import static jdk.nashorn.internal.codegen.MethodEmitter.Condition.GT;
    1.10 -import static jdk.nashorn.internal.codegen.MethodEmitter.Condition.LE;
    1.11 -import static jdk.nashorn.internal.codegen.MethodEmitter.Condition.LT;
    1.12 -import static jdk.nashorn.internal.codegen.MethodEmitter.Condition.NE;
    1.13 +import static jdk.nashorn.internal.codegen.Condition.EQ;
    1.14 +import static jdk.nashorn.internal.codegen.Condition.GE;
    1.15 +import static jdk.nashorn.internal.codegen.Condition.GT;
    1.16 +import static jdk.nashorn.internal.codegen.Condition.LE;
    1.17 +import static jdk.nashorn.internal.codegen.Condition.LT;
    1.18 +import static jdk.nashorn.internal.codegen.Condition.NE;
    1.19  
    1.20 -import jdk.nashorn.internal.codegen.MethodEmitter.Label;
    1.21 +import jdk.nashorn.internal.codegen.Label;
    1.22  import jdk.nashorn.internal.codegen.types.Type;
    1.23  import jdk.nashorn.internal.ir.BinaryNode;
    1.24  import jdk.nashorn.internal.ir.Node;
     2.1 --- a/src/jdk/nashorn/internal/codegen/ClassEmitter.java	Fri Feb 15 09:18:05 2013 +0100
     2.2 +++ b/src/jdk/nashorn/internal/codegen/ClassEmitter.java	Fri Feb 15 09:44:15 2013 +0100
     2.3 @@ -62,6 +62,7 @@
     2.4  import jdk.internal.org.objectweb.asm.ClassWriter;
     2.5  import jdk.internal.org.objectweb.asm.MethodVisitor;
     2.6  import jdk.internal.org.objectweb.asm.util.TraceClassVisitor;
     2.7 +import jdk.nashorn.internal.codegen.Emitter;
     2.8  import jdk.nashorn.internal.codegen.types.Type;
     2.9  import jdk.nashorn.internal.ir.FunctionNode;
    2.10  import jdk.nashorn.internal.runtime.Context;
    2.11 @@ -102,7 +103,6 @@
    2.12   * detect if this is not true
    2.13   *
    2.14   * @see Compiler
    2.15 - * @see CodeGenerator
    2.16   */
    2.17  public class ClassEmitter implements Emitter {
    2.18  
    2.19 @@ -156,7 +156,7 @@
    2.20       * @param superClassName  super class name for class
    2.21       * @param interfaceNames  names of interfaces implemented by this class, or null if none
    2.22       */
    2.23 -    public ClassEmitter(final Context context, final String className, final String superClassName, final String... interfaceNames) {
    2.24 +    ClassEmitter(final Context context, final String className, final String superClassName, final String... interfaceNames) {
    2.25          this(context, new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS));
    2.26          cw.visit(V1_7, ACC_PUBLIC | ACC_SUPER, className, null, superClassName, interfaceNames);
    2.27      }
    2.28 @@ -363,7 +363,7 @@
    2.29       * @param bytecode  byte array representing bytecode
    2.30       * @return disassembly as human readable string
    2.31       */
    2.32 -    public static String disassemble(final byte[] bytecode) {
    2.33 +    static String disassemble(final byte[] bytecode) {
    2.34          final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    2.35          try (final PrintWriter pw = new PrintWriter(baos)) {
    2.36              new ClassReader(bytecode).accept(new TraceClassVisitor(pw), 0);
    2.37 @@ -411,7 +411,7 @@
    2.38       *
    2.39       * @return method emitter to use for weaving this method
    2.40       */
    2.41 -    public MethodEmitter method(final String methodName, final Class<?> rtype, final Class<?>... ptypes) {
    2.42 +    MethodEmitter method(final String methodName, final Class<?> rtype, final Class<?>... ptypes) {
    2.43          return method(DEFAULT_METHOD_FLAGS, methodName, rtype, ptypes); //TODO why public default ?
    2.44      }
    2.45  
    2.46 @@ -425,7 +425,7 @@
    2.47       *
    2.48       * @return method emitter to use for weaving this method
    2.49       */
    2.50 -    public MethodEmitter method(final EnumSet<Flag> methodFlags, final String methodName, final Class<?> rtype, final Class<?>... ptypes) {
    2.51 +    MethodEmitter method(final EnumSet<Flag> methodFlags, final String methodName, final Class<?> rtype, final Class<?>... ptypes) {
    2.52          return new MethodEmitter(this, cw.visitMethod(Flag.getValue(methodFlags), methodName, methodDescriptor(rtype, ptypes), null, null));
    2.53      }
    2.54  
    2.55 @@ -437,7 +437,7 @@
    2.56       *
    2.57       * @return method emitter to use for weaving this method
    2.58       */
    2.59 -    public MethodEmitter method(final String methodName, final String descriptor) {
    2.60 +    MethodEmitter method(final String methodName, final String descriptor) {
    2.61          return method(DEFAULT_METHOD_FLAGS, methodName, descriptor);
    2.62      }
    2.63  
    2.64 @@ -450,7 +450,7 @@
    2.65       *
    2.66       * @return method emitter to use for weaving this method
    2.67       */
    2.68 -    public MethodEmitter method(final EnumSet<Flag> methodFlags, final String methodName, final String descriptor) {
    2.69 +    MethodEmitter method(final EnumSet<Flag> methodFlags, final String methodName, final String descriptor) {
    2.70          return new MethodEmitter(this, cw.visitMethod(Flag.getValue(methodFlags), methodName, descriptor, null, null));
    2.71      }
    2.72  
    2.73 @@ -460,7 +460,7 @@
    2.74       * @param functionNode the function node to generate a method for
    2.75       * @return method emitter to use for weaving this method
    2.76       */
    2.77 -    public MethodEmitter method(final FunctionNode functionNode) {
    2.78 +    MethodEmitter method(final FunctionNode functionNode) {
    2.79          final MethodVisitor mv = cw.visitMethod(
    2.80              ACC_PUBLIC | ACC_STATIC | (functionNode.isVarArg() ? ACC_VARARGS : 0),
    2.81              functionNode.getName(),
    2.82 @@ -476,7 +476,7 @@
    2.83       *
    2.84       * @return method emitter to use for weaving <clinit>
    2.85       */
    2.86 -    public MethodEmitter clinit() {
    2.87 +    MethodEmitter clinit() {
    2.88          return method(EnumSet.of(Flag.STATIC), CLINIT.tag(), void.class);
    2.89      }
    2.90  
    2.91 @@ -485,7 +485,7 @@
    2.92       *
    2.93       * @return method emitter to use for weaving <init>()V
    2.94       */
    2.95 -    public MethodEmitter init() {
    2.96 +    MethodEmitter init() {
    2.97          return method(INIT.tag(), void.class);
    2.98      }
    2.99  
   2.100 @@ -495,7 +495,7 @@
   2.101       * @param ptypes parameter types for constructor
   2.102       * @return method emitter to use for weaving <init>()V
   2.103       */
   2.104 -    public MethodEmitter init(final Class<?>... ptypes) {
   2.105 +    MethodEmitter init(final Class<?>... ptypes) {
   2.106          return method(INIT.tag(), void.class, ptypes);
   2.107      }
   2.108  
   2.109 @@ -507,7 +507,7 @@
   2.110       *
   2.111       * @return method emitter to use for weaving <init>(...)V
   2.112       */
   2.113 -    public MethodEmitter init(final EnumSet<Flag> flags, final Class<?>... ptypes) {
   2.114 +    MethodEmitter init(final EnumSet<Flag> flags, final Class<?>... ptypes) {
   2.115          return method(flags, INIT.tag(), void.class, ptypes);
   2.116      }
   2.117  
   2.118 @@ -521,7 +521,7 @@
   2.119       *
   2.120       * @see ClassEmitter.Flag
   2.121       */
   2.122 -    public final void field(final EnumSet<Flag> fieldFlags, final String fieldName, final Class<?> fieldType, final Object value) {
   2.123 +    final void field(final EnumSet<Flag> fieldFlags, final String fieldName, final Class<?> fieldType, final Object value) {
   2.124          cw.visitField(Flag.getValue(fieldFlags), fieldName, typeDescriptor(fieldType), null, value).visitEnd();
   2.125      }
   2.126  
   2.127 @@ -534,7 +534,7 @@
   2.128       *
   2.129       * @see ClassEmitter.Flag
   2.130       */
   2.131 -    public final void field(final EnumSet<Flag> fieldFlags, final String fieldName, final Class<?> fieldType) {
   2.132 +    final void field(final EnumSet<Flag> fieldFlags, final String fieldName, final Class<?> fieldType) {
   2.133          field(fieldFlags, fieldName, fieldType, null);
   2.134      }
   2.135  
   2.136 @@ -544,7 +544,7 @@
   2.137       * @param fieldName  name of field
   2.138       * @param fieldType  type of field
   2.139       */
   2.140 -    public final void field(final String fieldName, final Class<?> fieldType) {
   2.141 +    final void field(final String fieldName, final Class<?> fieldType) {
   2.142          field(EnumSet.of(Flag.PUBLIC), fieldName, fieldType, null);
   2.143      }
   2.144  
   2.145 @@ -554,7 +554,7 @@
   2.146       *
   2.147       * @return byte code array for generated class, null if class generation hasn't been ended with {@link ClassEmitter#end()}
   2.148       */
   2.149 -    public byte[] toByteArray() {
   2.150 +    byte[] toByteArray() {
   2.151          assert classEnded;
   2.152          if (!classEnded) {
   2.153              return null;
   2.154 @@ -572,7 +572,7 @@
   2.155       * Flags are provided for method handles, protection levels, static/virtual
   2.156       * fields/methods.
   2.157       */
   2.158 -    public static enum Flag {
   2.159 +    static enum Flag {
   2.160          /** method handle with static access */
   2.161          HANDLE_STATIC(H_INVOKESTATIC),
   2.162          /** method handle with new invoke special access */
   2.163 @@ -603,7 +603,7 @@
   2.164           * Get the value of this flag
   2.165           * @return the int value
   2.166           */
   2.167 -        public int getValue() {
   2.168 +        int getValue() {
   2.169              return value;
   2.170          }
   2.171  
   2.172 @@ -613,7 +613,7 @@
   2.173           * @param flags enum set of flags
   2.174           * @return an integer value representing the flags intrinsic values or:ed together
   2.175           */
   2.176 -        public static int getValue(final EnumSet<Flag> flags) {
   2.177 +        static int getValue(final EnumSet<Flag> flags) {
   2.178              int v = 0;
   2.179              for (final Flag flag : flags) {
   2.180                  v |= flag.getValue();
   2.181 @@ -621,5 +621,4 @@
   2.182              return v;
   2.183          }
   2.184      }
   2.185 -
   2.186  }
     3.1 --- a/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Fri Feb 15 09:18:05 2013 +0100
     3.2 +++ b/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Fri Feb 15 09:44:15 2013 +0100
     3.3 @@ -63,13 +63,7 @@
     3.4  import java.util.TreeMap;
     3.5  import jdk.nashorn.internal.codegen.ClassEmitter.Flag;
     3.6  import jdk.nashorn.internal.codegen.CompilerConstants.Call;
     3.7 -import jdk.nashorn.internal.codegen.MethodEmitter.Condition;
     3.8 -import jdk.nashorn.internal.codegen.MethodEmitter.Label;
     3.9  import jdk.nashorn.internal.codegen.RuntimeCallSite.SpecializedRuntimeNode;
    3.10 -import jdk.nashorn.internal.codegen.objects.FieldObjectCreator;
    3.11 -import jdk.nashorn.internal.codegen.objects.MapCreator;
    3.12 -import jdk.nashorn.internal.codegen.objects.ObjectCreator;
    3.13 -import jdk.nashorn.internal.codegen.objects.ObjectMapCreator;
    3.14  import jdk.nashorn.internal.codegen.types.ArrayType;
    3.15  import jdk.nashorn.internal.codegen.types.Type;
    3.16  import jdk.nashorn.internal.ir.AccessNode;
    3.17 @@ -118,6 +112,7 @@
    3.18  import jdk.nashorn.internal.runtime.CodeInstaller;
    3.19  import jdk.nashorn.internal.runtime.Context;
    3.20  import jdk.nashorn.internal.runtime.ECMAException;
    3.21 +import jdk.nashorn.internal.runtime.Property;
    3.22  import jdk.nashorn.internal.runtime.PropertyMap;
    3.23  import jdk.nashorn.internal.runtime.Scope;
    3.24  import jdk.nashorn.internal.runtime.ScriptFunction;
    3.25 @@ -147,7 +142,7 @@
    3.26   * The CodeGenerator visits nodes only once, tags them as resolved and emits
    3.27   * bytecode for them.
    3.28   */
    3.29 -public final class CodeGenerator extends NodeOperatorVisitor {
    3.30 +final class CodeGenerator extends NodeOperatorVisitor {
    3.31  
    3.32      /** Name of the Global object, cannot be referred to as .class, @see CodeGenerator */
    3.33      private static final String GLOBAL_OBJECT = Compiler.OBJECTS_PACKAGE + '/' + "Global";
    3.34 @@ -189,7 +184,7 @@
    3.35       *
    3.36       * @return the correct flags for a call site in the current function
    3.37       */
    3.38 -    public int getCallSiteFlags() {
    3.39 +    int getCallSiteFlags() {
    3.40          return getCurrentFunctionNode().isStrictMode() ? callSiteFlags | CALLSITE_STRICT : callSiteFlags;
    3.41      }
    3.42  
    3.43 @@ -302,7 +297,7 @@
    3.44       *
    3.45       * @return the method emitter used
    3.46       */
    3.47 -    public MethodEmitter load(final Node node) {
    3.48 +    MethodEmitter load(final Node node) {
    3.49          return load(node, false);
    3.50      }
    3.51  
    3.52 @@ -661,9 +656,8 @@
    3.53                  } else { // get global from scope (which is the self)
    3.54                      globalInstance();
    3.55                  }
    3.56 -
    3.57                  loadArgs(args, signature, isVarArg, argCount);
    3.58 -                method.invokeStatic(callee.getCompileUnit().getUnitClassName(), callee.getName(), signature);
    3.59 +                method.invokestatic(callee.getCompileUnit().getUnitClassName(), callee.getName(), signature);
    3.60                  assert method.peekType().equals(callee.getReturnType()) : method.peekType() + " != " + callee.getReturnType();
    3.61  
    3.62                  return null;
    3.63 @@ -1138,7 +1132,7 @@
    3.64                      savedMethod.swap();
    3.65                      savedMethod.loadScope();
    3.66                      savedMethod.swap();
    3.67 -                    savedMethod.invokeStatic(className, name, signature);
    3.68 +                    savedMethod.invokestatic(className, name, signature);
    3.69                  }
    3.70              } finally {
    3.71                  setCurrentCompileUnit(savedCompileUnit);
    3.72 @@ -1191,13 +1185,13 @@
    3.73       *
    3.74       * @param string string to load
    3.75       */
    3.76 -    public void loadConstant(final String string) {
    3.77 +    void loadConstant(final String string) {
    3.78          final String       unitClassName = getCurrentCompileUnit().getUnitClassName();
    3.79          final ClassEmitter classEmitter  = getCurrentCompileUnit().getClassEmitter();
    3.80          final int          index         = compiler.getConstantData().add(string);
    3.81  
    3.82          method.load(index);
    3.83 -        method.invokeStatic(unitClassName, GET_STRING.tag(), methodDescriptor(String.class, int.class));
    3.84 +        method.invokestatic(unitClassName, GET_STRING.tag(), methodDescriptor(String.class, int.class));
    3.85          classEmitter.needGetConstantMethod(String.class);
    3.86      }
    3.87  
    3.88 @@ -1207,7 +1201,7 @@
    3.89       *
    3.90       * @param object object to load
    3.91       */
    3.92 -    public void loadConstant(final Object object) {
    3.93 +    void loadConstant(final Object object) {
    3.94          final String       unitClassName = getCurrentCompileUnit().getUnitClassName();
    3.95          final ClassEmitter classEmitter  = getCurrentCompileUnit().getClassEmitter();
    3.96          final int          index         = compiler.getConstantData().add(object);
    3.97 @@ -1215,12 +1209,12 @@
    3.98  
    3.99          if (cls == PropertyMap.class) {
   3.100              method.load(index);
   3.101 -            method.invokeStatic(unitClassName, GET_MAP.tag(), methodDescriptor(PropertyMap.class, int.class));
   3.102 +            method.invokestatic(unitClassName, GET_MAP.tag(), methodDescriptor(PropertyMap.class, int.class));
   3.103              classEmitter.needGetConstantMethod(PropertyMap.class);
   3.104          } else if (cls.isArray()) {
   3.105              method.load(index);
   3.106              final String methodName = ClassEmitter.getArrayMethodName(cls);
   3.107 -            method.invokeStatic(unitClassName, methodName, methodDescriptor(cls, int.class));
   3.108 +            method.invokestatic(unitClassName, methodName, methodDescriptor(cls, int.class));
   3.109              classEmitter.needGetConstantMethod(cls);
   3.110          } else {
   3.111              method.loadConstants(unitClassName).load(index).arrayload();
   3.112 @@ -1363,7 +1357,12 @@
   3.113               */
   3.114              @Override
   3.115              protected MapCreator newMapCreator(final Class<?> fieldObjectClass) {
   3.116 -                return new ObjectMapCreator(fieldObjectClass, keys, symbols);
   3.117 +                return new MapCreator(fieldObjectClass, keys, symbols) {
   3.118 +                    @Override
   3.119 +                    protected int getPropertyFlags(final Symbol symbol, final boolean isVarArg) {
   3.120 +                        return super.getPropertyFlags(symbol, isVarArg) | Property.IS_ALWAYS_OBJECT;
   3.121 +                    }
   3.122 +                };
   3.123              }
   3.124  
   3.125          }.makeObject(method);
   3.126 @@ -1487,7 +1486,7 @@
   3.127  
   3.128              method.label(falseLabel);
   3.129              load(rhs);
   3.130 -            method.invokeStatic(CompilerConstants.className(ScriptRuntime.class), request.toString(), signature);
   3.131 +            method.invokestatic(CompilerConstants.className(ScriptRuntime.class), request.toString(), signature);
   3.132              method._goto(endLabel);
   3.133  
   3.134              method.label(trueLabel);
   3.135 @@ -1628,7 +1627,7 @@
   3.136              load(arg).convert(Type.OBJECT); //TODO this should not be necessary below Lower
   3.137          }
   3.138  
   3.139 -        method.invokeStatic(
   3.140 +        method.invokestatic(
   3.141              CompilerConstants.className(ScriptRuntime.class),
   3.142              runtimeNode.getRequest().toString(),
   3.143              new FunctionSignature(
   3.144 @@ -1746,7 +1745,7 @@
   3.145                  labels[i] = new Label("split_state_" + i);
   3.146              }
   3.147  
   3.148 -            caller.tableSwitch(low, targetCount, breakLabel, labels);
   3.149 +            caller.tableswitch(low, targetCount, breakLabel, labels);
   3.150              for (int i = low; i <= targetCount; i++) {
   3.151                  caller.label(labels[i - low]);
   3.152                  if (i == 0) {
   3.153 @@ -1853,7 +1852,7 @@
   3.154                      table[value - lo] = labels[i];
   3.155                  }
   3.156  
   3.157 -                method.tableSwitch(lo, hi, defaultLabel, table);
   3.158 +                method.tableswitch(lo, hi, defaultLabel, table);
   3.159              } else {
   3.160                  final int[] ints = new int[size];
   3.161  
   3.162 @@ -1861,7 +1860,7 @@
   3.163                      ints[i] = values[i];
   3.164                  }
   3.165  
   3.166 -                method.lookupSwitch(defaultLabel, ints, labels);
   3.167 +                method.lookupswitch(defaultLabel, ints, labels);
   3.168              }
   3.169          } else {
   3.170              load(expression);
   3.171 @@ -1869,7 +1868,7 @@
   3.172              if (expression.getType().isInteger()) {
   3.173                  method.convert(Type.NUMBER).dup();
   3.174                  method.store(tag);
   3.175 -                method.conditionalJump(MethodEmitter.Condition.NE, true, defaultLabel);
   3.176 +                method.conditionalJump(Condition.NE, true, defaultLabel);
   3.177              } else {
   3.178                  method.store(tag);
   3.179              }
   3.180 @@ -3245,7 +3244,7 @@
   3.181  
   3.182          new ObjectCreator(this, new ArrayList<String>(), new ArrayList<Symbol>(), false, false) {
   3.183              @Override
   3.184 -            public void makeObject(final MethodEmitter method) {
   3.185 +            protected void makeObject(final MethodEmitter method) {
   3.186                  final String className = isLazy ? SCRIPTFUNCTION_TRAMPOLINE_OBJECT : SCRIPTFUNCTION_IMPL_OBJECT;
   3.187  
   3.188                  method._new(className).dup();
   3.189 @@ -3286,36 +3285,36 @@
   3.190       * is from the code pipeline is Global
   3.191       */
   3.192      private MethodEmitter globalInstance() {
   3.193 -        return method.invokeStatic(GLOBAL_OBJECT, "instance", "()L" + GLOBAL_OBJECT + ';');
   3.194 +        return method.invokestatic(GLOBAL_OBJECT, "instance", "()L" + GLOBAL_OBJECT + ';');
   3.195      }
   3.196  
   3.197      private MethodEmitter globalObjectPrototype() {
   3.198 -        return method.invokeStatic(GLOBAL_OBJECT, "objectPrototype", methodDescriptor(ScriptObject.class));
   3.199 +        return method.invokestatic(GLOBAL_OBJECT, "objectPrototype", methodDescriptor(ScriptObject.class));
   3.200      }
   3.201  
   3.202      private MethodEmitter globalAllocateArguments() {
   3.203 -        return method.invokeStatic(GLOBAL_OBJECT, "allocateArguments", methodDescriptor(ScriptObject.class, Object[].class, Object.class, int.class));
   3.204 +        return method.invokestatic(GLOBAL_OBJECT, "allocateArguments", methodDescriptor(ScriptObject.class, Object[].class, Object.class, int.class));
   3.205      }
   3.206  
   3.207      private MethodEmitter globalNewRegExp() {
   3.208 -        return method.invokeStatic(GLOBAL_OBJECT, "newRegExp", methodDescriptor(Object.class, String.class, String.class));
   3.209 +        return method.invokestatic(GLOBAL_OBJECT, "newRegExp", methodDescriptor(Object.class, String.class, String.class));
   3.210      }
   3.211  
   3.212      private MethodEmitter globalRegExpCopy() {
   3.213 -        return method.invokeStatic(GLOBAL_OBJECT, "regExpCopy", methodDescriptor(Object.class, Object.class));
   3.214 +        return method.invokestatic(GLOBAL_OBJECT, "regExpCopy", methodDescriptor(Object.class, Object.class));
   3.215      }
   3.216  
   3.217      private MethodEmitter globalAllocateArray(final ArrayType type) {
   3.218          //make sure the native array is treated as an array type
   3.219 -        return method.invokeStatic(GLOBAL_OBJECT, "allocate", "(" + type.getDescriptor() + ")Ljdk/nashorn/internal/objects/NativeArray;");
   3.220 +        return method.invokestatic(GLOBAL_OBJECT, "allocate", "(" + type.getDescriptor() + ")Ljdk/nashorn/internal/objects/NativeArray;");
   3.221      }
   3.222  
   3.223      private MethodEmitter globalIsEval() {
   3.224 -        return method.invokeStatic(GLOBAL_OBJECT, "isEval", methodDescriptor(boolean.class, Object.class));
   3.225 +        return method.invokestatic(GLOBAL_OBJECT, "isEval", methodDescriptor(boolean.class, Object.class));
   3.226      }
   3.227  
   3.228      private MethodEmitter globalDirectEval() {
   3.229 -        return method.invokeStatic(GLOBAL_OBJECT, "directEval",
   3.230 +        return method.invokestatic(GLOBAL_OBJECT, "directEval",
   3.231                  methodDescriptor(Object.class, Object.class, Object.class, Object.class, Object.class, Object.class));
   3.232      }
   3.233  }
     4.1 --- a/src/jdk/nashorn/internal/codegen/CompilationPhase.java	Fri Feb 15 09:18:05 2013 +0100
     4.2 +++ b/src/jdk/nashorn/internal/codegen/CompilationPhase.java	Fri Feb 15 09:44:15 2013 +0100
     4.3 @@ -76,18 +76,7 @@
     4.4      CONSTANT_FOLDING_PHASE(EnumSet.of(INITIALIZED), CONSTANT_FOLDED) {
     4.5          @Override
     4.6          boolean transform(final Compiler compiler, final FunctionNode fn) {
     4.7 -            final Context context = compiler.getContext();
     4.8 -
     4.9 -            if (context._print_ast) {
    4.10 -                context.getErr().println(new ASTWriter(fn));
    4.11 -            }
    4.12 -
    4.13 -            if (context._print_parse) {
    4.14 -                context.getErr().println(new PrintVisitor(fn));
    4.15 -            }
    4.16 -
    4.17              fn.accept(new FoldConstants());
    4.18 -
    4.19              return true;
    4.20          }
    4.21  
    4.22 @@ -137,7 +126,7 @@
    4.23  
    4.24                  if (context._print_lower_parse) {
    4.25                      context.getErr().println(new PrintVisitor(fn));
    4.26 -                }
    4.27 +               }
    4.28              }
    4.29          }
    4.30  
     5.1 --- a/src/jdk/nashorn/internal/codegen/CompilerConstants.java	Fri Feb 15 09:18:05 2013 +0100
     5.2 +++ b/src/jdk/nashorn/internal/codegen/CompilerConstants.java	Fri Feb 15 09:44:15 2013 +0100
     5.3 @@ -320,7 +320,7 @@
     5.4          return new Call(null, className, name, desc) {
     5.5              @Override
     5.6              public MethodEmitter invoke(final MethodEmitter method) {
     5.7 -                return method.invokeSpecial(className, name, descriptor);
     5.8 +                return method.invokespecial(className, name, descriptor);
     5.9              }
    5.10          };
    5.11      }
    5.12 @@ -354,7 +354,7 @@
    5.13          return new Call(null, className, name, desc) {
    5.14              @Override
    5.15              public MethodEmitter invoke(final MethodEmitter method) {
    5.16 -                return method.invokeStatic(className, name, descriptor);
    5.17 +                return method.invokestatic(className, name, descriptor);
    5.18              }
    5.19          };
    5.20      }
    5.21 @@ -389,7 +389,7 @@
    5.22          return new Call(null, className(clazz), name, methodDescriptor(rtype, ptypes)) {
    5.23              @Override
    5.24              public MethodEmitter invoke(final MethodEmitter method) {
    5.25 -                return method.invokeVirtual(className, name, descriptor);
    5.26 +                return method.invokevirtual(className, name, descriptor);
    5.27              }
    5.28          };
    5.29      }
    5.30 @@ -409,7 +409,7 @@
    5.31          return new Call(null, className(clazz), name, methodDescriptor(rtype, ptypes)) {
    5.32              @Override
    5.33              public MethodEmitter invoke(final MethodEmitter method) {
    5.34 -                return method.invokeInterface(className, name, descriptor);
    5.35 +                return method.invokeinterface(className, name, descriptor);
    5.36              }
    5.37          };
    5.38      }
    5.39 @@ -519,7 +519,7 @@
    5.40          return new Call(MH.findStatic(lookup, clazz, name, MH.type(rtype, ptypes)), className(clazz), name, methodDescriptor(rtype, ptypes)) {
    5.41              @Override
    5.42              public MethodEmitter invoke(final MethodEmitter method) {
    5.43 -                return method.invokeStatic(className, name, descriptor);
    5.44 +                return method.invokestatic(className, name, descriptor);
    5.45              }
    5.46          };
    5.47      }
    5.48 @@ -553,7 +553,7 @@
    5.49          return new Call(MH.findVirtual(lookup, clazz, name, MH.type(rtype, ptypes)), className(clazz), name, methodDescriptor(rtype, ptypes)) {
    5.50              @Override
    5.51              public MethodEmitter invoke(final MethodEmitter method) {
    5.52 -                return method.invokeVirtual(className, name, descriptor);
    5.53 +                return method.invokevirtual(className, name, descriptor);
    5.54              }
    5.55          };
    5.56      }
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/jdk/nashorn/internal/codegen/Condition.java	Fri Feb 15 09:44:15 2013 +0100
     6.3 @@ -0,0 +1,107 @@
     6.4 +/*
     6.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
     6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.7 + *
     6.8 + * This code is free software; you can redistribute it and/or modify it
     6.9 + * under the terms of the GNU General Public License version 2 only, as
    6.10 + * published by the Free Software Foundation.  Oracle designates this
    6.11 + * particular file as subject to the "Classpath" exception as provided
    6.12 + * by Oracle in the LICENSE file that accompanied this code.
    6.13 + *
    6.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    6.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    6.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    6.17 + * version 2 for more details (a copy is included in the LICENSE file that
    6.18 + * accompanied this code).
    6.19 + *
    6.20 + * You should have received a copy of the GNU General Public License version
    6.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    6.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    6.23 + *
    6.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    6.25 + * or visit www.oracle.com if you need additional information or have any
    6.26 + * questions.
    6.27 + */
    6.28 +
    6.29 +package jdk.nashorn.internal.codegen;
    6.30 +
    6.31 +import static jdk.internal.org.objectweb.asm.Opcodes.IFEQ;
    6.32 +import static jdk.internal.org.objectweb.asm.Opcodes.IFGE;
    6.33 +import static jdk.internal.org.objectweb.asm.Opcodes.IFGT;
    6.34 +import static jdk.internal.org.objectweb.asm.Opcodes.IFLE;
    6.35 +import static jdk.internal.org.objectweb.asm.Opcodes.IFLT;
    6.36 +import static jdk.internal.org.objectweb.asm.Opcodes.IFNE;
    6.37 +import static jdk.internal.org.objectweb.asm.Opcodes.IF_ACMPEQ;
    6.38 +import static jdk.internal.org.objectweb.asm.Opcodes.IF_ACMPNE;
    6.39 +import static jdk.internal.org.objectweb.asm.Opcodes.IF_ICMPEQ;
    6.40 +import static jdk.internal.org.objectweb.asm.Opcodes.IF_ICMPGE;
    6.41 +import static jdk.internal.org.objectweb.asm.Opcodes.IF_ICMPGT;
    6.42 +import static jdk.internal.org.objectweb.asm.Opcodes.IF_ICMPLE;
    6.43 +import static jdk.internal.org.objectweb.asm.Opcodes.IF_ICMPLT;
    6.44 +import static jdk.internal.org.objectweb.asm.Opcodes.IF_ICMPNE;
    6.45 +import jdk.nashorn.internal.ir.RuntimeNode;
    6.46 +
    6.47 +/**
    6.48 + * Condition enum used for all kinds of jumps, regardless of type
    6.49 + */
    6.50 +enum Condition {
    6.51 +    EQ,
    6.52 +    NE,
    6.53 +    LE,
    6.54 +    LT,
    6.55 +    GE,
    6.56 +    GT;
    6.57 +
    6.58 +    static Condition forRuntimeRequest(final RuntimeNode.Request request) {
    6.59 +        try {
    6.60 +            final String reqString = request.toString().replace("_STRICT", "");
    6.61 +            return Condition.valueOf(reqString);
    6.62 +        } catch (final IllegalArgumentException e) {
    6.63 +            return null;
    6.64 +        }
    6.65 +    }
    6.66 +
    6.67 +    static int toUnary(final Condition c) {
    6.68 +        switch (c) {
    6.69 +        case EQ:
    6.70 +            return IFEQ;
    6.71 +        case NE:
    6.72 +            return IFNE;
    6.73 +        case LE:
    6.74 +            return IFLE;
    6.75 +        case LT:
    6.76 +            return IFLT;
    6.77 +        case GE:
    6.78 +            return IFGE;
    6.79 +        case GT:
    6.80 +            return IFGT;
    6.81 +        default:
    6.82 +            assert false;
    6.83 +            return -1;
    6.84 +        }
    6.85 +    }
    6.86 +
    6.87 +    static int toBinary(final Condition c) {
    6.88 +        return toBinary(c, false);
    6.89 +    }
    6.90 +
    6.91 +    static int toBinary(final Condition c, final boolean isObject) {
    6.92 +        switch (c) {
    6.93 +        case EQ:
    6.94 +            return isObject ? IF_ACMPEQ : IF_ICMPEQ;
    6.95 +        case NE:
    6.96 +            return isObject ? IF_ACMPNE : IF_ICMPNE;
    6.97 +        case LE:
    6.98 +            return IF_ICMPLE;
    6.99 +        case LT:
   6.100 +            return IF_ICMPLT;
   6.101 +        case GE:
   6.102 +            return IF_ICMPGE;
   6.103 +        case GT:
   6.104 +            return IF_ICMPGT;
   6.105 +        default:
   6.106 +            assert false;
   6.107 +            return -1;
   6.108 +        }
   6.109 +    }
   6.110 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/src/jdk/nashorn/internal/codegen/FieldObjectCreator.java	Fri Feb 15 09:44:15 2013 +0100
     7.3 @@ -0,0 +1,191 @@
     7.4 +/*
     7.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
     7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.7 + *
     7.8 + * This code is free software; you can redistribute it and/or modify it
     7.9 + * under the terms of the GNU General Public License version 2 only, as
    7.10 + * published by the Free Software Foundation.  Oracle designates this
    7.11 + * particular file as subject to the "Classpath" exception as provided
    7.12 + * by Oracle in the LICENSE file that accompanied this code.
    7.13 + *
    7.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    7.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    7.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    7.17 + * version 2 for more details (a copy is included in the LICENSE file that
    7.18 + * accompanied this code).
    7.19 + *
    7.20 + * You should have received a copy of the GNU General Public License version
    7.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    7.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    7.23 + *
    7.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    7.25 + * or visit www.oracle.com if you need additional information or have any
    7.26 + * questions.
    7.27 + */
    7.28 +
    7.29 +package jdk.nashorn.internal.codegen;
    7.30 +
    7.31 +import static jdk.nashorn.internal.codegen.CompilerConstants.ARGUMENTS;
    7.32 +import static jdk.nashorn.internal.codegen.CompilerConstants.constructorNoLookup;
    7.33 +import static jdk.nashorn.internal.codegen.CompilerConstants.typeDescriptor;
    7.34 +import static jdk.nashorn.internal.codegen.types.Type.OBJECT;
    7.35 +
    7.36 +import java.util.Iterator;
    7.37 +import java.util.List;
    7.38 +import jdk.nashorn.internal.codegen.types.Type;
    7.39 +import jdk.nashorn.internal.ir.Symbol;
    7.40 +import jdk.nashorn.internal.runtime.PropertyMap;
    7.41 +import jdk.nashorn.internal.runtime.ScriptObject;
    7.42 +import jdk.nashorn.internal.runtime.arrays.ArrayIndex;
    7.43 +
    7.44 +/**
    7.45 + * Analyze an object's characteristics for appropriate code generation. This
    7.46 + * is used for functions and for objects. A field object take a set of values which
    7.47 + * to assign to the various fields in the object. This is done by the generated code
    7.48 + *
    7.49 + * @param <T> the value type for the fields being written on object creation, e.g. Node
    7.50 + * @see jdk.nashorn.internal.ir.Node
    7.51 + */
    7.52 +public abstract class FieldObjectCreator<T> extends ObjectCreator {
    7.53 +    /** array of corresponding values to symbols (null for no values) */
    7.54 +    private final List<T> values;
    7.55 +
    7.56 +    /** call site flags to be used for invocations */
    7.57 +    private final int     callSiteFlags;
    7.58 +
    7.59 +    /**
    7.60 +     * Constructor
    7.61 +     *
    7.62 +     * @param codegen  code generator
    7.63 +     * @param keys     keys for fields in object
    7.64 +     * @param symbols  symbols for fields in object
    7.65 +     * @param values   list of values corresponding to keys
    7.66 +     */
    7.67 +    FieldObjectCreator(final CodeGenerator codegen, final List<String> keys, final List<Symbol> symbols, final List<T> values) {
    7.68 +        this(codegen, keys, symbols, values, false, false);
    7.69 +    }
    7.70 +
    7.71 +    /**
    7.72 +     * Constructor
    7.73 +     *
    7.74 +     * @param codegen      code generator
    7.75 +     * @param keys         keys for fields in object
    7.76 +     * @param symbols      symbols for fields in object
    7.77 +     * @param values       values (or null where no value) to be written to the fields
    7.78 +     * @param isScope      is this a scope object
    7.79 +     * @param hasArguments does the created object have an "arguments" property
    7.80 +     */
    7.81 +    FieldObjectCreator(final CodeGenerator codegen, final List<String> keys, final List<Symbol> symbols, final List<T> values, final boolean isScope, final boolean hasArguments) {
    7.82 +        super(codegen, keys, symbols, isScope, hasArguments);
    7.83 +        this.values        = values;
    7.84 +        this.callSiteFlags = codegen.getCallSiteFlags();
    7.85 +    }
    7.86 +
    7.87 +    /**
    7.88 +     * Loads the scope on the stack through the passed method emitter.
    7.89 +     * @param method the method emitter to use
    7.90 +     */
    7.91 +    protected void loadScope(final MethodEmitter method) {
    7.92 +        method.loadScope();
    7.93 +    }
    7.94 +
    7.95 +    /**
    7.96 +     * Construct an object.
    7.97 +     *
    7.98 +     * @param method the method emitter
    7.99 +     */
   7.100 +    @Override
   7.101 +    protected void makeObject(final MethodEmitter method) {
   7.102 +        makeMap();
   7.103 +
   7.104 +        method._new(getClassName()).dup(); // create instance
   7.105 +        loadMap(method); //load the map
   7.106 +
   7.107 +        if (isScope()) {
   7.108 +            loadScope(method);
   7.109 +
   7.110 +            if (hasArguments()) {
   7.111 +                method.loadArguments();
   7.112 +                method.invoke(constructorNoLookup(getClassName(), PropertyMap.class, ScriptObject.class, ARGUMENTS.type()));
   7.113 +            } else {
   7.114 +                method.invoke(constructorNoLookup(getClassName(), PropertyMap.class, ScriptObject.class));
   7.115 +            }
   7.116 +        } else {
   7.117 +            method.invoke(constructorNoLookup(getClassName(), PropertyMap.class));
   7.118 +        }
   7.119 +
   7.120 +        // Set values.
   7.121 +        final Iterator<Symbol> symbolIter = symbols.iterator();
   7.122 +        final Iterator<String> keyIter    = keys.iterator();
   7.123 +        final Iterator<T>      valueIter  = values.iterator();
   7.124 +
   7.125 +        while (symbolIter.hasNext()) {
   7.126 +            final Symbol symbol = symbolIter.next();
   7.127 +            final String key    = keyIter.next();
   7.128 +            final T      value  = valueIter.next();
   7.129 +
   7.130 +            if (symbol != null && value != null) {
   7.131 +                final int index = ArrayIndex.getArrayIndexNoThrow(key);
   7.132 +
   7.133 +                if (index < 0) {
   7.134 +                    putField(method, key, symbol.getFieldIndex(), value);
   7.135 +                } else {
   7.136 +                    putSlot(method, index, value);
   7.137 +                }
   7.138 +            }
   7.139 +        }
   7.140 +    }
   7.141 +
   7.142 +    /**
   7.143 +     * Technique for loading an initial value. Defined by anonymous subclasses in code gen.
   7.144 +     *
   7.145 +     * @param value Value to load.
   7.146 +     */
   7.147 +    protected abstract void loadValue(T value);
   7.148 +
   7.149 +    /**
   7.150 +     * Determine the type of a value. Defined by anonymous subclasses in code gen.
   7.151 +     *
   7.152 +     * @param value Value to inspect.
   7.153 +     *
   7.154 +     * @return Value type.
   7.155 +     */
   7.156 +    protected abstract Type getValueType(T value);
   7.157 +
   7.158 +    /**
   7.159 +     * Store a value in a field of the generated class object.
   7.160 +     *
   7.161 +     * @param method      Script method.
   7.162 +     * @param key         Property key.
   7.163 +     * @param fieldIndex  Field number.
   7.164 +     * @param value       Value to store.
   7.165 +     */
   7.166 +    private void putField(final MethodEmitter method, final String key, final int fieldIndex, final T value) {
   7.167 +        method.dup();
   7.168 +
   7.169 +        loadValue(value);
   7.170 +
   7.171 +        final Type valueType = getValueType(value);
   7.172 +        // for example when we have a with scope
   7.173 +        if (valueType.isObject() || valueType.isBoolean()) {
   7.174 +            method.convert(OBJECT);
   7.175 +        }
   7.176 +
   7.177 +        method.convert(OBJECT);
   7.178 +        method.putField(getClassName(), ObjectClassGenerator.getFieldName(fieldIndex, Type.OBJECT), typeDescriptor(Object.class));
   7.179 +    }
   7.180 +
   7.181 +    /**
   7.182 +     * Store a value in an indexed slot of a generated class object.
   7.183 +     *
   7.184 +     * @param method Script method.
   7.185 +     * @param index  Slot index.
   7.186 +     * @param value  Value to store.
   7.187 +     */
   7.188 +    private void putSlot(final MethodEmitter method, final int index, final T value) {
   7.189 +        method.dup();
   7.190 +        method.load(index);
   7.191 +        loadValue(value);
   7.192 +        method.dynamicSetIndex(callSiteFlags);
   7.193 +    }
   7.194 +}
     8.1 --- a/src/jdk/nashorn/internal/codegen/FunctionSignature.java	Fri Feb 15 09:18:05 2013 +0100
     8.2 +++ b/src/jdk/nashorn/internal/codegen/FunctionSignature.java	Fri Feb 15 09:44:15 2013 +0100
     8.3 @@ -202,7 +202,6 @@
     8.4          return methodType;
     8.5      }
     8.6  
     8.7 -
     8.8      private static Type[] objectArgs(final int nArgs) {
     8.9          final Type[] array = new Type[nArgs];
    8.10          for (int i = 0; i < nArgs; i++) {
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/src/jdk/nashorn/internal/codegen/Label.java	Fri Feb 15 09:44:15 2013 +0100
     9.3 @@ -0,0 +1,83 @@
     9.4 +/*
     9.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
     9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.7 + *
     9.8 + * This code is free software; you can redistribute it and/or modify it
     9.9 + * under the terms of the GNU General Public License version 2 only, as
    9.10 + * published by the Free Software Foundation.  Oracle designates this
    9.11 + * particular file as subject to the "Classpath" exception as provided
    9.12 + * by Oracle in the LICENSE file that accompanied this code.
    9.13 + *
    9.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    9.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    9.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    9.17 + * version 2 for more details (a copy is included in the LICENSE file that
    9.18 + * accompanied this code).
    9.19 + *
    9.20 + * You should have received a copy of the GNU General Public License version
    9.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    9.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    9.23 + *
    9.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    9.25 + * or visit www.oracle.com if you need additional information or have any
    9.26 + * questions.
    9.27 + */
    9.28 +package jdk.nashorn.internal.codegen;
    9.29 +
    9.30 +import java.util.ArrayDeque;
    9.31 +
    9.32 +import jdk.nashorn.internal.codegen.types.Type;
    9.33 +
    9.34 +/**
    9.35 + * Abstraction for labels, separating a label from the underlying
    9.36 + * byte code emitter. Also augmenting label with e.g. a name
    9.37 + * for easier debugging and reading code
    9.38 + *
    9.39 + * see -Dnashorn.codegen.debug, --log=codegen
    9.40 + */
    9.41 +public class Label extends jdk.internal.org.objectweb.asm.Label {
    9.42 +    /** Name of this label */
    9.43 +    private final String name;
    9.44 +
    9.45 +    /** Type stack at this label */
    9.46 +    private ArrayDeque<Type> stack;
    9.47 +
    9.48 +    /**
    9.49 +     * Constructor
    9.50 +     *
    9.51 +     * @param name name of this label
    9.52 +     */
    9.53 +    public Label(final String name) {
    9.54 +        super();
    9.55 +        this.name = name;
    9.56 +    }
    9.57 +
    9.58 +    /**
    9.59 +     * Copy constructor
    9.60 +     *
    9.61 +     * @param label a label to clone
    9.62 +     */
    9.63 +    public Label(final Label label) {
    9.64 +        super();
    9.65 +        this.name = label.name;
    9.66 +    }
    9.67 +
    9.68 +    ArrayDeque<Type> getStack() {
    9.69 +        return stack;
    9.70 +    }
    9.71 +
    9.72 +    void setStack(final ArrayDeque<Type> stack) {
    9.73 +        this.stack = stack;
    9.74 +    }
    9.75 +
    9.76 +    @Override
    9.77 +    public String toString() {
    9.78 +        final StringBuilder sb = new StringBuilder();
    9.79 +        String s = super.toString();
    9.80 +        s = s.substring(1, s.length());
    9.81 +        sb.append(name).append('_').append(Long.toHexString(Long.parseLong(s)));
    9.82 +
    9.83 +        return sb.toString();
    9.84 +    }
    9.85 +}
    9.86 +
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/src/jdk/nashorn/internal/codegen/MapCreator.java	Fri Feb 15 09:44:15 2013 +0100
    10.3 @@ -0,0 +1,122 @@
    10.4 +/*
    10.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    10.7 + *
    10.8 + * This code is free software; you can redistribute it and/or modify it
    10.9 + * under the terms of the GNU General Public License version 2 only, as
   10.10 + * published by the Free Software Foundation.  Oracle designates this
   10.11 + * particular file as subject to the "Classpath" exception as provided
   10.12 + * by Oracle in the LICENSE file that accompanied this code.
   10.13 + *
   10.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   10.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   10.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   10.17 + * version 2 for more details (a copy is included in the LICENSE file that
   10.18 + * accompanied this code).
   10.19 + *
   10.20 + * You should have received a copy of the GNU General Public License version
   10.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   10.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   10.23 + *
   10.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   10.25 + * or visit www.oracle.com if you need additional information or have any
   10.26 + * questions.
   10.27 + */
   10.28 +
   10.29 +package jdk.nashorn.internal.codegen;
   10.30 +
   10.31 +import java.util.ArrayList;
   10.32 +import java.util.List;
   10.33 +import jdk.nashorn.internal.ir.Symbol;
   10.34 +import jdk.nashorn.internal.runtime.AccessorProperty;
   10.35 +import jdk.nashorn.internal.runtime.Property;
   10.36 +import jdk.nashorn.internal.runtime.PropertyMap;
   10.37 +import jdk.nashorn.internal.runtime.arrays.ArrayIndex;
   10.38 +
   10.39 +/**
   10.40 + * Class that creates PropertyMap sent to script object constructors.
   10.41 + */
   10.42 +public class MapCreator {
   10.43 +    /** Object structure for objects associated with this map */
   10.44 +    private final Class<?> structure;
   10.45 +
   10.46 +    /** key set for object map */
   10.47 +    private final String[] keys;
   10.48 +
   10.49 +    /** corresponding symbol set for object map */
   10.50 +    private final Symbol[] symbols;
   10.51 +
   10.52 +    /**
   10.53 +     * Constructor
   10.54 +     *
   10.55 +     * @param structure structure to generate map for (a JO$ subclass)
   10.56 +     * @param keys      list of keys for map
   10.57 +     * @param symbols   list of symbols for map
   10.58 +     */
   10.59 +    MapCreator(final Class<?> structure, final List<String> keys, final List<Symbol> symbols) {
   10.60 +        final int size   = keys.size();
   10.61 +
   10.62 +        this.structure = structure;
   10.63 +        this.keys      = keys.toArray(new String[size]);
   10.64 +        this.symbols   = symbols.toArray(new Symbol[size]);
   10.65 +    }
   10.66 +
   10.67 +    /**
   10.68 +     * Constructs a property map based on a set of fields.
   10.69 +     *
   10.70 +     * @param hasArguments does the created object have an "arguments" property
   10.71 +     *
   10.72 +     * @return New map populated with accessor properties.
   10.73 +     */
   10.74 +    PropertyMap makeMap(final boolean hasArguments) {
   10.75 +        final List<Property> properties = new ArrayList<>();
   10.76 +
   10.77 +        assert keys != null;
   10.78 +
   10.79 +        for (int i = 0; i < keys.length; i++) {
   10.80 +            final String key    = keys[i];
   10.81 +            final Symbol symbol = symbols[i];
   10.82 +
   10.83 +            if (symbol != null && !ArrayIndex.isIndexKey(key)) {
   10.84 +                properties.add(new AccessorProperty(key, getPropertyFlags(symbol, hasArguments), structure, symbol.getFieldIndex()));
   10.85 +            }
   10.86 +        }
   10.87 +
   10.88 +        return PropertyMap.newMap(structure, properties);
   10.89 +    }
   10.90 +
   10.91 +    /**
   10.92 +     * Compute property flags given local state of a field. May be overridden and extended,
   10.93 +     *
   10.94 +     * @param symbol       symbol to check
   10.95 +     * @param hasArguments does the created object have an "arguments" property
   10.96 +     *
   10.97 +     * @return flags to use for fields
   10.98 +     */
   10.99 +    protected int getPropertyFlags(final Symbol symbol, final boolean hasArguments) {
  10.100 +        int flags = 0;
  10.101 +
  10.102 +        if (symbol.isParam()) {
  10.103 +            flags |= Property.IS_ALWAYS_OBJECT | Property.IS_PARAMETER;
  10.104 +        }
  10.105 +
  10.106 +        if (hasArguments) {
  10.107 +            flags |= Property.IS_ALWAYS_OBJECT | Property.HAS_ARGUMENTS;
  10.108 +        }
  10.109 +
  10.110 +        if (symbol.isScope()) {
  10.111 +            flags |= Property.NOT_CONFIGURABLE;
  10.112 +        }
  10.113 +
  10.114 +        if (symbol.canBePrimitive()) {
  10.115 +            flags |= Property.CAN_BE_PRIMITIVE;
  10.116 +        }
  10.117 +
  10.118 +        if (symbol.canBeUndefined()) {
  10.119 +            flags |= Property.CAN_BE_UNDEFINED;
  10.120 +        }
  10.121 +
  10.122 +        return flags;
  10.123 +    }
  10.124 +
  10.125 +}
    11.1 --- a/src/jdk/nashorn/internal/codegen/MethodEmitter.java	Fri Feb 15 09:18:05 2013 +0100
    11.2 +++ b/src/jdk/nashorn/internal/codegen/MethodEmitter.java	Fri Feb 15 09:44:15 2013 +0100
    11.3 @@ -43,10 +43,6 @@
    11.4  import static jdk.internal.org.objectweb.asm.Opcodes.IF_ACMPEQ;
    11.5  import static jdk.internal.org.objectweb.asm.Opcodes.IF_ACMPNE;
    11.6  import static jdk.internal.org.objectweb.asm.Opcodes.IF_ICMPEQ;
    11.7 -import static jdk.internal.org.objectweb.asm.Opcodes.IF_ICMPGE;
    11.8 -import static jdk.internal.org.objectweb.asm.Opcodes.IF_ICMPGT;
    11.9 -import static jdk.internal.org.objectweb.asm.Opcodes.IF_ICMPLE;
   11.10 -import static jdk.internal.org.objectweb.asm.Opcodes.IF_ICMPLT;
   11.11  import static jdk.internal.org.objectweb.asm.Opcodes.IF_ICMPNE;
   11.12  import static jdk.internal.org.objectweb.asm.Opcodes.INSTANCEOF;
   11.13  import static jdk.internal.org.objectweb.asm.Opcodes.INVOKEINTERFACE;
   11.14 @@ -114,7 +110,7 @@
   11.15      private final MethodVisitor method;
   11.16  
   11.17      /** Current type stack for current evaluation */
   11.18 -    protected ArrayDeque<Type> stack;
   11.19 +    private ArrayDeque<Type> stack;
   11.20  
   11.21      /** Parent classEmitter representing the class of this method */
   11.22      private final ClassEmitter classEmitter;
   11.23 @@ -287,7 +283,7 @@
   11.24       *
   11.25       * @return the type at position "pos" on the stack
   11.26       */
   11.27 -    public final Type peekType(final int pos) {
   11.28 +    final Type peekType(final int pos) {
   11.29          final Iterator<Type> iter = stack.iterator();
   11.30          for (int i = 0; i < pos; i++) {
   11.31              iter.next();
   11.32 @@ -300,7 +296,7 @@
   11.33       *
   11.34       * @return the type at the top of the stack
   11.35       */
   11.36 -    public final Type peekType() {
   11.37 +    final Type peekType() {
   11.38          return stack.peek();
   11.39      }
   11.40  
   11.41 @@ -312,7 +308,7 @@
   11.42       *
   11.43       * @return the method emitter
   11.44       */
   11.45 -    public MethodEmitter _new(final String classDescriptor) {
   11.46 +    MethodEmitter _new(final String classDescriptor) {
   11.47          debug("new", classDescriptor);
   11.48          method.visitTypeInsn(NEW, classDescriptor);
   11.49          pushType(Type.OBJECT);
   11.50 @@ -327,7 +323,7 @@
   11.51       *
   11.52       * @return the method emitter
   11.53       */
   11.54 -    public MethodEmitter _new(final Class<?> clazz) {
   11.55 +    MethodEmitter _new(final Class<?> clazz) {
   11.56          return _new(className(clazz));
   11.57      }
   11.58  
   11.59 @@ -338,7 +334,7 @@
   11.60       *
   11.61       * @return the method emitter
   11.62       */
   11.63 -    public MethodEmitter newInstance(final Class<?> clazz) {
   11.64 +    MethodEmitter newInstance(final Class<?> clazz) {
   11.65          return invoke(constructorNoLookup(clazz));
   11.66      }
   11.67  
   11.68 @@ -352,7 +348,7 @@
   11.69       * @return the method emitter, or null if depth is illegal and
   11.70       *  has no instruction equivalent.
   11.71       */
   11.72 -    public MethodEmitter dup(final int depth) {
   11.73 +    MethodEmitter dup(final int depth) {
   11.74          if (peekType().dup(method, depth) == null) {
   11.75              return null;
   11.76          }
   11.77 @@ -396,7 +392,7 @@
   11.78       *
   11.79       * @return the method emitter
   11.80       */
   11.81 -    public MethodEmitter dup2() {
   11.82 +    MethodEmitter dup2() {
   11.83          debug("dup2");
   11.84  
   11.85          if (peekType().isCategory2()) {
   11.86 @@ -417,7 +413,7 @@
   11.87       *
   11.88       * @return the method emitter
   11.89       */
   11.90 -    public MethodEmitter dup() {
   11.91 +    MethodEmitter dup() {
   11.92          return dup(0);
   11.93      }
   11.94  
   11.95 @@ -426,7 +422,7 @@
   11.96       *
   11.97       * @return the method emitter
   11.98       */
   11.99 -    public MethodEmitter pop() {
  11.100 +    MethodEmitter pop() {
  11.101          debug("pop", peekType());
  11.102          popType().pop(method);
  11.103          return this;
  11.104 @@ -438,7 +434,7 @@
  11.105       *
  11.106       * @return the method emitter
  11.107       */
  11.108 -    public MethodEmitter pop2() {
  11.109 +    MethodEmitter pop2() {
  11.110          if (peekType().isCategory2()) {
  11.111              popType();
  11.112          } else {
  11.113 @@ -453,7 +449,7 @@
  11.114       *
  11.115       * @return the method emitter
  11.116       */
  11.117 -    public MethodEmitter swap() {
  11.118 +    MethodEmitter swap() {
  11.119          debug("swap");
  11.120  
  11.121          final Type p0 = popType();
  11.122 @@ -473,7 +469,7 @@
  11.123       * @param start  start of scope
  11.124       * @param end    end of scope
  11.125       */
  11.126 -    public void localVariable(final Symbol symbol, final Label start, final Label end) {
  11.127 +    void localVariable(final Symbol symbol, final Label start, final Label end) {
  11.128          if (!symbol.hasSlot()) {
  11.129              return;
  11.130          }
  11.131 @@ -492,7 +488,7 @@
  11.132       *
  11.133       * @return the method emitter
  11.134       */
  11.135 -    public MethodEmitter newStringBuilder() {
  11.136 +    MethodEmitter newStringBuilder() {
  11.137          return invoke(constructorNoLookup(StringBuilder.class)).dup();
  11.138      }
  11.139  
  11.140 @@ -503,7 +499,7 @@
  11.141       *
  11.142       * @return the method emitter
  11.143       */
  11.144 -    public MethodEmitter stringBuilderAppend() {
  11.145 +    MethodEmitter stringBuilderAppend() {
  11.146          convert(Type.STRING);
  11.147          return invoke(virtualCallNoLookup(StringBuilder.class, "append", StringBuilder.class, String.class));
  11.148      }
  11.149 @@ -515,7 +511,7 @@
  11.150       * @param start start
  11.151       * @param end   end
  11.152       */
  11.153 -    public void markerVariable(final String name, final Label start, final Label end) {
  11.154 +    void markerVariable(final String name, final Label start, final Label end) {
  11.155          method.visitLocalVariable(name, Type.OBJECT.getDescriptor(), null, start, end, 0);
  11.156      }
  11.157  
  11.158 @@ -525,7 +521,7 @@
  11.159       *
  11.160       * @return the method emitter
  11.161       */
  11.162 -    public MethodEmitter and() {
  11.163 +    MethodEmitter and() {
  11.164          debug("and");
  11.165          pushType(get2i().and(method));
  11.166          return this;
  11.167 @@ -537,7 +533,7 @@
  11.168       *
  11.169       * @return the method emitter
  11.170       */
  11.171 -    public MethodEmitter or() {
  11.172 +    MethodEmitter or() {
  11.173          debug("or");
  11.174          pushType(get2i().or(method));
  11.175          return this;
  11.176 @@ -549,7 +545,7 @@
  11.177       *
  11.178       * @return the method emitter
  11.179       */
  11.180 -    public MethodEmitter xor() {
  11.181 +    MethodEmitter xor() {
  11.182          debug("xor");
  11.183          pushType(get2i().xor(method));
  11.184          return this;
  11.185 @@ -561,7 +557,7 @@
  11.186       *
  11.187       * @return the method emitter
  11.188       */
  11.189 -    public MethodEmitter shr() {
  11.190 +    MethodEmitter shr() {
  11.191          debug("shr");
  11.192          popType(Type.INT);
  11.193          pushType(popInteger().shr(method));
  11.194 @@ -574,7 +570,7 @@
  11.195       *
  11.196       * @return the method emitter
  11.197       */
  11.198 -    public MethodEmitter shl() {
  11.199 +    MethodEmitter shl() {
  11.200          debug("shl");
  11.201          popType(Type.INT);
  11.202          pushType(popInteger().shl(method));
  11.203 @@ -587,7 +583,7 @@
  11.204       *
  11.205       * @return the method emitter
  11.206       */
  11.207 -    public MethodEmitter sar() {
  11.208 +    MethodEmitter sar() {
  11.209          debug("sar");
  11.210          popType(Type.INT);
  11.211          pushType(popInteger().sar(method));
  11.212 @@ -599,7 +595,7 @@
  11.213       *
  11.214       * @return the method emitter
  11.215       */
  11.216 -    public MethodEmitter neg() {
  11.217 +    MethodEmitter neg() {
  11.218          debug("neg");
  11.219          pushType(popNumeric().neg(method));
  11.220          return this;
  11.221 @@ -611,7 +607,7 @@
  11.222       *
  11.223       * @param recovery label pointing to start of catch block
  11.224       */
  11.225 -    public void _catch(final Label recovery) {
  11.226 +    void _catch(final Label recovery) {
  11.227          stack.clear();
  11.228          stack.push(Type.OBJECT);
  11.229          label(recovery);
  11.230 @@ -625,7 +621,7 @@
  11.231       * @param recovery       start label for catch
  11.232       * @param typeDescriptor type descriptor for exception
  11.233       */
  11.234 -    public void _try(final Label entry, final Label exit, final Label recovery, final String typeDescriptor) {
  11.235 +    void _try(final Label entry, final Label exit, final Label recovery, final String typeDescriptor) {
  11.236          method.visitTryCatchBlock(entry, exit, recovery, typeDescriptor);
  11.237      }
  11.238  
  11.239 @@ -637,7 +633,7 @@
  11.240       * @param recovery start label for catch
  11.241       * @param clazz    exception class
  11.242       */
  11.243 -    public void _try(final Label entry, final Label exit, final Label recovery, final Class<?> clazz) {
  11.244 +    void _try(final Label entry, final Label exit, final Label recovery, final Class<?> clazz) {
  11.245          method.visitTryCatchBlock(entry, exit, recovery, CompilerConstants.className(clazz));
  11.246      }
  11.247  
  11.248 @@ -648,7 +644,7 @@
  11.249       * @param exit     end label for try
  11.250       * @param recovery start label for catch
  11.251       */
  11.252 -    public void _try(final Label entry, final Label exit, final Label recovery) {
  11.253 +    void _try(final Label entry, final Label exit, final Label recovery) {
  11.254          _try(entry, exit, recovery, (String)null);
  11.255      }
  11.256  
  11.257 @@ -658,7 +654,7 @@
  11.258       * @param unitClassName name of the compile unit from which to load constants
  11.259       * @return this method emitter
  11.260       */
  11.261 -    public MethodEmitter loadConstants(final String unitClassName) {
  11.262 +    MethodEmitter loadConstants(final String unitClassName) {
  11.263          getStatic(unitClassName, CONSTANTS.tag(), CONSTANTS.descriptor());
  11.264          assert peekType().isArray() : peekType();
  11.265          return this;
  11.266 @@ -673,7 +669,7 @@
  11.267       * @param type the type for which to push UNDEFINED
  11.268       * @return the method emitter
  11.269       */
  11.270 -    public MethodEmitter loadUndefined(final Type type) {
  11.271 +    MethodEmitter loadUndefined(final Type type) {
  11.272          debug("load undefined " + type);
  11.273          pushType(type.loadUndefined(method));
  11.274          return this;
  11.275 @@ -685,7 +681,7 @@
  11.276       * @param type the type
  11.277       * @return the method emitter
  11.278       */
  11.279 -    public MethodEmitter loadEmpty(final Type type) {
  11.280 +    MethodEmitter loadEmpty(final Type type) {
  11.281          debug("load empty " + type);
  11.282          pushType(type.loadEmpty(method));
  11.283          return this;
  11.284 @@ -696,7 +692,7 @@
  11.285       *
  11.286       * @return the method emitter
  11.287       */
  11.288 -    public MethodEmitter loadNull() {
  11.289 +    MethodEmitter loadNull() {
  11.290          debug("aconst_null");
  11.291          pushType(Type.OBJECT.ldc(method, null));
  11.292          return this;
  11.293 @@ -709,7 +705,7 @@
  11.294       *
  11.295       * @return the method emitter
  11.296       */
  11.297 -    public MethodEmitter loadType(final String className) {
  11.298 +    MethodEmitter loadType(final String className) {
  11.299          debug("load type", className);
  11.300          method.visitLdcInsn(jdk.internal.org.objectweb.asm.Type.getObjectType(className));
  11.301          pushType(Type.OBJECT);
  11.302 @@ -723,7 +719,7 @@
  11.303       *
  11.304       * @return the method emitter
  11.305       */
  11.306 -    public MethodEmitter load(final boolean b) {
  11.307 +    MethodEmitter load(final boolean b) {
  11.308          debug("load boolean", b);
  11.309          pushType(Type.BOOLEAN.ldc(method, b));
  11.310          return this;
  11.311 @@ -736,7 +732,7 @@
  11.312       *
  11.313       * @return the method emitter
  11.314       */
  11.315 -    public MethodEmitter load(final int i) {
  11.316 +    MethodEmitter load(final int i) {
  11.317          debug("load int", i);
  11.318          pushType(Type.INT.ldc(method, i));
  11.319          return this;
  11.320 @@ -749,7 +745,7 @@
  11.321       *
  11.322       * @return the method emitter
  11.323       */
  11.324 -    public MethodEmitter load(final double d) {
  11.325 +    MethodEmitter load(final double d) {
  11.326          debug("load double", d);
  11.327          pushType(Type.NUMBER.ldc(method, d));
  11.328          return this;
  11.329 @@ -762,7 +758,7 @@
  11.330       *
  11.331       * @return the method emitter
  11.332       */
  11.333 -    public MethodEmitter load(final long l) {
  11.334 +    MethodEmitter load(final long l) {
  11.335          debug("load long", l);
  11.336          pushType(Type.LONG.ldc(method, l));
  11.337          return this;
  11.338 @@ -772,7 +768,7 @@
  11.339       * Fetch the length of an array.
  11.340       * @return Array length.
  11.341       */
  11.342 -    public MethodEmitter arraylength() {
  11.343 +    MethodEmitter arraylength() {
  11.344          debug("arraylength");
  11.345          popType(Type.OBJECT);
  11.346          pushType(Type.OBJECT_ARRAY.arraylength(method));
  11.347 @@ -786,7 +782,7 @@
  11.348       *
  11.349       * @return the method emitter
  11.350       */
  11.351 -    public MethodEmitter load(final String s) {
  11.352 +    MethodEmitter load(final String s) {
  11.353          debug("load string", s);
  11.354  
  11.355          if (s == null) {
  11.356 @@ -826,7 +822,7 @@
  11.357       *
  11.358       * @return the method emitter
  11.359       */
  11.360 -    public MethodEmitter load(final Symbol symbol) {
  11.361 +    MethodEmitter load(final Symbol symbol) {
  11.362          assert symbol != null;
  11.363          if (symbol.hasSlot()) {
  11.364              final int slot = symbol.getSlot();
  11.365 @@ -837,7 +833,7 @@
  11.366              assert !symbol.isScope();
  11.367              assert functionNode.isVarArg() : "Non-vararg functions have slotted parameters";
  11.368              final int index = symbol.getFieldIndex();
  11.369 -            if(functionNode.needsArguments()) {
  11.370 +            if (functionNode.needsArguments()) {
  11.371                  // ScriptObject.getArgument(int) on arguments
  11.372                  debug("load symbol", symbol.getName(), " arguments index=", index);
  11.373                  loadArguments();
  11.374 @@ -864,7 +860,7 @@
  11.375       *
  11.376       * @return the method emitter
  11.377       */
  11.378 -    public MethodEmitter load(final Type type, final int slot) {
  11.379 +    MethodEmitter load(final Type type, final int slot) {
  11.380          debug("explicit load", type, slot);
  11.381          final Type loadType = type.load(method, slot);
  11.382          pushType(loadType == Type.OBJECT && isThisSlot(slot) ? Type.THIS : loadType);
  11.383 @@ -886,7 +882,7 @@
  11.384       *
  11.385       * @return the method emitter
  11.386       */
  11.387 -    public MethodEmitter loadThis() {
  11.388 +    MethodEmitter loadThis() {
  11.389          load(functionNode.getThisNode().getSymbol());
  11.390          return this;
  11.391      }
  11.392 @@ -896,7 +892,7 @@
  11.393       *
  11.394       * @return the method emitter
  11.395       */
  11.396 -    public MethodEmitter loadScope() {
  11.397 +    MethodEmitter loadScope() {
  11.398          if (peekType() == Type.SCOPE) {
  11.399              dup();
  11.400              return this;
  11.401 @@ -910,7 +906,7 @@
  11.402       *
  11.403       * @return the method emitter
  11.404       */
  11.405 -    public MethodEmitter loadResult() {
  11.406 +    MethodEmitter loadResult() {
  11.407          load(functionNode.getResultNode().getSymbol());
  11.408          return this;
  11.409      }
  11.410 @@ -924,11 +920,9 @@
  11.411       * @param descName   descriptor
  11.412       * @param flags      flags that describe this handle, e.g. invokespecial new, or invoke virtual
  11.413       *
  11.414 -     * @see ClassEmitter.Flag
  11.415 -     *
  11.416       * @return the method emitter
  11.417       */
  11.418 -    public MethodEmitter loadHandle(final String className, final String methodName, final String descName, final EnumSet<Flag> flags) {
  11.419 +    MethodEmitter loadHandle(final String className, final String methodName, final String descName, final EnumSet<Flag> flags) {
  11.420          debug("load handle ");
  11.421          pushType(Type.OBJECT.ldc(method, new Handle(Flag.getValue(flags), className, methodName, descName)));
  11.422          return this;
  11.423 @@ -939,7 +933,7 @@
  11.424       *
  11.425       * @return the method emitter
  11.426       */
  11.427 -    public MethodEmitter loadVarArgs() {
  11.428 +    MethodEmitter loadVarArgs() {
  11.429          debug("load var args " + functionNode.getVarArgsNode().getSymbol());
  11.430          return load(functionNode.getVarArgsNode().getSymbol());
  11.431      }
  11.432 @@ -949,7 +943,7 @@
  11.433       *
  11.434       * @return the method emitter
  11.435       */
  11.436 -    public MethodEmitter loadArguments() {
  11.437 +    MethodEmitter loadArguments() {
  11.438          debug("load arguments ", functionNode.getArgumentsNode().getSymbol());
  11.439          assert functionNode.getArgumentsNode().getSymbol().getSlot() != 0;
  11.440          return load(functionNode.getArgumentsNode().getSymbol());
  11.441 @@ -960,7 +954,7 @@
  11.442       *
  11.443       * @return the method emitter
  11.444       */
  11.445 -    public MethodEmitter loadCallee() {
  11.446 +    MethodEmitter loadCallee() {
  11.447          final Symbol calleeSymbol = functionNode.getCalleeNode().getSymbol();
  11.448          debug("load callee ", calleeSymbol);
  11.449          assert calleeSymbol.getSlot() == 0 : "callee has wrong slot " + calleeSymbol.getSlot() + " in " + functionNode.getName();
  11.450 @@ -971,7 +965,7 @@
  11.451      /**
  11.452       * Pop the scope from the stack and store it in its predefined slot
  11.453       */
  11.454 -    public void storeScope() {
  11.455 +    void storeScope() {
  11.456          debug("store scope");
  11.457          store(functionNode.getScopeNode().getSymbol());
  11.458      }
  11.459 @@ -979,7 +973,7 @@
  11.460      /**
  11.461       * Pop the return from the stack and store it in its predefined slot
  11.462       */
  11.463 -    public void storeResult() {
  11.464 +    void storeResult() {
  11.465          debug("store result");
  11.466          store(functionNode.getResultNode().getSymbol());
  11.467      }
  11.468 @@ -987,7 +981,7 @@
  11.469      /**
  11.470       * Pop the arguments array from the stack and store it in its predefined slot
  11.471       */
  11.472 -    public void storeArguments() {
  11.473 +    void storeArguments() {
  11.474          debug("store arguments");
  11.475          store(functionNode.getArgumentsNode().getSymbol());
  11.476      }
  11.477 @@ -996,7 +990,7 @@
  11.478       * Load an element from an array, determining type automatically
  11.479       * @return the method emitter
  11.480       */
  11.481 -    public MethodEmitter arrayload() {
  11.482 +    MethodEmitter arrayload() {
  11.483          debug("Xaload");
  11.484          popType(Type.INT);
  11.485          pushType(popArray().aload(method));
  11.486 @@ -1007,7 +1001,7 @@
  11.487       * Pop a value, an index and an array from the stack and store
  11.488       * the value at the given index in the array.
  11.489       */
  11.490 -    public void arraystore() {
  11.491 +    void arraystore() {
  11.492          debug("Xastore");
  11.493          final Type value = popType();
  11.494          final Type index = popType(Type.INT);
  11.495 @@ -1025,7 +1019,7 @@
  11.496       *
  11.497       * @param symbol symbol to store stack to
  11.498       */
  11.499 -    public void store(final Symbol symbol) {
  11.500 +    void store(final Symbol symbol) {
  11.501          assert symbol != null : "No symbol to store";
  11.502          if (symbol.hasSlot()) {
  11.503              final int slot = symbol.getSlot();
  11.504 @@ -1035,7 +1029,7 @@
  11.505              assert !symbol.isScope();
  11.506              assert functionNode.isVarArg() : "Non-vararg functions have slotted parameters";
  11.507              final int index = symbol.getFieldIndex();
  11.508 -            if(functionNode.needsArguments()) {
  11.509 +            if (functionNode.needsArguments()) {
  11.510                  debug("store symbol", symbol.getName(), " arguments index=", index);
  11.511                  loadArguments();
  11.512                  load(index);
  11.513 @@ -1057,7 +1051,7 @@
  11.514       * @param type the type to pop
  11.515       * @param slot the slot
  11.516       */
  11.517 -    public void store(final Type type, final int slot) {
  11.518 +    void store(final Type type, final int slot) {
  11.519          popType(type);
  11.520          type.store(method, slot);
  11.521      }
  11.522 @@ -1068,7 +1062,7 @@
  11.523       * @param slot the int slot
  11.524       * @param increment the amount to increment
  11.525       */
  11.526 -    public void iinc(final int slot, final int increment) {
  11.527 +    void iinc(final int slot, final int increment) {
  11.528          debug("iinc");
  11.529          method.visitIincInsn(slot, increment);
  11.530      }
  11.531 @@ -1094,7 +1088,7 @@
  11.532       *
  11.533       * @return the method emitter
  11.534       */
  11.535 -    public MethodEmitter _instanceof(final String classDescriptor) {
  11.536 +    MethodEmitter _instanceof(final String classDescriptor) {
  11.537          debug("instanceof", classDescriptor);
  11.538          popType(Type.OBJECT);
  11.539          method.visitTypeInsn(INSTANCEOF, classDescriptor);
  11.540 @@ -1111,7 +1105,7 @@
  11.541       *
  11.542       * @return the method emitter
  11.543       */
  11.544 -    public MethodEmitter _instanceof(final Class<?> clazz) {
  11.545 +    MethodEmitter _instanceof(final Class<?> clazz) {
  11.546          return _instanceof(CompilerConstants.className(clazz));
  11.547      }
  11.548  
  11.549 @@ -1123,7 +1117,7 @@
  11.550       *
  11.551       * @return the method emitter
  11.552       */
  11.553 -    public MethodEmitter checkcast(final String classDescriptor) {
  11.554 +    MethodEmitter checkcast(final String classDescriptor) {
  11.555          debug("checkcast", classDescriptor);
  11.556          assert peekType().isObject();
  11.557          method.visitTypeInsn(CHECKCAST, classDescriptor);
  11.558 @@ -1138,7 +1132,7 @@
  11.559       *
  11.560       * @return the method emitter
  11.561       */
  11.562 -    public MethodEmitter checkcast(final Class<?> clazz) {
  11.563 +    MethodEmitter checkcast(final Class<?> clazz) {
  11.564          return checkcast(CompilerConstants.className(clazz));
  11.565      }
  11.566  
  11.567 @@ -1150,7 +1144,7 @@
  11.568       *
  11.569       * @return the method emitter
  11.570       */
  11.571 -    public MethodEmitter newarray(final ArrayType arrayType) {
  11.572 +    MethodEmitter newarray(final ArrayType arrayType) {
  11.573          debug("newarray ", "arrayType=" + arrayType);
  11.574          popType(Type.INT); //LENGTH
  11.575          pushType(arrayType.newarray(method));
  11.576 @@ -1166,7 +1160,7 @@
  11.577       *
  11.578       * @return the method emitter
  11.579       */
  11.580 -    public MethodEmitter multinewarray(final ArrayType arrayType, final int dims) {
  11.581 +    MethodEmitter multinewarray(final ArrayType arrayType, final int dims) {
  11.582          debug("multianewarray ", arrayType, dims);
  11.583          for (int i = 0; i < dims; i++) {
  11.584              popType(Type.INT); //LENGTH
  11.585 @@ -1200,7 +1194,7 @@
  11.586       *
  11.587       * @return the method emitter
  11.588       */
  11.589 -    public MethodEmitter invoke(final Call call) {
  11.590 +    MethodEmitter invoke(final Call call) {
  11.591          return call.invoke(this);
  11.592      }
  11.593  
  11.594 @@ -1229,7 +1223,7 @@
  11.595       *
  11.596       * @return the method emitter
  11.597       */
  11.598 -    public MethodEmitter invokeSpecial(final String className, final String methodName, final String methodDescriptor) {
  11.599 +    MethodEmitter invokespecial(final String className, final String methodName, final String methodDescriptor) {
  11.600          debug("invokespecial", className + "." + methodName + methodDescriptor);
  11.601          return invoke(INVOKESPECIAL, className, methodName, methodDescriptor, true);
  11.602      }
  11.603 @@ -1243,7 +1237,7 @@
  11.604       *
  11.605       * @return the method emitter
  11.606       */
  11.607 -    public MethodEmitter invokeVirtual(final String className, final String methodName, final String methodDescriptor) {
  11.608 +    MethodEmitter invokevirtual(final String className, final String methodName, final String methodDescriptor) {
  11.609          debug("invokevirtual", className + "." + methodName + methodDescriptor + " " + stack);
  11.610          return invoke(INVOKEVIRTUAL, className, methodName, methodDescriptor, true);
  11.611      }
  11.612 @@ -1257,7 +1251,7 @@
  11.613       *
  11.614       * @return the method emitter
  11.615       */
  11.616 -    public MethodEmitter invokeStatic(final String className, final String methodName, final String methodDescriptor) {
  11.617 +    MethodEmitter invokestatic(final String className, final String methodName, final String methodDescriptor) {
  11.618          debug("invokestatic", className + "." + methodName + methodDescriptor);
  11.619          invoke(INVOKESTATIC, className, methodName, methodDescriptor, false);
  11.620          return this;
  11.621 @@ -1274,8 +1268,8 @@
  11.622       *
  11.623       * @return the method emitter
  11.624       */
  11.625 -    public MethodEmitter invokeStatic(final String className, final String methodName, final String methodDescriptor, final Type returnType) {
  11.626 -        invokeStatic(className, methodName, methodDescriptor);
  11.627 +    MethodEmitter invokeStatic(final String className, final String methodName, final String methodDescriptor, final Type returnType) {
  11.628 +        invokestatic(className, methodName, methodDescriptor);
  11.629          popType();
  11.630          pushType(returnType);
  11.631          return this;
  11.632 @@ -1290,7 +1284,7 @@
  11.633       *
  11.634       * @return the method emitter
  11.635       */
  11.636 -    public MethodEmitter invokeInterface(final String className, final String methodName, final String methodDescriptor) {
  11.637 +    MethodEmitter invokeinterface(final String className, final String methodName, final String methodDescriptor) {
  11.638          debug("invokeinterface", className + "." + methodName + methodDescriptor);
  11.639          return invoke(INVOKEINTERFACE, className, methodName, methodDescriptor, true);
  11.640      }
  11.641 @@ -1302,7 +1296,7 @@
  11.642       * @param values       case values for the table
  11.643       * @param table        default label
  11.644       */
  11.645 -    public void lookupSwitch(final Label defaultLabel, final int[] values, final Label[] table) {
  11.646 +    void lookupswitch(final Label defaultLabel, final int[] values, final Label[] table) {
  11.647          debug("lookupswitch", peekType());
  11.648          popType(Type.INT);
  11.649          method.visitLookupSwitchInsn(defaultLabel, values, table);
  11.650 @@ -1315,7 +1309,7 @@
  11.651       * @param defaultLabel  default label
  11.652       * @param table         label table
  11.653       */
  11.654 -    public void tableSwitch(final int lo, final int hi, final Label defaultLabel, final Label[] table) {
  11.655 +    void tableswitch(final int lo, final int hi, final Label defaultLabel, final Label[] table) {
  11.656          debug("tableswitch", peekType());
  11.657          popType(Type.INT);
  11.658          method.visitTableSwitchInsn(lo, hi, defaultLabel, table);
  11.659 @@ -1357,7 +1351,7 @@
  11.660       *
  11.661       * @param type the type for the return
  11.662       */
  11.663 -    public void _return(final Type type) {
  11.664 +    void _return(final Type type) {
  11.665          debug("return", type);
  11.666          assert stack.size() == 1 : "Only return value on stack allowed at return point - depth=" + stack.size() + " stack = " + stack;
  11.667          final Type stackType = peekType();
  11.668 @@ -1371,14 +1365,14 @@
  11.669      /**
  11.670       * Perform a return using the stack top value as the guide for the type
  11.671       */
  11.672 -    public void _return() {
  11.673 +    void _return() {
  11.674          _return(peekType());
  11.675      }
  11.676  
  11.677      /**
  11.678       * Perform a void return.
  11.679       */
  11.680 -    public void returnVoid() {
  11.681 +    void returnVoid() {
  11.682          debug("return [void]");
  11.683          assert stack.isEmpty() : stack;
  11.684          method.visitInsn(RETURN);
  11.685 @@ -1392,7 +1386,7 @@
  11.686       *
  11.687       * @param label destination label
  11.688       */
  11.689 -    public void splitAwareGoto(final Label label) {
  11.690 +    void splitAwareGoto(final Label label) {
  11.691  
  11.692          if (splitNode != null) {
  11.693              final int index = splitNode.getExternalTargets().indexOf(label);
  11.694 @@ -1418,7 +1412,7 @@
  11.695       *
  11.696       * @return the method emitter
  11.697       */
  11.698 -    public MethodEmitter cmp(final boolean isCmpG) {
  11.699 +    MethodEmitter cmp(final boolean isCmpG) {
  11.700          pushType(get2n().cmp(method, isCmpG));
  11.701          return this;
  11.702      }
  11.703 @@ -1443,7 +1437,7 @@
  11.704       *
  11.705       * @param label label to true case
  11.706       */
  11.707 -    public void if_acmpeq(final Label label) {
  11.708 +    void if_acmpeq(final Label label) {
  11.709          debug("if_acmpeq", label);
  11.710          jump(IF_ACMPEQ, label, 2);
  11.711      }
  11.712 @@ -1453,7 +1447,7 @@
  11.713       *
  11.714       * @param label label to true case
  11.715       */
  11.716 -    public void if_acmpne(final Label label) {
  11.717 +    void if_acmpne(final Label label) {
  11.718          debug("if_acmpne", label);
  11.719          jump(IF_ACMPNE, label, 2);
  11.720      }
  11.721 @@ -1463,7 +1457,7 @@
  11.722       *
  11.723       * @param label label to true case
  11.724       */
  11.725 -    public void ifnull(final Label label) {
  11.726 +    void ifnull(final Label label) {
  11.727          debug("ifnull", label);
  11.728          jump(IFNULL, label, 1);
  11.729      }
  11.730 @@ -1473,7 +1467,7 @@
  11.731       *
  11.732       * @param label label to true case
  11.733       */
  11.734 -    public void ifnonnull(final Label label) {
  11.735 +    void ifnonnull(final Label label) {
  11.736          debug("ifnonnull", label);
  11.737          jump(IFNONNULL, label, 1);
  11.738      }
  11.739 @@ -1483,7 +1477,7 @@
  11.740       *
  11.741       * @param label label to true case
  11.742       */
  11.743 -    public void ifeq(final Label label) {
  11.744 +    void ifeq(final Label label) {
  11.745          debug("ifeq ", label);
  11.746          jump(IFEQ, label, 1);
  11.747      }
  11.748 @@ -1493,7 +1487,7 @@
  11.749       *
  11.750       * @param label label to true case
  11.751       */
  11.752 -    public void if_icmpeq(final Label label) {
  11.753 +    void if_icmpeq(final Label label) {
  11.754          debug("if_icmpeq", label);
  11.755          jump(IF_ICMPEQ, label, 2);
  11.756      }
  11.757 @@ -1503,8 +1497,7 @@
  11.758       *
  11.759       * @param label label to true case
  11.760       */
  11.761 -
  11.762 -    public void ifne(final Label label) {
  11.763 +    void ifne(final Label label) {
  11.764          debug("ifne", label);
  11.765          jump(IFNE, label, 1);
  11.766      }
  11.767 @@ -1514,7 +1507,7 @@
  11.768       *
  11.769       * @param label label to true case
  11.770       */
  11.771 -    public void if_icmpne(final Label label) {
  11.772 +    void if_icmpne(final Label label) {
  11.773          debug("if_icmpne", label);
  11.774          jump(IF_ICMPNE, label, 2);
  11.775      }
  11.776 @@ -1524,7 +1517,7 @@
  11.777       *
  11.778       * @param label label to true case
  11.779       */
  11.780 -    public void iflt(final Label label) {
  11.781 +    void iflt(final Label label) {
  11.782          debug("iflt", label);
  11.783          jump(IFLT, label, 1);
  11.784      }
  11.785 @@ -1534,7 +1527,7 @@
  11.786       *
  11.787       * @param label label to true case
  11.788       */
  11.789 -    public void ifle(final Label label) {
  11.790 +    void ifle(final Label label) {
  11.791          debug("ifle", label);
  11.792          jump(IFLE, label, 1);
  11.793      }
  11.794 @@ -1544,7 +1537,7 @@
  11.795       *
  11.796       * @param label label to true case
  11.797       */
  11.798 -    public void ifgt(final Label label) {
  11.799 +    void ifgt(final Label label) {
  11.800          debug("ifgt", label);
  11.801          jump(IFGT, label, 1);
  11.802      }
  11.803 @@ -1554,7 +1547,7 @@
  11.804       *
  11.805       * @param label label to true case
  11.806       */
  11.807 -    public void ifge(final Label label) {
  11.808 +    void ifge(final Label label) {
  11.809          debug("ifge", label);
  11.810          jump(IFGE, label, 1);
  11.811      }
  11.812 @@ -1564,7 +1557,7 @@
  11.813       *
  11.814       * @param label destination label
  11.815       */
  11.816 -    public void _goto(final Label label) {
  11.817 +    void _goto(final Label label) {
  11.818          debug("goto", label);
  11.819          jump(GOTO, label, 0);
  11.820          stack = null;
  11.821 @@ -1617,7 +1610,7 @@
  11.822       *
  11.823       * @param label the label
  11.824       */
  11.825 -    public void label(final Label label) {
  11.826 +    void label(final Label label) {
  11.827          /*
  11.828           * If stack == null, this means that we came here not through a fallthrough.
  11.829           * E.g. a label after an athrow. Then we create a new stack if one doesn't exist
  11.830 @@ -1643,7 +1636,7 @@
  11.831       *
  11.832       * @return the method emitter
  11.833       */
  11.834 -    public MethodEmitter convert(final Type to) {
  11.835 +    MethodEmitter convert(final Type to) {
  11.836          final Type type = peekType().convert(method, to);
  11.837          if (type != null) {
  11.838              if (peekType() != to) {
  11.839 @@ -1696,7 +1689,7 @@
  11.840       *
  11.841       * @return the method emitter
  11.842       */
  11.843 -    public MethodEmitter add() {
  11.844 +    MethodEmitter add() {
  11.845          debug("add");
  11.846          pushType(get2().add(method));
  11.847          return this;
  11.848 @@ -1707,7 +1700,7 @@
  11.849       *
  11.850       * @return the method emitter
  11.851       */
  11.852 -    public MethodEmitter sub() {
  11.853 +    MethodEmitter sub() {
  11.854          debug("sub");
  11.855          pushType(get2n().sub(method));
  11.856          return this;
  11.857 @@ -1718,7 +1711,7 @@
  11.858       *
  11.859       * @return the method emitter
  11.860       */
  11.861 -    public MethodEmitter mul() {
  11.862 +    MethodEmitter mul() {
  11.863          debug("mul ");
  11.864          pushType(get2n().mul(method));
  11.865          return this;
  11.866 @@ -1729,7 +1722,7 @@
  11.867       *
  11.868       * @return the method emitter
  11.869       */
  11.870 -    public MethodEmitter div() {
  11.871 +    MethodEmitter div() {
  11.872          debug("div");
  11.873          pushType(get2n().div(method));
  11.874          return this;
  11.875 @@ -1740,7 +1733,7 @@
  11.876       *
  11.877       * @return the method emitter
  11.878       */
  11.879 -    public MethodEmitter rem() {
  11.880 +    MethodEmitter rem() {
  11.881          debug("rem");
  11.882          pushType(get2n().rem(method));
  11.883          return this;
  11.884 @@ -1795,7 +1788,7 @@
  11.885       *
  11.886       * @return the method emitter
  11.887       */
  11.888 -    public MethodEmitter dynamicNew(final int argCount, final int flags) {
  11.889 +    MethodEmitter dynamicNew(final int argCount, final int flags) {
  11.890          debug("dynamic_new", "argcount=" + argCount);
  11.891          final String signature = getDynamicSignature(Type.OBJECT, argCount);
  11.892          method.visitInvokeDynamicInsn("dyn:new", signature, LINKERBOOTSTRAP, flags);
  11.893 @@ -1812,7 +1805,7 @@
  11.894       *
  11.895       * @return the method emitter
  11.896       */
  11.897 -    public MethodEmitter dynamicCall(final Type returnType, final int argCount, final int flags) {
  11.898 +    MethodEmitter dynamicCall(final Type returnType, final int argCount, final int flags) {
  11.899          debug("dynamic_call", "args=" + argCount, "returnType=" + returnType);
  11.900          final String signature = getDynamicSignature(returnType, argCount); // +1 because the function itself is the 1st parameter for dynamic calls (what you call - call target)
  11.901          debug("   signature", signature);
  11.902 @@ -1831,7 +1824,7 @@
  11.903       *
  11.904       * @return the method emitter
  11.905       */
  11.906 -    public MethodEmitter dynamicRuntimeCall(final String name, final Type returnType, final RuntimeNode.Request request) {
  11.907 +    MethodEmitter dynamicRuntimeCall(final String name, final Type returnType, final RuntimeNode.Request request) {
  11.908          debug("dynamic_runtime_call", name, "args=" + request.getArity(), "returnType=" + returnType);
  11.909          final String signature = getDynamicSignature(returnType, request.getArity());
  11.910          debug("   signature", signature);
  11.911 @@ -1851,7 +1844,7 @@
  11.912       *
  11.913       * @return the method emitter
  11.914       */
  11.915 -    public MethodEmitter dynamicGet(final Type valueType, final String name, final int flags, final boolean isMethod) {
  11.916 +    MethodEmitter dynamicGet(final Type valueType, final String name, final int flags, final boolean isMethod) {
  11.917          debug("dynamic_get", name, valueType);
  11.918  
  11.919          Type type = valueType;
  11.920 @@ -1877,7 +1870,7 @@
  11.921       * @param name      name of property
  11.922       * @param flags     call site flags
  11.923       */
  11.924 -     public void dynamicSet(final Type valueType, final String name, final int flags) {
  11.925 +     void dynamicSet(final Type valueType, final String name, final int flags) {
  11.926          debug("dynamic_set", name, peekType());
  11.927  
  11.928          Type type = valueType;
  11.929 @@ -1902,7 +1895,7 @@
  11.930       *
  11.931       * @return the method emitter
  11.932       */
  11.933 -    public MethodEmitter dynamicGetIndex(final Type result, final int flags, final boolean isMethod) {
  11.934 +    MethodEmitter dynamicGetIndex(final Type result, final int flags, final boolean isMethod) {
  11.935          debug("dynamic_get_index", peekType(1) + "[" + peekType() + "]");
  11.936  
  11.937          Type resultType = result;
  11.938 @@ -1938,7 +1931,7 @@
  11.939       *
  11.940       * @param flags call site flags for setter
  11.941       */
  11.942 -    public void dynamicSetIndex(final int flags) {
  11.943 +    void dynamicSetIndex(final int flags) {
  11.944          debug("dynamic_set_index", peekType(2) + "[" + peekType(1) + "] =", peekType());
  11.945  
  11.946          Type value = peekType();
  11.947 @@ -2015,7 +2008,7 @@
  11.948        *
  11.949        * @return the method emitter
  11.950        */
  11.951 -    public MethodEmitter getField(final FieldAccess fa) {
  11.952 +    MethodEmitter getField(final FieldAccess fa) {
  11.953          return fa.get(this);
  11.954      }
  11.955  
  11.956 @@ -2024,7 +2017,7 @@
  11.957        *
  11.958        * @param fa the field access
  11.959        */
  11.960 -    public void putField(final FieldAccess fa) {
  11.961 +    void putField(final FieldAccess fa) {
  11.962          fa.put(this);
  11.963      }
  11.964  
  11.965 @@ -2038,7 +2031,7 @@
  11.966       *
  11.967       * @return the method emitter
  11.968       */
  11.969 -    public MethodEmitter getField(final String className, final String fieldName, final String fieldDescriptor) {
  11.970 +    MethodEmitter getField(final String className, final String fieldName, final String fieldDescriptor) {
  11.971          debug("getfield", "receiver=" + peekType(), className + "." + fieldName + fieldDescriptor);
  11.972          final Type receiver = popType();
  11.973          assert receiver.isObject();
  11.974 @@ -2056,7 +2049,7 @@
  11.975       *
  11.976       * @return the method emitter
  11.977       */
  11.978 -    public MethodEmitter getStatic(final String className, final String fieldName, final String fieldDescriptor) {
  11.979 +    MethodEmitter getStatic(final String className, final String fieldName, final String fieldDescriptor) {
  11.980          debug("getstatic", className + "." + fieldName + "." + fieldDescriptor);
  11.981          method.visitFieldInsn(GETSTATIC, className, fieldName, fieldDescriptor);
  11.982          pushType(fieldType(fieldDescriptor));
  11.983 @@ -2070,7 +2063,7 @@
  11.984       * @param fieldName       field name
  11.985       * @param fieldDescriptor field descriptor
  11.986       */
  11.987 -    public void putField(final String className, final String fieldName, final String fieldDescriptor) {
  11.988 +    void putField(final String className, final String fieldName, final String fieldDescriptor) {
  11.989          debug("putfield", "receiver=" + peekType(1), "value=" + peekType());
  11.990          popType(fieldType(fieldDescriptor));
  11.991          popType(Type.OBJECT);
  11.992 @@ -2084,7 +2077,7 @@
  11.993       * @param fieldName       field name
  11.994       * @param fieldDescriptor field descriptor
  11.995       */
  11.996 -    public void putStatic(final String className, final String fieldName, final String fieldDescriptor) {
  11.997 +    void putStatic(final String className, final String fieldName, final String fieldDescriptor) {
  11.998          debug("putfield", "value=" + peekType());
  11.999          popType(fieldType(fieldDescriptor));
 11.1000          method.visitFieldInsn(PUTSTATIC, className, fieldName, fieldDescriptor);
 11.1001 @@ -2096,7 +2089,7 @@
 11.1002       * @param line  line number
 11.1003       * @param label label
 11.1004       */
 11.1005 -    public void lineNumber(final int line, final Label label) {
 11.1006 +    void lineNumber(final int line, final Label label) {
 11.1007          method.visitLineNumber(line, label);
 11.1008      }
 11.1009  
 11.1010 @@ -2112,7 +2105,7 @@
 11.1011      /**
 11.1012       * Emit a System.err.print statement of whatever is on top of the bytecode stack
 11.1013       */
 11.1014 -     public void print() {
 11.1015 +     void print() {
 11.1016           getField(ERR_STREAM);
 11.1017           swap();
 11.1018           convert(Type.OBJECT);
 11.1019 @@ -2122,7 +2115,7 @@
 11.1020      /**
 11.1021       * Emit a System.err.println statement of whatever is on top of the bytecode stack
 11.1022       */
 11.1023 -     public void println() {
 11.1024 +     void println() {
 11.1025           getField(ERR_STREAM);
 11.1026           swap();
 11.1027           convert(Type.OBJECT);
 11.1028 @@ -2133,7 +2126,7 @@
 11.1029        * Emit a System.err.print statement
 11.1030        * @param string string to print
 11.1031        */
 11.1032 -     public void print(final String string) {
 11.1033 +     void print(final String string) {
 11.1034           getField(ERR_STREAM);
 11.1035           load(string);
 11.1036           invoke(PRINT);
 11.1037 @@ -2143,7 +2136,7 @@
 11.1038        * Emit a System.err.println statement
 11.1039        * @param string string to print
 11.1040        */
 11.1041 -     public void println(final String string) {
 11.1042 +     void println(final String string) {
 11.1043           getField(ERR_STREAM);
 11.1044           load(string);
 11.1045           invoke(PRINTLN);
 11.1046 @@ -2152,7 +2145,7 @@
 11.1047       /**
 11.1048        * Print a stacktrace to S
 11.1049        */
 11.1050 -     public void stacktrace() {
 11.1051 +     void stacktrace() {
 11.1052           _new(Throwable.class);
 11.1053           dup();
 11.1054           invoke(constructorNoLookup(Throwable.class));
 11.1055 @@ -2254,130 +2247,11 @@
 11.1056          }
 11.1057      }
 11.1058  
 11.1059 -
 11.1060 -    /**
 11.1061 -     * Abstraction for labels, separating a label from the underlying
 11.1062 -     * byte code emitter. Also augmenting label with e.g. a name
 11.1063 -     * for easier debugging and reading code
 11.1064 -     *
 11.1065 -     * see -Dnashorn.codegen.debug, --log=codegen
 11.1066 -     */
 11.1067 -    public static class Label extends jdk.internal.org.objectweb.asm.Label {
 11.1068 -        /** Name of this label */
 11.1069 -        private final String name;
 11.1070 -
 11.1071 -        /** Type stack at this label */
 11.1072 -        private ArrayDeque<Type> stack;
 11.1073 -
 11.1074 -        /**
 11.1075 -         * Constructor
 11.1076 -         *
 11.1077 -         * @param name name of this label
 11.1078 -         */
 11.1079 -        public Label(final String name) {
 11.1080 -            super();
 11.1081 -            this.name = name;
 11.1082 -        }
 11.1083 -
 11.1084 -        /**
 11.1085 -         * Copy constructor
 11.1086 -         *
 11.1087 -         * @param label a label to clone
 11.1088 -         */
 11.1089 -        public Label(final Label label) {
 11.1090 -            super();
 11.1091 -            name = label.name;
 11.1092 -        }
 11.1093 -
 11.1094 -        ArrayDeque<Type> getStack() {
 11.1095 -            return stack;
 11.1096 -        }
 11.1097 -
 11.1098 -        void setStack(final ArrayDeque<Type> stack) {
 11.1099 -            this.stack = stack;
 11.1100 -        }
 11.1101 -
 11.1102 -        @Override
 11.1103 -        public String toString() {
 11.1104 -            final StringBuilder sb = new StringBuilder();
 11.1105 -            String s = super.toString();
 11.1106 -            s = s.substring(1, s.length());
 11.1107 -            sb.append(name).append('_').append(Long.toHexString(Long.parseLong(s)));
 11.1108 -
 11.1109 -            return sb.toString();
 11.1110 -        }
 11.1111 -    }
 11.1112 -
 11.1113 -    /**
 11.1114 -     * Condition enum used for all kinds of jumps, regardless of type
 11.1115 -     */
 11.1116 -    static enum Condition {
 11.1117 -        EQ,
 11.1118 -        NE,
 11.1119 -        LE,
 11.1120 -        LT,
 11.1121 -        GE,
 11.1122 -        GT;
 11.1123 -
 11.1124 -        public static Condition forRuntimeRequest(final RuntimeNode.Request request) {
 11.1125 -            try {
 11.1126 -                final String reqString = request.toString().replace("_STRICT", "");
 11.1127 -                return Condition.valueOf(reqString);
 11.1128 -            } catch (final IllegalArgumentException e) {
 11.1129 -                return null;
 11.1130 -            }
 11.1131 -        }
 11.1132 -
 11.1133 -        public static int toUnary(final Condition c) {
 11.1134 -            switch (c) {
 11.1135 -            case EQ:
 11.1136 -                return IFEQ;
 11.1137 -            case NE:
 11.1138 -                return IFNE;
 11.1139 -            case LE:
 11.1140 -                return IFLE;
 11.1141 -            case LT:
 11.1142 -                return IFLT;
 11.1143 -            case GE:
 11.1144 -                return IFGE;
 11.1145 -            case GT:
 11.1146 -                return IFGT;
 11.1147 -            default:
 11.1148 -                assert false;
 11.1149 -                return -1;
 11.1150 -            }
 11.1151 -        }
 11.1152 -
 11.1153 -        public static int toBinary(final Condition c) {
 11.1154 -            return toBinary(c, false);
 11.1155 -        }
 11.1156 -
 11.1157 -        public static int toBinary(final Condition c, final boolean isObject) {
 11.1158 -            switch (c) {
 11.1159 -            case EQ:
 11.1160 -                return isObject ? IF_ACMPEQ : IF_ICMPEQ;
 11.1161 -            case NE:
 11.1162 -                return isObject ? IF_ACMPNE : IF_ICMPNE;
 11.1163 -            case LE:
 11.1164 -                return IF_ICMPLE;
 11.1165 -            case LT:
 11.1166 -                return IF_ICMPLT;
 11.1167 -            case GE:
 11.1168 -                return IF_ICMPGE;
 11.1169 -            case GT:
 11.1170 -                return IF_ICMPGT;
 11.1171 -            default:
 11.1172 -                assert false;
 11.1173 -                return -1;
 11.1174 -            }
 11.1175 -        }
 11.1176 -    }
 11.1177 -
 11.1178      /**
 11.1179       * Set the current function node being emitted
 11.1180       * @param functionNode the function node
 11.1181       */
 11.1182 -    public void setFunctionNode(final FunctionNode functionNode) {
 11.1183 +    void setFunctionNode(final FunctionNode functionNode) {
 11.1184          this.functionNode = functionNode;
 11.1185      }
 11.1186  
 11.1187 @@ -2387,7 +2261,7 @@
 11.1188       *
 11.1189       * @return split node
 11.1190       */
 11.1191 -    public SplitNode getSplitNode() {
 11.1192 +    SplitNode getSplitNode() {
 11.1193          return splitNode;
 11.1194      }
 11.1195  
 11.1196 @@ -2395,7 +2269,7 @@
 11.1197       * Set the split node for this method emitter
 11.1198       * @param splitNode split node
 11.1199       */
 11.1200 -    public void setSplitNode(final SplitNode splitNode) {
 11.1201 +    void setSplitNode(final SplitNode splitNode) {
 11.1202          this.splitNode = splitNode;
 11.1203      }
 11.1204  }
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java	Fri Feb 15 09:44:15 2013 +0100
    12.3 @@ -0,0 +1,760 @@
    12.4 +/*
    12.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    12.7 + *
    12.8 + * This code is free software; you can redistribute it and/or modify it
    12.9 + * under the terms of the GNU General Public License version 2 only, as
   12.10 + * published by the Free Software Foundation.  Oracle designates this
   12.11 + * particular file as subject to the "Classpath" exception as provided
   12.12 + * by Oracle in the LICENSE file that accompanied this code.
   12.13 + *
   12.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   12.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   12.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   12.17 + * version 2 for more details (a copy is included in the LICENSE file that
   12.18 + * accompanied this code).
   12.19 + *
   12.20 + * You should have received a copy of the GNU General Public License version
   12.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   12.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   12.23 + *
   12.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   12.25 + * or visit www.oracle.com if you need additional information or have any
   12.26 + * questions.
   12.27 + */
   12.28 +
   12.29 +package jdk.nashorn.internal.codegen;
   12.30 +
   12.31 +import static jdk.nashorn.internal.codegen.Compiler.SCRIPTS_PACKAGE;
   12.32 +import static jdk.nashorn.internal.codegen.CompilerConstants.ALLOCATE;
   12.33 +import static jdk.nashorn.internal.codegen.CompilerConstants.INIT_ARGUMENTS;
   12.34 +import static jdk.nashorn.internal.codegen.CompilerConstants.INIT_SCOPE;
   12.35 +import static jdk.nashorn.internal.codegen.CompilerConstants.JAVA_THIS;
   12.36 +import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_PREFIX;
   12.37 +import static jdk.nashorn.internal.codegen.CompilerConstants.MAP;
   12.38 +import static jdk.nashorn.internal.codegen.CompilerConstants.className;
   12.39 +import static jdk.nashorn.internal.codegen.CompilerConstants.constructorNoLookup;
   12.40 +import static jdk.nashorn.internal.runtime.linker.Lookup.MH;
   12.41 +
   12.42 +import java.lang.invoke.MethodHandle;
   12.43 +import java.lang.invoke.MethodHandles;
   12.44 +import java.lang.invoke.MethodType;
   12.45 +import java.util.Arrays;
   12.46 +import java.util.Collections;
   12.47 +import java.util.EnumSet;
   12.48 +import java.util.Iterator;
   12.49 +import java.util.LinkedList;
   12.50 +import java.util.List;
   12.51 +import jdk.nashorn.internal.codegen.ClassEmitter.Flag;
   12.52 +import jdk.nashorn.internal.codegen.types.Type;
   12.53 +import jdk.nashorn.internal.runtime.AccessorProperty;
   12.54 +import jdk.nashorn.internal.runtime.Context;
   12.55 +import jdk.nashorn.internal.runtime.DebugLogger;
   12.56 +import jdk.nashorn.internal.runtime.FunctionScope;
   12.57 +import jdk.nashorn.internal.runtime.JSType;
   12.58 +import jdk.nashorn.internal.runtime.PropertyMap;
   12.59 +import jdk.nashorn.internal.runtime.ScriptObject;
   12.60 +import jdk.nashorn.internal.runtime.ScriptRuntime;
   12.61 +import jdk.nashorn.internal.runtime.options.Options;
   12.62 +
   12.63 +/**
   12.64 + * Generates the ScriptObject subclass structure with fields for a user objects.
   12.65 + */
   12.66 +public final class ObjectClassGenerator {
   12.67 +
   12.68 +    /**
   12.69 +     * Marker for scope parameters.
   12.70 +     */
   12.71 +    static final String SCOPE_MARKER = "P";
   12.72 +
   12.73 +    /**
   12.74 +     * Debug field logger
   12.75 +     * Should we print debugging information for fields when they are generated and getters/setters are called?
   12.76 +     */
   12.77 +    public static final DebugLogger LOG          = new DebugLogger("fields", "nashorn.fields.debug");
   12.78 +
   12.79 +    /**
   12.80 +     * is field debugging enabled. Several modules in codegen and properties use this, hence
   12.81 +     * public access.
   12.82 +     */
   12.83 +    public static final boolean     DEBUG_FIELDS = LOG.isEnabled();
   12.84 +
   12.85 +    /**
   12.86 +     * Should the runtime only use java.lang.Object slots for fields? If this is false, the representation
   12.87 +     * will be a primitive 64-bit long value used for all primitives and a java.lang.Object for references.
   12.88 +     * This introduces a larger number of method handles in the system, as we need to have different getters
   12.89 +     * and setters for the different fields. Currently this introduces significant overhead in Hotspot.
   12.90 +     *
   12.91 +     * This is engineered to plug into the TaggedArray implementation, when it's done.
   12.92 +     */
   12.93 +    public static final boolean OBJECT_FIELDS_ONLY = !Options.getBooleanProperty("nashorn.fields.dual");
   12.94 +
   12.95 +    /** The field types in the system */
   12.96 +    private static final List<Type> FIELD_TYPES = new LinkedList<>();
   12.97 +
   12.98 +    /** What type is the primitive type in dual representation */
   12.99 +    public static final Type PRIMITIVE_TYPE = Type.LONG;
  12.100 +
  12.101 +    /**
  12.102 +     * The list of field types that we support - one type creates one field. This is currently either
  12.103 +     * LONG + OBJECT or just OBJECT for classic mode.
  12.104 +     */
  12.105 +    static {
  12.106 +        if (!OBJECT_FIELDS_ONLY) {
  12.107 +            System.err.println("WARNING!!! Running with primitive fields - there is untested functionality!");
  12.108 +            FIELD_TYPES.add(PRIMITIVE_TYPE);
  12.109 +        }
  12.110 +        FIELD_TYPES.add(Type.OBJECT);
  12.111 +    }
  12.112 +
  12.113 +    /** The context */
  12.114 +    private final Context context;
  12.115 +
  12.116 +    /**
  12.117 +     * The list of available accessor types in width order. This order is used for type guesses narrow->wide
  12.118 +     *  in the dual--fields world
  12.119 +     */
  12.120 +    public static final List<Type> ACCESSOR_TYPES = Collections.unmodifiableList(
  12.121 +            Arrays.asList(
  12.122 +                Type.INT,
  12.123 +                Type.LONG,
  12.124 +                Type.NUMBER,
  12.125 +                Type.OBJECT));
  12.126 +
  12.127 +    //these are hard coded for speed and so that we can switch on them
  12.128 +    private static final int TYPE_INT_INDEX    = 0; //getAccessorTypeIndex(int.class);
  12.129 +    private static final int TYPE_LONG_INDEX   = 1; //getAccessorTypeIndex(long.class);
  12.130 +    private static final int TYPE_DOUBLE_INDEX = 2; //getAccessorTypeIndex(double.class);
  12.131 +    private static final int TYPE_OBJECT_INDEX = 3; //getAccessorTypeIndex(Object.class);
  12.132 +
  12.133 +    /**
  12.134 +     * Constructor
  12.135 +     *
  12.136 +     * @param context a context
  12.137 +     */
  12.138 +    public ObjectClassGenerator(final Context context) {
  12.139 +        this.context = context;
  12.140 +        assert context != null;
  12.141 +    }
  12.142 +
  12.143 +    /**
  12.144 +     * Given a type of an accessor, return its index in [0..getNumberOfAccessorTypes())
  12.145 +     *
  12.146 +     * @param type the type
  12.147 +     *
  12.148 +     * @return the accessor index, or -1 if no accessor of this type exists
  12.149 +     */
  12.150 +    public static int getAccessorTypeIndex(final Type type) {
  12.151 +        return getAccessorTypeIndex(type.getTypeClass());
  12.152 +    }
  12.153 +
  12.154 +    /**
  12.155 +     * Given a class of an accessor, return its index in [0..getNumberOfAccessorTypes())
  12.156 +     *
  12.157 +     * Note that this is hardcoded with respect to the dynamic contents of the accessor
  12.158 +     * types array for speed. Hotspot got stuck with this as 5% of the runtime in
  12.159 +     * a benchmark when it looped over values and increased an index counter. :-(
  12.160 +     *
  12.161 +     * @param type the type
  12.162 +     *
  12.163 +     * @return the accessor index, or -1 if no accessor of this type exists
  12.164 +     */
  12.165 +    public static int getAccessorTypeIndex(final Class<?> type) {
  12.166 +        if (type == int.class) {
  12.167 +            return 0;
  12.168 +        } else if (type == long.class) {
  12.169 +            return 1;
  12.170 +        } else if (type == double.class) {
  12.171 +            return 2;
  12.172 +        } else if (!type.isPrimitive()) {
  12.173 +            return 3;
  12.174 +        }
  12.175 +        return -1;
  12.176 +    }
  12.177 +
  12.178 +    /**
  12.179 +     * Return the number of accessor types available.
  12.180 +     *
  12.181 +     * @return number of accessor types in system
  12.182 +     */
  12.183 +    public static int getNumberOfAccessorTypes() {
  12.184 +        return ACCESSOR_TYPES.size();
  12.185 +    }
  12.186 +
  12.187 +    /**
  12.188 +     * Return the accessor type based on its index in [0..getNumberOfAccessorTypes())
  12.189 +     * Indexes are ordered narrower->wider / optimistic->pessimistic. Invalidations always
  12.190 +     * go to a type of higher index
  12.191 +     *
  12.192 +     * @param index accessor type index
  12.193 +     *
  12.194 +     * @return a type corresponding to the index.
  12.195 +     */
  12.196 +
  12.197 +    public static Type getAccessorType(final int index) {
  12.198 +        return ACCESSOR_TYPES.get(index);
  12.199 +    }
  12.200 +
  12.201 +    /**
  12.202 +     * Returns the class name for JavaScript objects with fieldCount fields.
  12.203 +     *
  12.204 +     * @param fieldCount Number of fields to allocate.
  12.205 +     *
  12.206 +     * @return The class name.
  12.207 +     */
  12.208 +    public static String getClassName(final int fieldCount) {
  12.209 +        return fieldCount != 0 ? SCRIPTS_PACKAGE + '/' + JS_OBJECT_PREFIX.tag() + fieldCount :
  12.210 +                                 SCRIPTS_PACKAGE + '/' + JS_OBJECT_PREFIX.tag();
  12.211 +    }
  12.212 +
  12.213 +    /**
  12.214 +     * Returns the class name for JavaScript scope with fieldCount fields and
  12.215 +     * paramCount parameters.
  12.216 +     *
  12.217 +     * @param fieldCount Number of fields to allocate.
  12.218 +     * @param paramCount Number of parameters to allocate
  12.219 +     *
  12.220 +     * @return The class name.
  12.221 +     */
  12.222 +    public static String getClassName(final int fieldCount, final int paramCount) {
  12.223 +        return SCRIPTS_PACKAGE + '/' + JS_OBJECT_PREFIX.tag() + fieldCount + SCOPE_MARKER + paramCount;
  12.224 +    }
  12.225 +
  12.226 +    /**
  12.227 +     * Returns the name of a field based on number and type.
  12.228 +     *
  12.229 +     * @param fieldIndex Ordinal of field.
  12.230 +     * @param type       Type of field.
  12.231 +     *
  12.232 +     * @return The field name.
  12.233 +     */
  12.234 +    public static String getFieldName(final int fieldIndex, final Type type) {
  12.235 +        return type.getDescriptor().substring(0, 1) + fieldIndex;
  12.236 +    }
  12.237 +
  12.238 +    /**
  12.239 +     * In the world of Object fields, we also have no undefined SwitchPoint, to reduce as much potential
  12.240 +     * MethodHandle overhead as possible. In that case, we explicitly need to assign undefined to fields
  12.241 +     * when we initialize them.
  12.242 +     *
  12.243 +     * @param init       constructor to generate code in
  12.244 +     * @param className  name of class
  12.245 +     * @param fieldNames fields to initialize to undefined, where applicable
  12.246 +     */
  12.247 +    private static void initializeToUndefined(final MethodEmitter init, final String className, final List<String> fieldNames) {
  12.248 +        if (fieldNames.isEmpty()) {
  12.249 +            return;
  12.250 +        }
  12.251 +
  12.252 +        // always initialize fields to undefined, even with --dual-fields. Then it's ok to
  12.253 +        // remember things like "widest set type" in properties, and if it's object, don't
  12.254 +        // add any special "return undefined" getters, saving an invalidation
  12.255 +        init.load(Type.OBJECT, JAVA_THIS.slot());
  12.256 +        init.loadUndefined(Type.OBJECT);
  12.257 +
  12.258 +        final Iterator<String> iter = fieldNames.iterator();
  12.259 +        while (iter.hasNext()) {
  12.260 +            final String fieldName = iter.next();
  12.261 +            if (iter.hasNext()) {
  12.262 +                init.dup2();
  12.263 +            }
  12.264 +            init.putField(className, fieldName, Type.OBJECT.getDescriptor());
  12.265 +        }
  12.266 +    }
  12.267 +
  12.268 +    /**
  12.269 +     * Generate the byte codes for a JavaScript object class or scope.
  12.270 +     * Class name is a function of number of fields and number of param
  12.271 +     * fields
  12.272 +     *
  12.273 +     * @param descriptor Descriptor pulled from class name.
  12.274 +     *
  12.275 +     * @return Byte codes for generated class.
  12.276 +     */
  12.277 +    public byte[] generate(final String descriptor) {
  12.278 +        final String[] counts     = descriptor.split(SCOPE_MARKER);
  12.279 +        final int      fieldCount = Integer.valueOf(counts[0]);
  12.280 +
  12.281 +        if (counts.length == 1) {
  12.282 +            return generate(fieldCount);
  12.283 +        }
  12.284 +
  12.285 +        final int paramCount = Integer.valueOf(counts[1]);
  12.286 +
  12.287 +        return generate(fieldCount, paramCount);
  12.288 +    }
  12.289 +
  12.290 +    /**
  12.291 +     * Generate the byte codes for a JavaScript object class with fieldCount fields.
  12.292 +     *
  12.293 +     * @param fieldCount Number of fields in the JavaScript object.
  12.294 +     *
  12.295 +     * @return Byte codes for generated class.
  12.296 +     */
  12.297 +    public byte[] generate(final int fieldCount) {
  12.298 +        final String       className    = getClassName(fieldCount);
  12.299 +        final String       superName    = className(ScriptObject.class);
  12.300 +        final ClassEmitter classEmitter = newClassEmitter(className, superName);
  12.301 +        final List<String> initFields   = addFields(classEmitter, fieldCount);
  12.302 +
  12.303 +        final MethodEmitter init = newInitMethod(classEmitter);
  12.304 +        initializeToUndefined(init, className, initFields);
  12.305 +        init.returnVoid();
  12.306 +        init.end();
  12.307 +
  12.308 +        newEmptyInit(classEmitter, className);
  12.309 +        newAllocate(classEmitter, className);
  12.310 +
  12.311 +        return toByteArray(classEmitter);
  12.312 +    }
  12.313 +
  12.314 +    /**
  12.315 +     * Generate the byte codes for a JavaScript scope class with fieldCount fields
  12.316 +     * and paramCount parameters.
  12.317 +     *
  12.318 +     * @param fieldCount Number of fields in the JavaScript scope.
  12.319 +     * @param paramCount Number of parameters in the JavaScript scope
  12.320 +     * .
  12.321 +     * @return Byte codes for generated class.
  12.322 +     */
  12.323 +    public byte[] generate(final int fieldCount, final int paramCount) {
  12.324 +        final String className          = getClassName(fieldCount, paramCount);
  12.325 +        final String superName          = className(FunctionScope.class);
  12.326 +        final ClassEmitter classEmitter = newClassEmitter(className, superName);
  12.327 +        final List<String> initFields   = addFields(classEmitter, fieldCount);
  12.328 +
  12.329 +        final MethodEmitter init = newInitScopeMethod(classEmitter);
  12.330 +        initializeToUndefined(init, className, initFields);
  12.331 +        init.returnVoid();
  12.332 +        init.end();
  12.333 +
  12.334 +        final MethodEmitter initWithArguments = newInitScopeWithArgumentsMethod(classEmitter);
  12.335 +        initializeToUndefined(initWithArguments, className, initFields);
  12.336 +        initWithArguments.returnVoid();
  12.337 +        initWithArguments.end();
  12.338 +
  12.339 +        return toByteArray(classEmitter);
  12.340 +    }
  12.341 +
  12.342 +    /**
  12.343 +     * Generates the needed fields.
  12.344 +     *
  12.345 +     * @param classEmitter Open class emitter.
  12.346 +     * @param fieldCount   Number of fields.
  12.347 +     *
  12.348 +     * @return List fields that need to be initialized.
  12.349 +     */
  12.350 +    private static List<String> addFields(final ClassEmitter classEmitter, final int fieldCount) {
  12.351 +        final List<String> initFields = new LinkedList<>();
  12.352 +
  12.353 +        for (int i = 0; i < fieldCount; i++) {
  12.354 +            for (final Type type : FIELD_TYPES) {
  12.355 +                final String fieldName = getFieldName(i, type);
  12.356 +                classEmitter.field(fieldName, type.getTypeClass());
  12.357 +
  12.358 +                if (type == Type.OBJECT) {
  12.359 +                    initFields.add(fieldName);
  12.360 +                }
  12.361 +            }
  12.362 +        }
  12.363 +
  12.364 +        return initFields;
  12.365 +    }
  12.366 +
  12.367 +    /**
  12.368 +     * Allocate and initialize a new class emitter.
  12.369 +     *
  12.370 +     * @param className Name of JavaScript class.
  12.371 +     *
  12.372 +     * @return Open class emitter.
  12.373 +     */
  12.374 +    private ClassEmitter newClassEmitter(final String className, final String superName) {
  12.375 +        final ClassEmitter classEmitter = new ClassEmitter(context, className, superName);
  12.376 +        classEmitter.begin();
  12.377 +
  12.378 +        return classEmitter;
  12.379 +    }
  12.380 +
  12.381 +    /**
  12.382 +     * Allocate and initialize a new <init> method.
  12.383 +     *
  12.384 +     * @param classEmitter  Open class emitter.
  12.385 +     *
  12.386 +     * @return Open method emitter.
  12.387 +     */
  12.388 +    private static MethodEmitter newInitMethod(final ClassEmitter classEmitter) {
  12.389 +        final MethodEmitter init = classEmitter.init(PropertyMap.class);
  12.390 +        init.begin();
  12.391 +        init.load(Type.OBJECT, JAVA_THIS.slot());
  12.392 +        init.load(Type.OBJECT, MAP.slot());
  12.393 +        init.invoke(constructorNoLookup(ScriptObject.class, PropertyMap.class));
  12.394 +
  12.395 +        return init;
  12.396 +    }
  12.397 +
  12.398 +    /**
  12.399 +     * Allocate and initialize a new <init> method for scopes.
  12.400 +     * @param classEmitter  Open class emitter.
  12.401 +     * @return Open method emitter.
  12.402 +     */
  12.403 +    private static MethodEmitter newInitScopeMethod(final ClassEmitter classEmitter) {
  12.404 +        final MethodEmitter init = classEmitter.init(PropertyMap.class, ScriptObject.class);
  12.405 +        init.begin();
  12.406 +        init.load(Type.OBJECT, JAVA_THIS.slot());
  12.407 +        init.load(Type.OBJECT, MAP.slot());
  12.408 +        init.load(Type.OBJECT, INIT_SCOPE.slot());
  12.409 +        init.invoke(constructorNoLookup(FunctionScope.class, PropertyMap.class, ScriptObject.class));
  12.410 +
  12.411 +        return init;
  12.412 +    }
  12.413 +
  12.414 +    /**
  12.415 +     * Allocate and initialize a new <init> method for scopes with arguments.
  12.416 +     * @param classEmitter  Open class emitter.
  12.417 +     * @return Open method emitter.
  12.418 +     */
  12.419 +    private static MethodEmitter newInitScopeWithArgumentsMethod(final ClassEmitter classEmitter) {
  12.420 +        final MethodEmitter init = classEmitter.init(PropertyMap.class, ScriptObject.class, Object.class);
  12.421 +        init.begin();
  12.422 +        init.load(Type.OBJECT, JAVA_THIS.slot());
  12.423 +        init.load(Type.OBJECT, MAP.slot());
  12.424 +        init.load(Type.OBJECT, INIT_SCOPE.slot());
  12.425 +        init.load(Type.OBJECT, INIT_ARGUMENTS.slot());
  12.426 +        init.invoke(constructorNoLookup(FunctionScope.class, PropertyMap.class, ScriptObject.class, Object.class));
  12.427 +
  12.428 +        return init;
  12.429 +    }
  12.430 +
  12.431 +    /**
  12.432 +     * Add an empty <init> method to the JavaScript class.
  12.433 +     *
  12.434 +     * @param classEmitter Open class emitter.
  12.435 +     * @param className    Name of JavaScript class.
  12.436 +     */
  12.437 +    private static void newEmptyInit(final ClassEmitter classEmitter, final String className) {
  12.438 +        final MethodEmitter emptyInit = classEmitter.init();
  12.439 +        emptyInit.begin();
  12.440 +        emptyInit.load(Type.OBJECT, JAVA_THIS.slot());
  12.441 +        emptyInit.loadNull();
  12.442 +        emptyInit.invoke(constructorNoLookup(className, PropertyMap.class));
  12.443 +        emptyInit.returnVoid();
  12.444 +        emptyInit.end();
  12.445 +    }
  12.446 +
  12.447 +    /**
  12.448 +     * Add an empty <init> method to the JavaScript class.
  12.449 +     *
  12.450 +     * @param classEmitter Open class emitter.
  12.451 +     * @param className    Name of JavaScript class.
  12.452 +     */
  12.453 +    private static void newAllocate(final ClassEmitter classEmitter, final String className) {
  12.454 +        final MethodEmitter allocate = classEmitter.method(EnumSet.of(Flag.PUBLIC, Flag.STATIC), ALLOCATE.tag(), ScriptObject.class, PropertyMap.class);
  12.455 +        allocate.begin();
  12.456 +        allocate._new(className);
  12.457 +        allocate.dup();
  12.458 +        allocate.load(Type.typeFor(PropertyMap.class), 0);
  12.459 +        allocate.invoke(constructorNoLookup(className, PropertyMap.class));
  12.460 +        allocate._return();
  12.461 +        allocate.end();
  12.462 +    }
  12.463 +
  12.464 +    /**
  12.465 +     * Collects the byte codes for a generated JavaScript class.
  12.466 +     *
  12.467 +     * @param classEmitter Open class emitter.
  12.468 +     * @return Byte codes for the class.
  12.469 +     */
  12.470 +    private byte[] toByteArray(final ClassEmitter classEmitter) {
  12.471 +        classEmitter.end();
  12.472 +
  12.473 +        final byte[] code = classEmitter.toByteArray();
  12.474 +
  12.475 +        if (context != null && context._print_code) {
  12.476 +            Context.getCurrentErr().println(ClassEmitter.disassemble(code));
  12.477 +        }
  12.478 +
  12.479 +        if (context != null && context._verify_code) {
  12.480 +            context.verify(code);
  12.481 +        }
  12.482 +
  12.483 +        return code;
  12.484 +    }
  12.485 +
  12.486 +    /** Double to long bits, used with --dual-fields for primitive double values */
  12.487 +    private static final MethodHandle PACK_DOUBLE =
  12.488 +        MH.explicitCastArguments(MH.findStatic(MethodHandles.publicLookup(), Double.class, "doubleToRawLongBits", MH.type(long.class, double.class)), MH.type(long.class, double.class));
  12.489 +
  12.490 +    /** double bits to long, used with --dual-fields for primitive double values */
  12.491 +    private static MethodHandle UNPACK_DOUBLE =
  12.492 +        MH.findStatic(MethodHandles.publicLookup(), Double.class, "longBitsToDouble", MH.type(double.class, long.class));
  12.493 +
  12.494 +    /** object conversion quickies with JS semantics - used for return value and parameter filter */
  12.495 +    private static MethodHandle[] CONVERT_OBJECT = {
  12.496 +        JSType.TO_INT32.methodHandle(),
  12.497 +        JSType.TO_UINT32.methodHandle(),
  12.498 +        JSType.TO_NUMBER.methodHandle(),
  12.499 +        null
  12.500 +    };
  12.501 +
  12.502 +    /**
  12.503 +     * Given a primitiveGetter (optional for non dual fields) and an objectSetter that retrieve
  12.504 +     * the primitive and object version of a field respectively, return one with the correct
  12.505 +     * method type and the correct filters. For example, if the value is stored as a double
  12.506 +     * and we want an Object getter, in the dual fields world we'd pick the primitiveGetter,
  12.507 +     * which reads a long, use longBitsToDouble on the result to unpack it, and then change the
  12.508 +     * return type to Object, boxing it. In the objects only world there are only object fields,
  12.509 +     * primtives are boxed when asked for them and we don't need to bother with primitive encoding
  12.510 +     * (or even undefined, which if forType==null) representation, so we just return whatever is
  12.511 +     * in the object field. The object field is always initiated to Undefined, so here, where we have
  12.512 +     * the representation for Undefined in all our bits, this is not a problem.
  12.513 +     * <p>
  12.514 +     * Representing undefined in a primitive is hard, for an int there aren't enough bits, for a long
  12.515 +     * we could limit the width of a representation, and for a double (as long as it is stored as long,
  12.516 +     * as all NaNs will turn into QNaN on ia32, which is one bit pattern, we should use a special NaN).
  12.517 +     * Naturally we could have special undefined values for all types which mean "go look in a wider field",
  12.518 +     * but the guards needed on every getter took too much time.
  12.519 +     * <p>
  12.520 +     * To see how this is used, look for example in {@link AccessorProperty#getGetter}
  12.521 +     * <p>
  12.522 +     * @param forType         representation of the underlying type in the field, null if undefined
  12.523 +     * @param type            type to retrieve it as
  12.524 +     * @param primitiveGetter getter to read the primitive version of this field (null if Objects Only)
  12.525 +     * @param objectGetter    getter to read the object version of this field
  12.526 +     *
  12.527 +     * @return getter for the given representation that returns the given type
  12.528 +     */
  12.529 +    public static MethodHandle createGetter(final Class<?> forType, final Class<?> type, final MethodHandle primitiveGetter, final MethodHandle objectGetter) {
  12.530 +        final int fti = forType == null ? -1 : getAccessorTypeIndex(forType);
  12.531 +        final int ti  = getAccessorTypeIndex(type);
  12.532 +
  12.533 +        if (fti == TYPE_OBJECT_INDEX || OBJECT_FIELDS_ONLY) {
  12.534 +            if (ti == TYPE_OBJECT_INDEX) {
  12.535 +                return objectGetter;
  12.536 +            }
  12.537 +
  12.538 +            return MH.filterReturnValue(objectGetter, CONVERT_OBJECT[ti]);
  12.539 +        }
  12.540 +
  12.541 +        assert !OBJECT_FIELDS_ONLY;
  12.542 +        if (forType == null) {
  12.543 +            return GET_UNDEFINED[ti];
  12.544 +        }
  12.545 +
  12.546 +        final MethodType pmt = primitiveGetter.type();
  12.547 +
  12.548 +        switch (fti) {
  12.549 +        case TYPE_INT_INDEX:
  12.550 +        case TYPE_LONG_INDEX:
  12.551 +            switch (ti) {
  12.552 +            case TYPE_INT_INDEX:
  12.553 +                //get int while an int, truncating cast of long value
  12.554 +                return MH.explicitCastArguments(primitiveGetter, pmt.changeReturnType(int.class));
  12.555 +            case TYPE_LONG_INDEX:
  12.556 +                return primitiveGetter;
  12.557 +            default:
  12.558 +                return MH.asType(primitiveGetter, pmt.changeReturnType(type));
  12.559 +            }
  12.560 +        case TYPE_DOUBLE_INDEX:
  12.561 +            final MethodHandle getPrimitiveAsDouble = MH.filterReturnValue(primitiveGetter, UNPACK_DOUBLE);
  12.562 +            switch (ti) {
  12.563 +            case TYPE_INT_INDEX:
  12.564 +            case TYPE_LONG_INDEX:
  12.565 +                return MH.explicitCastArguments(getPrimitiveAsDouble, pmt.changeReturnType(type));
  12.566 +            case TYPE_DOUBLE_INDEX:
  12.567 +                return getPrimitiveAsDouble;
  12.568 +            default:
  12.569 +                return MH.asType(getPrimitiveAsDouble, pmt.changeReturnType(Object.class));
  12.570 +            }
  12.571 +        default:
  12.572 +            assert false;
  12.573 +            return null;
  12.574 +        }
  12.575 +    }
  12.576 +
  12.577 +    private static final MethodHandle IS_TYPE_GUARD = findOwnMH("isType", boolean.class, Class.class, Object.class);
  12.578 +
  12.579 +    @SuppressWarnings("unused")
  12.580 +    private static boolean isType(final Class<?> boxedForType, final Object x) {
  12.581 +        return x.getClass() == boxedForType;
  12.582 +    }
  12.583 +
  12.584 +    private static Class<? extends Number> getBoxedType(final Class<?> forType) {
  12.585 +        if (forType == int.class) {
  12.586 +            return Integer.class;
  12.587 +        }
  12.588 +
  12.589 +        if (forType == long.class) {
  12.590 +            return Long.class;
  12.591 +        }
  12.592 +
  12.593 +        if (forType == double.class) {
  12.594 +            return Double.class;
  12.595 +        }
  12.596 +
  12.597 +        assert false;
  12.598 +        return null;
  12.599 +    }
  12.600 +
  12.601 +    /**
  12.602 +     * If we are setting boxed types (because the compiler couldn't determine which they were) to
  12.603 +     * a primitive field, we can reuse the primitive field getter, as long as we are setting an element
  12.604 +     * of the same boxed type as the primitive type representation
  12.605 +     *
  12.606 +     * @param forType           the current type
  12.607 +     * @param primitiveSetter   primitive setter for the current type with an element of the current type
  12.608 +     * @param objectSetter      the object setter
  12.609 +     *
  12.610 +     * @return method handle that checks if the element to be set is of the currenttype, even though it's boxed
  12.611 +     *  and instead of using the generic object setter, that would blow up the type and invalidate the map,
  12.612 +     *  unbox it and call the primitive setter instead
  12.613 +     */
  12.614 +    public static MethodHandle createGuardBoxedPrimitiveSetter(final Class<?> forType, final MethodHandle primitiveSetter, final MethodHandle objectSetter) {
  12.615 +        final Class<? extends Number> boxedForType = getBoxedType(forType);
  12.616 +        //object setter that checks for primitive if current type is primitive
  12.617 +
  12.618 +        return MH.guardWithTest(
  12.619 +            MH.insertArguments(
  12.620 +                MH.dropArguments(
  12.621 +                    IS_TYPE_GUARD,
  12.622 +                    1,
  12.623 +                    Object.class),
  12.624 +                0,
  12.625 +                boxedForType),
  12.626 +                MH.asType(
  12.627 +                    primitiveSetter,
  12.628 +                    objectSetter.type()),
  12.629 +                objectSetter);
  12.630 +    }
  12.631 +
  12.632 +    /**
  12.633 +     * This is similar to the {@link ObjectClassGenerator#createGetter} function. Performs
  12.634 +     * the necessary operations to massage a setter operand of type {@code type} to
  12.635 +     * fit into the primitive field (if primitive and dual fields is enabled) or into
  12.636 +     * the object field (box if primitive and dual fields is disabled)
  12.637 +     *
  12.638 +     * @param forType         representation of the underlying object
  12.639 +     * @param type            representation of field to write, and setter signature
  12.640 +     * @param primitiveSetter setter that writes to the primitive field (null if Objects Only)
  12.641 +     * @param objectSetter    setter that writes to the object field
  12.642 +     *
  12.643 +     * @return the setter for the given representation that takes a {@code type}
  12.644 +     */
  12.645 +    public static MethodHandle createSetter(final Class<?> forType, final Class<?> type, final MethodHandle primitiveSetter, final MethodHandle objectSetter) {
  12.646 +        assert forType != null;
  12.647 +
  12.648 +        final int fti = getAccessorTypeIndex(forType);
  12.649 +        final int ti  = getAccessorTypeIndex(type);
  12.650 +
  12.651 +        if (fti == TYPE_OBJECT_INDEX || OBJECT_FIELDS_ONLY) {
  12.652 +            if (ti == TYPE_OBJECT_INDEX) {
  12.653 +                return objectSetter;
  12.654 +            }
  12.655 +
  12.656 +            return MH.asType(objectSetter, objectSetter.type().changeParameterType(1, type));
  12.657 +        }
  12.658 +
  12.659 +        assert !OBJECT_FIELDS_ONLY;
  12.660 +
  12.661 +        final MethodType pmt = primitiveSetter.type();
  12.662 +
  12.663 +        switch (fti) {
  12.664 +        case TYPE_INT_INDEX:
  12.665 +        case TYPE_LONG_INDEX:
  12.666 +            switch (ti) {
  12.667 +            case TYPE_INT_INDEX:
  12.668 +                return MH.asType(primitiveSetter, pmt.changeParameterType(1, int.class));
  12.669 +            case TYPE_LONG_INDEX:
  12.670 +                return primitiveSetter;
  12.671 +            case TYPE_DOUBLE_INDEX:
  12.672 +                return MH.filterArguments(primitiveSetter, 1, PACK_DOUBLE);
  12.673 +            default:
  12.674 +                return objectSetter;
  12.675 +            }
  12.676 +        case TYPE_DOUBLE_INDEX:
  12.677 +            if (ti == TYPE_OBJECT_INDEX) {
  12.678 +                return objectSetter;
  12.679 +            }
  12.680 +            return MH.asType(MH.filterArguments(primitiveSetter, 1, PACK_DOUBLE), pmt.changeParameterType(1, type));
  12.681 +        default:
  12.682 +            assert false;
  12.683 +            return null;
  12.684 +        }
  12.685 +    }
  12.686 +
  12.687 +    //
  12.688 +    // Provide generic getters and setters for undefined types. If a type is undefined, all
  12.689 +    // and marshals the set to the correct setter depending on the type of the value being set.
  12.690 +    // Note that there are no actual undefined versions of int, long and double in JavaScript,
  12.691 +    // but executing toInt32, toLong and toNumber always returns a working result, 0, 0L or NaN
  12.692 +    //
  12.693 +
  12.694 +    /** The value of Undefined cast to an int32 */
  12.695 +    public static final int    UNDEFINED_INT    = 0;
  12.696 +    /** The value of Undefined cast to a long */
  12.697 +    public static final long   UNDEFINED_LONG   = 0L;
  12.698 +    /** The value of Undefined cast to a double */
  12.699 +    public static final double UNDEFINED_DOUBLE = Double.NaN;
  12.700 +
  12.701 +    /**
  12.702 +     * Compute type name for correct undefined getter
  12.703 +     * @param type the type
  12.704 +     * @return name of getter
  12.705 +     */
  12.706 +    private static String typeName(final Type type) {
  12.707 +        String name = type.getTypeClass().getName();
  12.708 +        final int dot = name.lastIndexOf('.');
  12.709 +        if (dot != -1) {
  12.710 +            name = name.substring(dot + 1);
  12.711 +        }
  12.712 +        return Character.toUpperCase(name.charAt(0)) + name.substring(1);
  12.713 +    }
  12.714 +
  12.715 +    /**
  12.716 +     * Handles for undefined getters of the different types
  12.717 +     */
  12.718 +    private static final MethodHandle[] GET_UNDEFINED = new MethodHandle[ObjectClassGenerator.getNumberOfAccessorTypes()];
  12.719 +
  12.720 +    /**
  12.721 +     * Used to wrap getters for undefined values, where this matters. Currently only in dual fields.
  12.722 +     * If an object starts out as undefined it needs special getters until it has been assigned
  12.723 +     * something the first time
  12.724 +     *
  12.725 +     * @param returnType type to cast the undefined to
  12.726 +     *
  12.727 +     * @return undefined as returnType
  12.728 +     */
  12.729 +    public static MethodHandle getUndefined(final Class<?> returnType) {
  12.730 +        return GET_UNDEFINED[ObjectClassGenerator.getAccessorTypeIndex(returnType)];
  12.731 +    }
  12.732 +
  12.733 +    static {
  12.734 +        int pos = 0;
  12.735 +        for (final Type type : ACCESSOR_TYPES) {
  12.736 +            GET_UNDEFINED[pos++] = findOwnMH("getUndefined" + typeName(type), type.getTypeClass(), Object.class);
  12.737 +        }
  12.738 +    }
  12.739 +
  12.740 +    @SuppressWarnings("unused")
  12.741 +    private static int getUndefinedInt(final Object obj) {
  12.742 +        return UNDEFINED_INT;
  12.743 +    }
  12.744 +
  12.745 +    @SuppressWarnings("unused")
  12.746 +    private static long getUndefinedLong(final Object obj) {
  12.747 +        return UNDEFINED_LONG;
  12.748 +    }
  12.749 +
  12.750 +    @SuppressWarnings("unused")
  12.751 +    private static double getUndefinedDouble(final Object obj) {
  12.752 +        return UNDEFINED_DOUBLE;
  12.753 +    }
  12.754 +
  12.755 +    @SuppressWarnings("unused")
  12.756 +    private static Object getUndefinedObject(final Object obj) {
  12.757 +        return ScriptRuntime.UNDEFINED;
  12.758 +    }
  12.759 +
  12.760 +    private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
  12.761 +        return MH.findStatic(MethodHandles.lookup(), ObjectClassGenerator.class, name, MH.type(rtype, types));
  12.762 +    }
  12.763 +}
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/src/jdk/nashorn/internal/codegen/ObjectCreator.java	Fri Feb 15 09:44:15 2013 +0100
    13.3 @@ -0,0 +1,172 @@
    13.4 +/*
    13.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.7 + *
    13.8 + * This code is free software; you can redistribute it and/or modify it
    13.9 + * under the terms of the GNU General Public License version 2 only, as
   13.10 + * published by the Free Software Foundation.  Oracle designates this
   13.11 + * particular file as subject to the "Classpath" exception as provided
   13.12 + * by Oracle in the LICENSE file that accompanied this code.
   13.13 + *
   13.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   13.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   13.17 + * version 2 for more details (a copy is included in the LICENSE file that
   13.18 + * accompanied this code).
   13.19 + *
   13.20 + * You should have received a copy of the GNU General Public License version
   13.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   13.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   13.23 + *
   13.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   13.25 + * or visit www.oracle.com if you need additional information or have any
   13.26 + * questions.
   13.27 + */
   13.28 +
   13.29 +package jdk.nashorn.internal.codegen;
   13.30 +
   13.31 +import java.util.List;
   13.32 +import jdk.nashorn.internal.ir.Symbol;
   13.33 +import jdk.nashorn.internal.runtime.Context;
   13.34 +import jdk.nashorn.internal.runtime.PropertyMap;
   13.35 +
   13.36 +/**
   13.37 + * Base class for object creation code generation.
   13.38 + */
   13.39 +public abstract class ObjectCreator {
   13.40 +
   13.41 +    /** Compile unit for this ObjectCreator, see CompileUnit */
   13.42 +    protected final CompileUnit   compileUnit;
   13.43 +
   13.44 +    /** List of keys to initiate in this ObjectCreator */
   13.45 +    protected final List<String>  keys;
   13.46 +
   13.47 +    /** List of symbols to initiate in this ObjectCreator */
   13.48 +    protected final List<Symbol>  symbols;
   13.49 +
   13.50 +    /** Code generator */
   13.51 +    protected final CodeGenerator codegen;
   13.52 +
   13.53 +    private   final boolean       isScope;
   13.54 +    private   final boolean       hasArguments;
   13.55 +    private         int           fieldCount;
   13.56 +    private         int           paramCount;
   13.57 +    private         String        fieldObjectClassName;
   13.58 +    private         Class<?>      fieldObjectClass;
   13.59 +    private         PropertyMap   propertyMap;
   13.60 +
   13.61 +    /**
   13.62 +     * Constructor
   13.63 +     *
   13.64 +     * @param codegen      the code generator
   13.65 +     * @param keys         the keys
   13.66 +     * @param symbols      the symbols corresponding to keys, same index
   13.67 +     * @param isScope      is this object scope
   13.68 +     * @param hasArguments does the created object have an "arguments" property
   13.69 +     */
   13.70 +    protected ObjectCreator(final CodeGenerator codegen, final List<String> keys, final List<Symbol> symbols, final boolean isScope, final boolean hasArguments) {
   13.71 +        this.codegen       = codegen;
   13.72 +        this.compileUnit   = codegen.getCurrentCompileUnit();
   13.73 +        this.keys          = keys;
   13.74 +        this.symbols       = symbols;
   13.75 +        this.isScope       = isScope;
   13.76 +        this.hasArguments  = hasArguments;
   13.77 +
   13.78 +        countFields();
   13.79 +        findClass();
   13.80 +    }
   13.81 +
   13.82 +    /**
   13.83 +     * Tally the number of fields and parameters.
   13.84 +     */
   13.85 +    private void countFields() {
   13.86 +        for (final Symbol symbol : this.symbols) {
   13.87 +            if (symbol != null) {
   13.88 +                if (hasArguments() && symbol.isParam()) {
   13.89 +                    symbol.setFieldIndex(paramCount++);
   13.90 +                } else {
   13.91 +                    symbol.setFieldIndex(fieldCount++);
   13.92 +                }
   13.93 +            }
   13.94 +        }
   13.95 +    }
   13.96 +
   13.97 +    /**
   13.98 +     * Locate (or indirectly create) the object container class.
   13.99 +     */
  13.100 +    private void findClass() {
  13.101 +        fieldObjectClassName = isScope() ?
  13.102 +            ObjectClassGenerator.getClassName(fieldCount, paramCount) :
  13.103 +            ObjectClassGenerator.getClassName(fieldCount);
  13.104 +
  13.105 +        try {
  13.106 +            this.fieldObjectClass = Context.forStructureClass(Compiler.binaryName(fieldObjectClassName));
  13.107 +        } catch (final ClassNotFoundException e) {
  13.108 +            throw new AssertionError("Nashorn has encountered an internal error.  Structure can not be created.");
  13.109 +        }
  13.110 +    }
  13.111 +
  13.112 +    /**
  13.113 +     * Generate code for making the object.
  13.114 +     * @param method Script method.
  13.115 +     */
  13.116 +    protected abstract void makeObject(final MethodEmitter method);
  13.117 +
  13.118 +    /**
  13.119 +     * Create a new MapCreator
  13.120 +     * @param clazz type of MapCreator
  13.121 +     * @return map creator instantiated by type
  13.122 +     */
  13.123 +    protected MapCreator newMapCreator(final Class<?> clazz) {
  13.124 +        return new MapCreator(clazz, keys, symbols);
  13.125 +    }
  13.126 +
  13.127 +    /**
  13.128 +     * Construct the property map appropriate for the object.
  13.129 +     * @return the newly created property map
  13.130 +     */
  13.131 +    protected PropertyMap makeMap() {
  13.132 +        if (keys.isEmpty()) { //empty map
  13.133 +            propertyMap = PropertyMap.newMap(fieldObjectClass);
  13.134 +        } else {
  13.135 +            propertyMap = newMapCreator(fieldObjectClass).makeMap(hasArguments());
  13.136 +        }
  13.137 +        return propertyMap;
  13.138 +    }
  13.139 +
  13.140 +    /**
  13.141 +     * Emit the correct map for the object.
  13.142 +     * @param method method emitter
  13.143 +     * @return the method emitter
  13.144 +     */
  13.145 +    protected MethodEmitter loadMap(final MethodEmitter method) {
  13.146 +        codegen.loadConstant(propertyMap);
  13.147 +        return method;
  13.148 +    }
  13.149 +
  13.150 +    /**
  13.151 +     * Get the class name for the object class,
  13.152 +     * e.g. {@code com.nashorn.oracle.scripts.JO$2P0}
  13.153 +     *
  13.154 +     * @return script class name
  13.155 +     */
  13.156 +    String getClassName() {
  13.157 +        return fieldObjectClassName;
  13.158 +    }
  13.159 +
  13.160 +    /**
  13.161 +     * Is this a scope object
  13.162 +     * @return true if scope
  13.163 +     */
  13.164 +    protected boolean isScope() {
  13.165 +        return isScope;
  13.166 +    }
  13.167 +
  13.168 +    /**
  13.169 +     * Does the created object have an "arguments" property
  13.170 +     * @return true if has an "arguments" property
  13.171 +     */
  13.172 +    protected boolean hasArguments() {
  13.173 +        return hasArguments;
  13.174 +    }
  13.175 +}
    14.1 --- a/src/jdk/nashorn/internal/codegen/SharedScopeCall.java	Fri Feb 15 09:18:05 2013 +0100
    14.2 +++ b/src/jdk/nashorn/internal/codegen/SharedScopeCall.java	Fri Feb 15 09:44:15 2013 +0100
    14.3 @@ -48,7 +48,7 @@
    14.4   * <p>Scope calls must not be shared between normal callsites and callsites contained in a <tt>with</tt>
    14.5   * statement as this condition is not handled by current guards and will cause a runtime error.</p>
    14.6   */
    14.7 -public class SharedScopeCall {
    14.8 +class SharedScopeCall {
    14.9  
   14.10      /** Threshold for using shared scope calls with fast scope access. */
   14.11      public static final int FAST_SCOPE_CALL_THRESHOLD = 4;
   14.12 @@ -118,7 +118,7 @@
   14.13       * @param method the method emitter
   14.14       */
   14.15      public void generateInvoke(final MethodEmitter method) {
   14.16 -        method.invokeStatic(compileUnit.getUnitClassName(), methodName, getStaticSignature());
   14.17 +        method.invokestatic(compileUnit.getUnitClassName(), methodName, getStaticSignature());
   14.18      }
   14.19  
   14.20      /**
   14.21 @@ -138,8 +138,8 @@
   14.22  
   14.23          // Load correct scope by calling getProto() on the scope argument as often as specified
   14.24          // by the second argument.
   14.25 -        final MethodEmitter.Label parentLoopStart = new MethodEmitter.Label("parent_loop_start");
   14.26 -        final MethodEmitter.Label parentLoopDone = new MethodEmitter.Label("parent_loop_done");
   14.27 +        final Label parentLoopStart = new Label("parent_loop_start");
   14.28 +        final Label parentLoopDone  = new Label("parent_loop_done");
   14.29          method.load(Type.OBJECT, 0);
   14.30          method.label(parentLoopStart);
   14.31          method.load(Type.INT, 1);
    15.1 --- a/src/jdk/nashorn/internal/codegen/Splitter.java	Fri Feb 15 09:18:05 2013 +0100
    15.2 +++ b/src/jdk/nashorn/internal/codegen/Splitter.java	Fri Feb 15 09:44:15 2013 +0100
    15.3 @@ -396,7 +396,7 @@
    15.4           * @param targetNode the jump target node.
    15.5           * @param targetLabel the jump target label.
    15.6           */
    15.7 -        private void searchJumpTarget(final Node targetNode, final MethodEmitter.Label targetLabel) {
    15.8 +        private void searchJumpTarget(final Node targetNode, final Label targetLabel) {
    15.9  
   15.10              final SplitNode targetSplit = targetNodes.get(targetNode);
   15.11              // Note that targetSplit may be null, indicating that targetNode is in top level method.
   15.12 @@ -406,7 +406,7 @@
   15.13                  if (split == targetSplit) {
   15.14                      break;
   15.15                  }
   15.16 -                final List<MethodEmitter.Label> externalTargets = split.getExternalTargets();
   15.17 +                final List<Label> externalTargets = split.getExternalTargets();
   15.18                  if (!externalTargets.contains(targetLabel)) {
   15.19                      split.addExternalTarget(targetLabel);
   15.20                  }
    16.1 --- a/src/jdk/nashorn/internal/codegen/objects/FieldObjectCreator.java	Fri Feb 15 09:18:05 2013 +0100
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,194 +0,0 @@
    16.4 -/*
    16.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    16.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    16.7 - *
    16.8 - * This code is free software; you can redistribute it and/or modify it
    16.9 - * under the terms of the GNU General Public License version 2 only, as
   16.10 - * published by the Free Software Foundation.  Oracle designates this
   16.11 - * particular file as subject to the "Classpath" exception as provided
   16.12 - * by Oracle in the LICENSE file that accompanied this code.
   16.13 - *
   16.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   16.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   16.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   16.17 - * version 2 for more details (a copy is included in the LICENSE file that
   16.18 - * accompanied this code).
   16.19 - *
   16.20 - * You should have received a copy of the GNU General Public License version
   16.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   16.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   16.23 - *
   16.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   16.25 - * or visit www.oracle.com if you need additional information or have any
   16.26 - * questions.
   16.27 - */
   16.28 -
   16.29 -package jdk.nashorn.internal.codegen.objects;
   16.30 -
   16.31 -import static jdk.nashorn.internal.codegen.CompilerConstants.ARGUMENTS;
   16.32 -import static jdk.nashorn.internal.codegen.CompilerConstants.constructorNoLookup;
   16.33 -import static jdk.nashorn.internal.codegen.CompilerConstants.typeDescriptor;
   16.34 -import static jdk.nashorn.internal.codegen.types.Type.OBJECT;
   16.35 -
   16.36 -import java.util.Iterator;
   16.37 -import java.util.List;
   16.38 -import jdk.nashorn.internal.codegen.CodeGenerator;
   16.39 -import jdk.nashorn.internal.codegen.MethodEmitter;
   16.40 -import jdk.nashorn.internal.codegen.types.Type;
   16.41 -import jdk.nashorn.internal.ir.Symbol;
   16.42 -import jdk.nashorn.internal.runtime.PropertyMap;
   16.43 -import jdk.nashorn.internal.runtime.ScriptObject;
   16.44 -import jdk.nashorn.internal.runtime.arrays.ArrayIndex;
   16.45 -
   16.46 -/**
   16.47 - * Analyze an object's characteristics for appropriate code generation. This
   16.48 - * is used for functions and for objects. A field object take a set of values which
   16.49 - * to assign to the various fields in the object. This is done by the generated code
   16.50 - *
   16.51 - * @param <T> the value type for the fields being written on object creation, e.g. Node
   16.52 - * @see jdk.nashorn.internal.ir.Node
   16.53 - */
   16.54 -public abstract class FieldObjectCreator<T> extends ObjectCreator {
   16.55 -    /** array of corresponding values to symbols (null for no values) */
   16.56 -    private final List<T> values;
   16.57 -
   16.58 -    /** call site flags to be used for invocations */
   16.59 -    private final int     callSiteFlags;
   16.60 -
   16.61 -    /**
   16.62 -     * Constructor
   16.63 -     *
   16.64 -     * @param codegen  code generator
   16.65 -     * @param keys     keys for fields in object
   16.66 -     * @param symbols  symbols for fields in object
   16.67 -     * @param values   list of values corresponding to keys
   16.68 -     */
   16.69 -    public FieldObjectCreator(final CodeGenerator codegen, final List<String> keys, final List<Symbol> symbols, final List<T> values) {
   16.70 -        this(codegen, keys, symbols, values, false, false);
   16.71 -    }
   16.72 -
   16.73 -    /**
   16.74 -     * Constructor
   16.75 -     *
   16.76 -     * @param codegen      code generator
   16.77 -     * @param keys         keys for fields in object
   16.78 -     * @param symbols      symbols for fields in object
   16.79 -     * @param values       values (or null where no value) to be written to the fields
   16.80 -     * @param isScope      is this a scope object
   16.81 -     * @param hasArguments does the created object have an "arguments" property
   16.82 -     */
   16.83 -    public FieldObjectCreator(final CodeGenerator codegen, final List<String> keys, final List<Symbol> symbols, final List<T> values, final boolean isScope, final boolean hasArguments) {
   16.84 -        super(codegen, keys, symbols, isScope, hasArguments);
   16.85 -        this.values        = values;
   16.86 -        this.callSiteFlags = codegen.getCallSiteFlags();
   16.87 -    }
   16.88 -
   16.89 -    /**
   16.90 -     * Loads the scope on the stack through the passed method emitter.
   16.91 -     * @param method the method emitter to use
   16.92 -     */
   16.93 -    protected void loadScope(final MethodEmitter method) {
   16.94 -        method.loadScope();
   16.95 -    }
   16.96 -
   16.97 -    /**
   16.98 -     * Construct an object.
   16.99 -     *
  16.100 -     * @param method the method emitter
  16.101 -     */
  16.102 -    @Override
  16.103 -    public void makeObject(final MethodEmitter method) {
  16.104 -        makeMap();
  16.105 -
  16.106 -        method._new(getClassName()).dup(); // create instance
  16.107 -        loadMap(method); //load the map
  16.108 -
  16.109 -        if (isScope()) {
  16.110 -            loadScope(method);
  16.111 -
  16.112 -            if (hasArguments()) {
  16.113 -                method.loadArguments();
  16.114 -                method.invoke(constructorNoLookup(getClassName(), PropertyMap.class, ScriptObject.class, ARGUMENTS.type()));
  16.115 -            } else {
  16.116 -                method.invoke(constructorNoLookup(getClassName(), PropertyMap.class, ScriptObject.class));
  16.117 -            }
  16.118 -        } else {
  16.119 -            method.invoke(constructorNoLookup(getClassName(), PropertyMap.class));
  16.120 -        }
  16.121 -
  16.122 -        // Set values.
  16.123 -        final Iterator<Symbol> symbolIter = symbols.iterator();
  16.124 -        final Iterator<String> keyIter    = keys.iterator();
  16.125 -        final Iterator<T>      valueIter  = values.iterator();
  16.126 -
  16.127 -        while (symbolIter.hasNext()) {
  16.128 -            final Symbol symbol = symbolIter.next();
  16.129 -            final String key    = keyIter.next();
  16.130 -            final T      value  = valueIter.next();
  16.131 -
  16.132 -            if (symbol != null && value != null) {
  16.133 -                final int index = ArrayIndex.getArrayIndexNoThrow(key);
  16.134 -
  16.135 -                if (index < 0) {
  16.136 -                    putField(method, key, symbol.getFieldIndex(), value);
  16.137 -                } else {
  16.138 -                    putSlot(method, index, value);
  16.139 -                }
  16.140 -            }
  16.141 -        }
  16.142 -    }
  16.143 -
  16.144 -    /**
  16.145 -     * Technique for loading an initial value. Defined by anonymous subclasses in code gen.
  16.146 -     *
  16.147 -     * @param value Value to load.
  16.148 -     */
  16.149 -    protected abstract void loadValue(T value);
  16.150 -
  16.151 -    /**
  16.152 -     * Determine the type of a value. Defined by anonymous subclasses in code gen.
  16.153 -     *
  16.154 -     * @param value Value to inspect.
  16.155 -     *
  16.156 -     * @return Value type.
  16.157 -     */
  16.158 -    protected abstract Type getValueType(T value);
  16.159 -
  16.160 -    /**
  16.161 -     * Store a value in a field of the generated class object.
  16.162 -     *
  16.163 -     * @param method      Script method.
  16.164 -     * @param key         Property key.
  16.165 -     * @param fieldIndex  Field number.
  16.166 -     * @param value       Value to store.
  16.167 -     */
  16.168 -    private void putField(final MethodEmitter method, final String key, final int fieldIndex, final T value) {
  16.169 -        method.dup();
  16.170 -
  16.171 -        loadValue(value);
  16.172 -
  16.173 -        final Type valueType = getValueType(value);
  16.174 -        // for example when we have a with scope
  16.175 -        if (valueType.isObject() || valueType.isBoolean()) {
  16.176 -            method.convert(OBJECT);
  16.177 -        }
  16.178 -
  16.179 -        method.convert(OBJECT);
  16.180 -        method.putField(getClassName(), ObjectClassGenerator.getFieldName(fieldIndex, Type.OBJECT), typeDescriptor(Object.class));
  16.181 -    }
  16.182 -
  16.183 -    /**
  16.184 -     * Store a value in an indexed slot of a generated class object.
  16.185 -     *
  16.186 -     * @param method Script method.
  16.187 -     * @param index  Slot index.
  16.188 -     * @param value  Value to store.
  16.189 -     */
  16.190 -    private void putSlot(final MethodEmitter method, final int index, final T value) {
  16.191 -        method.dup();
  16.192 -        method.load(index);
  16.193 -        loadValue(value);
  16.194 -        method.dynamicSetIndex(callSiteFlags);
  16.195 -    }
  16.196 -
  16.197 -}
    17.1 --- a/src/jdk/nashorn/internal/codegen/objects/MapCreator.java	Fri Feb 15 09:18:05 2013 +0100
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,123 +0,0 @@
    17.4 -/*
    17.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    17.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    17.7 - *
    17.8 - * This code is free software; you can redistribute it and/or modify it
    17.9 - * under the terms of the GNU General Public License version 2 only, as
   17.10 - * published by the Free Software Foundation.  Oracle designates this
   17.11 - * particular file as subject to the "Classpath" exception as provided
   17.12 - * by Oracle in the LICENSE file that accompanied this code.
   17.13 - *
   17.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   17.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   17.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   17.17 - * version 2 for more details (a copy is included in the LICENSE file that
   17.18 - * accompanied this code).
   17.19 - *
   17.20 - * You should have received a copy of the GNU General Public License version
   17.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   17.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   17.23 - *
   17.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   17.25 - * or visit www.oracle.com if you need additional information or have any
   17.26 - * questions.
   17.27 - */
   17.28 -
   17.29 -package jdk.nashorn.internal.codegen.objects;
   17.30 -
   17.31 -import java.util.ArrayList;
   17.32 -import java.util.List;
   17.33 -import jdk.nashorn.internal.ir.Symbol;
   17.34 -import jdk.nashorn.internal.runtime.AccessorProperty;
   17.35 -import jdk.nashorn.internal.runtime.Property;
   17.36 -import jdk.nashorn.internal.runtime.PropertyMap;
   17.37 -import jdk.nashorn.internal.runtime.arrays.ArrayIndex;
   17.38 -
   17.39 -/**
   17.40 - * Class that creates PropertyMap sent to script object constructors.
   17.41 - */
   17.42 -public class MapCreator {
   17.43 -    /** Object structure for objects associated with this map */
   17.44 -    private final Class<?> structure;
   17.45 -
   17.46 -    /** key set for object map */
   17.47 -    private final String[] keys;
   17.48 -
   17.49 -    /** corresponding symbol set for object map */
   17.50 -    private final Symbol[] symbols;
   17.51 -
   17.52 -    /**
   17.53 -     * Constructor
   17.54 -     *
   17.55 -     * @param structure structure to generate map for (a JO$ subclass)
   17.56 -     * @param keys      list of keys for map
   17.57 -     * @param symbols   list of symbols for map
   17.58 -     */
   17.59 -    public MapCreator(final Class<?> structure, final List<String> keys, final List<Symbol> symbols) {
   17.60 -        final int size   = keys.size();
   17.61 -
   17.62 -        this.structure = structure;
   17.63 -        this.keys      = keys.toArray(new String[size]);
   17.64 -        this.symbols   = symbols.toArray(new Symbol[size]);
   17.65 -    }
   17.66 -
   17.67 -    /**
   17.68 -     * Constructs a property map based on a set of fields.
   17.69 -     *
   17.70 -     * @param hasArguments does the created object have an "arguments" property
   17.71 -     *
   17.72 -     * @return New map populated with accessor properties.
   17.73 -     */
   17.74 -    public PropertyMap makeMap(final boolean hasArguments) {
   17.75 -        final List<Property> properties = new ArrayList<>();
   17.76 -
   17.77 -        assert keys != null;
   17.78 -
   17.79 -        for (int i = 0; i < keys.length; i++) {
   17.80 -            final String key    = keys[i];
   17.81 -            final Symbol symbol = symbols[i];
   17.82 -
   17.83 -            if (symbol != null && !ArrayIndex.isIndexKey(key)) {
   17.84 -                properties.add(new AccessorProperty(key, getPropertyFlags(symbol, hasArguments), structure, symbol.getFieldIndex()));
   17.85 -            }
   17.86 -        }
   17.87 -
   17.88 -        return PropertyMap.newMap(structure, properties);
   17.89 -    }
   17.90 -
   17.91 -    /**
   17.92 -     * Compute property flags given local state of a field. Maybe be overridden and extended,
   17.93 -     * as is the case in {@link ObjectMapCreator}
   17.94 -     *
   17.95 -     * @param symbol       symbol to check
   17.96 -     * @param hasArguments does the created object have an "arguments" property
   17.97 -     *
   17.98 -     * @return flags to use for fields
   17.99 -     */
  17.100 -    protected int getPropertyFlags(final Symbol symbol, final boolean hasArguments) {
  17.101 -        int flags = 0;
  17.102 -
  17.103 -        if (symbol.isParam()) {
  17.104 -            flags |= Property.IS_ALWAYS_OBJECT | Property.IS_PARAMETER;
  17.105 -        }
  17.106 -
  17.107 -        if (hasArguments) {
  17.108 -            flags |= Property.IS_ALWAYS_OBJECT | Property.HAS_ARGUMENTS;
  17.109 -        }
  17.110 -
  17.111 -        if (symbol.isScope()) {
  17.112 -            flags |= Property.NOT_CONFIGURABLE;
  17.113 -        }
  17.114 -
  17.115 -        if (symbol.canBePrimitive()) {
  17.116 -            flags |= Property.CAN_BE_PRIMITIVE;
  17.117 -        }
  17.118 -
  17.119 -        if (symbol.canBeUndefined()) {
  17.120 -            flags |= Property.CAN_BE_UNDEFINED;
  17.121 -        }
  17.122 -
  17.123 -        return flags;
  17.124 -    }
  17.125 -
  17.126 -}
    18.1 --- a/src/jdk/nashorn/internal/codegen/objects/ObjectClassGenerator.java	Fri Feb 15 09:18:05 2013 +0100
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,762 +0,0 @@
    18.4 -/*
    18.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    18.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.7 - *
    18.8 - * This code is free software; you can redistribute it and/or modify it
    18.9 - * under the terms of the GNU General Public License version 2 only, as
   18.10 - * published by the Free Software Foundation.  Oracle designates this
   18.11 - * particular file as subject to the "Classpath" exception as provided
   18.12 - * by Oracle in the LICENSE file that accompanied this code.
   18.13 - *
   18.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   18.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   18.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   18.17 - * version 2 for more details (a copy is included in the LICENSE file that
   18.18 - * accompanied this code).
   18.19 - *
   18.20 - * You should have received a copy of the GNU General Public License version
   18.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   18.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   18.23 - *
   18.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   18.25 - * or visit www.oracle.com if you need additional information or have any
   18.26 - * questions.
   18.27 - */
   18.28 -
   18.29 -package jdk.nashorn.internal.codegen.objects;
   18.30 -
   18.31 -import static jdk.nashorn.internal.codegen.Compiler.SCRIPTS_PACKAGE;
   18.32 -import static jdk.nashorn.internal.codegen.CompilerConstants.ALLOCATE;
   18.33 -import static jdk.nashorn.internal.codegen.CompilerConstants.INIT_ARGUMENTS;
   18.34 -import static jdk.nashorn.internal.codegen.CompilerConstants.INIT_SCOPE;
   18.35 -import static jdk.nashorn.internal.codegen.CompilerConstants.JAVA_THIS;
   18.36 -import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_PREFIX;
   18.37 -import static jdk.nashorn.internal.codegen.CompilerConstants.MAP;
   18.38 -import static jdk.nashorn.internal.codegen.CompilerConstants.className;
   18.39 -import static jdk.nashorn.internal.codegen.CompilerConstants.constructorNoLookup;
   18.40 -import static jdk.nashorn.internal.runtime.linker.Lookup.MH;
   18.41 -
   18.42 -import java.lang.invoke.MethodHandle;
   18.43 -import java.lang.invoke.MethodHandles;
   18.44 -import java.lang.invoke.MethodType;
   18.45 -import java.util.Arrays;
   18.46 -import java.util.Collections;
   18.47 -import java.util.EnumSet;
   18.48 -import java.util.Iterator;
   18.49 -import java.util.LinkedList;
   18.50 -import java.util.List;
   18.51 -import jdk.nashorn.internal.codegen.ClassEmitter;
   18.52 -import jdk.nashorn.internal.codegen.ClassEmitter.Flag;
   18.53 -import jdk.nashorn.internal.codegen.MethodEmitter;
   18.54 -import jdk.nashorn.internal.codegen.types.Type;
   18.55 -import jdk.nashorn.internal.runtime.AccessorProperty;
   18.56 -import jdk.nashorn.internal.runtime.Context;
   18.57 -import jdk.nashorn.internal.runtime.DebugLogger;
   18.58 -import jdk.nashorn.internal.runtime.FunctionScope;
   18.59 -import jdk.nashorn.internal.runtime.JSType;
   18.60 -import jdk.nashorn.internal.runtime.PropertyMap;
   18.61 -import jdk.nashorn.internal.runtime.ScriptObject;
   18.62 -import jdk.nashorn.internal.runtime.ScriptRuntime;
   18.63 -import jdk.nashorn.internal.runtime.options.Options;
   18.64 -
   18.65 -/**
   18.66 - * Generates the ScriptObject subclass structure with fields for a user objects.
   18.67 - */
   18.68 -public final class ObjectClassGenerator {
   18.69 -
   18.70 -    /**
   18.71 -     * Marker for scope parameters.
   18.72 -     */
   18.73 -    public static final String SCOPE_MARKER = "P";
   18.74 -
   18.75 -    /**
   18.76 -     * Debug field logger
   18.77 -     * Should we print debugging information for fields when they are generated and getters/setters are called?
   18.78 -     */
   18.79 -    public static final DebugLogger LOG          = new DebugLogger("fields", "nashorn.fields.debug");
   18.80 -
   18.81 -    /**
   18.82 -     * is field debugging enabled. Several modules in codegen and properties use this, hence
   18.83 -     * public access.
   18.84 -     */
   18.85 -    public static final boolean     DEBUG_FIELDS = LOG.isEnabled();
   18.86 -
   18.87 -    /**
   18.88 -     * Should the runtime only use java.lang.Object slots for fields? If this is false, the representation
   18.89 -     * will be a primitive 64-bit long value used for all primitives and a java.lang.Object for references.
   18.90 -     * This introduces a larger number of method handles in the system, as we need to have different getters
   18.91 -     * and setters for the different fields. Currently this introduces significant overhead in Hotspot.
   18.92 -     *
   18.93 -     * This is engineered to plug into the TaggedArray implementation, when it's done.
   18.94 -     */
   18.95 -    public static final boolean OBJECT_FIELDS_ONLY = !Options.getBooleanProperty("nashorn.fields.dual");
   18.96 -
   18.97 -    /** The field types in the system */
   18.98 -    private static final List<Type> FIELD_TYPES = new LinkedList<>();
   18.99 -
  18.100 -    /** What type is the primitive type in dual representation */
  18.101 -    public static final Type PRIMITIVE_TYPE = Type.LONG;
  18.102 -
  18.103 -    /**
  18.104 -     * The list of field types that we support - one type creates one field. This is currently either
  18.105 -     * LONG + OBJECT or just OBJECT for classic mode.
  18.106 -     */
  18.107 -    static {
  18.108 -        if (!OBJECT_FIELDS_ONLY) {
  18.109 -            System.err.println("WARNING!!! Running with primitive fields - there is untested functionality!");
  18.110 -            FIELD_TYPES.add(PRIMITIVE_TYPE);
  18.111 -        }
  18.112 -        FIELD_TYPES.add(Type.OBJECT);
  18.113 -    }
  18.114 -
  18.115 -    /** The context */
  18.116 -    private final Context context;
  18.117 -
  18.118 -    /**
  18.119 -     * The list of available accessor types in width order. This order is used for type guesses narrow->wide
  18.120 -     *  in the dual--fields world
  18.121 -     */
  18.122 -    public static final List<Type> ACCESSOR_TYPES = Collections.unmodifiableList(
  18.123 -            Arrays.asList(
  18.124 -                Type.INT,
  18.125 -                Type.LONG,
  18.126 -                Type.NUMBER,
  18.127 -                Type.OBJECT));
  18.128 -
  18.129 -    //these are hard coded for speed and so that we can switch on them
  18.130 -    private static final int TYPE_INT_INDEX    = 0; //getAccessorTypeIndex(int.class);
  18.131 -    private static final int TYPE_LONG_INDEX   = 1; //getAccessorTypeIndex(long.class);
  18.132 -    private static final int TYPE_DOUBLE_INDEX = 2; //getAccessorTypeIndex(double.class);
  18.133 -    private static final int TYPE_OBJECT_INDEX = 3; //getAccessorTypeIndex(Object.class);
  18.134 -
  18.135 -    /**
  18.136 -     * Constructor
  18.137 -     *
  18.138 -     * @param context a context
  18.139 -     */
  18.140 -    public ObjectClassGenerator(final Context context) {
  18.141 -        this.context = context;
  18.142 -        assert context != null;
  18.143 -    }
  18.144 -
  18.145 -    /**
  18.146 -     * Given a type of an accessor, return its index in [0..getNumberOfAccessorTypes())
  18.147 -     *
  18.148 -     * @param type the type
  18.149 -     *
  18.150 -     * @return the accessor index, or -1 if no accessor of this type exists
  18.151 -     */
  18.152 -    public static int getAccessorTypeIndex(final Type type) {
  18.153 -        return getAccessorTypeIndex(type.getTypeClass());
  18.154 -    }
  18.155 -
  18.156 -    /**
  18.157 -     * Given a class of an accessor, return its index in [0..getNumberOfAccessorTypes())
  18.158 -     *
  18.159 -     * Note that this is hardcoded with respect to the dynamic contents of the accessor
  18.160 -     * types array for speed. Hotspot got stuck with this as 5% of the runtime in
  18.161 -     * a benchmark when it looped over values and increased an index counter. :-(
  18.162 -     *
  18.163 -     * @param type the type
  18.164 -     *
  18.165 -     * @return the accessor index, or -1 if no accessor of this type exists
  18.166 -     */
  18.167 -    public static int getAccessorTypeIndex(final Class<?> type) {
  18.168 -        if (type == int.class) {
  18.169 -            return 0;
  18.170 -        } else if (type == long.class) {
  18.171 -            return 1;
  18.172 -        } else if (type == double.class) {
  18.173 -            return 2;
  18.174 -        } else if (!type.isPrimitive()) {
  18.175 -            return 3;
  18.176 -        }
  18.177 -        return -1;
  18.178 -    }
  18.179 -
  18.180 -    /**
  18.181 -     * Return the number of accessor types available.
  18.182 -     *
  18.183 -     * @return number of accessor types in system
  18.184 -     */
  18.185 -    public static int getNumberOfAccessorTypes() {
  18.186 -        return ACCESSOR_TYPES.size();
  18.187 -    }
  18.188 -
  18.189 -    /**
  18.190 -     * Return the accessor type based on its index in [0..getNumberOfAccessorTypes())
  18.191 -     * Indexes are ordered narrower->wider / optimistic->pessimistic. Invalidations always
  18.192 -     * go to a type of higher index
  18.193 -     *
  18.194 -     * @param index accessor type index
  18.195 -     *
  18.196 -     * @return a type corresponding to the index.
  18.197 -     */
  18.198 -
  18.199 -    public static Type getAccessorType(final int index) {
  18.200 -        return ACCESSOR_TYPES.get(index);
  18.201 -    }
  18.202 -
  18.203 -    /**
  18.204 -     * Returns the class name for JavaScript objects with fieldCount fields.
  18.205 -     *
  18.206 -     * @param fieldCount Number of fields to allocate.
  18.207 -     *
  18.208 -     * @return The class name.
  18.209 -     */
  18.210 -    public static String getClassName(final int fieldCount) {
  18.211 -        return fieldCount != 0 ? SCRIPTS_PACKAGE + '/' + JS_OBJECT_PREFIX.tag() + fieldCount :
  18.212 -                                 SCRIPTS_PACKAGE + '/' + JS_OBJECT_PREFIX.tag();
  18.213 -    }
  18.214 -
  18.215 -    /**
  18.216 -     * Returns the class name for JavaScript scope with fieldCount fields and
  18.217 -     * paramCount parameters.
  18.218 -     *
  18.219 -     * @param fieldCount Number of fields to allocate.
  18.220 -     * @param paramCount Number of parameters to allocate
  18.221 -     *
  18.222 -     * @return The class name.
  18.223 -     */
  18.224 -    public static String getClassName(final int fieldCount, final int paramCount) {
  18.225 -        return SCRIPTS_PACKAGE + '/' + JS_OBJECT_PREFIX.tag() + fieldCount + SCOPE_MARKER + paramCount;
  18.226 -    }
  18.227 -
  18.228 -    /**
  18.229 -     * Returns the name of a field based on number and type.
  18.230 -     *
  18.231 -     * @param fieldIndex Ordinal of field.
  18.232 -     * @param type       Type of field.
  18.233 -     *
  18.234 -     * @return The field name.
  18.235 -     */
  18.236 -    public static String getFieldName(final int fieldIndex, final Type type) {
  18.237 -        return type.getDescriptor().substring(0, 1) + fieldIndex;
  18.238 -    }
  18.239 -
  18.240 -    /**
  18.241 -     * In the world of Object fields, we also have no undefined SwitchPoint, to reduce as much potential
  18.242 -     * MethodHandle overhead as possible. In that case, we explicitly need to assign undefined to fields
  18.243 -     * when we initialize them.
  18.244 -     *
  18.245 -     * @param init       constructor to generate code in
  18.246 -     * @param className  name of class
  18.247 -     * @param fieldNames fields to initialize to undefined, where applicable
  18.248 -     */
  18.249 -    private static void initializeToUndefined(final MethodEmitter init, final String className, final List<String> fieldNames) {
  18.250 -        if (fieldNames.isEmpty()) {
  18.251 -            return;
  18.252 -        }
  18.253 -
  18.254 -        // always initialize fields to undefined, even with --dual-fields. Then it's ok to
  18.255 -        // remember things like "widest set type" in properties, and if it's object, don't
  18.256 -        // add any special "return undefined" getters, saving an invalidation
  18.257 -        init.load(Type.OBJECT, JAVA_THIS.slot());
  18.258 -        init.loadUndefined(Type.OBJECT);
  18.259 -
  18.260 -        final Iterator<String> iter = fieldNames.iterator();
  18.261 -        while (iter.hasNext()) {
  18.262 -            final String fieldName = iter.next();
  18.263 -            if (iter.hasNext()) {
  18.264 -                init.dup2();
  18.265 -            }
  18.266 -            init.putField(className, fieldName, Type.OBJECT.getDescriptor());
  18.267 -        }
  18.268 -    }
  18.269 -
  18.270 -    /**
  18.271 -     * Generate the byte codes for a JavaScript object class or scope.
  18.272 -     * Class name is a function of number of fields and number of param
  18.273 -     * fields
  18.274 -     *
  18.275 -     * @param descriptor Descriptor pulled from class name.
  18.276 -     *
  18.277 -     * @return Byte codes for generated class.
  18.278 -     */
  18.279 -    public byte[] generate(final String descriptor) {
  18.280 -        final String[] counts     = descriptor.split(SCOPE_MARKER);
  18.281 -        final int      fieldCount = Integer.valueOf(counts[0]);
  18.282 -
  18.283 -        if (counts.length == 1) {
  18.284 -            return generate(fieldCount);
  18.285 -        }
  18.286 -
  18.287 -        final int paramCount = Integer.valueOf(counts[1]);
  18.288 -
  18.289 -        return generate(fieldCount, paramCount);
  18.290 -    }
  18.291 -
  18.292 -    /**
  18.293 -     * Generate the byte codes for a JavaScript object class with fieldCount fields.
  18.294 -     *
  18.295 -     * @param fieldCount Number of fields in the JavaScript object.
  18.296 -     *
  18.297 -     * @return Byte codes for generated class.
  18.298 -     */
  18.299 -    public byte[] generate(final int fieldCount) {
  18.300 -        final String       className    = getClassName(fieldCount);
  18.301 -        final String       superName    = className(ScriptObject.class);
  18.302 -        final ClassEmitter classEmitter = newClassEmitter(className, superName);
  18.303 -        final List<String> initFields   = addFields(classEmitter, fieldCount);
  18.304 -
  18.305 -        final MethodEmitter init = newInitMethod(classEmitter);
  18.306 -        initializeToUndefined(init, className, initFields);
  18.307 -        init.returnVoid();
  18.308 -        init.end();
  18.309 -
  18.310 -        newEmptyInit(classEmitter, className);
  18.311 -        newAllocate(classEmitter, className);
  18.312 -
  18.313 -        return toByteArray(classEmitter);
  18.314 -    }
  18.315 -
  18.316 -    /**
  18.317 -     * Generate the byte codes for a JavaScript scope class with fieldCount fields
  18.318 -     * and paramCount parameters.
  18.319 -     *
  18.320 -     * @param fieldCount Number of fields in the JavaScript scope.
  18.321 -     * @param paramCount Number of parameters in the JavaScript scope
  18.322 -     * .
  18.323 -     * @return Byte codes for generated class.
  18.324 -     */
  18.325 -    public byte[] generate(final int fieldCount, final int paramCount) {
  18.326 -        final String className          = getClassName(fieldCount, paramCount);
  18.327 -        final String superName          = className(FunctionScope.class);
  18.328 -        final ClassEmitter classEmitter = newClassEmitter(className, superName);
  18.329 -        final List<String> initFields   = addFields(classEmitter, fieldCount);
  18.330 -
  18.331 -        final MethodEmitter init = newInitScopeMethod(classEmitter);
  18.332 -        initializeToUndefined(init, className, initFields);
  18.333 -        init.returnVoid();
  18.334 -        init.end();
  18.335 -
  18.336 -        final MethodEmitter initWithArguments = newInitScopeWithArgumentsMethod(classEmitter);
  18.337 -        initializeToUndefined(initWithArguments, className, initFields);
  18.338 -        initWithArguments.returnVoid();
  18.339 -        initWithArguments.end();
  18.340 -
  18.341 -        return toByteArray(classEmitter);
  18.342 -    }
  18.343 -
  18.344 -    /**
  18.345 -     * Generates the needed fields.
  18.346 -     *
  18.347 -     * @param classEmitter Open class emitter.
  18.348 -     * @param fieldCount   Number of fields.
  18.349 -     *
  18.350 -     * @return List fields that need to be initialized.
  18.351 -     */
  18.352 -    private static List<String> addFields(final ClassEmitter classEmitter, final int fieldCount) {
  18.353 -        final List<String> initFields = new LinkedList<>();
  18.354 -
  18.355 -        for (int i = 0; i < fieldCount; i++) {
  18.356 -            for (final Type type : FIELD_TYPES) {
  18.357 -                final String fieldName = getFieldName(i, type);
  18.358 -                classEmitter.field(fieldName, type.getTypeClass());
  18.359 -
  18.360 -                if (type == Type.OBJECT) {
  18.361 -                    initFields.add(fieldName);
  18.362 -                }
  18.363 -            }
  18.364 -        }
  18.365 -
  18.366 -        return initFields;
  18.367 -    }
  18.368 -
  18.369 -    /**
  18.370 -     * Allocate and initialize a new class emitter.
  18.371 -     *
  18.372 -     * @param className Name of JavaScript class.
  18.373 -     *
  18.374 -     * @return Open class emitter.
  18.375 -     */
  18.376 -    private ClassEmitter newClassEmitter(final String className, final String superName) {
  18.377 -        final ClassEmitter classEmitter = new ClassEmitter(context, className, superName);
  18.378 -        classEmitter.begin();
  18.379 -
  18.380 -        return classEmitter;
  18.381 -    }
  18.382 -
  18.383 -    /**
  18.384 -     * Allocate and initialize a new <init> method.
  18.385 -     *
  18.386 -     * @param classEmitter  Open class emitter.
  18.387 -     *
  18.388 -     * @return Open method emitter.
  18.389 -     */
  18.390 -    private static MethodEmitter newInitMethod(final ClassEmitter classEmitter) {
  18.391 -        final MethodEmitter init = classEmitter.init(PropertyMap.class);
  18.392 -        init.begin();
  18.393 -        init.load(Type.OBJECT, JAVA_THIS.slot());
  18.394 -        init.load(Type.OBJECT, MAP.slot());
  18.395 -        init.invoke(constructorNoLookup(ScriptObject.class, PropertyMap.class));
  18.396 -
  18.397 -        return init;
  18.398 -    }
  18.399 -
  18.400 -    /**
  18.401 -     * Allocate and initialize a new <init> method for scopes.
  18.402 -     * @param classEmitter  Open class emitter.
  18.403 -     * @return Open method emitter.
  18.404 -     */
  18.405 -    private static MethodEmitter newInitScopeMethod(final ClassEmitter classEmitter) {
  18.406 -        final MethodEmitter init = classEmitter.init(PropertyMap.class, ScriptObject.class);
  18.407 -        init.begin();
  18.408 -        init.load(Type.OBJECT, JAVA_THIS.slot());
  18.409 -        init.load(Type.OBJECT, MAP.slot());
  18.410 -        init.load(Type.OBJECT, INIT_SCOPE.slot());
  18.411 -        init.invoke(constructorNoLookup(FunctionScope.class, PropertyMap.class, ScriptObject.class));
  18.412 -
  18.413 -        return init;
  18.414 -    }
  18.415 -
  18.416 -    /**
  18.417 -     * Allocate and initialize a new <init> method for scopes with arguments.
  18.418 -     * @param classEmitter  Open class emitter.
  18.419 -     * @return Open method emitter.
  18.420 -     */
  18.421 -    private static MethodEmitter newInitScopeWithArgumentsMethod(final ClassEmitter classEmitter) {
  18.422 -        final MethodEmitter init = classEmitter.init(PropertyMap.class, ScriptObject.class, Object.class);
  18.423 -        init.begin();
  18.424 -        init.load(Type.OBJECT, JAVA_THIS.slot());
  18.425 -        init.load(Type.OBJECT, MAP.slot());
  18.426 -        init.load(Type.OBJECT, INIT_SCOPE.slot());
  18.427 -        init.load(Type.OBJECT, INIT_ARGUMENTS.slot());
  18.428 -        init.invoke(constructorNoLookup(FunctionScope.class, PropertyMap.class, ScriptObject.class, Object.class));
  18.429 -
  18.430 -        return init;
  18.431 -    }
  18.432 -
  18.433 -    /**
  18.434 -     * Add an empty <init> method to the JavaScript class.
  18.435 -     *
  18.436 -     * @param classEmitter Open class emitter.
  18.437 -     * @param className    Name of JavaScript class.
  18.438 -     */
  18.439 -    private static void newEmptyInit(final ClassEmitter classEmitter, final String className) {
  18.440 -        final MethodEmitter emptyInit = classEmitter.init();
  18.441 -        emptyInit.begin();
  18.442 -        emptyInit.load(Type.OBJECT, JAVA_THIS.slot());
  18.443 -        emptyInit.loadNull();
  18.444 -        emptyInit.invoke(constructorNoLookup(className, PropertyMap.class));
  18.445 -        emptyInit.returnVoid();
  18.446 -        emptyInit.end();
  18.447 -    }
  18.448 -
  18.449 -    /**
  18.450 -     * Add an empty <init> method to the JavaScript class.
  18.451 -     *
  18.452 -     * @param classEmitter Open class emitter.
  18.453 -     * @param className    Name of JavaScript class.
  18.454 -     */
  18.455 -    private static void newAllocate(final ClassEmitter classEmitter, final String className) {
  18.456 -        final MethodEmitter allocate = classEmitter.method(EnumSet.of(Flag.PUBLIC, Flag.STATIC), ALLOCATE.tag(), ScriptObject.class, PropertyMap.class);
  18.457 -        allocate.begin();
  18.458 -        allocate._new(className);
  18.459 -        allocate.dup();
  18.460 -        allocate.load(Type.typeFor(PropertyMap.class), 0);
  18.461 -        allocate.invoke(constructorNoLookup(className, PropertyMap.class));
  18.462 -        allocate._return();
  18.463 -        allocate.end();
  18.464 -    }
  18.465 -
  18.466 -    /**
  18.467 -     * Collects the byte codes for a generated JavaScript class.
  18.468 -     *
  18.469 -     * @param classEmitter Open class emitter.
  18.470 -     * @return Byte codes for the class.
  18.471 -     */
  18.472 -    private byte[] toByteArray(final ClassEmitter classEmitter) {
  18.473 -        classEmitter.end();
  18.474 -
  18.475 -        final byte[] code = classEmitter.toByteArray();
  18.476 -
  18.477 -        if (context != null && context._print_code) {
  18.478 -            Context.getCurrentErr().println(ClassEmitter.disassemble(code));
  18.479 -        }
  18.480 -
  18.481 -        if (context != null && context._verify_code) {
  18.482 -            context.verify(code);
  18.483 -        }
  18.484 -
  18.485 -        return code;
  18.486 -    }
  18.487 -
  18.488 -    /** Double to long bits, used with --dual-fields for primitive double values */
  18.489 -    private static final MethodHandle PACK_DOUBLE =
  18.490 -        MH.explicitCastArguments(MH.findStatic(MethodHandles.publicLookup(), Double.class, "doubleToRawLongBits", MH.type(long.class, double.class)), MH.type(long.class, double.class));
  18.491 -
  18.492 -    /** double bits to long, used with --dual-fields for primitive double values */
  18.493 -    private static MethodHandle UNPACK_DOUBLE =
  18.494 -        MH.findStatic(MethodHandles.publicLookup(), Double.class, "longBitsToDouble", MH.type(double.class, long.class));
  18.495 -
  18.496 -    /** object conversion quickies with JS semantics - used for return value and parameter filter */
  18.497 -    private static MethodHandle[] CONVERT_OBJECT = {
  18.498 -        JSType.TO_INT32.methodHandle(),
  18.499 -        JSType.TO_UINT32.methodHandle(),
  18.500 -        JSType.TO_NUMBER.methodHandle(),
  18.501 -        null
  18.502 -    };
  18.503 -
  18.504 -    /**
  18.505 -     * Given a primitiveGetter (optional for non dual fields) and an objectSetter that retrieve
  18.506 -     * the primitive and object version of a field respectively, return one with the correct
  18.507 -     * method type and the correct filters. For example, if the value is stored as a double
  18.508 -     * and we want an Object getter, in the dual fields world we'd pick the primitiveGetter,
  18.509 -     * which reads a long, use longBitsToDouble on the result to unpack it, and then change the
  18.510 -     * return type to Object, boxing it. In the objects only world there are only object fields,
  18.511 -     * primtives are boxed when asked for them and we don't need to bother with primitive encoding
  18.512 -     * (or even undefined, which if forType==null) representation, so we just return whatever is
  18.513 -     * in the object field. The object field is always initiated to Undefined, so here, where we have
  18.514 -     * the representation for Undefined in all our bits, this is not a problem.
  18.515 -     * <p>
  18.516 -     * Representing undefined in a primitive is hard, for an int there aren't enough bits, for a long
  18.517 -     * we could limit the width of a representation, and for a double (as long as it is stored as long,
  18.518 -     * as all NaNs will turn into QNaN on ia32, which is one bit pattern, we should use a special NaN).
  18.519 -     * Naturally we could have special undefined values for all types which mean "go look in a wider field",
  18.520 -     * but the guards needed on every getter took too much time.
  18.521 -     * <p>
  18.522 -     * To see how this is used, look for example in {@link AccessorProperty#getGetter}
  18.523 -     * <p>
  18.524 -     * @param forType         representation of the underlying type in the field, null if undefined
  18.525 -     * @param type            type to retrieve it as
  18.526 -     * @param primitiveGetter getter to read the primitive version of this field (null if Objects Only)
  18.527 -     * @param objectGetter    getter to read the object version of this field
  18.528 -     *
  18.529 -     * @return getter for the given representation that returns the given type
  18.530 -     */
  18.531 -    public static MethodHandle createGetter(final Class<?> forType, final Class<?> type, final MethodHandle primitiveGetter, final MethodHandle objectGetter) {
  18.532 -        final int fti = forType == null ? -1 : getAccessorTypeIndex(forType);
  18.533 -        final int ti  = getAccessorTypeIndex(type);
  18.534 -
  18.535 -        if (fti == TYPE_OBJECT_INDEX || OBJECT_FIELDS_ONLY) {
  18.536 -            if (ti == TYPE_OBJECT_INDEX) {
  18.537 -                return objectGetter;
  18.538 -            }
  18.539 -
  18.540 -            return MH.filterReturnValue(objectGetter, CONVERT_OBJECT[ti]);
  18.541 -        }
  18.542 -
  18.543 -        assert !OBJECT_FIELDS_ONLY;
  18.544 -        if (forType == null) {
  18.545 -            return GET_UNDEFINED[ti];
  18.546 -        }
  18.547 -
  18.548 -        final MethodType pmt = primitiveGetter.type();
  18.549 -
  18.550 -        switch (fti) {
  18.551 -        case TYPE_INT_INDEX:
  18.552 -        case TYPE_LONG_INDEX:
  18.553 -            switch (ti) {
  18.554 -            case TYPE_INT_INDEX:
  18.555 -                //get int while an int, truncating cast of long value
  18.556 -                return MH.explicitCastArguments(primitiveGetter, pmt.changeReturnType(int.class));
  18.557 -            case TYPE_LONG_INDEX:
  18.558 -                return primitiveGetter;
  18.559 -            default:
  18.560 -                return MH.asType(primitiveGetter, pmt.changeReturnType(type));
  18.561 -            }
  18.562 -        case TYPE_DOUBLE_INDEX:
  18.563 -            final MethodHandle getPrimitiveAsDouble = MH.filterReturnValue(primitiveGetter, UNPACK_DOUBLE);
  18.564 -            switch (ti) {
  18.565 -            case TYPE_INT_INDEX:
  18.566 -            case TYPE_LONG_INDEX:
  18.567 -                return MH.explicitCastArguments(getPrimitiveAsDouble, pmt.changeReturnType(type));
  18.568 -            case TYPE_DOUBLE_INDEX:
  18.569 -                return getPrimitiveAsDouble;
  18.570 -            default:
  18.571 -                return MH.asType(getPrimitiveAsDouble, pmt.changeReturnType(Object.class));
  18.572 -            }
  18.573 -        default:
  18.574 -            assert false;
  18.575 -            return null;
  18.576 -        }
  18.577 -    }
  18.578 -
  18.579 -    private static final MethodHandle IS_TYPE_GUARD = findOwnMH("isType", boolean.class, Class.class, Object.class);
  18.580 -
  18.581 -    @SuppressWarnings("unused")
  18.582 -    private static boolean isType(final Class<?> boxedForType, final Object x) {
  18.583 -        return x.getClass() == boxedForType;
  18.584 -    }
  18.585 -
  18.586 -    private static Class<? extends Number> getBoxedType(final Class<?> forType) {
  18.587 -        if (forType == int.class) {
  18.588 -            return Integer.class;
  18.589 -        }
  18.590 -
  18.591 -        if (forType == long.class) {
  18.592 -            return Long.class;
  18.593 -        }
  18.594 -
  18.595 -        if (forType == double.class) {
  18.596 -            return Double.class;
  18.597 -        }
  18.598 -
  18.599 -        assert false;
  18.600 -        return null;
  18.601 -    }
  18.602 -
  18.603 -    /**
  18.604 -     * If we are setting boxed types (because the compiler couldn't determine which they were) to
  18.605 -     * a primitive field, we can reuse the primitive field getter, as long as we are setting an element
  18.606 -     * of the same boxed type as the primitive type representation
  18.607 -     *
  18.608 -     * @param forType           the current type
  18.609 -     * @param primitiveSetter   primitive setter for the current type with an element of the current type
  18.610 -     * @param objectSetter      the object setter
  18.611 -     *
  18.612 -     * @return method handle that checks if the element to be set is of the currenttype, even though it's boxed
  18.613 -     *  and instead of using the generic object setter, that would blow up the type and invalidate the map,
  18.614 -     *  unbox it and call the primitive setter instead
  18.615 -     */
  18.616 -    public static MethodHandle createGuardBoxedPrimitiveSetter(final Class<?> forType, final MethodHandle primitiveSetter, final MethodHandle objectSetter) {
  18.617 -        final Class<? extends Number> boxedForType = getBoxedType(forType);
  18.618 -        //object setter that checks for primitive if current type is primitive
  18.619 -
  18.620 -        return MH.guardWithTest(
  18.621 -            MH.insertArguments(
  18.622 -                MH.dropArguments(
  18.623 -                    IS_TYPE_GUARD,
  18.624 -                    1,
  18.625 -                    Object.class),
  18.626 -                0,
  18.627 -                boxedForType),
  18.628 -                MH.asType(
  18.629 -                    primitiveSetter,
  18.630 -                    objectSetter.type()),
  18.631 -                objectSetter);
  18.632 -    }
  18.633 -
  18.634 -    /**
  18.635 -     * This is similar to the {@link ObjectClassGenerator#createGetter} function. Performs
  18.636 -     * the necessary operations to massage a setter operand of type {@code type} to
  18.637 -     * fit into the primitive field (if primitive and dual fields is enabled) or into
  18.638 -     * the object field (box if primitive and dual fields is disabled)
  18.639 -     *
  18.640 -     * @param forType         representation of the underlying object
  18.641 -     * @param type            representation of field to write, and setter signature
  18.642 -     * @param primitiveSetter setter that writes to the primitive field (null if Objects Only)
  18.643 -     * @param objectSetter    setter that writes to the object field
  18.644 -     *
  18.645 -     * @return the setter for the given representation that takes a {@code type}
  18.646 -     */
  18.647 -    public static MethodHandle createSetter(final Class<?> forType, final Class<?> type, final MethodHandle primitiveSetter, final MethodHandle objectSetter) {
  18.648 -        assert forType != null;
  18.649 -
  18.650 -        final int fti = getAccessorTypeIndex(forType);
  18.651 -        final int ti  = getAccessorTypeIndex(type);
  18.652 -
  18.653 -        if (fti == TYPE_OBJECT_INDEX || OBJECT_FIELDS_ONLY) {
  18.654 -            if (ti == TYPE_OBJECT_INDEX) {
  18.655 -                return objectSetter;
  18.656 -            }
  18.657 -
  18.658 -            return MH.asType(objectSetter, objectSetter.type().changeParameterType(1, type));
  18.659 -        }
  18.660 -
  18.661 -        assert !OBJECT_FIELDS_ONLY;
  18.662 -
  18.663 -        final MethodType pmt = primitiveSetter.type();
  18.664 -
  18.665 -        switch (fti) {
  18.666 -        case TYPE_INT_INDEX:
  18.667 -        case TYPE_LONG_INDEX:
  18.668 -            switch (ti) {
  18.669 -            case TYPE_INT_INDEX:
  18.670 -                return MH.asType(primitiveSetter, pmt.changeParameterType(1, int.class));
  18.671 -            case TYPE_LONG_INDEX:
  18.672 -                return primitiveSetter;
  18.673 -            case TYPE_DOUBLE_INDEX:
  18.674 -                return MH.filterArguments(primitiveSetter, 1, PACK_DOUBLE);
  18.675 -            default:
  18.676 -                return objectSetter;
  18.677 -            }
  18.678 -        case TYPE_DOUBLE_INDEX:
  18.679 -            if (ti == TYPE_OBJECT_INDEX) {
  18.680 -                return objectSetter;
  18.681 -            }
  18.682 -            return MH.asType(MH.filterArguments(primitiveSetter, 1, PACK_DOUBLE), pmt.changeParameterType(1, type));
  18.683 -        default:
  18.684 -            assert false;
  18.685 -            return null;
  18.686 -        }
  18.687 -    }
  18.688 -
  18.689 -    //
  18.690 -    // Provide generic getters and setters for undefined types. If a type is undefined, all
  18.691 -    // and marshals the set to the correct setter depending on the type of the value being set.
  18.692 -    // Note that there are no actual undefined versions of int, long and double in JavaScript,
  18.693 -    // but executing toInt32, toLong and toNumber always returns a working result, 0, 0L or NaN
  18.694 -    //
  18.695 -
  18.696 -    /** The value of Undefined cast to an int32 */
  18.697 -    public static final int    UNDEFINED_INT    = 0;
  18.698 -    /** The value of Undefined cast to a long */
  18.699 -    public static final long   UNDEFINED_LONG   = 0L;
  18.700 -    /** The value of Undefined cast to a double */
  18.701 -    public static final double UNDEFINED_DOUBLE = Double.NaN;
  18.702 -
  18.703 -    /**
  18.704 -     * Compute type name for correct undefined getter
  18.705 -     * @param type the type
  18.706 -     * @return name of getter
  18.707 -     */
  18.708 -    private static String typeName(final Type type) {
  18.709 -        String name = type.getTypeClass().getName();
  18.710 -        final int dot = name.lastIndexOf('.');
  18.711 -        if (dot != -1) {
  18.712 -            name = name.substring(dot + 1);
  18.713 -        }
  18.714 -        return Character.toUpperCase(name.charAt(0)) + name.substring(1);
  18.715 -    }
  18.716 -
  18.717 -    /**
  18.718 -     * Handles for undefined getters of the different types
  18.719 -     */
  18.720 -    private static final MethodHandle[] GET_UNDEFINED = new MethodHandle[ObjectClassGenerator.getNumberOfAccessorTypes()];
  18.721 -
  18.722 -    /**
  18.723 -     * Used to wrap getters for undefined values, where this matters. Currently only in dual fields.
  18.724 -     * If an object starts out as undefined it needs special getters until it has been assigned
  18.725 -     * something the first time
  18.726 -     *
  18.727 -     * @param returnType type to cast the undefined to
  18.728 -     *
  18.729 -     * @return undefined as returnType
  18.730 -     */
  18.731 -    public static MethodHandle getUndefined(final Class<?> returnType) {
  18.732 -        return GET_UNDEFINED[ObjectClassGenerator.getAccessorTypeIndex(returnType)];
  18.733 -    }
  18.734 -
  18.735 -    static {
  18.736 -        int pos = 0;
  18.737 -        for (final Type type : ACCESSOR_TYPES) {
  18.738 -            GET_UNDEFINED[pos++] = findOwnMH("getUndefined" + typeName(type), type.getTypeClass(), Object.class);
  18.739 -        }
  18.740 -    }
  18.741 -
  18.742 -    @SuppressWarnings("unused")
  18.743 -    private static int getUndefinedInt(final Object obj) {
  18.744 -        return UNDEFINED_INT;
  18.745 -    }
  18.746 -
  18.747 -    @SuppressWarnings("unused")
  18.748 -    private static long getUndefinedLong(final Object obj) {
  18.749 -        return UNDEFINED_LONG;
  18.750 -    }
  18.751 -
  18.752 -    @SuppressWarnings("unused")
  18.753 -    private static double getUndefinedDouble(final Object obj) {
  18.754 -        return UNDEFINED_DOUBLE;
  18.755 -    }
  18.756 -
  18.757 -    @SuppressWarnings("unused")
  18.758 -    private static Object getUndefinedObject(final Object obj) {
  18.759 -        return ScriptRuntime.UNDEFINED;
  18.760 -    }
  18.761 -
  18.762 -    private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
  18.763 -        return MH.findStatic(MethodHandles.lookup(), ObjectClassGenerator.class, name, MH.type(rtype, types));
  18.764 -    }
  18.765 -}
    19.1 --- a/src/jdk/nashorn/internal/codegen/objects/ObjectCreator.java	Fri Feb 15 09:18:05 2013 +0100
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,176 +0,0 @@
    19.4 -/*
    19.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    19.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.7 - *
    19.8 - * This code is free software; you can redistribute it and/or modify it
    19.9 - * under the terms of the GNU General Public License version 2 only, as
   19.10 - * published by the Free Software Foundation.  Oracle designates this
   19.11 - * particular file as subject to the "Classpath" exception as provided
   19.12 - * by Oracle in the LICENSE file that accompanied this code.
   19.13 - *
   19.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   19.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   19.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   19.17 - * version 2 for more details (a copy is included in the LICENSE file that
   19.18 - * accompanied this code).
   19.19 - *
   19.20 - * You should have received a copy of the GNU General Public License version
   19.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   19.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   19.23 - *
   19.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   19.25 - * or visit www.oracle.com if you need additional information or have any
   19.26 - * questions.
   19.27 - */
   19.28 -
   19.29 -package jdk.nashorn.internal.codegen.objects;
   19.30 -
   19.31 -import java.util.List;
   19.32 -import jdk.nashorn.internal.codegen.CodeGenerator;
   19.33 -import jdk.nashorn.internal.codegen.CompileUnit;
   19.34 -import jdk.nashorn.internal.codegen.Compiler;
   19.35 -import jdk.nashorn.internal.codegen.MethodEmitter;
   19.36 -import jdk.nashorn.internal.ir.Symbol;
   19.37 -import jdk.nashorn.internal.runtime.Context;
   19.38 -import jdk.nashorn.internal.runtime.PropertyMap;
   19.39 -
   19.40 -/**
   19.41 - * Base class for object creation code generation.
   19.42 - */
   19.43 -public abstract class ObjectCreator {
   19.44 -
   19.45 -    /** Compile unit for this ObjectCreator, see CompileUnit */
   19.46 -    protected final CompileUnit   compileUnit;
   19.47 -
   19.48 -    /** List of keys to initiate in this ObjectCreator */
   19.49 -    protected final List<String>  keys;
   19.50 -
   19.51 -    /** List of symbols to initiate in this ObjectCreator */
   19.52 -    protected final List<Symbol>  symbols;
   19.53 -
   19.54 -    /** Code generator */
   19.55 -    protected final CodeGenerator codegen;
   19.56 -
   19.57 -    private   final boolean       isScope;
   19.58 -    private   final boolean       hasArguments;
   19.59 -    private         int           fieldCount;
   19.60 -    private         int           paramCount;
   19.61 -    private         String        fieldObjectClassName;
   19.62 -    private         Class<?>      fieldObjectClass;
   19.63 -    private         PropertyMap   propertyMap;
   19.64 -
   19.65 -    /**
   19.66 -     * Constructor
   19.67 -     *
   19.68 -     * @param codegen      the code generator
   19.69 -     * @param keys         the keys
   19.70 -     * @param symbols      the symbols corresponding to keys, same index
   19.71 -     * @param isScope      is this object scope
   19.72 -     * @param hasArguments does the created object have an "arguments" property
   19.73 -     */
   19.74 -    protected ObjectCreator(final CodeGenerator codegen, final List<String> keys, final List<Symbol> symbols, final boolean isScope, final boolean hasArguments) {
   19.75 -        this.codegen       = codegen;
   19.76 -        this.compileUnit   = codegen.getCurrentCompileUnit();
   19.77 -        this.keys          = keys;
   19.78 -        this.symbols       = symbols;
   19.79 -        this.isScope       = isScope;
   19.80 -        this.hasArguments  = hasArguments;
   19.81 -
   19.82 -        countFields();
   19.83 -        findClass();
   19.84 -    }
   19.85 -
   19.86 -    /**
   19.87 -     * Tally the number of fields and parameters.
   19.88 -     */
   19.89 -    private void countFields() {
   19.90 -        for (final Symbol symbol : this.symbols) {
   19.91 -            if (symbol != null) {
   19.92 -                if (hasArguments() && symbol.isParam()) {
   19.93 -                    symbol.setFieldIndex(paramCount++);
   19.94 -                } else {
   19.95 -                    symbol.setFieldIndex(fieldCount++);
   19.96 -                }
   19.97 -            }
   19.98 -        }
   19.99 -    }
  19.100 -
  19.101 -    /**
  19.102 -     * Locate (or indirectly create) the object container class.
  19.103 -     */
  19.104 -    private void findClass() {
  19.105 -        fieldObjectClassName = isScope() ?
  19.106 -            ObjectClassGenerator.getClassName(fieldCount, paramCount) :
  19.107 -            ObjectClassGenerator.getClassName(fieldCount);
  19.108 -
  19.109 -        try {
  19.110 -            this.fieldObjectClass = Context.forStructureClass(Compiler.binaryName(fieldObjectClassName));
  19.111 -        } catch (final ClassNotFoundException e) {
  19.112 -            throw new AssertionError("Nashorn has encountered an internal error.  Structure can not be created.");
  19.113 -        }
  19.114 -    }
  19.115 -
  19.116 -    /**
  19.117 -     * Generate code for making the object.
  19.118 -     * @param method Script method.
  19.119 -     */
  19.120 -    public abstract void makeObject(final MethodEmitter method);
  19.121 -
  19.122 -    /**
  19.123 -     * Create a new MapCreator
  19.124 -     * @param clazz type of MapCreator
  19.125 -     * @return map creator instantiated by type
  19.126 -     */
  19.127 -    protected MapCreator newMapCreator(final Class<?> clazz) {
  19.128 -        return new MapCreator(clazz, keys, symbols);
  19.129 -    }
  19.130 -
  19.131 -    /**
  19.132 -     * Construct the property map appropriate for the object.
  19.133 -     * @return the newly created property map
  19.134 -     */
  19.135 -    protected PropertyMap makeMap() {
  19.136 -        if (keys.isEmpty()) { //empty map
  19.137 -            propertyMap = PropertyMap.newMap(fieldObjectClass);
  19.138 -        } else {
  19.139 -            propertyMap = newMapCreator(fieldObjectClass).makeMap(hasArguments());
  19.140 -        }
  19.141 -        return propertyMap;
  19.142 -    }
  19.143 -
  19.144 -    /**
  19.145 -     * Emit the correct map for the object.
  19.146 -     * @param method method emitter
  19.147 -     * @return the method emitter
  19.148 -     */
  19.149 -    protected MethodEmitter loadMap(final MethodEmitter method) {
  19.150 -        codegen.loadConstant(propertyMap);
  19.151 -        return method;
  19.152 -    }
  19.153 -
  19.154 -    /**
  19.155 -     * Get the class name for the object class,
  19.156 -     * e.g. {@code com.nashorn.oracle.scripts.JO$2P0}
  19.157 -     *
  19.158 -     * @return script class name
  19.159 -     */
  19.160 -    public String getClassName() {
  19.161 -        return fieldObjectClassName;
  19.162 -    }
  19.163 -
  19.164 -    /**
  19.165 -     * Is this a scope object
  19.166 -     * @return true if scope
  19.167 -     */
  19.168 -    protected boolean isScope() {
  19.169 -        return isScope;
  19.170 -    }
  19.171 -
  19.172 -    /**
  19.173 -     * Does the created object have an "arguments" property
  19.174 -     * @return true if has an "arguments" property
  19.175 -     */
  19.176 -    protected boolean hasArguments() {
  19.177 -        return hasArguments;
  19.178 -    }
  19.179 -}
    20.1 --- a/src/jdk/nashorn/internal/codegen/objects/ObjectMapCreator.java	Fri Feb 15 09:18:05 2013 +0100
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,54 +0,0 @@
    20.4 -/*
    20.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    20.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.7 - *
    20.8 - * This code is free software; you can redistribute it and/or modify it
    20.9 - * under the terms of the GNU General Public License version 2 only, as
   20.10 - * published by the Free Software Foundation.  Oracle designates this
   20.11 - * particular file as subject to the "Classpath" exception as provided
   20.12 - * by Oracle in the LICENSE file that accompanied this code.
   20.13 - *
   20.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   20.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   20.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   20.17 - * version 2 for more details (a copy is included in the LICENSE file that
   20.18 - * accompanied this code).
   20.19 - *
   20.20 - * You should have received a copy of the GNU General Public License version
   20.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   20.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20.23 - *
   20.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   20.25 - * or visit www.oracle.com if you need additional information or have any
   20.26 - * questions.
   20.27 - */
   20.28 -
   20.29 -package jdk.nashorn.internal.codegen.objects;
   20.30 -
   20.31 -import java.util.List;
   20.32 -import jdk.nashorn.internal.ir.Symbol;
   20.33 -import jdk.nashorn.internal.runtime.Property;
   20.34 -
   20.35 -/**
   20.36 - * This map creator is used to guarantee that all properties start out as
   20.37 - * object types. Only semantically significant in the -Dnashorn.fields.dual=true world,
   20.38 - * where we want to avoid invalidation upon initialization e.g. for var x = {a:"str"};
   20.39 - */
   20.40 -
   20.41 -public class ObjectMapCreator extends MapCreator {
   20.42 -    /**
   20.43 -     * Constructor
   20.44 -     *
   20.45 -     * @param structure structure for object class
   20.46 -     * @param keys      keys in object
   20.47 -     * @param symbols   symbols in object corresponding to keys
   20.48 -     */
   20.49 -    public ObjectMapCreator(final Class<?> structure, final List<String> keys, final List<Symbol> symbols) {
   20.50 -        super(structure, keys, symbols);
   20.51 -    }
   20.52 -
   20.53 -    @Override
   20.54 -    protected int getPropertyFlags(final Symbol symbol, final boolean isVarArg) {
   20.55 -        return super.getPropertyFlags(symbol, isVarArg) | Property.IS_ALWAYS_OBJECT;
   20.56 -    }
   20.57 -}
    21.1 --- a/src/jdk/nashorn/internal/codegen/types/BooleanType.java	Fri Feb 15 09:18:05 2013 +0100
    21.2 +++ b/src/jdk/nashorn/internal/codegen/types/BooleanType.java	Fri Feb 15 09:44:15 2013 +0100
    21.3 @@ -59,7 +59,7 @@
    21.4  
    21.5  import jdk.internal.org.objectweb.asm.MethodVisitor;
    21.6  import jdk.nashorn.internal.codegen.CompilerConstants;
    21.7 -import jdk.nashorn.internal.codegen.objects.ObjectClassGenerator;
    21.8 +import jdk.nashorn.internal.codegen.ObjectClassGenerator;
    21.9  import jdk.nashorn.internal.runtime.JSType;
   21.10  
   21.11  /**
    22.1 --- a/src/jdk/nashorn/internal/codegen/types/IntType.java	Fri Feb 15 09:18:05 2013 +0100
    22.2 +++ b/src/jdk/nashorn/internal/codegen/types/IntType.java	Fri Feb 15 09:44:15 2013 +0100
    22.3 @@ -55,7 +55,7 @@
    22.4  
    22.5  import jdk.internal.org.objectweb.asm.MethodVisitor;
    22.6  import jdk.nashorn.internal.codegen.CompilerConstants;
    22.7 -import jdk.nashorn.internal.codegen.objects.ObjectClassGenerator;
    22.8 +import jdk.nashorn.internal.codegen.ObjectClassGenerator;
    22.9  
   22.10  /**
   22.11   * Type class: INT
    23.1 --- a/src/jdk/nashorn/internal/codegen/types/LongType.java	Fri Feb 15 09:18:05 2013 +0100
    23.2 +++ b/src/jdk/nashorn/internal/codegen/types/LongType.java	Fri Feb 15 09:44:15 2013 +0100
    23.3 @@ -49,7 +49,7 @@
    23.4  
    23.5  import jdk.internal.org.objectweb.asm.MethodVisitor;
    23.6  import jdk.nashorn.internal.codegen.CompilerConstants;
    23.7 -import jdk.nashorn.internal.codegen.objects.ObjectClassGenerator;
    23.8 +import jdk.nashorn.internal.codegen.ObjectClassGenerator;
    23.9  
   23.10  /**
   23.11   * Type class: LONG
    24.1 --- a/src/jdk/nashorn/internal/codegen/types/NumberType.java	Fri Feb 15 09:18:05 2013 +0100
    24.2 +++ b/src/jdk/nashorn/internal/codegen/types/NumberType.java	Fri Feb 15 09:44:15 2013 +0100
    24.3 @@ -42,7 +42,7 @@
    24.4  
    24.5  import jdk.internal.org.objectweb.asm.MethodVisitor;
    24.6  import jdk.nashorn.internal.codegen.CompilerConstants;
    24.7 -import jdk.nashorn.internal.codegen.objects.ObjectClassGenerator;
    24.8 +import jdk.nashorn.internal.codegen.ObjectClassGenerator;
    24.9  import jdk.nashorn.internal.runtime.JSType;
   24.10  
   24.11  class NumberType extends NumericType {
    25.1 --- a/src/jdk/nashorn/internal/ir/AccessNode.java	Fri Feb 15 09:18:05 2013 +0100
    25.2 +++ b/src/jdk/nashorn/internal/ir/AccessNode.java	Fri Feb 15 09:44:15 2013 +0100
    25.3 @@ -25,9 +25,9 @@
    25.4  
    25.5  package jdk.nashorn.internal.ir;
    25.6  
    25.7 -import static jdk.nashorn.internal.codegen.objects.ObjectClassGenerator.DEBUG_FIELDS;
    25.8 +import static jdk.nashorn.internal.codegen.ObjectClassGenerator.DEBUG_FIELDS;
    25.9  
   25.10 -import jdk.nashorn.internal.codegen.objects.ObjectClassGenerator;
   25.11 +import jdk.nashorn.internal.codegen.ObjectClassGenerator;
   25.12  import jdk.nashorn.internal.codegen.types.Type;
   25.13  import jdk.nashorn.internal.ir.visitor.NodeVisitor;
   25.14  import jdk.nashorn.internal.runtime.Source;
    26.1 --- a/src/jdk/nashorn/internal/ir/BaseNode.java	Fri Feb 15 09:18:05 2013 +0100
    26.2 +++ b/src/jdk/nashorn/internal/ir/BaseNode.java	Fri Feb 15 09:44:15 2013 +0100
    26.3 @@ -60,7 +60,7 @@
    26.4       */
    26.5      protected BaseNode(final BaseNode baseNode, final CopyState cs) {
    26.6          super(baseNode);
    26.7 -        base = cs.existingOrCopy(baseNode.getBase());
    26.8 +        this.base = cs.existingOrCopy(baseNode.getBase());
    26.9          setStart(base.getStart());
   26.10      }
   26.11  
    27.1 --- a/src/jdk/nashorn/internal/ir/Block.java	Fri Feb 15 09:18:05 2013 +0100
    27.2 +++ b/src/jdk/nashorn/internal/ir/Block.java	Fri Feb 15 09:44:15 2013 +0100
    27.3 @@ -40,7 +40,7 @@
    27.4  import java.util.HashMap;
    27.5  import java.util.List;
    27.6  import jdk.nashorn.internal.codegen.Frame;
    27.7 -import jdk.nashorn.internal.codegen.MethodEmitter.Label;
    27.8 +import jdk.nashorn.internal.codegen.Label;
    27.9  import jdk.nashorn.internal.ir.annotations.Ignore;
   27.10  import jdk.nashorn.internal.ir.annotations.ParentNode;
   27.11  import jdk.nashorn.internal.ir.visitor.NodeVisitor;
   27.12 @@ -94,7 +94,6 @@
   27.13          this.function   = function;
   27.14          this.statements = new ArrayList<>();
   27.15          this.symbols    = new HashMap<>();
   27.16 -        this.frame      = null;
   27.17          this.entryLabel = new Label("block_entry");
   27.18          this.breakLabel = new Label("block_break");
   27.19      }
   27.20 @@ -108,16 +107,16 @@
   27.21      protected Block(final Block block, final CopyState cs) {
   27.22          super(block);
   27.23  
   27.24 -        parent     = block.parent;
   27.25 -        function   = block.function;
   27.26 -        statements = new ArrayList<>();
   27.27 +        this.parent     = block.parent;
   27.28 +        this.function   = block.function;
   27.29 +        this.statements = new ArrayList<>();
   27.30          for (final Node statement : block.getStatements()) {
   27.31              statements.add(cs.existingOrCopy(statement));
   27.32          }
   27.33 -        symbols    = new HashMap<>();
   27.34 -        frame      = block.frame == null ? null : block.frame.copy();
   27.35 -        entryLabel = new Label(block.entryLabel);
   27.36 -        breakLabel = new Label(block.breakLabel);
   27.37 +        this.symbols    = new HashMap<>();
   27.38 +        this.frame      = block.frame == null ? null : block.frame.copy();
   27.39 +        this.entryLabel = new Label(block.entryLabel);
   27.40 +        this.breakLabel = new Label(block.breakLabel);
   27.41  
   27.42          assert block.symbols.isEmpty() : "must not clone with symbols";
   27.43      }
    28.1 --- a/src/jdk/nashorn/internal/ir/BreakNode.java	Fri Feb 15 09:18:05 2013 +0100
    28.2 +++ b/src/jdk/nashorn/internal/ir/BreakNode.java	Fri Feb 15 09:44:15 2013 +0100
    28.3 @@ -25,7 +25,7 @@
    28.4  
    28.5  package jdk.nashorn.internal.ir;
    28.6  
    28.7 -import jdk.nashorn.internal.codegen.MethodEmitter;
    28.8 +import jdk.nashorn.internal.codegen.Label;
    28.9  import jdk.nashorn.internal.ir.visitor.NodeVisitor;
   28.10  import jdk.nashorn.internal.runtime.Source;
   28.11  
   28.12 @@ -75,7 +75,7 @@
   28.13       * Return the target label of this break node.
   28.14       * @return the target label.
   28.15       */
   28.16 -    public MethodEmitter.Label getTargetLabel() {
   28.17 +    public Label getTargetLabel() {
   28.18          if (targetNode instanceof BreakableNode) {
   28.19              return ((BreakableNode)targetNode).getBreakLabel();
   28.20          } else if (targetNode instanceof Block) {
    29.1 --- a/src/jdk/nashorn/internal/ir/BreakableNode.java	Fri Feb 15 09:18:05 2013 +0100
    29.2 +++ b/src/jdk/nashorn/internal/ir/BreakableNode.java	Fri Feb 15 09:44:15 2013 +0100
    29.3 @@ -25,7 +25,7 @@
    29.4  
    29.5  package jdk.nashorn.internal.ir;
    29.6  
    29.7 -import jdk.nashorn.internal.codegen.MethodEmitter;
    29.8 +import jdk.nashorn.internal.codegen.Label;
    29.9  import jdk.nashorn.internal.runtime.Source;
   29.10  
   29.11  /**
   29.12 @@ -35,7 +35,7 @@
   29.13  public abstract class BreakableNode extends Node {
   29.14  
   29.15      /** break label. */
   29.16 -    protected MethodEmitter.Label breakLabel;
   29.17 +    protected Label breakLabel;
   29.18  
   29.19      /**
   29.20       * Constructor
   29.21 @@ -61,7 +61,7 @@
   29.22       * Return the break label, i.e. the location to go to on break.
   29.23       * @return the break label
   29.24       */
   29.25 -    public MethodEmitter.Label getBreakLabel() {
   29.26 +    public Label getBreakLabel() {
   29.27          return breakLabel;
   29.28      }
   29.29  
    30.1 --- a/src/jdk/nashorn/internal/ir/CallNode.java	Fri Feb 15 09:18:05 2013 +0100
    30.2 +++ b/src/jdk/nashorn/internal/ir/CallNode.java	Fri Feb 15 09:44:15 2013 +0100
    30.3 @@ -164,10 +164,10 @@
    30.4              newArgs.add(cs.existingOrCopy(arg));
    30.5          }
    30.6  
    30.7 -        function     = cs.existingOrCopy(callNode.function);     //TODO existing or same?
    30.8 -        args         = newArgs;
    30.9 -        isNew        = callNode.isNew;
   30.10 -        inWithBlock  = callNode.inWithBlock;
   30.11 +        this.function     = cs.existingOrCopy(callNode.function);     //TODO existing or same?
   30.12 +        this.args         = newArgs;
   30.13 +        this.isNew        = callNode.isNew;
   30.14 +        this.inWithBlock  = callNode.inWithBlock;
   30.15      }
   30.16  
   30.17  
    31.1 --- a/src/jdk/nashorn/internal/ir/CaseNode.java	Fri Feb 15 09:18:05 2013 +0100
    31.2 +++ b/src/jdk/nashorn/internal/ir/CaseNode.java	Fri Feb 15 09:44:15 2013 +0100
    31.3 @@ -25,7 +25,7 @@
    31.4  
    31.5  package jdk.nashorn.internal.ir;
    31.6  
    31.7 -import jdk.nashorn.internal.codegen.MethodEmitter.Label;
    31.8 +import jdk.nashorn.internal.codegen.Label;
    31.9  import jdk.nashorn.internal.ir.visitor.NodeVisitor;
   31.10  import jdk.nashorn.internal.runtime.Source;
   31.11  
    32.1 --- a/src/jdk/nashorn/internal/ir/CatchNode.java	Fri Feb 15 09:18:05 2013 +0100
    32.2 +++ b/src/jdk/nashorn/internal/ir/CatchNode.java	Fri Feb 15 09:44:15 2013 +0100
    32.3 @@ -67,10 +67,10 @@
    32.4      private CatchNode(final CatchNode catchNode, final CopyState cs) {
    32.5          super(catchNode);
    32.6  
    32.7 -        exception          = (IdentNode)cs.existingOrCopy(catchNode.exception);
    32.8 -        exceptionCondition = cs.existingOrCopy(catchNode.exceptionCondition);
    32.9 -        body               = (Block)cs.existingOrCopy(catchNode.body);
   32.10 -        isSyntheticRethrow = catchNode.isSyntheticRethrow;
   32.11 +        this.exception          = (IdentNode)cs.existingOrCopy(catchNode.exception);
   32.12 +        this.exceptionCondition = cs.existingOrCopy(catchNode.exceptionCondition);
   32.13 +        this.body               = (Block)cs.existingOrCopy(catchNode.body);
   32.14 +        this.isSyntheticRethrow = catchNode.isSyntheticRethrow;
   32.15       }
   32.16  
   32.17      @Override
    33.1 --- a/src/jdk/nashorn/internal/ir/ContinueNode.java	Fri Feb 15 09:18:05 2013 +0100
    33.2 +++ b/src/jdk/nashorn/internal/ir/ContinueNode.java	Fri Feb 15 09:44:15 2013 +0100
    33.3 @@ -25,7 +25,7 @@
    33.4  
    33.5  package jdk.nashorn.internal.ir;
    33.6  
    33.7 -import jdk.nashorn.internal.codegen.MethodEmitter;
    33.8 +import jdk.nashorn.internal.codegen.Label;
    33.9  import jdk.nashorn.internal.ir.visitor.NodeVisitor;
   33.10  import jdk.nashorn.internal.runtime.Source;
   33.11  
   33.12 @@ -72,7 +72,7 @@
   33.13       * Return the target label of this continue node.
   33.14       * @return the target label.
   33.15       */
   33.16 -    public MethodEmitter.Label getTargetLabel() {
   33.17 +    public Label getTargetLabel() {
   33.18          assert targetNode instanceof WhileNode : "continue target must be a while node";
   33.19          return ((WhileNode)targetNode).getContinueLabel();
   33.20      }
    34.1 --- a/src/jdk/nashorn/internal/ir/IdentNode.java	Fri Feb 15 09:18:05 2013 +0100
    34.2 +++ b/src/jdk/nashorn/internal/ir/IdentNode.java	Fri Feb 15 09:44:15 2013 +0100
    34.3 @@ -28,9 +28,9 @@
    34.4  import static jdk.nashorn.internal.codegen.CompilerConstants.__DIR__;
    34.5  import static jdk.nashorn.internal.codegen.CompilerConstants.__FILE__;
    34.6  import static jdk.nashorn.internal.codegen.CompilerConstants.__LINE__;
    34.7 -import static jdk.nashorn.internal.codegen.objects.ObjectClassGenerator.DEBUG_FIELDS;
    34.8 +import static jdk.nashorn.internal.codegen.ObjectClassGenerator.DEBUG_FIELDS;
    34.9  
   34.10 -import jdk.nashorn.internal.codegen.objects.ObjectClassGenerator;
   34.11 +import jdk.nashorn.internal.codegen.ObjectClassGenerator;
   34.12  import jdk.nashorn.internal.codegen.types.Type;
   34.13  import jdk.nashorn.internal.ir.visitor.NodeVisitor;
   34.14  import jdk.nashorn.internal.runtime.Source;
    35.1 --- a/src/jdk/nashorn/internal/ir/IndexNode.java	Fri Feb 15 09:18:05 2013 +0100
    35.2 +++ b/src/jdk/nashorn/internal/ir/IndexNode.java	Fri Feb 15 09:44:15 2013 +0100
    35.3 @@ -25,9 +25,9 @@
    35.4  
    35.5  package jdk.nashorn.internal.ir;
    35.6  
    35.7 -import static jdk.nashorn.internal.codegen.objects.ObjectClassGenerator.DEBUG_FIELDS;
    35.8 +import static jdk.nashorn.internal.codegen.ObjectClassGenerator.DEBUG_FIELDS;
    35.9  
   35.10 -import jdk.nashorn.internal.codegen.objects.ObjectClassGenerator;
   35.11 +import jdk.nashorn.internal.codegen.ObjectClassGenerator;
   35.12  import jdk.nashorn.internal.codegen.types.Type;
   35.13  import jdk.nashorn.internal.ir.visitor.NodeVisitor;
   35.14  import jdk.nashorn.internal.runtime.Source;
    36.1 --- a/src/jdk/nashorn/internal/ir/LabelNode.java	Fri Feb 15 09:18:05 2013 +0100
    36.2 +++ b/src/jdk/nashorn/internal/ir/LabelNode.java	Fri Feb 15 09:44:15 2013 +0100
    36.3 @@ -68,10 +68,10 @@
    36.4      private LabelNode(final LabelNode labelNode, final CopyState cs) {
    36.5          super(labelNode);
    36.6  
    36.7 -        label        = (IdentNode)cs.existingOrCopy(labelNode.label);
    36.8 -        body         = (Block)cs.existingOrCopy(labelNode.body);
    36.9 -        breakNode    = cs.existingOrSame(labelNode.breakNode);
   36.10 -        continueNode = cs.existingOrSame(labelNode.continueNode);
   36.11 +        this.label        = (IdentNode)cs.existingOrCopy(labelNode.label);
   36.12 +        this.body         = (Block)cs.existingOrCopy(labelNode.body);
   36.13 +        this.breakNode    = cs.existingOrSame(labelNode.breakNode);
   36.14 +        this.continueNode = cs.existingOrSame(labelNode.continueNode);
   36.15      }
   36.16  
   36.17      @Override
    37.1 --- a/src/jdk/nashorn/internal/ir/LineNumberNode.java	Fri Feb 15 09:18:05 2013 +0100
    37.2 +++ b/src/jdk/nashorn/internal/ir/LineNumberNode.java	Fri Feb 15 09:44:15 2013 +0100
    37.3 @@ -53,7 +53,7 @@
    37.4     private LineNumberNode(final LineNumberNode lineNumberNode) {
    37.5          super(lineNumberNode);
    37.6  
    37.7 -        lineNumber = lineNumberNode.getLineNumber();
    37.8 +        this.lineNumber = lineNumberNode.getLineNumber();
    37.9      }
   37.10  
   37.11      @Override
    38.1 --- a/src/jdk/nashorn/internal/ir/ObjectNode.java	Fri Feb 15 09:18:05 2013 +0100
    38.2 +++ b/src/jdk/nashorn/internal/ir/ObjectNode.java	Fri Feb 15 09:44:15 2013 +0100
    38.3 @@ -68,8 +68,8 @@
    38.4              newElements.add(cs.existingOrCopy(element));
    38.5          }
    38.6  
    38.7 -        context  = (Block)cs.existingOrCopy(objectNode.context);
    38.8 -        elements = newElements;
    38.9 +        this.context  = (Block)cs.existingOrCopy(objectNode.context);
   38.10 +        this.elements = newElements;
   38.11      }
   38.12  
   38.13      @Override
    39.1 --- a/src/jdk/nashorn/internal/ir/ReturnNode.java	Fri Feb 15 09:18:05 2013 +0100
    39.2 +++ b/src/jdk/nashorn/internal/ir/ReturnNode.java	Fri Feb 15 09:44:15 2013 +0100
    39.3 @@ -65,8 +65,8 @@
    39.4      private ReturnNode(final ReturnNode returnNode, final CopyState cs) {
    39.5          super(returnNode);
    39.6  
    39.7 -        expression = cs.existingOrCopy(returnNode.expression);
    39.8 -        tryChain   = (TryNode)cs.existingOrSame(returnNode.tryChain);
    39.9 +        this.expression = cs.existingOrCopy(returnNode.expression);
   39.10 +        this.tryChain   = (TryNode)cs.existingOrSame(returnNode.tryChain);
   39.11      }
   39.12  
   39.13      @Override
    40.1 --- a/src/jdk/nashorn/internal/ir/SplitNode.java	Fri Feb 15 09:18:05 2013 +0100
    40.2 +++ b/src/jdk/nashorn/internal/ir/SplitNode.java	Fri Feb 15 09:44:15 2013 +0100
    40.3 @@ -29,6 +29,7 @@
    40.4  import java.util.Collections;
    40.5  import java.util.List;
    40.6  import jdk.nashorn.internal.codegen.CompileUnit;
    40.7 +import jdk.nashorn.internal.codegen.Label;
    40.8  import jdk.nashorn.internal.codegen.MethodEmitter;
    40.9  import jdk.nashorn.internal.ir.annotations.Ignore;
   40.10  import jdk.nashorn.internal.ir.annotations.Reference;
   40.11 @@ -57,7 +58,7 @@
   40.12  
   40.13      /** A list of target labels in parent methods this split node may encounter. */
   40.14      @Ignore
   40.15 -    private final List<MethodEmitter.Label> externalTargets;
   40.16 +    private final List<Label> externalTargets;
   40.17  
   40.18      /** True if this split node or any of its children contain a return statement. */
   40.19      private boolean hasReturn;
   40.20 @@ -85,10 +86,10 @@
   40.21      private SplitNode(final SplitNode splitNode, final CopyState cs) {
   40.22          super(splitNode);
   40.23  
   40.24 -        name         = splitNode.name;
   40.25 -        functionNode = (FunctionNode)cs.existingOrSame(splitNode.functionNode);
   40.26 -        body         = cs.existingOrCopy(splitNode.body);
   40.27 -        externalTargets = new ArrayList<>();
   40.28 +        this.name         = splitNode.name;
   40.29 +        this.functionNode = (FunctionNode)cs.existingOrSame(splitNode.functionNode);
   40.30 +        this.body         = cs.existingOrCopy(splitNode.body);
   40.31 +        this.externalTargets = new ArrayList<>();
   40.32      }
   40.33  
   40.34      @Override
   40.35 @@ -196,7 +197,7 @@
   40.36       * Get the external targets for this SplitNode
   40.37       * @return list of external targets
   40.38       */
   40.39 -    public List<MethodEmitter.Label> getExternalTargets() {
   40.40 +    public List<Label> getExternalTargets() {
   40.41          return Collections.unmodifiableList(externalTargets);
   40.42      }
   40.43  
   40.44 @@ -204,7 +205,7 @@
   40.45       * Add an external target for this SplitNode
   40.46       * @param targetLabel target label
   40.47       */
   40.48 -    public void addExternalTarget(final MethodEmitter.Label targetLabel) {
   40.49 +    public void addExternalTarget(final Label targetLabel) {
   40.50          externalTargets.add(targetLabel);
   40.51      }
   40.52  
    41.1 --- a/src/jdk/nashorn/internal/ir/SwitchNode.java	Fri Feb 15 09:18:05 2013 +0100
    41.2 +++ b/src/jdk/nashorn/internal/ir/SwitchNode.java	Fri Feb 15 09:44:15 2013 +0100
    41.3 @@ -28,7 +28,7 @@
    41.4  import java.util.ArrayList;
    41.5  import java.util.Collections;
    41.6  import java.util.List;
    41.7 -import jdk.nashorn.internal.codegen.MethodEmitter.Label;
    41.8 +import jdk.nashorn.internal.codegen.Label;
    41.9  import jdk.nashorn.internal.ir.annotations.Ignore;
   41.10  import jdk.nashorn.internal.ir.visitor.NodeVisitor;
   41.11  import jdk.nashorn.internal.runtime.Source;
   41.12 @@ -59,12 +59,7 @@
   41.13       */
   41.14      public SwitchNode(final Source source, final long token, final int finish) {
   41.15          super(source, token, finish);
   41.16 -
   41.17 -        expression  = null;
   41.18 -        tag         = null;
   41.19 -        cases       = null;
   41.20 -        defaultCase = null;
   41.21 -        breakLabel  = new Label("switch_break");
   41.22 +        this.breakLabel  = new Label("switch_break");
   41.23      }
   41.24  
   41.25      private SwitchNode(final SwitchNode switchNode, final CopyState cs) {
   41.26 @@ -76,11 +71,11 @@
   41.27             newCases.add((CaseNode)cs.existingOrCopy(caseNode));
   41.28          }
   41.29  
   41.30 -        expression  = cs.existingOrCopy(switchNode.getExpression());
   41.31 -        tag         = switchNode.getTag();
   41.32 -        cases       = newCases;
   41.33 -        defaultCase = (CaseNode)cs.existingOrCopy(switchNode.getDefaultCase());
   41.34 -        breakLabel  = new Label(switchNode.getBreakLabel());
   41.35 +        this.expression  = cs.existingOrCopy(switchNode.getExpression());
   41.36 +        this.tag         = switchNode.getTag();
   41.37 +        this.cases       = newCases;
   41.38 +        this.defaultCase = (CaseNode)cs.existingOrCopy(switchNode.getDefaultCase());
   41.39 +        this.breakLabel  = new Label(switchNode.getBreakLabel());
   41.40      }
   41.41  
   41.42      @Override
    42.1 --- a/src/jdk/nashorn/internal/ir/ThrowNode.java	Fri Feb 15 09:18:05 2013 +0100
    42.2 +++ b/src/jdk/nashorn/internal/ir/ThrowNode.java	Fri Feb 15 09:44:15 2013 +0100
    42.3 @@ -60,8 +60,8 @@
    42.4      private ThrowNode(final ThrowNode throwNode, final CopyState cs) {
    42.5          super(throwNode);
    42.6  
    42.7 -        expression = cs.existingOrCopy(throwNode.expression);
    42.8 -        tryChain = (TryNode)cs.existingOrSame(throwNode.tryChain);
    42.9 +        this.expression = cs.existingOrCopy(throwNode.expression);
   42.10 +        this.tryChain = (TryNode)cs.existingOrSame(throwNode.tryChain);
   42.11      }
   42.12  
   42.13      @Override
    43.1 --- a/src/jdk/nashorn/internal/ir/TryNode.java	Fri Feb 15 09:18:05 2013 +0100
    43.2 +++ b/src/jdk/nashorn/internal/ir/TryNode.java	Fri Feb 15 09:44:15 2013 +0100
    43.3 @@ -28,7 +28,7 @@
    43.4  import java.util.ArrayList;
    43.5  import java.util.Collections;
    43.6  import java.util.List;
    43.7 -import jdk.nashorn.internal.codegen.MethodEmitter.Label;
    43.8 +import jdk.nashorn.internal.codegen.Label;
    43.9  import jdk.nashorn.internal.ir.annotations.Ignore;
   43.10  import jdk.nashorn.internal.ir.visitor.NodeVisitor;
   43.11  import jdk.nashorn.internal.runtime.Source;
    44.1 --- a/src/jdk/nashorn/internal/ir/UnaryNode.java	Fri Feb 15 09:18:05 2013 +0100
    44.2 +++ b/src/jdk/nashorn/internal/ir/UnaryNode.java	Fri Feb 15 09:44:15 2013 +0100
    44.3 @@ -67,7 +67,7 @@
    44.4      protected UnaryNode(final UnaryNode unaryNode, final CopyState cs) {
    44.5          super(unaryNode);
    44.6  
    44.7 -        rhs = cs.existingOrCopy(unaryNode.rhs);
    44.8 +        this.rhs = cs.existingOrCopy(unaryNode.rhs);
    44.9      }
   44.10  
   44.11      /**
    45.1 --- a/src/jdk/nashorn/internal/ir/WhileNode.java	Fri Feb 15 09:18:05 2013 +0100
    45.2 +++ b/src/jdk/nashorn/internal/ir/WhileNode.java	Fri Feb 15 09:44:15 2013 +0100
    45.3 @@ -25,7 +25,7 @@
    45.4  
    45.5  package jdk.nashorn.internal.ir;
    45.6  
    45.7 -import jdk.nashorn.internal.codegen.MethodEmitter.Label;
    45.8 +import jdk.nashorn.internal.codegen.Label;
    45.9  import jdk.nashorn.internal.ir.visitor.NodeVisitor;
   45.10  import jdk.nashorn.internal.runtime.Source;
   45.11  
   45.12 @@ -53,10 +53,8 @@
   45.13      public WhileNode(final Source source, final long token, final int finish) {
   45.14          super(source, token, finish);
   45.15  
   45.16 -        test          = null;
   45.17 -        body          = null;
   45.18 -        breakLabel    = new Label("while_break");
   45.19 -        continueLabel = new Label("while_continue");
   45.20 +        this.breakLabel    = new Label("while_break");
   45.21 +        this.continueLabel = new Label("while_continue");
   45.22      }
   45.23  
   45.24      /**
   45.25 @@ -68,10 +66,10 @@
   45.26      protected WhileNode(final WhileNode whileNode, final CopyState cs) {
   45.27          super(whileNode);
   45.28  
   45.29 -        test          = cs.existingOrCopy(whileNode.test);
   45.30 -        body          = (Block)cs.existingOrCopy(whileNode.body);
   45.31 -        breakLabel    = new Label(whileNode.breakLabel);
   45.32 -        continueLabel = new Label(whileNode.continueLabel);
   45.33 +        this.test          = cs.existingOrCopy(whileNode.test);
   45.34 +        this.body          = (Block)cs.existingOrCopy(whileNode.body);
   45.35 +        this.breakLabel    = new Label(whileNode.breakLabel);
   45.36 +        this.continueLabel = new Label(whileNode.continueLabel);
   45.37      }
   45.38  
   45.39      @Override
    46.1 --- a/src/jdk/nashorn/internal/ir/WithNode.java	Fri Feb 15 09:18:05 2013 +0100
    46.2 +++ b/src/jdk/nashorn/internal/ir/WithNode.java	Fri Feb 15 09:44:15 2013 +0100
    46.3 @@ -57,8 +57,8 @@
    46.4      private WithNode(final WithNode withNode, final CopyState cs) {
    46.5          super(withNode);
    46.6  
    46.7 -        expression = cs.existingOrCopy(withNode.expression);
    46.8 -        body       = (Block)cs.existingOrCopy(withNode.body);
    46.9 +        this.expression = cs.existingOrCopy(withNode.expression);
   46.10 +        this.body       = (Block)cs.existingOrCopy(withNode.body);
   46.11      }
   46.12  
   46.13      @Override
    47.1 --- a/src/jdk/nashorn/internal/objects/NativeRegExp.java	Fri Feb 15 09:18:05 2013 +0100
    47.2 +++ b/src/jdk/nashorn/internal/objects/NativeRegExp.java	Fri Feb 15 09:44:15 2013 +0100
    47.3 @@ -203,8 +203,7 @@
    47.4      }
    47.5  
    47.6      /**
    47.7 -     * External constructor used in generated code created by {@link jdk.nashorn.internal.codegen.CodeGenerator}, which
    47.8 -     * explain the {@code public} access.
    47.9 +     * External constructor used in generated code, which explains the public access
   47.10       *
   47.11       * @param regexp regexp
   47.12       * @param flags  flags
    48.1 --- a/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java	Fri Feb 15 09:18:05 2013 +0100
    48.2 +++ b/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java	Fri Feb 15 09:44:15 2013 +0100
    48.3 @@ -94,7 +94,6 @@
    48.4  
    48.5      /**
    48.6       * Constructor called by (compiler) generated code for {@link ScriptObject}s.
    48.7 -     * Code is generated by {@link jdk.nashorn.internal.codegen.CodeGenerator#newFunctionObject}
    48.8       *
    48.9       * @param data static function data
   48.10       * @param methodHandle handle for invocation
    49.1 --- a/src/jdk/nashorn/internal/runtime/AccessorProperty.java	Fri Feb 15 09:18:05 2013 +0100
    49.2 +++ b/src/jdk/nashorn/internal/runtime/AccessorProperty.java	Fri Feb 15 09:44:15 2013 +0100
    49.3 @@ -25,24 +25,24 @@
    49.4  
    49.5  package jdk.nashorn.internal.runtime;
    49.6  
    49.7 -import static jdk.nashorn.internal.codegen.objects.ObjectClassGenerator.ACCESSOR_TYPES;
    49.8 -import static jdk.nashorn.internal.codegen.objects.ObjectClassGenerator.DEBUG_FIELDS;
    49.9 -import static jdk.nashorn.internal.codegen.objects.ObjectClassGenerator.LOG;
   49.10 -import static jdk.nashorn.internal.codegen.objects.ObjectClassGenerator.OBJECT_FIELDS_ONLY;
   49.11 -import static jdk.nashorn.internal.codegen.objects.ObjectClassGenerator.PRIMITIVE_TYPE;
   49.12 -import static jdk.nashorn.internal.codegen.objects.ObjectClassGenerator.createGetter;
   49.13 -import static jdk.nashorn.internal.codegen.objects.ObjectClassGenerator.createGuardBoxedPrimitiveSetter;
   49.14 -import static jdk.nashorn.internal.codegen.objects.ObjectClassGenerator.createSetter;
   49.15 -import static jdk.nashorn.internal.codegen.objects.ObjectClassGenerator.getAccessorType;
   49.16 -import static jdk.nashorn.internal.codegen.objects.ObjectClassGenerator.getAccessorTypeIndex;
   49.17 -import static jdk.nashorn.internal.codegen.objects.ObjectClassGenerator.getNumberOfAccessorTypes;
   49.18 +import static jdk.nashorn.internal.codegen.ObjectClassGenerator.ACCESSOR_TYPES;
   49.19 +import static jdk.nashorn.internal.codegen.ObjectClassGenerator.DEBUG_FIELDS;
   49.20 +import static jdk.nashorn.internal.codegen.ObjectClassGenerator.LOG;
   49.21 +import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY;
   49.22 +import static jdk.nashorn.internal.codegen.ObjectClassGenerator.PRIMITIVE_TYPE;
   49.23 +import static jdk.nashorn.internal.codegen.ObjectClassGenerator.createGetter;
   49.24 +import static jdk.nashorn.internal.codegen.ObjectClassGenerator.createGuardBoxedPrimitiveSetter;
   49.25 +import static jdk.nashorn.internal.codegen.ObjectClassGenerator.createSetter;
   49.26 +import static jdk.nashorn.internal.codegen.ObjectClassGenerator.getAccessorType;
   49.27 +import static jdk.nashorn.internal.codegen.ObjectClassGenerator.getAccessorTypeIndex;
   49.28 +import static jdk.nashorn.internal.codegen.ObjectClassGenerator.getNumberOfAccessorTypes;
   49.29  import static jdk.nashorn.internal.runtime.linker.Lookup.MH;
   49.30  import static jdk.nashorn.internal.runtime.linker.MethodHandleFactory.stripName;
   49.31  
   49.32  import java.lang.invoke.MethodHandle;
   49.33  import java.lang.invoke.MethodHandles;
   49.34  import java.lang.invoke.MethodType;
   49.35 -import jdk.nashorn.internal.codegen.objects.ObjectClassGenerator;
   49.36 +import jdk.nashorn.internal.codegen.ObjectClassGenerator;
   49.37  import jdk.nashorn.internal.codegen.types.Type;
   49.38  import jdk.nashorn.internal.runtime.linker.Lookup;
   49.39  import jdk.nashorn.internal.runtime.linker.MethodHandleFactory;
    50.1 --- a/src/jdk/nashorn/internal/runtime/Context.java	Fri Feb 15 09:18:05 2013 +0100
    50.2 +++ b/src/jdk/nashorn/internal/runtime/Context.java	Fri Feb 15 09:44:15 2013 +0100
    50.3 @@ -51,8 +51,9 @@
    50.4  import jdk.nashorn.internal.codegen.ClassEmitter;
    50.5  import jdk.nashorn.internal.codegen.Compiler;
    50.6  import jdk.nashorn.internal.codegen.Namespace;
    50.7 -import jdk.nashorn.internal.codegen.objects.ObjectClassGenerator;
    50.8 +import jdk.nashorn.internal.codegen.ObjectClassGenerator;
    50.9  import jdk.nashorn.internal.ir.FunctionNode;
   50.10 +import jdk.nashorn.internal.ir.debug.ASTWriter;
   50.11  import jdk.nashorn.internal.ir.debug.PrintVisitor;
   50.12  import jdk.nashorn.internal.parser.Parser;
   50.13  import jdk.nashorn.internal.runtime.linker.JavaAdapterFactory;
   50.14 @@ -917,7 +918,11 @@
   50.15              return null;
   50.16          }
   50.17  
   50.18 -        if (_print_lower_parse) {
   50.19 +        if (_print_ast) {
   50.20 +            getErr().println(new ASTWriter(functionNode));
   50.21 +        }
   50.22 +
   50.23 +        if (_print_parse) {
   50.24              getErr().println(new PrintVisitor(functionNode));
   50.25          }
   50.26  
    51.1 --- a/src/jdk/nashorn/internal/runtime/ECMAException.java	Fri Feb 15 09:18:05 2013 +0100
    51.2 +++ b/src/jdk/nashorn/internal/runtime/ECMAException.java	Fri Feb 15 09:44:15 2013 +0100
    51.3 @@ -46,7 +46,6 @@
    51.4  public final class ECMAException extends NashornException {
    51.5      /**
    51.6       * Method handle pointing to the constructor {@link ECMAException#ECMAException(Object, String, int, int)},
    51.7 -     * used from {@link jdk.nashorn.internal.codegen.CodeGenerator}
    51.8       */
    51.9      public static final Call THROW_INIT = constructorNoLookup(ECMAException.class, Object.class, String.class, int.class, int.class);
   51.10  
    52.1 --- a/src/jdk/nashorn/internal/runtime/FindProperty.java	Fri Feb 15 09:18:05 2013 +0100
    52.2 +++ b/src/jdk/nashorn/internal/runtime/FindProperty.java	Fri Feb 15 09:44:15 2013 +0100
    52.3 @@ -28,7 +28,7 @@
    52.4  import static jdk.nashorn.internal.runtime.linker.Lookup.MH;
    52.5  
    52.6  import java.lang.invoke.MethodHandle;
    52.7 -import jdk.nashorn.internal.codegen.objects.ObjectClassGenerator;
    52.8 +import jdk.nashorn.internal.codegen.ObjectClassGenerator;
    52.9  
   52.10  /**
   52.11   * This class represents the result from a find property search.
    53.1 --- a/src/jdk/nashorn/internal/runtime/Property.java	Fri Feb 15 09:18:05 2013 +0100
    53.2 +++ b/src/jdk/nashorn/internal/runtime/Property.java	Fri Feb 15 09:44:15 2013 +0100
    53.3 @@ -31,7 +31,7 @@
    53.4  
    53.5  import java.lang.invoke.MethodHandle;
    53.6  import java.util.Objects;
    53.7 -import jdk.nashorn.internal.codegen.objects.ObjectClassGenerator;
    53.8 +import jdk.nashorn.internal.codegen.ObjectClassGenerator;
    53.9  import jdk.nashorn.internal.codegen.types.Type;
   53.10  
   53.11  /**
    54.1 --- a/src/jdk/nashorn/internal/runtime/Scope.java	Fri Feb 15 09:18:05 2013 +0100
    54.2 +++ b/src/jdk/nashorn/internal/runtime/Scope.java	Fri Feb 15 09:44:15 2013 +0100
    54.3 @@ -27,7 +27,6 @@
    54.4  
    54.5  import static jdk.nashorn.internal.codegen.CompilerConstants.interfaceCallNoLookup;
    54.6  
    54.7 -import jdk.nashorn.internal.codegen.CodeGenerator;
    54.8  import jdk.nashorn.internal.codegen.CompilerConstants;
    54.9  
   54.10  /**
   54.11 @@ -35,10 +34,10 @@
   54.12   */
   54.13  public interface Scope {
   54.14  
   54.15 -    /** Method handle that points to {@link Scope#getSplitState}. Used by {@link CodeGenerator} */
   54.16 +    /** Method handle that points to {@link Scope#getSplitState}. */
   54.17      public static final CompilerConstants.Call GET_SPLIT_STATE = interfaceCallNoLookup(Scope.class, "getSplitState", int.class);
   54.18  
   54.19 -    /** Method handle that points to {@link Scope#setSplitState(int)}. Used by {@link CodeGenerator} */
   54.20 +    /** Method handle that points to {@link Scope#setSplitState(int)}. */
   54.21      public static final CompilerConstants.Call SET_SPLIT_STATE = interfaceCallNoLookup(Scope.class, "setSplitState", void.class, int.class);
   54.22  
   54.23      /**
    55.1 --- a/src/jdk/nashorn/internal/runtime/ScriptObject.java	Fri Feb 15 09:18:05 2013 +0100
    55.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java	Fri Feb 15 09:44:15 2013 +0100
    55.3 @@ -60,7 +60,7 @@
    55.4  import jdk.internal.dynalink.linker.LinkRequest;
    55.5  import jdk.internal.dynalink.support.CallSiteDescriptorFactory;
    55.6  import jdk.nashorn.internal.codegen.CompilerConstants.Call;
    55.7 -import jdk.nashorn.internal.codegen.objects.ObjectClassGenerator;
    55.8 +import jdk.nashorn.internal.codegen.ObjectClassGenerator;
    55.9  import jdk.nashorn.internal.objects.AccessorPropertyDescriptor;
   55.10  import jdk.nashorn.internal.objects.DataPropertyDescriptor;
   55.11  import jdk.nashorn.internal.runtime.arrays.ArrayData;
   55.12 @@ -144,13 +144,13 @@
   55.13      /** Method handle for setting a function argument at a given index. Used from MapCreator */
   55.14      public static final Call SET_ARGUMENT       = virtualCall(ScriptObject.class, "setArgument", void.class, int.class, Object.class);
   55.15  
   55.16 -    /** Method handle for getting the proto of a ScriptObject - used by {@link jdk.nashorn.internal.codegen.CodeGenerator} */
   55.17 +    /** Method handle for getting the proto of a ScriptObject */
   55.18      public static final Call GET_PROTO          = virtualCallNoLookup(ScriptObject.class, "getProto", ScriptObject.class);
   55.19  
   55.20 -    /** Method handle for setting the proto of a ScriptObject - used by {@link jdk.nashorn.internal.codegen.CodeGenerator} */
   55.21 +    /** Method handle for setting the proto of a ScriptObject */
   55.22      public static final Call SET_PROTO          = virtualCallNoLookup(ScriptObject.class, "setProto", void.class, ScriptObject.class);
   55.23  
   55.24 -    /** Method handle for setting the user accessors of a ScriptObject - used by {@link jdk.nashorn.internal.codegen.CodeGenerator} */
   55.25 +    /** Method handle for setting the user accessors of a ScriptObject */
   55.26      public static final Call SET_USER_ACCESSORS = virtualCall(ScriptObject.class, "setUserAccessors", void.class, String.class, ScriptFunction.class, ScriptFunction.class);
   55.27  
   55.28      /** Method handle for getter for {@link UserAccessorProperty}, given a slot */
    56.1 --- a/src/jdk/nashorn/internal/runtime/ScriptRuntime.java	Fri Feb 15 09:18:05 2013 +0100
    56.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptRuntime.java	Fri Feb 15 09:44:15 2013 +0100
    56.3 @@ -71,27 +71,25 @@
    56.4      /** Method handle to generic === operator, operating on objects */
    56.5      public static final Call EQ_STRICT = staticCallNoLookup(ScriptRuntime.class, "EQ_STRICT", boolean.class, Object.class, Object.class);
    56.6  
    56.7 -    /** Method handle used to enter a {@code with} scope at runtime. Used from {@link jdk.nashorn.internal.codegen.CodeGenerator} */
    56.8 +    /** Method handle used to enter a {@code with} scope at runtime. */
    56.9      public static final Call OPEN_WITH = staticCallNoLookup(ScriptRuntime.class, "openWith", ScriptObject.class, ScriptObject.class, Object.class);
   56.10  
   56.11 -    /** Method handle used to exit a {@code with} scope at runtime. Used from {@link jdk.nashorn.internal.codegen.CodeGenerator} */
   56.12 +    /** Method handle used to exit a {@code with} scope at runtime. */
   56.13      public static final Call CLOSE_WITH = staticCallNoLookup(ScriptRuntime.class, "closeWith", ScriptObject.class, ScriptObject.class);
   56.14  
   56.15      /**
   56.16       * Method used to place a scope's variable into the Global scope, which has to be done for the
   56.17 -     * properties declared at outermost script level. Used from {@link jdk.nashorn.internal.codegen.CodeGenerator}
   56.18 +     * properties declared at outermost script level.
   56.19       */
   56.20      public static final Call MERGE_SCOPE = staticCallNoLookup(ScriptRuntime.class, "mergeScope", ScriptObject.class, ScriptObject.class);
   56.21  
   56.22      /**
   56.23       * Return an appropriate iterator for the elements in a for-in construct
   56.24 -     * Used from {@link jdk.nashorn.internal.codegen.CodeGenerator}
   56.25       */
   56.26      public static final Call TO_PROPERTY_ITERATOR = staticCallNoLookup(ScriptRuntime.class, "toPropertyIterator", Iterator.class, Object.class);
   56.27  
   56.28      /**
   56.29       * Return an appropriate iterator for the elements in a for-each construct
   56.30 -     * Used from {@link jdk.nashorn.internal.codegen.CodeGenerator}
   56.31       */
   56.32      public static final Call TO_VALUE_ITERATOR = staticCallNoLookup(ScriptRuntime.class, "toValueIterator", Iterator.class, Object.class);
   56.33  
    57.1 --- a/src/jdk/nashorn/internal/runtime/SetMethodCreator.java	Fri Feb 15 09:18:05 2013 +0100
    57.2 +++ b/src/jdk/nashorn/internal/runtime/SetMethodCreator.java	Fri Feb 15 09:44:15 2013 +0100
    57.3 @@ -31,7 +31,7 @@
    57.4  import java.lang.invoke.MethodHandle;
    57.5  import jdk.internal.dynalink.CallSiteDescriptor;
    57.6  import jdk.internal.dynalink.linker.GuardedInvocation;
    57.7 -import jdk.nashorn.internal.codegen.objects.ObjectClassGenerator;
    57.8 +import jdk.nashorn.internal.codegen.ObjectClassGenerator;
    57.9  import jdk.nashorn.internal.runtime.linker.Lookup;
   57.10  import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor;
   57.11  import jdk.nashorn.internal.runtime.linker.NashornGuards;
    58.1 --- a/src/jdk/nashorn/internal/runtime/StructureLoader.java	Fri Feb 15 09:18:05 2013 +0100
    58.2 +++ b/src/jdk/nashorn/internal/runtime/StructureLoader.java	Fri Feb 15 09:44:15 2013 +0100
    58.3 @@ -38,7 +38,7 @@
    58.4  import java.security.CodeSource;
    58.5  import java.security.PrivilegedActionException;
    58.6  import java.security.PrivilegedExceptionAction;
    58.7 -import jdk.nashorn.internal.codegen.objects.ObjectClassGenerator;
    58.8 +import jdk.nashorn.internal.codegen.ObjectClassGenerator;
    58.9  
   58.10  /**
   58.11   * Responsible for on the fly construction of structure classes as well

mercurial