Search in sources :

Example 46 with FrameSlot

use of com.oracle.truffle.api.frame.FrameSlot in project sulong by graalvm.

the class LazyToTruffleConverterImpl method getNullableFrameSlots.

private static FrameSlot[][] getNullableFrameSlots(FrameDescriptor frame, BitSet[] nullablePerBlock, List<FrameSlot> notNullable) {
    List<? extends FrameSlot> frameSlots = frame.getSlots();
    FrameSlot[][] result = new FrameSlot[nullablePerBlock.length][];
    for (int i = 0; i < nullablePerBlock.length; i++) {
        BitSet nullable = nullablePerBlock[i];
        int bitIndex = -1;
        ArrayList<FrameSlot> nullableSlots = new ArrayList<>();
        while ((bitIndex = nullable.nextSetBit(bitIndex + 1)) >= 0) {
            FrameSlot frameSlot = frameSlots.get(bitIndex);
            if (!notNullable.contains(frameSlot)) {
                nullableSlots.add(frameSlot);
            }
        }
        if (nullableSlots.size() > 0) {
            result[i] = nullableSlots.toArray(new FrameSlot[nullableSlots.size()]);
        } else {
            assert result[i] == null;
        }
    }
    return result;
}
Also used : FrameSlot(com.oracle.truffle.api.frame.FrameSlot) BitSet(java.util.BitSet) ArrayList(java.util.ArrayList)

Example 47 with FrameSlot

use of com.oracle.truffle.api.frame.FrameSlot in project sulong by graalvm.

the class LLVMGlobalWriteNode method slowPrimitiveWrite.

public static void slowPrimitiveWrite(LLVMContext context, LLVMMemory memory, PrimitiveType primitiveType, LLVMGlobal global, Object value) {
    MaterializedFrame frame = context.getGlobalFrame();
    FrameSlot slot = global.getSlot();
    boolean isNative = frame.getValue(slot) instanceof Native;
    long address = isNative ? ((Native) frame.getValue(slot)).getPointer() : 0;
    switch(primitiveType.getPrimitiveKind()) {
        case I1:
            if (isNative) {
                memory.putI1(address, (boolean) value);
            } else {
                frame.setBoolean(slot, (boolean) value);
            }
            return;
        case I8:
            if (isNative) {
                memory.putI8(address, (byte) value);
            } else {
                frame.setByte(slot, (byte) value);
            }
            return;
        case I16:
            if (isNative) {
                memory.putI16(address, (short) value);
            } else {
                frame.setInt(slot, (short) value);
            }
            return;
        case I32:
            if (isNative) {
                memory.putI32(address, (int) value);
            } else {
                frame.setInt(slot, (int) value);
            }
            return;
        case I64:
            if (isNative) {
                memory.putI64(address, (long) value);
            } else {
                frame.setLong(slot, (long) value);
            }
            return;
        case FLOAT:
            if (isNative) {
                memory.putFloat(address, (float) value);
            } else {
                frame.setFloat(slot, (float) value);
            }
            return;
        case DOUBLE:
            if (isNative) {
                memory.putDouble(address, (double) value);
            } else {
                frame.setDouble(slot, (double) value);
            }
            return;
    }
    CompilerDirectives.transferToInterpreter();
    throw new IllegalStateException();
}
Also used : Native(com.oracle.truffle.llvm.runtime.global.LLVMGlobal.Native) IsNative(com.oracle.truffle.llvm.runtime.global.LLVMGlobal.IsNative) FrameSlot(com.oracle.truffle.api.frame.FrameSlot) MaterializedFrame(com.oracle.truffle.api.frame.MaterializedFrame)

Aggregations

FrameSlot (com.oracle.truffle.api.frame.FrameSlot)47 LLVMExpressionNode (com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode)12 PrimitiveType (com.oracle.truffle.llvm.runtime.types.PrimitiveType)11 PointerType (com.oracle.truffle.llvm.runtime.types.PointerType)10 FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)7 TypeDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor)7 StructureType (com.oracle.truffle.llvm.runtime.types.StructureType)6 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 Type (com.oracle.truffle.llvm.runtime.types.Type)5 CallTarget (com.oracle.truffle.api.CallTarget)4 TruffleRuntime (com.oracle.truffle.api.TruffleRuntime)3 RootNode (com.oracle.truffle.api.nodes.RootNode)3 Phi (com.oracle.truffle.llvm.parser.LLVMPhiManager.Phi)3 LLVMArithmeticInstructionType (com.oracle.truffle.llvm.parser.instructions.LLVMArithmeticInstructionType)3 LLVMConversionType (com.oracle.truffle.llvm.parser.instructions.LLVMConversionType)3 SymbolImpl (com.oracle.truffle.llvm.parser.model.SymbolImpl)3 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)2 Frame (com.oracle.truffle.api.frame.Frame)2 FrameInstance (com.oracle.truffle.api.frame.FrameInstance)2