Explicitly provide an optional closure/obj pointer to trans_call_glue so that it can push one in the right position when calling glue, instead of always pushing a null. As far as I can tell this only affects calls to obj drop glue, since only that makes use of an object binding passed as closure/obj, so pass the binding there as needed.
This commit is contained in:
parent
df75165cf4
commit
373f904c92
1 changed files with 81 additions and 38 deletions
|
@ -1715,15 +1715,16 @@ let trans_visitor
|
||||||
(code:Il.code)
|
(code:Il.code)
|
||||||
(dst:Il.cell option)
|
(dst:Il.cell option)
|
||||||
(args:Il.cell array)
|
(args:Il.cell array)
|
||||||
|
(clo:Il.cell option)
|
||||||
: unit =
|
: unit =
|
||||||
let inner dst =
|
let inner dst cloptr =
|
||||||
let scratch = next_vreg_cell Il.voidptr_t in
|
let scratch = next_vreg_cell Il.voidptr_t in
|
||||||
let pop _ = emit (Il.Pop scratch) in
|
let pop _ = emit (Il.Pop scratch) in
|
||||||
for i = ((Array.length args) - 1) downto 0
|
for i = ((Array.length args) - 1) downto 0
|
||||||
do
|
do
|
||||||
emit (Il.Push (Il.Cell args.(i)))
|
emit (Il.Push (Il.Cell args.(i)))
|
||||||
done;
|
done;
|
||||||
emit (Il.Push zero);
|
emit (Il.Push cloptr);
|
||||||
emit (Il.Push (Il.Cell abi.Abi.abi_tp_cell));
|
emit (Il.Push (Il.Cell abi.Abi.abi_tp_cell));
|
||||||
emit (Il.Push dst);
|
emit (Il.Push dst);
|
||||||
call_code code;
|
call_code code;
|
||||||
|
@ -1731,35 +1732,46 @@ let trans_visitor
|
||||||
pop ();
|
pop ();
|
||||||
pop ();
|
pop ();
|
||||||
Array.iter (fun _ -> pop()) args;
|
Array.iter (fun _ -> pop()) args;
|
||||||
|
in
|
||||||
|
let cloptr =
|
||||||
|
match clo with
|
||||||
|
None -> zero
|
||||||
|
| Some cloptr -> Il.Cell cloptr
|
||||||
in
|
in
|
||||||
match dst with
|
match dst with
|
||||||
None -> inner zero
|
None -> inner zero cloptr
|
||||||
| Some dst -> aliasing true dst (fun dst -> inner (Il.Cell dst))
|
| Some dst ->
|
||||||
|
aliasing true dst (fun dst -> inner (Il.Cell dst) cloptr)
|
||||||
|
|
||||||
and trans_call_static_glue
|
and trans_call_static_glue
|
||||||
(callee:Il.operand)
|
(callee:Il.operand)
|
||||||
(dst:Il.cell option)
|
(dst:Il.cell option)
|
||||||
(args:Il.cell array)
|
(args:Il.cell array)
|
||||||
|
(clo:Il.cell option)
|
||||||
: unit =
|
: unit =
|
||||||
trans_call_glue (code_of_operand callee) dst args
|
trans_call_glue (code_of_operand callee) dst args clo
|
||||||
|
|
||||||
and trans_call_dynamic_glue
|
and trans_call_dynamic_glue
|
||||||
(tydesc:Il.cell)
|
(tydesc:Il.cell)
|
||||||
(idx:int)
|
(idx:int)
|
||||||
(dst:Il.cell option)
|
(dst:Il.cell option)
|
||||||
(args:Il.cell array)
|
(args:Il.cell array)
|
||||||
|
(clo:Il.cell option)
|
||||||
: unit =
|
: unit =
|
||||||
let fptr = get_vtbl_entry_idx tydesc idx in
|
let fptr = get_vtbl_entry_idx tydesc idx in
|
||||||
trans_call_glue (code_of_operand (Il.Cell fptr)) dst args
|
trans_call_glue (code_of_operand (Il.Cell fptr)) dst args clo
|
||||||
|
|
||||||
and trans_call_simple_static_glue
|
and trans_call_simple_static_glue
|
||||||
(fix:fixup)
|
(fix:fixup)
|
||||||
(ty_params:Il.cell)
|
(ty_params:Il.cell)
|
||||||
(arg:Il.cell)
|
(args:Il.cell array)
|
||||||
|
(clo:Il.cell option)
|
||||||
: unit =
|
: unit =
|
||||||
trans_call_static_glue
|
trans_call_static_glue
|
||||||
(code_fixup_to_ptr_operand fix)
|
(code_fixup_to_ptr_operand fix)
|
||||||
None [| alias ty_params; arg |]
|
None
|
||||||
|
(Array.append [| alias ty_params |] args)
|
||||||
|
clo
|
||||||
|
|
||||||
and get_tydesc_params
|
and get_tydesc_params
|
||||||
(outer_ty_params:Il.cell)
|
(outer_ty_params:Il.cell)
|
||||||
|
@ -1781,7 +1793,8 @@ let trans_visitor
|
||||||
(ty_param:int)
|
(ty_param:int)
|
||||||
(vtbl_idx:int)
|
(vtbl_idx:int)
|
||||||
(ty_params:Il.cell)
|
(ty_params:Il.cell)
|
||||||
(arg:Il.cell)
|
(args:Il.cell array)
|
||||||
|
(clo:Il.cell option)
|
||||||
: unit =
|
: unit =
|
||||||
iflog (fun _ ->
|
iflog (fun _ ->
|
||||||
annotate (Printf.sprintf "calling tydesc[%d].glue[%d]"
|
annotate (Printf.sprintf "calling tydesc[%d].glue[%d]"
|
||||||
|
@ -1789,8 +1802,11 @@ let trans_visitor
|
||||||
let td = get_ty_param ty_params ty_param in
|
let td = get_ty_param ty_params ty_param in
|
||||||
let ty_params_ptr = get_tydesc_params ty_params td in
|
let ty_params_ptr = get_tydesc_params ty_params td in
|
||||||
trans_call_dynamic_glue
|
trans_call_dynamic_glue
|
||||||
td vtbl_idx
|
td
|
||||||
None [| ty_params_ptr; arg; |]
|
vtbl_idx
|
||||||
|
None
|
||||||
|
(Array.append [| ty_params_ptr |] args)
|
||||||
|
clo
|
||||||
|
|
||||||
(* trans_compare returns a quad number of the cjmp, which the caller
|
(* trans_compare returns a quad number of the cjmp, which the caller
|
||||||
patches to the cjmp destination. *)
|
patches to the cjmp destination. *)
|
||||||
|
@ -2468,13 +2484,21 @@ let trans_visitor
|
||||||
let null_dtor_jmp = null_check dtor in
|
let null_dtor_jmp = null_check dtor in
|
||||||
(* Call any dtor, if present. *)
|
(* Call any dtor, if present. *)
|
||||||
note_drop_step ty "drop_ty: calling obj dtor";
|
note_drop_step ty "drop_ty: calling obj dtor";
|
||||||
trans_call_dynamic_glue tydesc
|
trans_call_dynamic_glue
|
||||||
Abi.tydesc_field_obj_drop_glue None [| binding |];
|
tydesc
|
||||||
|
Abi.tydesc_field_obj_drop_glue
|
||||||
|
None
|
||||||
|
[| binding |]
|
||||||
|
(Some binding);
|
||||||
patch null_dtor_jmp;
|
patch null_dtor_jmp;
|
||||||
(* Drop the body. *)
|
(* Drop the body. *)
|
||||||
note_drop_step ty "drop_ty: dropping obj body";
|
note_drop_step ty "drop_ty: dropping obj body";
|
||||||
trans_call_dynamic_glue tydesc
|
trans_call_dynamic_glue
|
||||||
Abi.tydesc_field_drop_glue None [| ty_params; alias body |];
|
tydesc
|
||||||
|
Abi.tydesc_field_drop_glue
|
||||||
|
None
|
||||||
|
[| ty_params; alias body |]
|
||||||
|
None;
|
||||||
(* FIXME: this will fail if the user has lied about the
|
(* FIXME: this will fail if the user has lied about the
|
||||||
* state-ness of their obj. We need to store state-ness in the
|
* state-ness of their obj. We need to store state-ness in the
|
||||||
* captured tydesc, and use that. *)
|
* captured tydesc, and use that. *)
|
||||||
|
@ -2492,7 +2516,11 @@ let trans_visitor
|
||||||
begin
|
begin
|
||||||
fun cell ->
|
fun cell ->
|
||||||
trans_call_simple_dynamic_glue
|
trans_call_simple_dynamic_glue
|
||||||
i Abi.tydesc_field_drop_glue ty_params cell
|
i
|
||||||
|
Abi.tydesc_field_drop_glue
|
||||||
|
ty_params
|
||||||
|
[| cell |]
|
||||||
|
None
|
||||||
end;
|
end;
|
||||||
note_drop_step ty "drop_ty: done parametric-ty path";
|
note_drop_step ty "drop_ty: done parametric-ty path";
|
||||||
|
|
||||||
|
@ -2514,7 +2542,9 @@ let trans_visitor
|
||||||
|
|
||||||
trans_call_simple_static_glue
|
trans_call_simple_static_glue
|
||||||
(get_free_glue ty (mctrl = MEM_gc) curr_iso)
|
(get_free_glue ty (mctrl = MEM_gc) curr_iso)
|
||||||
ty_params cell;
|
ty_params
|
||||||
|
[| cell |]
|
||||||
|
None;
|
||||||
|
|
||||||
(* Null the slot out to prevent double-free if the frame
|
(* Null the slot out to prevent double-free if the frame
|
||||||
* unwinds.
|
* unwinds.
|
||||||
|
@ -2603,7 +2633,7 @@ let trans_visitor
|
||||||
trans_call_static_glue
|
trans_call_static_glue
|
||||||
(code_fixup_to_ptr_operand glue_fix)
|
(code_fixup_to_ptr_operand glue_fix)
|
||||||
(Some dst)
|
(Some dst)
|
||||||
[| alias ty_params; src; clone_task |]
|
[| alias ty_params; src; clone_task |] None
|
||||||
| _ ->
|
| _ ->
|
||||||
iter_ty_parts_full ty_params dst src ty
|
iter_ty_parts_full ty_params dst src ty
|
||||||
(clone_ty ty_params clone_task) curr_iso
|
(clone_ty ty_params clone_task) curr_iso
|
||||||
|
@ -2640,7 +2670,10 @@ let trans_visitor
|
||||||
lea vr body_mem;
|
lea vr body_mem;
|
||||||
trace_word cx.ctxt_sess.Session.sess_trace_drop vr;
|
trace_word cx.ctxt_sess.Session.sess_trace_drop vr;
|
||||||
trans_call_simple_static_glue
|
trans_call_simple_static_glue
|
||||||
(get_drop_glue body_ty curr_iso) ty_params vr;
|
(get_drop_glue body_ty curr_iso)
|
||||||
|
ty_params
|
||||||
|
[| vr |]
|
||||||
|
None;
|
||||||
note_drop_step ty "in free-ty, calling free";
|
note_drop_step ty "in free-ty, calling free";
|
||||||
trans_free cell is_gc;
|
trans_free cell is_gc;
|
||||||
end;
|
end;
|
||||||
|
@ -2700,7 +2733,9 @@ let trans_visitor
|
||||||
lea tmp body_mem;
|
lea tmp body_mem;
|
||||||
trans_call_simple_static_glue
|
trans_call_simple_static_glue
|
||||||
(get_mark_glue ty curr_iso)
|
(get_mark_glue ty curr_iso)
|
||||||
ty_params tmp;
|
ty_params
|
||||||
|
[| tmp |]
|
||||||
|
None;
|
||||||
List.iter patch marked_jump;
|
List.iter patch marked_jump;
|
||||||
|
|
||||||
| MEM_interior when type_is_structured ty ->
|
| MEM_interior when type_is_structured ty ->
|
||||||
|
@ -2714,7 +2749,9 @@ let trans_visitor
|
||||||
lea tmp mem;
|
lea tmp mem;
|
||||||
trans_call_simple_static_glue
|
trans_call_simple_static_glue
|
||||||
(get_mark_glue ty curr_iso)
|
(get_mark_glue ty curr_iso)
|
||||||
ty_params tmp
|
ty_params
|
||||||
|
[| tmp |]
|
||||||
|
None
|
||||||
|
|
||||||
| _ -> ()
|
| _ -> ()
|
||||||
|
|
||||||
|
@ -3033,7 +3070,9 @@ let trans_visitor
|
||||||
let ty_params_ptr = get_tydesc_params ty_params td in
|
let ty_params_ptr = get_tydesc_params ty_params td in
|
||||||
trans_call_dynamic_glue
|
trans_call_dynamic_glue
|
||||||
td Abi.tydesc_field_copy_glue
|
td Abi.tydesc_field_copy_glue
|
||||||
(Some dst) [| ty_params_ptr; src; |]
|
(Some dst)
|
||||||
|
[| ty_params_ptr; src; |]
|
||||||
|
None
|
||||||
end
|
end
|
||||||
|
|
||||||
| Ast.TY_fn _
|
| Ast.TY_fn _
|
||||||
|
@ -4090,7 +4129,11 @@ let trans_visitor
|
||||||
let fp = get_iter_outer_frame_ptr_for_current_frame () in
|
let fp = get_iter_outer_frame_ptr_for_current_frame () in
|
||||||
let vr = next_vreg_cell Il.voidptr_t in
|
let vr = next_vreg_cell Il.voidptr_t in
|
||||||
mov vr zero;
|
mov vr zero;
|
||||||
trans_call_glue (code_of_operand block_fptr) None [| vr; fp |]
|
trans_call_glue
|
||||||
|
(code_of_operand block_fptr)
|
||||||
|
None
|
||||||
|
[| vr; fp |]
|
||||||
|
None
|
||||||
|
|
||||||
and trans_vec_append dst_cell dst_ty src_oper src_ty =
|
and trans_vec_append dst_cell dst_ty src_oper src_ty =
|
||||||
let elt_ty = seq_unit_ty dst_ty in
|
let elt_ty = seq_unit_ty dst_ty in
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue