Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #163 from OffchainLabs/stub_out_finalize_ref
Browse files Browse the repository at this point in the history
stub-out js_finalize_ref
  • Loading branch information
rachel-bousfield authored Oct 6, 2023
2 parents 15391f9 + bf6df49 commit 5378a9d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
11 changes: 3 additions & 8 deletions arbitrator/jit/src/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,18 +261,13 @@ fn get_field(env: &mut WasmEnv, source: u32, field: &[u8]) -> GoValue {
}

/// go side: λ(v value)
// TODO: implement ref counting
pub fn js_finalize_ref(mut env: WasmEnvMut, sp: u32) {
let (mut sp, env) = GoStack::new(sp, &mut env);
let pool = &mut env.js_state.pool;
let (mut sp, _) = GoStack::new(sp, &mut env);

let val = JsValue::new(sp.read_u64());
match val {
JsValue::Ref(x) if x < DYNAMIC_OBJECT_ID_BASE => {}
JsValue::Ref(x) => {
if pool.remove(x).is_none() {
eprintln!("Go trying to finalize unknown ref {}", x);
}
}
JsValue::Ref(_) => {}
val => eprintln!("Go trying to finalize {:?}", val),
}
}
Expand Down
8 changes: 2 additions & 6 deletions arbitrator/wasm-libraries/go-stub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,17 +618,13 @@ pub unsafe extern "C" fn go__syscall_js_valueIndex(sp: usize) {
}

/// Safety: λ(v value)
/// TODO: reference counting
#[no_mangle]
pub unsafe extern "C" fn go__syscall_js_finalizeRef(sp: usize) {
let mut sp = GoStack::new(sp);
let val = JsValue::new(sp.read_u64());
match val {
JsValue::Ref(x) if x < DYNAMIC_OBJECT_ID_BASE => {}
JsValue::Ref(x) => {
if DynamicObjectPool::singleton().remove(x).is_none() {
eprintln!("Go attempting to finalize unknown ref {}", x);
}
}
JsValue::Ref(_) => {}
val => eprintln!("Go attempting to finalize {:?}", val),
}
}
Expand Down

0 comments on commit 5378a9d

Please sign in to comment.