Teach severing logic to handle obj and fn types.

This commit is contained in:
Graydon Hoare 2010-07-02 16:12:58 -07:00
parent ec0de963e0
commit 0be19e8a95
1 changed files with 27 additions and 14 deletions

View File

@ -2547,23 +2547,36 @@ let trans_visitor
(curr_iso:Ast.ty_iso option) (curr_iso:Ast.ty_iso option)
: unit = : unit =
let _ = note_gc_step ty "severing" in let _ = note_gc_step ty "severing" in
match ty_mem_ctrl ty with let sever_box c =
MEM_gc -> let _ = check_box_rty c in
let null_jmp = null_check c in
let rc = box_rc_cell c in
let _ = note_gc_step ty "severing GC cell" in
emit (Il.binary Il.SUB rc (Il.Cell rc) one);
mov c zero;
patch null_jmp
in
let _ = check_box_rty cell in match strip_mutable_or_constrained_ty ty with
let null_jmp = null_check cell in Ast.TY_fn _
let rc = box_rc_cell cell in | Ast.TY_obj _ ->
let _ = note_gc_step ty "severing GC slot" in if type_has_state ty
emit (Il.binary Il.SUB rc (Il.Cell rc) one); then
mov cell zero; let binding = get_element_ptr cell Abi.binding_field_binding in
patch null_jmp sever_box binding;
| MEM_interior when type_is_structured ty -> | _ ->
iter_ty_parts ty_params cell ty match ty_mem_ctrl ty with
(sever_ty ty_params) curr_iso MEM_gc ->
sever_box cell
| _ -> () | MEM_interior when type_is_structured ty ->
(* No need to follow links / call glue; severing is shallow. *) iter_ty_parts ty_params cell ty
(sever_ty ty_params) curr_iso
| _ -> ()
(* No need to follow links / call glue; severing is
shallow. *)
and clone_ty and clone_ty
(ty_params:Il.cell) (ty_params:Il.cell)