15
15
import com .oracle .truffle .api .dsl .Specialization ;
16
16
import com .oracle .truffle .api .nodes .ExplodeLoop ;
17
17
import com .oracle .truffle .api .object .DynamicObject ;
18
- import com .oracle .truffle .api .profiles .BranchProfile ;
19
18
import com .oracle .truffle .api .profiles .ConditionProfile ;
20
19
import org .truffleruby .Layouts ;
21
20
import org .truffleruby .language .RubyBaseNode ;
@@ -27,6 +26,7 @@ public abstract class SetNode extends RubyBaseNode {
27
26
@ Child private LookupEntryNode lookupEntryNode ;
28
27
@ Child private CompareHashKeysNode compareHashKeysNode = new CompareHashKeysNode ();
29
28
@ Child private FreezeHashKeyIfNeededNode freezeHashKeyIfNeededNode = FreezeHashKeyIfNeededNodeGen .create ();
29
+ private final ConditionProfile byIdentityProfile = ConditionProfile .createBinaryProfile ();
30
30
31
31
public static SetNode create () {
32
32
return SetNodeGen .create ();
@@ -35,8 +35,7 @@ public static SetNode create() {
35
35
public abstract Object executeSet (DynamicObject hash , Object key , Object value , boolean byIdentity );
36
36
37
37
@ Specialization (guards = "isNullHash(hash)" )
38
- public Object setNull (DynamicObject hash , Object originalKey , Object value , boolean byIdentity ,
39
- @ Cached ("createBinaryProfile()" ) ConditionProfile byIdentityProfile ) {
38
+ public Object setNull (DynamicObject hash , Object originalKey , Object value , boolean byIdentity ) {
40
39
assert HashOperations .verifyStore (getContext (), hash );
41
40
boolean compareByIdentity = byIdentityProfile .profile (byIdentity );
42
41
final Object key = freezeHashKeyIfNeededNode .executeFreezeIfNeeded (originalKey , compareByIdentity );
@@ -57,9 +56,7 @@ public Object setNull(DynamicObject hash, Object originalKey, Object value, bool
57
56
@ ExplodeLoop
58
57
@ Specialization (guards = "isPackedHash(hash)" )
59
58
public Object setPackedArray (DynamicObject hash , Object originalKey , Object value , boolean byIdentity ,
60
- @ Cached ("createBinaryProfile()" ) ConditionProfile byIdentityProfile ,
61
- @ Cached ("createBinaryProfile()" ) ConditionProfile strategyProfile ,
62
- @ Cached ("create()" ) BranchProfile extendProfile ) {
59
+ @ Cached ("createBinaryProfile()" ) ConditionProfile strategyProfile ) {
63
60
assert HashOperations .verifyStore (getContext (), hash );
64
61
final boolean compareByIdentity = byIdentityProfile .profile (byIdentity );
65
62
final Object key = freezeHashKeyIfNeededNode .executeFreezeIfNeeded (originalKey , compareByIdentity );
@@ -69,6 +66,7 @@ public Object setPackedArray(DynamicObject hash, Object originalKey, Object valu
69
66
final Object [] store = (Object []) Layouts .HASH .getStore (hash );
70
67
final int size = Layouts .HASH .getSize (hash );
71
68
69
+ // written very carefully to allow PE
72
70
for (int n = 0 ; n < getContext ().getOptions ().HASH_PACKED_ARRAY_MAX ; n ++) {
73
71
if (n < size ) {
74
72
final int otherHashed = PackedArrayStrategy .getHashed (store , n );
@@ -81,9 +79,7 @@ public Object setPackedArray(DynamicObject hash, Object originalKey, Object valu
81
79
}
82
80
}
83
81
84
- extendProfile .enter ();
85
-
86
- if (strategyProfile .profile (size + 1 <= getContext ().getOptions ().HASH_PACKED_ARRAY_MAX )) {
82
+ if (strategyProfile .profile (size < getContext ().getOptions ().HASH_PACKED_ARRAY_MAX )) {
87
83
PackedArrayStrategy .setHashedKeyValue (store , size , hashed , key , value );
88
84
Layouts .HASH .setSize (hash , size + 1 );
89
85
return value ;
@@ -99,7 +95,6 @@ public Object setPackedArray(DynamicObject hash, Object originalKey, Object valu
99
95
100
96
@ Specialization (guards = "isBucketHash(hash)" )
101
97
public Object setBuckets (DynamicObject hash , Object originalKey , Object value , boolean byIdentity ,
102
- @ Cached ("createBinaryProfile()" ) ConditionProfile byIdentityProfile ,
103
98
@ Cached ("createBinaryProfile()" ) ConditionProfile foundProfile ,
104
99
@ Cached ("createBinaryProfile()" ) ConditionProfile bucketCollisionProfile ,
105
100
@ Cached ("createBinaryProfile()" ) ConditionProfile appendingProfile ,
0 commit comments