61
61
import com .oracle .graal .python .nodes .function .builtins .PythonTernaryBuiltinNode ;
62
62
import com .oracle .graal .python .nodes .function .builtins .PythonUnaryBuiltinNode ;
63
63
import com .oracle .graal .python .nodes .truffle .PythonArithmeticTypes ;
64
+ import com .oracle .graal .python .runtime .ExecutionContext .IndirectCallContext ;
64
65
import com .oracle .graal .python .runtime .PythonContext ;
66
+ import com .oracle .graal .python .runtime .exception .PException ;
65
67
import com .oracle .graal .python .runtime .exception .PythonErrorType ;
66
68
import com .oracle .truffle .api .CompilerAsserts ;
67
69
import com .oracle .truffle .api .CompilerDirectives ;
@@ -199,10 +201,12 @@ private BytesNodes.ToBytesNode getToBytesNode() {
199
201
abstract static class TRegexCallCompile extends PythonTernaryBuiltinNode {
200
202
201
203
@ Specialization (limit = "1" )
202
- Object call (Object callable , Object arg1 , Object arg2 ,
204
+ Object call (VirtualFrame frame , Object callable , Object arg1 , Object arg2 ,
203
205
@ Cached ("create()" ) BranchProfile syntaxError ,
204
206
@ Cached ("create()" ) BranchProfile typeError ,
205
- @ CachedLibrary ("callable" ) InteropLibrary interop ) {
207
+ @ CachedLibrary ("callable" ) InteropLibrary interop ,
208
+ @ CachedContext (PythonLanguage .class ) PythonContext context ) {
209
+ PException savedExceptionState = IndirectCallContext .enter (frame , context , this );
206
210
try {
207
211
return interop .execute (callable , arg1 , arg2 );
208
212
} catch (ArityException | UnsupportedTypeException | UnsupportedMessageException e ) {
@@ -215,6 +219,8 @@ Object call(Object callable, Object arg1, Object arg2,
215
219
}
216
220
// just re-throw
217
221
throw e ;
222
+ } finally {
223
+ IndirectCallContext .exit (context , savedExceptionState );
218
224
}
219
225
}
220
226
}
@@ -225,14 +231,18 @@ Object call(Object callable, Object arg1, Object arg2,
225
231
abstract static class TRegexCallExec extends PythonTernaryBuiltinNode {
226
232
227
233
@ Specialization (limit = "1" )
228
- Object call (Object callable , Object arg1 , Number arg2 ,
234
+ Object call (VirtualFrame frame , Object callable , Object arg1 , Number arg2 ,
229
235
@ Cached ("create()" ) BranchProfile typeError ,
230
- @ CachedLibrary ("callable" ) InteropLibrary interop ) {
236
+ @ CachedLibrary ("callable" ) InteropLibrary interop ,
237
+ @ CachedContext (PythonLanguage .class ) PythonContext context ) {
238
+ PException savedExceptionState = IndirectCallContext .enter (frame , context , this );
231
239
try {
232
240
return interop .execute (callable , arg1 , arg2 );
233
241
} catch (ArityException | UnsupportedTypeException | UnsupportedMessageException e ) {
234
242
typeError .enter ();
235
243
throw raise (TypeError , "%s" , e );
244
+ } finally {
245
+ IndirectCallContext .exit (context , savedExceptionState );
236
246
}
237
247
}
238
248
}
0 commit comments