Commit 6d46f0fb authored by qinsoon's avatar qinsoon

[wip] impl thread local

parent 5b031514
......@@ -3,14 +3,19 @@
name = "mu"
version = "0.0.1"
authors = [ "Your name <you@example.com>" ]
build = "build.rs"
[dependencies.immix_rust]
path = "gc"
[build-dependencies.gcc]
git = "https://github.com/alexcrichton/gcc-rs"
[dependencies]
lazy_static = "0.1.15"
log = "0.3.5"
simple_logger = "0.4.0"
nalgebra = "0.8.2"
linked-hash-map = "0.0.10"
hprof = "0.1.3"
\ No newline at end of file
hprof = "0.1.3"
memmap = "0.4.0"
\ No newline at end of file
extern crate gcc;
#[cfg(target_os = "macos")]
#[cfg(target_arch = "x86_64")]
fn main() {
gcc::compile_library("libruntime.a", &["src/runtime/runtime_x64_macos.c"]);
}
\ No newline at end of file
......@@ -8,4 +8,5 @@ extern crate immix_rust as gc;
pub mod utils;
pub mod ast;
pub mod vm;
pub mod compiler;
pub mod compiler;
pub mod runtime;
pub mod thread;
\ No newline at end of file
#include <stdint.h>
#include <stdlib.h>
__thread void* mu_tls;
void* init_thread_local(void* local) {
return NULL;
}
void* aligned_mem(uint64_t size, uint64_t align) {
}
extern crate memmap;
use gc::Mutator;
use ast::ir::*;
use utils::ByteSize;
pub const STACK_SIZE : ByteSize = (4 << 20); // 4mb
#[cfg(target_arch = "x86_64")]
pub const PAGE_SIZE : ByteSize = (4 << 10); // 4kb
pub struct MuStack {
hdr: MuEntityHeader,
func_id: MuID,
size: ByteSize,
// lo addr hi addr
// | overflow guard page | actual stack ..................... | underflow guard page|
// | | | |
// overflowGuard lowerBound upperBound
// underflowGuard
overflow_guard : Address,
lower_bound : Address,
upper_bound : Address,
underflow_guard: Address,
exception_obj : Option<Address>,
#[allow(dead_code)]
mmap : memmap::Mmap
}
impl MuStack {
pub fn new(id: MuID, func_id: MuID) -> MuStack {
let total_size = PAGE_SIZE * 2 + STACK_SIZE;
let anon_mmap = match memmap::Mmap::anonymous(total_size, memmap::Protection::ReadWrite) {
Ok(m) => m,
Err(_) => panic!("failed to mmap for a stack"),
};
let overflow_guard = Address::from_ptr(anon_mmap.ptr());
unimplemented!()
}
}
pub struct MuThread {
hdr: MuEntityHeader,
allocator: Box<Mutator>,
user_tls: Address
}
\ No newline at end of file
#![allow(dead_code)]
extern crate immix_rust as gc;
pub use gc::common::Address;
pub use gc::common::ObjectReference;
pub type ByteSize = usize;
mod linked_hashset;
......
mod context;
mod vm;
mod vm_options;
mod machine_code;
pub mod api;
pub mod bundle;
pub use vm::context::VM;
pub use vm::vm::VM;
pub use vm::vm_options::VMOptions;
pub use vm::machine_code::CompiledFunction;
pub use vm::machine_code::MachineCode;
......@@ -9,6 +9,8 @@ use compiler::backend;
use compiler::backend::BackendTypeInfo;
use vm::machine_code::CompiledFunction;
use vm::vm_options::VMOptions;
use runtime::thread::MuStack;
use runtime::thread::MuThread;
use std::sync::RwLock;
use std::cell::RefCell;
......@@ -231,4 +233,8 @@ impl <'a> VM {
pub fn func_sigs(&self) -> &RwLock<HashMap<MuID, P<MuFuncSig>>> {
&self.func_sigs
}
pub fn new_stack(&self, func_id: MuID) -> Box<MuStack> {
Box::new(MuStack::new(self.next_id(), func_id))
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment