27
27
import com .oracle .truffle .api .nodes .ExplodeLoop ;
28
28
import com .oracle .truffle .api .nodes .ExplodeLoop .LoopExplosionKind ;
29
29
import com .oracle .truffle .api .nodes .Node ;
30
- import com .oracle .truffle .api .profiles .BranchProfile ;
31
30
import com .oracle .truffle .api .profiles .InlinedBranchProfile ;
32
31
import com .oracle .truffle .api .profiles .InlinedConditionProfile ;
33
32
import com .oracle .truffle .api .profiles .LoopConditionProfile ;
41
40
import org .truffleruby .core .hash .CompareHashKeysNode ;
42
41
import org .truffleruby .core .hash .Entry ;
43
42
import org .truffleruby .core .hash .FreezeHashKeyIfNeededNode ;
44
- import org .truffleruby .core .hash .FreezeHashKeyIfNeededNodeGen ;
45
43
import org .truffleruby .core .hash .HashGuards ;
46
44
import org .truffleruby .core .hash .HashLiteralNode ;
47
45
import org .truffleruby .core .hash .HashingNodes ;
52
50
import org .truffleruby .language .dispatch .DispatchNode ;
53
51
import org .truffleruby .language .objects .shared .PropagateSharingNode ;
54
52
import org .truffleruby .language .objects .shared .SharedObjects ;
53
+ import org .truffleruby .core .hash .library .PackedHashStoreLibraryFactory .SmallHashLiteralNodeGen ;
55
54
56
55
@ ExportLibrary (value = HashStoreLibrary .class , receiverType = Object [].class )
57
56
@ GenerateUncached
@@ -481,21 +480,21 @@ protected boolean equalKeys(CompareHashKeysNode compareHashKeys, boolean compare
481
480
}
482
481
}
483
482
484
- public static class SmallHashLiteralNode extends HashLiteralNode {
483
+ public abstract static class SmallHashLiteralNode extends HashLiteralNode {
485
484
486
485
@ Child private HashingNodes .ToHashByHashCode hashNode ;
487
486
@ Child private DispatchNode equalNode ;
488
487
@ Child private BooleanCastNode booleanCastNode ;
489
- @ Child private FreezeHashKeyIfNeededNode freezeHashKeyIfNeededNode = FreezeHashKeyIfNeededNodeGen .create ();
490
- private final BranchProfile duplicateKeyProfile = BranchProfile .create ();
491
488
492
489
public SmallHashLiteralNode (RubyNode [] keyValues ) {
493
490
super (keyValues );
494
491
}
495
492
493
+ @ Specialization
496
494
@ ExplodeLoop
497
- @ Override
498
- public Object execute (VirtualFrame frame ) {
495
+ protected Object doHash (VirtualFrame frame ,
496
+ @ Cached InlinedBranchProfile duplicateKeyProfile ,
497
+ @ Cached FreezeHashKeyIfNeededNode freezeHashKeyIfNeededNode ) {
499
498
final Object [] store = createStore ();
500
499
int size = 0 ;
501
500
@@ -512,7 +511,7 @@ public Object execute(VirtualFrame frame) {
512
511
if (i < size &&
513
512
hashed == getHashed (store , i ) &&
514
513
callEqual (key , getKey (store , i ))) {
515
- duplicateKeyProfile .enter ();
514
+ duplicateKeyProfile .enter (this );
516
515
setKey (store , i , key );
517
516
setValue (store , i , value );
518
517
duplicateKey = true ;
@@ -559,7 +558,7 @@ private boolean callEqual(Object receiver, Object key) {
559
558
560
559
@ Override
561
560
public RubyNode cloneUninitialized () {
562
- var copy = new SmallHashLiteralNode (cloneUninitialized (keyValues ));
561
+ var copy = SmallHashLiteralNodeGen . create (cloneUninitialized (keyValues ));
563
562
return copy .copyFlags (this );
564
563
}
565
564
0 commit comments