aboutsummaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
authorRoy Frostig <[email protected]>2010-08-09 15:45:08 -0700
committerRoy Frostig <[email protected]>2010-08-09 15:45:08 -0700
commit982dcc29bf6cd41e967a0befe0c6195811cd6a55 (patch)
tree5973524a65f4a2095b75b63c8d72b2b3804ddd6a /src/boot
parentXFailed some tests. (diff)
downloadrust-982dcc29bf6cd41e967a0befe0c6195811cd6a55.tar.xz
rust-982dcc29bf6cd41e967a0befe0c6195811cd6a55.zip
Get object's captured typarams when calculating sizes in the backend's fn-prologue-generation for object methods.
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/be/abi.ml3
-rw-r--r--src/boot/be/il.ml7
-rw-r--r--src/boot/be/x86.ml61
-rw-r--r--src/boot/me/dwarf.ml4
-rw-r--r--src/boot/me/layout.ml8
-rw-r--r--src/boot/me/semant.ml69
-rw-r--r--src/boot/me/trans.ml67
7 files changed, 139 insertions, 80 deletions
diff --git a/src/boot/be/abi.ml b/src/boot/be/abi.ml
index dc28c270..5bdf21fa 100644
--- a/src/boot/be/abi.ml
+++ b/src/boot/be/abi.ml
@@ -121,7 +121,8 @@ type abi =
-> Common.size (* callsz *)
-> Common.nabi
-> Common.fixup (* grow_task *)
- -> unit);
+ -> bool (* is_obj_fn *)
+ -> unit);
abi_emit_fn_epilogue: (Il.emitter -> unit);
diff --git a/src/boot/be/il.ml b/src/boot/be/il.ml
index 172d8661..2a5b643a 100644
--- a/src/boot/be/il.ml
+++ b/src/boot/be/il.ml
@@ -901,6 +901,13 @@ let get_element_ptr
(string_of_cell fmt mem_cell)
;;
+let ptr_cast (cell:cell) (rty:referent_ty) : cell =
+ match cell with
+ Mem (mem, _) -> Mem (mem, rty)
+ | Reg (reg, AddrTy _) -> Reg (reg, AddrTy rty)
+ | _ -> bug () "expected address cell in Il.ptr_cast"
+;;
+
(*
* Local Variables:
* fill-column: 78;
diff --git a/src/boot/be/x86.ml b/src/boot/be/x86.ml
index 55b101bb..826127a0 100644
--- a/src/boot/be/x86.ml
+++ b/src/boot/be/x86.ml
@@ -593,6 +593,7 @@ let restore_frame_base (e:Il.emitter) (base:Il.reg) (retpc:Il.reg) : unit =
*
* *ebp+20+(4*N) = [argN ]
* ...
+ * *ebp+28 = [arg2 ] = obj/closure ptr
* *ebp+24 = [arg1 ] = task ptr
* *ebp+20 = [arg0 ] = out ptr
* *ebp+16 = [retpc ]
@@ -1033,7 +1034,7 @@ let unwind_glue
(* Puts result in eax; clobbers ecx, edx in the process. *)
-let rec calculate_sz (e:Il.emitter) (size:size) : unit =
+let rec calculate_sz (e:Il.emitter) (size:size) (in_obj:bool) : unit =
let emit = Il.emit e in
let mov dst src = emit (Il.umov dst src) in
let push x = emit (Il.Push x) in
@@ -1045,11 +1046,48 @@ let rec calculate_sz (e:Il.emitter) (size:size) : unit =
let mul x y = emit (Il.binary Il.UMUL (rc x) (ro x) (ro y)) in
let subi x y = emit (Il.binary Il.SUB (rc x) (ro x) (immi y)) in
let eax_gets_a_and_ecx_gets_b a b =
- calculate_sz e b;
+ calculate_sz e b in_obj;
push (ro eax);
- calculate_sz e a;
+ calculate_sz e a in_obj;
pop (rc ecx);
in
+
+ let ty_param_n_in_obj_fn i =
+ (*
+ * Here we are trying to immitate the obj-fn branch of
+ * Trans.get_ty_params_of_current_frame while using
+ * eax as our only register.
+ *)
+
+ (* Bind all the referent types we'll need... *)
+
+ let obj_body_rty = Semant.obj_closure_rty word_bits in
+ let tydesc_rty = Semant.tydesc_rty word_bits in
+ (* Note that we cheat here and pretend only to have i+1 tydescs (because
+ we GEP to the i'th while still in this function, so no one outside
+ finds out about the lie. *)
+ let tydesc_tys = Array.init (i + 1) (fun _ -> Ast.TY_type) in
+ let ty_params_ty = Ast.TY_tup tydesc_tys in
+ let ty_params_rty = Semant.referent_type word_bits ty_params_ty in
+
+ (* ... and fetch! *)
+
+ mov (rc eax) (Il.Cell closure_ptr);
+ let obj_body = word_n (h eax) Abi.box_rc_field_body in
+ let obj_body = Il.ptr_cast obj_body obj_body_rty in
+ let tydesc_ptr = get_element_ptr obj_body Abi.obj_body_elt_tydesc in
+
+ mov (rc eax) (Il.Cell tydesc_ptr);
+ let tydesc = Il.ptr_cast (word_at (h eax)) tydesc_rty in
+ let ty_params_ptr =
+ get_element_ptr tydesc Abi.tydesc_field_first_param
+ in
+
+ mov (rc eax) (Il.Cell ty_params_ptr);
+ let ty_params = Il.ptr_cast (word_at (h eax)) ty_params_rty in
+ get_element_ptr ty_params i
+ in
+
match size with
SIZE_fixed i ->
mov (rc eax) (immi i)
@@ -1061,15 +1099,23 @@ let rec calculate_sz (e:Il.emitter) (size:size) : unit =
mov (rc eax) (imm (Asm.M_POS f))
| SIZE_param_size i ->
- mov (rc eax) (Il.Cell (ty_param_n i));
+ if in_obj
+ then
+ mov (rc eax) (Il.Cell (ty_param_n_in_obj_fn i))
+ else
+ mov (rc eax) (Il.Cell (ty_param_n i));
mov (rc eax) (Il.Cell (word_n (h eax) Abi.tydesc_field_size))
| SIZE_param_align i ->
- mov (rc eax) (Il.Cell (ty_param_n i));
+ if in_obj
+ then
+ mov (rc eax) (Il.Cell (ty_param_n_in_obj_fn i))
+ else
+ mov (rc eax) (Il.Cell (ty_param_n i));
mov (rc eax) (Il.Cell (word_n (h eax) Abi.tydesc_field_align))
| SIZE_rt_neg a ->
- calculate_sz e a;
+ calculate_sz e a in_obj;
neg eax
| SIZE_rt_add (a, b) ->
@@ -1185,6 +1231,7 @@ let fn_prologue
(callsz:size)
(nabi:nabi)
(grow_task_fixup:fixup)
+ (is_obj_fn:bool)
: unit =
let esi_n = word_n (h esi) in
@@ -1314,7 +1361,7 @@ let fn_prologue
emit (Il.jmp Il.JA Il.CodeNone);
(* Calculate dynamic frame size. *)
- calculate_sz e call_and_frame_sz;
+ calculate_sz e call_and_frame_sz is_obj_fn;
((ro eax), Some primordial_underflow_jmp_pc)
end
| Some e -> ((imm e), None)
diff --git a/src/boot/me/dwarf.ml b/src/boot/me/dwarf.ml
index d3fb81de..0ec7af78 100644
--- a/src/boot/me/dwarf.ml
+++ b/src/boot/me/dwarf.ml
@@ -1677,7 +1677,7 @@ let dwarf_visitor
in
let record trec =
- let rty = referent_type abi (Ast.TY_rec trec) in
+ let rty = referent_type word_bits (Ast.TY_rec trec) in
let rty_sz = Il.referent_ty_size abi.Abi.abi_word_bits in
let fix = new_fixup "record type DIE" in
let die = DEF (fix, SEQ [|
@@ -1926,7 +1926,7 @@ let dwarf_visitor
* I'm a bit surprised by that!
*)
- let rty = referent_type abi (Ast.TY_tag ttag) in
+ let rty = referent_type word_bits (Ast.TY_tag ttag) in
let rty_sz = Il.referent_ty_size abi.Abi.abi_word_bits in
let rtys =
match rty with
diff --git a/src/boot/me/layout.ml b/src/boot/me/layout.ml
index a9358795..6464a8f7 100644
--- a/src/boot/me/layout.ml
+++ b/src/boot/me/layout.ml
@@ -113,7 +113,7 @@ let layout_visitor
| Il.CodeTy -> true
| Il.NilTy -> false
in
- rt_in_mem (slot_referent_type cx.ctxt_abi slot)
+ rt_in_mem (slot_referent_type cx.ctxt_abi.Abi.abi_word_bits slot)
in
let rty_sz rty = Il.referent_ty_size cx.ctxt_abi.Abi.abi_word_bits rty in
@@ -142,7 +142,7 @@ let layout_visitor
: unit =
let accum (off,align) id : (size * size) =
let slot = get_slot cx id in
- let rt = slot_referent_type cx.ctxt_abi slot in
+ let rt = slot_referent_type cx.ctxt_abi.Abi.abi_word_bits slot in
let (elt_size, elt_align) = rty_layout rt in
if vregs_ok
&& (is_subword_size elt_size)
@@ -170,7 +170,9 @@ let layout_visitor
then elt_off
else neg_sz (add_sz elt_off elt_size)
in
- Stack.push (slot_referent_type cx.ctxt_abi slot) slot_accum;
+ Stack.push
+ (slot_referent_type cx.ctxt_abi.Abi.abi_word_bits slot)
+ slot_accum;
iflog
begin
fun _ ->
diff --git a/src/boot/me/semant.ml b/src/boot/me/semant.ml
index bcaec2b4..a3a8abdf 100644
--- a/src/boot/me/semant.ml
+++ b/src/boot/me/semant.ml
@@ -1822,24 +1822,24 @@ let run_passes
(* Rust type -> IL type conversion. *)
-let word_sty (abi:Abi.abi) : Il.scalar_ty =
- Il.ValTy abi.Abi.abi_word_bits
+let word_sty (word_bits:Il.bits) : Il.scalar_ty =
+ Il.ValTy word_bits
;;
-let word_rty (abi:Abi.abi) : Il.referent_ty =
- Il.ScalarTy (word_sty abi)
+let word_rty (word_bits:Il.bits) : Il.referent_ty =
+ Il.ScalarTy (word_sty word_bits)
;;
-let tydesc_rty (abi:Abi.abi) : Il.referent_ty =
+let tydesc_rty (word_bits:Il.bits) : Il.referent_ty =
(*
* NB: must match corresponding tydesc structure
* in trans and offsets in ABI exactly.
*)
Il.StructTy
[|
- word_rty abi; (* Abi.tydesc_field_first_param *)
- word_rty abi; (* Abi.tydesc_field_size *)
- word_rty abi; (* Abi.tydesc_field_align *)
+ word_rty word_bits; (* Abi.tydesc_field_first_param *)
+ word_rty word_bits; (* Abi.tydesc_field_size *)
+ word_rty word_bits; (* Abi.tydesc_field_align *)
Il.ScalarTy (Il.AddrTy Il.CodeTy); (* Abi.tydesc_field_copy_glue *)
Il.ScalarTy (Il.AddrTy Il.CodeTy); (* Abi.tydesc_field_drop_glue *)
Il.ScalarTy (Il.AddrTy Il.CodeTy); (* Abi.tydesc_field_free_glue *)
@@ -1849,29 +1849,29 @@ let tydesc_rty (abi:Abi.abi) : Il.referent_ty =
|]
;;
-let obj_closure_rty (abi:Abi.abi) : Il.referent_ty =
+let obj_closure_rty (word_bits:Il.bits) : Il.referent_ty =
Il.StructTy [|
- word_rty abi;
+ word_rty word_bits;
Il.StructTy [|
- Il.ScalarTy (Il.AddrTy (tydesc_rty abi));
- word_rty abi (* A lie: it's opaque, but this permits
- * GEP'ing to it. *)
+ Il.ScalarTy (Il.AddrTy (tydesc_rty word_bits));
+ word_rty word_bits (* A lie: it's opaque, but this permits
+ * GEP'ing to it. *)
|]
|]
;;
-let rec referent_type (abi:Abi.abi) (t:Ast.ty) : Il.referent_ty =
+let rec referent_type (word_bits:Il.bits) (t:Ast.ty) : Il.referent_ty =
let s t = Il.ScalarTy t in
let v b = Il.ValTy b in
let p t = Il.AddrTy t in
let sv b = s (v b) in
let sp t = s (p t) in
- let word = word_rty abi in
+ let word = word_rty word_bits in
let ptr = sp Il.OpaqueTy in
let rc_ptr = sp (Il.StructTy [| word; Il.OpaqueTy |]) in
let codeptr = sp Il.CodeTy in
- let tup ttup = Il.StructTy (Array.map (referent_type abi) ttup) in
+ let tup ttup = Il.StructTy (Array.map (referent_type word_bits) ttup) in
let tag ttag =
let union =
Il.UnionTy
@@ -1916,7 +1916,7 @@ let rec referent_type (abi:Abi.abi) (t:Ast.ty) : Il.referent_ty =
Il.StructTy [| codeptr; fn_closure_ptr |]
| Ast.TY_obj _ ->
- let obj_closure_ptr = sp (obj_closure_rty abi) in
+ let obj_closure_ptr = sp (obj_closure_rty word_bits) in
Il.StructTy [| ptr; obj_closure_ptr |]
| Ast.TY_tag ttag -> tag ttag
@@ -1928,26 +1928,26 @@ let rec referent_type (abi:Abi.abi) (t:Ast.ty) : Il.referent_ty =
| Ast.TY_port _
| Ast.TY_task -> rc_ptr
- | Ast.TY_type -> sp (tydesc_rty abi)
+ | Ast.TY_type -> sp (tydesc_rty word_bits)
| Ast.TY_native _ -> ptr
| Ast.TY_box t ->
- sp (Il.StructTy [| word; referent_type abi t |])
+ sp (Il.StructTy [| word; referent_type word_bits t |])
- | Ast.TY_mutable t -> referent_type abi t
+ | Ast.TY_mutable t -> referent_type word_bits t
| Ast.TY_param (i, _) -> Il.ParamTy i
| Ast.TY_named _ -> bug () "named type in referent_type"
- | Ast.TY_constrained (t, _) -> referent_type abi t
+ | Ast.TY_constrained (t, _) -> referent_type word_bits t
-and slot_referent_type (abi:Abi.abi) (sl:Ast.slot) : Il.referent_ty =
+and slot_referent_type (word_bits:Il.bits) (sl:Ast.slot) : Il.referent_ty =
let s t = Il.ScalarTy t in
let p t = Il.AddrTy t in
let sp t = s (p t) in
- let rty = referent_type abi (slot_ty sl) in
+ let rty = referent_type word_bits (slot_ty sl) in
match sl.Ast.slot_mode with
| Ast.MODE_local -> rty
| Ast.MODE_alias -> sp rty
@@ -1958,7 +1958,7 @@ let task_rty (abi:Abi.abi) : Il.referent_ty =
begin
Array.init
Abi.n_visible_task_fields
- (fun _ -> word_rty abi)
+ (fun _ -> word_rty abi.Abi.abi_word_bits)
end
;;
@@ -1970,14 +1970,17 @@ let call_args_referent_type_full
(iterator_arg_rtys:Il.referent_ty array)
(indirect_arg_rtys:Il.referent_ty array)
: Il.referent_ty =
- let out_slot_rty = slot_referent_type abi out_slot in
+ let out_slot_rty = slot_referent_type abi.Abi.abi_word_bits out_slot in
let out_ptr_rty = Il.ScalarTy (Il.AddrTy out_slot_rty) in
let task_ptr_rty = Il.ScalarTy (Il.AddrTy (task_rty abi)) in
let ty_param_rtys =
- let td = Il.ScalarTy (Il.AddrTy (tydesc_rty abi)) in
+ let td = Il.ScalarTy (Il.AddrTy (tydesc_rty abi.Abi.abi_word_bits)) in
Il.StructTy (Array.init n_ty_params (fun _ -> td))
in
- let arg_rtys = Il.StructTy (Array.map (slot_referent_type abi) in_slots) in
+ let arg_rtys =
+ Il.StructTy
+ (Array.map (slot_referent_type abi.Abi.abi_word_bits) in_slots)
+ in
(*
* NB: must match corresponding calltup structure in trans and
* member indices in ABI exactly.
@@ -2003,7 +2006,7 @@ let call_args_referent_type
(* Abi.indirect_args_elt_closure *)
match closure with
None ->
- [| word_rty cx.ctxt_abi |]
+ [| word_rty cx.ctxt_abi.Abi.abi_word_bits |]
| Some c ->
[| Il.ScalarTy (Il.AddrTy c) |]
in
@@ -2057,16 +2060,18 @@ let direct_call_args_referent_type
;;
let ty_sz (abi:Abi.abi) (t:Ast.ty) : int64 =
- force_sz (Il.referent_ty_size abi.Abi.abi_word_bits (referent_type abi t))
+ let wb = abi.Abi.abi_word_bits in
+ force_sz (Il.referent_ty_size wb (referent_type wb t))
;;
let ty_align (abi:Abi.abi) (t:Ast.ty) : int64 =
- force_sz (Il.referent_ty_align abi.Abi.abi_word_bits (referent_type abi t))
+ let wb = abi.Abi.abi_word_bits in
+ force_sz (Il.referent_ty_align wb (referent_type wb t))
;;
let slot_sz (abi:Abi.abi) (s:Ast.slot) : int64 =
- force_sz (Il.referent_ty_size abi.Abi.abi_word_bits
- (slot_referent_type abi s))
+ let wb = abi.Abi.abi_word_bits in
+ force_sz (Il.referent_ty_size wb (slot_referent_type wb s))
;;
let word_slot (abi:Abi.abi) : Ast.slot =
diff --git a/src/boot/me/trans.ml b/src/boot/me/trans.ml
index 97dce2b2..67e81c84 100644
--- a/src/boot/me/trans.ml
+++ b/src/boot/me/trans.ml
@@ -292,7 +292,7 @@ let trans_visitor
in
let ptr_at (mem:Il.mem) (pointee_ty:Ast.ty) : Il.cell =
- rty_ptr_at mem (referent_type abi pointee_ty)
+ rty_ptr_at mem (referent_type word_bits pointee_ty)
in
let need_scalar_ty (rty:Il.referent_ty) : Il.scalar_ty =
@@ -330,11 +330,7 @@ let trans_visitor
(cell_str mem_cell)
in
- let rec ptr_cast (cell:Il.cell) (rty:Il.referent_ty) : Il.cell =
- match cell with
- Il.Mem (mem, _) -> Il.Mem (mem, rty)
- | Il.Reg (reg, Il.AddrTy _) -> Il.Reg (reg, Il.AddrTy rty)
- | _ -> bug () "expected address cell in Trans.ptr_cast"
+ let rec ptr_cast = Il.ptr_cast
and curr_crate_ptr _ : Il.cell =
word_at (fp_imm frame_crate_ptr)
@@ -453,7 +449,7 @@ let trans_visitor
in
let slot_id_referent_type (slot_id:node_id) : Il.referent_ty =
- slot_referent_type abi (get_slot cx slot_id)
+ slot_referent_type word_bits (get_slot cx slot_id)
in
let caller_args_cell (args_rty:Il.referent_ty) : Il.cell =
@@ -523,7 +519,7 @@ let trans_visitor
let get_obj_for_current_frame _ =
deref (ptr_cast
(get_closure_for_current_frame ())
- (Il.ScalarTy (Il.AddrTy (obj_closure_rty abi))))
+ (Il.ScalarTy (Il.AddrTy (obj_closure_rty word_bits))))
in
let get_ty_params_of_current_frame _ : Il.cell =
@@ -536,7 +532,7 @@ let trans_visitor
let obj = get_element_ptr obj_box Abi.box_rc_field_body in
let tydesc = get_element_ptr obj Abi.obj_body_elt_tydesc in
let ty_params_ty = Ast.TY_tup (make_tydesc_tys n_ty_params) in
- let ty_params_rty = referent_type abi ty_params_ty in
+ let ty_params_rty = referent_type word_bits ty_params_ty in
let ty_params =
get_element_ptr (deref tydesc) Abi.tydesc_field_first_param
in
@@ -721,7 +717,7 @@ let trans_visitor
in
let ty_sz_in_current_frame (ty:Ast.ty) : Il.operand =
- let rty = referent_type abi ty in
+ let rty = referent_type word_bits ty in
let sz = Il.referent_ty_size word_bits rty in
calculate_sz_in_current_frame sz
in
@@ -730,7 +726,7 @@ let trans_visitor
(ty_params:Il.cell)
(ty:Ast.ty)
: Il.operand =
- let rty = referent_type abi ty in
+ let rty = referent_type word_bits ty in
let sz = Il.referent_ty_size word_bits rty in
calculate_sz ty_params sz
in
@@ -931,7 +927,7 @@ let trans_visitor
mov idx atop;
emit (Il.binary Il.UMUL idx (Il.Cell idx) unit_sz);
let elt_mem = trans_bounds_check (deref cell) (Il.Cell idx) in
- (Il.Mem (elt_mem, referent_type abi ty), ty)
+ (Il.Mem (elt_mem, referent_type word_bits ty), ty)
in
(*
* All lval components aside from explicit-deref just auto-deref
@@ -1120,7 +1116,7 @@ let trans_visitor
and trans_static_string (s:string) : Il.operand =
Il.Cell (crate_rel_to_ptr
(trans_crate_rel_static_string_operand s)
- (referent_type abi Ast.TY_str))
+ (referent_type word_bits Ast.TY_str))
and get_static_tydesc
(idopt:node_id option)
@@ -1226,7 +1222,7 @@ let trans_visitor
let fty = Hashtbl.find (snd caller) ident in
let self_args_rty =
call_args_referent_type cx 0
- (Ast.TY_fn fty) (Some (obj_closure_rty abi))
+ (Ast.TY_fn fty) (Some (obj_closure_rty word_bits))
in
let callsz = Il.referent_ty_size word_bits self_args_rty in
let spill = new_fixup "forwarding fn spill" in
@@ -1394,7 +1390,7 @@ let trans_visitor
push_new_emitter_with_vregs None;
iflog (fun _ -> annotate "prologue");
abi.Abi.abi_emit_fn_prologue (emitter())
- framesz callsz nabi_rust (upcall_fixup "upcall_grow_task");
+ framesz callsz nabi_rust (upcall_fixup "upcall_grow_task") false;
write_frame_info_ptrs None;
(* FIXME: not clear why, but checking interrupt in glue context
* causes many.rs to crash when run on a sufficiently large number
@@ -1473,8 +1469,8 @@ let trans_visitor
(* FIXME (issue #5): mutability flag *)
: Il.referent_ty =
let rc = Il.ScalarTy word_sty in
- let targ = referent_type abi (mk_simple_ty_fn [||]) in
- let bindings = Array.map (slot_referent_type abi) bs in
+ let targ = referent_type word_bits (mk_simple_ty_fn [||]) in
+ let bindings = Array.map (slot_referent_type word_bits) bs in
Il.StructTy [| rc; targ; Il.StructTy bindings |]
(* FIXME (issue #2): this should eventually use tail calling logic *)
@@ -2331,7 +2327,7 @@ let trans_visitor
(get_element_ptr_dyn_in_current_frame
vec Abi.vec_elt_data))
in
- let unit_rty = referent_type abi unit_ty in
+ let unit_rty = referent_type word_bits unit_ty in
let body_rty = Il.StructTy (Array.map (fun _ -> unit_rty) atoms) in
let body = Il.Mem (body_mem, body_rty) in
Array.iteri
@@ -2377,12 +2373,12 @@ let trans_visitor
let root_desc =
Il.Cell (crate_rel_to_ptr
(get_static_tydesc idopt t 0L 0L force_stateful)
- (tydesc_rty abi))
+ (tydesc_rty word_bits))
in
let (t, param_descs) = linearize_ty_params t in
let descs = Array.append [| root_desc |] param_descs in
let n = Array.length descs in
- let rty = referent_type abi t in
+ let rty = referent_type word_bits t in
let (size_sz, align_sz) = Il.referent_ty_layout word_bits rty in
let size = calculate_sz_in_current_frame size_sz in
let align = calculate_sz_in_current_frame align_sz in
@@ -2418,7 +2414,7 @@ let trans_visitor
(ty_sz abi ty)
(ty_align abi ty)
mut)
- (tydesc_rty abi))
+ (tydesc_rty word_bits))
and box_rc_cell (cell:Il.cell) : Il.cell =
get_element_ptr (deref cell) Abi.box_rc_field_refcnt
@@ -2435,7 +2431,7 @@ let trans_visitor
in
let ty = simplified_ty ty in
let refty_sz =
- Il.referent_ty_size abi.Abi.abi_word_bits (referent_type abi ty)
+ Il.referent_ty_size abi.Abi.abi_word_bits (referent_type word_bits ty)
in
match refty_sz with
SIZE_fixed _ -> imm (Int64.add (ty_sz abi ty) header_sz)
@@ -2532,7 +2528,7 @@ let trans_visitor
trans_compare_simple Il.JAE (Il.Cell ptr) (Il.Cell lim)
in
let unit_cell =
- deref (ptr_cast ptr (referent_type abi unit_ty))
+ deref (ptr_cast ptr (referent_type word_bits unit_ty))
in
f unit_cell unit_cell unit_ty curr_iso;
add_to ptr unit_sz;
@@ -4310,7 +4306,7 @@ let trans_visitor
push_new_emitter_with_vregs (Some id);
iflog (fun _ -> annotate "prologue");
abi.Abi.abi_emit_fn_prologue (emitter())
- framesz callsz nabi_rust (upcall_fixup "upcall_grow_task");
+ framesz callsz nabi_rust (upcall_fixup "upcall_grow_task") false;
write_frame_info_ptrs None;
iflog (fun _ -> annotate "finished prologue");
trans_block fe.Ast.for_each_body;
@@ -4394,7 +4390,7 @@ let trans_visitor
let dst_fill = get_element_ptr dst_vec Abi.vec_elt_fill in
(* Copy loop: *)
- let eltp_rty = Il.AddrTy (referent_type abi elt_ty) in
+ let eltp_rty = Il.AddrTy (referent_type word_bits elt_ty) in
let dptr = next_vreg_cell eltp_rty in
let sptr = next_vreg_cell eltp_rty in
let dlim = next_vreg_cell eltp_rty in
@@ -4771,7 +4767,7 @@ let trans_visitor
end
in
- let trans_frame_entry (fnid:node_id) : unit =
+ let trans_frame_entry (fnid:node_id) (obj_fn:bool) : unit =
let framesz = get_framesz cx fnid in
let callsz = get_callsz cx fnid in
Stack.push (Stack.create()) epilogue_jumps;
@@ -4785,7 +4781,7 @@ let trans_visitor
(string_of_size callsz)));
abi.Abi.abi_emit_fn_prologue
(emitter()) framesz callsz nabi_rust
- (upcall_fixup "upcall_grow_task");
+ (upcall_fixup "upcall_grow_task") obj_fn;
write_frame_info_ptrs (Some fnid);
check_interrupt_flag ();
@@ -4809,8 +4805,9 @@ let trans_visitor
let trans_fn
(fnid:node_id)
(body:Ast.block)
+ (obj_fn:bool)
: unit =
- trans_frame_entry fnid;
+ trans_frame_entry fnid obj_fn;
trans_block body;
trans_frame_exit fnid true;
in
@@ -4819,7 +4816,7 @@ let trans_visitor
(obj_id:node_id)
(header:Ast.header_slots)
: unit =
- trans_frame_entry obj_id;
+ trans_frame_entry obj_id true;
let all_args_rty = current_fn_args_rty None in
let all_args_cell = caller_args_cell all_args_rty in
@@ -4838,7 +4835,7 @@ let trans_visitor
let obj_args_ty = Ast.TY_tup obj_args_tup in
let state_ty = Ast.TY_tup [| Ast.TY_type; obj_args_ty |] in
let state_ptr_ty = Ast.TY_box state_ty in
- let state_ptr_rty = referent_type abi state_ptr_ty in
+ let state_ptr_rty = referent_type word_bits state_ptr_ty in
let state_malloc_sz = box_allocation_size state_ptr_ty in
let ctor_ty = Hashtbl.find cx.ctxt_all_item_types obj_id in
@@ -4940,7 +4937,7 @@ let trans_visitor
in
let trans_required_fn (fnid:node_id) (blockid:node_id) : unit =
- trans_frame_entry fnid;
+ trans_frame_entry fnid false;
emit (Il.Enter (Hashtbl.find cx.ctxt_block_fixups blockid));
let (ilib, conv) = Hashtbl.find cx.ctxt_required_items fnid in
let lib_num =
@@ -5078,7 +5075,7 @@ let trans_visitor
(tagid:node_id)
(tag:(Ast.header_tup * Ast.ty_tag * node_id))
: unit =
- trans_frame_entry tagid;
+ trans_frame_entry tagid false;
trace_str cx.ctxt_sess.Session.sess_trace_tag
("in tag constructor " ^ n);
let (header_tup, _, _) = tag in
@@ -5141,7 +5138,7 @@ let trans_visitor
iflog (fun _ -> log cx "translating defined item #%d = %s"
(int_of_node i.id) (path_name()));
match i.node.Ast.decl_item with
- Ast.MOD_ITEM_fn f -> trans_fn i.id f.Ast.fn_body
+ Ast.MOD_ITEM_fn f -> trans_fn i.id f.Ast.fn_body false
| Ast.MOD_ITEM_tag t -> trans_tag n i.id t
| Ast.MOD_ITEM_obj ob ->
trans_obj_ctor i.id
@@ -5175,7 +5172,7 @@ let trans_visitor
push_new_emitter_with_vregs (Some b.id);
iflog (fun _ -> annotate "prologue");
abi.Abi.abi_emit_fn_prologue (emitter())
- framesz callsz nabi_rust (upcall_fixup "upcall_grow_task");
+ framesz callsz nabi_rust (upcall_fixup "upcall_grow_task") true;
write_frame_info_ptrs None;
iflog (fun _ -> annotate "finished prologue");
trans_block b;
@@ -5185,7 +5182,7 @@ let trans_visitor
in
let visit_defined_obj_fn_pre _ _ fn =
- trans_fn fn.id fn.node.Ast.fn_body
+ trans_fn fn.id fn.node.Ast.fn_body true
in
let visit_required_obj_fn_pre _ _ _ =