Skip to content

Commit 3e363d8

Browse files
committed
Address many truffle-sharing warnings
1 parent fa3246f commit 3e363d8

34 files changed

+159
-136
lines changed

src/main/java/org/truffleruby/core/MarkingServiceNodes.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
2121
import com.oracle.truffle.api.dsl.Bind;
2222
import com.oracle.truffle.api.dsl.Cached;
23+
import com.oracle.truffle.api.dsl.Cached.Shared;
2324
import com.oracle.truffle.api.dsl.GenerateUncached;
2425
import com.oracle.truffle.api.dsl.Specialization;
2526
import com.oracle.truffle.api.profiles.ConditionProfile;
@@ -93,15 +94,15 @@ protected void nothingToMark(ExtensionCallStack stack) {
9394

9495
@Specialization(guards = "stack.hasSingleMarkObject()")
9596
protected void markSingleObject(ExtensionCallStack stack,
96-
@Cached DispatchNode callNode) {
97+
@Shared @Cached DispatchNode callNode) {
9798
ValueWrapper value = stack.getSingleMarkObject();
9899
callNode.call(getContext().getCoreLibrary().truffleCExtModule, "run_marker", value.getObject());
99100
}
100101

101102
@TruffleBoundary
102103
@Specialization(guards = { "stack.hasMarkObjects()", "!stack.hasSingleMarkObject()" })
103104
protected void marksToRun(ExtensionCallStack stack,
104-
@Cached DispatchNode callNode) {
105+
@Shared @Cached DispatchNode callNode) {
105106
// Run the markers...
106107
var valuesForMarking = stack.getMarkOnExitObjects();
107108
// Push a new stack frame because we should

src/main/java/org/truffleruby/core/MathNodes.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353

5454
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
5555
import com.oracle.truffle.api.dsl.Cached;
56+
import com.oracle.truffle.api.dsl.Cached.Shared;
5657
import com.oracle.truffle.api.dsl.Fallback;
5758
import com.oracle.truffle.api.dsl.Specialization;
5859
import com.oracle.truffle.api.profiles.BranchProfile;
@@ -549,13 +550,13 @@ public abstract static class MinNode extends PrimitiveArrayArgumentsNode {
549550

550551
@Specialization
551552
protected int min(int a, int b,
552-
@Cached ConditionProfile profile) {
553+
@Shared @Cached ConditionProfile profile) {
553554
return profile.profile(a < b) ? a : b;
554555
}
555556

556557
@Specialization
557558
protected long min(long a, long b,
558-
@Cached ConditionProfile profile) {
559+
@Shared @Cached ConditionProfile profile) {
559560
return profile.profile(a < b) ? a : b;
560561
}
561562

src/main/java/org/truffleruby/core/TruffleSystemNodes.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
7171
import com.oracle.truffle.api.TruffleFile;
7272
import com.oracle.truffle.api.dsl.Cached;
73+
import com.oracle.truffle.api.dsl.Cached.Shared;
7374
import com.oracle.truffle.api.dsl.Specialization;
7475
import com.oracle.truffle.api.profiles.ConditionProfile;
7576

@@ -230,8 +231,8 @@ public abstract static class LogNode extends CoreMethodArrayArgumentsNode {
230231

231232
@Specialization(guards = { "strings.isRubyString(message)", "level == cachedLevel" }, limit = "3")
232233
protected Object logCached(RubySymbol level, Object message,
233-
@Cached RubyStringLibrary strings,
234-
@Cached ToJavaStringNode toJavaStringNode,
234+
@Shared @Cached RubyStringLibrary strings,
235+
@Shared @Cached ToJavaStringNode toJavaStringNode,
235236
@Cached("level") RubySymbol cachedLevel,
236237
@Cached("getLevel(cachedLevel)") Level javaLevel) {
237238
log(javaLevel, toJavaStringNode.executeToJavaString(message));
@@ -240,8 +241,8 @@ protected Object logCached(RubySymbol level, Object message,
240241

241242
@Specialization(guards = "strings.isRubyString(message)", replaces = "logCached", limit = "1")
242243
protected Object log(RubySymbol level, Object message,
243-
@Cached RubyStringLibrary strings,
244-
@Cached ToJavaStringNode toJavaStringNode) {
244+
@Shared @Cached RubyStringLibrary strings,
245+
@Shared @Cached ToJavaStringNode toJavaStringNode) {
245246
log(getLevel(level), toJavaStringNode.executeToJavaString(message));
246247
return nil;
247248
}

src/main/java/org/truffleruby/core/VMPrimitiveNodes.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@
9393
import com.oracle.truffle.api.CompilerDirectives;
9494
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
9595
import com.oracle.truffle.api.dsl.Cached;
96+
import com.oracle.truffle.api.dsl.Cached.Exclusive;
97+
import com.oracle.truffle.api.dsl.Cached.Shared;
9698
import com.oracle.truffle.api.dsl.Specialization;
9799
import com.oracle.truffle.api.frame.VirtualFrame;
98100
import com.oracle.truffle.api.profiles.BranchProfile;
@@ -271,8 +273,8 @@ public abstract static class VMWatchSignalNode extends PrimitiveArrayArgumentsNo
271273
@Specialization(guards = { "libSignalString.isRubyString(signalString)", "libAction.isRubyString(action)" },
272274
limit = "1")
273275
protected boolean watchSignalString(Object signalString, boolean isRubyDefaultHandler, Object action,
274-
@Cached RubyStringLibrary libSignalString,
275-
@Cached RubyStringLibrary libAction) {
276+
@Shared @Cached RubyStringLibrary libSignalString,
277+
@Exclusive @Cached RubyStringLibrary libAction) {
276278
final String actionString = RubyGuards.getJavaString(action);
277279
final String signalName = RubyGuards.getJavaString(signalString);
278280

@@ -291,7 +293,7 @@ protected boolean watchSignalString(Object signalString, boolean isRubyDefaultHa
291293
@TruffleBoundary
292294
@Specialization(guards = "libSignalString.isRubyString(signalString)", limit = "1")
293295
protected boolean watchSignalProc(Object signalString, boolean isRubyDefaultHandler, RubyProc action,
294-
@Cached RubyStringLibrary libSignalString) {
296+
@Shared @Cached RubyStringLibrary libSignalString) {
295297
final RubyContext context = getContext();
296298

297299
if (getLanguage().getCurrentThread() != context.getThreadManager().getRootThread()) {

src/main/java/org/truffleruby/core/hash/HashNodes.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747

4848
import com.oracle.truffle.api.CompilerDirectives;
4949
import com.oracle.truffle.api.dsl.Cached;
50+
import com.oracle.truffle.api.dsl.Cached.Shared;
5051
import com.oracle.truffle.api.dsl.ImportStatic;
5152
import com.oracle.truffle.api.dsl.Specialization;
5253
import com.oracle.truffle.api.nodes.ExplodeLoop;
@@ -380,7 +381,7 @@ protected RubyHash initialize(RubyHash hash, NotProvided defaultValue, Nil block
380381

381382
@Specialization
382383
protected RubyHash initialize(RubyHash hash, NotProvided defaultValue, RubyProc block,
383-
@Cached PropagateSharingNode propagateSharingNode) {
384+
@Shared @Cached PropagateSharingNode propagateSharingNode) {
384385
assert HashStoreLibrary.verify(hash);
385386
hash.defaultValue = nil;
386387
propagateSharingNode.executePropagate(hash, block);
@@ -390,7 +391,7 @@ protected RubyHash initialize(RubyHash hash, NotProvided defaultValue, RubyProc
390391

391392
@Specialization(guards = "wasProvided(defaultValue)")
392393
protected RubyHash initialize(RubyHash hash, Object defaultValue, Nil block,
393-
@Cached PropagateSharingNode propagateSharingNode) {
394+
@Shared @Cached PropagateSharingNode propagateSharingNode) {
394395
assert HashStoreLibrary.verify(hash);
395396
propagateSharingNode.executePropagate(hash, defaultValue);
396397
hash.defaultValue = defaultValue;

src/main/java/org/truffleruby/core/hash/HashingNodes.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package org.truffleruby.core.hash;
1111

1212
import com.oracle.truffle.api.dsl.Cached;
13+
import com.oracle.truffle.api.dsl.Cached.Shared;
1314
import com.oracle.truffle.api.dsl.Fallback;
1415
import com.oracle.truffle.api.dsl.GenerateUncached;
1516
import com.oracle.truffle.api.dsl.NeverDefault;
@@ -92,13 +93,13 @@ protected int hashBignum(RubyBignum value) {
9293

9394
@Specialization
9495
protected int hashString(RubyString value,
95-
@Cached StringHelperNodes.HashStringNode stringHashNode) {
96+
@Shared @Cached StringHelperNodes.HashStringNode stringHashNode) {
9697
return (int) stringHashNode.execute(value);
9798
}
9899

99100
@Specialization
100101
protected int hashImmutableString(ImmutableRubyString value,
101-
@Cached StringHelperNodes.HashStringNode stringHashNode) {
102+
@Shared @Cached StringHelperNodes.HashStringNode stringHashNode) {
102103
return (int) stringHashNode.execute(value);
103104
}
104105

src/main/java/org/truffleruby/core/hash/RubyHash.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,29 +125,29 @@ public Object accept(Frame frame, Object hash, Object key) {
125125
@ExportMessage(name = "isHashEntryReadable", limit = "hashStrategyLimit()")
126126
public final boolean isHashEntryExisting(Object key,
127127
@CachedLibrary("this.store") HashStoreLibrary hashStores,
128-
@Cached @Exclusive ForeignToRubyNode toRuby) {
128+
@Cached @Shared ForeignToRubyNode toRuby) {
129129
return hashStores.lookupOrDefault(store, null, this, toRuby.executeConvert(key), NULL_PROVIDER) != null;
130130
}
131131

132132
@ExportMessage(name = "isHashEntryModifiable")
133133
@ExportMessage(name = "isHashEntryRemovable")
134134
public boolean isHashEntryModifiableAndRemovable(Object key,
135135
@CachedLibrary("this") InteropLibrary interop,
136-
@Cached IsFrozenNode isFrozenNode) {
136+
@Cached @Shared IsFrozenNode isFrozenNode) {
137137
return !isFrozenNode.execute(this) && interop.isHashEntryExisting(this, key);
138138
}
139139

140140
@ExportMessage
141141
public boolean isHashEntryInsertable(Object key,
142142
@CachedLibrary("this") InteropLibrary interop,
143-
@Cached IsFrozenNode isFrozenNode) {
143+
@Cached @Shared IsFrozenNode isFrozenNode) {
144144
return !isFrozenNode.execute(this) && !interop.isHashEntryExisting(this, key);
145145
}
146146

147147
@ExportMessage(limit = "hashStrategyLimit()")
148148
public Object readHashValue(Object key,
149149
@CachedLibrary("this.store") HashStoreLibrary hashStores,
150-
@Cached @Exclusive ForeignToRubyNode toRuby,
150+
@Cached @Shared ForeignToRubyNode toRuby,
151151
@Cached ConditionProfile unknownKey)
152152
throws UnknownKeyException {
153153
final Object value = hashStores.lookupOrDefault(store, null, this, toRuby.executeConvert(key), NULL_PROVIDER);
@@ -160,15 +160,15 @@ public Object readHashValue(Object key,
160160
@ExportMessage(limit = "hashStrategyLimit()")
161161
public Object readHashValueOrDefault(Object key, Object defaultValue,
162162
@CachedLibrary("this.store") HashStoreLibrary hashStores,
163-
@Cached @Exclusive ForeignToRubyNode toRuby) {
163+
@Cached @Shared ForeignToRubyNode toRuby) {
164164
return hashStores
165165
.lookupOrDefault(store, null, this, toRuby.executeConvert(key), new DefaultProvider(defaultValue));
166166
}
167167

168168
@ExportMessage
169169
public void writeHashEntry(Object key, Object value,
170170
@Cached @Exclusive DispatchNode set,
171-
@Cached IsFrozenNode isFrozenNode,
171+
@Cached @Shared IsFrozenNode isFrozenNode,
172172
@Cached @Shared ForeignToRubyNode toRuby)
173173
throws UnsupportedMessageException {
174174
if (isFrozenNode.execute(this)) {
@@ -180,7 +180,7 @@ public void writeHashEntry(Object key, Object value,
180180
@ExportMessage
181181
public void removeHashEntry(Object key,
182182
@Cached @Exclusive DispatchNode delete,
183-
@Cached IsFrozenNode isFrozenNode,
183+
@Shared @Cached IsFrozenNode isFrozenNode,
184184
@CachedLibrary("this") InteropLibrary interop,
185185
@Cached @Shared ForeignToRubyNode toRuby)
186186
throws UnsupportedMessageException, UnknownKeyException {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@SuppressPackageWarnings({ "truffle-sharing", "truffle-inlining" })
1+
@SuppressPackageWarnings({ "truffle-inlining" })
22
package org.truffleruby.core.hash;
33

44
import com.oracle.truffle.api.dsl.SuppressPackageWarnings;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@SuppressPackageWarnings({ "truffle-sharing", "truffle-inlining" })
1+
@SuppressPackageWarnings({ "truffle-inlining" })
22
package org.truffleruby.core.klass;
33

44
import com.oracle.truffle.api.dsl.SuppressPackageWarnings;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@SuppressPackageWarnings({ "truffle-sharing", "truffle-inlining" })
1+
@SuppressPackageWarnings({ "truffle-inlining" })
22
package org.truffleruby.core.method;
33

44
import com.oracle.truffle.api.dsl.SuppressPackageWarnings;

0 commit comments

Comments
 (0)