Inline markers added

This commit is contained in:
Michael Bogdanov
2014-08-19 14:32:47 +04:00
committed by Andrey Breslav
parent e035fc3219
commit 469db95662
4 changed files with 57 additions and 0 deletions
@@ -55,6 +55,7 @@ import java.util.ListIterator;
import java.util.Map;
import static org.jetbrains.jet.codegen.AsmUtil.*;
import static org.jetbrains.jet.codegen.inline.InlineCodegenUtil.addInlineMarker;
public class InlineCodegen implements CallGenerator {
private final GenerationState state;
@@ -204,6 +205,8 @@ public class InlineCodegen implements CallGenerator {
//through generation captured parameters will be added to invocationParamBuilder
putClosureParametersOnStack();
addInlineMarker(codegen.v, true);
Parameters parameters = invocationParamBuilder.buildParameters();
InliningContext info = new RootInliningContext(expressionMap,
@@ -242,6 +245,9 @@ public class InlineCodegen implements CallGenerator {
generateAndInsertFinallyBlocks(adapter, infos);
adapter.accept(new InliningInstructionAdapter(codegen.v));
addInlineMarker(codegen.v, false);
return result;
}
@@ -72,6 +72,9 @@ public class InlineCodegenUtil {
public static final String NON_LOCAL_RETURN = "$$$$$NON_LOCAL_RETURN$$$$$";
public static final String ROOT_LABEL = "$$$$$ROOT$$$$$";
public static final String INLINE_MARKER_CLASS_NAME = "kotlin/jvm/internal/InlineMarker";
public static final String INLINE_MARKER_BEFORE_METHOD_NAME = "beforeInlineCall";
public static final String INLINE_MARKER_AFTER_METHOD_NAME = "afterInlineCall";
@Nullable
public static MethodNode getMethodNode(
@@ -377,4 +380,13 @@ public class InlineCodegenUtil {
return labelNames == null ? null : labelNames.get(l);
}
}
public static void addInlineMarker(
@NotNull InstructionAdapter v,
boolean isStartNotEnd
) {
v.visitMethodInsn(Opcodes.INVOKESTATIC, INLINE_MARKER_CLASS_NAME,
(isStartNotEnd ? INLINE_MARKER_BEFORE_METHOD_NAME : INLINE_MARKER_AFTER_METHOD_NAME),
"()V", false);
}
}
@@ -196,6 +196,7 @@ public class MethodInliner {
int valueParamShift = getNextLocalIndex();//NB: don't inline cause it changes
putStackValuesIntoLocals(info.getInvokeParamsWithoutCaptured(), valueParamShift, this, desc);
addInlineMarker(this, true);
Parameters lambdaParameters = info.addAllParameters(nodeRemapper);
InlinedLambdaRemapper newCapturedRemapper =
@@ -217,6 +218,7 @@ public class MethodInliner {
Method delegate = typeMapper.mapSignature(info.getFunctionDescriptor()).getAsmMethod();
StackValue.onStack(delegate.getReturnType()).put(bridge.getReturnType(), this);
setLambdaInlining(false);
addInlineMarker(this, false);
}
else if (isAnonymousConstructorCall(owner, name)) { //TODO add method
assert invocation != null : "<init> call not corresponds to new call" + owner + " " + name;
@@ -0,0 +1,37 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.jvm.internal;
public class InlineMarker {
public static void beforeInlineCall() {
}
public static void afterInlineCall() {
}
public static void beforeLambdaCall() {
}
public static void afterLambdaCall() {
}
}