Major enhancements to LLVM code generation and type handling: 1. String Operations: - Added StringBox length fast-path (length/len methods) - Converts i8* to handle when needed for len_h call - Consistent handle-based string operations 2. Array/Map Fast-paths: - ArrayBox: get/set/push/length operations - MapBox: get/set/has/size with handle-based keys - Optimized paths for common collection operations 3. Field Access: - getField/setField implementation with handle conversion - Proper i64 handle to pointer conversions 4. NewBox Improvements: - StringBox/IntegerBox pass-through optimizations - Fallback to env.box.new when type_id unavailable - Support for dynamic box creation 5. Documentation: - Added ARCHITECTURE.md for overall design - Added EXTERNCALL.md for external call specs - Added LOWERING_LLVM.md for LLVM lowering rules - Added PLUGIN_ABI.md for plugin interface 6. Type System: - Added UserBox type registration in nyash_box.toml - Consistent handle (i64) representation across system Results: More robust LLVM code generation with proper type handling 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1.2 KiB
1.2 KiB
Plugin ABI (by-id / tagged) — Snapshot
This summarizes the ABI surfaces used by LLVM in Phase 15. Details live in NyRT (crates/nyrt).
Fixed-arity by-id shims
- Integer-dominant:
i64 @nyash_plugin_invoke3_i64(i64 type_id, i64 method_id, i64 argc, i64 recv_h, i64 a1, i64 a2, i64 a3, i64 a4) - Float-dominant:
f64 @nyash_plugin_invoke3_f64(i64 type_id, i64 method_id, i64 argc, i64 recv_h, f64 a1, f64 a2, f64 a3, f64 a4)
Tagged shims (mixed types)
- Fixed (<=4 args):
i64 @nyash_plugin_invoke3_tagged_i64(i64 type_id, i64 method_id, i64 argc, i64 recv_h, i64 a1, i64 t1, i64 a2, i64 t2, i64 a3, i64 t3, i64 a4, i64 t4) - Vector (N args):
i64 @nyash.plugin.invoke_tagged_v_i64(i64 type_id, i64 method_id, i64 argc, i64 recv_h, i8* vals, i8* tags)
Tag codes (minimal):
- 3=int, 5=float, 8=handle(ptr). Others are reserved/experimental.
Return mapping (LLVM lowering)
- If destination is annotated as Integer/Bool → keep i64 as integer.
- If destination is String/Box/Array/Future/Unknown → cast i64 handle to opaque pointer for SSA flow; do not
inttoptrwhere a C string is expected.
Notes
- These ABIs are used by both built-ins (nyrt) and plugins for consistency.
- The LLVM backend is the reference; other backends will be aligned later.