feat: less gc (WIP)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use std::marker::PhantomData;
|
||||
use std::rc::Rc;
|
||||
use std::ops::Deref;
|
||||
|
||||
use gc_arena::{Collect, Gc, Mutation};
|
||||
@@ -63,7 +64,7 @@ impl<'gc> From<JITValue> for Value<'gc> {
|
||||
match value.tag {
|
||||
Int => Value::Int(unsafe { value.data.int }),
|
||||
Null => Value::Null,
|
||||
Function => Value::Func(unsafe { Gc::from_ptr(value.data.ptr as *const _) }),
|
||||
Function => Value::Func(unsafe { Rc::from_raw(value.data.ptr as *const _) }),
|
||||
Thunk => Value::Thunk(self::Thunk {
|
||||
thunk: unsafe { Gc::from_ptr(value.data.ptr as *const _) },
|
||||
}),
|
||||
@@ -72,19 +73,21 @@ impl<'gc> From<JITValue> for Value<'gc> {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&Value<'_>> for JITValue {
|
||||
fn from(value: &Value) -> Self {
|
||||
impl From<Value<'_>> for JITValue {
|
||||
fn from(value: Value) -> Self {
|
||||
match value {
|
||||
&Value::Int(int) => JITValue {
|
||||
Value::Int(int) => JITValue {
|
||||
tag: ValueTag::Int,
|
||||
data: JITValueData { int },
|
||||
},
|
||||
&Value::Func(func) => JITValue {
|
||||
tag: ValueTag::Function,
|
||||
data: JITValueData {
|
||||
ptr: Gc::as_ptr(func) as *const _,
|
||||
},
|
||||
},
|
||||
Value::Func(func) => {
|
||||
JITValue {
|
||||
tag: ValueTag::Function,
|
||||
data: JITValueData {
|
||||
ptr: Rc::into_raw(func) as *const _,
|
||||
},
|
||||
}
|
||||
}
|
||||
Value::Thunk(thunk) => JITValue {
|
||||
tag: ValueTag::Thunk,
|
||||
data: JITValueData {
|
||||
|
||||
Reference in New Issue
Block a user