Fix local variable shift for inline functions
This commit is contained in:
committed by
Natalia Ukhorskaya
parent
9168572b8c
commit
d985f56b8d
@@ -706,7 +706,12 @@ public class InlineCodegen extends CallGenerator {
|
|||||||
|
|
||||||
FrameMap frameMap = finallyCodegen.getFrameMap();
|
FrameMap frameMap = finallyCodegen.getFrameMap();
|
||||||
FrameMap.Mark mark = frameMap.mark();
|
FrameMap.Mark mark = frameMap.mark();
|
||||||
while (frameMap.getCurrentSize() < processor.getNextFreeLocalIndex()) {
|
int marker = -1;
|
||||||
|
Set<LocalVarNodeWrapper> intervals = processor.getLocalVarsMetaInfo().getCurrentIntervals();
|
||||||
|
for (LocalVarNodeWrapper interval : intervals) {
|
||||||
|
marker = Math.max(interval.getNode().index + 1, marker);
|
||||||
|
}
|
||||||
|
while (frameMap.getCurrentSize() < Math.max(processor.getNextFreeLocalIndex(), offsetForFinallyLocalVar + marker)) {
|
||||||
frameMap.enterTemp(Type.INT_TYPE);
|
frameMap.enterTemp(Type.INT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -492,4 +492,23 @@ public class InlineCodegenUtil {
|
|||||||
public static boolean isStoreInstruction(int opcode) {
|
public static boolean isStoreInstruction(int opcode) {
|
||||||
return opcode >= Opcodes.ISTORE && opcode <= Opcodes.ASTORE;
|
return opcode >= Opcodes.ISTORE && opcode <= Opcodes.ASTORE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int calcMarkerShift(Parameters parameters, MethodNode node) {
|
||||||
|
int markerShiftTemp = getIndexAfterLastMarker(node);
|
||||||
|
return markerShiftTemp - parameters.getRealArgsSizeOnStack() + parameters.getArgsSizeOnStack();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static int getIndexAfterLastMarker(MethodNode node) {
|
||||||
|
int markerShiftTemp = -1;
|
||||||
|
for (LocalVariableNode variable : node.localVariables) {
|
||||||
|
if (isFakeLocalVariableForInline(variable.name)) {
|
||||||
|
markerShiftTemp = Math.max(markerShiftTemp, variable.index + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return markerShiftTemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isFakeLocalVariableForInline(@NotNull String name) {
|
||||||
|
return name.startsWith(JvmAbi.LOCAL_VARIABLE_NAME_PREFIX_INLINE_FUNCTION) || name.startsWith(JvmAbi.LOCAL_VARIABLE_NAME_PREFIX_INLINE_ARGUMENT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ public class MethodInliner {
|
|||||||
RemappingMethodAdapter remappingMethodAdapter = new RemappingMethodAdapter(resultNode.access, resultNode.desc, resultNode,
|
RemappingMethodAdapter remappingMethodAdapter = new RemappingMethodAdapter(resultNode.access, resultNode.desc, resultNode,
|
||||||
new TypeRemapper(currentTypeMapping));
|
new TypeRemapper(currentTypeMapping));
|
||||||
|
|
||||||
|
final int markerShift = InlineCodegenUtil.calcMarkerShift(parameters, node);
|
||||||
InlineAdapter lambdaInliner = new InlineAdapter(remappingMethodAdapter, parameters.getArgsSizeOnStack(), sourceMapper) {
|
InlineAdapter lambdaInliner = new InlineAdapter(remappingMethodAdapter, parameters.getArgsSizeOnStack(), sourceMapper) {
|
||||||
|
|
||||||
private AnonymousObjectGeneration anonymousObjectGen;
|
private AnonymousObjectGeneration anonymousObjectGen;
|
||||||
@@ -217,7 +218,7 @@ public class MethodInliner {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int valueParamShift = getNextLocalIndex();//NB: don't inline cause it changes
|
int valueParamShift = Math.max(getNextLocalIndex(), markerShift);//NB: don't inline cause it changes
|
||||||
putStackValuesIntoLocals(info.getInvokeParamsWithoutCaptured(), valueParamShift, this, desc);
|
putStackValuesIntoLocals(info.getInvokeParamsWithoutCaptured(), valueParamShift, this, desc);
|
||||||
|
|
||||||
addInlineMarker(this, true);
|
addInlineMarker(this, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user