When translating vec-append, delay destination string's null-byte-accounting length decrement until the destination string has already been resized. Closes #163.

This commit is contained in:
Roy Frostig 2010-09-20 17:26:24 -07:00
parent 7ab3b305e4
commit 3c3421e01d

View file

@ -4612,11 +4612,6 @@ let trans_visitor
let src_cell = need_cell src_oper in
let src_vec = deref src_cell in
let src_fill = get_element_ptr src_vec Abi.vec_elt_fill in
let dst_vec = deref dst_cell in
let dst_fill = get_element_ptr dst_vec Abi.vec_elt_fill in
if trailing_null
then sub_from dst_fill (imm 1L);
aliasing true dst_cell
begin
@ -4635,10 +4630,12 @@ let trans_visitor
* to add to.
*)
(* Reload dst vec, fill; might have changed. *)
let dst_vec = deref dst_cell in
let dst_fill = get_element_ptr dst_vec Abi.vec_elt_fill in
if trailing_null
then sub_from dst_fill (imm 1L);
(* Copy loop: *)
let eltp_rty = Il.AddrTy (referent_type cx elt_ty) in
let dptr = next_vreg_cell eltp_rty in
@ -4671,7 +4668,8 @@ let trans_visitor
patch fwd_jmp;
check_interrupt_flag ();
let back_jmp =
trans_compare_simple Il.JB (Il.Cell dptr) (Il.Cell dlim)
trans_compare_simple
Il.JB (Il.Cell dptr) (Il.Cell dlim)
in
List.iter
(fun j -> patch_existing j back_jmp_targ) back_jmp;