12
12
import com .oracle .truffle .api .CompilerDirectives ;
13
13
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
14
14
import com .oracle .truffle .api .TruffleSafepoint ;
15
+ import com .oracle .truffle .api .dsl .Bind ;
15
16
import com .oracle .truffle .api .dsl .Cached ;
16
17
import com .oracle .truffle .api .dsl .Cached .Exclusive ;
17
18
import com .oracle .truffle .api .dsl .Cached .Shared ;
23
24
import com .oracle .truffle .api .library .ExportLibrary ;
24
25
import com .oracle .truffle .api .library .ExportMessage ;
25
26
import com .oracle .truffle .api .nodes .ExplodeLoop ;
26
- import com .oracle .truffle .api .profiles .ConditionProfile ;
27
+ import com .oracle .truffle .api .nodes .Node ;
28
+ import com .oracle .truffle .api .profiles .InlinedConditionProfile ;
27
29
import com .oracle .truffle .api .profiles .LoopConditionProfile ;
28
30
import org .truffleruby .RubyContext ;
29
31
import org .truffleruby .RubyLanguage ;
@@ -218,12 +220,13 @@ static void appendToLookupChain(Entry[] entries, Entry entry, int bucketIndex) {
218
220
@ ExportMessage
219
221
protected Object lookupOrDefault (Frame frame , RubyHash hash , Object key , PEBiFunction defaultNode ,
220
222
@ Cached @ Shared LookupEntryNode lookup ,
221
- @ Cached @ Exclusive ConditionProfile found ) {
223
+ @ Cached @ Exclusive InlinedConditionProfile found ,
224
+ @ Bind ("$node" ) Node node ) {
222
225
223
226
final Entry [] entries = this .entries ;
224
227
final HashLookupResult hashLookupResult = lookup .execute (hash , entries , key );
225
228
226
- if (found .profile (hashLookupResult .getEntry () != null )) {
229
+ if (found .profile (node , hashLookupResult .getEntry () != null )) {
227
230
return hashLookupResult .getEntry ().getValue ();
228
231
}
229
232
@@ -236,10 +239,11 @@ protected boolean set(RubyHash hash, Object key, Object value, boolean byIdentit
236
239
@ Cached @ Exclusive PropagateSharingNode propagateSharingKey ,
237
240
@ Cached @ Exclusive PropagateSharingNode propagateSharingValue ,
238
241
@ Cached @ Shared LookupEntryNode lookup ,
239
- @ Cached @ Exclusive ConditionProfile missing ,
240
- @ Cached @ Exclusive ConditionProfile bucketCollision ,
241
- @ Cached @ Exclusive ConditionProfile appending ,
242
- @ Cached @ Exclusive ConditionProfile resize ) {
242
+ @ Cached @ Exclusive InlinedConditionProfile missing ,
243
+ @ Cached @ Exclusive InlinedConditionProfile bucketCollision ,
244
+ @ Cached @ Exclusive InlinedConditionProfile appending ,
245
+ @ Cached @ Exclusive InlinedConditionProfile resize ,
246
+ @ Bind ("$node" ) Node node ) {
243
247
assert verify (hash );
244
248
245
249
final Object key2 = freezeHashKeyIfNeeded .executeFreezeIfNeeded (key , byIdentity );
@@ -251,17 +255,17 @@ protected boolean set(RubyHash hash, Object key, Object value, boolean byIdentit
251
255
final HashLookupResult result = lookup .execute (hash , entries , key2 );
252
256
final Entry entry = result .getEntry ();
253
257
254
- if (missing .profile (entry == null )) {
258
+ if (missing .profile (node , entry == null )) {
255
259
final Entry newEntry = new Entry (result .getHashed (), key2 , value );
256
260
257
- if (bucketCollision .profile (result .getPreviousEntry () == null )) {
261
+ if (bucketCollision .profile (node , result .getPreviousEntry () == null )) {
258
262
entries [result .getIndex ()] = newEntry ;
259
263
} else {
260
264
result .getPreviousEntry ().setNextInLookup (newEntry );
261
265
}
262
266
263
267
final Entry lastInSequence = this .lastInSequence ;
264
- if (appending .profile (lastInSequence == null )) {
268
+ if (appending .profile (node , lastInSequence == null )) {
265
269
this .firstInSequence = newEntry ;
266
270
} else {
267
271
lastInSequence .setNextInSequence (newEntry );
@@ -272,7 +276,7 @@ protected boolean set(RubyHash hash, Object key, Object value, boolean byIdentit
272
276
final int newSize = (hash .size += 1 );
273
277
assert verify (hash );
274
278
275
- if (resize .profile (newSize / (double ) entries .length > LOAD_FACTOR )) {
279
+ if (resize .profile (node , newSize / (double ) entries .length > LOAD_FACTOR )) {
276
280
resize (hash , newSize );
277
281
assert ((BucketsHashStore ) hash .store ).verify (hash ); // store changed!
278
282
}
@@ -287,14 +291,15 @@ protected boolean set(RubyHash hash, Object key, Object value, boolean byIdentit
287
291
@ ExportMessage
288
292
protected Object delete (RubyHash hash , Object key ,
289
293
@ Cached @ Shared LookupEntryNode lookup ,
290
- @ Cached @ Exclusive ConditionProfile missing ) {
294
+ @ Cached @ Exclusive InlinedConditionProfile missing ,
295
+ @ Bind ("$node" ) Node node ) {
291
296
assert verify (hash );
292
297
293
298
final Entry [] entries = this .entries ;
294
299
final HashLookupResult lookupResult = lookup .execute (hash , entries , key );
295
300
final Entry entry = lookupResult .getEntry ();
296
301
297
- if (missing .profile (entry == null )) {
302
+ if (missing .profile (node , entry == null )) {
298
303
return null ;
299
304
}
300
305
@@ -307,7 +312,8 @@ protected Object delete(RubyHash hash, Object key,
307
312
308
313
@ ExportMessage
309
314
protected Object deleteLast (RubyHash hash , Object key ,
310
- @ Cached @ Exclusive ConditionProfile singleEntry ) {
315
+ @ Cached @ Exclusive InlinedConditionProfile singleEntry ,
316
+ @ Bind ("$node" ) Node node ) {
311
317
assert verify (hash );
312
318
313
319
final Entry [] entries = this .entries ;
@@ -328,7 +334,7 @@ protected Object deleteLast(RubyHash hash, Object key,
328
334
}
329
335
assert entry .getNextInSequence () == null ;
330
336
331
- if (singleEntry .profile (this .firstInSequence == entry )) {
337
+ if (singleEntry .profile (node , this .firstInSequence == entry )) {
332
338
assert entry .getPreviousInSequence () == null ;
333
339
this .firstInSequence = null ;
334
340
this .lastInSequence = null ;
@@ -571,8 +577,8 @@ abstract static class LookupEntryNode extends RubyBaseNode {
571
577
protected HashLookupResult lookup (RubyHash hash , Entry [] entries , Object key ,
572
578
@ Cached HashingNodes .ToHash hashNode ,
573
579
@ Cached CompareHashKeysNode compareHashKeysNode ,
574
- @ Cached ConditionProfile byIdentityProfile ) {
575
- final boolean compareByIdentity = byIdentityProfile .profile (hash .compareByIdentity );
580
+ @ Cached InlinedConditionProfile byIdentityProfile ) {
581
+ final boolean compareByIdentity = byIdentityProfile .profile (this , hash .compareByIdentity );
576
582
int hashed = hashNode .execute (key , compareByIdentity );
577
583
578
584
final int index = getBucketIndex (hashed , entries .length );
0 commit comments