Commit Graph

34 Commits

Author SHA1 Message Date
ddae7fe1fc Phase 10_6b scheduler complete; 10_4 GC hooks + counting/strict tracing; 10_c minimal JIT path (i64/bool consts, binop/compare/return, hostcall opt-in); docs & examples; add Phase 10.7 roadmap (JIT branch wiring + minimal ABI). 2025-08-27 17:06:46 +09:00
de03514085 feat: Phase 10_b JIT implementation progress + academic paper ideas
Phase 10_b JIT Lower implementation:
- IRBuilder abstraction with NoopBuilder (emit counting) 
- CraneliftBuilder skeleton (feature `cranelift-jit`) 
- LowerCore implementation (Const/Copy/BinOp/Cmp/Branch/Ret) 
- Engine.compile with builder selection and JIT handle generation 
- JIT function table with stub functions 
- Basic i64 const/binop/ret emission for Cranelift
- VM execution path with NYASH_JIT_EXEC=1 support

Academic ideas and analysis:
- "Everything is Thread-Safe Box" concept
- "GC as debug tool" paradigm analysis
- GC switchable semantic equivalence documentation
- Gemini & Codex evaluation on academic paper potential
- Nyash academic papers potential themes

Current limitations:
- Return values limited to i64 (VMValue::Integer)
- Arguments not yet supported
- Compare/Branch emit not implemented
- Trap→VM fallback not implemented

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-27 03:16:57 +09:00
e5515ea5e9 docs: Update Phase 9.79b progress - ChatGPT5's implementation advances
- Phase 9.79b.1:  Minimal scope achieved (method_id introduction)
- Phase 9.79b.2:  Minimum completed
  - Universal fast-path thunks (toString/type/equals/clone)
  - Monomorphic PIC with 8-hit threshold for promotion
  - PluginBoxV2 fast-path with minimal TLV support
  - Lazy seed/reservation for builtin/plugin/user slots
  - Version-based cache invalidation framework
- Phase 9.79b.3: → In progress (TypeMeta/Thunk + Poly-PIC + Diagnostics)

🤖 ChatGPT5 is making solid progress on the unified box design implementation\!
2025-08-27 00:06:40 +09:00
2960a9b2f8 PIC direct-call: cache InstanceBox function name after threshold\n- Add boxcall_pic_funcname cache in VM\n- execute_boxcall uses cache for direct function calls\n- Threshold=8 hits per site\n- Update CURRENT_TASK 2025-08-26 22:11:17 +09:00
35049606f3 phase_9_79b_2 (PIC skeleton): Add monomorphic PIC hit counters\n- VM stores per-(receiver-type, method_id/name) hit counts\n- execute_boxcall records hits before dispatch\n- CURRENT_TASK updated 2025-08-26 20:59:37 +09:00
edbc38daad phase_9_79b_2 (skeleton): VM BoxCall fast-path for universal slots\n- execute_boxcall now takes optional method_id\n- Fast-path thunks for toString/type/equals/clone\n- Dispatch updated; docs progress note in CURRENT_TASK 2025-08-26 20:56:06 +09:00
e21778c048 phase_9_79b_1: Add Unified Registry IDs + Builder Slotting\n- MIR BoxCall carries optional method_id (slot)\n- Slot registry with universal slots [0..3]\n- Builder resolves method_id when receiver type known\n- Printer shows method_id; backends updated\n- Update CURRENT_TASK + MIR spec note 2025-08-26 20:48:48 +09:00
6eda81f5db feat: Major documentation reorganization and unified Box design updates
## Documentation & Organization
- Moved copilot_issues.txt → 00_MASTER_ROADMAP.md (phases folder)
- Created Phase 9.79b.1 & 9.79b.2 plans for unified Box implementation
- Updated unified-box-design-deep-analysis.md with ChatGPT5 insights
- Added P2P documentation and examples (ping-pong, self-ping)

## Code Updates
- P2PBox: Reverted to original error state for demonstration
- VM: Enhanced BoxCall dispatch for unified approach
- Updated box factory, interpreter calls, and transport layer

## Cleanup & Privacy
- Removed private/ and private_test/ from git tracking
- Added private folders to .gitignore for security
- Cleaned root directory: moved backups, removed temp files
- Moved consultation files to docs/archive/consultations/

