9
9
*/
10
10
package org .truffleruby .core .fiber ;
11
11
12
+ import com .oracle .truffle .api .dsl .GenerateCached ;
13
+ import com .oracle .truffle .api .dsl .GenerateInline ;
12
14
import com .oracle .truffle .api .frame .VirtualFrame ;
15
+ import com .oracle .truffle .api .nodes .Node ;
13
16
import com .oracle .truffle .api .profiles .InlinedBranchProfile ;
14
17
import com .oracle .truffle .api .profiles .InlinedConditionProfile ;
15
18
import com .oracle .truffle .api .strings .TruffleString ;
@@ -54,18 +57,21 @@ protected Object transfer(
54
57
ArgumentsDescriptor descriptor ,
55
58
Object [] args ,
56
59
@ Cached FiberTransferNode fiberTransferNode ) {
57
- return fiberTransferNode .execute (currentFiber , toFiber , operation , descriptor , args );
60
+ return fiberTransferNode .execute (this , currentFiber , toFiber , operation , descriptor , args );
58
61
}
59
62
60
63
}
61
64
65
+ @ GenerateCached (false )
66
+ @ GenerateInline
62
67
public abstract static class FiberTransferNode extends RubyBaseNode {
63
68
64
- public abstract Object execute (RubyFiber currentFiber , RubyFiber toFiber , FiberOperation operation ,
69
+ public abstract Object execute (Node node , RubyFiber currentFiber , RubyFiber toFiber , FiberOperation operation ,
65
70
ArgumentsDescriptor descriptor , Object [] args );
66
71
67
72
@ Specialization
68
- protected Object transfer (
73
+ protected static Object transfer (
74
+ Node node ,
69
75
RubyFiber currentFiber ,
70
76
RubyFiber toFiber ,
71
77
FiberOperation operation ,
@@ -75,19 +81,19 @@ protected Object transfer(
75
81
@ Cached InlinedBranchProfile errorProfile ) {
76
82
77
83
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 ));
80
86
}
81
87
82
88
if (toFiber .rubyThread != currentFiber .rubyThread ) {
83
- errorProfile .enter (this );
89
+ errorProfile .enter (node );
84
90
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 ));
87
93
}
88
94
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 );
91
97
// Ignore the descriptor like CRuby here, see https://bugs.ruby-lang.org/issues/18621
92
98
return singleValueCastNode .executeSingleValue (descriptorAndArgs .args );
93
99
}
@@ -170,7 +176,7 @@ protected Object transfer(VirtualFrame frame, RubyFiber toFiber, Object[] rawArg
170
176
return singleValueCastNode .executeSingleValue (rawArgs );
171
177
}
172
178
173
- return fiberTransferNode .execute (currentFiber , toFiber , FiberOperation .TRANSFER ,
179
+ return fiberTransferNode .execute (this , currentFiber , toFiber , FiberOperation .TRANSFER ,
174
180
RubyArguments .getDescriptor (frame ), rawArgs );
175
181
}
176
182
@@ -222,7 +228,7 @@ protected Object resume(
222
228
coreExceptions ().fiberError ("attempt to resume a transferring fiber" , this ));
223
229
}
224
230
225
- return fiberTransferNode .execute (currentFiber , toFiber , operation , descriptor , args );
231
+ return fiberTransferNode .execute (this , currentFiber , toFiber , operation , descriptor , args );
226
232
}
227
233
228
234
}
@@ -252,6 +258,7 @@ protected Object raise(RubyFiber fiber, RubyException exception,
252
258
if (fiber .status == FiberStatus .SUSPENDED && !fiber .yielding ) {
253
259
final RubyFiber currentFiber = getLanguage ().getCurrentFiber ();
254
260
return fiberTransferNode .execute (
261
+ this ,
255
262
currentFiber ,
256
263
fiber ,
257
264
FiberOperation .RAISE ,
@@ -301,6 +308,7 @@ protected Object fiberYield(VirtualFrame frame, Object[] rawArgs,
301
308
.getReturnFiber (currentFiber , this , errorProfile );
302
309
303
310
return fiberTransferNode .execute (
311
+ this ,
304
312
currentFiber ,
305
313
fiberYieldedTo ,
306
314
FiberOperation .YIELD ,
0 commit comments