Skip to content

Commit b2cff2d

Browse files
committed
Fix some failing tests; remove root node comparison in MaterializeFrameNode; fix runtime compilation of SyncFrameValuesNode
1 parent ed50e8f commit b2cff2d

File tree

4 files changed

+39
-30
lines changed

4 files changed

+39
-30
lines changed

graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_shutdown.py

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
ARGS = []
5252
if sys.implementation.name == 'graalpy':
5353
ARGS = ['--python.EnableDebuggingBuiltins']
54+
if not __graalpython__.is_native and __graalpython__.is_bytecode_dsl_interpreter:
55+
ARGS += ['--vm.Dpython.EnableBytecodeDSLInterpreter=true']
5456
COMMAND = [sys.executable, *ARGS, str(MODULE_PATH)]
5557

5658

graalpython/com.oracle.graal.python.test/src/tests/test_ssl_java_integration.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,9 @@ def test_load_default_verify_keystore():
6363
""")
6464
env = os.environ.copy()
6565
env['JAVA_TOOL_OPTIONS'] = f"-Djavax.net.ssl.trustStore={curdir}/ssldata/signing_keystore.jks"
66-
subprocess.run([sys.executable, '-c', src], env=env, check=True)
66+
67+
args = []
68+
if __graalpython__.is_bytecode_dsl_interpreter:
69+
args += ['--vm.Dpython.EnableBytecodeDSLInterpreter=true']
70+
71+
subprocess.run([sys.executable, *args, '-c', src], env=env, check=True)

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLRootNode.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -3095,11 +3095,11 @@ public static void doEnter(VirtualFrame frame, Object contextManager,
30953095
Object type = getClass.execute(inliningTarget, contextManager);
30963096
Object enter = lookupEnter.execute(frame, type, contextManager);
30973097
if (enter == PNone.NO_VALUE) {
3098-
throw raiseNode.get(inliningTarget).raise(AttributeError, new Object[]{T___ENTER__});
3098+
throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.N_OBJECT_DOES_NOT_SUPPORT_CONTEXT_MANAGER_PROTOCOL, type);
30993099
}
31003100
Object exit = lookupExit.execute(frame, type, contextManager);
31013101
if (exit == PNone.NO_VALUE) {
3102-
throw raiseNode.get(inliningTarget).raise(AttributeError, new Object[]{T___EXIT__});
3102+
throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.N_OBJECT_DOES_NOT_SUPPORT_CONTEXT_MANAGER_PROTOCOL_EXIT, type);
31033103
}
31043104
Object result = callEnter.executeObject(frame, enter, contextManager);
31053105
exitSetter.setObject(frame, exit);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/MaterializeFrameNode.java

+29-27
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
import com.oracle.graal.python.runtime.PythonOptions;
5050
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
5151
import com.oracle.graal.python.util.PythonUtils;
52+
import com.oracle.truffle.api.CompilerAsserts;
5253
import com.oracle.truffle.api.Truffle;
53-
import com.oracle.truffle.api.bytecode.BytecodeLocation;
5454
import com.oracle.truffle.api.bytecode.BytecodeNode;
5555
import com.oracle.truffle.api.dsl.Bind;
5656
import com.oracle.truffle.api.dsl.Cached;
@@ -180,13 +180,6 @@ private static void processBytecodeFrame(Frame frameToMaterialize, PFrame pyFram
180180
return;
181181
}
182182
if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
183-
BytecodeDSLFrameInfo bytecodeDSLFrameInfo = (BytecodeDSLFrameInfo) info;
184-
PBytecodeDSLRootNode rootNode = bytecodeDSLFrameInfo.getRootNode();
185-
186-
if (location.getRootNode() != rootNode) {
187-
throw new AssertionError("A node that did not belong to this root node was passed as a location.");
188-
}
189-
190183
if (location instanceof PBytecodeDSLRootNode) {
191184
/**
192185
* Sometimes we don't have a precise location (see
@@ -248,20 +241,45 @@ public abstract static class SyncFrameValuesNode extends Node {
248241

249242
public abstract void execute(PFrame pyFrame, Frame frameToSync);
250243

251-
@Specialization(guards = {"!pyFrame.hasCustomLocals()", "frameToSync.getFrameDescriptor() == cachedFd",
244+
@Specialization(guards = {"!pyFrame.hasCustomLocals()",
245+
"frameToSync.getFrameDescriptor() == cachedFd",
252246
"variableSlotCount(cachedFd) < 32"}, limit = "1")
253247
@ExplodeLoop
254248
static void doSyncExploded(PFrame pyFrame, Frame frameToSync,
255249
@Cached(value = "frameToSync.getFrameDescriptor()") FrameDescriptor cachedFd) {
256250
MaterializedFrame target = pyFrame.getLocals();
257251
assert cachedFd == target.getFrameDescriptor();
258-
doCopy(cachedFd, frameToSync, target);
252+
int slotCount = variableSlotCount(cachedFd);
253+
254+
if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
255+
FrameInfo info = (FrameInfo) cachedFd.getInfo();
256+
if (info instanceof BytecodeDSLFrameInfo bytecodeDSLFrameInfo) {
257+
bytecodeDSLFrameInfo.getRootNode().copyLocals(frameToSync, target, slotCount);
258+
}
259+
} else {
260+
for (int i = 0; i < slotCount; i++) {
261+
PythonUtils.copyFrameSlot(frameToSync, target, i);
262+
}
263+
}
259264
}
260265

261266
@Specialization(guards = "!pyFrame.hasCustomLocals()", replaces = "doSyncExploded")
267+
@ExplodeLoop
262268
static void doSync(PFrame pyFrame, Frame frameToSync) {
263269
MaterializedFrame target = pyFrame.getLocals();
264-
doCopy(frameToSync.getFrameDescriptor(), frameToSync, target);
270+
FrameDescriptor fd = target.getFrameDescriptor();
271+
int slotCount = variableSlotCount(fd);
272+
273+
if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
274+
FrameInfo info = (FrameInfo) fd.getInfo();
275+
if (info instanceof BytecodeDSLFrameInfo bytecodeDSLFrameInfo) {
276+
bytecodeDSLFrameInfo.getRootNode().copyLocals(frameToSync, target, slotCount);
277+
}
278+
} else {
279+
for (int i = 0; i < slotCount; i++) {
280+
PythonUtils.copyFrameSlot(frameToSync, target, i);
281+
}
282+
}
265283
}
266284

267285
@Specialization(guards = "pyFrame.hasCustomLocals()")
@@ -278,21 +296,5 @@ protected static int variableSlotCount(FrameDescriptor fd) {
278296
}
279297
return info.getVariableCount();
280298
}
281-
282-
private static void doCopy(FrameDescriptor fd, Frame source, MaterializedFrame destination) {
283-
FrameInfo info = (FrameInfo) fd.getInfo();
284-
if (info == null) {
285-
return;
286-
}
287-
int count = info.getVariableCount();
288-
289-
if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
290-
((BytecodeDSLFrameInfo) info).getRootNode().copyLocals(source, destination, count);
291-
} else {
292-
for (int i = 0; i < count; i++) {
293-
PythonUtils.copyFrameSlot(source, destination, i);
294-
}
295-
}
296-
}
297299
}
298300
}

0 commit comments

Comments
 (0)