Search in sources :

Example 1 with FrameSlotTypeException

use of com.oracle.truffle.api.frame.FrameSlotTypeException in project graal by oracle.

the class OptimizedOSRLoopNodeTest method testTransferToInterpreter.

/*
     * Test that calling CompilerDirectives.transferToInterpreter does not invalidate the target.
     */
@Test
public void testTransferToInterpreter() {
    OSRLoopFactory factory = CONFIGURED;
    class TransferToInterpreterTestRepeatingNode extends TestRepeatingNode {

        @Override
        public boolean executeRepeating(VirtualFrame frame) {
            try {
                if (CompilerDirectives.inCompiledCode()) {
                    CompilerDirectives.transferToInterpreter();
                }
                int counter = frame.getInt(param1);
                frame.setInt(param1, counter - 1);
                return counter != 0;
            } catch (FrameSlotTypeException e) {
                return false;
            }
        }
    }
    TestRootNode rootNode = new TestRootNode(factory, new TransferToInterpreterTestRepeatingNode());
    CallTarget target = runtime.createCallTarget(rootNode);
    target.call(OSR_THRESHOLD + 1);
    try {
        // Invalidation is asynchronous.
        Thread.sleep(100);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    Assert.assertNotNull(rootNode.getOSRTarget());
}
Also used : VirtualFrame(com.oracle.truffle.api.frame.VirtualFrame) FrameSlotTypeException(com.oracle.truffle.api.frame.FrameSlotTypeException) RootCallTarget(com.oracle.truffle.api.RootCallTarget) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) DataPoint(org.junit.experimental.theories.DataPoint) Test(org.junit.Test)

Example 2 with FrameSlotTypeException

use of com.oracle.truffle.api.frame.FrameSlotTypeException in project TrufflePascal by Aspect26.

the class FileProgramArgumentAssignmentNode method executeVoid.

@Override
public void executeVoid(VirtualFrame frame) {
    try {
        FileValue file = (FileValue) frame.getObject(frameSlot);
        file.assignFilePath((String) frame.getArguments()[index]);
    } catch (FrameSlotTypeException e) {
        throw new PascalRuntimeException("Something went wrong");
    }
}
Also used : FileValue(cz.cuni.mff.d3s.trupple.language.runtime.customvalues.FileValue) FrameSlotTypeException(com.oracle.truffle.api.frame.FrameSlotTypeException) PascalRuntimeException(cz.cuni.mff.d3s.trupple.language.runtime.exceptions.PascalRuntimeException)

Example 3 with FrameSlotTypeException

use of com.oracle.truffle.api.frame.FrameSlotTypeException in project TrufflePascal by Aspect26.

the class WithNode method executeVoid.

@Override
public void executeVoid(VirtualFrame frame) {
    try {
        for (FrameSlot recordSlot : this.recordSlots) {
            RecordValue record = (RecordValue) frame.getObject(recordSlot);
            frame = record.getFrame();
        }
        innerStatement.executeVoid(frame);
    } catch (FrameSlotTypeException e) {
        throw new PascalRuntimeException("Unexpected accessing of non record type");
    }
}
Also used : FrameSlotTypeException(com.oracle.truffle.api.frame.FrameSlotTypeException) FrameSlot(com.oracle.truffle.api.frame.FrameSlot) RecordValue(cz.cuni.mff.d3s.trupple.language.runtime.customvalues.RecordValue) PascalRuntimeException(cz.cuni.mff.d3s.trupple.language.runtime.exceptions.PascalRuntimeException)

Example 4 with FrameSlotTypeException

use of com.oracle.truffle.api.frame.FrameSlotTypeException in project TrufflePascal by Aspect26.

the class ProgramArgumentAssignmentNode method assignFile.

private void assignFile(VirtualFrame frame, String filePath) {
    try {
        FileValue file = (FileValue) frame.getObject(targetSlot);
        file.assignFilePath(filePath);
    } catch (FrameSlotTypeException e) {
        throw new PascalRuntimeException("Something went wrong");
    }
}
Also used : FileValue(cz.cuni.mff.d3s.trupple.language.runtime.customvalues.FileValue) FrameSlotTypeException(com.oracle.truffle.api.frame.FrameSlotTypeException) PascalRuntimeException(cz.cuni.mff.d3s.trupple.language.runtime.exceptions.PascalRuntimeException)

Example 5 with FrameSlotTypeException

use of com.oracle.truffle.api.frame.FrameSlotTypeException in project TrufflePascal by Aspect26.

the class ForNode method executeVoid.

@Override
public void executeVoid(VirtualFrame frame) {
    try {
        ControlInterface controlInterface = null;
        switch(controlSlot.getKind()) {
            case Int:
                controlInterface = this.createIntControlInterface(frame);
                break;
            case Long:
                controlInterface = this.createLongControlInterface(frame);
                break;
            case Byte:
                controlInterface = this.createCharControlInterface(frame);
                break;
            case Object:
                Object controlValue = frame.getObject(controlSlot);
                if (controlValue instanceof EnumValue) {
                    controlInterface = this.createEnumControlInterface(frame);
                    break;
                } else {
                    throw new PascalRuntimeException("Unsupported control variable type");
                }
        }
        this.execute(frame, controlInterface, ascending);
    } catch (FrameSlotTypeException | UnexpectedResultException e) {
        throw new PascalRuntimeException("Something went wrong.");
    }
}
Also used : FrameSlotTypeException(com.oracle.truffle.api.frame.FrameSlotTypeException) UnexpectedResultException(com.oracle.truffle.api.nodes.UnexpectedResultException) EnumValue(cz.cuni.mff.d3s.trupple.language.runtime.customvalues.EnumValue) PascalRuntimeException(cz.cuni.mff.d3s.trupple.language.runtime.exceptions.PascalRuntimeException)

Aggregations

FrameSlotTypeException (com.oracle.truffle.api.frame.FrameSlotTypeException)6 PascalRuntimeException (cz.cuni.mff.d3s.trupple.language.runtime.exceptions.PascalRuntimeException)4 FileValue (cz.cuni.mff.d3s.trupple.language.runtime.customvalues.FileValue)2 CallTarget (com.oracle.truffle.api.CallTarget)1 RootCallTarget (com.oracle.truffle.api.RootCallTarget)1 FrameSlot (com.oracle.truffle.api.frame.FrameSlot)1 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)1 UnexpectedResultException (com.oracle.truffle.api.nodes.UnexpectedResultException)1 LLVMAddress (com.oracle.truffle.llvm.runtime.LLVMAddress)1 LLVMException (com.oracle.truffle.llvm.runtime.LLVMException)1 LLVMStack (com.oracle.truffle.llvm.runtime.memory.LLVMStack)1 EnumValue (cz.cuni.mff.d3s.trupple.language.runtime.customvalues.EnumValue)1 RecordValue (cz.cuni.mff.d3s.trupple.language.runtime.customvalues.RecordValue)1 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)1 Test (org.junit.Test)1 DataPoint (org.junit.experimental.theories.DataPoint)1