aboutsummaryrefslogtreecommitdiff
path: root/src/boot/me
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-11-16 13:51:32 -0800
committerGraydon Hoare <[email protected]>2010-11-16 13:51:32 -0800
commit26ecec4e123781c6e99e92cf42ce585e33a861ef (patch)
tree3da15ea6afe073b2b29e657749f9d53534030e4a /src/boot/me
parentFix typo in x86 backend glue that was, by luck, only crashing on OSX. (diff)
downloadrust-26ecec4e123781c6e99e92cf42ce585e33a861ef.tar.xz
rust-26ecec4e123781c6e99e92cf42ce585e33a861ef.zip
Update frame logic to be compatible with SysV x86 ABI. Improves diagnostics.
Diffstat (limited to 'src/boot/me')
-rw-r--r--src/boot/me/layout.ml28
-rw-r--r--src/boot/me/trans.ml13
2 files changed, 26 insertions, 15 deletions
diff --git a/src/boot/me/layout.ml b/src/boot/me/layout.ml
index 870e7a51..977066c0 100644
--- a/src/boot/me/layout.ml
+++ b/src/boot/me/layout.ml
@@ -26,27 +26,30 @@ let layout_visitor
* |output ptr (implicit arg) |
* +----------------------------+ <-- fp + abi_frame_base_sz
* |return pc |
- * |callee-save registers |
+ * |old fp | <-- fp
+ * +----------------------------+
+ * |other callee-save registers |
* |... |
- * +----------------------------+ <-- fp
+ * +----------------------------+ <-- fp - callee_saves
* |crate ptr |
* |crate-rel frame info disp |
- * +----------------------------+ <-- fp - abi_frame_info_sz
- * |spills determined in ra |
+ * +----------------------------+ <-- fp - (callee_saves
+ * |spills determined in ra | + abi_frame_info_sz)
* |... |
* |... |
- * +----------------------------+ <-- fp - (abi_frame_info_sz
- * |... | + spillsz)
- * |frame-allocated stuff |
+ * +----------------------------+ <-- fp - (callee_saves
+ * |... | + abi_frame_info_sz
+ * |frame-allocated stuff | + spillsz)
* |determined in resolve |
* |laid out in layout |
* |... |
* |... |
- * +----------------------------+ <-- fp - framesz
+ * +----------------------------+ <-- fp - (callee_saves + framesz)
* |call space | == sp + callsz
* |... |
* |... |
- * +----------------------------+ <-- fp - (framesz + callsz) == sp
+ * +----------------------------+ <-- fp - (callee_saves
+ * + framesz + callsz) == sp
*
* - Slot offsets fall into three classes:
*
@@ -246,11 +249,13 @@ let layout_visitor
let (frame_id, frame_blocks) = Stack.top frame_stack in
let frame_spill = Hashtbl.find cx.ctxt_spill_fixups frame_id in
let sz =
+ (* NB: the "frame size" does not include the callee-saves. *)
add_sz
(add_sz
(rty_sz (frame_rty frame_blocks))
(SIZE_fixup_mem_sz frame_spill))
- (SIZE_fixed cx.ctxt_abi.Abi.abi_frame_info_sz)
+ (SIZE_fixed
+ cx.ctxt_abi.Abi.abi_frame_info_sz)
in
let curr = Hashtbl.find cx.ctxt_frame_sizes frame_id in
let sz = max_sz curr sz in
@@ -354,8 +359,9 @@ let layout_visitor
let (frame_id, frame_blocks) = Stack.top frame_stack in
let frame_spill = Hashtbl.find cx.ctxt_spill_fixups frame_id in
let spill_sz = SIZE_fixup_mem_sz frame_spill in
+ let callee_saves_sz = SIZE_fixed cx.ctxt_abi.Abi.abi_callee_saves_sz in
let info_sz = SIZE_fixed cx.ctxt_abi.Abi.abi_frame_info_sz in
- let locals_off = add_sz spill_sz info_sz in
+ let locals_off = add_sz spill_sz (add_sz info_sz callee_saves_sz) in
let off =
if Stack.is_empty frame_blocks
then locals_off
diff --git a/src/boot/me/trans.ml b/src/boot/me/trans.ml
index 686e7417..1fdd40ad 100644
--- a/src/boot/me/trans.ml
+++ b/src/boot/me/trans.ml
@@ -142,8 +142,13 @@ let trans_visitor
let arg0_disp =
Int64.add abi.Abi.abi_frame_base_sz abi.Abi.abi_implicit_args_sz
in
- let frame_crate_ptr = word_n (-1) in
- let frame_fns_disp = word_n (-2) in
+ let frame_info_disp =
+ Int64.neg (Int64.add
+ abi.Abi.abi_frame_info_sz
+ abi.Abi.abi_callee_saves_sz)
+ in
+ let frame_fns_disp = Int64.add frame_info_disp (word_n 0) in
+ let frame_crate_ptr_disp = Int64.add frame_info_disp (word_n 1) in
let fn_ty (id:node_id) : Ast.ty =
Hashtbl.find cx.ctxt_all_item_types id
@@ -396,7 +401,7 @@ let trans_visitor
and cell_cast = Il.cell_cast
and curr_crate_ptr _ : Il.cell =
- word_at (fp_imm frame_crate_ptr)
+ word_at (fp_imm frame_crate_ptr_disp)
and crate_rel_to_ptr (rel:Il.operand) (rty:Il.referent_ty) : Il.cell =
(in_quad_category "crate_rel -> ptr"
@@ -1645,7 +1650,7 @@ let trans_visitor
iflog (fun _ -> annotate "write frame-info pointers");
Abi.load_fixup_addr (emitter())
crate_ptr_reg cx.ctxt_crate_fixup Il.OpaqueTy;
- mov (word_at (fp_imm frame_crate_ptr)) (Il.Cell (crate_ptr_cell));
+ mov (word_at (fp_imm frame_crate_ptr_disp)) (Il.Cell (crate_ptr_cell));
imov (word_at (fp_imm frame_fns_disp)) frame_fns
and check_interrupt_flag _ =