< prev index next >

src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java

Print this page




 527         p0.swap(method, p1);
 528 
 529         pushType(p0);
 530         stack.markLocalLoad(l0);
 531         pushType(p1);
 532         stack.markLocalLoad(l1);
 533         return this;
 534     }
 535 
 536     void pack() {
 537         final Type type = peekType();
 538         if (type.isInteger()) {
 539             convert(PRIMITIVE_FIELD_TYPE);
 540         } else if (type.isLong()) {
 541             //nop
 542         } else if (type.isNumber()) {
 543             invokestatic("java/lang/Double", "doubleToRawLongBits", "(D)J");
 544         } else {
 545             assert false : type + " cannot be packed!";
 546         }
 547         //all others are nops, objects aren't packed
 548     }
 549 
 550     /**
 551      * Initializes a bytecode method parameter
 552      * @param symbol the symbol for the parameter
 553      * @param type the type of the parameter
 554      * @param start the label for the start of the method
 555      */
 556     void initializeMethodParameter(final Symbol symbol, final Type type, final Label start) {
 557         assert symbol.isBytecodeLocal();
 558         localVariableDefs.put(symbol, new LocalVariableDef(start.getLabel(), type));
 559     }
 560 
 561     /**
 562      * Create a new string builder, call the constructor and push the instance to the stack.
 563      *
 564      * @return the method emitter
 565      */
 566     MethodEmitter newStringBuilder() {
 567         return invoke(constructorNoLookup(StringBuilder.class)).dup();




 527         p0.swap(method, p1);
 528 
 529         pushType(p0);
 530         stack.markLocalLoad(l0);
 531         pushType(p1);
 532         stack.markLocalLoad(l1);
 533         return this;
 534     }
 535 
 536     void pack() {
 537         final Type type = peekType();
 538         if (type.isInteger()) {
 539             convert(PRIMITIVE_FIELD_TYPE);
 540         } else if (type.isLong()) {
 541             //nop
 542         } else if (type.isNumber()) {
 543             invokestatic("java/lang/Double", "doubleToRawLongBits", "(D)J");
 544         } else {
 545             assert false : type + " cannot be packed!";
 546         }

 547     }
 548 
 549     /**
 550      * Initializes a bytecode method parameter
 551      * @param symbol the symbol for the parameter
 552      * @param type the type of the parameter
 553      * @param start the label for the start of the method
 554      */
 555     void initializeMethodParameter(final Symbol symbol, final Type type, final Label start) {
 556         assert symbol.isBytecodeLocal();
 557         localVariableDefs.put(symbol, new LocalVariableDef(start.getLabel(), type));
 558     }
 559 
 560     /**
 561      * Create a new string builder, call the constructor and push the instance to the stack.
 562      *
 563      * @return the method emitter
 564      */
 565     MethodEmitter newStringBuilder() {
 566         return invoke(constructorNoLookup(StringBuilder.class)).dup();


< prev index next >