## Other Improvements
- Added object literal syntax improvement idea
- Updated CLAUDE.md with master roadmap reference
- Updated CURRENT_TASK.md with latest progress

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-26 20:30:07 +09:00
22212aa314 refactor: Major interpreter modularization and P2PBox enhancements
Major Interpreter Refactoring:
- Split core.rs (373 lines removed) into focused modules
- Split expressions/calls.rs (460 lines removed) into cleaner structure
- Added new modules: calls.rs, errors.rs, eval.rs, methods_dispatch.rs, state.rs
- Improved separation of concerns across interpreter components

P2PBox Enhancements:
- Added on_once() for one-time event handlers
- Added off() for handler deregistration
- Implemented handler flags with AtomicBool for thread-safe management
- Added loopback testing cache (last_from, last_intent_name)
- Improved Arc-based state sharing for transport and handlers

Plugin Loader Unification (In Progress):
- Created plugin_loader_unified.rs skeleton
- Created plugin_ffi_common.rs for shared FFI utilities
- Migration plan documented (2400 lines → 1100 lines target)

MIR & VM Improvements:
- Enhanced modularized MIR builder structure
- Added BoxCall dispatch improvements
- Better separation in builder modules

Documentation Updates:
- Added Phase 9.79a unified box dispatch plan
- Created plugin loader migration plan
- Updated CURRENT_TASK.md with latest progress

All tests passing (180 tests) - ready for next phase of refactoring

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-26 19:13:57 +09:00
f1a4a78379 Docs: mark PoC features as deprecated (unified ops are default)
- mir_typeop_poc / mir_refbarrier_unify_poc are no-op now; Builder emits
  TypeOp/WeakRef/Barrier by default; Optimizer normalizes legacy ops.
- Update CURRENT_TASK and architecture/proposal docs accordingly.
2025-08-26 06:41:30 +09:00
391a095f4c Phase 9.78h: Stabilize MIR26 pipeline
- Add lib test to sync Core Instruction names with docs (INSTRUCTION_SET.md)
- Optimizer: Pass 0 normalizes legacy ops -> unified (TypeCheck/Cast->TypeOp,
  WeakNew/WeakLoad->WeakRef, BarrierRead/Write->Barrier)
- Optimizer: diagnostics for legacy ops; forbid via NYASH_OPT_DIAG_FORBID_LEGACY=1
- Runner: treat diagnostics (unlowered/legacy) as fatal when enabled
- Printer: unify legacy print style to TypeOp/WeakRef/Barrier
- Verifier: treat Phi inputs correctly (skip merge/dominance violations for Phi)
- Docs: update PHI_NORMALIZATION_PLAN; CURRENT_TASK: add risk note for op duplication
- Misc: PHI debugging/logs kept stable; snapshots still green
2025-08-26 06:30:01 +09:00
bf4b87526e phase(9.78h): stabilize MIR/VM pipeline
- Add MIR26 doc≡code sync test (tests/mir_instruction_set_sync.rs)
- Quiet snapshots; filter plugin/net logs; golden all green
- Delegate VM phi selection to LoopExecutor (borrow-safe)
- ResultBox migration: remove legacy box_trait::ResultBox paths
- VM BoxRef arithmetic fallbacks via toString().parse::<i64>()
- Bridge BoxCall(InstanceBox) to Class.method/arity in VM
- Fix Effects purity (READ -> readonly, not pure)
- Mark Catch as CONTROL to prevent DCE; Try/Catch test green
- Add env-gated debug logs (effects, verifier, mir-printer, trycatch, ref, bin)
- Update CURRENT_TASK with progress and next steps
2025-08-26 05:49:23 +09:00
1e735d7717 runner: split modes (mir/vm/llvm/bench) and extract plugin init; interpreter: split objects into ops/methods/fields; VM logs gated; Phi selection minimal fix; CURRENT_TASK updated; remove legacy backups 2025-08-26 04:34:14 +09:00
11c149ac2b docs(current): refresh reboot shortcuts, smoke cmds, and next steps after VM compare fix; add quick restart guide 2025-08-26 03:33:01 +09:00
5765953e5f docs(current): record VM and/or truthiness, unify IntegerBox (re-export), and note loop-compare fix plan 2025-08-26 02:39:52 +09:00
44305404e4 Update CURRENT_TASK: mark MIR26 consolidation confirmed; note loop builder stabilization, CLI core-ci guide/script, ResultBox stage-0; update last-updated date. Ready to reopen without stream issues. 2025-08-26 01:44:14 +09:00
9c94e88b86 ResultBox migration (stage 0): suppress legacy deprecation warnings in box_trait impls; keep dual handling in VM. Fix verifier Display for SuspiciousBarrierContext. Expose VM stats fields to vm_stats module. CLI core_ci guide and script in place. 2025-08-26 01:42:18 +09:00
7ccd5420ac Docs/CurrentTask: add explicit refactor goals/milestones/steps. VM modules: add Purpose/Responsibilities/Key APIs/Typical Callers headers. Build+goldens green. 2025-08-26 01:07:23 +09:00
2a02eb7a52 Refactor (light): move VM value ops to backend/vm_values.rs; add backend/vm_boxcall.rs with call_box_method_impl and rewire call_unified_method. Update CURRENT_TASK for refactor start. 2025-08-26 00:48:09 +09:00
f82ad5a84d Phase 9.78h: VM BinOp and/or short-circuit + BoxRef<Integer> arithmetic; add diagnostic hooks. Update CURRENT_TASK with progress and VM path-tracing TODO. Align docs: MIR26 canonical spec and phase docs. 2025-08-26 00:06:35 +09:00
b8e416fb03 refactor: MIR builder modularization complete - ready for handoff
- MIRビルダーのモジュール化完了(1,547行→6モジュール)
  - core.rs (205行): MirBuilder本体
  - expressions.rs (621行): 式変換処理
  - statements.rs (165行): 文変換処理
  - control_flow.rs (194行): 制御フロー
  - box_handlers.rs (73行): Box処理
- 現在builder_modularizedに退避(MIR命令構造変更により調整必要)
- フルビルド可能な状態を維持
- CURRENT_TASK.mdに引き継ぎポイント記載

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-25 19:33:07 +09:00
4caa07d865 docs: Update CURRENT_TASK.md after MIR builder refactoring completion
- Marked MIR builder modularization as completed
- Added completion dates and commit hashes
- Updated next priority tasks from copilot_issues.txt
- Cleaned up completed task descriptions
2025-08-25 19:09:29 +09:00
17adc4347d refactor: MIR builder - complete modularization (Phase 6-8)
- Phase 6: statements.rs (165 lines) - 6 functions
  - build_print_statement, build_block
  - build_local_statement, build_return_statement
  - build_throw_statement, build_nowait_statement

- Phase 7: control_flow.rs (194 lines) - 4 functions
  - build_if_statement, build_loop_statement
  - build_try_catch_statement, is_current_block_terminated

- Phase 8: box_handlers.rs (73 lines) - 2 functions
  - build_static_main_box, build_box_declaration

Total: 30 functions moved across 4 modules
Original builder.rs reduced from 1547 lines
Build verified successfully
2025-08-25 18:43:45 +09:00
4b984d937b refactor: MIR builder - extract expressions module (Phase 3-5)
- Moved all expression-related functions to expressions.rs (621 lines)
- Includes: build_expression, build_literal, binary/unary ops
- Added missing functions for build_expression completeness:
  - build_assignment, build_field_assignment
  - build_new_expression, build_await_expression
- expressions.rs now contains 16 functions total
- Build verified successfully
2025-08-25 18:15:23 +09:00
cff58dbc0a refactor: MIR Builder Phase 1 - モジュール分割準備完了
【Phase 1完了内容】
- src/mir/builder/ ディレクトリ構造作成
- MirBuilder コア機能を core.rs に分離(8関数実装済み)
- 責務別モジュール準備(expressions/statements/control_flow/box_handlers)
- ビルド確認: 新構造でコンパイル正常完了

【技術詳細】
- MirBuilder本体 + emit_instruction/emit_type_check等コア機能
- プレースホルダー実装でビルド安全性確保
- CURRENT_TASK.md更新(Phase 1完了状況記録)
- 49関数/1547行の段階的分割準備

【次のPhase】
- Phase 2: 実際の関数移動(expressions.rs最優先)
- 慎重アプローチ: デッドコード削除は後回し

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-25 17:49:21 +09:00
0aef8d49a7 Phase 2: TypeOp変換の一本化(Optimizer安全ネット削除)\nPhase 3: 可視化/スナップショット基盤(--mir-verbose-effects, snapshot/compare/ci_check)\nDocs: Phase 1/2 完了マーク・利用方法追記 2025-08-24 01:58:41 +09:00
3c3dc86be0 feat: MIR builder TypeOp lowering for is/as methods and isType/asType functions
- Add early TypeOp lowering in build_expression for method-style is()/as()
- Add early TypeOp lowering in build_expression for function-style isType()/asType()
- Add special handling in build_print_statement for print(isType/asType(...))
- Fix MIR optimizer borrow checker issues and remove obsolete BoxFieldLoad
- Extract string literal helper supports both direct literals and StringBox wrappers
- Note: isType call generation still has issues (undefined SSA value in print)

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-24 00:05:12 +09:00
2949648e71 fix: MIR builder me resolution for static box methods
- Fixed me ValueId inconsistency in static box methods
- Previously, each me reference generated a new const __me__ ValueId
- Now caches the first me ValueId in variable_map for reuse
- This ensures RefSet and RefGet operate on the same object
- ArrayBox get/set/push now working correctly in VM mode
- Test results: 1, 42, 3 (as expected)

