performance optimizations:
- classes for object/class object and function literals are final - class objects call own methods via this in oppose to static field in parent
This commit is contained in:
@@ -90,7 +90,7 @@ public class ClosureCodegen extends GenerationStateAware {
|
||||
|
||||
cv.defineClass(fun,
|
||||
V1_6,
|
||||
ACC_PUBLIC/*|ACC_SUPER*/,
|
||||
ACC_PUBLIC|ACC_FINAL/*|ACC_SUPER*/,
|
||||
name.getInternalName(),
|
||||
null,
|
||||
funClass.getInternalName(),
|
||||
|
||||
@@ -1864,14 +1864,13 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
ClassReceiver classReceiver = (ClassReceiver) descriptor;
|
||||
ClassDescriptor classReceiverDeclarationDescriptor = classReceiver.getDeclarationDescriptor();
|
||||
if (DescriptorUtils.isClassObject(classReceiverDeclarationDescriptor)) {
|
||||
ClassDescriptor containingDeclaration = (ClassDescriptor) classReceiverDeclarationDescriptor.getContainingDeclaration();
|
||||
Type classObjType = typeMapper.mapType(containingDeclaration.getDefaultType(), JetTypeMapperMode.IMPL);
|
||||
if (context.getContextDescriptor() instanceof ConstructorDescriptor &&
|
||||
classReceiverDeclarationDescriptor.getDefaultType()
|
||||
.equals(((ConstructorDescriptor) context.getContextDescriptor()).getReturnType())) {
|
||||
v.load(0, classObjType);
|
||||
if (context.getContextDescriptor() instanceof FunctionDescriptor &&
|
||||
classReceiverDeclarationDescriptor == context.getContextDescriptor().getContainingDeclaration()) {
|
||||
v.load(0, OBJECT_TYPE);
|
||||
}
|
||||
else {
|
||||
ClassDescriptor containingDeclaration = (ClassDescriptor) classReceiverDeclarationDescriptor.getContainingDeclaration();
|
||||
Type classObjType = typeMapper.mapType(containingDeclaration.getDefaultType(), JetTypeMapperMode.IMPL);
|
||||
v.getstatic(classObjType.getInternalName(), "$classobj", exprType.getDescriptor());
|
||||
}
|
||||
StackValue.onStack(exprType).put(type, v);
|
||||
|
||||
@@ -107,6 +107,10 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
isEnum = true;
|
||||
}
|
||||
|
||||
if(descriptor.getKind() == ClassKind.OBJECT || descriptor.getKind() == ClassKind.CLASS_OBJECT) {
|
||||
isFinal = true;
|
||||
}
|
||||
|
||||
if (!jetClass.hasModifier(JetTokens.OPEN_KEYWORD) && !isAbstract) {
|
||||
isFinal = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user