Skip to content

Commit 97b2cb7

Browse files
committed
do not implement VirtualFrame
1 parent 4ea63df commit 97b2cb7

File tree

1 file changed

+15
-69
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function

1 file changed

+15
-69
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/PArguments.java

Lines changed: 15 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@
3232
import com.oracle.graal.python.builtins.objects.object.PythonObject;
3333
import com.oracle.graal.python.nodes.function.ClassBodyRootNode;
3434
import com.oracle.graal.python.runtime.exception.PException;
35-
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
3635
import com.oracle.truffle.api.CompilerDirectives.ValueType;
36+
import com.oracle.truffle.api.Truffle;
3737
import com.oracle.truffle.api.frame.Frame;
3838
import com.oracle.truffle.api.frame.FrameDescriptor;
39-
import com.oracle.truffle.api.frame.FrameSlot;
4039
import com.oracle.truffle.api.frame.MaterializedFrame;
4140
import com.oracle.truffle.api.frame.VirtualFrame;
4241

@@ -91,6 +90,8 @@
9190
public final class PArguments {
9291
public static final Object[] EMPTY_VARARGS = new Object[0];
9392

93+
private static final FrameDescriptor EMTPY_FD = new FrameDescriptor();
94+
9495
private static final int INDEX_VARIABLE_ARGUMENTS = 0;
9596
private static final int INDEX_KEYWORD_ARGUMENTS = 1;
9697
private static final int INDEX_GENERATOR_FRAME = 2;
@@ -351,83 +352,28 @@ public static PDict getGeneratorFrameLocals(Object[] arguments) {
351352
}
352353

353354
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));
355356
}
356357

357358
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);
359363
}
360364

361365
/**
362366
* Represents the current thread state information that needs to be passed
363-
* between calls. Should only have one implementation.
367+
* between calls.
364368
*/
365-
public interface ThreadState {
366-
}
367-
368369
@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;
380373

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;
383377
}
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(); }
432378
}
433379
}

0 commit comments

Comments
 (0)