Added 64 bit width to sizes and handle it in memory implementations.

This commit is contained in:
Florian Nücke
2020-09-24 13:26:03 +02:00
parent 49b6a56ca3
commit eb22fef001
3 changed files with 13 additions and 0 deletions

View File

@@ -4,8 +4,10 @@ public final class Sizes {
public static final int SIZE_8 = 8;
public static final int SIZE_16 = 16;
public static final int SIZE_32 = 32;
public static final int SIZE_64 = 64;
public static final int SIZE_8_LOG2 = 0;
public static final int SIZE_16_LOG2 = 1;
public static final int SIZE_32_LOG2 = 2;
public static final int SIZE_64_LOG2 = 3;
}

View File

@@ -34,6 +34,9 @@ public class ByteBufferMemory implements PhysicalMemory {
return data.getShort(offset);
case Sizes.SIZE_32_LOG2:
return data.getInt(offset);
case Sizes.SIZE_64_LOG2:
// TODO Widen API to support 64 bit values and addresses.
return (int) data.getLong(offset);
default:
throw new IllegalArgumentException();
}

View File

@@ -60,6 +60,10 @@ public final class UnsafeMemory implements PhysicalMemory {
case Sizes.SIZE_32_LOG2:
assert (offset & 0b11) == 0;
return UNSAFE.getInt(address + offset);
case Sizes.SIZE_64_LOG2:
assert (offset & 0b111) == 0;
// TODO Widen API to support 64 bit values and addresses.
return (int) UNSAFE.getLong(address + offset);
default:
throw new IllegalArgumentException();
}
@@ -80,6 +84,10 @@ public final class UnsafeMemory implements PhysicalMemory {
assert (offset & 0b11) == 0;
UNSAFE.putInt(address + offset, value);
break;
case Sizes.SIZE_64_LOG2:
assert (offset & 0b111) == 0;
UNSAFE.putLong(address + offset, value);
break;
default:
throw new IllegalArgumentException();
}