GitLab will be upgraded to the 12.10.14-ce.0 on 28 Sept 2020 at 2.00pm (AEDT) to 2.30pm (AEDT). During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to us at N110 (b) CSIT building.

Commit 188e7acc authored by Isaac Oscar Gariano's avatar Isaac Oscar Gariano

Fixed threadlocal register implementation

parent 10e9b6f1
...@@ -217,7 +217,7 @@ fn compute_immediate_dominators(dominators: &LinkedMultiMap<MuName, MuName>) ...@@ -217,7 +217,7 @@ fn compute_immediate_dominators(dominators: &LinkedMultiMap<MuName, MuName>)
} }
} }
assert_eq!(immediate_doms.len(), dominators.len() - 1); // entry block does not have idom //assert_eq!(immediate_doms.len(), dominators.len() - 1); // entry block does not have idom
immediate_doms immediate_doms
} }
......
...@@ -123,15 +123,11 @@ fn emit_muir_dot_inner(file: &mut File, f_name: MuName, f_content: &FunctionCont ...@@ -123,15 +123,11 @@ fn emit_muir_dot_inner(file: &mut File, f_name: MuName, f_content: &FunctionCont
// all the instructions // all the instructions
for inst in block_content.body.iter() { for inst in block_content.body.iter() {
<<<<<<< HEAD
write!( write!(
file, file,
" {}\\l", " {}\\l",
escape_string(format!("{}", inst.as_inst())) escape_string(format!("{}", inst.as_inst()))
).unwrap(); ).unwrap();
=======
write!(file, " {}\\l", escape_string(format!("{}", inst.as_inst_ref()))).unwrap();
>>>>>>> malloc
} }
// "]; // "];
......
...@@ -39,45 +39,49 @@ ...@@ -39,45 +39,49 @@
FP .req X29 FP .req X29
LR .req X30 LR .req X30
.macro push_pair src1 src2 stack=SP .macro push_pair src1 src2 i stack=SP
STP \src2 , \src1, [ \stack ,#-16]! STP \src2 , \src1, [ \stack, #-16*(\i+1)]
.endm .endm
.macro pop_pair dest1 dest2 stack=SP .macro pop_pair dest1 dest2 i stack=SP
LDP \dest1 , \dest2 , [ \stack ],#16 LDP \dest1 , \dest2 , [ \stack, #16*\i]
.endm .endm
.macro enter_frame .macro enter_frame
push_pair LR, FP STP FP, LR, [SP, #-16]!
MOV FP, SP MOV FP, SP
.endm .endm
.macro exit_frame .macro exit_frame
pop_pair FP, LR LDP FP, LR, [SP], #16
.endm .endm
.macro push_callee_saved stack=SP .macro push_callee_saved stack=SP
push_pair X19, X20, \stack push_pair X19, X20, 0, \stack
push_pair X21, X22, \stack push_pair X21, X22, 1, \stack
push_pair X23, X24, \stack push_pair X23, X24, 2, \stack
push_pair X25, X26, \stack push_pair X25, X26, 3, \stack
push_pair X27, X28, \stack push_pair X27, X28, 4, \stack
push_pair D8, D9, \stack push_pair D8, D9, 5, \stack
push_pair D10, D11, \stack push_pair D10, D11, 6, \stack
push_pair D12, D13, \stack push_pair D12, D13, 7, \stack
push_pair D14, D15, \stack push_pair D14, D15, 8, \stack
SUB \stack, \stack, #16*9
.endm .endm
.macro pop_callee_saved stack=SP .macro pop_callee_saved stack=SP
pop_pair D15, D14, \stack pop_pair D15, D14, 0, \stack
pop_pair D13, D12, \stack pop_pair D13, D12, 1, \stack
pop_pair D11, D10, \stack pop_pair D11, D10, 2, \stack
pop_pair D9, D8, \stack pop_pair D9, D8, 3, \stack
pop_pair X28, X27, 4, \stack
pop_pair X26, X25, 5, \stack
pop_pair X24, X23, 6, \stack
pop_pair X22, X21, 7, \stack
pop_pair X20, X19, 8, \stack
pop_pair X28, X27, \stack ADD \stack, \stack, #16*9
pop_pair X26, X25, \stack
pop_pair X24, X23, \stack
pop_pair X22, X21, \stack
pop_pair X20, X19, \stack
.endm .endm
\ No newline at end of file
...@@ -133,7 +133,7 @@ pub extern "C" fn throw_exception_internal(exception_obj: Address, frame_cursor: ...@@ -133,7 +133,7 @@ pub extern "C" fn throw_exception_internal(exception_obj: Address, frame_cursor:
} }
// The above loop will only exit when a catch block is found, so restore to it // The above loop will only exit when a catch block is found, so restore to it
unsafe { unsafe {
thread::exception_restore(catch_address, frame_cursor.to_ptr(), sp); thread::exception_restore(catch_address, frame_cursor.to_ptr(), sp, thread::muentry_get_thread_local());
} }
} }
......
...@@ -27,22 +27,36 @@ end_func get_current_frame_bp ...@@ -27,22 +27,36 @@ end_func get_current_frame_bp
# X0 # X0
begin_func muentry_throw_exception begin_func muentry_throw_exception
# save all callee-saved registers and pass tham as argument 2 # save all callee-saved registers and pass tham as argument 2
push_pair LR, FP enter_frame
MOV FP, SP
push_callee_saved push_callee_saved
MOV X1, FP // X1 is the frame pointer MOV X1, FP // X1 is the frame pointer
BL throw_exception_internal BL throw_exception_internal
# won't return # won't return
end_func muentry_throw_exception end_func muentry_throw_exception
# _exception_restore(dest: Address, frame_cursor: *const Word, sp: Address) -> !
# X0 X1 X2 # exception_restore(dest: Address, frame_cursor: *const Word, sp: Address, mu_tls: Address) -> !
# X0 X1 X2 X3
begin_func exception_restore begin_func exception_restore
SUB X1, X1, #144 // Skip to the bottom of the frame cursor // Load mu tls value
// load each callee saved register relative to the stack pointer MOV X28, X3
pop_callee_saved X1
pop_pair FP, LR, X1 SUB X1, X1, #144 // Skip to the bottom of the frame cursor
MOV SP, X2 // load each callee saved register relative to the stack pointer
BR X0 pop_pair D15, D14, 0, X1
pop_pair D13, D12, 1, X1
pop_pair D11, D10, 2, X1
pop_pair D9, D8, 3, X1
pop_pair XZR, X27, 4, X1 // Don't restore X28
pop_pair X26, X25, 5, X1
pop_pair X24, X23, 6, X1
pop_pair X22, X21, 7, X1
pop_pair X20, X19, 8, X1
ADD X1, X1, #144 // Skip to the top of the frame cursor
LDP FP, LR, [X1], #16
MOV SP, X2
BR X0
end_func exception_restore end_func exception_restore
# starts a muthread that passes values to the target # starts a muthread that passes values to the target
...@@ -90,10 +104,6 @@ begin_func muthread_start_exceptional ...@@ -90,10 +104,6 @@ begin_func muthread_start_exceptional
MOV X11, SP MOV X11, SP
STR X11, [X2] STR X11, [X2]
// Update the MU_TL register
BL muentry_get_thread_local
MOV X28, X0
// Swap to the new stack // Swap to the new stack
MOV SP, X1 MOV SP, X1
SUB SP, SP, #144 // Alocate space for callee saved registers SUB SP, SP, #144 // Alocate space for callee saved registers
......
...@@ -398,7 +398,7 @@ extern "C" { ...@@ -398,7 +398,7 @@ extern "C" {
/// dest: code address to execute (catch block) /// dest: code address to execute (catch block)
/// callee_saved: a sequence of value that will be restored in order /// callee_saved: a sequence of value that will be restored in order
/// sp: stack pointer for the new execution /// sp: stack pointer for the new execution
pub fn exception_restore(dest: Address, callee_saved: *const Word, sp: Address) -> !; pub fn exception_restore(dest: Address, callee_saved: *const Word, sp: Address, mu_tls: Address) -> !;
} }
#[cfg(not(feature = "sel4-rumprun-target-side"))] #[cfg(not(feature = "sel4-rumprun-target-side"))]
...@@ -429,7 +429,7 @@ extern "C" { ...@@ -429,7 +429,7 @@ extern "C" {
#[allow(dead_code)] #[allow(dead_code)]
fn muentry_swap_back_to_native_stack(sp_loc: Address); fn muentry_swap_back_to_native_stack(sp_loc: Address);
pub fn get_current_frame_bp() -> Address; pub fn get_current_frame_bp() -> Address;
pub fn exception_restore(dest: Address, callee_saved: *const Word, sp: Address) -> !; pub fn exception_restore(dest: Address, callee_saved: *const Word, sp: Address, mu_tls: Address) -> !;
} }
#[cfg(feature = "sel4-rumprun-target-side")] #[cfg(feature = "sel4-rumprun-target-side")]
......
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