Skip to content

Commit 9d1b2e9

Browse files
committed
SingleValueCastNode is DSL inlinable node
1 parent 6aceeb5 commit 9d1b2e9

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

src/main/java/org/truffleruby/core/cast/SingleValueCastNode.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
*/
1010
package org.truffleruby.core.cast;
1111

12+
import com.oracle.truffle.api.dsl.GenerateCached;
13+
import com.oracle.truffle.api.dsl.GenerateInline;
1214
import com.oracle.truffle.api.dsl.GenerateUncached;
15+
import com.oracle.truffle.api.nodes.Node;
1316
import org.truffleruby.core.array.RubyArray;
1417
import org.truffleruby.language.RubyBaseNode;
1518
import org.truffleruby.language.RubyGuards;
@@ -18,24 +21,26 @@
1821
import com.oracle.truffle.api.dsl.Specialization;
1922

2023
@GenerateUncached
24+
@GenerateInline
25+
@GenerateCached(false)
2126
@ImportStatic(value = { RubyGuards.class })
2227
public abstract class SingleValueCastNode extends RubyBaseNode {
2328

24-
public abstract Object executeSingleValue(Object[] args);
29+
public abstract Object execute(Node node, Object[] args);
2530

2631
@Specialization(guards = "noArguments(args)")
27-
protected Object castNil(Object[] args) {
32+
protected static Object castNil(Object[] args) {
2833
return nil;
2934
}
3035

3136
@Specialization(guards = "singleArgument(args)")
32-
protected Object castSingle(Object[] args) {
37+
protected static Object castSingle(Object[] args) {
3338
return args[0];
3439
}
3540

3641
@Specialization(guards = { "!noArguments(args)", "!singleArgument(args)" })
37-
protected RubyArray castMany(Object[] args) {
38-
return createArray(args);
42+
protected static RubyArray castMany(Node node, Object[] args) {
43+
return createArray(node, args);
3944
}
4045

4146
}

src/main/java/org/truffleruby/core/fiber/FiberNodes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected static Object transfer(
9595
var descriptorAndArgs = getContext(node).fiberManager.transferControlTo(currentFiber, toFiber, operation,
9696
descriptor, args, node);
9797
// Ignore the descriptor like CRuby here, see https://bugs.ruby-lang.org/issues/18621
98-
return singleValueCastNode.executeSingleValue(descriptorAndArgs.args);
98+
return singleValueCastNode.execute(node, descriptorAndArgs.args);
9999
}
100100

101101
}
@@ -173,7 +173,7 @@ protected Object transfer(VirtualFrame frame, RubyFiber toFiber, Object[] rawArg
173173

174174
if (sameFiberProfile.profile(this, currentFiber == toFiber)) {
175175
// A Fiber can transfer to itself
176-
return singleValueCastNode.executeSingleValue(rawArgs);
176+
return singleValueCastNode.execute(this, rawArgs);
177177
}
178178

179179
return fiberTransferNode.execute(this, currentFiber, toFiber, FiberOperation.TRANSFER,

src/main/java/org/truffleruby/core/module/ModuleNodes.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,7 +1649,7 @@ protected static Object methods(Frame callerFrame, RubyModule module, Object[] r
16491649
} finally {
16501650
profileAndReportLoopCount(node, loopProfile, i);
16511651
}
1652-
return singleValueCastNode.executeSingleValue(names);
1652+
return singleValueCastNode.execute(node, names);
16531653
}
16541654

16551655
private static void checkNotClass(Node node, RubyModule module, InlinedBranchProfile errorProfile) {
@@ -1726,7 +1726,7 @@ protected Object methods(Frame callerFrame, RubyModule module, Object[] rubyArgs
17261726
for (Object name : names) {
17271727
setMethodVisibilityNode.execute(module, name, Visibility.PUBLIC);
17281728
}
1729-
return singleValueCastNode.executeSingleValue(names);
1729+
return singleValueCastNode.execute(this, names);
17301730
}
17311731
}
17321732

@@ -1768,7 +1768,7 @@ protected Object methods(Frame callerFrame, RubyModule module, Object[] rubyArgs
17681768
for (Object name : names) {
17691769
setMethodVisibilityNode.execute(module, name, Visibility.PRIVATE);
17701770
}
1771-
return singleValueCastNode.executeSingleValue(names);
1771+
return singleValueCastNode.execute(this, names);
17721772
}
17731773
}
17741774

@@ -2054,7 +2054,7 @@ protected Object methods(Frame callerFrame, RubyModule module, Object[] rubyArgs
20542054
for (Object name : names) {
20552055
setMethodVisibilityNode.execute(module, name, Visibility.PROTECTED);
20562056
}
2057-
return singleValueCastNode.executeSingleValue(names);
2057+
return singleValueCastNode.execute(this, names);
20582058
}
20592059
}
20602060

src/main/java/org/truffleruby/language/methods/CallForeignMethodNode.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ protected abstract static class ConvertForOperatorAndReDispatchNode extends Ruby
165165
protected static Object callBoolean(Node node, Object receiver, String name, Object[] args,
166166
@CachedLibrary("receiver") InteropLibrary receivers,
167167
@Cached @Shared TranslateInteropExceptionNode translateInteropException,
168-
@Cached @Shared DispatchNode dispatch) {
168+
@Cached(inline = false) @Shared DispatchNode dispatch) {
169169
try {
170170
return dispatch.call(receivers.asBoolean(receiver), name, args);
171171
} catch (InteropException e) {
@@ -179,7 +179,7 @@ protected static Object callBoolean(Node node, Object receiver, String name, Obj
179179
protected static Object callInt(Node node, Object receiver, String name, Object[] args,
180180
@CachedLibrary("receiver") InteropLibrary receivers,
181181
@Cached @Shared TranslateInteropExceptionNode translateInteropException,
182-
@Cached @Shared DispatchNode dispatch) {
182+
@Cached(inline = false) @Shared DispatchNode dispatch) {
183183
try {
184184
return dispatch.call(receivers.asInt(receiver), name, args);
185185
} catch (InteropException e) {
@@ -196,7 +196,7 @@ protected static Object callInt(Node node, Object receiver, String name, Object[
196196
protected static Object callLong(Node node, Object receiver, String name, Object[] args,
197197
@CachedLibrary("receiver") InteropLibrary receivers,
198198
@Cached @Shared TranslateInteropExceptionNode translateInteropException,
199-
@Cached @Shared DispatchNode dispatch) {
199+
@Cached(inline = false) @Shared DispatchNode dispatch) {
200200
try {
201201
return dispatch.call(receivers.asLong(receiver), name, args);
202202
} catch (InteropException e) {
@@ -213,7 +213,7 @@ protected static Object callLong(Node node, Object receiver, String name, Object
213213
protected static Object callBigInteger(Node node, Object receiver, String name, Object[] args,
214214
@CachedLibrary("receiver") InteropLibrary receivers,
215215
@Cached @Shared TranslateInteropExceptionNode translateInteropException,
216-
@Cached @Shared DispatchNode dispatch) {
216+
@Cached(inline = false) @Shared DispatchNode dispatch) {
217217
try {
218218
return dispatch.call(new RubyBignum(receivers.asBigInteger(receiver)), name, args);
219219
} catch (InteropException e) {
@@ -230,7 +230,7 @@ protected static Object callBigInteger(Node node, Object receiver, String name,
230230
protected static Object callDouble(Node node, Object receiver, String name, Object[] args,
231231
@CachedLibrary("receiver") InteropLibrary receivers,
232232
@Cached @Shared TranslateInteropExceptionNode translateInteropException,
233-
@Cached @Shared DispatchNode dispatch) {
233+
@Cached(inline = false) @Shared DispatchNode dispatch) {
234234
try {
235235
return dispatch.call(receivers.asDouble(receiver), name, args);
236236
} catch (InteropException e) {

0 commit comments

Comments
 (0)