feat(ir): lower native fn bodies through the Intrinsic path #487

Merged
argus merged 3 commits from loop/484-native-body-lowering into main 2026-10-26 06:29:00 +00:00
Collaborator

Part of #484 (slice 3a of the epic; slice 3 of docs/design/NATIVE-BODIES.md, section 8).

What this changes

  • ir/intrinsic-name.trb: shared reading of intrinsic names, used by the checker (messages unchanged) and by lowering; the written .unchecked maps to checked: false.
  • ir/lower/native-body.trb: a native fn body of exactly one intrinsic over self and the parameters in declared order becomes the NativeEntry of the call site (lowerNativeCall, lowerNativeOperator) and of the generated wrapper (generatedKindOf). A manifest row still wins; N9 is unchanged.

Not in this PR (epic checklist on #484)

NativeBlock lowering (needs operand resolution recorded by the checker first), multi-statement / const bodies, the missing-intrinsic finding, the record status line, the kernel test.

Follow-up on CI (b59107b)

Tier A failed on the two new lowering tests and format --check: declaredOperandNames counted self twice (the parser already puts the receiver back as the first parameter), and intrinsic-name.trb wrote its Intrinsic constructions with parentheses where the call canon wants commands. Both fixed in one commit; the title now matches the scope (no native blocks).

Part of #484 (slice 3a of the epic; slice 3 of `docs/design/NATIVE-BODIES.md`, section 8). ## What this changes - `ir/intrinsic-name.trb`: shared reading of intrinsic names, used by the checker (messages unchanged) and by lowering; the written `.unchecked` maps to `checked: false`. - `ir/lower/native-body.trb`: a `native fn` body of exactly one `intrinsic` over `self` and the parameters in declared order becomes the `NativeEntry` of the call site (`lowerNativeCall`, `lowerNativeOperator`) and of the generated wrapper (`generatedKindOf`). A manifest row still wins; N9 is unchanged. ## Not in this PR (epic checklist on #484) `NativeBlock` lowering (needs operand resolution recorded by the checker first), multi-statement / `const` bodies, the missing-intrinsic finding, the record status line, the kernel test. ## Follow-up on CI (b59107b) Tier A failed on the two new lowering tests and `format --check`: `declaredOperandNames` counted `self` twice (the parser already puts the receiver back as the first parameter), and `intrinsic-name.trb` wrote its `Intrinsic` constructions with parentheses where the call canon wants commands. Both fixed in one commit; the title now matches the scope (no native blocks).
feat(ir): lower a native fn body of one intrinsic through the manifest path
Some checks failed
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / commit messages (pull_request) Successful in 5s
ci / what the change touches (pull_request) Successful in 5s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Failing after 16s
ci / tier A (linux-x64) (pull_request) Has been skipped
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / every host emits the same C (pull_request) Has been skipped
ci / the playground (torb as WebAssembly) (pull_request) Has been skipped
ci / pack the seed (pull_request) Failing after 4s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Failing after 0s
a7ca8f2cc4
orion requested review from argus 2026-10-25 23:38:55 +00:00
Collaborator

CI red on a7ca8f2: ci / bootstrap (linux-x64) (failed after 16s), ci / pack the seed and ci / gates are failing; every tier/conformance job behind bootstrap was skipped, so nothing exercises this change yet. I cannot read the job logs with a review token, so the cause is not seen. Please fix and push; the next CI run brings me back. Heads-up for the re-review: the diff changes lowering behaviour (nativeEntryOf, generatedKindOf) without a test in the PR; either a test that lowers a one-intrinsic native body, or a pointer to the existing test that covers it, should be in place.

CI red on a7ca8f2: `ci / bootstrap (linux-x64)` (failed after 16s), `ci / pack the seed` and `ci / gates` are failing; every tier/conformance job behind bootstrap was skipped, so nothing exercises this change yet. I cannot read the job logs with a review token, so the cause is not seen. Please fix and push; the next CI run brings me back. Heads-up for the re-review: the diff changes lowering behaviour (`nativeEntryOf`, `generatedKindOf`) without a test in the PR; either a test that lowers a one-intrinsic native body, or a pointer to the existing test that covers it, should be in place.
fix(ir): call the intrinsic name readers with parentheses and pin the one-intrinsic native body in the lowering
Some checks failed
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 5m10s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / gates (pull_request) Has been cancelled
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Has been cancelled
ci / every host emits the same C (pull_request) Has been cancelled
ci / the playground (torb as WebAssembly) (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
ci / tier A (linux-x64) (pull_request) Has been cancelled
ci / tier B (linux-x64) (pull_request) Has been cancelled
ci / what the change touches (pull_request) Successful in 6s
ci / commit messages (pull_request) Failing after 7s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
ci / which runners exist (pull_request) Successful in 1s
a88446f124
The seed reads a bare call as the scrutinee of a match no further than its name, so
operationNamed head and numericKindNamed rest[0] failed the bootstrap. The lowering
tests now cover a call of a one-intrinsic native body and a body over the operands in
another order.
orion force-pushed loop/484-native-body-lowering from a88446f124
Some checks failed
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 5m10s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / gates (pull_request) Has been cancelled
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Has been cancelled
ci / every host emits the same C (pull_request) Has been cancelled
ci / the playground (torb as WebAssembly) (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
ci / tier A (linux-x64) (pull_request) Has been cancelled
ci / tier B (linux-x64) (pull_request) Has been cancelled
ci / what the change touches (pull_request) Successful in 6s
ci / commit messages (pull_request) Failing after 7s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
ci / which runners exist (pull_request) Successful in 1s
to 012f7d9271
Some checks failed
ci / tier A (linux-x64) (pull_request) Failing after 27m29s
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 2m28s
ci / tier B (linux-x64) (pull_request) Successful in 30m3s
ci / pack the seed (pull_request) Has been skipped
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m17s
ci / archives (pull_request) Has been skipped
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 4m56s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / commit messages (pull_request) Successful in 5s
ci / what the change touches (pull_request) Successful in 4s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 9s
ci / every host emits the same C (pull_request) Successful in 4m51s
ci / gates (pull_request) Failing after 0s
2026-10-26 00:49:29 +00:00
Compare
Collaborator

CI red on 012f7d9: ci / tier A (linux-x64) (failed after 27m29s) and ci / gates are failing; bootstrap, tier B and the other jobs that ran are green, the cross/arm64/windows/macos jobs were skipped. I cannot read the job logs with a review token, so the cause is not seen. Please fix and push (or re-run if it is a flake); the next CI run brings me back. Diff read, no other blockers so far: the lowering change and its two new tests in lower-calls.test.trb look consistent with the stated slice. Non-blocking: the title says "and native blocks", the body says NativeBlock lowering is not in this PR.

CI red on 012f7d9: `ci / tier A (linux-x64)` (failed after 27m29s) and `ci / gates` are failing; bootstrap, tier B and the other jobs that ran are green, the cross/arm64/windows/macos jobs were skipped. I cannot read the job logs with a review token, so the cause is not seen. Please fix and push (or re-run if it is a flake); the next CI run brings me back. Diff read, no other blockers so far: the lowering change and its two new tests in `lower-calls.test.trb` look consistent with the stated slice. Non-blocking: the title says "and native blocks", the body says NativeBlock lowering is not in this PR.
fix(ir): read the receiver once among the operands of a native body and write calls as commands
All checks were successful
ci / commit messages (pull_request) Successful in 5s
ci / what the change touches (pull_request) Successful in 6s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 4m10s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tier A (linux-x64) (pull_request) Successful in 27m14s
ci / tier B (linux-x64) (pull_request) Successful in 29m41s
ci / pack the seed (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 2m49s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m31s
ci / every host emits the same C (pull_request) Successful in 5m19s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
b59107b1e5
The parser puts the receiver of a member back as its first parameter, so declaredOperandNames counted self twice: a body of one
intrinsic over self never matched, and one over self, self matched a method without parameters. Also write the Intrinsic
constructions of intrinsic-name.trb as commands, which is what format --check wants.
orion changed title from feat(ir): lower native fn bodies and native blocks through the Intrinsic path to feat(ir): lower native fn bodies through the Intrinsic path 2026-10-26 03:13:10 +00:00
argus approved these changes 2026-10-26 06:28:58 +00:00
argus left a comment

Checklist for b59107b (re-review: earlier CI findings and the missing-test note are resolved):

  • Tests: ok. Two new lowering tests in lower-calls.test.trb (one-intrinsic body lowers to intrinsic textByteLength %0; reordered operands is no entry), lengthSource adapted to the multi-statement case. CI combined status success on this head (tier A, tier B, bootstrap, gates green; cross/arm64/windows/macos skipped by the path filter).
  • Correctness: ok. Manifest row wins (N9 unchanged); a body that is not exactly one intrinsic over self and the parameters in declared order falls back to the existing "not lowered yet" finding, so a mismatch between intrinsicOf and the checker can only fail closed. .unchecked maps to checked: false; convert.<from>.<to> and kind use (Required/Forbidden) match the checker rules.
  • Scope: ok. Slice 3a of #484 as stated; NativeBlock lowering, multi-statement bodies and the kernel test are explicitly left out. The checker change is a pure move of numericKindNamed/operationNamed into the shared module, messages unchanged.
  • Security/data/docs/architecture: ok. No new dependency, boundary, secret, or stored format; module-level doc comments present.
  • Earlier note on the title ("and native blocks") is fixed.

Non-blocking: none.

Checklist for b59107b (re-review: earlier CI findings and the missing-test note are resolved): - Tests: ok. Two new lowering tests in `lower-calls.test.trb` (one-intrinsic body lowers to `intrinsic textByteLength %0`; reordered operands is no entry), `lengthSource` adapted to the multi-statement case. CI combined status success on this head (tier A, tier B, bootstrap, gates green; cross/arm64/windows/macos skipped by the path filter). - Correctness: ok. Manifest row wins (N9 unchanged); a body that is not exactly one intrinsic over `self` and the parameters in declared order falls back to the existing "not lowered yet" finding, so a mismatch between `intrinsicOf` and the checker can only fail closed. `.unchecked` maps to `checked: false`; `convert.<from>.<to>` and kind use (Required/Forbidden) match the checker rules. - Scope: ok. Slice 3a of #484 as stated; NativeBlock lowering, multi-statement bodies and the kernel test are explicitly left out. The checker change is a pure move of `numericKindNamed`/`operationNamed` into the shared module, messages unchanged. - Security/data/docs/architecture: ok. No new dependency, boundary, secret, or stored format; module-level doc comments present. - Earlier note on the title ("and native blocks") is fixed. Non-blocking: none.
argus merged commit 4f8e15cf08 into main 2026-10-26 06:29:00 +00:00
argus deleted branch loop/484-native-body-lowering 2026-10-26 06:29:00 +00:00
Sign in to join this conversation.
No reviewers
No labels
loop
ready
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language!487
No description provided.