Commit b814438f authored by qinsoon's avatar qinsoon

[wip] primordial thread launch

parent 2d522d20
[package]
name = "mu"
version = "0.0.1"
authors = [ "Your name <you@example.com>" ]
build = "build.rs"
[lib]
crate-type = ["cdylib", "rlib"]
[build-dependencies.gcc]
git = "https://github.com/alexcrichton/gcc-rs"
......@@ -18,7 +20,6 @@ hprof = "0.1.3"
memmap = "0.4.0"
memsec = "0.1.9"
rustc-serialize = "*"
time = "0.1.34"
aligned_alloc = "0.1.2"
crossbeam = "0.2.8"
\ No newline at end of file
......@@ -1133,6 +1133,7 @@ pub fn emit_context(vm: &VM) {
Ok(file) => file
};
// bss
{
// put globals into bss section
file.write_fmt(format_args!("\t.bss\n")).unwrap();
......@@ -1159,12 +1160,17 @@ pub fn emit_context(vm: &VM) {
}
}
// data
// serialize vm
{
let serialize_vm = json::encode(&vm).unwrap();
file.write("\t.data\n".as_bytes()).unwrap();
file.write_fmt(format_args!("vm: .asciiz \"{}\"", serialize_vm)).unwrap();
let vm_symbol = symbol("vm".to_string());
file.write_fmt(format_args!("{}\n", directive_globl(vm_symbol.clone()))).unwrap();
let escape_serialize_vm = serialize_vm.replace("\"", "\\\"");
file.write_fmt(format_args!("\t{}: .asciz \"{}\"", vm_symbol, escape_serialize_vm)).unwrap();
file.write("\n".as_bytes()).unwrap();
}
......
......@@ -500,6 +500,9 @@ impl <'a> VM {
#[no_mangle]
pub extern fn mu_main(serialized_vm : *const c_char, len: usize) {
use rustc_serialize::json;
println!("mu_main() started...");
let str_vm = unsafe {String::from_raw_parts(serialized_vm as *mut u8, len, len)};
let vm : Arc<VM> = Arc::new(json::decode(&str_vm).unwrap());
......
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