|
32 | 32 | import com.oracle.graal.python.builtins.objects.object.PythonObject;
|
33 | 33 | import com.oracle.graal.python.nodes.function.ClassBodyRootNode;
|
34 | 34 | import com.oracle.graal.python.runtime.exception.PException;
|
35 |
| -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; |
36 | 35 | import com.oracle.truffle.api.CompilerDirectives.ValueType;
|
| 36 | +import com.oracle.truffle.api.Truffle; |
37 | 37 | import com.oracle.truffle.api.frame.Frame;
|
38 | 38 | import com.oracle.truffle.api.frame.FrameDescriptor;
|
39 |
| -import com.oracle.truffle.api.frame.FrameSlot; |
40 | 39 | import com.oracle.truffle.api.frame.MaterializedFrame;
|
41 | 40 | import com.oracle.truffle.api.frame.VirtualFrame;
|
42 | 41 |
|
|
91 | 90 | public final class PArguments {
|
92 | 91 | public static final Object[] EMPTY_VARARGS = new Object[0];
|
93 | 92 |
|
| 93 | + private static final FrameDescriptor EMTPY_FD = new FrameDescriptor(); |
| 94 | + |
94 | 95 | private static final int INDEX_VARIABLE_ARGUMENTS = 0;
|
95 | 96 | private static final int INDEX_KEYWORD_ARGUMENTS = 1;
|
96 | 97 | private static final int INDEX_GENERATOR_FRAME = 2;
|
@@ -351,83 +352,28 @@ public static PDict getGeneratorFrameLocals(Object[] arguments) {
|
351 | 352 | }
|
352 | 353 |
|
353 | 354 | public static ThreadState getThreadState(VirtualFrame frame) {
|
354 |
| - return new ThreadStateImpl(PArguments.getCurrentFrameInfo(frame), PArguments.getException(frame)); |
| 355 | + return new ThreadState(PArguments.getCurrentFrameInfo(frame), PArguments.getException(frame)); |
355 | 356 | }
|
356 | 357 |
|
357 | 358 | public static VirtualFrame frameForCall(ThreadState frame) {
|
358 |
| - return (ThreadStateImpl) frame; |
| 359 | + Object[] args = PArguments.create(); |
| 360 | + PArguments.setCurrentFrameInfo(args, frame.info); |
| 361 | + PArguments.setException(args, frame.exc); |
| 362 | + return Truffle.getRuntime().createVirtualFrame(args, EMTPY_FD); |
359 | 363 | }
|
360 | 364 |
|
361 | 365 | /**
|
362 | 366 | * Represents the current thread state information that needs to be passed
|
363 |
| - * between calls. Should only have one implementation. |
| 367 | + * between calls. |
364 | 368 | */
|
365 |
| - public interface ThreadState { |
366 |
| - } |
367 |
| - |
368 | 369 | @ValueType
|
369 |
| - private static final class ThreadStateImpl implements VirtualFrame, ThreadState { |
370 |
| - @CompilationFinal(dimensions = 1) private final Object[] args = PArguments.create(); |
371 |
| - |
372 |
| - private ThreadStateImpl(PFrame.Reference info, PException exc) { |
373 |
| - PArguments.setCurrentFrameInfo(args, info); |
374 |
| - PArguments.setException(args, exc); |
375 |
| - } |
376 |
| - |
377 |
| - public Object[] getArguments() { |
378 |
| - return args; |
379 |
| - } |
| 370 | + public static final class ThreadState { |
| 371 | + private final PFrame.Reference info; |
| 372 | + private final PException exc; |
380 | 373 |
|
381 |
| - private static AbstractMethodError error() { |
382 |
| - return new AbstractMethodError("FrameState shouldn't be used as proper frame"); |
| 374 | + private ThreadState(PFrame.Reference info, PException exc) { |
| 375 | + this.info = info; |
| 376 | + this.exc = exc; |
383 | 377 | }
|
384 |
| - |
385 |
| - public FrameDescriptor getFrameDescriptor() { throw error(); } |
386 |
| - |
387 |
| - public Object getObject(FrameSlot slot) { throw error(); } |
388 |
| - |
389 |
| - public void setObject(FrameSlot slot, Object value) { throw error(); } |
390 |
| - |
391 |
| - public byte getByte(FrameSlot slot) { throw error(); } |
392 |
| - |
393 |
| - public void setByte(FrameSlot slot, byte value) { throw error(); } |
394 |
| - |
395 |
| - public boolean getBoolean(FrameSlot slot) { throw error(); } |
396 |
| - |
397 |
| - public void setBoolean(FrameSlot slot, boolean value) { throw error(); } |
398 |
| - |
399 |
| - public int getInt(FrameSlot slot) { throw error(); } |
400 |
| - |
401 |
| - public void setInt(FrameSlot slot, int value) { throw error(); } |
402 |
| - |
403 |
| - public long getLong(FrameSlot slot) { throw error(); } |
404 |
| - |
405 |
| - public void setLong(FrameSlot slot, long value) { throw error(); } |
406 |
| - |
407 |
| - public float getFloat(FrameSlot slot) { throw error(); } |
408 |
| - |
409 |
| - public void setFloat(FrameSlot slot, float value) { throw error(); } |
410 |
| - |
411 |
| - public double getDouble(FrameSlot slot) { throw error(); } |
412 |
| - |
413 |
| - public void setDouble(FrameSlot slot, double value) { throw error(); } |
414 |
| - |
415 |
| - public Object getValue(FrameSlot slot) { throw error(); } |
416 |
| - |
417 |
| - public MaterializedFrame materialize() { throw error(); } |
418 |
| - |
419 |
| - public boolean isObject(FrameSlot slot) { throw error(); } |
420 |
| - |
421 |
| - public boolean isByte(FrameSlot slot) { throw error(); } |
422 |
| - |
423 |
| - public boolean isBoolean(FrameSlot slot) { throw error(); } |
424 |
| - |
425 |
| - public boolean isInt(FrameSlot slot) { throw error(); } |
426 |
| - |
427 |
| - public boolean isLong(FrameSlot slot) { throw error(); } |
428 |
| - |
429 |
| - public boolean isFloat(FrameSlot slot) { throw error(); } |
430 |
| - |
431 |
| - public boolean isDouble(FrameSlot slot) { throw error(); } |
432 | 378 | }
|
433 | 379 | }
|
0 commit comments