@@ -160,14 +160,6 @@ private static int indexPosToValuePos(int[] index, int indexPos) {
160
160
return index [indexPos + 1 ];
161
161
}
162
162
163
- // For promoting from packed to compact
164
- public void putHashKeyValue (int hashcode , Object key , Object value ) {
165
- int pos = kvStoreInsertionPos ;
166
- SetKvAtNode .insertIntoKv (this , key , value );
167
- SetKvAtNode .insertIntoIndex (hashcode , pos + 1 , index ,
168
- InlinedLoopConditionProfile .getUncached (), null );
169
- }
170
-
171
163
@ ExportMessage
172
164
Object lookupOrDefault (Frame frame , RubyHash hash , Object key , PEBiFunction defaultNode ,
173
165
@ Cached @ Shared GetIndexPosForKeyNode getIndexPosForKeyNode ,
@@ -586,7 +578,7 @@ static boolean keyDoesntExist(
586
578
}
587
579
588
580
keyPos = store .kvStoreInsertionPos ;
589
- insertIntoKv (store , key , value );
581
+ insertIntoKv (store , keyPos , key , value );
590
582
591
583
assert store .index [indexPos + 1 ] <= 0 ;
592
584
store .index [indexPos ] = keyHash ;
@@ -596,43 +588,42 @@ static boolean keyDoesntExist(
596
588
597
589
if (indexResizingIsNeeded .profile (node , hash .size >= store .indexGrowthThreshold )) {
598
590
// Resize the index array after insertion, as it invalidates indexPos
599
- resizeIndex (store , node );
591
+ resizeIndex (store );
600
592
}
601
593
602
594
return true ;
603
595
}
604
596
605
- private static void insertIntoIndex (int keyHash , int kvPos , int [] index ,
606
- InlinedLoopConditionProfile unavailableSlot , Node node ) {
607
- int pos = indexPosFromHashCode (keyHash , index .length );
597
+ private static void insertIntoIndex (int hashCode , int valuePos , int [] index ) {
598
+ int pos = indexPosFromHashCode (hashCode , index .length );
608
599
609
- while (unavailableSlot . profile ( node , index [pos + 1 ] > INDEX_SLOT_UNUSED ) ) {
600
+ while (index [pos + 1 ] > INDEX_SLOT_UNUSED ) {
610
601
pos = incrementIndexPos (pos , index .length );
611
602
}
612
603
613
- index [pos ] = keyHash ;
614
- index [pos + 1 ] = kvPos ;
604
+ index [pos ] = hashCode ;
605
+ index [pos + 1 ] = valuePos ;
615
606
}
616
607
617
- private static void insertIntoKv (CompactHashStore store , Object key , Object value ) {
618
- store .kvStore [store . kvStoreInsertionPos ] = key ;
619
- store .kvStore [store . kvStoreInsertionPos + 1 ] = value ;
620
- store .kvStoreInsertionPos += 2 ;
608
+ private static void insertIntoKv (CompactHashStore store , int keyPos , Object key , Object value ) {
609
+ store .kvStore [keyPos ] = key ;
610
+ store .kvStore [keyPos + 1 ] = value ;
611
+ store .kvStoreInsertionPos = keyPos + 2 ;
621
612
}
622
613
623
614
@ TruffleBoundary
624
- private static void resizeIndex (CompactHashStore store , Node node ) {
615
+ private static void resizeIndex (CompactHashStore store ) {
625
616
int [] oldIndex = store .index ;
626
617
int [] newIndex = new int [2 * oldIndex .length ];
627
618
int newIndexCapacity = newIndex .length >> 1 ;
628
619
629
620
int i = 0 ;
630
621
for (; i < oldIndex .length ; i += 2 ) {
631
622
int hash = oldIndex [i ];
632
- int kvPos = oldIndex [i + 1 ];
623
+ int valuePos = oldIndex [i + 1 ];
633
624
634
- if (kvPos > INDEX_SLOT_UNUSED ) {
635
- insertIntoIndex (hash , kvPos , newIndex , InlinedLoopConditionProfile . getUncached (), node );
625
+ if (valuePos > INDEX_SLOT_UNUSED ) {
626
+ insertIntoIndex (hash , valuePos , newIndex );
636
627
}
637
628
}
638
629
@@ -645,6 +636,14 @@ private static void resizeKvStore(CompactHashStore store) {
645
636
}
646
637
}
647
638
639
+ /** For promoting from packed to compact */
640
+ void insertHashKeyValue (int hashCode , Object key , Object value ) {
641
+ int keyPos = kvStoreInsertionPos ;
642
+ int valuePos = keyPos + 1 ;
643
+ SetKvAtNode .insertIntoKv (this , keyPos , key , value );
644
+ SetKvAtNode .insertIntoIndex (hashCode , valuePos , index );
645
+ }
646
+
648
647
public static final class CompactHashLiteralNode extends HashLiteralNode {
649
648
650
649
@ Child HashStoreLibrary hashes ;
0 commit comments