Skip to content

Commit eb1f2f1

Browse files
committed
---
yaml --- r: 591 b: refs/heads/master c: b2b72a0 h: refs/heads/master i: 589: fa097d6 587: 9e6fb78 583: 4f11678 575: 310ecee v: v3
1 parent dffd45f commit eb1f2f1

File tree

5 files changed

+41
-36
lines changed

5 files changed

+41
-36
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: af6e1d2c2ba777622c21455f897bbc7a1c88372d
2+
refs/heads/master: b2b72a08dbd18e384972dd835a93df9167380247

trunk/src/boot/be/abi.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@ let stk_field_data = stk_field_limit + 1;;
4747

4848
(* Both obj and fn are two-word "bindings": One word points to some
4949
* static dispatch information (vtbl or thunk), and the other points to
50-
* some bag of bound data (object-body or closure). *)
50+
* some bag of bound data (object-body or closure).
51+
*)
5152

5253
let binding_field_dispatch = 0;;
5354
let binding_field_bound_data = 1;;
5455

5556
let obj_field_vtbl = binding_field_dispatch;;
56-
let obj_field_body_box = binding_field_bound_data;;
57+
let obj_field_box = binding_field_bound_data;;
58+
5759
let obj_body_elt_tydesc = 0;;
5860
let obj_body_elt_fields = 1;;
5961

trunk/src/boot/be/x86.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ let rec calculate_sz (e:Il.emitter) (size:size) (in_obj:bool) : unit =
10551055

