Shared var initialization moved to variable declaration generation

This commit is contained in:
Svetlana Isakova
2012-08-20 21:53:54 +04:00
parent 6527df3be1
commit a7636f7b74
2 changed files with 12 additions and 9 deletions
@@ -935,7 +935,14 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
final Type sharedVarType = typeMapper.getSharedVarType(variableDescriptor); final Type sharedVarType = typeMapper.getSharedVarType(variableDescriptor);
final Type type = sharedVarType != null ? sharedVarType : asmType(variableDescriptor.getType()); final Type type = sharedVarType != null ? sharedVarType : asmType(variableDescriptor.getType());
myFrameMap.enter(variableDescriptor, type.getSize()); int index = myFrameMap.enter(variableDescriptor, type.getSize());
if (sharedVarType != null) {
v.anew(sharedVarType);
v.dup();
v.invokespecial(sharedVarType.getInternalName(), "<init>", "()V");
v.store(index, TYPE_OBJECT);
}
leaveTasks.add(new Function<StackValue, Void>() { leaveTasks.add(new Function<StackValue, Void>() {
@Override @Override
@@ -2578,12 +2585,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
assert variableDescriptor != null; assert variableDescriptor != null;
Type varType = asmType(variableDescriptor.getType()); Type varType = asmType(variableDescriptor.getType());
if (sharedVarType != null) {
v.anew(sharedVarType);
v.dup();
v.invokespecial(sharedVarType.getInternalName(), "<init>", "()V");
v.store(index, TYPE_OBJECT);
}
JetExpression initializer = property.getInitializer(); JetExpression initializer = property.getInitializer();
if (initializer != null) { if (initializer != null) {
@@ -34,10 +34,12 @@ public class FrameMap {
private final TObjectIntHashMap<DeclarationDescriptor> myVarSizes = new TObjectIntHashMap<DeclarationDescriptor>(); private final TObjectIntHashMap<DeclarationDescriptor> myVarSizes = new TObjectIntHashMap<DeclarationDescriptor>();
private int myMaxIndex = 0; private int myMaxIndex = 0;
public void enter(DeclarationDescriptor descriptor, int size) { public int enter(DeclarationDescriptor descriptor, int size) {
myVarIndex.put(descriptor, myMaxIndex); int index = myMaxIndex;
myVarIndex.put(descriptor, index);
myMaxIndex += size; myMaxIndex += size;
myVarSizes.put(descriptor, size); myVarSizes.put(descriptor, size);
return index;
} }
public int leave(DeclarationDescriptor descriptor) { public int leave(DeclarationDescriptor descriptor) {