implements PR-O1.5
This commit is contained in:
+27
-1
@@ -116,6 +116,33 @@ class BytecodeEmitterTest {
|
||||
assertEquals(0x2000, readU32(module.code(), 2));
|
||||
}
|
||||
|
||||
@Test
|
||||
void emitMustProducePcToSpanForEveryInstructionStartWhenSpansAreProvided() {
|
||||
final var emitter = new BytecodeEmitter();
|
||||
final var module = emitter.emit(new BytecodeEmitter.EmissionPlan(
|
||||
0,
|
||||
ReadOnlyList.empty(),
|
||||
ReadOnlyList.empty(),
|
||||
ReadOnlyList.from(
|
||||
new BytecodeEmitter.FunctionPlan(
|
||||
"main",
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
4,
|
||||
ReadOnlyList.from(
|
||||
BytecodeEmitter.Operation.halt(new BytecodeModule.SourceSpan(1, 0, 1)),
|
||||
BytecodeEmitter.Operation.callFunc(0, new BytecodeModule.SourceSpan(1, 2, 3)),
|
||||
BytecodeEmitter.Operation.intrinsic(0x2000, new BytecodeModule.SourceSpan(1, 4, 5)),
|
||||
BytecodeEmitter.Operation.ret(new BytecodeModule.SourceSpan(1, 6, 7)))))));
|
||||
|
||||
assertEquals(4, module.debugInfo().pcToSpan().size());
|
||||
assertEquals(0, module.debugInfo().pcToSpan().get(0).pc());
|
||||
assertEquals(2, module.debugInfo().pcToSpan().get(1).pc());
|
||||
assertEquals(8, module.debugInfo().pcToSpan().get(2).pc());
|
||||
assertEquals(14, module.debugInfo().pcToSpan().get(3).pc());
|
||||
}
|
||||
|
||||
private static int readU16(final byte[] bytes, final int offset) {
|
||||
return ByteBuffer.wrap(bytes, offset, 2).order(ByteOrder.LITTLE_ENDIAN).getShort() & 0xFFFF;
|
||||
}
|
||||
@@ -124,4 +151,3 @@ class BytecodeEmitterTest {
|
||||
return ByteBuffer.wrap(bytes, offset, 4).order(ByteOrder.LITTLE_ENDIAN).getInt();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -52,6 +52,7 @@ class LowerToIRVMServiceTest {
|
||||
final var emissionOps = lowered.emissionPlan().functions().getFirst().operations();
|
||||
assertEquals(p.studio.compiler.backend.bytecode.BytecodeEmitter.OperationKind.HOSTCALL, emissionOps.get(0).kind());
|
||||
assertEquals(p.studio.compiler.backend.bytecode.BytecodeEmitter.OperationKind.INTRINSIC, emissionOps.get(1).kind());
|
||||
assertTrue(emissionOps.stream().allMatch(op -> op.span() != null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user