|
19 | 19 | import org.jcodings.specific.USASCIIEncoding;
|
20 | 20 | import org.jcodings.specific.UTF8Encoding;
|
21 | 21 | import org.truffleruby.Layouts;
|
22 |
| -import org.truffleruby.RubyContext; |
23 | 22 | import org.truffleruby.builtins.CoreMethod;
|
24 | 23 | import org.truffleruby.builtins.CoreMethodArrayArgumentsNode;
|
25 | 24 | import org.truffleruby.builtins.CoreMethodNode;
|
@@ -175,64 +174,66 @@ protected int getCacheLimit() {
|
175 | 174 | }
|
176 | 175 | }
|
177 | 176 |
|
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()); |
183 | 183 |
|
184 |
| - if (owned) { |
185 |
| - MutexOperations.unlockInternal(lock); |
186 |
| - } |
187 |
| - try { |
188 |
| - return dispatchNode.callWithBlock(receiver, method.getString(), block, args); |
189 |
| - } finally { |
190 | 184 | if (owned) {
|
191 |
| - MutexOperations.internalLockEvenWithException(context, lock, currentNode); |
| 185 | + MutexOperations.unlockInternal(lock); |
192 | 186 | }
|
| 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); |
193 | 196 | }
|
194 |
| - } else { |
195 |
| - return dispatchNode.callWithBlock(receiver, method.getString(), block, args); |
196 | 197 | }
|
197 | 198 | }
|
198 | 199 |
|
199 | 200 | @Primitive(name = "send_without_cext_lock")
|
200 |
| - public abstract static class SendWithoutCExtLockNode extends PrimitiveArrayArgumentsNode { |
| 201 | + public abstract static class SendWithoutCExtLockNode extends SendWithoutCExtLockBaseNode { |
201 | 202 | @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, |
203 | 205 | @Cached ArrayToObjectArrayNode arrayToObjectArrayNode,
|
204 | 206 | @Cached DispatchNode dispatchNode,
|
205 | 207 | @Cached ConditionProfile ownedProfile) {
|
206 | 208 | 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); |
209 | 210 | }
|
210 | 211 |
|
211 | 212 | }
|
212 | 213 |
|
213 | 214 | @Primitive(name = "send_argv_without_cext_lock")
|
214 |
| - public abstract static class SendARGVWithoutCExtLockNode extends PrimitiveArrayArgumentsNode { |
| 215 | + public abstract static class SendARGVWithoutCExtLockNode extends SendWithoutCExtLockBaseNode { |
215 | 216 | @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, |
217 | 219 | @Cached UnwrapCArrayNode unwrapCArrayNode,
|
218 | 220 | @Cached DispatchNode dispatchNode,
|
219 | 221 | @Cached ConditionProfile ownedProfile) {
|
220 | 222 | 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); |
223 | 224 | }
|
224 | 225 | }
|
225 | 226 |
|
226 | 227 | @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 { |
228 | 229 | @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, |
230 | 232 | @Cached UnwrapCArrayNode unwrapCArrayNode,
|
231 | 233 | @Cached(parameters = "PUBLIC") DispatchNode dispatchNode,
|
232 | 234 | @Cached ConditionProfile ownedProfile) {
|
233 | 235 | 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); |
236 | 237 | }
|
237 | 238 | }
|
238 | 239 |
|
|
0 commit comments