Skip to content

Commit 351ae11

Browse files
committed
Use 'ListGeneralizationNode' instead of 'storage.generalizeFor'.
1 parent 02c5cee commit 351ae11

File tree

1 file changed

+15
-4
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins

1 file changed

+15
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/ListNodes.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
5151
import com.oracle.graal.python.builtins.modules.MathGuards;
5252
import com.oracle.graal.python.builtins.objects.PNone;
53+
import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.ListGeneralizationNode;
5354
import com.oracle.graal.python.builtins.objects.ints.PInt;
5455
import com.oracle.graal.python.builtins.objects.list.PList;
5556
import com.oracle.graal.python.builtins.objects.slice.PSlice;
@@ -467,14 +468,16 @@ Object doGeneric(Object object) {
467468
@ImportStatic({PGuards.class, SpecialMethodNames.class})
468469
public abstract static class SetSliceNode extends PBaseNode {
469470

471+
@Child private ListGeneralizationNode genNode;
472+
470473
public abstract PNone execute(PList list, PSlice slice, Object value);
471474

472475
@Specialization(guards = {"isPTuple(value)", "isEmptyStorage(list)"})
473476
public PNone doPListEmptyTupleValue(PList list, PSlice slice, PSequence value,
474477
@Cached("createBinaryProfile()") ConditionProfile wrongLength) {
475478
if (value.len() > 0) {
476479
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());
478481
list.setSequenceStorage(newStorage);
479482
setSlice(list, slice, pvalue, wrongLength);
480483
}
@@ -493,7 +496,7 @@ public PNone doPListTupleValue(PList list, PSlice slice, PSequence value,
493496
public PNone doPListEmpty(PList list, PSlice slice, PSequence value,
494497
@Cached("createBinaryProfile()") ConditionProfile wrongLength) {
495498
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());
497500
list.setSequenceStorage(newStorage);
498501
setSlice(list, slice, value, wrongLength);
499502
}
@@ -511,7 +514,7 @@ public PNone doPListInt(PList list, PSlice slice, PSequence value,
511514
@Specialization(guards = {"!areTheSameType(list, value)"})
512515
public PNone doPList(PList list, PSlice slice, PSequence value,
513516
@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());
515518
list.setSequenceStorage(newStorage);
516519
setSlice(list, slice, value, wrongLength);
517520
return PNone.NONE;
@@ -542,7 +545,7 @@ private void canGeneralize(PList list, PSlice slice, PSequence value, ConditionP
542545
try {
543546
setSlice(list, slice, value, wrongLength);
544547
} catch (SequenceStoreException e) {
545-
SequenceStorage newStorage = list.getSequenceStorage().generalizeFor(value.getSequenceStorage().getIndicativeValue(), value.getSequenceStorage());
548+
SequenceStorage newStorage = getGenNode().execute(list.getSequenceStorage(), value.getSequenceStorage().getIndicativeValue());
546549
list.setSequenceStorage(newStorage);
547550
try {
548551
setSlice(list, slice, value, wrongLength);
@@ -552,6 +555,14 @@ private void canGeneralize(PList list, PSlice slice, PSequence value, ConditionP
552555
}
553556
}
554557

558+
private ListGeneralizationNode getGenNode() {
559+
if (genNode == null) {
560+
CompilerDirectives.transferToInterpreterAndInvalidate();
561+
genNode = insert(ListGeneralizationNode.create());
562+
}
563+
return genNode;
564+
}
565+
555566
private void setSlice(PSequence list, PSlice slice, PSequence value, ConditionProfile wrongLength) {
556567
SequenceStorage store = list.getSequenceStorage();
557568
PSlice.SliceInfo sinfo = slice.computeActualIndices(store.length());

0 commit comments

Comments
 (0)