Skip to content

Commit 6fbb9ee

Browse files
committed
Pass the current frame for Primitive.send_without_cext_lock & friends
* This was unintentionally removed in ce19ce4
1 parent a50c8e5 commit 6fbb9ee

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

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

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.jcodings.specific.USASCIIEncoding;
2020
import org.jcodings.specific.UTF8Encoding;
2121
import org.truffleruby.Layouts;
22-
import org.truffleruby.RubyContext;
2322
import org.truffleruby.builtins.CoreMethod;
2423
import org.truffleruby.builtins.CoreMethodArrayArgumentsNode;
2524
import org.truffleruby.builtins.CoreMethodNode;
@@ -175,64 +174,66 @@ protected int getCacheLimit() {
175174
}
176175
}
177176

178-
public static Object sendWithoutCExtLock(RubyContext context, Object receiver, RubySymbol method, Object block,
179-
DispatchNode dispatchNode, ConditionProfile ownedProfile, Object[] args, Node currentNode) {
180-
if (context.getOptions().CEXT_LOCK) {
181-
final ReentrantLock lock = context.getCExtensionsLock();
182-
boolean owned = ownedProfile.profile(lock.isHeldByCurrentThread());
177+
public abstract static class SendWithoutCExtLockBaseNode extends PrimitiveArrayArgumentsNode {
178+
public Object sendWithoutCExtLock(VirtualFrame frame, Object receiver, RubySymbol method, Object block,
179+
DispatchNode dispatchNode, ConditionProfile ownedProfile, Object[] args) {
180+
if (getContext().getOptions().CEXT_LOCK) {
181+
final ReentrantLock lock = getContext().getCExtensionsLock();
182+
boolean owned = ownedProfile.profile(lock.isHeldByCurrentThread());
183183

184-
if (owned) {
185-
MutexOperations.unlockInternal(lock);
186-
}
187-
try {
188-
return dispatchNode.callWithBlock(receiver, method.getString(), block, args);
189-
} finally {
190184
if (owned) {
191-
MutexOperations.internalLockEvenWithException(context, lock, currentNode);
185+
MutexOperations.unlockInternal(lock);
192186
}
187+
try {
188+
return dispatchNode.dispatch(frame, receiver, method.getString(), block, args);
189+
} finally {
190+
if (owned) {
191+
MutexOperations.internalLockEvenWithException(getContext(), lock, this);
192+
}
193+
}
194+
} else {
195+
return dispatchNode.dispatch(frame, receiver, method.getString(), block, args);
193196
}
194-
} else {
195-
return dispatchNode.callWithBlock(receiver, method.getString(), block, args);
196197
}
197198
}
198199

199200
@Primitive(name = "send_without_cext_lock")
200-
public abstract static class SendWithoutCExtLockNode extends PrimitiveArrayArgumentsNode {
201+
public abstract static class SendWithoutCExtLockNode extends SendWithoutCExtLockBaseNode {
201202
@Specialization
202-
protected Object sendWithoutCExtLock(Object receiver, RubySymbol method, RubyArray argsArray, Object block,
203+
protected Object sendWithoutCExtLock(
204+
VirtualFrame frame, Object receiver, RubySymbol method, RubyArray argsArray, Object block,
203205
@Cached ArrayToObjectArrayNode arrayToObjectArrayNode,
204206
@Cached DispatchNode dispatchNode,
205207
@Cached ConditionProfile ownedProfile) {
206208
final Object[] args = arrayToObjectArrayNode.executeToObjectArray(argsArray);
207-
return CExtNodes
208-
.sendWithoutCExtLock(getContext(), receiver, method, block, dispatchNode, ownedProfile, args, this);
209+
return sendWithoutCExtLock(frame, receiver, method, block, dispatchNode, ownedProfile, args);
209210
}
210211

211212
}
212213

213214
@Primitive(name = "send_argv_without_cext_lock")
214-
public abstract static class SendARGVWithoutCExtLockNode extends PrimitiveArrayArgumentsNode {
215+
public abstract static class SendARGVWithoutCExtLockNode extends SendWithoutCExtLockBaseNode {
215216
@Specialization
216-
protected Object sendWithoutCExtLock(Object receiver, RubySymbol method, Object argv, Object block,
217+
protected Object sendWithoutCExtLock(
218+
VirtualFrame frame, Object receiver, RubySymbol method, Object argv, Object block,
217219
@Cached UnwrapCArrayNode unwrapCArrayNode,
218220
@Cached DispatchNode dispatchNode,
219221
@Cached ConditionProfile ownedProfile) {
220222
final Object[] args = unwrapCArrayNode.execute(argv);
221-
return CExtNodes
222-
.sendWithoutCExtLock(getContext(), receiver, method, block, dispatchNode, ownedProfile, args, this);
223+
return sendWithoutCExtLock(frame, receiver, method, block, dispatchNode, ownedProfile, args);
223224
}
224225
}
225226

226227
@Primitive(name = "public_send_argv_without_cext_lock", lowerFixnum = 2)
227-
public abstract static class PublicSendARGVWithoutCExtLockNode extends PrimitiveArrayArgumentsNode {
228+
public abstract static class PublicSendARGVWithoutCExtLockNode extends SendWithoutCExtLockBaseNode {
228229
@Specialization
229-
protected Object publicSendWithoutLock(Object receiver, RubySymbol method, Object argv, Object block,
230+
protected Object publicSendWithoutLock(
231+
VirtualFrame frame, Object receiver, RubySymbol method, Object argv, Object block,
230232
@Cached UnwrapCArrayNode unwrapCArrayNode,
231233
@Cached(parameters = "PUBLIC") DispatchNode dispatchNode,
232234
@Cached ConditionProfile ownedProfile) {
233235
final Object[] args = unwrapCArrayNode.execute(argv);
234-
return CExtNodes
235-
.sendWithoutCExtLock(getContext(), receiver, method, block, dispatchNode, ownedProfile, args, this);
236+
return sendWithoutCExtLock(frame, receiver, method, block, dispatchNode, ownedProfile, args);
236237
}
237238
}
238239

0 commit comments

Comments
 (0)