18 KiB
18 KiB
Phase 20.6 — Checklist
Status: Planning Duration: 12 weeks (2026-03-01 → 2026-05-24)
進捗スナップショット(2025‑10 反映)
済(実装/統合)
- MirCall 正規化(Callee=Method/ModuleFunction/Extern/Constructor)
- NewBox→Constructor 既定ON(Builder/Optimizer 統一)
- Static Box “me” 注入を Rewrite へ移設 + Verifier で違反 Fail‑Fast
- LoopForm(quick 既定ON/PHI 安定)
- Boot/Lock(Zero‑Box Boot):
--frozen/--lock/--lock-verify/--lock-diff - PluginLoader v2: BootPlan 優先で探索撤退(TOML I/O 抑止)
- Lock Diff: libraries/plugins/order と先頭不一致/位置ズレ表示
- ValueIdAllocator 常時ON(ValueIdGenerator 撤退)
- スモーク刷新(quick/integration): 旧仕様/プラグイン依存スモークを opsサマリ or Hako最小コードへ置換し、全緑化
残(20.6 範囲:設計/文書中心・挙動不変)
- memory ops(load/store/copy)最終仕様と Golden 設計
- typeop(cast/check)最終仕様と Verifier 規約の整合
- unaryop(not/neg)表記の確定(Mir JSON v1 への反映)
- PublishedKnown と
/arity規約の明記(Builder/VM の使い分け) - Box Eq/Ne 統一経路(Enum.equals / nyrt.ops.op_eq)の記述強化
- Boot/Lock 運用 CLI 例を PLAN/INDEX にも併記
Phase B Complete: VM Core (Week 1-6)
Week 1-2: Memory Operations (2026-03-01 - 03-14)
Implementation
- Design memory operation handlers
- Implement
load_handler.hako- Load value from memory
- Handle invalid memory addresses
- Result-based error handling
- Implement
store_handler.hako- Store value to memory
- Handle memory overflow
- Result-based error handling
- Implement
copy_handler.hako- Copy value between registers
- Handle invalid register IDs
- Result-based error handling
Testing
- Create test suite:
tests/golden/phase-b/memory/ test_load_basic.hako- Basic load operationtest_store_basic.hako- Basic store operationtest_copy_basic.hako- Basic copy operationtest_load_invalid_address.hako- Error handlingtest_store_overflow.hako- Error handlingtest_memory_aliasing.hako- Multiple referencestest_load_store_cycle.hako- Load after storetest_copy_chain.hako- Multiple copiestest_memory_edge_cases.hako- Edge casestest_memory_stress.hako- Stress test
Integration
- Update instruction dispatcher to handle new ops
- Run Golden Tests for memory operations
- Measure performance vs Rust-VM
- Document memory operation design
Week 3-4: Unified Call (MirCall) (2026-03-15 - 03-28)
Implementation
- Design unified MirCall handler
- Implement
mir_call_handler.hako(単一エントリ)- Callee::Method(受領者付き)
- Callee::ModuleFunction("Box.method/arity")
- Callee::Extern("iface.method")
- Callee::Constructor{box_type}
- Result-based error handling / Effect tracking
Testing
- Create test suite:
tests/golden/phase-b/calls/ test_method_call.hako- Methodtest_module_function_call.hako- Module functiontest_closure_call_basic.hako- Basic closuretest_closure_call_capture.hako- Closure with capturetest_extern_call_time.hako- External call (time)test_extern_call_array_size.hako- External call (array.size)test_constructor_call.hako- Constructor calleetest_call_recursion.hako- Recursive calltest_call_nested.hako- Nested callstest_call_with_complex_args.hako- Complex argumentstest_call_error_handling.hako- Error propagationtest_mircall_all_variants.hako- All MirCall variants
Integration
- Update instruction dispatcher to handle call ops
- Run Golden Tests for call operations
- Measure call performance vs Rust-VM
- Document MirCall unification design
Week 5: Type Operations (2026-03-29 - 04-04)
Implementation
- Design type operation handlers
- Implement
typeop_handler.hako- Type checking (is_a?)
- Type casting (as)
- Type comparison
- Result-based error handling (Box creation は MirCall::Constructor に統一)
Testing
- Create test suite:
tests/golden/phase-b/types/ test_typeop_check.hako- Type checkingtest_typeop_cast.hako- Type castingtest_typeop_compare.hako- Type comparisontest_typeop_invalid.hako- Invalid type operationtest_constructor_basic.hako- Constructor calleetest_constructor_birth_lifecycle.hako- Birth method calltest_type_operations_stress.hako- Stress test
Integration
- Update instruction dispatcher to handle type ops
- Run Golden Tests for type operations
- Measure type operation performance
- Document type system design
Week 6: Control Optimizations + Golden Tests (2026-04-05 - 04-11)
Implementation
- Implement
barrier_handler.hako- GC barrier semantics
- Memory ordering
- Implement
safepoint_handler.hako- GC safepoint semantics
- Stack scanning preparation
- Implement
loopform_handler.hako- Loop detection hint
- Optimization metadata
- Implement
unaryop_handler.hako- Unary negation
- Logical NOT
- Result-based error handling
Golden Test Suite (100+ tests)
Arithmetic (10 tests)
test_arithmetic_add.hakotest_arithmetic_sub.hakotest_arithmetic_mul.hakotest_arithmetic_div.hakotest_arithmetic_mod.hakotest_arithmetic_overflow.hakotest_arithmetic_underflow.hakotest_arithmetic_divide_by_zero.hakotest_arithmetic_complex.hakotest_arithmetic_stress.hako
Control Flow (10 tests)
test_control_if_else.hakotest_control_loop.hakotest_control_nested_loop.hakotest_control_branch.hakotest_control_jump.hakotest_control_phi_simple.hakotest_control_phi_complex.hakotest_control_early_return.hakotest_control_break_continue.hakotest_control_stress.hako
Collections (10 tests)
test_collections_array_ops.hakotest_collections_map_ops.hakotest_collections_array_iteration.hakotest_collections_map_iteration.hakotest_collections_nested_arrays.hakotest_collections_nested_maps.hakotest_collections_mixed.hakotest_collections_large_array.hakotest_collections_large_map.hakotest_collections_stress.hako
Recursion (5 tests)
test_recursion_factorial.hakotest_recursion_fibonacci.hakotest_recursion_ackermann.hakotest_recursion_mutual.hakotest_recursion_deep.hako
Closures (5 tests)
test_closures_capture.hakotest_closures_nested.hakotest_closures_multiple_capture.hakotest_closures_return_closure.hakotest_closures_closure_chain.hako
Strings (10 tests)
test_strings_concat.hakotest_strings_substring.hakotest_strings_length.hakotest_strings_compare.hakotest_strings_empty.hakotest_strings_unicode.hakotest_strings_escape.hakotest_strings_long.hakotest_strings_interpolation.hakotest_strings_stress.hako
Types (10 tests)
test_types_check.hakotest_types_cast.hakotest_types_newbox.hakotest_types_inheritance.hakotest_types_polymorphism.hakotest_types_interface.hakotest_types_null_handling.hakotest_types_error_propagation.hakotest_types_complex.hakotest_types_stress.hako
Memory (10 tests)
test_memory_load.hakotest_memory_store.hakotest_memory_copy.hakotest_memory_aliasing.hakotest_memory_stack.hakotest_memory_heap.hakotest_memory_gc_barrier.hakotest_memory_gc_safepoint.hakotest_memory_leak_check.hakotest_memory_stress.hako
Complex (30 tests)
test_complex_mini_compiler.hakotest_complex_json_parser.hakotest_complex_expression_evaluator.hakotest_complex_state_machine.hakotest_complex_tree_traversal.hakotest_complex_graph_algorithm.hakotest_complex_sorting.hakotest_complex_searching.hakotest_complex_pattern_matching.hakotest_complex_regex.hakotest_complex_http_parser.hakotest_complex_csv_parser.hakotest_complex_xml_parser.hakotest_complex_markdown_parser.hakotest_complex_code_formatter.hakotest_complex_calculator.hakotest_complex_interpreter.hakotest_complex_vm_simulator.hakotest_complex_assembler.hakotest_complex_disassembler.hakotest_complex_profiler.hakotest_complex_debugger.hakotest_complex_optimizer.hakotest_complex_code_generator.hakotest_complex_type_checker.hakotest_complex_linter.hakotest_complex_test_framework.hakotest_complex_build_system.hakotest_complex_package_manager.hakotest_complex_stress_all.hako
Performance Measurement
- Run all Golden Tests (100+)
- Measure Hako-VM vs Rust-VM performance
- Generate performance report
- Verify: Hako-VM ≥ 50% of Rust-VM
Week 6 Deliverables
- All 16 MIR instructions implemented
- 100+ Golden Tests ALL PASS
- Performance report complete
- Phase B completion report
Phase C: Dispatch Unification (Week 7-12)
Week 7-8: Resolver Integration (2026-04-12 - 04-25)
Design
- Finalize Resolver architecture
- Design MethodHandle structure
- Design type registry structure
- Review with ChatGPT/Claude
Implementation
- Implement
resolver_box.hakolookup(type_id, method, arity) -> MethodHandle- Type registry initialization
- Method registration API
- Fail-Fast for unknown methods
- Implement
method_handle_box.hako- Handle storage (implementation + metadata)
- Arity information
- Type information
- Implement
type_registry_box.hako- Type registration
- Method registry per type
- Lookup optimization
Testing
- Create test suite:
tests/golden/phase-c/resolver/ test_resolver_lookup_success.hako- Successful lookuptest_resolver_lookup_failure.hako- Fail-Fast behaviortest_resolver_arity_mismatch.hako- Arity checktest_resolver_type_not_found.hako- Unknown typetest_resolver_method_not_found.hako- Unknown methodtest_resolver_registration.hako- Type registrationtest_resolver_override.hako- Method overridetest_resolver_inheritance.hako- Method inheritancetest_resolver_multiple_types.hako- Multiple typestest_resolver_performance.hako- Lookup performancetest_resolver_edge_cases.hako(10 tests) - Edge cases
Integration
- Integrate Resolver with call_handler
- Run integration tests (20 tests)
- Measure lookup performance
- Document Resolver design
Week 9-10: CallableBox Refactoring (2026-04-26 - 05-09)
Design
- Finalize CallableBox architecture
- Design NoOperatorGuard mechanism
- Design macro desugaring strategy
- Review with ChatGPT/Claude
Implementation
- Implement
exec_box.hakocall_by_handle(handle, args, guard)- Argument validation
- NoOperatorGuard integration
- Error handling
- Implement
no_operator_guard_box.hako- Guard activation/deactivation
- Recursion prevention (for op_eq, etc.)
- Thread-local state (if needed)
- Implement macro desugaring (compiler side)
arr.push(value)→Callable.ref_method(arr, :push, 1).call([value])- Operator desugaring (e.g.,
a + b→Callable.ref_operator(a, :+, 1).call([b]))
Testing
- Create test suite:
tests/golden/phase-c/callable/ test_callable_call_by_handle.hako- Basic calltest_callable_no_operator_guard.hako- Guard mechanismtest_callable_recursion_prevention.hako- Prevent re-entrytest_callable_arity_validation.hako- Arity checktest_callable_error_propagation.hako- Error handlingtest_macro_desugar_method.hako- Method desugaringtest_macro_desugar_operator.hako- Operator desugaringtest_macro_desugar_chain.hako- Method chainingtest_macro_desugar_nested.hako- Nested callstest_callable_performance.hako- Call performancetest_callable_edge_cases.hako(15 tests) - Edge cases
Integration
- Integrate ExecBox with Resolver
- Update compiler for macro desugaring
- Run integration tests (25 tests)
- Measure call overhead
- Document CallableBox design
Week 11: Universal Route Minimization (2026-05-10 - 05-16)
Removal Tasks
- Identify all special-case dispatch code
- Remove Global function special case
- Remove Box method special case
- Remove Closure special case
- Remove Constructor special case
- Remove Module function special case
- Remove hardcoded method tables
- Remove fallback implementations
Unification Tasks
- All calls go through Resolver.lookup
- All invocations go through ExecBox.call_by_handle
- Verify Fail-Fast for unknown methods
- Verify no silent fallbacks
Testing
- Create test suite:
tests/golden/phase-c/unification/ test_unification_no_global_special_case.hako- No special casetest_unification_no_box_special_case.hako- No special casetest_unification_no_closure_special_case.hako- No special casetest_unification_no_constructor_special_case.hako- No special casetest_unification_no_module_special_case.hako- No special casetest_unification_fail_fast_unknown_method.hako- Fail-Fasttest_unification_fail_fast_wrong_arity.hako- Fail-Fasttest_unification_no_fallback.hako- No fallbacktest_unification_all_paths.hako(22 tests) - All code paths
Codebase Cleanup
- Remove unused code
- Simplify control flow
- Consolidate error handling
- Update documentation
Integration
- Run all Golden Tests again (100+)
- Verify no regressions
- Measure performance (should be same or better)
- Document route minimization
C‑ABI Unification (design only in 20.6)
Documents / Flags
- Draft ABI header spec(hako_abi_v1: TypeId/Handle/Result/Dispatch/Allocator)
- Two‑Layer Export policy(Stable ABI / Inlinable API)を docs に追加
- env docs に flags を追記:
NYASH_ABI_BASIC_ON,NYASH_ABI_BUILTIN_LINK - Build presets(default/embedded/research)を記載
Verification
- フラグOFFで quick/integration 緑(挙動不変)
- CI は ABI フラグ非依存(導入のみ)
Week 12: Integration + Documentation (2026-05-17 - 05-24)
Integration Testing
- Re-run all Golden Tests (155+ tests)
- Phase B tests: 50 tests
- Phase C tests: 75 tests
- Integration tests: 30 tests
- Verify 100% PASS rate
- Run stress tests
- Run regression tests
Performance Testing
- Run benchmark suite
- Measure Hako-VM vs Rust-VM
- Verify: Hako-VM ≥ 50% of Rust-VM
- Generate performance report
- Identify bottlenecks (for Phase 20.7)
Documentation
- VM Core Complete Reference
- All 16 instructions documented
- Control flow patterns
- Memory model
- Error handling
- Dispatch Unification Design Doc
- Resolver architecture
- CallableBox design
- NoOperatorGuard mechanism
- Macro desugaring strategy
- Performance Report
- Benchmark results
- Performance comparison
- Bottleneck analysis
- Optimization recommendations
- Phase 20.6 Completion Report
- Summary of achievements
- Lessons learned
- Known issues
- Recommendations for Phase 20.7
- Phase 20.7 Planning Doc
- Collections in Hakorune
- MapBox implementation plan
- ArrayBox implementation plan
- Deterministic behavior design
Code Review
- Self-review complete
- ChatGPT review complete
- Claude review complete
- Address all review comments
CI Integration
- All Golden Tests passing in CI
- Performance benchmarks in CI
- Documentation builds in CI
- Release notes prepared
Summary Checklist
Phase B Complete (Week 1-6)
- All 16 MIR instructions implemented
- 50+ Golden Tests for Phase B
- Performance: Hako-VM ≥ 50% of Rust-VM
- Phase B completion report
Phase C Complete (Week 7-12)
- Resolver.lookup implemented
- ExecBox.call_by_handle implemented
- Special-case dispatch removed
- 75+ Golden Tests for Phase C
- Phase C completion report
Overall Phase 20.6
- 155+ Golden Tests ALL PASS
- Dispatch unified (single path)
- Performance verified (≥ 50%)
- Documentation complete
- Phase 20.7 planned
- Phase 20.6 completion report submitted
Completion (2025‑10)
- Acceptance 達成:
- quick/integration 緑(AOT canaries 含む)
- Gate‑C Strict の代表負例が安定(診断文言固定)
- 実施メモ:
- quick: BlockBuilder/JsonEmit 依存の古いスモークを opsサマリ化(非プラグイン・純粋)。
- integration: 自己ホストM2 parity を Hakoコード直書きのVM/LLVM 比較に刷新。
- FFI‑C: devゲート(HAKO_FFI_C_STRICT)導入。既定は無効、検証時のみ厳格Fail‑Fastを確認。
Created: 2025-10-14 Last Updated: 2025-10-14 Status: Planning Total Tasks: 200+ checkboxes All Uncompleted: [ ] (ready for execution)