...
 
Commits (2)
......@@ -83,6 +83,10 @@ lazy_static! {
MuType::new(new_internal_id(), MuType_::ThreadRef)
);
pub static ref IRBUILDERREF_TYPE : P<MuType> = P(
MuType::new(new_internal_id(), MuType_::ThreadRef)
);
pub static ref INTERNAL_TYPES : Vec<P<MuType>> = vec![
ADDRESS_TYPE.clone(),
UINT1_TYPE.clone(),
......@@ -204,7 +208,8 @@ impl MuType {
pub fn is_opaque_reference(&self) -> bool {
match self.v {
MuType_::FuncRef(_) | MuType_::StackRef | MuType_::ThreadRef => true,
MuType_::FuncRef(_) | MuType_::StackRef | MuType_::ThreadRef |
MuType_::IRBuilderRef => true,
_ => false
}
}
......@@ -247,6 +252,7 @@ impl MuType {
MuType_::FuncRef(_) |
MuType_::UFuncPtr(_) |
MuType_::ThreadRef |
MuType_::IRBuilderRef |
MuType_::StackRef |
MuType_::Tagref64 |
MuType_::UPtr(_) => true,
......@@ -313,7 +319,9 @@ impl MuType {
MuType_::IRef(_) => true,
MuType_::WeakRef(_) => true,
MuType_::Array(ref elem_ty, _) | MuType_::Vector(ref elem_ty, _) => elem_ty.is_traced(),
MuType_::ThreadRef | MuType_::StackRef | MuType_::Tagref64 => true,
MuType_::IRBuilderRef | MuType_::ThreadRef | MuType_::StackRef | MuType_::Tagref64 => {
true
}
MuType_::Hybrid(ref tag) => {
let map = HYBRID_TAG_MAP.read().unwrap();
let hybrid_ty = map.get(tag).unwrap();
......@@ -444,6 +452,7 @@ impl MuType {
WeakRef(_) |
UPtr(_) |
ThreadRef |
IRBuilderRef |
StackRef |
Tagref64 |
FuncRef(_) |
......@@ -492,7 +501,8 @@ pub enum MuType_ {
ThreadRef,
/// stackref
StackRef,
/// irbuilderref
IRBuilderRef,
/// tagref64: hold a double or an int or an ref<void>
Tagref64,
......@@ -514,8 +524,8 @@ impl MuType_ {
}
}
rodal_enum!(MuType_{(Int: size), Float, Double, (Ref: ty), (IRef: ty), (WeakRef: ty), (UPtr: ty),
(Struct: tag), (Array: ty, size), (Hybrid: tag), Void, ThreadRef, StackRef, Tagref64,
(Vector: ty, size), (FuncRef: ty), (UFuncPtr: ty)});
(Struct: tag), (Array: ty, size), (Hybrid: tag), Void, IRBuilderRef, ThreadRef, StackRef,
Tagref64, (Vector: ty, size), (FuncRef: ty), (UFuncPtr: ty)});
impl fmt::Display for MuType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
......@@ -535,6 +545,7 @@ impl fmt::Display for MuType_ {
&MuType_::UPtr(ref ty) => write!(f, "uptr<{}>", ty),
&MuType_::Array(ref ty, size) => write!(f, "array<{} {}>", ty, size),
&MuType_::Void => write!(f, "void"),
&MuType_::IRBuilderRef => write!(f, "irbuilderref"),
&MuType_::ThreadRef => write!(f, "threadref"),
&MuType_::StackRef => write!(f, "stackref"),
&MuType_::Tagref64 => write!(f, "tagref64"),
......
......@@ -291,6 +291,7 @@ impl BackendType {
MuType_::UFuncPtr(_) |
MuType_::FuncRef(_) |
MuType_::ThreadRef |
MuType_::IRBuilderRef |
MuType_::StackRef => BackendType {
size: 8,
alignment: 8,
......
This diff is collapsed.
......@@ -493,21 +493,7 @@ impl MuCtx {
pub fn new_ir_builder(&mut self) -> *mut CMuIRBuilder {
info!("Creating MuIRBuilder...");
let b: Box<MuIRBuilder> = MuIRBuilder::new(self.mvm);
let b_ptr = Box::into_raw(b);
debug!("The MuIRBuilder address: {:?}", b_ptr);
let cb = make_new_MuIRBuilder(b_ptr as *mut c_void);
debug!("The C-visible CMuIRBuilder struct address: {:?}", cb);
unsafe {
(*b_ptr).c_struct = cb;
}
cb
MuIRBuilder::new_c(self.mvm)
}
pub fn make_boot_image(
......
This diff is collapsed.
......@@ -51,6 +51,13 @@ impl MuVM {
}
}
pub fn from_vm(vm: Arc<VM>) -> MuVM {
MuVM {
vm: vm,
name_cache: Mutex::new(HashMap::new())
}
}
pub fn new_context(&self) -> *mut CMuCtx {
info!("Creating MuCtx...");
......@@ -117,6 +124,7 @@ impl MuVM {
pub fn current_thread_as_mu_thread(&self, threadlocal: CMuCPtr) {
unsafe {
//MuThread::current_thread_as_mu_thread
thread::MuThread::current_thread_as_mu_thread(
transmute::<CMuCPtr, Address>(threadlocal),
self.vm.clone()
......@@ -172,6 +180,27 @@ pub extern "C" fn mu_fastimpl_new_with_opts(opts: *const c_char) -> *mut CMuVM {
c_mvm
}
#[no_mangle]
pub extern "C" fn mu_fastimpl_get_running_vm() -> *mut CMuVM {
info!("Getting the running Mu micro VM fast implementation instance...");
let mvm = Box::new(MuVM::from_vm(thread::MuThread::current().vm.clone()));
let mvm_ptr = Box::into_raw(mvm);
debug!("The MuVM instance address: {:?}", mvm_ptr);
let c_mvm = make_new_MuVM(mvm_ptr as *mut c_void);
debug!("The C-visible CMuVM struct address: {:?}", c_mvm);
c_mvm
}
#[no_mangle]
pub extern "C" fn muentry_new_ir_builder () -> *mut CMuIRBuilder {
let mvm = mu_fastimpl_get_running_vm();
info!("Creating MuIRBuilder...");
MuIRBuilder::new_c(super::super::api_bridge::from_MuVM_ptr(mvm))
}
use vm::built_info;
#[no_mangle]
......
......@@ -41,10 +41,12 @@ pub use self::api_impl::mu_fastimpl_new;
/// creates a Zebu instance with specified options
/// See vm_options.rs for supported options.
pub use self::api_impl::mu_fastimpl_new_with_opts;
pub use self::api_impl::mu_fastimpl_get_running_vm;
pub use self::api_impl::muentry_new_ir_builder;
/// returns a version string for current Zebu build
pub use self::api_impl::mu_get_version;
pub use self::api_bridge::*;
mod deps {
pub use ast::ir::WPID;
pub use ast::ir::MuID;
......
......@@ -22,6 +22,7 @@ extern "C" {
#endif
MuVM *mu_fastimpl_new();
MuVM *mu_fastimpl_get_running_vm();
MuVM *mu_fastimpl_new_with_opts(const char*);
const char* mu_get_version();
......
......@@ -29,4 +29,4 @@ pub mod built_info;
pub mod api;
/// handle type for client. This handle type is opaque to the client
pub mod handle;
pub mod handle;
\ No newline at end of file