🔧 Technical Details:
- build_me_expression() now stores fallback ValueId in variable_map
- Subsequent me references reuse the same ValueId
- VM BoxCall debug logs confirm ArrayBox methods dispatch correctly

Co-Authored-By: ChatGPT5
Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 21:13:02 +09:00
fffbac9aac feat: MIR TypeOp/WeakRef/Barrier PoC implementation
- Add TypeOpKind, WeakRefOp, BarrierOp enums for unified instructions
- Implement TypeOp instruction combining TypeCheck/Cast
- Implement WeakRef instruction combining WeakNew/WeakLoad
- Implement Barrier instruction combining BarrierRead/BarrierWrite
- Update VM to handle new unified instructions
- Update MIR printer for new instruction formats
- Add feature flags mir_typeop_poc and mir_refbarrier_unify_poc
- Maintain backward compatibility with legacy instructions

This is Phase 8.5 MIR instruction diet PoC implementation.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 19:27:02 +09:00
98fd6a1e3e docs: Update CURRENT_TASK with VM enhancements and test results
- Document dynamic type conversion implementations
- Add test results for Integer non-zero conditions
- Update ArrayBox/MapBox VM method support status
- Record SocketBox timeout method implementations

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 18:52:18 +09:00
70af0fe566 feat: Add HTTP status tests and dynamic plugin documentation
- Add e2e_vm_http_status_404/500 tests to verify HTTP status handling
- ResultBox properly returns Ok(Response) for HTTP errors, Err for connection failures
- Create dynamic-plugin-flow.md documenting MIR→VM→Registry→Plugin flow
- Add vm-stats test files for HTTP 404/500 status codes
- Update net-plugin.md with HTTP error handling clarification
- Create E2E_TESTS.md documenting all E2E test behaviors
- Add mir-26-instruction-diet.md for MIR optimization plans
- Add vm-stats-cookbook.md for VM statistics usage guide
- Update MIR verifier to properly track self-assignment patterns

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 16:33:32 +09:00
dd09e81018 feat: Add VM instruction statistics and fix plugin TLV debugging
Major changes:
- Add --vm-stats and --vm-stats-json CLI flags for VM instruction profiling
- Implement instruction counting by opcode type with JSON output support
- Add enhanced TLV debug logging with NYASH_DEBUG_PLUGIN=1 environment variable
- Fix missing fields in CliConfig and ASTNode::BoxDeclaration for test compatibility
- Improve plugin method call error messages with argument count/type details

This enables MIR→VM conversion health checks and supports the Phase 8.6 VM optimization goals.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 03:40:17 +09:00
080458d4d4 fix: Correct HttpRequestBox method_id mapping in nyash.toml
Fixed the method ID order in HttpRequestBox configuration to match plugin implementation:
- path: method_id 1 (was incorrectly 2)
- readBody: method_id 2 (was incorrectly 3)
- respond: method_id 3 (was incorrectly 1)

This resolves the 45-day debugging issue where req.respond(resp) was calling
the wrong plugin method, causing HTTP responses to have empty bodies.

All E2E tests now pass:
- e2e_http_stub_end_to_end 
- e2e_http_multiple_requests_order 
- e2e_http_post_and_headers 
- e2e_http_server_restart 
- e2e_http_server_shutdown_and_restart 

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-22 12:09:06 +09:00
cc2a820af7 feat(plugin): Fix plugin BoxRef return and Box argument support
- Fixed deadlock in FileBox plugin copyFrom implementation (single lock)
- Added TLV Handle (tag=8) parsing in calls.rs for returned BoxRefs
- Improved plugin loader with config path consistency and detailed logging
- Fixed loader routing for proper Handle type_id/fini_method_id resolution
- Added detailed logging for TLV encoding/decoding in plugin_loader_v2

Test docs/examples/plugin_boxref_return.nyash now works correctly:
- cloneSelf() returns FileBox Handle properly
- copyFrom(Box) accepts plugin Box arguments
- Both FileBox instances close and fini correctly

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-21 00:41:26 +09:00