Skip to content

Commit 348e434

Browse files
committed
Clean up nomenclature in the Abi constants brigade. Purge magic GEP numbers in trans. Adjust obj_closure_rty (and its consumers) to be more explicit about the fact that it is a box.
1 parent de8a7dc commit 348e434

File tree

7 files changed

+118
-75
lines changed

7 files changed

+118
-75
lines changed

src/boot/be/abi.ml

+22-14
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ let frame_glue_fns_field_mark = 0;;
2626
let frame_glue_fns_field_drop = 1;;
2727
let frame_glue_fns_field_reloc = 2;;
2828

29-
let box_rc_slot_field_refcnt = 0;;
30-
let box_rc_slot_field_body = 1;;
29+
let box_rc_field_refcnt = 0;;
30+
let box_rc_field_body = 1;;
3131

32-
let box_gc_slot_alloc_base = (-3);;
33-
let box_gc_slot_field_prev = (-3);;
34-
let box_gc_slot_field_next = (-2);;
35-
let box_gc_slot_field_ctrl = (-1);;
36-
let box_gc_slot_field_refcnt = 0;;
37-
let box_gc_slot_field_body = 1;;
32+
let box_gc_alloc_base = (-3);;
33+
let box_gc_field_prev = (-3);;
34+
let box_gc_field_next = (-2);;
35+
let box_gc_field_ctrl = (-1);;
36+
let box_gc_field_refcnt = 0;;
37+
let box_gc_field_body = 1;;
3838

3939
let box_rc_header_size = 1;;
4040
let box_gc_header_size = 4;;
@@ -45,13 +45,21 @@ let stk_field_valgrind_id = 0 + 1;;
4545
let stk_field_limit = stk_field_valgrind_id + 1;;
4646
let stk_field_data = stk_field_limit + 1;;
4747

48-
let binding_size = 2;;
49-
let binding_field_item = 0;;
50-
let binding_field_binding = 1;;
48+
let obj_elt_vtbl = 0;;
49+
let obj_elt_body_box = 1;;
5150

52-
let obj_elt_rc = 0;;
53-
let obj_elt_tydesc = 1;;
54-
let obj_elt_fields = 2;;
51+
let obj_body_elt_tydesc = 0;;
52+
let obj_body_elt_fields = 1;;
53+
54+
let fn_elt_thunk = 0;;
55+
let fn_elt_closure = 1;;
56+
57+
let closure_elt_rc = 0;;
58+
let closure_elt_target = 1;;
59+
let closure_elt_bound_args = 2;;
60+
61+
let tag_elt_discriminant = 0;;
62+
let tag_elt_variant = 1;;
5563

5664
let general_code_alignment = 16;;
5765

src/boot/be/x86.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ let sweep_gc_chain
830830
emit (Il.jmp Il.JE
831831
(codefix exit_jmp_fix)); (* if nonzero *)
832832
mov (rc ecx) (* Load GC ctrl word *)
833-
(c (edi_n Abi.box_gc_slot_field_ctrl));
833+
(c (edi_n Abi.box_gc_field_ctrl));
834834
mov (rc eax) (ro ecx);
835835
band (rc eax) (immi 1L); (* Extract mark to eax. *)
836836
band (* Clear mark in ecx. *)
@@ -840,7 +840,7 @@ let sweep_gc_chain
840840
if clear_mark
841841
then
842842
mov (* Write-back cleared. *)
843-
((edi_n Abi.box_gc_slot_field_ctrl))
843+
((edi_n Abi.box_gc_field_ctrl))
844844
(ro ecx);
845845

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

873873
mark skip_jmp_fix;
874874
mov (rc edi) (* Advance down chain *)
875-
(c (edi_n Abi.box_gc_slot_field_next));
875+
(c (edi_n Abi.box_gc_field_next));
876876
emit (Il.jmp Il.JMP
877877
(codefix repeat_jmp_fix)); (* loop *)
878878
mark exit_jmp_fix;

src/boot/llvm/lltrans.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -453,15 +453,15 @@ let trans_crate
453453
llbuilder :=
454454
if_ptr_in_slot_not_null
455455
(decr_refcnt_and_if_zero
456-
Abi.box_rc_slot_field_refcnt
456+
Abi.box_rc_field_refcnt
457457
free_and_null_out_slot)
458458
(!llbuilder)
459459

460460
| MEM_rc_opaque ->
461461
llbuilder :=
462462
if_ptr_in_slot_not_null
463463
(decr_refcnt_and_if_zero
464-
Abi.box_rc_slot_field_refcnt
464+
Abi.box_rc_field_refcnt
465465
free_and_null_out_slot)
466466
(!llbuilder)
467467

src/boot/me/dwarf.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2019,7 +2019,7 @@ let dwarf_visitor
20192019
let box_type t =
20202020
let fix = new_fixup "box DIE" in
20212021
let body_off =
2022-
word_sz_int * Abi.box_rc_slot_field_body
2022+
word_sz_int * Abi.box_rc_field_body
20232023
in
20242024
emit_die (DEF (fix, SEQ [|
20252025
uleb (get_abbrev_code abbrev_box_type);

src/boot/me/layout.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ let layout_visitor
222222
let offset =
223223
let word_sz = cx.ctxt_abi.Abi.abi_word_sz in
224224
let word_n (n:int) = Int64.mul word_sz (Int64.of_int n) in
225-
SIZE_fixed (word_n (Abi.box_rc_slot_field_body
225+
SIZE_fixed (word_n (Abi.box_rc_field_body
226226
+ 1 (* the state tydesc. *)))
227227
in
228228
log cx "laying out object-state for node #%d at offset %s"

src/boot/me/semant.ml

+8-5
Original file line numberDiff line numberDiff line change
@@ -1894,11 +1894,14 @@ let tydesc_rty (abi:Abi.abi) : Il.referent_ty =
18941894
;;
18951895

18961896
let obj_closure_rty (abi:Abi.abi) : Il.referent_ty =
1897-
Il.StructTy [| word_rty abi;
1898-
Il.ScalarTy (Il.AddrTy (tydesc_rty abi));
1899-
word_rty abi (* A lie: it's opaque, but this permits
1900-
* GEP'ing to it. *)
1901-
|]
1897+
Il.StructTy [|
1898+
word_rty abi;
1899+
Il.StructTy [|
1900+
Il.ScalarTy (Il.AddrTy (tydesc_rty abi));
1901+
word_rty abi (* A lie: it's opaque, but this permits
1902+
* GEP'ing to it. *)
1903+
|]
1904+
|]
19021905
;;
19031906

19041907
let rec referent_type (abi:Abi.abi) (t:Ast.ty) : Il.referent_ty =

0 commit comments

Comments
 (0)