When copying function values, null out the destination's binding iff the source's binding is null.
This commit is contained in:
parent
ee04c0236c
commit
8559a85cca
2 changed files with 24 additions and 15 deletions
|
@ -2933,12 +2933,18 @@ let trans_visitor
|
||||||
: unit =
|
: unit =
|
||||||
drop_ty (get_ty_params_of_current_frame()) cell ty None
|
drop_ty (get_ty_params_of_current_frame()) cell ty None
|
||||||
|
|
||||||
|
(* Returns a mark for a jmp that must be patched to the continuation of
|
||||||
|
* the null case (i.e. fall-through means not null).
|
||||||
|
*)
|
||||||
and null_check (cell:Il.cell) : quad_idx =
|
and null_check (cell:Il.cell) : quad_idx =
|
||||||
emit (Il.cmp (Il.Cell cell) zero);
|
emit (Il.cmp (Il.Cell cell) zero);
|
||||||
let j = mark() in
|
let j = mark() in
|
||||||
emit (Il.jmp Il.JE Il.CodeNone);
|
emit (Il.jmp Il.JE Il.CodeNone);
|
||||||
j
|
j
|
||||||
|
|
||||||
|
(* Returns a mark for a jmp that must be patched to the continuation of
|
||||||
|
* the non-zero refcount case (i.e. fall-through means zero refcount).
|
||||||
|
*)
|
||||||
and drop_refcount_and_cmp (boxed:Il.cell) : quad_idx =
|
and drop_refcount_and_cmp (boxed:Il.cell) : quad_idx =
|
||||||
iflog (fun _ -> annotate "drop refcount and maybe free");
|
iflog (fun _ -> annotate "drop refcount and maybe free");
|
||||||
let rc = box_rc_cell boxed in
|
let rc = box_rc_cell boxed in
|
||||||
|
@ -3268,7 +3274,14 @@ let trans_visitor
|
||||||
dst_binding (Ast.TY_box Ast.TY_int)
|
dst_binding (Ast.TY_box Ast.TY_int)
|
||||||
src_binding (Ast.TY_box Ast.TY_int)
|
src_binding (Ast.TY_box Ast.TY_int)
|
||||||
curr_iso;
|
curr_iso;
|
||||||
patch null_jmp
|
let end_jmp = mark() in
|
||||||
|
emit (Il.jmp Il.JMP Il.CodeNone);
|
||||||
|
patch null_jmp;
|
||||||
|
(* The src had a null binding, so make sure the dst
|
||||||
|
* does now too.
|
||||||
|
*)
|
||||||
|
mov dst_binding zero;
|
||||||
|
patch end_jmp
|
||||||
end
|
end
|
||||||
|
|
||||||
| _ ->
|
| _ ->
|
||||||
|
|
|
@ -13,11 +13,8 @@ fn test_simple() {
|
||||||
ret u;
|
ret u;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME we don't really want to bind here but if we don't then the
|
let map.hashfn[uint] hasher = hash;
|
||||||
// hashmap's drop glue UMRs when trying to drop these functions, which
|
let map.eqfn[uint] eqer = eq;
|
||||||
// it stores internally.
|
|
||||||
let map.hashfn[uint] hasher = bind hash(_);
|
|
||||||
let map.eqfn[uint] eqer = bind eq(_, _);
|
|
||||||
let map.hashmap[uint, uint] hm = map.mk_hashmap[uint, uint](hasher, eqer);
|
let map.hashmap[uint, uint] hm = map.mk_hashmap[uint, uint](hasher, eqer);
|
||||||
|
|
||||||
hm.insert(10u, 12u);
|
hm.insert(10u, 12u);
|
||||||
|
@ -43,7 +40,7 @@ fn test_simple() {
|
||||||
fn test_growth() {
|
fn test_growth() {
|
||||||
log "*** starting test_growth";
|
log "*** starting test_growth";
|
||||||
|
|
||||||
let uint map_capacity = 64u; // Keep in sync with map.mk_hashmap
|
let uint num_to_insert = 64u;
|
||||||
|
|
||||||
fn eq(&uint x, &uint y) -> bool { ret x == y; }
|
fn eq(&uint x, &uint y) -> bool { ret x == y; }
|
||||||
fn hash(&uint u) -> uint {
|
fn hash(&uint u) -> uint {
|
||||||
|
@ -52,13 +49,12 @@ fn test_growth() {
|
||||||
ret u;
|
ret u;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: as in test_simple(), don't really want to bind.
|
let map.hashfn[uint] hasher = hash;
|
||||||
let map.hashfn[uint] hasher = bind hash(_);
|
let map.eqfn[uint] eqer = eq;
|
||||||
let map.eqfn[uint] eqer = bind eq(_, _);
|
|
||||||
let map.hashmap[uint, uint] hm = map.mk_hashmap[uint, uint](hasher, eqer);
|
let map.hashmap[uint, uint] hm = map.mk_hashmap[uint, uint](hasher, eqer);
|
||||||
|
|
||||||
let uint i = 0u;
|
let uint i = 0u;
|
||||||
while (i < map_capacity) {
|
while (i < num_to_insert) {
|
||||||
hm.insert(i, i * i);
|
hm.insert(i, i * i);
|
||||||
log "inserting " + std._uint.to_str(i, 10u)
|
log "inserting " + std._uint.to_str(i, 10u)
|
||||||
+ " -> " + std._uint.to_str(i * i, 10u);
|
+ " -> " + std._uint.to_str(i * i, 10u);
|
||||||
|
@ -68,22 +64,22 @@ fn test_growth() {
|
||||||
log "-----";
|
log "-----";
|
||||||
|
|
||||||
i = 0u;
|
i = 0u;
|
||||||
while (i < map_capacity) {
|
while (i < num_to_insert) {
|
||||||
log "get(" + std._uint.to_str(i, 10u) + ") = "
|
log "get(" + std._uint.to_str(i, 10u) + ") = "
|
||||||
+ std._uint.to_str(hm.get(i), 10u);
|
+ std._uint.to_str(hm.get(i), 10u);
|
||||||
check (hm.get(i) == i * i);
|
check (hm.get(i) == i * i);
|
||||||
i += 1u;
|
i += 1u;
|
||||||
}
|
}
|
||||||
|
|
||||||
hm.insert(map_capacity, 17u);
|
hm.insert(num_to_insert, 17u);
|
||||||
check (hm.get(map_capacity) == 17u);
|
check (hm.get(num_to_insert) == 17u);
|
||||||
|
|
||||||
log "-----";
|
log "-----";
|
||||||
|
|
||||||
hm.rehash();
|
hm.rehash();
|
||||||
|
|
||||||
i = 0u;
|
i = 0u;
|
||||||
while (i < map_capacity) {
|
while (i < num_to_insert) {
|
||||||
log "get(" + std._uint.to_str(i, 10u) + ") = "
|
log "get(" + std._uint.to_str(i, 10u) + ") = "
|
||||||
+ std._uint.to_str(hm.get(i), 10u);
|
+ std._uint.to_str(hm.get(i), 10u);
|
||||||
check (hm.get(i) == i * i);
|
check (hm.get(i) == i * i);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue