Number collector types in the self-hosting layout fixture

Emitted ScrCycType descriptors now carry collector statistics indices from ShapeHost.nextCycKind, counted from FIRST_EMITTED_CYC_KIND. The llvm-layouts.ts host lacked the hook, so its class descriptors and vtables stamped kind 0 and the native layout emission diverged from the production emitter's.
This commit is contained in:
Malte Ubl
2026-10-11 09:39:58 -07:00
parent def6f86a0e
commit f4eafed2b5
+4
View File
@@ -3,6 +3,7 @@ import { deserializeModule } from "../../../packages/compiler/src/ir/serialize.j
import { computeTraced } from "../../../packages/compiler/src/backend/cycle-analysis.js";
import { buildClassGraph, classFieldIndex, type ClassHost } from "../../../packages/compiler/src/backend/llvm/classes.js";
import { emitLlvmLayouts } from "../../../packages/compiler/src/backend/llvm/layouts.js";
import { FIRST_EMITTED_CYC_KIND } from "../../../packages/compiler/src/backend/llvm/alloc.js";
import { LlvmDebugInfo } from "../../../packages/compiler/src/backend/llvm/debug-info.js";
import { LlWalkers, type WalkerHost } from "../../../packages/compiler/src/backend/llvm/walkers.js";
import { BlockBuilder } from "../../../packages/compiler/src/backend/llvm/blocks.js";
@@ -36,6 +37,7 @@ try {
const units: { union: string; tag: number }[] = [];
let needsOom = false;
let needsBadTag = false;
let cycKinds = 0;
const traced = computeTraced(mod);
const nullableUnions = new NullableUnions(mod);
const unionsById = new Map((mod.unions ?? []).map((union) => [union.id, union]));
@@ -51,6 +53,8 @@ try {
},
sizeType: request.bits === 32 ? "i32" : "i64",
cycleBufferedOffset: 6,
// Collector statistics indices, numbered as LlEmitter numbers them.
nextCycKind: () => FIRST_EMITTED_CYC_KIND + cycKinds++,
tracedShapes: traced.shapes,
tracedUnions: traced.unions,
recordsById: new Map((mod.records ?? []).map((record) => [record.id, record])),