Skip to content

Commit 553d873

Browse files
committed
Addressing truffle-inlining warnings in library package
1 parent 703b104 commit 553d873

File tree

4 files changed

+38
-31
lines changed

4 files changed

+38
-31
lines changed

src/main/java/org/truffleruby/core/hash/library/BucketsHashStore.java

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.oracle.truffle.api.CompilerDirectives;
1313
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
1414
import com.oracle.truffle.api.TruffleSafepoint;
15+
import com.oracle.truffle.api.dsl.Bind;
1516
import com.oracle.truffle.api.dsl.Cached;
1617
import com.oracle.truffle.api.dsl.Cached.Exclusive;
1718
import com.oracle.truffle.api.dsl.Cached.Shared;
@@ -23,7 +24,8 @@
2324
import com.oracle.truffle.api.library.ExportLibrary;
2425
import com.oracle.truffle.api.library.ExportMessage;
2526
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;
2729
import com.oracle.truffle.api.profiles.LoopConditionProfile;
2830
import org.truffleruby.RubyContext;
2931
import org.truffleruby.RubyLanguage;
@@ -218,12 +220,13 @@ static void appendToLookupChain(Entry[] entries, Entry entry, int bucketIndex) {
218220
@ExportMessage
219221
protected Object lookupOrDefault(Frame frame, RubyHash hash, Object key, PEBiFunction defaultNode,
220222
@Cached @Shared LookupEntryNode lookup,
221-
@Cached @Exclusive ConditionProfile found) {
223+
@Cached @Exclusive InlinedConditionProfile found,
224+
@Bind("$node") Node node) {
222225

223226
final Entry[] entries = this.entries;
224227
final HashLookupResult hashLookupResult = lookup.execute(hash, entries, key);
225228

226-
if (found.profile(hashLookupResult.getEntry() != null)) {
229+
if (found.profile(node, hashLookupResult.getEntry() != null)) {
227230
return hashLookupResult.getEntry().getValue();
228231
}
229232

@@ -236,10 +239,11 @@ protected boolean set(RubyHash hash, Object key, Object value, boolean byIdentit
236239
@Cached @Exclusive PropagateSharingNode propagateSharingKey,
237240
@Cached @Exclusive PropagateSharingNode propagateSharingValue,
238241
@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) {
243247
assert verify(hash);
244248

245249
final Object key2 = freezeHashKeyIfNeeded.executeFreezeIfNeeded(key, byIdentity);
@@ -251,17 +255,17 @@ protected boolean set(RubyHash hash, Object key, Object value, boolean byIdentit
251255
final HashLookupResult result = lookup.execute(hash, entries, key2);
252256
final Entry entry = result.getEntry();
253257

254-
if (missing.profile(entry == null)) {
258+
if (missing.profile(node, entry == null)) {
255259
final Entry newEntry = new Entry(result.getHashed(), key2, value);
256260

257-
if (bucketCollision.profile(result.getPreviousEntry() == null)) {
261+
if (bucketCollision.profile(node, result.getPreviousEntry() == null)) {
258262
entries[result.getIndex()] = newEntry;
259263
} else {
260264
result.getPreviousEntry().setNextInLookup(newEntry);
261265
}
262266

263267
final Entry lastInSequence = this.lastInSequence;
264-
if (appending.profile(lastInSequence == null)) {
268+
if (appending.profile(node, lastInSequence == null)) {
265269
this.firstInSequence = newEntry;
266270
} else {
267271
lastInSequence.setNextInSequence(newEntry);
@@ -272,7 +276,7 @@ protected boolean set(RubyHash hash, Object key, Object value, boolean byIdentit
272276
final int newSize = (hash.size += 1);
273277
assert verify(hash);
274278

275-
if (resize.profile(newSize / (double) entries.length > LOAD_FACTOR)) {
279+
if (resize.profile(node, newSize / (double) entries.length > LOAD_FACTOR)) {
276280
resize(hash, newSize);
277281
assert ((BucketsHashStore) hash.store).verify(hash); // store changed!
278282
}
@@ -287,14 +291,15 @@ protected boolean set(RubyHash hash, Object key, Object value, boolean byIdentit
287291
@ExportMessage
288292
protected Object delete(RubyHash hash, Object key,
289293
@Cached @Shared LookupEntryNode lookup,
290-
@Cached @Exclusive ConditionProfile missing) {
294+
@Cached @Exclusive InlinedConditionProfile missing,
295+
@Bind("$node") Node node) {
291296
assert verify(hash);
292297

293298
final Entry[] entries = this.entries;
294299
final HashLookupResult lookupResult = lookup.execute(hash, entries, key);
295300
final Entry entry = lookupResult.getEntry();
296301

297-
if (missing.profile(entry == null)) {
302+
if (missing.profile(node, entry == null)) {
298303
return null;
299304
}
300305

@@ -307,7 +312,8 @@ protected Object delete(RubyHash hash, Object key,
307312

308313
@ExportMessage
309314
protected Object deleteLast(RubyHash hash, Object key,
310-
@Cached @Exclusive ConditionProfile singleEntry) {
315+
@Cached @Exclusive InlinedConditionProfile singleEntry,
316+
@Bind("$node") Node node) {
311317
assert verify(hash);
312318

313319
final Entry[] entries = this.entries;
@@ -328,7 +334,7 @@ protected Object deleteLast(RubyHash hash, Object key,
328334
}
329335
assert entry.getNextInSequence() == null;
330336

331-
if (singleEntry.profile(this.firstInSequence == entry)) {
337+
if (singleEntry.profile(node, this.firstInSequence == entry)) {
332338
assert entry.getPreviousInSequence() == null;
333339
this.firstInSequence = null;
334340
this.lastInSequence = null;
@@ -571,8 +577,8 @@ abstract static class LookupEntryNode extends RubyBaseNode {
571577
protected HashLookupResult lookup(RubyHash hash, Entry[] entries, Object key,
572578
@Cached HashingNodes.ToHash hashNode,
573579
@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);
576582
int hashed = hashNode.execute(key, compareByIdentity);
577583

578584
final int index = getBucketIndex(hashed, entries.length);

src/main/java/org/truffleruby/core/hash/library/HashStoreLibrary.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import com.oracle.truffle.api.library.LibraryFactory;
2222
import com.oracle.truffle.api.nodes.EncapsulatingNodeReference;
2323
import com.oracle.truffle.api.nodes.Node;
24-
import com.oracle.truffle.api.profiles.ConditionProfile;
24+
import com.oracle.truffle.api.profiles.InlinedConditionProfile;
2525
import org.truffleruby.collections.PEBiFunction;
2626
import org.truffleruby.core.array.RubyArray;
2727
import org.truffleruby.core.hash.HashGuards;
@@ -129,10 +129,10 @@ public static YieldPairNode create() {
129129
@Specialization
130130
protected Object yieldPair(RubyProc block, Object key, Object value,
131131
@Cached CallBlockNode yieldNode,
132-
@Cached ConditionProfile arityMoreThanOne) {
132+
@Cached InlinedConditionProfile arityMoreThanOne) {
133133
// MRI behavior, see rb_hash_each_pair()
134134
// We use getMethodArityNumber() here since for non-lambda the semantics are the same for both branches
135-
if (arityMoreThanOne.profile(block.arity.getMethodArityNumber() > 1)) {
135+
if (arityMoreThanOne.profile(this, block.arity.getMethodArityNumber() > 1)) {
136136
return yieldNode.yield(block, key, value);
137137
} else {
138138
return yieldNode.yield(block, createArray(new Object[]{ key, value }));

src/main/java/org/truffleruby/core/hash/library/PackedHashStoreLibrary.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.oracle.truffle.api.CompilerDirectives;
1313
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
1414
import com.oracle.truffle.api.TruffleSafepoint;
15+
import com.oracle.truffle.api.dsl.Bind;
1516
import com.oracle.truffle.api.dsl.Cached;
1617
import com.oracle.truffle.api.dsl.Cached.Exclusive;
1718
import com.oracle.truffle.api.dsl.Cached.Shared;
@@ -25,8 +26,10 @@
2526
import com.oracle.truffle.api.library.ExportMessage;
2627
import com.oracle.truffle.api.nodes.ExplodeLoop;
2728
import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind;
29+
import com.oracle.truffle.api.nodes.Node;
2830
import com.oracle.truffle.api.profiles.BranchProfile;
29-
import com.oracle.truffle.api.profiles.ConditionProfile;
31+
import com.oracle.truffle.api.profiles.InlinedBranchProfile;
32+
import com.oracle.truffle.api.profiles.InlinedConditionProfile;
3033
import com.oracle.truffle.api.profiles.LoopConditionProfile;
3134
import org.truffleruby.RubyContext;
3235
import org.truffleruby.RubyLanguage;
@@ -192,7 +195,8 @@ protected static boolean set(Object[] store, RubyHash hash, Object key, Object v
192195
@Cached @Shared PropagateSharingNode propagateSharingValue,
193196
@Cached @Shared CompareHashKeysNode compareHashKeys,
194197
@CachedLibrary(limit = "hashStrategyLimit()") HashStoreLibrary hashes,
195-
@Cached ConditionProfile withinCapacity) {
198+
@Cached InlinedConditionProfile withinCapacity,
199+
@Bind("this") Node node) {
196200

197201
assert verify(store, hash);
198202
final int size = hash.size;
@@ -213,7 +217,7 @@ protected static boolean set(Object[] store, RubyHash hash, Object key, Object v
213217
}
214218
}
215219

216-
if (withinCapacity.profile(size < MAX_ENTRIES)) {
220+
if (withinCapacity.profile(node, size < MAX_ENTRIES)) {
217221
setHashedKeyValue(store, size, hashed, key2, value);
218222
hash.size += 1;
219223
return true;
@@ -448,10 +452,11 @@ private boolean sameKeys(ReferenceEqualNode refEqual, boolean compareByIdentity,
448452
protected Object getPackedArray(
449453
Frame frame, RubyHash hash, Object key, int hashed, PEBiFunction defaultValueNode,
450454
@Cached CompareHashKeysNode compareHashKeys,
451-
@Cached BranchProfile notInHashProfile,
452-
@Cached ConditionProfile byIdentityProfile) {
455+
@Cached InlinedBranchProfile notInHashProfile,
456+
@Cached InlinedConditionProfile byIdentityProfile,
457+
@Bind("$node") Node node) {
453458

454-
final boolean compareByIdentity = byIdentityProfile.profile(hash.compareByIdentity);
459+
final boolean compareByIdentity = byIdentityProfile.profile(node, hash.compareByIdentity);
455460
final Object[] store = (Object[]) hash.store;
456461
final int size = hash.size;
457462
for (int n = 0; n < MAX_ENTRIES; n++) {
@@ -464,7 +469,7 @@ protected Object getPackedArray(
464469
}
465470
}
466471

467-
notInHashProfile.enter();
472+
notInHashProfile.enter(node);
468473
return defaultValueNode.accept(frame, hash, key);
469474
}
470475

src/main/java/org/truffleruby/core/hash/library/package-info.java

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)