implements PR-19.8 published wrapper entrypoint lowering
This commit is contained in:
+38
@@ -57,6 +57,44 @@ class LowerToIRVMServiceTest {
|
||||
assertEquals(0, lowered.module().functions().get(1).instructions().get(0).immediate());
|
||||
}
|
||||
|
||||
@Test
|
||||
void lowerMustPublishSyntheticWrapperAtFunctionZeroAndKeepFinalRetInWrapperPath() {
|
||||
final var backend = IRBackend.builder()
|
||||
.entryPointCallableName("__pbs.frame_wrapper$m0")
|
||||
.entryPointModuleId(new ModuleId(0))
|
||||
.executableFunctions(ReadOnlyList.from(
|
||||
fn("__pbs.file_init$f1", "app", 30, ReadOnlyList.from(ret())),
|
||||
fn("__pbs.module_init$m0", "app", 31, ReadOnlyList.from(
|
||||
callFunc("app", "__pbs.file_init$f1", 30),
|
||||
ret())),
|
||||
fn("__pbs.project_init$m0", "app", 32, ReadOnlyList.from(
|
||||
callFunc("app", "boot", 10),
|
||||
ret())),
|
||||
fn("boot", "app", 10, ReadOnlyList.from(ret())),
|
||||
fn("frame", "app", 20, ReadOnlyList.from(ret())),
|
||||
fn("__pbs.frame_wrapper$m0", "app", 40, ReadOnlyList.from(
|
||||
callFunc("app", "__pbs.module_init$m0", 31),
|
||||
callFunc("app", "__pbs.project_init$m0", 32),
|
||||
callFunc("app", "frame", 20),
|
||||
ret()))))
|
||||
.build();
|
||||
|
||||
final var lowered = new LowerToIRVMService().lower(backend);
|
||||
|
||||
assertEquals("__pbs.frame_wrapper$m0", lowered.module().functions().get(0).name());
|
||||
assertEquals(IRVMOp.CALL, lowered.module().functions().get(0).instructions().get(0).op());
|
||||
assertEquals(IRVMOp.CALL, lowered.module().functions().get(0).instructions().get(1).op());
|
||||
assertEquals(IRVMOp.CALL, lowered.module().functions().get(0).instructions().get(2).op());
|
||||
assertEquals(IRVMOp.RET, lowered.module().functions().get(0).instructions().get(3).op());
|
||||
assertEquals(IRVMOp.RET, lowered.module().functions().stream()
|
||||
.filter(function -> "frame".equals(function.name()))
|
||||
.findFirst()
|
||||
.orElseThrow()
|
||||
.instructions()
|
||||
.getLast()
|
||||
.op());
|
||||
}
|
||||
|
||||
@Test
|
||||
void lowerMustMapHostAndIntrinsicCallsites() {
|
||||
final var backend = IRBackend.builder()
|
||||
|
||||
Reference in New Issue
Block a user