Skip to content

Commit 6aceeb5

Browse files
committed
FiberTransferNode is DSL inlinable node
1 parent efac4e8 commit 6aceeb5

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

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

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

12+
import com.oracle.truffle.api.dsl.GenerateCached;
13+
import com.oracle.truffle.api.dsl.GenerateInline;
1214
import com.oracle.truffle.api.frame.VirtualFrame;
15+
import com.oracle.truffle.api.nodes.Node;
1316
import com.oracle.truffle.api.profiles.InlinedBranchProfile;
1417
import com.oracle.truffle.api.profiles.InlinedConditionProfile;
1518
import com.oracle.truffle.api.strings.TruffleString;
@@ -54,18 +57,21 @@ protected Object transfer(
5457
ArgumentsDescriptor descriptor,
5558
Object[] args,
5659
@Cached FiberTransferNode fiberTransferNode) {
57-
return fiberTransferNode.execute(currentFiber, toFiber, operation, descriptor, args);
60+
return fiberTransferNode.execute(this, currentFiber, toFiber, operation, descriptor, args);
5861
}
5962

6063
}
6164

65+
@GenerateCached(false)
66+
@GenerateInline
6267
public abstract static class FiberTransferNode extends RubyBaseNode {
6368

64-
public abstract Object execute(RubyFiber currentFiber, RubyFiber toFiber, FiberOperation operation,
69+
public abstract Object execute(Node node, RubyFiber currentFiber, RubyFiber toFiber, FiberOperation operation,
6570
ArgumentsDescriptor descriptor, Object[] args);
6671

6772
@Specialization
68-
protected Object transfer(
73+
protected static Object transfer(
74+
Node node,
6975
RubyFiber currentFiber,
7076
RubyFiber toFiber,
7177
FiberOperation operation,
@@ -75,19 +81,19 @@ protected Object transfer(
7581
@Cached InlinedBranchProfile errorProfile) {
7682

7783
if (toFiber.isTerminated()) {
78-
errorProfile.enter(this);
79-
throw new RaiseException(getContext(), coreExceptions().deadFiberCalledError(this));
84+
errorProfile.enter(node);
85+
throw new RaiseException(getContext(node), coreExceptions(node).deadFiberCalledError(node));
8086
}
8187

8288
if (toFiber.rubyThread != currentFiber.rubyThread) {
83-
errorProfile.enter(this);
89+
errorProfile.enter(node);
8490
throw new RaiseException(
85-
getContext(),
86-
coreExceptions().fiberError("fiber called across threads", this));
91+
getContext(node),
92+
coreExceptions(node).fiberError("fiber called across threads", node));
8793
}
8894

89-
var descriptorAndArgs = getContext().fiberManager.transferControlTo(currentFiber, toFiber, operation,
90-
descriptor, args, this);
95+
var descriptorAndArgs = getContext(node).fiberManager.transferControlTo(currentFiber, toFiber, operation,
96+
descriptor, args, node);
9197
// Ignore the descriptor like CRuby here, see https://bugs.ruby-lang.org/issues/18621
9298
return singleValueCastNode.executeSingleValue(descriptorAndArgs.args);
9399
}
@@ -170,7 +176,7 @@ protected Object transfer(VirtualFrame frame, RubyFiber toFiber, Object[] rawArg
170176
return singleValueCastNode.executeSingleValue(rawArgs);
171177
}
172178

173-
return fiberTransferNode.execute(currentFiber, toFiber, FiberOperation.TRANSFER,
179+
return fiberTransferNode.execute(this, currentFiber, toFiber, FiberOperation.TRANSFER,
174180
RubyArguments.getDescriptor(frame), rawArgs);
175181
}
176182

@@ -222,7 +228,7 @@ protected Object resume(
222228
coreExceptions().fiberError("attempt to resume a transferring fiber", this));
223229
}
224230

225-
return fiberTransferNode.execute(currentFiber, toFiber, operation, descriptor, args);
231+
return fiberTransferNode.execute(this, currentFiber, toFiber, operation, descriptor, args);
226232
}
227233

228234
}
@@ -252,6 +258,7 @@ protected Object raise(RubyFiber fiber, RubyException exception,
252258
if (fiber.status == FiberStatus.SUSPENDED && !fiber.yielding) {
253259
final RubyFiber currentFiber = getLanguage().getCurrentFiber();
254260
return fiberTransferNode.execute(
261+
this,
255262
currentFiber,
256263
fiber,
257264
FiberOperation.RAISE,
@@ -301,6 +308,7 @@ protected Object fiberYield(VirtualFrame frame, Object[] rawArgs,
301308
.getReturnFiber(currentFiber, this, errorProfile);
302309

303310
return fiberTransferNode.execute(
311+
this,
304312
currentFiber,
305313
fiberYieldedTo,
306314
FiberOperation.YIELD,

0 commit comments

Comments
 (0)