diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/inline/InlineCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/inline/InlineCodegen.java index d52e80a4028..90efcc13a73 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/inline/InlineCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/inline/InlineCodegen.java @@ -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; } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/inline/InlineCodegenUtil.java b/compiler/backend/src/org/jetbrains/jet/codegen/inline/InlineCodegenUtil.java index 978c2c2bbbd..f05f4396bb2 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/inline/InlineCodegenUtil.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/inline/InlineCodegenUtil.java @@ -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); + } } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/inline/MethodInliner.java b/compiler/backend/src/org/jetbrains/jet/codegen/inline/MethodInliner.java index 14288988580..79f730f1054 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/inline/MethodInliner.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/inline/MethodInliner.java @@ -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 : " call not corresponds to new call" + owner + " " + name; diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/InlineMarker.java b/core/runtime.jvm/src/kotlin/jvm/internal/InlineMarker.java new file mode 100644 index 00000000000..58d5cd62169 --- /dev/null +++ b/core/runtime.jvm/src/kotlin/jvm/internal/InlineMarker.java @@ -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() { + + } + +} \ No newline at end of file