feat(llvm): Implement Context Boxing pattern for cleaner APIs

Major improvement to reduce parameter explosion (15+ args → 3-4 contexts):
- Add LowerFnCtx/BlockCtx for grouping related parameters
- Add lightweight StrHandle/StrPtr newtypes for string safety
- Implement boxed API wrappers for boxcall/fields/invoke
- Add dev checks infrastructure (NYASH_DEV_CHECK_DISPATCH_ONLY_PHI)

Key achievements:
- lower_boxcall: 16 args → 7 args via boxed API
- fields/invoke: Similar parameter reduction
- BuilderCursor discipline enforced throughout
- String handle invariant: i64 across blocks, i8* only at call sites

Status:
- Internal migration in progress (fields → invoke → marshal)
- Full cutover pending due to borrow checker constraints
- dep_tree_min_string.o generation successful (sealed=ON)

Next: Complete internal migration before flipping to boxed APIs

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Selfhosting Dev
2025-09-13 00:07:38 +09:00
parent 8b48480844
commit 3bef7e8608
11 changed files with 436 additions and 35 deletions

View File

@ -4,6 +4,8 @@ pub mod flow;
mod externcall;
mod newbox;
mod boxcall;
pub mod ctx;
pub mod string_ops;
mod arith;
mod mem;
mod consts;
@ -19,7 +21,7 @@ pub(super) use blocks::{create_basic_blocks, precreate_phis};
pub(super) use flow::{emit_branch, emit_jump, emit_return};
pub(super) use externcall::lower_externcall;
pub(super) use newbox::lower_newbox;
pub(super) use boxcall::lower_boxcall;
pub(super) use boxcall::{lower_boxcall, lower_boxcall_boxed};
pub(super) use arith::lower_compare;
pub(super) use mem::{lower_load, lower_store};
pub(super) use consts::lower_const;
@ -27,4 +29,5 @@ pub(super) use arith_ops::{lower_binop, lower_unary};
pub(super) use call::lower_call;
pub(super) use loopform::{LoopFormContext, lower_while_loopform};
pub(super) use loopform::normalize_header_phis_for_latch;
pub(super) use loopform::dev_check_dispatch_only_phi;
pub(super) use resolver::Resolver;