|
163 | 163 | import com.oracle.graal.python.runtime.PythonContext;
|
164 | 164 | import com.oracle.graal.python.runtime.PythonCore;
|
165 | 165 | import com.oracle.graal.python.runtime.PythonOptions;
|
| 166 | +import com.oracle.graal.python.runtime.PythonParser; |
166 | 167 | import com.oracle.graal.python.runtime.PythonParser.ParserMode;
|
167 | 168 | import com.oracle.graal.python.runtime.exception.PException;
|
168 | 169 | import com.oracle.graal.python.runtime.exception.PythonErrorType;
|
@@ -685,18 +686,24 @@ Object execCustomGlobalsGlobalLocals(Object source, PDict globals, @SuppressWarn
|
685 | 686 | PArguments.setPFrame(args, factory().createPFrame(globals));
|
686 | 687 | RootCallTarget rootCallTarget = code.getRootCallTarget();
|
687 | 688 | if (rootCallTarget == null) {
|
688 |
| - Source src = Source.newBuilder("python", new String(code.getCodestring()), code.getName()).build(); |
689 |
| - Node root = getCore().getParser().parse(ParserMode.File, getCore(), src, null); |
690 |
| - if (root instanceof RootNode) { |
691 |
| - rootCallTarget = Truffle.getRuntime().createCallTarget((RootNode) root); |
692 |
| - } |
| 689 | + rootCallTarget = extractRootCallTargetFromSource(code); |
693 | 690 | }
|
694 | 691 | if (rootCallTarget == null) {
|
695 | 692 | throw raise(ValueError, "cannot create the rootCallTarget from the code object: %p", code);
|
696 | 693 | }
|
697 | 694 | return indirectCallNode.call(rootCallTarget, args);
|
698 | 695 | }
|
699 | 696 |
|
| 697 | + @TruffleBoundary |
| 698 | + private RootCallTarget extractRootCallTargetFromSource(PCode code) { |
| 699 | + Source src = Source.newBuilder("python", new String(code.getCodestring()), code.getName()).build(); |
| 700 | + Node root = getCore().getParser().parse(ParserMode.File, getCore(), src, null); |
| 701 | + if (root instanceof RootNode) { |
| 702 | + return Truffle.getRuntime().createCallTarget((RootNode) root); |
| 703 | + } |
| 704 | + return null; |
| 705 | + } |
| 706 | + |
700 | 707 | @Specialization(guards = {"isMapping(locals)"})
|
701 | 708 | Object execInheritGlobalsCustomLocals(VirtualFrame frame, Object source, @SuppressWarnings("unused") PNone globals, Object locals,
|
702 | 709 | @Cached("create()") ReadCallerFrameNode readCallerFrameNode) {
|
|
0 commit comments