@@ -1228,8 +1228,8 @@ let trans_visitor
1228
1228
(sorted_htab_keys fns))
1229
1229
end
1230
1230
1231
- and trans_init_str (dst :Ast.lval ) (s :string ) : unit =
1232
- (* Include null byte. *)
1231
+ and trans_init_str (dst :Ast.lval ) (s :string ) : unit =
1232
+ (* Include null byte. *)
1233
1233
let init_sz = Int64. of_int ((String. length s) + 1 ) in
1234
1234
let static = trans_static_string s in
1235
1235
let (dst, _) = trans_lval_init dst in
@@ -1715,51 +1715,63 @@ let trans_visitor
1715
1715
(code :Il.code )
1716
1716
(dst :Il.cell option )
1717
1717
(args :Il.cell array )
1718
+ (clo :Il.cell option )
1718
1719
: unit =
1719
- let inner dst =
1720
+ let inner dst cloptr =
1720
1721
let scratch = next_vreg_cell Il. voidptr_t in
1721
1722
let pop _ = emit (Il. Pop scratch) in
1722
1723
for i = ((Array. length args) - 1 ) downto 0
1723
1724
do
1724
1725
emit (Il. Push (Il. Cell args.(i)))
1725
1726
done ;
1726
- emit (Il. Push zero );
1727
+ emit (Il. Push cloptr );
1727
1728
emit (Il. Push (Il. Cell abi.Abi. abi_tp_cell));
1728
1729
emit (Il. Push dst);
1729
1730
call_code code;
1730
1731
pop () ;
1731
1732
pop () ;
1732
1733
pop () ;
1733
1734
Array. iter (fun _ -> pop() ) args;
1735
+ in
1736
+ let cloptr =
1737
+ match clo with
1738
+ None -> zero
1739
+ | Some cloptr -> Il. Cell cloptr
1734
1740
in
1735
1741
match dst with
1736
- None -> inner zero
1737
- | Some dst -> aliasing true dst (fun dst -> inner (Il. Cell dst))
1742
+ None -> inner zero cloptr
1743
+ | Some dst ->
1744
+ aliasing true dst (fun dst -> inner (Il. Cell dst) cloptr)
1738
1745
1739
1746
and trans_call_static_glue
1740
1747
(callee :Il.operand )
1741
1748
(dst :Il.cell option )
1742
1749
(args :Il.cell array )
1750
+ (clo :Il.cell option )
1743
1751
: unit =
1744
- trans_call_glue (code_of_operand callee) dst args
1752
+ trans_call_glue (code_of_operand callee) dst args clo
1745
1753
1746
1754
and trans_call_dynamic_glue
1747
1755
(tydesc :Il.cell )
1748
1756
(idx :int )
1749
1757
(dst :Il.cell option )
1750
1758
(args :Il.cell array )
1759
+ (clo :Il.cell option )
1751
1760
: unit =
1752
1761
let fptr = get_vtbl_entry_idx tydesc idx in
1753
- trans_call_glue (code_of_operand (Il. Cell fptr)) dst args
1762
+ trans_call_glue (code_of_operand (Il. Cell fptr)) dst args clo
1754
1763
1755
1764
and trans_call_simple_static_glue
1756
1765
(fix :fixup )
1757
1766
(ty_params :Il.cell )
1758
- (arg :Il.cell )
1767
+ (args :Il.cell array )
1768
+ (clo :Il.cell option )
1759
1769
: unit =
1760
1770
trans_call_static_glue
1761
1771
(code_fixup_to_ptr_operand fix)
1762
- None [| alias ty_params; arg |]
1772
+ None
1773
+ (Array. append [| alias ty_params |] args)
1774
+ clo
1763
1775
1764
1776
and get_tydesc_params
1765
1777
(outer_ty_params :Il.cell )
@@ -1781,16 +1793,20 @@ let trans_visitor
1781
1793
(ty_param :int )
1782
1794
(vtbl_idx :int )
1783
1795
(ty_params :Il.cell )
1784
- (arg :Il.cell )
1796
+ (args :Il.cell array )
1797
+ (clo :Il.cell option )
1785
1798
: unit =
1786
1799
iflog (fun _ ->
1787
1800
annotate (Printf. sprintf " calling tydesc[%d].glue[%d]"
1788
1801
ty_param vtbl_idx));
1789
1802
let td = get_ty_param ty_params ty_param in
1790
1803
let ty_params_ptr = get_tydesc_params ty_params td in
1791
1804
trans_call_dynamic_glue
1792
- td vtbl_idx
1793
- None [| ty_params_ptr; arg; |]
1805
+ td
1806
+ vtbl_idx
1807
+ None
1808
+ (Array. append [| ty_params_ptr |] args)
1809
+ clo
1794
1810
1795
1811
(* trans_compare returns a quad number of the cjmp, which the caller
1796
1812
patches to the cjmp destination. *)
@@ -2467,23 +2483,31 @@ let trans_visitor
2467
2483
in
2468
2484
let null_dtor_jmp = null_check dtor in
2469
2485
(* Call any dtor, if present. *)
2470
- note_drop_step ty " drop_ty: calling obj dtor" ;
2471
- trans_call_dynamic_glue tydesc
2472
- Abi. tydesc_field_obj_drop_glue None [| binding |];
2473
- patch null_dtor_jmp;
2474
- (* Drop the body. *)
2475
- note_drop_step ty " drop_ty: dropping obj body" ;
2476
- trans_call_dynamic_glue tydesc
2477
- Abi. tydesc_field_drop_glue None [| ty_params; alias body |];
2478
- (* FIXME: this will fail if the user has lied about the
2479
- * state-ness of their obj. We need to store state-ness in the
2480
- * captured tydesc, and use that. *)
2481
- note_drop_step ty " drop_ty: freeing obj body" ;
2482
- trans_free binding (type_has_state ty);
2483
- mov binding zero;
2484
- patch rc_jmp;
2485
- patch null_jmp;
2486
- note_drop_step ty " drop_ty: done obj path" ;
2486
+ note_drop_step ty " drop_ty: calling obj dtor" ;
2487
+ trans_call_dynamic_glue
2488
+ tydesc
2489
+ Abi. tydesc_field_obj_drop_glue
2490
+ None
2491
+ [| binding |]
2492
+ (Some binding);
2493
+ patch null_dtor_jmp;
2494
+ (* Drop the body. *)
2495
+ note_drop_step ty " drop_ty: dropping obj body" ;
2496
+ trans_call_dynamic_glue
2497
+ tydesc
2498
+ Abi. tydesc_field_drop_glue
2499
+ None
2500
+ [| ty_params; alias body |]
2501
+ None ;
2502
+ (* FIXME: this will fail if the user has lied about the
2503
+ * state-ness of their obj. We need to store state-ness in the
2504
+ * captured tydesc, and use that. *)
2505
+ note_drop_step ty " drop_ty: freeing obj body" ;
2506
+ trans_free binding (type_has_state ty);
2507
+ mov binding zero;
2508
+ patch rc_jmp;
2509
+ patch null_jmp;
2510
+ note_drop_step ty " drop_ty: done obj path" ;
2487
2511
2488
2512
2489
2513
| Ast. TY_param (i , _ ) ->
@@ -2492,7 +2516,11 @@ let trans_visitor
2492
2516
begin
2493
2517
fun cell ->
2494
2518
trans_call_simple_dynamic_glue
2495
- i Abi. tydesc_field_drop_glue ty_params cell
2519
+ i
2520
+ Abi. tydesc_field_drop_glue
2521
+ ty_params
2522
+ [| cell |]
2523
+ None
2496
2524
end;
2497
2525
note_drop_step ty " drop_ty: done parametric-ty path" ;
2498
2526
@@ -2514,7 +2542,9 @@ let trans_visitor
2514
2542
2515
2543
trans_call_simple_static_glue
2516
2544
(get_free_glue ty (mctrl = MEM_gc ) curr_iso)
2517
- ty_params cell;
2545
+ ty_params
2546
+ [| cell |]
2547
+ None ;
2518
2548
2519
2549
(* Null the slot out to prevent double-free if the frame
2520
2550
* unwinds.
@@ -2603,7 +2633,7 @@ let trans_visitor
2603
2633
trans_call_static_glue
2604
2634
(code_fixup_to_ptr_operand glue_fix)
2605
2635
(Some dst)
2606
- [| alias ty_params; src; clone_task |]
2636
+ [| alias ty_params; src; clone_task |] None
2607
2637
| _ ->
2608
2638
iter_ty_parts_full ty_params dst src ty
2609
2639
(clone_ty ty_params clone_task) curr_iso
@@ -2640,7 +2670,10 @@ let trans_visitor
2640
2670
lea vr body_mem;
2641
2671
trace_word cx.ctxt_sess.Session. sess_trace_drop vr;
2642
2672
trans_call_simple_static_glue
2643
- (get_drop_glue body_ty curr_iso) ty_params vr;
2673
+ (get_drop_glue body_ty curr_iso)
2674
+ ty_params
2675
+ [| vr |]
2676
+ None ;
2644
2677
note_drop_step ty " in free-ty, calling free" ;
2645
2678
trans_free cell is_gc;
2646
2679
end ;
@@ -2700,7 +2733,9 @@ let trans_visitor
2700
2733
lea tmp body_mem;
2701
2734
trans_call_simple_static_glue
2702
2735
(get_mark_glue ty curr_iso)
2703
- ty_params tmp;
2736
+ ty_params
2737
+ [| tmp |]
2738
+ None ;
2704
2739
List. iter patch marked_jump;
2705
2740
2706
2741
| MEM_interior when type_is_structured ty ->
@@ -2714,7 +2749,9 @@ let trans_visitor
2714
2749
lea tmp mem;
2715
2750
trans_call_simple_static_glue
2716
2751
(get_mark_glue ty curr_iso)
2717
- ty_params tmp
2752
+ ty_params
2753
+ [| tmp |]
2754
+ None
2718
2755
2719
2756
| _ -> ()
2720
2757
@@ -3033,7 +3070,9 @@ let trans_visitor
3033
3070
let ty_params_ptr = get_tydesc_params ty_params td in
3034
3071
trans_call_dynamic_glue
3035
3072
td Abi. tydesc_field_copy_glue
3036
- (Some dst) [| ty_params_ptr; src; |]
3073
+ (Some dst)
3074
+ [| ty_params_ptr; src; |]
3075
+ None
3037
3076
end
3038
3077
3039
3078
| Ast. TY_fn _
@@ -4090,7 +4129,11 @@ let trans_visitor
4090
4129
let fp = get_iter_outer_frame_ptr_for_current_frame () in
4091
4130
let vr = next_vreg_cell Il. voidptr_t in
4092
4131
mov vr zero;
4093
- trans_call_glue (code_of_operand block_fptr) None [| vr; fp |]
4132
+ trans_call_glue
4133
+ (code_of_operand block_fptr)
4134
+ None
4135
+ [| vr; fp |]
4136
+ None
4094
4137
4095
4138
and trans_vec_append dst_cell dst_ty src_oper src_ty =
4096
4139
let elt_ty = seq_unit_ty dst_ty in
0 commit comments