@@ -46,7 +46,10 @@ public final class TranslatorEnvironment {
46
46
private EconomicMap <Object , Integer > nameToIndex = EconomicMap .create ();
47
47
private FrameDescriptor .Builder frameDescriptorBuilder ;
48
48
private FrameDescriptor frameDescriptor ;
49
- private final BlockFrameDescriptorInfo blockFrameDescriptorInfo ;
49
+ /** The descriptor info is shared for all blocks at the same level (i.e., for TranslatorEnvironment direct
50
+ * children), in order to save footprint. It is therefore created in the parent TranslatorEnvironment of those
51
+ * blocks using that descriptor info. */
52
+ private final BlockFrameDescriptorInfo descriptorInfoForChildren ;
50
53
51
54
private final List <Integer > flipFlopStates = new ArrayList <>();
52
55
@@ -82,19 +85,18 @@ public TranslatorEnvironment(
82
85
83
86
if (descriptor == null ) {
84
87
if (blockDepth > 0 ) {
85
- BlockFrameDescriptorInfo parentBlockDescriptor = Objects
86
- .requireNonNull (parent .blockFrameDescriptorInfo );
87
- this .frameDescriptorBuilder = newFrameDescriptorBuilderForBlock (parentBlockDescriptor );
88
- this .blockFrameDescriptorInfo = new BlockFrameDescriptorInfo (
89
- parentBlockDescriptor .getSpecialVariableAssumption ());
88
+ BlockFrameDescriptorInfo descriptorInfo = Objects .requireNonNull (parent .descriptorInfoForChildren );
89
+ this .frameDescriptorBuilder = newFrameDescriptorBuilderForBlock (descriptorInfo );
90
+ this .descriptorInfoForChildren = new BlockFrameDescriptorInfo (
91
+ descriptorInfo .getSpecialVariableAssumption ());
90
92
} else {
91
93
var specialVariableAssumption = createSpecialVariableAssumption ();
92
94
this .frameDescriptorBuilder = newFrameDescriptorBuilderForMethod (specialVariableAssumption );
93
- this .blockFrameDescriptorInfo = new BlockFrameDescriptorInfo (specialVariableAssumption );
95
+ this .descriptorInfoForChildren = new BlockFrameDescriptorInfo (specialVariableAssumption );
94
96
}
95
97
} else {
96
98
this .frameDescriptor = descriptor ;
97
- this .blockFrameDescriptorInfo = new BlockFrameDescriptorInfo (descriptor );
99
+ this .descriptorInfoForChildren = new BlockFrameDescriptorInfo (descriptor );
98
100
99
101
assert descriptor .getNumberOfAuxiliarySlots () == 0 ;
100
102
int slots = descriptor .getNumberOfSlots ();
@@ -149,14 +151,9 @@ public boolean isTopLevelObjectScope() {
149
151
}
150
152
151
153
// region frame descriptor
152
- public static FrameDescriptor .Builder newFrameDescriptorBuilderForBlock (BlockFrameDescriptorInfo parentBlockInfo ) {
153
- if (parentBlockInfo == null ) {
154
- throw CompilerDirectives .shouldNotReachHere (
155
- "Frame descriptor for block has to have parent" );
156
- }
157
-
154
+ public static FrameDescriptor .Builder newFrameDescriptorBuilderForBlock (BlockFrameDescriptorInfo descriptorInfo ) {
158
155
var builder = FrameDescriptor .newBuilder ().defaultValue (Nil .INSTANCE );
159
- builder .info (parentBlockInfo );
156
+ builder .info (Objects . requireNonNull ( descriptorInfo ) );
160
157
161
158
int selfIndex = builder .addSlot (FrameSlotKind .Illegal , SelfNode .SELF_IDENTIFIER , null );
162
159
if (selfIndex != SelfNode .SELF_INDEX ) {
@@ -298,7 +295,7 @@ public FrameDescriptor computeFrameDescriptor() {
298
295
}
299
296
300
297
frameDescriptor = frameDescriptorBuilder .build ();
301
- blockFrameDescriptorInfo . set (frameDescriptor );
298
+ descriptorInfoForChildren . setParentDescriptor (frameDescriptor );
302
299
frameDescriptorBuilder = null ;
303
300
nameToIndex = null ;
304
301
return frameDescriptor ;
0 commit comments