26
26
package com .oracle .graal .python .builtins .objects .function ;
27
27
28
28
import com .oracle .graal .python .builtins .objects .cell .PCell ;
29
- import com .oracle .graal .python .builtins .objects .dict .PDict ;
30
29
import com .oracle .graal .python .builtins .objects .frame .PFrame ;
31
- import com .oracle .graal .python .builtins .objects .frame .PFrame .Reference ;
32
30
import com .oracle .graal .python .builtins .objects .object .PythonObject ;
33
31
import com .oracle .graal .python .runtime .exception .PException ;
34
32
import com .oracle .graal .python .util .PythonUtils ;
35
33
import com .oracle .truffle .api .CompilerAsserts ;
36
- import com .oracle .truffle .api .CompilerDirectives .ValueType ;
37
- import com .oracle .truffle .api .Truffle ;
38
34
import com .oracle .truffle .api .frame .Frame ;
39
- import com .oracle .truffle .api .frame .FrameDescriptor ;
40
35
import com .oracle .truffle .api .frame .MaterializedFrame ;
41
36
import com .oracle .truffle .api .frame .VirtualFrame ;
42
- import com .oracle .truffle .api .profiles .ConditionProfile ;
43
37
44
38
//@formatter:off
45
39
/**
69
63
* | ... |
70
64
* | arg_(nArgs-1) |
71
65
* +-------------------+
72
- *
73
- * The layout of a generator frame (stored in INDEX_GENERATOR_FRAME in the figure above)
74
- * is different in on place:
75
- *
76
- * MaterializedFrame
77
- * |
78
- * | ....
79
- * | | |
80
- * | +----------------------+
81
- * INDEX_CALLER_FRAME_INFO -> | PDict (locals) |
82
- * +----------------------+
83
- * | .... |
84
66
*/
85
67
//@formatter:on
86
68
public final class PArguments {
87
- private static final FrameDescriptor EMTPY_FD = new FrameDescriptor ();
88
69
89
70
private static final int INDEX_VARIABLE_ARGUMENTS = 0 ;
90
71
private static final int INDEX_KEYWORD_ARGUMENTS = 1 ;
@@ -334,25 +315,9 @@ public static void setGeneratorFunction(Object[] arguments, PFunction generatorF
334
315
arguments [INDEX_GENERATOR_FRAME ] = generatorFunction ;
335
316
}
336
317
337
- public static void setGeneratorFrameLocals (Object [] arguments , PDict locals ) {
338
- arguments [INDEX_CALLER_FRAME_INFO ] = locals ;
339
- }
340
-
341
- public static PDict getGeneratorFrameLocals (Frame frame ) {
342
- return getGeneratorFrameLocals (frame .getArguments ());
343
- }
344
-
345
- public static PDict getGeneratorFrameLocals (Object [] arguments ) {
346
- return (PDict ) arguments [INDEX_CALLER_FRAME_INFO ];
347
- }
348
-
349
318
/**
350
319
* Synchronizes the arguments array of a Truffle frame with a {@link PFrame}. Copies only those
351
320
* arguments that are necessary to be synchronized between the two.
352
- *
353
- * NOTE: such arguments usually need to be preserved in {@link ThreadState} so that when we are
354
- * materializing a frame restored from {@link ThreadState}, the newly created instance of
355
- * {@link PFrame} will contain those arguments.
356
321
*/
357
322
public static void synchronizeArgs (Frame frameToMaterialize , PFrame escapedFrame ) {
358
323
Object [] arguments = frameToMaterialize .getArguments ();
@@ -368,40 +333,4 @@ public static void synchronizeArgs(Frame frameToMaterialize, PFrame escapedFrame
368
333
369
334
escapedFrame .setArguments (copiedArgs );
370
335
}
371
-
372
- public static ThreadState getThreadState (VirtualFrame frame ) {
373
- assert frame != null : "cannot get thread state without a frame" ;
374
- return new ThreadState (PArguments .getCurrentFrameInfo (frame ),
375
- PArguments .getExceptionUnchecked (frame .getArguments ()),
376
- PArguments .getGlobals (frame ));
377
- }
378
-
379
- public static ThreadState getThreadStateOrNull (VirtualFrame frame , ConditionProfile hasFrameProfile ) {
380
- return hasFrameProfile .profile (frame != null ) ? getThreadState (frame ) : null ;
381
- }
382
-
383
- public static VirtualFrame frameForCall (ThreadState frame ) {
384
- Object [] args = PArguments .create ();
385
- PArguments .setCurrentFrameInfo (args , frame .info );
386
- PArguments .setExceptionUnchecked (args , frame .exc );
387
- args [INDEX_GLOBALS_ARGUMENT ] = frame .globals ;
388
- return Truffle .getRuntime ().createVirtualFrame (args , EMTPY_FD );
389
- }
390
-
391
- /**
392
- * Represents the current thread state information that needs to be passed between calls.
393
- */
394
- @ ValueType
395
- public static final class ThreadState {
396
- private final PFrame .Reference info ;
397
- // The type is object because it is Object in the frame and casting it slows things down
398
- private final Object exc ;
399
- private final Object globals ;
400
-
401
- private ThreadState (Reference info , Object exc , Object globals ) {
402
- this .info = info ;
403
- this .exc = exc ;
404
- this .globals = globals ;
405
- }
406
- }
407
336
}
0 commit comments