new test main with code directly (fixes)

This commit is contained in:
2026-03-24 13:42:32 +00:00
parent 14f9b5dd26
commit 5630f8f119
63 changed files with 1677 additions and 198 deletions
@@ -0,0 +1,73 @@
package p.studio.compiler.backend.irvm;
import java.util.HashMap;
import java.util.Map;
import java.util.OptionalInt;
final class IRVMIntrinsicRegistry {
private static final Map<IntrinsicKey, Integer> FINAL_ID_BY_INTRINSIC = createRegistry();
private IRVMIntrinsicRegistry() {
}
static OptionalInt resolveFinalId(
final String canonicalName,
final long canonicalVersion) {
if (canonicalName == null || canonicalName.isBlank()) {
return OptionalInt.empty();
}
final var resolved = FINAL_ID_BY_INTRINSIC.get(new IntrinsicKey(canonicalName, canonicalVersion));
if (resolved == null) {
return OptionalInt.empty();
}
return OptionalInt.of(resolved);
}
private static Map<IntrinsicKey, Integer> createRegistry() {
final var registry = new HashMap<IntrinsicKey, Integer>();
register(registry, "vec2.dot", 1, 0x1000);
register(registry, "vec2.length", 1, 0x1001);
register(registry, "input.pad", 1, 0x2000);
register(registry, "input.touch", 1, 0x2001);
register(registry, "input.pad.up", 1, 0x2010);
register(registry, "input.pad.down", 1, 0x2011);
register(registry, "input.pad.left", 1, 0x2012);
register(registry, "input.pad.right", 1, 0x2013);
register(registry, "input.pad.a", 1, 0x2014);
register(registry, "input.pad.b", 1, 0x2015);
register(registry, "input.pad.x", 1, 0x2016);
register(registry, "input.pad.y", 1, 0x2017);
register(registry, "input.pad.l", 1, 0x2018);
register(registry, "input.pad.r", 1, 0x2019);
register(registry, "input.pad.start", 1, 0x201A);
register(registry, "input.pad.select", 1, 0x201B);
register(registry, "input.touch.button", 1, 0x2020);
register(registry, "input.touch.x", 1, 0x2021);
register(registry, "input.touch.y", 1, 0x2022);
register(registry, "input.button.pressed", 1, 0x2030);
register(registry, "input.button.released", 1, 0x2031);
register(registry, "input.button.down", 1, 0x2032);
register(registry, "input.button.hold", 1, 0x2033);
return Map.copyOf(registry);
}
private static void register(
final Map<IntrinsicKey, Integer> registry,
final String canonicalName,
final long canonicalVersion,
final int finalId) {
final var previous = registry.put(new IntrinsicKey(canonicalName, canonicalVersion), finalId);
if (previous != null && previous != finalId) {
throw new IllegalStateException("duplicate intrinsic registry identity: " + canonicalName + "@" + canonicalVersion);
}
}
private record IntrinsicKey(
String canonicalName,
long canonicalVersion) {
}
}
@@ -2,6 +2,7 @@ package p.studio.compiler.backend.irvm;
public enum IRVMLoweringErrorCode {
LOWER_IRVM_EMPTY_EXECUTABLE_INPUT,
LOWER_IRVM_ENTRYPOINT_DECLARATION_MISSING,
LOWER_IRVM_ENTRYPOINT_MISSING,
LOWER_IRVM_ENTRYPOINT_AMBIGUOUS,
LOWER_IRVM_MISSING_CALLEE,
@@ -173,7 +173,7 @@ public class IRVMValidator {
if (inHeight < pops) {
throw new IRVMValidationException(
IRVMValidationErrorCode.MARSHAL_VERIFY_PRECHECK_STACK_UNDERFLOW,
"stack underflow",
"stack underflow. need=%d have=%d".formatted(pops, inHeight),
functionIndex,
pc);
}
@@ -42,7 +42,7 @@ public class LowerToIRVMService {
"IRBackend has no executable functions");
}
final var ordered = orderFunctions(backend.getExecutableFunctions());
final var ordered = orderFunctions(backend);
final var funcIdByCallableId = new HashMap<CallableId, Integer>();
for (var i = 0; i < ordered.size(); i++) {
final var fn = ordered.get(i);
@@ -145,9 +145,31 @@ public class LowerToIRVMService {
IRVMLoweringErrorCode.LOWER_IRVM_INVALID_INTRINSIC_ID,
"invalid intrinsic id: " + intrinsic.intrinsicId());
}
instructions.add(new IRVMInstruction(IRVMOp.INTRINSIC, intrinsicIndex));
final var canonicalIntrinsic = backend.getIntrinsicPool().get(intrinsicIndex);
if (!canonicalIntrinsic.canonicalName().equals(intrinsic.canonicalName())
|| canonicalIntrinsic.canonicalVersion() != intrinsic.canonicalVersion()) {
throw loweringError(
fn,
instr,
IRVMLoweringErrorCode.LOWER_IRVM_INVALID_INTRINSIC_ID,
"intrinsic identity mismatch between callsite and pool: call=%s@%d pool=%s@%d".formatted(
intrinsic.canonicalName(),
intrinsic.canonicalVersion(),
canonicalIntrinsic.canonicalName(),
canonicalIntrinsic.canonicalVersion()));
}
final var finalIntrinsicId = IRVMIntrinsicRegistry
.resolveFinalId(canonicalIntrinsic.canonicalName(), canonicalIntrinsic.canonicalVersion())
.orElseThrow(() -> loweringError(
fn,
instr,
IRVMLoweringErrorCode.LOWER_IRVM_INVALID_INTRINSIC_ID,
"unknown VM-owned intrinsic identity: %s@%d".formatted(
canonicalIntrinsic.canonicalName(),
canonicalIntrinsic.canonicalVersion())));
instructions.add(new IRVMInstruction(IRVMOp.INTRINSIC, finalIntrinsicId));
operations.add(BytecodeEmitter.Operation.intrinsic(
intrinsicIndex,
finalIntrinsicId,
instr.expectedArgSlots(),
instr.expectedRetSlots(),
sourceSpan));
@@ -231,22 +253,29 @@ public class LowerToIRVMService {
return program;
}
private ReadOnlyList<IRBackendExecutableFunction> orderFunctions(
final ReadOnlyList<IRBackendExecutableFunction> functions) {
final var sorted = new ArrayList<>(functions.asList());
private ReadOnlyList<IRBackendExecutableFunction> orderFunctions(final IRBackend backend) {
final var entryPointCallableName = backend.getEntryPointCallableName();
if (entryPointCallableName == null || entryPointCallableName.isBlank()) {
throw new IRVMLoweringException(
IRVMLoweringErrorCode.LOWER_IRVM_ENTRYPOINT_DECLARATION_MISSING,
"frontend IRBackend entrypoint declaration is missing");
}
final var sorted = new ArrayList<>(backend.getExecutableFunctions().asList());
sorted.sort(FUNCTION_ORDER);
final var entrypoints = sorted.stream()
.filter(candidate -> "main".equals(candidate.callableName()))
.filter(candidate -> entryPointCallableName.equals(candidate.callableName()))
.toList();
if (entrypoints.isEmpty()) {
throw new IRVMLoweringException(
IRVMLoweringErrorCode.LOWER_IRVM_ENTRYPOINT_MISSING,
"missing entrypoint callable 'main'");
"missing entrypoint callable '%s'".formatted(entryPointCallableName));
}
if (entrypoints.size() > 1) {
throw new IRVMLoweringException(
IRVMLoweringErrorCode.LOWER_IRVM_ENTRYPOINT_AMBIGUOUS,
"ambiguous entrypoint: found %d callables named 'main'".formatted(entrypoints.size()));
"ambiguous entrypoint: found %d callables named '%s'".formatted(
entrypoints.size(),
entryPointCallableName));
}
final var entrypoint = entrypoints.getFirst();
final var ordered = new ArrayList<IRBackendExecutableFunction>(sorted.size());
@@ -21,6 +21,7 @@ public class BuilderPipelineContext {
public IRVMProgram optimizedIrvm;
public BytecodeModule bytecodeModule;
public byte[] bytecodeBytes;
public Path bytecodeArtifactPath;
private BuilderPipelineContext(
final BuilderPipelineConfig config,
@@ -23,7 +23,8 @@ public class BuilderPipelineService {
new OptimizeIRVMPipelineStage(),
new EmitBytecodePipelineStage(),
new LinkBytecodePipelineStage(),
new VerifyBytecodePipelineStage()
new VerifyBytecodePipelineStage(),
new WriteBytecodeArtifactPipelineStage()
);
INSTANCE = new BuilderPipelineService(stages);
}
@@ -0,0 +1,72 @@
package p.studio.compiler.workspaces.stages;
import lombok.extern.slf4j.Slf4j;
import p.studio.compiler.messages.BuildingIssueSink;
import p.studio.compiler.models.BuilderPipelineContext;
import p.studio.compiler.workspaces.PipelineStage;
import p.studio.utilities.logs.LogAggregator;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
@Slf4j
public class WriteBytecodeArtifactPipelineStage implements PipelineStage {
private static final String OUTPUT_DIR = "build";
private static final String OUTPUT_FILE = "program.pbx";
@Override
public BuildingIssueSink run(final BuilderPipelineContext ctx, final LogAggregator logs) {
if (ctx.rootProjectPathCanon == null) {
return BuildingIssueSink.empty()
.report(builder -> builder
.error(true)
.phase("BACKEND_WRITE_ARTIFACT")
.code("MARSHAL_FORMAT_STAGE_INPUT_MISSING")
.message("[BUILD]: root project path is missing before WriteBytecodeArtifact stage"));
}
final var bytes = resolveBytes(ctx);
if (bytes == null || bytes.length == 0) {
return BuildingIssueSink.empty()
.report(builder -> builder
.error(true)
.phase("BACKEND_WRITE_ARTIFACT")
.code("MARSHAL_FORMAT_STAGE_INPUT_MISSING")
.message("[BUILD]: bytecode bytes are missing before WriteBytecodeArtifact stage"));
}
final var outputDir = ctx.rootProjectPathCanon.resolve(OUTPUT_DIR);
final var outputPath = outputDir.resolve(OUTPUT_FILE);
try {
Files.createDirectories(outputDir);
Files.write(
outputPath,
bytes,
StandardOpenOption.CREATE,
StandardOpenOption.TRUNCATE_EXISTING,
StandardOpenOption.WRITE);
ctx.bytecodeArtifactPath = outputPath;
logs.using(log).info("[BUILD]: wrote bytecode artifact to " + outputPath);
return BuildingIssueSink.empty();
} catch (IOException e) {
return BuildingIssueSink.empty()
.report(builder -> builder
.error(true)
.phase("BACKEND_WRITE_ARTIFACT")
.code("MARSHAL_ARTIFACT_WRITE_FAILED")
.message("[BUILD]: failed to write bytecode artifact: " + outputPath)
.exception(e));
}
}
private byte[] resolveBytes(final BuilderPipelineContext ctx) {
if (ctx.bytecodeBytes != null && ctx.bytecodeBytes.length > 0) {
return ctx.bytecodeBytes;
}
if (ctx.bytecodeModule != null) {
return ctx.bytecodeModule.serialize();
}
return null;
}
}
@@ -68,7 +68,7 @@ class GoldenArtifactsTest {
"",
"",
null,
new IRBackendExecutableFunction.IntrinsicCallMetadata("core.color.pack", 1, new IntrinsicId(0)),
new IRBackendExecutableFunction.IntrinsicCallMetadata("input.pad", 1, new IntrinsicId(0)),
0,
0,
Span.none()),
@@ -80,7 +80,7 @@ class GoldenArtifactsTest {
null,
Span.none())),
Span.none())))
.intrinsicPool(ReadOnlyList.from(new IntrinsicReference("core.color.pack", 1)))
.intrinsicPool(ReadOnlyList.from(new IntrinsicReference("input.pad", 1)))
.build();
}
@@ -204,7 +204,7 @@ class IRVMValidatorTest {
}
@Test
void validateProgramMustApplyHostcallStackEffectsFromMetadata() {
void validateProgramMustRejectHostcallWhenDeclaredArgsAreMissingOnStack() {
final var module = new IRVMModule(
"core-v1",
ReadOnlyList.from(new IRVMFunction(
@@ -36,15 +36,34 @@ class LowerToIRVMServiceTest {
assertEquals(0, lowered.module().functions().get(1).instructions().get(0).immediate());
}
@Test
void lowerMustUseFrontendDeclaredEntrypointCallable() {
final var backend = IRBackend.builder()
.entryPointCallableName("frame")
.executableFunctions(ReadOnlyList.from(
fn("aux", "app", 11, ReadOnlyList.from(
callFunc("app", "frame", 10),
ret())),
fn("frame", "app", 10, ReadOnlyList.from(
ret()))))
.build();
final var lowered = new LowerToIRVMService().lower(backend);
assertEquals("frame", lowered.module().functions().get(0).name());
assertEquals("aux", lowered.module().functions().get(1).name());
assertEquals(0, lowered.module().functions().get(1).instructions().get(0).immediate());
}
@Test
void lowerMustMapHostAndIntrinsicCallsites() {
final var backend = IRBackend.builder()
.executableFunctions(ReadOnlyList.from(
fn("main", "app", 10, ReadOnlyList.from(
callHost("gfx", "draw_pixel", 1, 0, 0),
callIntrinsic("core.color.pack", 1, 0),
callIntrinsic("input.pad", 1, 0),
ret()))))
.intrinsicPool(ReadOnlyList.from(new IntrinsicReference("core.color.pack", 1)))
.intrinsicPool(ReadOnlyList.from(new IntrinsicReference("input.pad", 1)))
.build();
final var lowered = new LowerToIRVMService().lower(backend);
@@ -52,7 +71,7 @@ class LowerToIRVMServiceTest {
final var instructions = lowered.module().functions().getFirst().instructions();
assertEquals(IRVMOp.HOSTCALL, instructions.get(0).op());
assertEquals(IRVMOp.INTRINSIC, instructions.get(1).op());
assertEquals(0, instructions.get(1).immediate());
assertEquals(0x2000, instructions.get(1).immediate());
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());
@@ -84,6 +103,21 @@ class LowerToIRVMServiceTest {
assertEquals(IRVMLoweringErrorCode.LOWER_IRVM_MISSING_CALLEE, thrown.code());
}
@Test
void lowerMustRejectUnknownCanonicalIntrinsicIdentity() {
final var backend = IRBackend.builder()
.executableFunctions(ReadOnlyList.from(
fn("main", "app", 10, ReadOnlyList.from(
callIntrinsic("core.color.pack", 1, 0),
ret()))))
.intrinsicPool(ReadOnlyList.from(new IntrinsicReference("core.color.pack", 1)))
.build();
final var thrown = assertThrows(IRVMLoweringException.class, () -> new LowerToIRVMService().lower(backend));
assertEquals(IRVMLoweringErrorCode.LOWER_IRVM_INVALID_INTRINSIC_ID, thrown.code());
assertTrue(thrown.getMessage().contains("unknown VM-owned intrinsic identity"));
}
@Test
void lowerMustRejectCallArgSlotMismatch() {
final var backend = IRBackend.builder()
@@ -141,6 +175,18 @@ class LowerToIRVMServiceTest {
assertEquals(IRVMLoweringErrorCode.LOWER_IRVM_ENTRYPOINT_MISSING, thrown.code());
}
@Test
void lowerMustRejectWhenEntrypointDeclarationIsMissing() {
final var backend = IRBackend.builder()
.entryPointCallableName(" ")
.executableFunctions(ReadOnlyList.from(
fn("main", "app", 10, ReadOnlyList.from(ret()))))
.build();
final var thrown = assertThrows(IRVMLoweringException.class, () -> new LowerToIRVMService().lower(backend));
assertEquals(IRVMLoweringErrorCode.LOWER_IRVM_ENTRYPOINT_DECLARATION_MISSING, thrown.code());
}
@Test
void lowerMustRejectWhenEntrypointIsAmbiguous() {
final var backend = IRBackend.builder()
@@ -31,9 +31,9 @@ class OptimizeIRVMEquivalenceHarnessTest {
.executableFunctions(ReadOnlyList.from(
fn("main", 1, ReadOnlyList.from(
callHost("gfx", "draw_pixel", 1, 0, 0),
callIntrinsic("core.color.pack", 1, 0, 0, 0),
callIntrinsic("input.pad", 1, 0, 0, 0),
ret()))))
.intrinsicPool(ReadOnlyList.from(new IntrinsicReference("core.color.pack", 1)))
.intrinsicPool(ReadOnlyList.from(new IntrinsicReference("input.pad", 1)))
.build();
final var lowered = new LowerToIRVMService().lower(backend);
@@ -145,9 +145,9 @@ class BackendGateIIntegrationTest {
void gateI_validIntrinsicPath() {
final var module = emitFromBackend(backendWithSingleFunction(
fn("main", ReadOnlyList.from(
callIntrinsic("core.color.pack", 1, 0),
callIntrinsic("input.pad", 1, 0),
ret())),
ReadOnlyList.from(new IntrinsicReference("core.color.pack", 1))));
ReadOnlyList.from(new IntrinsicReference("input.pad", 1))));
final var check = compatibilityAdapter.check(module);
assertEquals(CompatibilityError.NONE, check.error());
@@ -9,6 +9,7 @@ import p.studio.compiler.workspaces.stages.LowerToIRVMPipelineStage;
import p.studio.compiler.workspaces.stages.OptimizeIRVMPipelineStage;
import p.studio.compiler.workspaces.stages.ResolveDepsPipelineStage;
import p.studio.compiler.workspaces.stages.VerifyBytecodePipelineStage;
import p.studio.compiler.workspaces.stages.WriteBytecodeArtifactPipelineStage;
import java.lang.reflect.Field;
import java.util.List;
@@ -35,7 +36,8 @@ class BuilderPipelineServiceOrderTest {
OptimizeIRVMPipelineStage.class,
EmitBytecodePipelineStage.class,
LinkBytecodePipelineStage.class,
VerifyBytecodePipelineStage.class),
VerifyBytecodePipelineStage.class,
WriteBytecodeArtifactPipelineStage.class),
stageTypes);
}
}
@@ -141,4 +141,67 @@ class LowerToIRVMPipelineStageTest {
assertEquals(12, firstIssue.getStart());
assertEquals(24, firstIssue.getEnd());
}
@Test
void runMustRejectCallWhenStackDoesNotProvideDeclaredArgs() {
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
ctx.irBackend = IRBackend.builder()
.executableFunctions(ReadOnlyList.from(
new IRBackendExecutableFunction(
new FileId(0),
"app",
"callee",
new CallableId(2),
0,
10,
1,
0,
0,
1,
ReadOnlyList.from(new IRBackendExecutableFunction.Instruction(
IRBackendExecutableFunction.InstructionKind.RET,
"",
"",
null,
null,
Span.none())),
Span.none()),
new IRBackendExecutableFunction(
new FileId(0),
"app",
"main",
new CallableId(1),
0,
10,
0,
0,
0,
1,
ReadOnlyList.from(
new IRBackendExecutableFunction.Instruction(
IRBackendExecutableFunction.InstructionKind.CALL_FUNC,
"app",
"callee",
new CallableId(2),
null,
null,
1,
0,
Span.none()),
new IRBackendExecutableFunction.Instruction(
IRBackendExecutableFunction.InstructionKind.RET,
"",
"",
null,
null,
Span.none())),
Span.none())))
.build();
final var issues = new LowerToIRVMPipelineStage().run(ctx, LogAggregator.empty());
final var firstIssue = issues.asCollection().iterator().next();
assertTrue(issues.hasErrors());
assertEquals("MARSHAL_VERIFY_PRECHECK_STACK_UNDERFLOW", firstIssue.getCode());
}
}
@@ -0,0 +1,86 @@
package p.studio.compiler.workspaces.stages;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import p.studio.compiler.backend.bytecode.BytecodeModule;
import p.studio.compiler.messages.BuilderPipelineConfig;
import p.studio.compiler.models.BuilderPipelineContext;
import p.studio.utilities.logs.LogAggregator;
import p.studio.utilities.structures.ReadOnlyList;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
class WriteBytecodeArtifactPipelineStageTest {
@TempDir
Path tempDir;
@Test
void runMustFailWhenRootProjectPathIsMissing() {
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
ctx.bytecodeBytes = new byte[] { 0x01 };
final var issues = new WriteBytecodeArtifactPipelineStage().run(ctx, LogAggregator.empty());
final var firstIssue = issues.asCollection().iterator().next();
assertTrue(issues.hasErrors());
assertEquals("BACKEND_WRITE_ARTIFACT", firstIssue.getPhase());
assertEquals("MARSHAL_FORMAT_STAGE_INPUT_MISSING", firstIssue.getCode());
}
@Test
void runMustFailWhenBytecodeInputIsMissing() {
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
ctx.rootProjectPathCanon = tempDir;
final var issues = new WriteBytecodeArtifactPipelineStage().run(ctx, LogAggregator.empty());
final var firstIssue = issues.asCollection().iterator().next();
assertTrue(issues.hasErrors());
assertEquals("BACKEND_WRITE_ARTIFACT", firstIssue.getPhase());
assertEquals("MARSHAL_FORMAT_STAGE_INPUT_MISSING", firstIssue.getCode());
}
@Test
void runMustWriteBuildProgramPbxFromByteArray() throws Exception {
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
ctx.rootProjectPathCanon = tempDir;
ctx.bytecodeBytes = new byte[] { 0x50, 0x42, 0x58, 0x00 };
final var issues = new WriteBytecodeArtifactPipelineStage().run(ctx, LogAggregator.empty());
final var outputPath = tempDir.resolve("build").resolve("program.pbx");
assertFalse(issues.hasErrors());
assertTrue(Files.exists(outputPath));
assertArrayEquals(ctx.bytecodeBytes, Files.readAllBytes(outputPath));
assertEquals(outputPath, ctx.bytecodeArtifactPath);
}
@Test
void runMustWriteBuildProgramPbxFromModuleWhenByteArrayIsMissing() throws Exception {
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
ctx.rootProjectPathCanon = tempDir;
ctx.bytecodeModule = new BytecodeModule(
0,
ReadOnlyList.empty(),
ReadOnlyList.empty(),
new byte[] { (byte) 0x51, 0x00 },
null,
ReadOnlyList.empty(),
ReadOnlyList.empty());
final var issues = new WriteBytecodeArtifactPipelineStage().run(ctx, LogAggregator.empty());
final var outputPath = tempDir.resolve("build").resolve("program.pbx");
assertFalse(issues.hasErrors());
assertTrue(Files.exists(outputPath));
assertArrayEquals(ctx.bytecodeModule.serialize(), Files.readAllBytes(outputPath));
assertEquals(outputPath, ctx.bytecodeArtifactPath);
}
}
@@ -1 +1 @@
504253000000000004000000000000000000000000000000000000000000000001000000500000001400000002000000640000000e00000003000000720000004400000005000000b60000001b00000001000000000000000e000000000000000000020071000000000072000000000051000300000000000000010000000000000000000000060000000100000000000000000000000c0000000100000000000000000000000100000000000000040000006d61696e0100000003006766780a00647261775f706978656c010000000000
504253000000000004000000000000000000000000000000000000000000000001000000500000001400000002000000640000000e00000003000000720000004400000005000000b60000001b00000001000000000000000e000000000000000000020071000000000072000020000051000300000000000000010000000000000000000000060000000100000000000000000000000c0000000100000000000000000000000100000000000000040000006d61696e0100000003006766780a00647261775f706978656c010000000000
@@ -1,5 +1,5 @@
profile=core-v1
fn#0:main param=0 local=0 ret=0 max=2
HOSTCALL imm=0
INTRINSIC imm=0
INTRINSIC imm=8192
RET imm=-