Skip to content

Commit 314b906

Browse files
committed
Add more tracing code to trans for refcount events.
1 parent b172862 commit 314b906

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

src/boot/me/trans.ml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2453,9 +2453,8 @@ let trans_visitor
24532453
note_drop_step ty "drop_ty: obj path";
24542454
let binding = get_element_ptr cell Abi.binding_field_binding in
24552455
let null_jmp = null_check binding in
2456+
let rc_jmp = drop_refcount_and_cmp binding in
24562457
let obj = deref binding in
2457-
let rc = get_element_ptr obj 0 in
2458-
let rc_jmp = drop_refcount_and_cmp rc in
24592458
let tydesc = get_element_ptr obj 1 in
24602459
let body = get_element_ptr obj 2 in
24612460
let ty_params =
@@ -2505,8 +2504,7 @@ let trans_visitor
25052504

25062505
let _ = check_box_rty cell in
25072506
let null_jmp = null_check cell in
2508-
let rc = box_rc_cell cell in
2509-
let j = drop_refcount_and_cmp rc in
2507+
let j = drop_refcount_and_cmp cell in
25102508

25112509
(* FIXME (issue #25): check to see that the box has
25122510
* further box members; if it doesn't we can elide the
@@ -2525,7 +2523,7 @@ let trans_visitor
25252523
note_drop_step ty "drop_ty: done box-drop path";
25262524

25272525
| MEM_interior when type_is_structured ty ->
2528-
note_drop_step ty "drop:ty structured-interior path";
2526+
note_drop_step ty "drop_ty structured-interior path";
25292527
iter_ty_parts ty_params cell ty
25302528
(drop_ty ty_params) curr_iso;
25312529
note_drop_step ty "drop_ty: done structured-interior path";
@@ -2740,14 +2738,35 @@ let trans_visitor
27402738
emit (Il.jmp Il.JE Il.CodeNone);
27412739
j
27422740

2743-
and drop_refcount_and_cmp (rc:Il.cell) : quad_idx =
2741+
and drop_refcount_and_cmp (boxed:Il.cell) : quad_idx =
27442742
iflog (fun _ -> annotate "drop refcount and maybe free");
2743+
let rc = box_rc_cell boxed in
2744+
if cx.ctxt_sess.Session.sess_trace_gc ||
2745+
cx.ctxt_sess.Session.sess_trace_drop
2746+
then
2747+
begin
2748+
trace_str true "refcount--";
2749+
trace_word true boxed;
2750+
trace_word true rc
2751+
end;
27452752
emit (Il.binary Il.SUB rc (Il.Cell rc) one);
27462753
emit (Il.cmp (Il.Cell rc) zero);
27472754
let j = mark () in
27482755
emit (Il.jmp Il.JNE Il.CodeNone);
27492756
j
27502757

2758+
and incr_refcount (boxed:Il.cell) : unit =
2759+
let rc = box_rc_cell boxed in
2760+
if cx.ctxt_sess.Session.sess_trace_gc ||
2761+
cx.ctxt_sess.Session.sess_trace_drop
2762+
then
2763+
begin
2764+
trace_str true "refcount++";
2765+
trace_word true boxed;
2766+
trace_word true rc
2767+
end;
2768+
add_to rc one
2769+
27512770
and drop_slot
27522771
(ty_params:Il.cell)
27532772
(cell:Il.cell)
@@ -2917,7 +2936,7 @@ let trans_visitor
29172936
| (MEM_rc_struct, MEM_rc_struct) ->
29182937
(* Lightweight copy: twiddle refcounts, move pointer. *)
29192938
anno "refcounted light";
2920-
add_to (box_rc_cell src) one;
2939+
incr_refcount src;
29212940
if not initializing
29222941
then
29232942
drop_ty ty_params dst dst_ty None;

0 commit comments

Comments
 (0)