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;
}
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();
}
Aggregations