WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

Commit bf5b86a9 authored by qinsoon's avatar qinsoon
Browse files

several fixes

parent 464b63ba
......@@ -79,6 +79,28 @@ impl MuType {
}
}
pub fn is_struct(&self) -> bool {
match self.v {
MuType_::Struct(_) => true,
_ => false
}
}
pub fn is_hybrid(&self) -> bool {
match self.v {
MuType_::Hybrid(_) => true,
_ => false
}
}
pub fn get_struct_hybrid_tag(&self) -> Option<MuName> {
match self.v {
MuType_::Hybrid(ref name)
| MuType_::Struct(ref name) => Some(name.clone()),
_ => None
}
}
pub fn is_ref(&self) -> bool {
match self.v {
MuType_::Ref(_) => true,
......
......@@ -10,6 +10,7 @@ mod asm_backend;
pub use compiler::backend::x86_64::asm_backend::ASMCodeGen;
pub use compiler::backend::x86_64::asm_backend::emit_code;
pub use compiler::backend::x86_64::asm_backend::emit_context;
pub use compiler::backend::x86_64::asm_backend::emit_context_with_reloc;
#[cfg(feature = "aot")]
pub use compiler::backend::x86_64::asm_backend::spill_rewrite;
......
......@@ -51,6 +51,8 @@ pub use compiler::backend::x86_64::emit_code;
#[cfg(target_arch = "x86_64")]
pub use compiler::backend::x86_64::emit_context;
#[cfg(target_arch = "x86_64")]
pub use compiler::backend::x86_64::emit_context_with_reloc;
#[cfg(target_arch = "x86_64")]
pub use compiler::backend::x86_64::spill_rewrite;
// ARM
......
......@@ -25,7 +25,10 @@ impl <'vm> Compiler<'vm> {
}
pub fn compile(&self, func: &mut MuFunctionVersion) {
trace!("{:?}", func);
info!("");
info!("Start compiling {}", func);
info!("");
debug!("{:?}", func);
// FIXME: should use function name here (however hprof::enter only accept &'static str)
let _p = hprof::enter("Function Compilation");
......
......@@ -129,7 +129,7 @@ impl CompilerPass for TreeGen {
debug!("check depth tree for {}", func);
for entry in func.content.as_ref().unwrap().blocks.iter() {
debug!("block {}", entry.0);
debug!("block {}", entry.1.name().unwrap());
for inst in entry.1.content.as_ref().unwrap().body.iter() {
debug!("{}", inst);
......
......@@ -170,14 +170,13 @@ impl MuStack {
debug!("0x{:x} | UPPER_BOUND", self.upper_bound);
while cursor >= self.lower_bound {
let val = unsafe{cursor.load::<Word>()};
print!("0x{:x} | 0x{:x} ({})", cursor, val, val);
if cursor == self.sp {
print!(" <- SP");
debug!("0x{:x} | 0x{:x} ({}) <- SP", cursor, val, val);
} else {
debug!("0x{:x} | 0x{:x} ({})", cursor, val, val);
}
debug!("");
cursor = cursor.sub(WORD_SIZE);
count += 1;
......
......@@ -99,7 +99,7 @@ impl MuIRBuilder {
pub fn gen_sym(&mut self, name: Option<String>) -> MuID {
let my_id = self.next_id();
debug!("gen_sym({:?}) -> {}", name, my_id);
trace!("gen_sym({:?}) -> {}", name, my_id);
match name {
None => {},
......
......@@ -135,6 +135,16 @@ impl APIHandleValue {
}
}
pub fn as_address(&self) -> Address {
match self {
&APIHandleValue::IRef (_, addr)
| &APIHandleValue::Ref (_, addr)
| &APIHandleValue::UPtr(_, addr)
| &APIHandleValue::UFP (_, addr) => addr,
_ => panic!("expected iref/ref/uptr/ufp which contains a pointer, found {}", self)
}
}
pub fn as_int(&self) -> u64 {
match self {
&APIHandleValue::Int(val, _) => val,
......
......@@ -693,8 +693,20 @@ impl <'a> VM {
fn declare_type_internal(&self, types: &mut RwLockWriteGuard<HashMap<MuID, P<MuType>>>, id: MuID, ty: P<MuType>) {
debug_assert!(!types.contains_key(&id));
info!("declare type #{} = {}", id, ty);
types.insert(id, ty.clone());
info!("declare type #{} = {}", id, ty);
if ty.is_struct() {
let tag = ty.get_struct_hybrid_tag().unwrap();
let struct_map_guard = STRUCT_TAG_MAP.read().unwrap();
let struct_inner = struct_map_guard.get(&tag).unwrap();
info!(" {}", struct_inner);
} else if ty.is_hybrid() {
let tag = ty.get_struct_hybrid_tag().unwrap();
let hybrid_map_guard = HYBRID_TAG_MAP.read().unwrap();
let hybrid_inner = hybrid_map_guard.get(&tag).unwrap();
info!(" {}", hybrid_inner);
}
}
pub fn get_type(&self, id: MuID) -> P<MuType> {
......@@ -1016,8 +1028,29 @@ impl <'a> VM {
// make primordial thread in vm
self.make_primordial_thread(func_id, false, vec![]); // do not pass const args, use argc/argv
// deal with relocation symbols
assert_eq!(sym_fields.len(), sym_strings.len());
let symbols = {
let mut ret = hashmap!{};
for i in 0..sym_fields.len() {
let addr = sym_fields[i].v.as_address();
ret.insert(addr, sym_strings[i].clone());
}
ret
};
assert_eq!(reloc_fields.len(), reloc_strings.len());
let fields = {
let mut ret = hashmap!{};
for i in 0..reloc_fields.len() {
let addr = reloc_fields[i].v.as_address();
ret.insert(addr, reloc_strings[i].clone());
}
ret
};
// emit context (serialized vm, etc)
backend::emit_context(self);
backend::emit_context_with_reloc(self, symbols, fields);
// link
self.link_boot_image(whitelist_funcs, output_file);
......
......@@ -1020,6 +1020,7 @@ def test_make_boot_image_simple():
assert res.returncode == 0, res.err
assert res.out == '%s\nabc\n123\n' % exe
@pytest.mark.xfail(reason = "doesnt work for now")
@may_spawn_proc
def test_rpytarget_print_argv():
from rpython.translator.interactive import Translation
......@@ -1045,6 +1046,29 @@ def test_rpytarget_print_argv():
assert res.returncode == 0, res.err
assert res.out == '[%s, abc, 123]\n' % exe
@pytest.mark.xfail(reason = "probably need to align frame size to 16 bytes")
@may_spawn_proc
def test_rpython_helloworld():
from rpython.translator.interactive import Translation
def main(argv):
print "hello world"
return 0
t = Translation(main, None, backend='mu', muimpl='fast', mucodegen='api')
t.driver.exe_name = '/tmp/test_helloworld'
t.compile_mu()
exe = py.path.local('/tmp/test_helloworld.mu')
# zebu
import os
from rpython.translator.mu import dir_mu
exe.chmod(stat.S_IRWXU)
res = platform.execute(str(exe), [], env={'DYLD_LIBRARY_PATH': os.path.join(dir_mu, 'rpyc')})
assert res.returncode == 0, res.err
assert res.out == 'hello world\n'
@pytest.mark.skipif("True")
@may_spawn_proc
def test_rpytarget_sha1sum():
......
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