mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-02 08:35:07 +08:00
test: complete compiler performance regression coverage
- Record the new array fixture in the frontend parity baseline. - Keep runtime ABI checks precise for optimized class brand probes.
This commit is contained in:
@@ -108,7 +108,7 @@ test("class brand probes borrow a local only across an inert literal key", () =>
|
||||
const key: IrExpr = { kind: "strLit", value: "object:Example", type: STRING, loc: receiverLoc };
|
||||
const probe: IrExpr = { kind: "libCall", fn: "dyn.typedRefIs", args: [ref(dyn), key], type: BOOL, loc: receiverLoc };
|
||||
const borrowed = work(probe, dyn);
|
||||
expect(borrowed).not.toContain("call ptr @scr_dyn_retain");
|
||||
expect(borrowed).not.toContain("call ptr @scr_dyn_retain_v(");
|
||||
expect(borrowed).toContain("icmp ne ptr");
|
||||
expect(borrowed).toContain("icmp eq i32");
|
||||
expect(borrowed).toContain("@scr_dyn_typed_ref_is_key");
|
||||
@@ -118,7 +118,7 @@ test("class brand probes borrow a local only across an inert literal key", () =>
|
||||
const computed = work({ ...probe, args: [ref(dyn), {
|
||||
kind: "toString", operand: ref(dyn), type: STRING, loc: receiverLoc,
|
||||
}] }, dyn);
|
||||
expect(computed).toContain("call ptr @scr_dyn_retain");
|
||||
expect(computed).toContain("call ptr @scr_dyn_retain_v(");
|
||||
});
|
||||
|
||||
test("capture boxes keep their ordinary owned-read contract", () => {
|
||||
|
||||
@@ -199,7 +199,7 @@ interface LlDeclare {
|
||||
/** `declare zeroext i1 @scr_x(ptr, i1 zeroext, ...)` → shape (parameter
|
||||
* attributes stripped; only the type words matter for the C prototype). */
|
||||
function parseDeclare(text: string): LlDeclare | undefined {
|
||||
const m = /^declare\s+(.+?)\s*@([A-Za-z0-9_$.]+)\((.*)\)$/.exec(text.trim());
|
||||
const m = /^declare\s+(.+?)\s*@([A-Za-z0-9_$.]+)\(([^()]*)\)(?:\s+.*)?$/.exec(text.trim());
|
||||
if (!m) return undefined;
|
||||
const ret = m[1]!.replace(/\b(zeroext|signext|noalias|nonnull)\b/g, " ").replace(/\s+/g, " ").trim();
|
||||
const parts = m[3]!.trim() === "" ? [] : m[3]!.split(",").map((p) =>
|
||||
@@ -227,6 +227,13 @@ function checkDeclare(d: LlDeclare, protos: Map<string, CProto>): string | undef
|
||||
}
|
||||
|
||||
describe("LLVM backend declares match scr_runtime.h prototypes", () => {
|
||||
test("function memory attributes do not change the declared ABI", async () => {
|
||||
const declaration = parseDeclare("declare zeroext i1 @scr_dyn_typed_ref_is_key(ptr, ptr) memory(read)");
|
||||
expect(declaration).toEqual({ ret: "i1", name: "scr_dyn_typed_ref_is_key", params: ["ptr", "ptr"], variadic: false });
|
||||
const { protos } = await parseHeader();
|
||||
expect(checkDeclare(declaration!, protos)).toBeUndefined();
|
||||
});
|
||||
|
||||
test("externally linkable objects reference the versioned runtime marker", async () => {
|
||||
const loc = { file: "/source/abi-marker.ts", start: 0, end: 0 };
|
||||
const mod: IrModule = {
|
||||
|
||||
@@ -8698,6 +8698,12 @@
|
||||
],
|
||||
"diags": []
|
||||
},
|
||||
"<repo>/tests/corpus/array-truncate-reuse.ts": {
|
||||
"order": [
|
||||
"<repo>/tests/corpus/array-truncate-reuse.ts"
|
||||
],
|
||||
"diags": []
|
||||
},
|
||||
"<repo>/tests/corpus/async-backend-factory.mjs": {
|
||||
"order": [
|
||||
"<repo>/tests/corpus/async-backend-factory.mjs"
|
||||
|
||||
Reference in New Issue
Block a user