Java Code Examples for jdk.internal.org.objectweb.asm.commons.InstructionAdapter#ifeq()

The following examples show how to use jdk.internal.org.objectweb.asm.commons.InstructionAdapter#ifeq() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaAdapterBytecodeGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void generateClassInit() {
    final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_STATIC, CLASS_INIT,
            VOID_METHOD_DESCRIPTOR, null, null));

    // Assign "global = Context.getGlobal()"
    GET_NON_NULL_GLOBAL.invoke(mv);
    mv.putstatic(generatedClassName, GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR);

    GET_CLASS_OVERRIDES.invoke(mv);
    if(samName != null) {
        // If the class is a SAM, allow having ScriptFunction passed as class overrides
        mv.dup();
        mv.instanceOf(SCRIPT_FUNCTION_TYPE);
        mv.dup();
        mv.putstatic(generatedClassName, IS_FUNCTION_FIELD_NAME, BOOLEAN_TYPE_DESCRIPTOR);
        final Label notFunction = new Label();
        mv.ifeq(notFunction);
        mv.dup();
        mv.checkcast(SCRIPT_FUNCTION_TYPE);
        emitInitCallThis(mv);
        mv.visitLabel(notFunction);
    }
    mv.putstatic(generatedClassName, DELEGATE_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR);

    endInitMethod(mv);
}
 
Example 2
Source File: JavaAdapterBytecodeGenerator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Emit code to restore the previous Nashorn Context when needed.
 * @param mv the instruction adapter
 * @param currentGlobalVar index of the local variable holding the reference to the current global at method
 * entry.
 * @param globalsDifferVar index of the boolean local variable that is true if the global needs to be restored.
 */
private static void emitFinally(final InstructionAdapter mv, final int currentGlobalVar, final int globalsDifferVar) {
    // Emit code to restore the previous Nashorn global if needed
    mv.visitVarInsn(ILOAD, globalsDifferVar);
    final Label skip = new Label();
    mv.ifeq(skip);
    mv.visitVarInsn(ALOAD, currentGlobalVar);
    invokeSetGlobal(mv);
    mv.visitLabel(skip);
}
 
Example 3
Source File: JavaAdapterBytecodeGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Emit code to restore the previous Nashorn Context when needed.
 * @param mv the instruction adapter
 * @param currentGlobalVar index of the local variable holding the reference to the current global at method
 * entry.
 * @param globalsDifferVar index of the boolean local variable that is true if the global needs to be restored.
 */
private static void emitFinally(final InstructionAdapter mv, final int currentGlobalVar, final int globalsDifferVar) {
    // Emit code to restore the previous Nashorn global if needed
    mv.visitVarInsn(ILOAD, globalsDifferVar);
    final Label skip = new Label();
    mv.ifeq(skip);
    mv.visitVarInsn(ALOAD, currentGlobalVar);
    invokeSetGlobal(mv);
    mv.visitLabel(skip);
}
 
Example 4
Source File: JavaAdapterBytecodeGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Emit code to restore the previous Nashorn Context when needed.
 * @param mv the instruction adapter
 * @param currentGlobalVar index of the local variable holding the reference to the current global at method
 * entry.
 * @param globalsDifferVar index of the boolean local variable that is true if the global needs to be restored.
 */
private static void emitFinally(final InstructionAdapter mv, final int currentGlobalVar, final int globalsDifferVar) {
    // Emit code to restore the previous Nashorn global if needed
    mv.visitVarInsn(ILOAD, globalsDifferVar);
    final Label skip = new Label();
    mv.ifeq(skip);
    mv.visitVarInsn(ALOAD, currentGlobalVar);
    invokeSetGlobal(mv);
    mv.visitLabel(skip);
}
 
Example 5
Source File: JavaAdapterBytecodeGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Emit code to restore the previous Nashorn Context when needed.
 * @param mv the instruction adapter
 * @param currentGlobalVar index of the local variable holding the reference to the current global at method
 * entry.
 * @param globalsDifferVar index of the boolean local variable that is true if the global needs to be restored.
 */
private static void emitFinally(final InstructionAdapter mv, final int currentGlobalVar, final int globalsDifferVar) {
    // Emit code to restore the previous Nashorn global if needed
    mv.visitVarInsn(ILOAD, globalsDifferVar);
    final Label skip = new Label();
    mv.ifeq(skip);
    mv.visitVarInsn(ALOAD, currentGlobalVar);
    invokeSetGlobal(mv);
    mv.visitLabel(skip);
}
 
Example 6
Source File: JavaAdapterBytecodeGenerator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Emit code to restore the previous Nashorn Context when needed.
 * @param mv the instruction adapter
 * @param currentGlobalVar index of the local variable holding the reference to the current global at method
 * entry.
 * @param globalsDifferVar index of the boolean local variable that is true if the global needs to be restored.
 */
private static void emitFinally(final InstructionAdapter mv, final int currentGlobalVar, final int globalsDifferVar) {
    // Emit code to restore the previous Nashorn global if needed
    mv.visitVarInsn(ILOAD, globalsDifferVar);
    final Label skip = new Label();
    mv.ifeq(skip);
    mv.visitVarInsn(ALOAD, currentGlobalVar);
    invokeSetGlobal(mv);
    mv.visitLabel(skip);
}
 
