From 229553f7a42aab49a6be4193833e1b4e16e8a07d Mon Sep 17 00:00:00 2001 From: tomoaki Date: Sat, 27 Dec 2025 02:15:13 +0900 Subject: [PATCH] refactor(nyrt): consolidate ny_release_strong into lifecycle module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase 29y.1 cleanup: Eliminate duplicate ny_release_strong implementation. Changes: - Remove duplicate ny_release_strong from lib.rs (11 lines) - Consolidate into ffi/lifecycle.rs (rename shim → legacy name) - Maintain backward compatibility with existing LLVM lowering Verification: - quick: 154/154 PASS - integration phase29y: 2/2 PASS 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- crates/nyash_kernel/src/ffi/lifecycle.rs | 14 ++++++-------- crates/nyash_kernel/src/lib.rs | 11 ----------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/crates/nyash_kernel/src/ffi/lifecycle.rs b/crates/nyash_kernel/src/ffi/lifecycle.rs index 5e3dcc05..d581b8c3 100644 --- a/crates/nyash_kernel/src/ffi/lifecycle.rs +++ b/crates/nyash_kernel/src/ffi/lifecycle.rs @@ -57,18 +57,16 @@ pub extern "C" fn nyrt_handle_release_h(handle: i64) { } // ============================================================================ -// Compatibility shim for existing code +// Legacy name (backward compatibility) // ============================================================================ -/// ny_release_strong: Compatibility shim +/// ny_release_strong: Legacy name (backward compatibility) /// -/// Legacy name for nyrt_handle_release_h. -/// New code should use nyrt_handle_release_h directly. +/// Original name from Phase 287. Kept for backward compatibility with existing +/// LLVM lowering code. Equivalent to nyrt_handle_release_h. /// -/// # Deprecation -/// This function is kept for backward compatibility with existing LLVM lowering. -/// Future phases will migrate callers to nyrt_handle_release_h. +/// New code should prefer nyrt_handle_release_h for clarity. #[no_mangle] -pub extern "C" fn ny_release_strong_shim(handle: i64) { +pub extern "C" fn ny_release_strong(handle: i64) { nyrt_handle_release_h(handle); } diff --git a/crates/nyash_kernel/src/lib.rs b/crates/nyash_kernel/src/lib.rs index c93bcd19..9b1d5d45 100644 --- a/crates/nyash_kernel/src/lib.rs +++ b/crates/nyash_kernel/src/lib.rs @@ -713,17 +713,6 @@ pub extern "C" fn ny_check_safepoint() { nyash_rust::runtime::global_hooks::safepoint_and_poll(); } -// export: ny_release_strong(handle: i64) -> void -// Phase 287: Release strong reference for variable overwrite semantics -#[no_mangle] -pub extern "C" fn ny_release_strong(handle: i64) { - if handle > 0 { - // Drop the handle - this decrements the reference count - // and may trigger deallocation if count reaches zero - nyash_rust::runtime::host_handles::drop_handle(handle as u64); - } -} - #[export_name = "nyash.string.birth_h"] pub extern "C" fn nyash_string_birth_h_export() -> i64 { // Create a new StringBox via unified plugin host; return runtime handle as i64