aboutsummaryrefslogtreecommitdiff
path: root/src/boot/be
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-10-05 18:09:49 -0700
committerGraydon Hoare <[email protected]>2010-10-05 18:09:49 -0700
commitcdf67b1f2e34ceb27a922cde7edc526597200b96 (patch)
tree828af70a52db9bd6e902010b408e18b862064023 /src/boot/be
parentUse RTLD_GLOBAL when loading libraries. This is needed to get LLVM working on... (diff)
downloadrust-cdf67b1f2e34ceb27a922cde7edc526597200b96.tar.xz
rust-cdf67b1f2e34ceb27a922cde7edc526597200b96.zip
Better backpointer logic.
Diffstat (limited to 'src/boot/be')
-rw-r--r--src/boot/be/il.ml13
-rw-r--r--src/boot/be/x86.ml6
2 files changed, 15 insertions, 4 deletions
diff --git a/src/boot/be/il.ml b/src/boot/be/il.ml
index 0e13b4c0..0888f8e8 100644
--- a/src/boot/be/il.ml
+++ b/src/boot/be/il.ml
@@ -903,9 +903,20 @@ let get_element_ptr
(string_of_cell fmt mem_cell)
;;
-let ptr_cast (cell:cell) (rty:referent_ty) : cell =
+let cell_cast (cell:cell) (rty:referent_ty) : cell =
match cell with
Mem (mem, _) -> Mem (mem, rty)
+ | Reg (reg, _) ->
+ begin
+ match rty with
+ ScalarTy st -> Reg (reg, st)
+ | _ -> bug () "expected scalar type in Il.cell_cast on register"
+ end
+
+
+let ptr_cast (cell:cell) (rty:referent_ty) : cell =
+ match cell with
+ Mem (mem, ScalarTy (AddrTy _)) -> Mem (mem, ScalarTy (AddrTy rty))
| Reg (reg, AddrTy _) -> Reg (reg, AddrTy rty)
| _ -> bug () "expected address cell in Il.ptr_cast"
;;
diff --git a/src/boot/be/x86.ml b/src/boot/be/x86.ml
index eb96d0ac..468d1ab1 100644
--- a/src/boot/be/x86.ml
+++ b/src/boot/be/x86.ml
@@ -1078,17 +1078,17 @@ let rec calculate_sz
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_box_rty in
+ let obj_body = Il.cell_cast obj_body obj_box_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 tydesc = Il.cell_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
+ let ty_params = Il.cell_cast (word_at (h eax)) ty_params_rty in
get_element_ptr ty_params i
in