10561056
(* Bind all the referent types we'll need... *)
10571057

1058-
let obj_body_rty = Semant.obj_closure_rty word_bits in
1058+
let obj_box_rty = Semant.obj_box_rty word_bits in
10591059
let tydesc_rty = Semant.tydesc_rty word_bits in
10601060
(* Note that we cheat here and pretend only to have i+1 tydescs (because
10611061
we GEP to the i'th while still in this function, so no one outside
@@ -1068,7 +1068,7 @@ let rec calculate_sz (e:Il.emitter) (size:size) (in_obj:bool) : unit =
10681068

10691069
mov (rc eax) (Il.Cell closure_ptr);
10701070
let obj_body = word_n (h eax) Abi.box_rc_field_body in
1071-
let obj_body = Il.ptr_cast obj_body obj_body_rty in
1071+
let obj_body = Il.ptr_cast obj_body obj_box_rty in
10721072
let tydesc_ptr = get_element_ptr obj_body Abi.obj_body_elt_tydesc in
10731073

10741074
mov (rc eax) (Il.Cell tydesc_ptr);

trunk/src/boot/me/semant.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,7 +1878,10 @@ let tydesc_rty (word_bits:Il.bits) : Il.referent_ty =
18781878
|]
18791879
;;
18801880

1881-
let obj_closure_rty (word_bits:Il.bits) : Il.referent_ty =
1881+
(*
1882+
* [ rc [ tydesc* | obj-body ] ]
1883+
*)
1884+
let obj_box_rty (word_bits:Il.bits) : Il.referent_ty =
18821885
Il.StructTy [|
18831886
word_rty word_bits;
18841887
Il.StructTy [|
@@ -1945,8 +1948,8 @@ let rec referent_type (word_bits:Il.bits) (t:Ast.ty) : Il.referent_ty =
19451948
Il.StructTy [| codeptr; fn_closure_ptr |]
19461949

19471950
| Ast.TY_obj _ ->
1948-
let obj_closure_ptr = sp (obj_closure_rty word_bits) in
1949-
Il.StructTy [| ptr; obj_closure_ptr |]
1951+
let obj_box_ptr = sp (obj_box_rty word_bits) in
1952+
Il.StructTy [| ptr; obj_box_ptr |]
19501953

19511954
| Ast.TY_tag ttag -> tag ttag
19521955
| Ast.TY_iso tiso -> tag tiso.Ast.iso_group.(tiso.Ast.iso_index)

trunk/src/boot/me/trans.ml

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ let trans_visitor
459459
in
460460
deref (ptr_cast
461461
(get_element_ptr indirect_args Abi.indirect_args_elt_closure)
462-
(Il.ScalarTy (Il.AddrTy (obj_closure_rty word_bits))))
462+
(Il.ScalarTy (Il.AddrTy (obj_box_rty word_bits))))
463463
in
464464

465465
let fp_to_args (fp:Il.cell) (args_rty:Il.referent_ty): Il.cell =
@@ -1236,7 +1236,7 @@ let trans_visitor
12361236
let fty = Hashtbl.find (snd caller) ident in
12371237
let self_args_rty =
12381238
call_args_referent_type cx 0
1239-
(Ast.TY_fn fty) (Some (obj_closure_rty word_bits))
1239+
(Ast.TY_fn fty) (Some (obj_box_rty word_bits))
12401240
in
12411241
let callsz = Il.referent_ty_size word_bits self_args_rty in
12421242
let spill = new_fixup "forwarding fn spill" in
@@ -1891,8 +1891,8 @@ let trans_visitor
18911891
begin
18921892
match ty with
18931893
Ast.TY_obj _ ->
1894-
let lhs_binding = get_element_ptr lhs Abi.obj_field_body_box in
1895-
let rhs_binding = get_element_ptr rhs Abi.obj_field_body_box in
1894+
let lhs_binding = get_element_ptr lhs Abi.obj_field_box in
1895+
let rhs_binding = get_element_ptr rhs Abi.obj_field_box in
18961896
let lhs_box, rhs_box = deref lhs_binding, deref rhs_binding in
18971897
let lhs_obj = get_element_ptr lhs_box Abi.box_rc_field_body in
18981898
let rhs_obj = get_element_ptr rhs_box Abi.box_rc_field_body in
@@ -2643,7 +2643,7 @@ let trans_visitor
26432643

26442644
| Ast.TY_obj _ ->
26452645
note_drop_step ty "drop_ty: obj path";
2646-
let binding = get_element_ptr cell Abi.obj_field_body_box in
2646+
let binding = get_element_ptr cell Abi.obj_field_box in
26472647
let null_jmp = null_check binding in
26482648
let rc_jmp = drop_refcount_and_cmp binding in
26492649
let obj_box = deref binding in
@@ -4948,14 +4948,14 @@ let trans_visitor
49484948
all_args_cell Abi.calltup_elt_ty_params
49494949
in
49504950

4951-
let obj_args_tup =
4951+
let obj_fields_tup =
49524952
Array.map (fun (sloti,_) -> (slot_ty sloti.node)) header
49534953
in
4954-
let obj_args_ty = Ast.TY_tup obj_args_tup in
4955-
let state_ty = Ast.TY_tup [| Ast.TY_type; obj_args_ty |] in
4956-
let state_ptr_ty = Ast.TY_box state_ty in
4957-
let state_ptr_rty = referent_type word_bits state_ptr_ty in
4958-
let state_malloc_sz = box_allocation_size state_ptr_ty in
4954+
let obj_fields_ty = Ast.TY_tup obj_fields_tup in
4955+
let obj_body_ty = Ast.TY_tup [| Ast.TY_type; obj_fields_ty |] in
4956+
let box_ptr_ty = Ast.TY_box obj_body_ty in
4957+
let box_ptr_rty = referent_type word_bits box_ptr_ty in
4958+
let box_malloc_sz = box_allocation_size box_ptr_ty in
49594959

49604960
let ctor_ty = Hashtbl.find cx.ctxt_all_item_types obj_id in
49614961
let obj_ty =
@@ -4973,48 +4973,48 @@ let trans_visitor
49734973
let dst_pair_item_cell =
49744974
get_element_ptr dst_pair_cell Abi.obj_field_vtbl
49754975
in
4976-
let dst_pair_state_cell =
4977-
get_element_ptr dst_pair_cell Abi.obj_field_body_box
4976+
let dst_pair_box_cell =
4977+
get_element_ptr dst_pair_cell Abi.obj_field_box
49784978
in
49794979

49804980
(* Load first cell of pair with vtbl ptr.*)
49814981
iflog (fun _ -> annotate "mov vtbl-ptr to obj.item cell");
49824982
mov dst_pair_item_cell (Il.Cell vtbl_cell);
49834983

4984-
(* Load second cell of pair with pointer to fresh state tuple.*)
4985-
iflog (fun _ -> annotate "malloc state-tuple to obj.state cell");
4986-
trans_malloc dst_pair_state_cell state_malloc_sz zero;
4984+
(* Load second cell of pair with pointer to fresh body tuple.*)
4985+
iflog (fun _ -> annotate "malloc state-tuple to obj.box-ptr cell");
4986+
trans_malloc dst_pair_box_cell box_malloc_sz zero;
49874987

4988-
(* Copy args into the state tuple. *)
4989-
let state_ptr = next_vreg_cell (need_scalar_ty state_ptr_rty) in
4990-
iflog (fun _ -> annotate "load obj.state ptr to vreg");
4991-
mov state_ptr (Il.Cell dst_pair_state_cell);
4992-
let state = deref state_ptr in
4988+
(* Copy rc, tydesc, args into the obj. *)
4989+
let box_ptr = next_vreg_cell (need_scalar_ty box_ptr_rty) in
4990+
iflog (fun _ -> annotate "load obj.box ptr to vreg");
4991+
mov box_ptr (Il.Cell dst_pair_box_cell);
4992+
let box = deref box_ptr in
49934993
let refcnt =
4994-
get_element_ptr_dyn_in_current_frame state
4994+
get_element_ptr_dyn_in_current_frame box
49954995
Abi.box_rc_field_refcnt
49964996
in
49974997
let body =
4998-
get_element_ptr_dyn_in_current_frame state
4998+
get_element_ptr_dyn_in_current_frame box
49994999
Abi.box_rc_field_body
50005000
in
50015001
let obj_tydesc =
50025002
get_element_ptr_dyn_in_current_frame body Abi.obj_body_elt_tydesc
50035003
in
5004-
let obj_args =
5004+
let obj_fields =
50055005
get_element_ptr_dyn_in_current_frame body Abi.obj_body_elt_fields
50065006
in
5007-
iflog (fun _ -> annotate "write refcnt=1 to obj state");
5007+
iflog (fun _ -> annotate "write refcnt=1 to obj box");
50085008
mov refcnt one;
5009-
iflog (fun _ -> annotate "get args-tup tydesc");
5009+
iflog (fun _ -> annotate "write tydesc to obj body");
50105010
mov obj_tydesc
50115011
(Il.Cell (get_tydesc
50125012
(Some obj_id)
5013-
(Ast.TY_tup obj_args_tup)));
5013+
(Ast.TY_tup obj_fields_tup)));
50145014
iflog (fun _ -> annotate "copy ctor args to obj args");
50155015
trans_copy_tup
50165016
frame_ty_params true
5017-
obj_args frame_args obj_args_tup;
5017+
obj_fields frame_args obj_fields_tup;
50185018
(* We have to do something curious here: we can't drop the
50195019
* arg slots directly as in the normal frame-exit sequence,
50205020
* because the arg slot ids are actually given layout

0 commit comments

Comments
 (0)