60
60
import com .oracle .graal .python .nodes .util .CannotCastException ;
61
61
import com .oracle .graal .python .nodes .util .CastToJavaLongLossyNode ;
62
62
import com .oracle .graal .python .runtime .ExecutionContext .IndirectCalleeContext ;
63
+ import com .oracle .graal .python .runtime .GilNode ;
63
64
import com .oracle .graal .python .runtime .PythonContext ;
64
65
import com .oracle .graal .python .runtime .PythonOptions ;
65
- import com .oracle .graal .python .runtime .GilNode ;
66
66
import com .oracle .graal .python .runtime .exception .ExceptionUtils ;
67
67
import com .oracle .graal .python .runtime .exception .PException ;
68
68
import com .oracle .graal .python .runtime .exception .PythonExitException ;
@@ -88,6 +88,8 @@ public class TopLevelExceptionHandler extends RootNode {
88
88
@ CompilationFinal private LanguageReference <PythonLanguage > language ;
89
89
@ CompilationFinal private ContextReference <PythonContext > context ;
90
90
91
+ @ Child GilNode gilNode = GilNode .create ();
92
+
91
93
public TopLevelExceptionHandler (PythonLanguage language , RootNode child ) {
92
94
super (language );
93
95
this .sourceSection = child .getSourceSection ();
@@ -121,7 +123,8 @@ private PythonContext getContext() {
121
123
@ Override
122
124
@ SuppressWarnings ("try" )
123
125
public Object execute (VirtualFrame frame ) {
124
- try (GilNode .UncachedAcquire gil = GilNode .uncachedAcquire ()) {
126
+ boolean wasAcquired = gilNode .acquire ();
127
+ try {
125
128
if (exception != null ) {
126
129
throw handlePythonException (exception .getEscapedException ());
127
130
} else {
@@ -140,6 +143,8 @@ public Object execute(VirtualFrame frame) {
140
143
throw e ;
141
144
}
142
145
}
146
+ } finally {
147
+ gilNode .release (wasAcquired );
143
148
}
144
149
}
145
150
0 commit comments