Example 7
Source File: JavaAdapterBytecodeGenerator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Emit code to restore the previous Nashorn Context when needed.
 * @param mv the instruction adapter
 * @param currentGlobalVar index of the local variable holding the reference to the current global at method
 * entry.
 * @param globalsDifferVar index of the boolean local variable that is true if the global needs to be restored.
 */
private static void emitFinally(final InstructionAdapter mv, final int currentGlobalVar, final int globalsDifferVar) {
    // Emit code to restore the previous Nashorn global if needed
    mv.visitVarInsn(ILOAD, globalsDifferVar);
    final Label skip = new Label();
    mv.ifeq(skip);
    mv.visitVarInsn(ALOAD, currentGlobalVar);
    invokeSetGlobal(mv);
    mv.visitLabel(skip);
}
 
Example 8
Source File: JavaAdapterBytecodeGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Emit code to restore the previous Nashorn Context when needed.
 * @param mv the instruction adapter
 * @param currentGlobalVar index of the local variable holding the reference to the current global at method
 * entry.
 * @param globalsDifferVar index of the boolean local variable that is true if the global needs to be restored.
 */
private static void emitFinally(final InstructionAdapter mv, final int currentGlobalVar, final int globalsDifferVar) {
    // Emit code to restore the previous Nashorn global if needed
    mv.visitVarInsn(ILOAD, globalsDifferVar);
    final Label skip = new Label();
    mv.ifeq(skip);
    mv.visitVarInsn(ALOAD, currentGlobalVar);
    invokeSetGlobal(mv);
    mv.visitLabel(skip);
}
 
Example 9
Source File: JavaAdapterBytecodeGenerator.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Emit code to restore the previous Nashorn Context when needed.
 * @param mv the instruction adapter
 * @param currentGlobalVar index of the local variable holding the reference to the current global at method
 * entry.
 * @param globalsDifferVar index of the boolean local variable that is true if the global needs to be restored.
 */
private static void emitFinally(final InstructionAdapter mv, final int currentGlobalVar, final int globalsDifferVar) {
    // Emit code to restore the previous Nashorn global if needed
    mv.visitVarInsn(ILOAD, globalsDifferVar);
    final Label skip = new Label();
    mv.ifeq(skip);
    mv.visitVarInsn(ALOAD, currentGlobalVar);
    invokeSetGlobal(mv);
    mv.visitLabel(skip);
}
 
Example 10
Source File: JavaAdapterBytecodeGenerator.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Emit code to restore the previous Nashorn Context when needed.
 * @param mv the instruction adapter
 * @param currentGlobalVar index of the local variable holding the reference to the current global at method
 * entry.
 * @param globalsDifferVar index of the boolean local variable that is true if the global needs to be restored.
 */
private static void emitFinally(final InstructionAdapter mv, final int currentGlobalVar, final int globalsDifferVar) {
    // Emit code to restore the previous Nashorn global if needed
    mv.visitVarInsn(ILOAD, globalsDifferVar);
    final Label skip = new Label();
    mv.ifeq(skip);
    mv.visitVarInsn(ALOAD, currentGlobalVar);
    invokeSetGlobal(mv);
    mv.visitLabel(skip);
}
 
Example 11
Source File: JavaAdapterBytecodeGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private void generateOverridingConstructorWithObjectParam(final InstructionAdapter mv, final String ctorDescriptor) {
    mv.visitCode();
    final int extraArgOffset = emitSuperConstructorCall(mv, ctorDescriptor);

    // Check for ScriptObjectMirror
    mv.visitVarInsn(ALOAD, extraArgOffset);
    mv.instanceOf(SCRIPT_OBJECT_MIRROR_TYPE);
    final Label notMirror = new Label();
    mv.ifeq(notMirror);

    mv.visitVarInsn(ALOAD, 0);
    mv.visitVarInsn(ALOAD, extraArgOffset);
    mv.iconst(0);
    UNWRAP_MIRROR.invoke(mv);
    mv.putfield(generatedClassName, DELEGATE_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR);

    mv.visitVarInsn(ALOAD, 0);
    mv.visitVarInsn(ALOAD, extraArgOffset);
    mv.iconst(1);
    UNWRAP_MIRROR.invoke(mv);
    mv.putfield(generatedClassName, GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR);

    final Label done = new Label();

    if (samName != null) {
        mv.visitVarInsn(ALOAD, 0);
        mv.getfield(generatedClassName, DELEGATE_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR);
        mv.instanceOf(SCRIPT_FUNCTION_TYPE);
        mv.ifeq(done);

        // Assign "isFunction = true"
        mv.visitVarInsn(ALOAD, 0);
        mv.iconst(1);
        mv.putfield(generatedClassName, IS_FUNCTION_FIELD_NAME, BOOLEAN_TYPE_DESCRIPTOR);

        mv.visitVarInsn(ALOAD, 0);
        mv.dup();
        mv.getfield(generatedClassName, DELEGATE_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR);
        mv.checkcast(SCRIPT_FUNCTION_TYPE);
        emitInitCallThis(mv);
        mv.goTo(done);
    }

    mv.visitLabel(notMirror);

    // Throw error if not a ScriptObject
    mv.visitVarInsn(ALOAD, extraArgOffset);
    NOT_AN_OBJECT.invoke(mv);

    mv.visitLabel(done);
    endInitMethod(mv);
}