diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index 055b8c6d192..7285d999718 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -2125,7 +2125,7 @@ public class ExpressionCodegen extends JetVisitor implem CallableDescriptor descriptor = resolvedCall.getResultingDescriptor(); boolean isInline = call != null && descriptor instanceof SimpleFunctionDescriptor && ((SimpleFunctionDescriptor) descriptor).getInlineStrategy().isInline(); Inliner inliner = !isInline ? Inliner.NOT_INLINE : - new InlineCodegen(this, true, state, disable, (SimpleFunctionDescriptor) unwrapFakeOverride( + new InlineCodegen(this, state, (SimpleFunctionDescriptor) unwrapFakeOverride( (CallableMemberDescriptor) descriptor.getOriginal()), call); if (resolvedCall instanceof VariableAsFunctionResolvedCall) { diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/asm/InlineCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/asm/InlineCodegen.java index 5a602e9bf1f..8edf7b4903a 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/asm/InlineCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/asm/InlineCodegen.java @@ -44,6 +44,7 @@ import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContextUtils; import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants; +import org.jetbrains.jet.lang.types.lang.InlineStrategy; import org.jetbrains.jet.lang.types.lang.InlineUtil; import org.jetbrains.jet.renderer.DescriptorRenderer; @@ -62,12 +63,10 @@ public class InlineCodegen implements ParentCodegenAware, Inliner { private final ExpressionCodegen codegen; - private final boolean notSeparateInline; + private final boolean asFunctionInline; private final GenerationState state; - private final boolean disabled; - private final Call call; private final SimpleFunctionDescriptor functionDescriptor; @@ -90,18 +89,15 @@ public class InlineCodegen implements ParentCodegenAware, Inliner { public InlineCodegen( @NotNull ExpressionCodegen codegen, - boolean notSeparateInline, @NotNull GenerationState state, - boolean disabled, @NotNull SimpleFunctionDescriptor functionDescriptor, @NotNull Call call ) { + assert functionDescriptor.getInlineStrategy().isInline() : "InlineCodegen could inline only inline function but " + functionDescriptor; + this.state = state; this.typeMapper = state.getTypeMapper(); - this.codegen = codegen; - this.notSeparateInline = notSeparateInline; - this.disabled = disabled; this.call = call; this.functionDescriptor = functionDescriptor.getOriginal(); bindingContext = codegen.getBindingContext(); @@ -110,6 +106,10 @@ public class InlineCodegen implements ParentCodegenAware, Inliner { context = (MethodContext) getContext(functionDescriptor, state); originalFunctionFrame = context.prepareFrame(typeMapper); jvmSignature = typeMapper.mapSignature(functionDescriptor, context.getContextKind()); + + InlineStrategy inlineStrategy = + codegen.getContext().isInlineFunction() ? InlineStrategy.IN_PLACE : functionDescriptor.getInlineStrategy(); + this.asFunctionInline = false; } @@ -244,7 +244,7 @@ public class InlineCodegen implements ParentCodegenAware, Inliner { public void putCapturedInLocal( @NotNull Type type, @Nullable StackValue stackValue, @Nullable ValueParameterDescriptor valueParameterDescriptor, int index ) { - if (!disabled && notSeparateInline && Type.VOID_TYPE != type) { + if (!asFunctionInline && Type.VOID_TYPE != type) { //TODO remap only inlinable closure => otherwise we could get a lot of problem boolean couldBeRemapped = !shouldPutValue(type, stackValue, codegen.getContext(), valueParameterDescriptor); StackValue remappedIndex = couldBeRemapped ? stackValue : null; @@ -364,14 +364,9 @@ public class InlineCodegen implements ParentCodegenAware, Inliner { } } - public boolean isDisabled() { - return disabled; - } - @Override public boolean isInliningClosure(JetExpression expression, ValueParameterDescriptor valueParameterDescriptora) { - return !disabled && - expression instanceof JetFunctionLiteralExpression && + return expression instanceof JetFunctionLiteralExpression && !InlineUtil.hasNoinlineAnnotation(valueParameterDescriptora); }