@@ -283,35 +283,40 @@ Object doGeneric(VirtualFrame frame, Object object) {
283
283
*/
284
284
@ GenerateUncached
285
285
public abstract static class AppendNode extends PNodeWithContext {
286
+ private static final BranchProfile [] DISABLED = new BranchProfile [] { BranchProfile .getUncached () };
286
287
287
288
public abstract void execute (PList list , Object value );
288
289
289
- protected static boolean [] flagContainer (boolean flag ) {
290
- boolean [] container = new boolean [1 ];
291
- container [0 ] = flag ;
292
- return container ;
290
+ static BranchProfile [] getUpdateStoreProfile () {
291
+ return new BranchProfile [1 ];
292
+ }
293
+
294
+ static BranchProfile [] getUpdateStoreProfileUncached () {
295
+ return DISABLED ;
293
296
}
294
297
295
298
@ Specialization
296
299
public void appendObjectGeneric (PList list , Object value ,
297
- @ Cached SequenceStorageNodes .AppendNode appendInInterpreterNode ,
298
300
@ Cached SequenceStorageNodes .AppendNode appendNode ,
299
- @ Cached (value = "flagContainer(false)" , uncached = "flagContainer(true)" , dimensions = 1 ) boolean [] triedToCompile ,
300
- @ Cached BranchProfile updateStoreProfile ) {
301
- if (CompilerDirectives .inInterpreter () && !triedToCompile [0 ] && list .getOrigin () != null ) {
302
- SequenceStorage newStore = appendInInterpreterNode .execute (list .getSequenceStorage (), value , ListGeneralizationNode .SUPPLIER );
301
+ @ Cached (value = "getUpdateStoreProfile()" , uncached = "getUpdateStoreProfileUncached()" , dimensions = 1 ) BranchProfile [] updateStoreProfile ) {
302
+ if (updateStoreProfile [0 ] == null ) {
303
+ // Executed for the first time. We don't pollute the AppendNode specializations,
304
+ // yet, in case we're transitioning exactly once, because we'll pontentially pass
305
+ // that information on to the list origin and it'll never happen again.
306
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
307
+ SequenceStorage newStore = SequenceStorageNodes .AppendNode .getUncached ().execute (list .getSequenceStorage (), value , ListGeneralizationNode .SUPPLIER );
308
+ updateStoreProfile [0 ] = BranchProfile .create ();
303
309
list .setSequenceStorage (newStore );
304
310
if (list .getOrigin () != null && newStore instanceof BasicSequenceStorage ) {
305
311
list .getOrigin ().reportUpdatedCapacity ((BasicSequenceStorage ) newStore );
306
312
}
307
313
} else {
308
- if (!triedToCompile [0 ]) {
309
- CompilerDirectives .transferToInterpreterAndInvalidate ();
310
- triedToCompile [0 ] = true ;
311
- }
312
314
SequenceStorage newStore = appendNode .execute (list .getSequenceStorage (), value , ListGeneralizationNode .SUPPLIER );
313
- if (list .getSequenceStorage () != newStore ) {
314
- updateStoreProfile .enter ();
315
+ if (CompilerDirectives .inInterpreter () && list .getOrigin () != null && newStore instanceof BasicSequenceStorage ) {
316
+ list .setSequenceStorage (newStore );
317
+ list .getOrigin ().reportUpdatedCapacity ((BasicSequenceStorage ) newStore );
318
+ } else if (list .getSequenceStorage () != newStore ) {
319
+ updateStoreProfile [0 ].enter ();
315
320
list .setSequenceStorage (newStore );
316
321
}
317
322
}
0 commit comments