@@ -2453,9 +2453,8 @@ let trans_visitor
2453
2453
note_drop_step ty " drop_ty: obj path" ;
2454
2454
let binding = get_element_ptr cell Abi. binding_field_binding in
2455
2455
let null_jmp = null_check binding in
2456
+ let rc_jmp = drop_refcount_and_cmp binding in
2456
2457
let obj = deref binding in
2457
- let rc = get_element_ptr obj 0 in
2458
- let rc_jmp = drop_refcount_and_cmp rc in
2459
2458
let tydesc = get_element_ptr obj 1 in
2460
2459
let body = get_element_ptr obj 2 in
2461
2460
let ty_params =
@@ -2505,8 +2504,7 @@ let trans_visitor
2505
2504
2506
2505
let _ = check_box_rty cell in
2507
2506
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
2510
2508
2511
2509
(* FIXME (issue #25): check to see that the box has
2512
2510
* further box members; if it doesn't we can elide the
@@ -2525,7 +2523,7 @@ let trans_visitor
2525
2523
note_drop_step ty " drop_ty: done box-drop path" ;
2526
2524
2527
2525
| 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" ;
2529
2527
iter_ty_parts ty_params cell ty
2530
2528
(drop_ty ty_params) curr_iso;
2531
2529
note_drop_step ty " drop_ty: done structured-interior path" ;
@@ -2740,14 +2738,35 @@ let trans_visitor
2740
2738
emit (Il. jmp Il. JE Il. CodeNone );
2741
2739
j
2742
2740
2743
- and drop_refcount_and_cmp (rc :Il.cell ) : quad_idx =
2741
+ and drop_refcount_and_cmp (boxed :Il.cell ) : quad_idx =
2744
2742
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 ;
2745
2752
emit (Il. binary Il. SUB rc (Il. Cell rc) one);
2746
2753
emit (Il. cmp (Il. Cell rc) zero);
2747
2754
let j = mark () in
2748
2755
emit (Il. jmp Il. JNE Il. CodeNone );
2749
2756
j
2750
2757
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
+
2751
2770
and drop_slot
2752
2771
(ty_params :Il.cell )
2753
2772
(cell :Il.cell )
@@ -2917,7 +2936,7 @@ let trans_visitor
2917
2936
| (MEM_rc_struct, MEM_rc_struct) ->
2918
2937
(* Lightweight copy: twiddle refcounts, move pointer. *)
2919
2938
anno " refcounted light" ;
2920
- add_to (box_rc_cell src) one ;
2939
+ incr_refcount src;
2921
2940
if not initializing
2922
2941
then
2923
2942
drop_ty ty_params dst dst_ty None ;
0 commit comments