diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_shutdown.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_shutdown.py index 88ba72a09c..7be19de1cf 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_shutdown.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_shutdown.py @@ -51,6 +51,8 @@ ARGS = [] if sys.implementation.name == 'graalpy': ARGS = ['--python.EnableDebuggingBuiltins'] + if not __graalpython__.is_native and __graalpython__.is_bytecode_dsl_interpreter: + ARGS += ['--vm.Dpython.EnableBytecodeDSLInterpreter=true'] COMMAND = [sys.executable, *ARGS, str(MODULE_PATH)] diff --git a/graalpython/com.oracle.graal.python.test/src/tests/test_ssl_java_integration.py b/graalpython/com.oracle.graal.python.test/src/tests/test_ssl_java_integration.py index 6582d17f04..f21974b29c 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/test_ssl_java_integration.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/test_ssl_java_integration.py @@ -63,4 +63,9 @@ def test_load_default_verify_keystore(): """) env = os.environ.copy() env['JAVA_TOOL_OPTIONS'] = f"-Djavax.net.ssl.trustStore={curdir}/ssldata/signing_keystore.jks" - subprocess.run([sys.executable, '-c', src], env=env, check=True) + + args = [] + if __graalpython__.is_bytecode_dsl_interpreter: + args += ['--vm.Dpython.EnableBytecodeDSLInterpreter=true'] + + subprocess.run([sys.executable, *args, '-c', src], env=env, check=True) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLRootNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLRootNode.java index 5cea0ea4e6..8e6d3cc3cf 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLRootNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLRootNode.java @@ -3095,11 +3095,11 @@ public static void doEnter(VirtualFrame frame, Object contextManager, Object type = getClass.execute(inliningTarget, contextManager); Object enter = lookupEnter.execute(frame, type, contextManager); if (enter == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(AttributeError, new Object[]{T___ENTER__}); + throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.N_OBJECT_DOES_NOT_SUPPORT_CONTEXT_MANAGER_PROTOCOL, type); } Object exit = lookupExit.execute(frame, type, contextManager); if (exit == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(AttributeError, new Object[]{T___EXIT__}); + throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.N_OBJECT_DOES_NOT_SUPPORT_CONTEXT_MANAGER_PROTOCOL_EXIT, type); } Object result = callEnter.executeObject(frame, enter, contextManager); exitSetter.setObject(frame, exit); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/MaterializeFrameNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/MaterializeFrameNode.java index a2d4df4cf0..7789ea25a1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/MaterializeFrameNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/MaterializeFrameNode.java @@ -49,8 +49,8 @@ import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.object.PythonObjectFactory; import com.oracle.graal.python.util.PythonUtils; +import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.Truffle; -import com.oracle.truffle.api.bytecode.BytecodeLocation; import com.oracle.truffle.api.bytecode.BytecodeNode; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -180,13 +180,6 @@ private static void processBytecodeFrame(Frame frameToMaterialize, PFrame pyFram return; } if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { - BytecodeDSLFrameInfo bytecodeDSLFrameInfo = (BytecodeDSLFrameInfo) info; - PBytecodeDSLRootNode rootNode = bytecodeDSLFrameInfo.getRootNode(); - - if (location.getRootNode() != rootNode) { - throw new AssertionError("A node that did not belong to this root node was passed as a location."); - } - if (location instanceof PBytecodeDSLRootNode) { /** * Sometimes we don't have a precise location (see @@ -248,20 +241,45 @@ public abstract static class SyncFrameValuesNode extends Node { public abstract void execute(PFrame pyFrame, Frame frameToSync); - @Specialization(guards = {"!pyFrame.hasCustomLocals()", "frameToSync.getFrameDescriptor() == cachedFd", + @Specialization(guards = {"!pyFrame.hasCustomLocals()", + "frameToSync.getFrameDescriptor() == cachedFd", "variableSlotCount(cachedFd) < 32"}, limit = "1") @ExplodeLoop static void doSyncExploded(PFrame pyFrame, Frame frameToSync, @Cached(value = "frameToSync.getFrameDescriptor()") FrameDescriptor cachedFd) { MaterializedFrame target = pyFrame.getLocals(); assert cachedFd == target.getFrameDescriptor(); - doCopy(cachedFd, frameToSync, target); + int slotCount = variableSlotCount(cachedFd); + + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + FrameInfo info = (FrameInfo) cachedFd.getInfo(); + if (info instanceof BytecodeDSLFrameInfo bytecodeDSLFrameInfo) { + bytecodeDSLFrameInfo.getRootNode().copyLocals(frameToSync, target, slotCount); + } + } else { + for (int i = 0; i < slotCount; i++) { + PythonUtils.copyFrameSlot(frameToSync, target, i); + } + } } @Specialization(guards = "!pyFrame.hasCustomLocals()", replaces = "doSyncExploded") + @ExplodeLoop static void doSync(PFrame pyFrame, Frame frameToSync) { MaterializedFrame target = pyFrame.getLocals(); - doCopy(frameToSync.getFrameDescriptor(), frameToSync, target); + FrameDescriptor fd = target.getFrameDescriptor(); + int slotCount = variableSlotCount(fd); + + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + FrameInfo info = (FrameInfo) fd.getInfo(); + if (info instanceof BytecodeDSLFrameInfo bytecodeDSLFrameInfo) { + bytecodeDSLFrameInfo.getRootNode().copyLocals(frameToSync, target, slotCount); + } + } else { + for (int i = 0; i < slotCount; i++) { + PythonUtils.copyFrameSlot(frameToSync, target, i); + } + } } @Specialization(guards = "pyFrame.hasCustomLocals()") @@ -278,21 +296,5 @@ protected static int variableSlotCount(FrameDescriptor fd) { } return info.getVariableCount(); } - - private static void doCopy(FrameDescriptor fd, Frame source, MaterializedFrame destination) { - FrameInfo info = (FrameInfo) fd.getInfo(); - if (info == null) { - return; - } - int count = info.getVariableCount(); - - if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { - ((BytecodeDSLFrameInfo) info).getRootNode().copyLocals(source, destination, count); - } else { - for (int i = 0; i < count; i++) { - PythonUtils.copyFrameSlot(source, destination, i); - } - } - } } }