4949import com .oracle .graal .python .runtime .PythonOptions ;
5050import com .oracle .graal .python .runtime .object .PythonObjectFactory ;
5151import com .oracle .graal .python .util .PythonUtils ;
52+ import com .oracle .truffle .api .CompilerAsserts ;
5253import com .oracle .truffle .api .Truffle ;
53- import com .oracle .truffle .api .bytecode .BytecodeLocation ;
5454import com .oracle .truffle .api .bytecode .BytecodeNode ;
5555import com .oracle .truffle .api .dsl .Bind ;
5656import 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