@@ -3968,10 +3968,6 @@ static boolean isObjectSequenceStorage(SequenceStorage s) {
39683968 @ ImportStatic (PInt .class )
39693969 public abstract static class InsertItemArrayBasedStorageNode extends Node {
39703970
3971- public static SequenceStorage executeUncached (ArrayBasedSequenceStorage storage , int index , Object value ) {
3972- return SequenceStorageNodesFactory .InsertItemArrayBasedStorageNodeGen .getUncached ().execute (null , storage , index , value );
3973- }
3974-
39753971 protected abstract SequenceStorage execute (Node inliningTarget , ArrayBasedSequenceStorage storage , int index , Object value );
39763972
39773973 @ Specialization
@@ -4037,6 +4033,40 @@ static SequenceStorage doGeneralization(Node inliningTarget, ArrayBasedSequenceS
40374033 }
40384034 }
40394035
4036+ @ GenerateUncached
4037+ @ GenerateInline
4038+ public abstract static class InsertItemNativePrimitiveBasedStorageNode extends Node {
4039+ protected abstract SequenceStorage execute (Node inliningTarget , NativePrimitiveSequenceStorage storage , int index , Object value );
4040+
4041+ @ Specialization
4042+ static SequenceStorage doIntStorage (Node inliningTarget , NativeIntSequenceStorage storage , int index , int value ,
4043+ @ Cached EnsureCapacityNode ensureCapacity ) {
4044+ int length = storage .length ();
4045+ var context = PythonContext .get (inliningTarget );
4046+ var unsafe = context .getUnsafe ();
4047+ long itemSize = storage .getItemSize ();
4048+ ensureCapacity .execute (inliningTarget , storage , length + 1 );
4049+ // shifting tail to the right by one slot
4050+ long startAddr = storage .getValueBufferAddr () + (index * itemSize );
4051+ long endAddr = startAddr + itemSize ;
4052+ long sizeInBytes = (length - index ) * itemSize ;
4053+ unsafe .copyMemory (startAddr , endAddr , sizeInBytes );
4054+
4055+ storage .setIntItemNormalized (index , value );
4056+ storage .incLength ();
4057+ return storage ;
4058+ }
4059+
4060+ @ Fallback
4061+ static SequenceStorage doGeneralization (Node inliningTarget , NativePrimitiveSequenceStorage storage , int idx , Object value ,
4062+ @ Cached GetInternalObjectArrayNode getInternalObjectArrayNode ) {
4063+ Object [] values = getInternalObjectArrayNode .execute (inliningTarget , storage );
4064+ ObjectSequenceStorage newStorage = new ObjectSequenceStorage (values );
4065+ newStorage .insertItem (idx , value );
4066+ return newStorage ;
4067+ }
4068+ }
4069+
40404070 @ GenerateUncached
40414071 @ GenerateInline
40424072 @ GenerateCached (false )
@@ -4062,24 +4092,10 @@ static SequenceStorage doArrayBasedStorage(Node inliningTarget, ArrayBasedSequen
40624092
40634093 }
40644094
4065- // TODO introduce something similar to InsertItemArrayBasedStorageNode
40664095 @ Specialization
4067- static SequenceStorage doNativeInt (Node inliningTarget , NativeIntSequenceStorage storage , int index , int value ,
4068- @ Exclusive @ Cached EnsureCapacityNode ensureCapacity ) {
4069- int length = storage .length ();
4070- var context = PythonContext .get (inliningTarget );
4071- var unsafe = context .getUnsafe ();
4072- long itemSize = storage .getItemSize ();
4073- ensureCapacity .execute (inliningTarget , storage , length + 1 );
4074- // shifting tail to the right by one slot
4075- long startAddr = storage .getValueBufferAddr () + (index * itemSize );
4076- long endAddr = startAddr + itemSize ;
4077- long sizeInBytes = (length - index ) * itemSize ;
4078- unsafe .copyMemory (startAddr , endAddr , sizeInBytes );
4079-
4080- storage .setIntItemNormalized (index , value );
4081- storage .incLength ();
4082- return storage ;
4096+ static SequenceStorage doNativeStorage (Node inliningTarget , NativeIntSequenceStorage storage , int index , Object value ,
4097+ @ Cached InsertItemNativePrimitiveBasedStorageNode insertNativeStorageNode ) {
4098+ return insertNativeStorageNode .execute (inliningTarget , storage , index , value );
40834099 }
40844100
40854101 @ Specialization
0 commit comments