6060import com .oracle .graal .python .nodes .util .CannotCastException ;
6161import com .oracle .graal .python .nodes .util .CastToJavaLongLossyNode ;
6262import com .oracle .graal .python .runtime .ExecutionContext .IndirectCalleeContext ;
63+ import com .oracle .graal .python .runtime .GilNode ;
6364import com .oracle .graal .python .runtime .PythonContext ;
6465import com .oracle .graal .python .runtime .PythonOptions ;
65- import com .oracle .graal .python .runtime .GilNode ;
6666import com .oracle .graal .python .runtime .exception .ExceptionUtils ;
6767import com .oracle .graal .python .runtime .exception .PException ;
6868import com .oracle .graal .python .runtime .exception .PythonExitException ;
@@ -88,6 +88,8 @@ public class TopLevelExceptionHandler extends RootNode {
8888 @ CompilationFinal private LanguageReference <PythonLanguage > language ;
8989 @ CompilationFinal private ContextReference <PythonContext > context ;
9090
91+ @ Child GilNode gilNode = GilNode .create ();
92+
9193 public TopLevelExceptionHandler (PythonLanguage language , RootNode child ) {
9294 super (language );
9395 this .sourceSection = child .getSourceSection ();
@@ -121,7 +123,8 @@ private PythonContext getContext() {
121123 @ Override
122124 @ SuppressWarnings ("try" )
123125 public Object execute (VirtualFrame frame ) {
124- try (GilNode .UncachedAcquire gil = GilNode .uncachedAcquire ()) {
126+ boolean wasAcquired = gilNode .acquire ();
127+ try {
125128 if (exception != null ) {
126129 throw handlePythonException (exception .getEscapedException ());
127130 } else {
@@ -140,6 +143,8 @@ public Object execute(VirtualFrame frame) {
140143 throw e ;
141144 }
142145 }
146+ } finally {
147+ gilNode .release (wasAcquired );
143148 }
144149 }
145150
0 commit comments