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 681ae5aa authored by qinsoon's avatar qinsoon
Browse files

[wip] going to implement catch part

parent 252880c9
......@@ -765,6 +765,21 @@ impl CodeGenerator for ASMCodeGen {
}
}
fn emit_nop(&mut self, bytes: usize) {
trace!("emit: nop ({} bytes)", bytes);
let asm = String::from("nop");
self.add_asm_inst(
asm,
vec![],
vec![],
vec![],
vec![],
false
);
}
fn emit_cmp_r64_r64(&mut self, op1: &P<Value>, op2: &P<Value>) {
trace!("emit: cmp {} {}", op1, op2);
......@@ -1155,13 +1170,13 @@ impl CodeGenerator for ASMCodeGen {
fn emit_call_near_rel32(&mut self, callsite: String, func: MuName) -> ValueLocation {
trace!("emit: call {}", func);
let callsite_symbol = symbol(callsite.clone());
self.add_asm_symbolic(directive_globl(callsite_symbol.clone()));
self.add_asm_symbolic(format!("{}:", callsite_symbol.clone()));
let asm = format!("call {}", symbol(func));
self.add_asm_call(asm);
let callsite_symbol = symbol(callsite.clone());
self.add_asm_symbolic(directive_globl(callsite_symbol.clone()));
self.add_asm_symbolic(format!("{}:", callsite_symbol.clone()));
ValueLocation::Relocatable(RegGroup::GPR, callsite)
}
......
......@@ -16,6 +16,8 @@ pub trait CodeGenerator {
fn set_block_liveout(&mut self, block_name: MuName, live_out: &Vec<P<Value>>);
fn end_block(&mut self, block_name: MuName);
fn emit_nop(&mut self, bytes: usize);
fn emit_cmp_r64_r64(&mut self, op1: &P<Value>, op2: &P<Value>);
fn emit_cmp_r64_imm32(&mut self, op1: &P<Value>, op2: i32);
fn emit_cmp_r64_mem64(&mut self, op1: &P<Value>, op2: &P<Value>);
......
......@@ -19,7 +19,7 @@ use vm::VM;
use rustc_serialize::{Encodable, Encoder, Decodable, Decoder};
#[derive(RustcEncodable, RustcDecodable)]
#[derive(RustcEncodable, RustcDecodable, Clone)]
pub struct Frame {
func_ver_id: MuID,
cur_offset: isize, // offset to rbp
......@@ -87,7 +87,7 @@ impl Frame {
}
}
#[derive(RustcEncodable, RustcDecodable)]
#[derive(RustcEncodable, RustcDecodable, Clone)]
pub struct FrameSlot {
pub offset: isize,
pub value: P<Value>
......
......@@ -56,12 +56,17 @@ pub extern fn muentry_throw_exception(exception_obj: Address) {
// get return address (the slot above RBP slot)
// let return_addr = unsafe {rbp.plus(POINTER_SIZE).load::<Address>()};
let rwlock_cf = match cf_lock.get(&cursor.func_ver_id) {
Some(ret) => ret,
None => panic!("cannot find compiled func with func_id {}, possibly didnt find the right frame for return address", cursor.func_id)
// release the locks, and keep a clone of the frame
// because we may improperly leave this function
// FIXME: consider using Rust () -> ! to tell Rust compiler that we may not finish the func
let frame = {
let rwlock_cf = match cf_lock.get(&cursor.func_ver_id) {
Some(ret) => ret,
None => panic!("cannot find compiled func with func_id {}, possibly didnt find the right frame for return address", cursor.func_id)
};
let rwlock_cf = rwlock_cf.read().unwrap();
rwlock_cf.frame.clone()
};
let rwlock_cf = rwlock_cf.read().unwrap();
let ref frame = rwlock_cf.frame;
trace!("frame info: {}", frame);
// update callee saved register location
......@@ -81,9 +86,10 @@ pub extern fn muentry_throw_exception(exception_obj: Address) {
let exception_callsites = frame.get_exception_callsites();
for &(ref possible_callsite, ref dest) in exception_callsites.iter() {
let possible_callsite_addr = possible_callsite.to_address();
trace!("..check {} at 0x{:x}", possible_callsite, possible_callsite_addr);
if callsite == possible_callsite_addr {
trace!("found catch block at {}", dest);
trace!("found catch block at {}", dest);
// found an exception block
let dest_addr = dest.to_address();
......@@ -160,11 +166,12 @@ fn find_func_for_address (cf: &RwLockReadGuard<HashMap<MuID, RwLock<CompiledFunc
let end = func.end.to_address();
trace!("CompiledFunction: func_id={}, fv_id={}, start=0x{:x}, end=0x{:x}", func.func_id, func.func_ver_id, start, end);
if pc_addr >= start && pc_addr <= end {
// pc won't be the start of a function, but could be the end
if pc_addr > start && pc_addr <= end {
trace!("Found CompiledFunction: func_id={}, fv_id={}", func.func_id, func.func_ver_id);
return (func.func_id, func.func_ver_id);
}
}
panic!("cannot find compiled function for pc 0x{:x}");
panic!("cannot find compiled function for pc 0x{:x}", pc_addr);
}
\ No newline at end of file
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