diff --git a/Cargo.toml b/Cargo.toml index 4dd43f9e..dc28eb05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,14 +42,14 @@ llvm-harness = [] llvm-inkwell-legacy = ["dep:inkwell"] llvm = ["llvm-harness"] # (removed) Optional modular MIR builder feature -cranelift-jit = [ - "dep:cranelift-codegen", - "dep:cranelift-frontend", - "dep:cranelift-module", - "dep:cranelift-jit", - "dep:cranelift-object", - "dep:cranelift-native" -] +# cranelift-jit = [ # ARCHIVED: Moved to archive/jit-cranelift/ during Phase 15 +# "dep:cranelift-codegen", +# "dep:cranelift-frontend", +# "dep:cranelift-module", +# "dep:cranelift-jit", +# "dep:cranelift-object", +# "dep:cranelift-native" +# ] aot-plan-import = [] [lib] @@ -157,13 +157,13 @@ wasm-bindgen = "0.2" console_error_panic_hook = "0.1" js-sys = "0.3" -# Cranelift JIT (optional; enabled via feature "cranelift-jit") -cranelift-codegen = { version = "0.103", optional = true } -cranelift-frontend = { version = "0.103", optional = true } -cranelift-module = { version = "0.103", optional = true } -cranelift-jit = { version = "0.103", optional = true } -cranelift-object = { version = "0.103", optional = true } -cranelift-native = { version = "0.103", optional = true } +# Cranelift JIT (ARCHIVED: moved to archive/jit-cranelift/ during Phase 15) +# cranelift-codegen = { version = "0.103", optional = true } +# cranelift-frontend = { version = "0.103", optional = true } +# cranelift-module = { version = "0.103", optional = true } +# cranelift-jit = { version = "0.103", optional = true } +# cranelift-object = { version = "0.103", optional = true } +# cranelift-native = { version = "0.103", optional = true } # WASM backend dependencies (Phase 8) - optional for faster builds wabt = { version = "0.10", optional = true } diff --git a/archive/jit-cranelift/ARCHIVE_NOTES.md b/archive/jit-cranelift/ARCHIVE_NOTES.md new file mode 100644 index 00000000..e500c8b5 --- /dev/null +++ b/archive/jit-cranelift/ARCHIVE_NOTES.md @@ -0,0 +1,96 @@ +# JIT/Cranelift アーカイブ - Phase 15 + +## 📅 アーカイブ日時 +2025-09-23 - Phase 15 セルフホスティング集中開発期間中 + +## 🎯 アーカイブ理由 + +### 現在の開発焦点 +- **Phase 15**: Nyashセルフホスティング(80k→20k行革命) +- **開発対象**: PyVMとLLVMバックエンドのみ +- **JIT/Cranelift**: 現在未使用、ビルドエラーや混乱の原因 + +### 具体的な問題 +1. **ビルドエラー**: `cranelift-jit` フィーチャーでのビルド失敗 +2. **AI開発者の混乱**: JSON開発Claude Codeが誤ってJITルートを参照 +3. **リソース分散**: メンテナンスコストが高い +4. **Phase 15集中**: PyVM/LLVM開発に集中したい + +## 📂 アーカイブ内容 + +### 移動されたディレクトリ・ファイル +``` +archive/jit-cranelift/ +├── src/ +│ ├── jit/ # JIT実装コア(ABI、エンジン、ローワリング等) +│ └── backend/cranelift/ # Craneliftバックエンド実装 +├── scripts/ +│ └── build_jit.sh # JITビルドスクリプト +└── tools/ + ├── jit_compare_smoke.sh # JIT比較スモークテスト + └── smokes/ + ├── jit_smoke.sh # JITスモークテスト + └── smoke_vm_jit.sh # VM-JIT比較テスト +``` + +### Cargo.toml変更 +- `cranelift-jit` フィーチャーをコメントアウト +- JIT関連の依存関係を無効化 + +## 🔄 復活手順(将来用) + +### 1. ファイル復元 +```bash +# アーカイブから復元 +mv archive/jit-cranelift/src/jit src/ +mv archive/jit-cranelift/src/backend/cranelift src/backend/ +mv archive/jit-cranelift/scripts/build_jit.sh . +mv archive/jit-cranelift/tools/* tools/ +``` + +### 2. Cargo.toml復元 +```toml +[features] +cranelift-jit = ["dep:cranelift", "dep:cranelift-jit", "dep:cranelift-module"] + +[dependencies] +cranelift = { version = "0.103", optional = true } +cranelift-jit = { version = "0.103", optional = true } +cranelift-module = { version = "0.103", optional = true } +``` + +### 3. ビルド確認 +```bash +# JITビルドテスト +cargo build --release --features cranelift-jit + +# スモークテスト実行 +./tools/jit_smoke.sh +``` + +### 4. 統合テスト +- PyVM vs JIT性能比較 +- LLVM vs JIT出力比較 +- 全バックエンド統合テスト + +## 💡 設計ノート + +### JIT実装の特徴 +- **Cranelift統合**: Wasmtime/Craneliftエコシステム活用 +- **ホストコール最適化**: Rustネイティブ関数との高速ブリッジ +- **メモリ管理**: GCとJITの協調動作 +- **デバッグ支援**: JIT統計・トレース機能 + +### 将来的な価値 +- **高速実行**: 本格運用時の性能向上 +- **AOTコンパイル**: ネイティブバイナリ生成 +- **WebAssembly統合**: WASM実行環境との統一 + +## 📋 関連Issue・PR +- JIT/Craneliftビルドエラー修正が必要 +- AIエージェント向けドキュメント整備 +- Phase 15完了後の復活検討 + +--- + +**Note**: このアーカイブは一時的な措置です。Phase 15完了後、JIT/Craneliftの復活と最新化を検討します。 \ No newline at end of file diff --git a/build_jit.sh b/archive/jit-cranelift/scripts/build_jit.sh similarity index 100% rename from build_jit.sh rename to archive/jit-cranelift/scripts/build_jit.sh diff --git a/src/backend/cranelift/builder.rs b/archive/jit-cranelift/src/backend/cranelift/builder.rs similarity index 100% rename from src/backend/cranelift/builder.rs rename to archive/jit-cranelift/src/backend/cranelift/builder.rs diff --git a/src/backend/cranelift/context.rs b/archive/jit-cranelift/src/backend/cranelift/context.rs similarity index 100% rename from src/backend/cranelift/context.rs rename to archive/jit-cranelift/src/backend/cranelift/context.rs diff --git a/src/backend/cranelift/jit.rs b/archive/jit-cranelift/src/backend/cranelift/jit.rs similarity index 100% rename from src/backend/cranelift/jit.rs rename to archive/jit-cranelift/src/backend/cranelift/jit.rs diff --git a/src/backend/cranelift/mod.rs b/archive/jit-cranelift/src/backend/cranelift/mod.rs similarity index 100% rename from src/backend/cranelift/mod.rs rename to archive/jit-cranelift/src/backend/cranelift/mod.rs diff --git a/src/boxes/jit_config_box.rs b/archive/jit-cranelift/src/boxes/jit_config_box.rs similarity index 100% rename from src/boxes/jit_config_box.rs rename to archive/jit-cranelift/src/boxes/jit_config_box.rs diff --git a/src/boxes/jit_events_box.rs b/archive/jit-cranelift/src/boxes/jit_events_box.rs similarity index 100% rename from src/boxes/jit_events_box.rs rename to archive/jit-cranelift/src/boxes/jit_events_box.rs diff --git a/src/boxes/jit_hostcall_registry_box.rs b/archive/jit-cranelift/src/boxes/jit_hostcall_registry_box.rs similarity index 100% rename from src/boxes/jit_hostcall_registry_box.rs rename to archive/jit-cranelift/src/boxes/jit_hostcall_registry_box.rs diff --git a/src/boxes/jit_policy_box.rs b/archive/jit-cranelift/src/boxes/jit_policy_box.rs similarity index 100% rename from src/boxes/jit_policy_box.rs rename to archive/jit-cranelift/src/boxes/jit_policy_box.rs diff --git a/src/boxes/jit_stats_box.rs b/archive/jit-cranelift/src/boxes/jit_stats_box.rs similarity index 100% rename from src/boxes/jit_stats_box.rs rename to archive/jit-cranelift/src/boxes/jit_stats_box.rs diff --git a/src/boxes/jit_strict_box.rs b/archive/jit-cranelift/src/boxes/jit_strict_box.rs similarity index 100% rename from src/boxes/jit_strict_box.rs rename to archive/jit-cranelift/src/boxes/jit_strict_box.rs diff --git a/src/jit/abi.rs b/archive/jit-cranelift/src/jit/abi.rs similarity index 100% rename from src/jit/abi.rs rename to archive/jit-cranelift/src/jit/abi.rs diff --git a/src/jit/boundary.rs b/archive/jit-cranelift/src/jit/boundary.rs similarity index 100% rename from src/jit/boundary.rs rename to archive/jit-cranelift/src/jit/boundary.rs diff --git a/src/jit/config.rs b/archive/jit-cranelift/src/jit/config.rs similarity index 100% rename from src/jit/config.rs rename to archive/jit-cranelift/src/jit/config.rs diff --git a/src/jit/engine.rs b/archive/jit-cranelift/src/jit/engine.rs similarity index 100% rename from src/jit/engine.rs rename to archive/jit-cranelift/src/jit/engine.rs diff --git a/src/jit/events.rs b/archive/jit-cranelift/src/jit/events.rs similarity index 100% rename from src/jit/events.rs rename to archive/jit-cranelift/src/jit/events.rs diff --git a/src/jit/extern/async.rs b/archive/jit-cranelift/src/jit/extern/async.rs similarity index 100% rename from src/jit/extern/async.rs rename to archive/jit-cranelift/src/jit/extern/async.rs diff --git a/src/jit/extern/birth.rs b/archive/jit-cranelift/src/jit/extern/birth.rs similarity index 100% rename from src/jit/extern/birth.rs rename to archive/jit-cranelift/src/jit/extern/birth.rs diff --git a/src/jit/extern/collections.rs b/archive/jit-cranelift/src/jit/extern/collections.rs similarity index 100% rename from src/jit/extern/collections.rs rename to archive/jit-cranelift/src/jit/extern/collections.rs diff --git a/src/jit/extern/handles.rs b/archive/jit-cranelift/src/jit/extern/handles.rs similarity index 100% rename from src/jit/extern/handles.rs rename to archive/jit-cranelift/src/jit/extern/handles.rs diff --git a/src/jit/extern/host_bridge.rs b/archive/jit-cranelift/src/jit/extern/host_bridge.rs similarity index 100% rename from src/jit/extern/host_bridge.rs rename to archive/jit-cranelift/src/jit/extern/host_bridge.rs diff --git a/src/jit/extern/mod.rs b/archive/jit-cranelift/src/jit/extern/mod.rs similarity index 100% rename from src/jit/extern/mod.rs rename to archive/jit-cranelift/src/jit/extern/mod.rs diff --git a/src/jit/extern/result.rs b/archive/jit-cranelift/src/jit/extern/result.rs similarity index 100% rename from src/jit/extern/result.rs rename to archive/jit-cranelift/src/jit/extern/result.rs diff --git a/src/jit/extern/runtime.rs b/archive/jit-cranelift/src/jit/extern/runtime.rs similarity index 100% rename from src/jit/extern/runtime.rs rename to archive/jit-cranelift/src/jit/extern/runtime.rs diff --git a/src/jit/hostcall_registry.rs b/archive/jit-cranelift/src/jit/hostcall_registry.rs similarity index 100% rename from src/jit/hostcall_registry.rs rename to archive/jit-cranelift/src/jit/hostcall_registry.rs diff --git a/src/jit/lower/builder.rs b/archive/jit-cranelift/src/jit/lower/builder.rs similarity index 100% rename from src/jit/lower/builder.rs rename to archive/jit-cranelift/src/jit/lower/builder.rs diff --git a/src/jit/lower/builder/cranelift.rs b/archive/jit-cranelift/src/jit/lower/builder/cranelift.rs similarity index 100% rename from src/jit/lower/builder/cranelift.rs rename to archive/jit-cranelift/src/jit/lower/builder/cranelift.rs diff --git a/src/jit/lower/builder/noop.rs b/archive/jit-cranelift/src/jit/lower/builder/noop.rs similarity index 100% rename from src/jit/lower/builder/noop.rs rename to archive/jit-cranelift/src/jit/lower/builder/noop.rs diff --git a/src/jit/lower/builder/object.rs b/archive/jit-cranelift/src/jit/lower/builder/object.rs similarity index 100% rename from src/jit/lower/builder/object.rs rename to archive/jit-cranelift/src/jit/lower/builder/object.rs diff --git a/src/jit/lower/builder/rt_shims.rs b/archive/jit-cranelift/src/jit/lower/builder/rt_shims.rs similarity index 100% rename from src/jit/lower/builder/rt_shims.rs rename to archive/jit-cranelift/src/jit/lower/builder/rt_shims.rs diff --git a/src/jit/lower/builder/tls.rs b/archive/jit-cranelift/src/jit/lower/builder/tls.rs similarity index 100% rename from src/jit/lower/builder/tls.rs rename to archive/jit-cranelift/src/jit/lower/builder/tls.rs diff --git a/src/jit/lower/cfg_dot.rs b/archive/jit-cranelift/src/jit/lower/cfg_dot.rs similarity index 100% rename from src/jit/lower/cfg_dot.rs rename to archive/jit-cranelift/src/jit/lower/cfg_dot.rs diff --git a/src/jit/lower/core.rs b/archive/jit-cranelift/src/jit/lower/core.rs similarity index 100% rename from src/jit/lower/core.rs rename to archive/jit-cranelift/src/jit/lower/core.rs diff --git a/src/jit/lower/core/analysis.rs b/archive/jit-cranelift/src/jit/lower/core/analysis.rs similarity index 100% rename from src/jit/lower/core/analysis.rs rename to archive/jit-cranelift/src/jit/lower/core/analysis.rs diff --git a/src/jit/lower/core/cfg.rs b/archive/jit-cranelift/src/jit/lower/core/cfg.rs similarity index 100% rename from src/jit/lower/core/cfg.rs rename to archive/jit-cranelift/src/jit/lower/core/cfg.rs diff --git a/src/jit/lower/core/ops_ext.rs b/archive/jit-cranelift/src/jit/lower/core/ops_ext.rs similarity index 100% rename from src/jit/lower/core/ops_ext.rs rename to archive/jit-cranelift/src/jit/lower/core/ops_ext.rs diff --git a/src/jit/lower/core/string_len.rs b/archive/jit-cranelift/src/jit/lower/core/string_len.rs similarity index 100% rename from src/jit/lower/core/string_len.rs rename to archive/jit-cranelift/src/jit/lower/core/string_len.rs diff --git a/src/jit/lower/core_hostcall.rs b/archive/jit-cranelift/src/jit/lower/core_hostcall.rs similarity index 100% rename from src/jit/lower/core_hostcall.rs rename to archive/jit-cranelift/src/jit/lower/core_hostcall.rs diff --git a/src/jit/lower/core_ops.rs b/archive/jit-cranelift/src/jit/lower/core_ops.rs similarity index 100% rename from src/jit/lower/core_ops.rs rename to archive/jit-cranelift/src/jit/lower/core_ops.rs diff --git a/src/jit/lower/extern_thunks.rs b/archive/jit-cranelift/src/jit/lower/extern_thunks.rs similarity index 100% rename from src/jit/lower/extern_thunks.rs rename to archive/jit-cranelift/src/jit/lower/extern_thunks.rs diff --git a/src/jit/lower/mod.rs b/archive/jit-cranelift/src/jit/lower/mod.rs similarity index 100% rename from src/jit/lower/mod.rs rename to archive/jit-cranelift/src/jit/lower/mod.rs diff --git a/src/jit/manager.rs b/archive/jit-cranelift/src/jit/manager.rs similarity index 100% rename from src/jit/manager.rs rename to archive/jit-cranelift/src/jit/manager.rs diff --git a/src/jit/mod.rs b/archive/jit-cranelift/src/jit/mod.rs similarity index 100% rename from src/jit/mod.rs rename to archive/jit-cranelift/src/jit/mod.rs diff --git a/src/jit/observe.rs b/archive/jit-cranelift/src/jit/observe.rs similarity index 100% rename from src/jit/observe.rs rename to archive/jit-cranelift/src/jit/observe.rs diff --git a/src/jit/policy.rs b/archive/jit-cranelift/src/jit/policy.rs similarity index 100% rename from src/jit/policy.rs rename to archive/jit-cranelift/src/jit/policy.rs diff --git a/src/jit/policy/invoke.rs b/archive/jit-cranelift/src/jit/policy/invoke.rs similarity index 100% rename from src/jit/policy/invoke.rs rename to archive/jit-cranelift/src/jit/policy/invoke.rs diff --git a/src/jit/rt.rs b/archive/jit-cranelift/src/jit/rt.rs similarity index 100% rename from src/jit/rt.rs rename to archive/jit-cranelift/src/jit/rt.rs diff --git a/src/jit/semantics/clif.rs b/archive/jit-cranelift/src/jit/semantics/clif.rs similarity index 100% rename from src/jit/semantics/clif.rs rename to archive/jit-cranelift/src/jit/semantics/clif.rs diff --git a/src/jit/semantics/mod.rs b/archive/jit-cranelift/src/jit/semantics/mod.rs similarity index 100% rename from src/jit/semantics/mod.rs rename to archive/jit-cranelift/src/jit/semantics/mod.rs diff --git a/src/jit/shim_trace.rs b/archive/jit-cranelift/src/jit/shim_trace.rs similarity index 100% rename from src/jit/shim_trace.rs rename to archive/jit-cranelift/src/jit/shim_trace.rs diff --git a/src/semantics/clif_adapter.rs b/archive/jit-cranelift/src/semantics/clif_adapter.rs similarity index 100% rename from src/semantics/clif_adapter.rs rename to archive/jit-cranelift/src/semantics/clif_adapter.rs diff --git a/tools/jit_compare_smoke.sh b/archive/jit-cranelift/tools/jit_compare_smoke.sh similarity index 100% rename from tools/jit_compare_smoke.sh rename to archive/jit-cranelift/tools/jit_compare_smoke.sh diff --git a/archive/jit-cranelift/tools/smokes/jit_smoke.sh b/archive/jit-cranelift/tools/smokes/jit_smoke.sh new file mode 100644 index 00000000..113d1e2a --- /dev/null +++ b/archive/jit-cranelift/tools/smokes/jit_smoke.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# Archived: JIT smoke (not maintained in current phase). Kept for reference. +set -euo pipefail + +SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +ROOT_DIR=$(CDPATH= cd -- "$SCRIPT_DIR/../../" && pwd) + +BIN="$ROOT_DIR/target/release/nyash" +if [ ! -x "$BIN" ]; then + echo "Building nyash (release, JIT)..." >&2 + cargo build --release --features cranelift-jit >/dev/null +fi + +echo "[JIT Smoke] Core VM/JIT (plugins disabled)" >&2 +NYASH_DISABLE_PLUGINS=1 NYASH_CLI_VERBOSE=1 "$ROOT_DIR/tools/smokes/archive/smoke_vm_jit.sh" >/tmp/nyash-jit-core.out +grep -q '^✅ smoke done' /tmp/nyash-jit-core.out || { echo "FAIL: core VM/JIT smoke" >&2; cat /tmp/nyash-jit-core.out; exit 1; } +echo "PASS: core VM/JIT smoke" >&2 + +echo "All PASS (archived JIT smoke)" >&2 + diff --git a/src/boxes/debug_box.rs b/src/boxes/debug_box.rs index 9fed8efc..57710721 100644 --- a/src/boxes/debug_box.rs +++ b/src/boxes/debug_box.rs @@ -328,17 +328,18 @@ impl DebugBox { // --- Phase 1: JIT/Plugin shim tracing --- pub fn trace_plugin_calls(&self, on: bool) -> Result, RuntimeError> { - crate::jit::shim_trace::set_enabled(on); + // ARCHIVED: JIT functionality moved to archive/jit-cranelift/ println!( - "[DEBUG] JIT shim trace: {}", + "[DEBUG] JIT shim trace: {} (JIT ARCHIVED - no-op)", if on { "ENABLED" } else { "DISABLED" } ); Ok(Box::new(VoidBox::new())) } pub fn get_jit_events(&self) -> Result, RuntimeError> { - let s = crate::jit::shim_trace::snapshot_joined(); - Ok(Box::new(StringBox::new(s))) + // ARCHIVED: JIT functionality moved to archive/jit-cranelift/ + let s = "[JIT ARCHIVED] No JIT events available - JIT moved to archive/jit-cranelift/"; + Ok(Box::new(StringBox::new(s.to_string()))) } } diff --git a/src/boxes/mod.rs b/src/boxes/mod.rs index 4ea1acff..612c9b9d 100644 --- a/src/boxes/mod.rs +++ b/src/boxes/mod.rs @@ -73,12 +73,13 @@ pub mod console_box; pub mod debug_config_box; pub mod function_box; pub mod gc_config_box; -pub mod jit_config_box; -pub mod jit_events_box; -pub mod jit_hostcall_registry_box; -pub mod jit_policy_box; -pub mod jit_stats_box; -pub mod jit_strict_box; +// ARCHIVED: JIT Box modules moved to archive/jit-cranelift/ during Phase 15 +// pub mod jit_config_box; +// pub mod jit_events_box; +// pub mod jit_hostcall_registry_box; +// pub mod jit_policy_box; +// pub mod jit_stats_box; +// pub mod jit_strict_box; pub mod map_box; #[cfg(not(target_arch = "wasm32"))] pub mod qr_box; diff --git a/src/lib.rs b/src/lib.rs index e95c6160..a51733cd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,7 +48,7 @@ pub mod mir_aot_plan_import { // Backends pub mod backend; -pub mod jit; // Cranelift JIT subsystem (skeleton) +// pub mod jit; // ARCHIVED: Cranelift JIT subsystem moved to archive/jit-cranelift/ pub mod semantics; // Unified semantics trait for MIR evaluation/lowering pub mod benchmarks; diff --git a/src/semantics/mod.rs b/src/semantics/mod.rs index 34b9632d..c39d2662 100644 --- a/src/semantics/mod.rs +++ b/src/semantics/mod.rs @@ -84,5 +84,5 @@ pub trait SemanticsExt: Semantics { impl SemanticsExt for T {} -pub mod clif_adapter; +// pub mod clif_adapter; // ARCHIVED: moved to archive/jit-cranelift/ pub mod vm_impl;