< prev index next >
src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MethodGenerator.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
--- 1,7 ----
/*
! * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
*** 29,39 ****
import java.util.Iterator;
import java.util.Map;
import java.util.Stack;
! import com.sun.org.apache.bcel.internal.Constants;
import com.sun.org.apache.bcel.internal.classfile.Field;
import com.sun.org.apache.bcel.internal.classfile.Method;
import com.sun.org.apache.bcel.internal.generic.ALOAD;
import com.sun.org.apache.bcel.internal.generic.ASTORE;
import com.sun.org.apache.bcel.internal.generic.BranchHandle;
--- 29,39 ----
import java.util.Iterator;
import java.util.Map;
import java.util.Stack;
! import com.sun.org.apache.bcel.internal.Const;
import com.sun.org.apache.bcel.internal.classfile.Field;
import com.sun.org.apache.bcel.internal.classfile.Method;
import com.sun.org.apache.bcel.internal.generic.ALOAD;
import com.sun.org.apache.bcel.internal.generic.ASTORE;
import com.sun.org.apache.bcel.internal.generic.BranchHandle;
*** 53,63 ****
import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL;
import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC;
import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
import com.sun.org.apache.bcel.internal.generic.ISTORE;
import com.sun.org.apache.bcel.internal.generic.Instruction;
! import com.sun.org.apache.bcel.internal.generic.InstructionConstants;
import com.sun.org.apache.bcel.internal.generic.InstructionHandle;
import com.sun.org.apache.bcel.internal.generic.InstructionList;
import com.sun.org.apache.bcel.internal.generic.InstructionTargeter;
import com.sun.org.apache.bcel.internal.generic.LocalVariableGen;
import com.sun.org.apache.bcel.internal.generic.LocalVariableInstruction;
--- 53,63 ----
import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL;
import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC;
import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
import com.sun.org.apache.bcel.internal.generic.ISTORE;
import com.sun.org.apache.bcel.internal.generic.Instruction;
! import com.sun.org.apache.bcel.internal.generic.InstructionConst;
import com.sun.org.apache.bcel.internal.generic.InstructionHandle;
import com.sun.org.apache.bcel.internal.generic.InstructionList;
import com.sun.org.apache.bcel.internal.generic.InstructionTargeter;
import com.sun.org.apache.bcel.internal.generic.LocalVariableGen;
import com.sun.org.apache.bcel.internal.generic.LocalVariableInstruction;
*** 85,96 ****
private static final String START_ELEMENT_SIG
= "(" + STRING_SIG + ")V";
private static final String END_ELEMENT_SIG
= START_ELEMENT_SIG;
- private InstructionList _mapTypeSub;
-
private static final int DOM_INDEX = 1;
private static final int ITERATOR_INDEX = 2;
private static final int HANDLER_INDEX = 3;
private static final int MAX_METHOD_SIZE = 65535;
--- 85,94 ----
*** 1313,1324 ****
// Allocate instance of class in which we'll copy in or copy out locals
// and make two copies: last copy is used to invoke constructor;
// other two are used for references to fields in the CopyLocals object
InstructionHandle outlinedMethodCallSetup =
oldMethCopyInIL.append(new NEW(cpg.addClass(argTypeName)));
! oldMethCopyInIL.append(InstructionConstants.DUP);
! oldMethCopyInIL.append(InstructionConstants.DUP);
oldMethCopyInIL.append(
new INVOKESPECIAL(cpg.addMethodref(argTypeName, "<init>", "()V")));
// Generate code to invoke the new outlined method, and place the code
// on oldMethCopyOutIL
--- 1311,1322 ----
// Allocate instance of class in which we'll copy in or copy out locals
// and make two copies: last copy is used to invoke constructor;
// other two are used for references to fields in the CopyLocals object
InstructionHandle outlinedMethodCallSetup =
oldMethCopyInIL.append(new NEW(cpg.addClass(argTypeName)));
! oldMethCopyInIL.append(InstructionConst.DUP);
! oldMethCopyInIL.append(InstructionConst.DUP);
oldMethCopyInIL.append(
new INVOKESPECIAL(cpg.addMethodref(argTypeName, "<init>", "()V")));
// Generate code to invoke the new outlined method, and place the code
// on oldMethCopyOutIL
*** 1330,1341 ****
new INVOKESTATIC(cpg.addMethodref(
classGen.getClassName(),
outlinedMethodName,
outlinedMethodGen.getSignature())));
} else {
! oldMethCopyOutIL.append(InstructionConstants.THIS);
! oldMethCopyOutIL.append(InstructionConstants.SWAP);
outlinedMethodRef =
oldMethCopyOutIL.append(
new INVOKEVIRTUAL(cpg.addMethodref(
classGen.getClassName(),
outlinedMethodName,
--- 1328,1339 ----
new INVOKESTATIC(cpg.addMethodref(
classGen.getClassName(),
outlinedMethodName,
outlinedMethodGen.getSignature())));
} else {
! oldMethCopyOutIL.append(InstructionConst.THIS);
! oldMethCopyOutIL.append(InstructionConst.SWAP);
outlinedMethodRef =
oldMethCopyOutIL.append(
new INVOKEVIRTUAL(cpg.addMethodref(
classGen.getClassName(),
outlinedMethodName,
*** 1477,1487 ****
// Generate code for the old method to store the
// value of the local into the correct field in
// CopyLocals prior to invocation of the
// outlined method.
oldMethCopyInIL.append(
! InstructionConstants.DUP);
InstructionHandle copyInLoad =
oldMethCopyInIL.append(
loadLocal(oldLocalVarIndex, varType));
oldMethCopyInIL.append(new PUTFIELD(fieldRef));
--- 1475,1485 ----
// Generate code for the old method to store the
// value of the local into the correct field in
// CopyLocals prior to invocation of the
// outlined method.
oldMethCopyInIL.append(
! InstructionConst.DUP);
InstructionHandle copyInLoad =
oldMethCopyInIL.append(
loadLocal(oldLocalVarIndex, varType));
oldMethCopyInIL.append(new PUTFIELD(fieldRef));
*** 1496,1506 ****
// Generate code for start of the outlined
// method to copy the value from a field in
// CopyLocals to the new local in the outlined
// method
newMethCopyInIL.append(
! InstructionConstants.ALOAD_1);
newMethCopyInIL.append(new GETFIELD(fieldRef));
newMethCopyInIL.append(
storeLocal(newLocalVarIndex, varType));
}
--- 1494,1504 ----
// Generate code for start of the outlined
// method to copy the value from a field in
// CopyLocals to the new local in the outlined
// method
newMethCopyInIL.append(
! InstructionConst.ALOAD_1);
newMethCopyInIL.append(new GETFIELD(fieldRef));
newMethCopyInIL.append(
storeLocal(newLocalVarIndex, varType));
}
*** 1508,1528 ****
// Generate code for the end of the outlined
// method to copy the value from the new local
// variable into a field in CopyLocals
// method
newMethCopyOutIL.append(
! InstructionConstants.ALOAD_1);
newMethCopyOutIL.append(
loadLocal(newLocalVarIndex, varType));
newMethCopyOutIL.append(new PUTFIELD(fieldRef));
// Generate code to copy the value from a field
// in CopyLocals into a local in the original
// method following invocation of the outlined
// method.
oldMethCopyOutIL.append(
! InstructionConstants.DUP);
oldMethCopyOutIL.append(new GETFIELD(fieldRef));
InstructionHandle copyOutStore =
oldMethCopyOutIL.append(
storeLocal(oldLocalVarIndex, varType));
--- 1506,1526 ----
// Generate code for the end of the outlined
// method to copy the value from the new local
// variable into a field in CopyLocals
// method
newMethCopyOutIL.append(
! InstructionConst.ALOAD_1);
newMethCopyOutIL.append(
loadLocal(newLocalVarIndex, varType));
newMethCopyOutIL.append(new PUTFIELD(fieldRef));
// Generate code to copy the value from a field
// in CopyLocals into a local in the original
// method following invocation of the outlined
// method.
oldMethCopyOutIL.append(
! InstructionConst.DUP);
oldMethCopyOutIL.append(new GETFIELD(fieldRef));
InstructionHandle copyOutStore =
oldMethCopyOutIL.append(
storeLocal(oldLocalVarIndex, varType));
*** 1665,1675 ****
ih = ih.getNext();
}
// POP the reference to the CopyLocals object from the stack
! oldMethCopyOutIL.append(InstructionConstants.POP);
// Now that the generation of the outlined code is complete, update
// the old local variables with new start and end ranges, as required.
Iterator revisedLocalVarStartPairIter = revisedLocalVarStart.entrySet()
.iterator();
--- 1663,1673 ----
ih = ih.getNext();
}
// POP the reference to the CopyLocals object from the stack
! oldMethCopyOutIL.append(InstructionConst.POP);
// Now that the generation of the outlined code is complete, update
// the old local variables with new start and end ranges, as required.
Iterator revisedLocalVarStartPairIter = revisedLocalVarStart.entrySet()
.iterator();
*** 1706,1716 ****
oldMethodIL.insert(first, oldMethCopyOutIL);
// Insert the copying code into the outlined method
newIL.insert(newMethCopyInIL);
newIL.append(newMethCopyOutIL);
! newIL.append(InstructionConstants.RETURN);
// Discard instructions in outlineable chunk from old method
try {
oldMethodIL.delete(first, last);
} catch (TargetLostException e) {
--- 1704,1714 ----
oldMethodIL.insert(first, oldMethCopyOutIL);
// Insert the copying code into the outlined method
newIL.insert(newMethCopyInIL);
newIL.append(newMethCopyOutIL);
! newIL.append(InstructionConst.RETURN);
// Discard instructions in outlineable chunk from old method
try {
oldMethodIL.delete(first, last);
} catch (TargetLostException e) {
*** 1997,2038 ****
Instruction inst = ih.getInstruction();
switch (inst.getOpcode()) {
// Instructions that may have 16-bit or 32-bit branch targets.
// The size of the branch offset might increase by two bytes.
! case Constants.GOTO:
! case Constants.JSR:
maxOffsetChange = maxOffsetChange + 2;
break;
// Instructions that contain padding for alignment purposes
// Up to three bytes of padding might be needed. For greater
// accuracy, we should be able to discount any padding already
// added to these instructions by InstructionList.setPosition(),
// their APIs do not expose that information.
! case Constants.TABLESWITCH:
! case Constants.LOOKUPSWITCH:
maxOffsetChange = maxOffsetChange + 3;
break;
// Instructions that might be rewritten by this method as a
// conditional branch followed by an unconditional branch.
// The unconditional branch would require five bytes.
! case Constants.IF_ACMPEQ:
! case Constants.IF_ACMPNE:
! case Constants.IF_ICMPEQ:
! case Constants.IF_ICMPGE:
! case Constants.IF_ICMPGT:
! case Constants.IF_ICMPLE:
! case Constants.IF_ICMPLT:
! case Constants.IF_ICMPNE:
! case Constants.IFEQ:
! case Constants.IFGE:
! case Constants.IFGT:
! case Constants.IFLE:
! case Constants.IFLT:
! case Constants.IFNE:
! case Constants.IFNONNULL:
! case Constants.IFNULL:
maxOffsetChange = maxOffsetChange + 5;
break;
}
}
--- 1995,2036 ----
Instruction inst = ih.getInstruction();
switch (inst.getOpcode()) {
// Instructions that may have 16-bit or 32-bit branch targets.
// The size of the branch offset might increase by two bytes.
! case Const.GOTO:
! case Const.JSR:
maxOffsetChange = maxOffsetChange + 2;
break;
// Instructions that contain padding for alignment purposes
// Up to three bytes of padding might be needed. For greater
// accuracy, we should be able to discount any padding already
// added to these instructions by InstructionList.setPosition(),
// their APIs do not expose that information.
! case Const.TABLESWITCH:
! case Const.LOOKUPSWITCH:
maxOffsetChange = maxOffsetChange + 3;
break;
// Instructions that might be rewritten by this method as a
// conditional branch followed by an unconditional branch.
// The unconditional branch would require five bytes.
! case Const.IF_ACMPEQ:
! case Const.IF_ACMPNE:
! case Const.IF_ICMPEQ:
! case Const.IF_ICMPGE:
! case Const.IF_ICMPGT:
! case Const.IF_ICMPLE:
! case Const.IF_ICMPLT:
! case Const.IF_ICMPNE:
! case Const.IFEQ:
! case Const.IFGE:
! case Const.IFGT:
! case Const.IFLE:
! case Const.IFLT:
! case Const.IFNE:
! case Const.IFNONNULL:
! case Const.IFNULL:
maxOffsetChange = maxOffsetChange + 5;
break;
}
}
*** 2075,2085 ****
// If the original IF was the last instruction in
// InstructionList, add a new no-op to act as the target
// of the new IF
if (nextHandle == null) {
! nextHandle = il.append(gotoHandle, NOP);
}
// Make the new IF instruction branch around the GOTO
invertedIfHandle.updateTarget(target, nextHandle);
--- 2073,2083 ----
// If the original IF was the last instruction in
// InstructionList, add a new no-op to act as the target
// of the new IF
if (nextHandle == null) {
! nextHandle = il.append(gotoHandle, InstructionConst.NOP);
}
// Make the new IF instruction branch around the GOTO
invertedIfHandle.updateTarget(target, nextHandle);
< prev index next >