Some renaming

This commit is contained in:
Mikhael Bogdanov
2014-06-03 16:19:48 +04:00
committed by Michael Bogdanov
parent 30ddbb0682
commit b37c0d3fff
4 changed files with 14 additions and 14 deletions
@@ -62,7 +62,7 @@ public class InlineAdapter extends InstructionAdapter {
return nextLocalIndex; return nextLocalIndex;
} }
public void setInlining(boolean isInlining) { public void setLambdaInlining(boolean isInlining) {
this.isInlining = isInlining; this.isInlining = isInlining;
if (isInlining) { if (isInlining) {
nextLocalIndexBeforeInline = nextLocalIndex; nextLocalIndexBeforeInline = nextLocalIndex;
@@ -214,11 +214,11 @@ public class InlineCodegenUtil {
return false; return false;
} }
public static boolean isLambdaConstructorCall(@NotNull String internalName, @NotNull String methodName) { public static boolean isAnonymousConstructorCall(@NotNull String internalName, @NotNull String methodName) {
return "<init>".equals(methodName) && isLambdaClass(internalName); return "<init>".equals(methodName) && isAnonymousClass(internalName);
} }
public static boolean isLambdaClass(String internalName) { public static boolean isAnonymousClass(String internalName) {
String shortName = getLastNamePart(internalName); String shortName = getLastNamePart(internalName);
int index = shortName.lastIndexOf("$"); int index = shortName.lastIndexOf("$");
@@ -128,7 +128,7 @@ public class LambdaInfo implements CapturedParamOwner {
} }
@NotNull @NotNull
public List<Type> getParamsWithoutCapturedValOrVar() { public List<Type> getInvokeParamsWithoutCaptured() {
Type[] types = typeMapper.mapSignature(functionDescriptor).getAsmMethod().getArgumentTypes(); Type[] types = typeMapper.mapSignature(functionDescriptor).getAsmMethod().getArgumentTypes();
return Arrays.asList(types); return Arrays.asList(types);
} }
@@ -35,7 +35,7 @@ import org.jetbrains.org.objectweb.asm.tree.analysis.*;
import java.util.*; import java.util.*;
import static org.jetbrains.jet.codegen.inline.InlineCodegenUtil.isInvokeOnLambda; import static org.jetbrains.jet.codegen.inline.InlineCodegenUtil.isInvokeOnLambda;
import static org.jetbrains.jet.codegen.inline.InlineCodegenUtil.isLambdaConstructorCall; import static org.jetbrains.jet.codegen.inline.InlineCodegenUtil.isAnonymousConstructorCall;
public class MethodInliner { public class MethodInliner {
@@ -129,12 +129,12 @@ 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));
InlineAdapter inliner = new InlineAdapter(remappingMethodAdapter, parameters.totalSize()) { InlineAdapter lambdaInliner = new InlineAdapter(remappingMethodAdapter, parameters.totalSize()) {
private ConstructorInvocation invocation; private ConstructorInvocation invocation;
@Override @Override
public void anew(Type type) { public void anew(Type type) {
if (isLambdaConstructorCall(type.getInternalName(), "<init>")) { if (isAnonymousConstructorCall(type.getInternalName(), "<init>")) {
invocation = iterator.next(); invocation = iterator.next();
if (invocation.shouldRegenerate()) { if (invocation.shouldRegenerate()) {
@@ -179,14 +179,14 @@ public class MethodInliner {
} }
int valueParamShift = getNextLocalIndex();//NB: don't inline cause it changes int valueParamShift = getNextLocalIndex();//NB: don't inline cause it changes
putStackValuesIntoLocals(info.getParamsWithoutCapturedValOrVar(), valueParamShift, this, desc); putStackValuesIntoLocals(info.getInvokeParamsWithoutCaptured(), valueParamShift, this, desc);
Parameters lambdaParameters = info.addAllParameters(nodeRemapper); Parameters lambdaParameters = info.addAllParameters(nodeRemapper);
InlinedLambdaRemapper newCapturedRemapper = InlinedLambdaRemapper newCapturedRemapper =
new InlinedLambdaRemapper(info.getLambdaClassType().getInternalName(), nodeRemapper, lambdaParameters); new InlinedLambdaRemapper(info.getLambdaClassType().getInternalName(), nodeRemapper, lambdaParameters);
setInlining(true); setLambdaInlining(true);
MethodInliner inliner = new MethodInliner(info.getNode(), lambdaParameters, MethodInliner inliner = new MethodInliner(info.getNode(), lambdaParameters,
inliningContext.subInlineLambda(info), inliningContext.subInlineLambda(info),
newCapturedRemapper, true /*cause all calls in same module as lambda*/, newCapturedRemapper, true /*cause all calls in same module as lambda*/,
@@ -201,9 +201,9 @@ public class MethodInliner {
typeMapper.mapSignature(ClosureCodegen.getErasedInvokeFunction(info.getFunctionDescriptor())).getAsmMethod(); typeMapper.mapSignature(ClosureCodegen.getErasedInvokeFunction(info.getFunctionDescriptor())).getAsmMethod();
Method delegate = typeMapper.mapSignature(info.getFunctionDescriptor()).getAsmMethod(); Method delegate = typeMapper.mapSignature(info.getFunctionDescriptor()).getAsmMethod();
StackValue.onStack(delegate.getReturnType()).put(bridge.getReturnType(), this); StackValue.onStack(delegate.getReturnType()).put(bridge.getReturnType(), this);
setInlining(false); setLambdaInlining(false);
} }
else if (isLambdaConstructorCall(owner, name)) { //TODO add method else if (isAnonymousConstructorCall(owner, name)) { //TODO add method
assert invocation != null : "<init> call not corresponds to new call" + owner + " " + name; assert invocation != null : "<init> call not corresponds to new call" + owner + " " + name;
if (invocation.shouldRegenerate()) { if (invocation.shouldRegenerate()) {
//put additional captured parameters on stack //put additional captured parameters on stack
@@ -224,7 +224,7 @@ public class MethodInliner {
}; };
node.accept(inliner); node.accept(lambdaInliner);
return resultNode; return resultNode;
} }
@@ -344,7 +344,7 @@ public class MethodInliner {
invokeCalls.add(new InvokeCall(varIndex, lambdaInfo)); invokeCalls.add(new InvokeCall(varIndex, lambdaInfo));
} }
else if (isLambdaConstructorCall(owner, name)) { else if (isAnonymousConstructorCall(owner, name)) {
Map<Integer, LambdaInfo> lambdaMapping = new HashMap<Integer, LambdaInfo>(); Map<Integer, LambdaInfo> lambdaMapping = new HashMap<Integer, LambdaInfo>();
int paramStart = frame.getStackSize() - paramLength; int paramStart = frame.getStackSize() - paramLength;