Skip to content

Commit

Permalink
Clean up nomenclature in the Abi constants brigade. Purge magic GEP n…
Browse files Browse the repository at this point in the history
…umbers in trans. Adjust obj_closure_rty (and its consumers) to be more explicit about the fact that it is a box.
  • Loading branch information
froystig committed Jul 16, 2010
1 parent de8a7dc commit 348e434
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 75 deletions.
36 changes: 22 additions & 14 deletions src/boot/be/abi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ let frame_glue_fns_field_mark = 0;;
let frame_glue_fns_field_drop = 1;;
let frame_glue_fns_field_reloc = 2;;

let box_rc_slot_field_refcnt = 0;;
let box_rc_slot_field_body = 1;;
let box_rc_field_refcnt = 0;;
let box_rc_field_body = 1;;

let box_gc_slot_alloc_base = (-3);;
let box_gc_slot_field_prev = (-3);;
let box_gc_slot_field_next = (-2);;
let box_gc_slot_field_ctrl = (-1);;
let box_gc_slot_field_refcnt = 0;;
let box_gc_slot_field_body = 1;;
let box_gc_alloc_base = (-3);;
let box_gc_field_prev = (-3);;
let box_gc_field_next = (-2);;
let box_gc_field_ctrl = (-1);;
let box_gc_field_refcnt = 0;;
let box_gc_field_body = 1;;

let box_rc_header_size = 1;;
let box_gc_header_size = 4;;
Expand All @@ -45,13 +45,21 @@ let stk_field_valgrind_id = 0 + 1;;
let stk_field_limit = stk_field_valgrind_id + 1;;
let stk_field_data = stk_field_limit + 1;;

let binding_size = 2;;
let binding_field_item = 0;;
let binding_field_binding = 1;;
let obj_elt_vtbl = 0;;
let obj_elt_body_box = 1;;

let obj_elt_rc = 0;;
let obj_elt_tydesc = 1;;
let obj_elt_fields = 2;;
let obj_body_elt_tydesc = 0;;
let obj_body_elt_fields = 1;;

let fn_elt_thunk = 0;;
let fn_elt_closure = 1;;

let closure_elt_rc = 0;;
let closure_elt_target = 1;;
let closure_elt_bound_args = 2;;

let tag_elt_discriminant = 0;;
let tag_elt_variant = 1;;

let general_code_alignment = 16;;

Expand Down
6 changes: 3 additions & 3 deletions src/boot/be/x86.ml
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ let sweep_gc_chain
emit (Il.jmp Il.JE
(codefix exit_jmp_fix)); (* if nonzero *)
mov (rc ecx) (* Load GC ctrl word *)
(c (edi_n Abi.box_gc_slot_field_ctrl));
(c (edi_n Abi.box_gc_field_ctrl));
mov (rc eax) (ro ecx);
band (rc eax) (immi 1L); (* Extract mark to eax. *)
band (* Clear mark in ecx. *)
Expand All @@ -840,7 +840,7 @@ let sweep_gc_chain
if clear_mark
then
mov (* Write-back cleared. *)
((edi_n Abi.box_gc_slot_field_ctrl))
((edi_n Abi.box_gc_field_ctrl))
(ro ecx);

emit (Il.cmp (ro eax) (immi 0L));
Expand Down Expand Up @@ -872,7 +872,7 @@ let sweep_gc_chain

mark skip_jmp_fix;
mov (rc edi) (* Advance down chain *)
(c (edi_n Abi.box_gc_slot_field_next));
(c (edi_n Abi.box_gc_field_next));
emit (Il.jmp Il.JMP
(codefix repeat_jmp_fix)); (* loop *)
mark exit_jmp_fix;
Expand Down
4 changes: 2 additions & 2 deletions src/boot/llvm/lltrans.ml
Original file line number Diff line number Diff line change
Expand Up @@ -453,15 +453,15 @@ let trans_crate
llbuilder :=
if_ptr_in_slot_not_null
(decr_refcnt_and_if_zero
Abi.box_rc_slot_field_refcnt
Abi.box_rc_field_refcnt
free_and_null_out_slot)
(!llbuilder)

| MEM_rc_opaque ->
llbuilder :=
if_ptr_in_slot_not_null
(decr_refcnt_and_if_zero
Abi.box_rc_slot_field_refcnt
Abi.box_rc_field_refcnt
free_and_null_out_slot)
(!llbuilder)

Expand Down
2 changes: 1 addition & 1 deletion src/boot/me/dwarf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2019,7 +2019,7 @@ let dwarf_visitor
let box_type t =
let fix = new_fixup "box DIE" in
let body_off =
word_sz_int * Abi.box_rc_slot_field_body
word_sz_int * Abi.box_rc_field_body
in
emit_die (DEF (fix, SEQ [|
uleb (get_abbrev_code abbrev_box_type);
Expand Down
2 changes: 1 addition & 1 deletion src/boot/me/layout.ml
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ let layout_visitor
let offset =
let word_sz = cx.ctxt_abi.Abi.abi_word_sz in
let word_n (n:int) = Int64.mul word_sz (Int64.of_int n) in
SIZE_fixed (word_n (Abi.box_rc_slot_field_body
SIZE_fixed (word_n (Abi.box_rc_field_body
+ 1 (* the state tydesc. *)))
in
log cx "laying out object-state for node #%d at offset %s"
Expand Down
13 changes: 8 additions & 5 deletions src/boot/me/semant.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1894,11 +1894,14 @@ let tydesc_rty (abi:Abi.abi) : Il.referent_ty =
;;

let obj_closure_rty (abi:Abi.abi) : Il.referent_ty =
Il.StructTy [| word_rty abi;
Il.ScalarTy (Il.AddrTy (tydesc_rty abi));
word_rty abi (* A lie: it's opaque, but this permits
* GEP'ing to it. *)
|]
Il.StructTy [|
word_rty abi;
Il.StructTy [|
Il.ScalarTy (Il.AddrTy (tydesc_rty abi));
word_rty abi (* A lie: it's opaque, but this permits
* GEP'ing to it. *)
|]
|]
;;

let rec referent_type (abi:Abi.abi) (t:Ast.ty) : Il.referent_ty =
Expand Down
Loading

0 comments on commit 348e434

Please sign in to comment.