Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: runtime number singleton value cache #1206

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions kclvm/runtime/src/value/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ static mut kclvm_value_Bool_true_obj: usize = 0;
#[allow(non_camel_case_types, non_upper_case_globals)]
static mut kclvm_value_Bool_false_obj: usize = 0;

#[allow(non_camel_case_types, non_upper_case_globals)]
static mut kclvm_value_Int_0_obj: usize = 0;

#[allow(non_camel_case_types, non_upper_case_globals)]
static mut kclvm_value_Float_0_obj: usize = 0;

// Undefine/None

#[no_mangle]
Expand Down Expand Up @@ -148,14 +142,6 @@ pub extern "C" fn kclvm_value_Int(
v: kclvm_int_t,
) -> *mut kclvm_value_ref_t {
let ctx = mut_ptr_as_ref(ctx);
if v == 0 {
unsafe {
if kclvm_value_Int_0_obj == 0 {
kclvm_value_Int_0_obj = new_mut_ptr(ctx, ValueRef::int(0)) as usize;
}
return kclvm_value_Int_0_obj as *mut kclvm_value_ref_t;
}
}
new_mut_ptr(ctx, ValueRef::int(v))
}

Expand All @@ -166,14 +152,6 @@ pub extern "C" fn kclvm_value_Float(
v: kclvm_float_t,
) -> *mut kclvm_value_ref_t {
let ctx = mut_ptr_as_ref(ctx);
if v == 0.0 {
unsafe {
if kclvm_value_Float_0_obj == 0 {
kclvm_value_Float_0_obj = new_mut_ptr(ctx, ValueRef::float(0.0)) as usize;
}
return kclvm_value_Float_0_obj as *mut kclvm_value_ref_t;
}
}
new_mut_ptr(ctx, ValueRef::float(v))
}

Expand Down Expand Up @@ -708,12 +686,6 @@ pub unsafe extern "C" fn kclvm_value_delete(p: *mut kclvm_value_ref_t) {
if p as usize == kclvm_value_Bool_false_obj {
return;
}
if p as usize == kclvm_value_Int_0_obj {
return;
}
if p as usize == kclvm_value_Float_0_obj {
return;
}
}
let val = ptr_as_ref(p);
val.from_raw();
Expand Down
Loading