Addded inline closure flag
This commit is contained in:
@@ -1717,6 +1717,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
StackValue value = context.lookupInContext(descriptor, StackValue.local(0, OBJECT_TYPE), state, false);
|
||||
if (value != null) {
|
||||
if (context.isSpecialStackValue(value) != null) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (value instanceof StackValue.Composed) {
|
||||
StackValue.Composed composed = (StackValue.Composed) value;
|
||||
|
||||
@@ -212,6 +212,7 @@ public class InlineCodegen implements ParentCodegenAware, Inliner {
|
||||
MethodContext parentContext = codegen.getContext();
|
||||
|
||||
MethodContext context = parentContext.intoClosure(descriptor, codegen, typeMapper).intoFunction(descriptor);
|
||||
context.setInlineClosure(true);
|
||||
|
||||
JvmMethodSignature jvmMethodSignature = typeMapper.mapSignature(descriptor);
|
||||
Method asmMethod = jvmMethodSignature.getAsmMethod();
|
||||
@@ -271,7 +272,7 @@ public class InlineCodegen implements ParentCodegenAware, Inliner {
|
||||
boolean shouldPut = false == (stackValue != null && stackValue instanceof StackValue.Local);
|
||||
if (shouldPut) {
|
||||
//we could recapture field of anonymous objects cause they couldn't change
|
||||
if ((stackValue instanceof StackValue.Extension || stackValue instanceof StackValue.Field) && codegen.getContext().getContextDescriptor() instanceof AnonymousFunctionDescriptor) {
|
||||
if ((stackValue instanceof StackValue.Composed || stackValue instanceof StackValue.Field) && codegen.getContext().getContextDescriptor() instanceof AnonymousFunctionDescriptor) {
|
||||
if (descriptor != null && !InlineUtil.hasNoinlineAnnotation(descriptor)) {
|
||||
//check type of context
|
||||
return false;
|
||||
|
||||
@@ -30,6 +30,16 @@ public class MethodContext extends CodegenContext<CallableMemberDescriptor> {
|
||||
|
||||
private Label methodStartLabel;
|
||||
|
||||
private boolean isInlineClosure;
|
||||
|
||||
public MethodContext(
|
||||
@NotNull FunctionDescriptor contextType,
|
||||
@NotNull OwnerKind contextKind,
|
||||
@NotNull CodegenContext parentContext
|
||||
) {
|
||||
this(contextType, contextKind, parentContext, null);
|
||||
}
|
||||
|
||||
protected MethodContext(
|
||||
@NotNull FunctionDescriptor contextDescriptor,
|
||||
@NotNull OwnerKind contextKind,
|
||||
@@ -85,4 +95,22 @@ public class MethodContext extends CodegenContext<CallableMemberDescriptor> {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setInlineClosure(boolean isInlineClosure) {
|
||||
this.isInlineClosure = isInlineClosure;
|
||||
}
|
||||
|
||||
public StackValue isSpecialStackValue(StackValue stackValue) {
|
||||
if (isInlineClosure && stackValue instanceof StackValue.Composed) {
|
||||
StackValue prefix = ((StackValue.Composed) stackValue).prefix;
|
||||
StackValue suffix = ((StackValue.Composed) stackValue).suffix;
|
||||
if (prefix instanceof StackValue.Local && ((StackValue.Local) prefix).index == 0) {
|
||||
if (suffix instanceof StackValue.Field) {
|
||||
StackValue.Field field = (StackValue.Field) suffix;
|
||||
return StackValue.field(field.type, field.owner, field.name, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user