Skip to content

Commit

Permalink
Fixed the bounds-checking code (to some degree...)
Browse files Browse the repository at this point in the history
  • Loading branch information
colinbenner committed Dec 31, 2011
1 parent f61f94e commit 32153e8
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/asmcomp/llvmcompile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -333,16 +333,14 @@ let rec helper in_tail_position in_try_block instr =
let arr = helper false in_try_block arr in
let index = helper false in_try_block index in
assert (typeof arr <> Void);
let header = getelementptr (cast arr addr_type) (Lconst("-" ^ string_of_int size_addr, int_type)) in
let length = load header in
let cond = comp "icmp ule" (typeof length) index length in
let cond = comp "icmp ule" (typeof index) arr index in
let c = c () in
add_function (addr_type, "ccc", "caml_ml_array_bound_error", []);
Lcomment "checking bounds..."
@@ Lbr_cond(cond, "out_of_bounds" ^ c, "ok" ^ c)
@@ Llabel ("out_of_bounds" ^ c)
@@ call Void (Lvar("@caml_ml_array_bound_error",Any)) []
@@ Lbr ("ok" ^ c)
@@ Lunreachable
@@ Llabel ("ok" ^ c)
| Cop(Ccheckbound _, _) -> error "not implemented: checkound with #args != 2"
| Cop(op, exprs) -> compile_operation in_try_block op exprs
Expand Down

0 comments on commit 32153e8

Please sign in to comment.