Lowering: one helper knows the array layout (#453 step 1) - #478
Merged
Merged
Conversation
An array value becomes one pointer to a heap header { data, length,
capacity } that never moves, so every alias sees push/pop/splice/length=.
Rollout in three PRs: a behaviour-free layout helper, the switch, growth.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Eight tasks in three PRs. Rulings folded into the spec: a null header reads as an empty array (R1), main's string[] argv is made by a new op (R2), the rest element is built in MLIRGen (R3). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
….cpp) ArrayLayout reads and writes an array's data and length, and makes one. No change to the generated IR: --emit=llvm identical for every suite test under gc, rc and own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… ArrayLayout
The last places outside the helper that knew the { data, length } layout.
Also drops the llvmArrayType/loc locals Task 1 left unused.
No change to the generated IR.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 1 of the arrays-as-references plan for #453 (spec:
docs/superpowers/specs/2026-10-03-array-reference-design.md).Refactor only, no behaviour change. A new
ArrayLayouthelper (include/TypeScript/LowerToLLVM/ArrayLayout.h) is now the one place that knows an array value is a{ data, length }struct. The array ops inLowerToLLVM.cpp(length, push/pop/shift/unshift/splice, create/new/view), the casts and truthiness inCastLogicHelper.h, the read-only constant arrays and element addressing inLLVMCodeHelper.h, the===path (viaextractArrayPtr) and the retain/release routines inOwnershipRoutineLogic.hall go through it. OutsideArrayLayout.hnothing referencesARRAY_DATA_INDEX/ARRAY_SIZE_INDEXany more except the non-array fallback inLengthOf. UnusedllvmArrayType/loclocals left by the first commit are removed.Verification
--emit=llvm --no-default-libfor every suite test (774 tests) under gc, rc and own = 4388 files (2066.ll+ 2322.err), base compiler (main at 4dd14ca) vs this branch. The compiler's IR output is nondeterministic from run to run at baseline (hash-suffixed names,___cast<>/___bin_op_union member order, string-length constants), so a rawdiff -rqis not empty even for two runs of the unmodified compiler. The comparison therefore normalises those (digit runs of 5+ in names, cast names, string-length constants).tests-01types_utility-rc.ll,tests-conditionalTypes2-own.err,tests-conditionalTypes2-rc.ll).test-compile-gc-defaultlib-collector(stale local default library, unrelated);test-compile-shared-export-import-declare-linknameis Disabled.🤖 Generated with Claude Code