Files
hakorune/docs/development/abi/host_api.md
Moe Charm 773256380d Phase 12: VM/JIT identical execution tests + host API slot routing
ChatGPT5による統一実行パス実装:
- VM/JIT同一実行テスト追加(Array/Map/String/Instance)
- host_api slot経由呼び出し(NYASH_JIT_HOST_BRIDGE=1)
- extern_registry拡張(console系メソッドslot登録)
- CI: vm-jit-identical.yml(STRICT/非STRICT両系テスト)
- InstanceBox getField/setField slot 1,2統一

技術的改善:
- JIT: ops_ext委譲による統一メソッド解決
- VM: vtable/PIC/名前ベースフォールバック階層
- host_bridge: TLV encode/decode BoxRef対応
- C ABI: nyrt_host_api.h外部公開ヘッダー

テスト追加:
- identical_exec_collections: Array/Map操作一致
- identical_exec_instance: ユーザー定義Box一致
- identical_exec_string: StringBox操作一致
- host_reverse_slot: 逆引きslot解決テスト

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 09:12:39 +09:00

1.0 KiB

NyRT Host Reverse-Call API (Phase 12)

Purpose

  • Provide a stable ABI for plugins to call back into the host to operate on HostHandles.
  • Enable vtable/slot-based dispatch for Array/Map/String/Instance with GC-barrier correctness.

Exports

  • nyrt_host_call_name(handle, method, args_tlv) -> out_tlv
  • nyrt_host_call_slot(handle, slot, args_tlv) -> out_tlv (preferred)

TLV Tags (subset)

  • 1: bool
  • 2: i32
  • 3: i64/u64 (8 bytes LE)
  • 5: f64
  • 6/7: string (utf8)
  • 8: PluginHandle (type_id:u32, instance_id:u32)
  • 9: HostHandle (u64) for user/builtin boxes

Slots

  • InstanceBox: 1(getField), 2(setField), 3(has), 4(size)
  • ArrayBox: 100(get), 101(set), 102(len)
  • MapBox: 200(size), 201(len), 202(has), 203(get), 204(set)
  • StringBox: 300(len)

Barriers

  • Mutators (Instance.setField, Array.set, Map.set) invoke a write barrier using TLS-bound current VM.
  • JIT must bind set_current_vm/clear_current_vm around host-bridge calls; VM does this at the JIT boundary.

Header

  • See include/nyrt_host_api.h for C prototypes and TLV summary.