Skip to content

Commit 404a086

Browse files
committed
[GR-45042] Address truffle-inlining warnings 2
PullRequest: truffleruby/3808
2 parents 47fc94c + fd9915e commit 404a086

File tree

159 files changed

+2005
-1799
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+2005
-1799
lines changed

src/main/java/org/truffleruby/builtins/YieldingCoreMethodNode.java

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

src/main/java/org/truffleruby/cext/CExtNodes.java

Lines changed: 86 additions & 82 deletions
Large diffs are not rendered by default.

src/main/java/org/truffleruby/cext/IDToSymbolNode.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import static org.truffleruby.core.symbol.CoreSymbols.idToIndex;
1313

14+
import com.oracle.truffle.api.profiles.InlinedBranchProfile;
1415
import org.truffleruby.core.string.StringUtils;
1516
import org.truffleruby.core.symbol.CoreSymbols;
1617
import org.truffleruby.core.symbol.RubySymbol;
@@ -21,7 +22,6 @@
2122
import com.oracle.truffle.api.dsl.GenerateUncached;
2223
import com.oracle.truffle.api.dsl.ReportPolymorphism;
2324
import com.oracle.truffle.api.dsl.Specialization;
24-
import com.oracle.truffle.api.profiles.BranchProfile;
2525

2626
@GenerateUncached
2727
@ReportPolymorphism
@@ -31,11 +31,11 @@ public abstract class IDToSymbolNode extends RubyBaseNode {
3131

3232
@Specialization(guards = "isStaticSymbol(value)")
3333
protected RubySymbol unwrapStaticSymbol(long value,
34-
@Cached BranchProfile errorProfile) {
34+
@Cached InlinedBranchProfile errorProfile) {
3535
final int index = idToIndex(value);
3636
final RubySymbol symbol = getLanguage().coreSymbols.STATIC_SYMBOLS[index];
3737
if (symbol == null) {
38-
errorProfile.enter();
38+
errorProfile.enter(this);
3939
throw new RaiseException(
4040
getContext(),
4141
coreExceptions().runtimeError(

src/main/java/org/truffleruby/cext/SymbolToIDNode.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
package org.truffleruby.cext;
1111

12+
import com.oracle.truffle.api.profiles.InlinedConditionProfile;
1213
import org.truffleruby.core.symbol.RubySymbol;
1314
import org.truffleruby.language.RubyBaseNode;
1415

@@ -17,7 +18,6 @@
1718
import com.oracle.truffle.api.dsl.GenerateUncached;
1819
import com.oracle.truffle.api.dsl.ReportPolymorphism;
1920
import com.oracle.truffle.api.dsl.Specialization;
20-
import com.oracle.truffle.api.profiles.ConditionProfile;
2121

2222
@GenerateUncached
2323
@ReportPolymorphism
@@ -36,8 +36,8 @@ protected Object getIDCached(RubySymbol symbol,
3636
@Specialization(replaces = "getIDCached")
3737
protected Object getIDUncached(RubySymbol symbol,
3838
@Cached @Shared WrapNode wrapNode,
39-
@Cached ConditionProfile staticSymbolProfile) {
40-
if (staticSymbolProfile.profile(symbol.getId() != RubySymbol.UNASSIGNED_ID)) {
39+
@Cached InlinedConditionProfile staticSymbolProfile) {
40+
if (staticSymbolProfile.profile(this, symbol.getId() != RubySymbol.UNASSIGNED_ID)) {
4141
return symbol.getId();
4242
}
4343
return wrapNode.execute(symbol);

src/main/java/org/truffleruby/cext/UnwrapNode.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.oracle.truffle.api.dsl.Bind;
1919
import com.oracle.truffle.api.interop.InvalidArrayIndexException;
2020
import com.oracle.truffle.api.nodes.ExplodeLoop;
21+
import com.oracle.truffle.api.profiles.InlinedBranchProfile;
2122
import com.oracle.truffle.api.profiles.LoopConditionProfile;
2223
import org.truffleruby.language.NotProvided;
2324
import org.truffleruby.language.RubyBaseNode;
@@ -26,15 +27,13 @@
2627
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
2728
import com.oracle.truffle.api.dsl.Cached;
2829
import com.oracle.truffle.api.dsl.Cached.Shared;
29-
import com.oracle.truffle.api.dsl.Cached.Exclusive;
3030
import com.oracle.truffle.api.dsl.Fallback;
3131
import com.oracle.truffle.api.dsl.GenerateUncached;
3232
import com.oracle.truffle.api.dsl.ImportStatic;
3333
import com.oracle.truffle.api.dsl.Specialization;
3434
import com.oracle.truffle.api.interop.InteropLibrary;
3535
import com.oracle.truffle.api.interop.UnsupportedMessageException;
3636
import com.oracle.truffle.api.library.CachedLibrary;
37-
import com.oracle.truffle.api.profiles.BranchProfile;
3837

3938
@GenerateUncached
4039
@ImportStatic(ValueWrapperManager.class)
@@ -73,12 +72,12 @@ protected long unwrapTaggedLong(long handle) {
7372

7473
@Specialization(guards = "isTaggedObject(handle)")
7574
protected Object unwrapTaggedObject(long handle,
76-
@Cached BranchProfile noHandleProfile) {
75+
@Cached InlinedBranchProfile noHandleProfile) {
7776
final ValueWrapper wrapper = getContext()
7877
.getValueWrapperManager()
7978
.getWrapperFromHandleMap(handle, getLanguage());
8079
if (wrapper == null) {
81-
noHandleProfile.enter();
80+
noHandleProfile.enter(this);
8281
raiseError(handle);
8382
}
8483
return wrapper.getObject();
@@ -158,16 +157,16 @@ protected ValueWrapper longToWrapper(long value,
158157
return nativeToWrapperNode.execute(value);
159158
}
160159

161-
@Specialization(guards = { "!isWrapper(value)", "values.isPointer(value)" }, limit = "getCacheLimit()")
160+
@Fallback
162161
protected ValueWrapper genericToWrapper(Object value,
163-
@CachedLibrary("value") InteropLibrary values,
162+
@CachedLibrary(limit = "getCacheLimit()") InteropLibrary values,
164163
@Cached @Shared NativeToWrapperNode nativeToWrapperNode,
165-
@Cached BranchProfile unsupportedProfile) {
164+
@Cached InlinedBranchProfile unsupportedProfile) {
166165
long handle;
167166
try {
168167
handle = values.asPointer(value);
169168
} catch (UnsupportedMessageException e) {
170-
unsupportedProfile.enter();
169+
unsupportedProfile.enter(this);
171170
throw new RaiseException(getContext(), coreExceptions().argumentError(e.getMessage(), this, e));
172171
}
173172
return nativeToWrapperNode.execute(handle);
@@ -251,20 +250,20 @@ protected long unwrapValueTaggedLong(ValueWrapper value) {
251250

252251
@Specialization
253252
protected Object longToWrapper(long value,
254-
@Cached @Exclusive UnwrapNativeNode unwrapNode) {
255-
return unwrapNode.execute(value);
253+
@Cached @Shared UnwrapNativeNode unwrapNativeNode) {
254+
return unwrapNativeNode.execute(value);
256255
}
257256

258-
@Specialization(guards = { "!isWrapper(value)", "values.isPointer(value)" }, limit = "getCacheLimit()")
257+
@Specialization(guards = { "!isWrapper(value)", "!isImplicitLong(value)" })
259258
protected Object unwrapGeneric(Object value,
260-
@CachedLibrary("value") InteropLibrary values,
261-
@Cached @Exclusive UnwrapNativeNode unwrapNativeNode,
262-
@Cached BranchProfile unsupportedProfile) {
259+
@CachedLibrary(limit = "getCacheLimit()") InteropLibrary values,
260+
@Cached @Shared UnwrapNativeNode unwrapNativeNode,
261+
@Cached InlinedBranchProfile unsupportedProfile) {
263262
long handle;
264263
try {
265264
handle = values.asPointer(value);
266265
} catch (UnsupportedMessageException e) {
267-
unsupportedProfile.enter();
266+
unsupportedProfile.enter(this);
268267
throw new RaiseException(getContext(), coreExceptions().argumentError(e.getMessage(), this, e));
269268
}
270269
return unwrapNativeNode.execute(handle);

src/main/java/org/truffleruby/cext/ValueWrapper.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
*/
1010
package org.truffleruby.cext;
1111

12+
import com.oracle.truffle.api.dsl.Bind;
13+
import com.oracle.truffle.api.nodes.Node;
14+
import com.oracle.truffle.api.profiles.InlinedBranchProfile;
1215
import org.truffleruby.RubyLanguage;
1316
import org.truffleruby.cext.ValueWrapperManager.AllocateHandleNode;
1417
import org.truffleruby.cext.ValueWrapperManager.HandleBlock;
@@ -25,7 +28,6 @@
2528
import com.oracle.truffle.api.interop.UnsupportedMessageException;
2629
import com.oracle.truffle.api.library.ExportLibrary;
2730
import com.oracle.truffle.api.library.ExportMessage;
28-
import com.oracle.truffle.api.profiles.BranchProfile;
2931

3032
/** This object represents a VALUE in C which wraps the raw Ruby object. This allows foreign access methods to be set up
3133
* which convert these value wrappers to native pointers without affecting the semantics of the wrapped objects. */
@@ -102,22 +104,24 @@ protected boolean isPointer() {
102104
@ExportMessage
103105
protected static void toNative(ValueWrapper wrapper,
104106
@Cached AllocateHandleNode createNativeHandleNode,
105-
@Cached @Exclusive BranchProfile createHandleProfile) {
107+
@Cached @Exclusive InlinedBranchProfile createHandleProfile,
108+
@Bind("$node") Node node) {
106109
if (!wrapper.isPointer()) {
107-
createHandleProfile.enter();
110+
createHandleProfile.enter(node);
108111
createNativeHandleNode.execute(wrapper);
109112
}
110113
}
111114

112115
@ExportMessage
113116
protected static long asPointer(ValueWrapper wrapper,
114117
@Cached KeepAliveNode keepAliveNode,
115-
@Cached @Exclusive BranchProfile taggedObjectProfile) {
118+
@Cached @Exclusive InlinedBranchProfile taggedObjectProfile,
119+
@Bind("$node") Node node) {
116120
long handle = wrapper.getHandle();
117121
assert handle != ValueWrapperManager.UNSET_HANDLE;
118122

119123
if (ValueWrapperManager.isTaggedObject(handle)) {
120-
taggedObjectProfile.enter();
124+
taggedObjectProfile.enter(node);
121125

122126
keepAliveNode.execute(wrapper);
123127
}
@@ -142,11 +146,12 @@ protected boolean isMemberReadable(String member) {
142146

143147
@ExportMessage
144148
protected static Object readMember(ValueWrapper wrapper, String member,
145-
@Cached @Exclusive BranchProfile errorProfile) throws UnknownIdentifierException {
149+
@Cached @Exclusive InlinedBranchProfile errorProfile,
150+
@Bind("$node") Node node) throws UnknownIdentifierException {
146151
if ("value".equals(member)) {
147152
return wrapper.object;
148153
} else {
149-
errorProfile.enter();
154+
errorProfile.enter(node);
150155
throw UnknownIdentifierException.create(member);
151156
}
152157
}

src/main/java/org/truffleruby/cext/WrapNode.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
import static org.truffleruby.cext.ValueWrapperManager.LONG_TAG;
1313
import static org.truffleruby.cext.ValueWrapperManager.UNSET_HANDLE;
1414

15+
import com.oracle.truffle.api.dsl.Bind;
1516
import com.oracle.truffle.api.dsl.NeverDefault;
17+
import com.oracle.truffle.api.nodes.Node;
18+
import com.oracle.truffle.api.profiles.InlinedBranchProfile;
1619
import com.oracle.truffle.api.strings.TruffleString;
1720
import org.truffleruby.Layouts;
1821
import org.truffleruby.core.encoding.Encodings;
@@ -30,7 +33,6 @@
3033
import com.oracle.truffle.api.dsl.Specialization;
3134
import com.oracle.truffle.api.library.CachedLibrary;
3235
import com.oracle.truffle.api.object.DynamicObjectLibrary;
33-
import com.oracle.truffle.api.profiles.BranchProfile;
3436

3537
import java.lang.invoke.VarHandle;
3638

@@ -46,9 +48,9 @@ public static WrapNode create() {
4648

4749
@Specialization
4850
protected ValueWrapper wrapLong(long value,
49-
@Cached @Exclusive BranchProfile smallFixnumProfile) {
51+
@Cached @Exclusive InlinedBranchProfile smallFixnumProfile) {
5052
if (value >= ValueWrapperManager.MIN_FIXNUM_VALUE && value <= ValueWrapperManager.MAX_FIXNUM_VALUE) {
51-
smallFixnumProfile.enter();
53+
smallFixnumProfile.enter(this);
5254
long val = (value << 1) | LONG_TAG;
5355
return new ValueWrapper(null, val, null);
5456
} else {
@@ -87,10 +89,10 @@ protected ValueWrapper wrapNil(Nil value) {
8789

8890
@Specialization(guards = "!isNil(value)")
8991
protected ValueWrapper wrapImmutable(ImmutableRubyObject value,
90-
@Cached @Shared BranchProfile noHandleProfile) {
92+
@Cached @Shared InlinedBranchProfile noHandleProfile) {
9193
ValueWrapper wrapper = value.getValueWrapper();
9294
if (wrapper == null) {
93-
noHandleProfile.enter();
95+
noHandleProfile.enter(this);
9496
synchronized (value) {
9597
wrapper = value.getValueWrapper();
9698
if (wrapper == null) {
@@ -106,12 +108,13 @@ protected ValueWrapper wrapImmutable(ImmutableRubyObject value,
106108
}
107109

108110
@Specialization(limit = "getDynamicObjectCacheLimit()")
109-
protected ValueWrapper wrapValue(RubyDynamicObject value,
111+
protected static ValueWrapper wrapValue(RubyDynamicObject value,
110112
@CachedLibrary("value") DynamicObjectLibrary objectLibrary,
111-
@Cached @Shared BranchProfile noHandleProfile) {
113+
@Cached @Shared InlinedBranchProfile noHandleProfile,
114+
@Bind("this") Node node) {
112115
ValueWrapper wrapper = (ValueWrapper) objectLibrary.getOrDefault(value, Layouts.VALUE_WRAPPER_IDENTIFIER, null);
113116
if (wrapper == null) {
114-
noHandleProfile.enter();
117+
noHandleProfile.enter(node);
115118
synchronized (value) {
116119
wrapper = (ValueWrapper) objectLibrary.getOrDefault(value, Layouts.VALUE_WRAPPER_IDENTIFIER, null);
117120
if (wrapper == null) {

src/main/java/org/truffleruby/cext/package-info.java

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

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import com.oracle.truffle.api.RootCallTarget;
1313
import com.oracle.truffle.api.dsl.GenerateUncached;
14+
import com.oracle.truffle.api.profiles.InlinedBranchProfile;
1415
import org.truffleruby.annotations.CoreMethod;
1516
import org.truffleruby.annotations.CoreModule;
1617
import org.truffleruby.core.inlined.AlwaysInlinedMethodNode;
@@ -25,7 +26,6 @@
2526
import com.oracle.truffle.api.dsl.Cached;
2627
import com.oracle.truffle.api.dsl.Specialization;
2728
import com.oracle.truffle.api.frame.Frame;
28-
import com.oracle.truffle.api.profiles.BranchProfile;
2929

3030
@CoreModule(value = "main", isClass = true)
3131
public abstract class MainNodes {
@@ -57,12 +57,12 @@ protected Object forward(Frame callerFrame, Object self, Object[] rubyArgs, Root
5757
public abstract static class MainUsingNode extends UsingNode {
5858
@Specialization
5959
protected Object mainUsing(Frame callerFrame, Object self, Object[] rubyArgs, RootCallTarget target,
60-
@Cached BranchProfile errorProfile) {
60+
@Cached InlinedBranchProfile errorProfile) {
6161
needCallerFrame(callerFrame, target);
6262
final Object refinementModule = RubyArguments.getArgument(rubyArgs, 0);
6363
final InternalMethod callerMethod = RubyArguments.getMethod(callerFrame);
6464
if (!isCalledFromTopLevel(callerMethod)) {
65-
errorProfile.enter();
65+
errorProfile.enter(this);
6666
throw new RaiseException(
6767
getContext(),
6868
coreExceptions().runtimeError("main.using is permitted only at toplevel", this));

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

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

1212
import com.oracle.truffle.api.dsl.NeverDefault;
13+
import com.oracle.truffle.api.profiles.InlinedConditionProfile;
1314
import org.truffleruby.cext.ValueWrapper;
1415
import org.truffleruby.core.MarkingService.ExtensionCallStack;
1516
import org.truffleruby.language.RubyBaseNode;
@@ -23,7 +24,6 @@
2324
import com.oracle.truffle.api.dsl.Cached.Shared;
2425
import com.oracle.truffle.api.dsl.GenerateUncached;
2526
import com.oracle.truffle.api.dsl.Specialization;
26-
import com.oracle.truffle.api.profiles.ConditionProfile;
2727

2828
public class MarkingServiceNodes {
2929

@@ -41,8 +41,8 @@ protected void keepFirstObject(ValueWrapper object,
4141
@Specialization(guards = "stack.hasSingleKeptObject()")
4242
protected void keepCreatingList(ValueWrapper object,
4343
@Bind("getStack(object)") ExtensionCallStack stack,
44-
@Cached ConditionProfile sameObjectProfile) {
45-
if (sameObjectProfile.profile(object != stack.current.preservedObject)) {
44+
@Cached InlinedConditionProfile sameObjectProfile) {
45+
if (sameObjectProfile.profile(this, object != stack.current.preservedObject)) {
4646
createKeptList(object, stack);
4747
}
4848
}
@@ -119,6 +119,7 @@ protected void marksToRun(ExtensionCallStack stack,
119119
}
120120

121121

122+
@NeverDefault
122123
public static RunMarkOnExitNode create() {
123124
return MarkingServiceNodesFactory.RunMarkOnExitNodeGen.create();
124125
}

0 commit comments

Comments
 (0)