50
50
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
51
51
import com .oracle .graal .python .builtins .modules .MathGuards ;
52
52
import com .oracle .graal .python .builtins .objects .PNone ;
53
+ import com .oracle .graal .python .builtins .objects .common .SequenceStorageNodes .ListGeneralizationNode ;
53
54
import com .oracle .graal .python .builtins .objects .ints .PInt ;
54
55
import com .oracle .graal .python .builtins .objects .list .PList ;
55
56
import com .oracle .graal .python .builtins .objects .slice .PSlice ;
@@ -467,14 +468,16 @@ Object doGeneric(Object object) {
467
468
@ ImportStatic ({PGuards .class , SpecialMethodNames .class })
468
469
public abstract static class SetSliceNode extends PBaseNode {
469
470
471
+ @ Child private ListGeneralizationNode genNode ;
472
+
470
473
public abstract PNone execute (PList list , PSlice slice , Object value );
471
474
472
475
@ Specialization (guards = {"isPTuple(value)" , "isEmptyStorage(list)" })
473
476
public PNone doPListEmptyTupleValue (PList list , PSlice slice , PSequence value ,
474
477
@ Cached ("createBinaryProfile()" ) ConditionProfile wrongLength ) {
475
478
if (value .len () > 0 ) {
476
479
PList pvalue = factory ().createList (((PTuple ) value ).getArray ());
477
- SequenceStorage newStorage = list . getSequenceStorage ().generalizeFor ( pvalue .getSequenceStorage (). getIndicativeValue () , pvalue .getSequenceStorage ());
480
+ SequenceStorage newStorage = getGenNode ().execute ( list .getSequenceStorage (), pvalue .getSequenceStorage (). getIndicativeValue ());
478
481
list .setSequenceStorage (newStorage );
479
482
setSlice (list , slice , pvalue , wrongLength );
480
483
}
@@ -493,7 +496,7 @@ public PNone doPListTupleValue(PList list, PSlice slice, PSequence value,
493
496
public PNone doPListEmpty (PList list , PSlice slice , PSequence value ,
494
497
@ Cached ("createBinaryProfile()" ) ConditionProfile wrongLength ) {
495
498
if (value .len () > 0 ) {
496
- SequenceStorage newStorage = list . getSequenceStorage ().generalizeFor ( value .getSequenceStorage (). getIndicativeValue () , value .getSequenceStorage ());
499
+ SequenceStorage newStorage = getGenNode ().execute ( list .getSequenceStorage (), value .getSequenceStorage (). getIndicativeValue ());
497
500
list .setSequenceStorage (newStorage );
498
501
setSlice (list , slice , value , wrongLength );
499
502
}
@@ -511,7 +514,7 @@ public PNone doPListInt(PList list, PSlice slice, PSequence value,
511
514
@ Specialization (guards = {"!areTheSameType(list, value)" })
512
515
public PNone doPList (PList list , PSlice slice , PSequence value ,
513
516
@ Cached ("createBinaryProfile()" ) ConditionProfile wrongLength ) {
514
- SequenceStorage newStorage = list . getSequenceStorage ().generalizeFor ( value .getSequenceStorage (). getIndicativeValue () , value .getSequenceStorage ());
517
+ SequenceStorage newStorage = getGenNode ().execute ( list .getSequenceStorage (), value .getSequenceStorage (). getIndicativeValue ());
515
518
list .setSequenceStorage (newStorage );
516
519
setSlice (list , slice , value , wrongLength );
517
520
return PNone .NONE ;
@@ -542,7 +545,7 @@ private void canGeneralize(PList list, PSlice slice, PSequence value, ConditionP
542
545
try {
543
546
setSlice (list , slice , value , wrongLength );
544
547
} catch (SequenceStoreException e ) {
545
- SequenceStorage newStorage = list . getSequenceStorage ().generalizeFor ( value .getSequenceStorage (). getIndicativeValue () , value .getSequenceStorage ());
548
+ SequenceStorage newStorage = getGenNode ().execute ( list .getSequenceStorage (), value .getSequenceStorage (). getIndicativeValue ());
546
549
list .setSequenceStorage (newStorage );
547
550
try {
548
551
setSlice (list , slice , value , wrongLength );
@@ -552,6 +555,14 @@ private void canGeneralize(PList list, PSlice slice, PSequence value, ConditionP
552
555
}
553
556
}
554
557
558
+ private ListGeneralizationNode getGenNode () {
559
+ if (genNode == null ) {
560
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
561
+ genNode = insert (ListGeneralizationNode .create ());
562
+ }
563
+ return genNode ;
564
+ }
565
+
555
566
private void setSlice (PSequence list , PSlice slice , PSequence value , ConditionProfile wrongLength ) {
556
567
SequenceStorage store = list .getSequenceStorage ();
557
568
PSlice .SliceInfo sinfo = slice .computeActualIndices (store .length ());
0 commit comments