feat: initial parallel impl
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use inkwell::OptimizationLevel;
|
||||
@@ -9,7 +8,7 @@ use inkwell::execution_engine::ExecutionEngine;
|
||||
use inkwell::module::Module;
|
||||
|
||||
use crate::env::VmEnv;
|
||||
use crate::ty::internal::{Value, Thunk};
|
||||
use crate::ty::internal::Value;
|
||||
|
||||
mod helpers;
|
||||
mod compile;
|
||||
@@ -51,29 +50,29 @@ pub union JITValueData {
|
||||
ptr: *const (),
|
||||
}
|
||||
|
||||
impl<'gc> From<JITValue> for Value<'gc> {
|
||||
impl From<JITValue> for Value {
|
||||
fn from(value: JITValue) -> Self {
|
||||
use ValueTag::*;
|
||||
match value.tag {
|
||||
Int => Value::Int(unsafe { value.data.int }),
|
||||
Null => Value::Null,
|
||||
Function => Value::Func(unsafe { Rc::from_raw(value.data.ptr as *const _) }),
|
||||
/* Function => Value::Func(unsafe { Rc::from_raw(value.data.ptr as *const _) }),
|
||||
Thunk => Value::Thunk(self::Thunk {
|
||||
thunk: unsafe { Rc::from_raw(value.data.ptr as *const _) },
|
||||
}),
|
||||
}), */
|
||||
_ => todo!("not implemented for {:?}", value.tag),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Value<'_>> for JITValue {
|
||||
impl From<Value> for JITValue {
|
||||
fn from(value: Value) -> Self {
|
||||
match value {
|
||||
Value::Int(int) => JITValue {
|
||||
tag: ValueTag::Int,
|
||||
data: JITValueData { int },
|
||||
},
|
||||
Value::Func(func) => JITValue {
|
||||
/* Value::Func(func) => JITValue {
|
||||
tag: ValueTag::Function,
|
||||
data: JITValueData {
|
||||
ptr: Rc::into_raw(func) as *const _,
|
||||
@@ -84,23 +83,23 @@ impl From<Value<'_>> for JITValue {
|
||||
data: JITValueData {
|
||||
ptr: Rc::into_raw(thunk.thunk) as *const _,
|
||||
},
|
||||
},
|
||||
}, */
|
||||
_ => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct JITFunc<'gc>(F<'gc>, PhantomData<&'gc mut ()>);
|
||||
type F<'gc> = unsafe extern "C" fn(*const VmEnv<'gc>) -> JITValue;
|
||||
pub struct JITFunc<'ctx>(F, PhantomData<&'ctx mut ()>);
|
||||
type F = unsafe extern "C" fn(*const VmEnv) -> JITValue;
|
||||
|
||||
impl<'gc> From<F<'gc>> for JITFunc<'gc> {
|
||||
fn from(value: F<'gc>) -> Self {
|
||||
impl From<F> for JITFunc<'_> {
|
||||
fn from(value: F) -> Self {
|
||||
Self(value, PhantomData)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'gc> Deref for JITFunc<'gc> {
|
||||
type Target = F<'gc>;
|
||||
impl Deref for JITFunc<'_> {
|
||||
type Target = F;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user