49
49
import com .oracle .graal .python .runtime .PythonOptions ;
50
50
import com .oracle .graal .python .runtime .object .PythonObjectFactory ;
51
51
import com .oracle .graal .python .util .PythonUtils ;
52
+ import com .oracle .truffle .api .CompilerAsserts ;
52
53
import com .oracle .truffle .api .Truffle ;
53
- import com .oracle .truffle .api .bytecode .BytecodeLocation ;
54
54
import com .oracle .truffle .api .bytecode .BytecodeNode ;
55
55
import com .oracle .truffle .api .dsl .Bind ;
56
56
import com .oracle .truffle .api .dsl .Cached ;
@@ -180,13 +180,6 @@ private static void processBytecodeFrame(Frame frameToMaterialize, PFrame pyFram
180
180
return ;
181
181
}
182
182
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
-
190
183
if (location instanceof PBytecodeDSLRootNode ) {
191
184
/**
192
185
* Sometimes we don't have a precise location (see
@@ -248,20 +241,45 @@ public abstract static class SyncFrameValuesNode extends Node {
248
241
249
242
public abstract void execute (PFrame pyFrame , Frame frameToSync );
250
243
251
- @ Specialization (guards = {"!pyFrame.hasCustomLocals()" , "frameToSync.getFrameDescriptor() == cachedFd" ,
244
+ @ Specialization (guards = {"!pyFrame.hasCustomLocals()" ,
245
+ "frameToSync.getFrameDescriptor() == cachedFd" ,
252
246
"variableSlotCount(cachedFd) < 32" }, limit = "1" )
253
247
@ ExplodeLoop
254
248
static void doSyncExploded (PFrame pyFrame , Frame frameToSync ,
255
249
@ Cached (value = "frameToSync.getFrameDescriptor()" ) FrameDescriptor cachedFd ) {
256
250
MaterializedFrame target = pyFrame .getLocals ();
257
251
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
+ }
259
264
}
260
265
261
266
@ Specialization (guards = "!pyFrame.hasCustomLocals()" , replaces = "doSyncExploded" )
267
+ @ ExplodeLoop
262
268
static void doSync (PFrame pyFrame , Frame frameToSync ) {
263
269
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
+ }
265
283
}
266
284
267
285
@ Specialization (guards = "pyFrame.hasCustomLocals()" )
@@ -278,21 +296,5 @@ protected static int variableSlotCount(FrameDescriptor fd) {
278
296
}
279
297
return info .getVariableCount ();
280
298
}
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
- }
297
299
}
298
300
}
0 commit comments