KT-37024 Optimized delegated property metadata generation in inline fun
This commit is contained in:
@@ -4587,10 +4587,16 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
// We can use the $$delegatedProperties array as in non-inline functions and upon inlining, detect elements at what indices
|
||||
// of that array are used in the inline function body, load the corresponding initializing bytecode from <clinit> of the
|
||||
// container class (where the PropertyReferenceNImpl instance is created), copy and adapt it at the call site
|
||||
//noinspection ConstantConditions
|
||||
StackValue value = context.getFunctionDescriptor().isInline()
|
||||
? generatePropertyReference(variable.getDelegate(), variableDescriptor, variableDescriptor, null)
|
||||
: PropertyCodegen.getDelegatedPropertyMetadata(variableDescriptor, bindingContext);
|
||||
StackValue value;
|
||||
if (PropertyCodegen.isDelegatedPropertyWithOptimizedMetadata(variableDescriptor, bindingContext)) {
|
||||
value = PropertyCodegen.getOptimizedDelegatedPropertyMetadataValue();
|
||||
} else if (context.getFunctionDescriptor().isInline()) {
|
||||
//noinspection ConstantConditions
|
||||
value = generatePropertyReference(variable.getDelegate(), variableDescriptor, variableDescriptor, null);
|
||||
}
|
||||
else {
|
||||
value = PropertyCodegen.getDelegatedPropertyMetadata(variableDescriptor, bindingContext);
|
||||
}
|
||||
value.put(K_PROPERTY_TYPE, null, v);
|
||||
metadataVar.storeSelector(K_PROPERTY_TYPE, null, v);
|
||||
}
|
||||
|
||||
@@ -564,13 +564,24 @@ public class PropertyCodegen {
|
||||
return codegen.invokeFunction(resolvedCall, receiver);
|
||||
}
|
||||
|
||||
public static boolean isDelegatedPropertyWithOptimizedMetadata(
|
||||
@NotNull VariableDescriptorWithAccessors descriptor,
|
||||
@NotNull BindingContext bindingContext
|
||||
) {
|
||||
return Boolean.TRUE == bindingContext.get(DELEGATED_PROPERTY_WITH_OPTIMIZED_METADATA, descriptor);
|
||||
}
|
||||
|
||||
public static @NotNull StackValue getOptimizedDelegatedPropertyMetadataValue() {
|
||||
return StackValue.constant(null, K_PROPERTY_TYPE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static StackValue getDelegatedPropertyMetadata(
|
||||
@NotNull VariableDescriptorWithAccessors descriptor,
|
||||
@NotNull BindingContext bindingContext
|
||||
) {
|
||||
if (Boolean.TRUE == bindingContext.get(DELEGATED_PROPERTY_WITH_OPTIMIZED_METADATA, descriptor)) {
|
||||
return StackValue.constant(null, K_PROPERTY_TYPE);
|
||||
if (isDelegatedPropertyWithOptimizedMetadata(descriptor, bindingContext)) {
|
||||
return getOptimizedDelegatedPropertyMetadataValue();
|
||||
}
|
||||
|
||||
Type owner = bindingContext.get(DELEGATED_PROPERTY_METADATA_OWNER, descriptor);
|
||||
|
||||
Reference in New Issue
Block a user