Skip to content

Commit 8f89636

Browse files
committed
---
yaml --- r: 623 b: refs/heads/master c: 9481907 h: refs/heads/master i: 621: 857432c 619: b146828 615: ca91f14 607: fc731d4 v: v3
1 parent fed96e3 commit 8f89636

File tree

4 files changed

+53
-38
lines changed

4 files changed

+53
-38
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 6ec8c210168120abc6cf95cf5bda5e0df824447a
2+
refs/heads/master: 9481907211e33360ff493ca60c4b3211caf1b897

trunk/src/boot/me/resolve.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,10 @@ let stmt_collecting_visitor
122122
htab_put slots key slot_id;
123123
htab_put cx.ctxt_slot_keys slot_id key
124124
| Ast.PAT_tag (_, pats) -> Array.iter (resolve_pat block) pats
125-
| Ast.PAT_lit _ | Ast.PAT_wild -> ()
125+
| Ast.PAT_lit _
126+
| Ast.PAT_wild -> ()
126127
in
127-
Array.iter (fun { node = (p, b) } -> resolve_pat b p) arms
128+
Array.iter (fun { node = (p, b) } -> resolve_pat b p) arms
128129
| _ -> ()
129130
end;
130131
inner.Walk.visit_stmt_pre stmt

trunk/src/boot/me/trans.ml

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4139,23 +4139,18 @@ let trans_visitor
41394139
let trans_arm arm : quad_idx =
41404140
let (pat, block) = arm.node in
41414141

4142-
(* Translates the pattern and returns the following pair.
4143-
*
4144-
* fst: The addresses of the branch instructions that are taken if
4145-
* the match fails.
4146-
* snd: The (cell, slot) pairs of any slots bound and initialized
4147-
* in PAT_slot pattern leaves.
4142+
(* Translates the pattern and returns the addresses of the branch
4143+
* instructions that are taken if the match fails.
41484144
*)
41494145
let rec trans_pat
41504146
(pat:Ast.pat)
41514147
(src_cell:Il.cell)
41524148
(src_ty:Ast.ty)
4153-
: (quad_idx list) * ((Il.cell * Ast.slot) list) =
4149+
: quad_idx list =
41544150

41554151
match pat with
41564152
Ast.PAT_lit lit ->
4157-
(trans_compare_simple Il.JNE (trans_lit lit) (Il.Cell src_cell),
4158-
[])
4153+
trans_compare_simple Il.JNE (trans_lit lit) (Il.Cell src_cell)
41594154

41604155
| Ast.PAT_tag (lval, pats) ->
41614156
let tag_name = tag_ctor_name_to_tag_name (lval_to_name lval) in
@@ -4185,19 +4180,18 @@ let trans_visitor
41854180

41864181
let tup_cell:Il.cell = get_variant_ptr union_cell tag_number in
41874182

4188-
let trans_elem_pat i elem_pat
4189-
: (quad_idx list) * ((Il.cell * Ast.slot) list) =
4183+
let trans_elem_pat i elem_pat : quad_idx list =
41904184
let elem_cell =
41914185
get_element_ptr_dyn_in_current_frame tup_cell i
41924186
in
41934187
let elem_ty = ty_tup.(i) in
41944188
trans_pat elem_pat elem_cell elem_ty
41954189
in
41964190

4197-
let (elem_jumps, bindings) =
4198-
List.split (Array.to_list (Array.mapi trans_elem_pat pats))
4191+
let elem_jumps =
4192+
List.concat (Array.to_list (Array.mapi trans_elem_pat pats))
41994193
in
4200-
(next_jumps @ (List.concat elem_jumps), List.concat bindings)
4194+
next_jumps @ elem_jumps
42014195

42024196
| Ast.PAT_slot (dst, _) ->
42034197
let dst_slot = get_slot cx dst.id in
@@ -4206,24 +4200,14 @@ let trans_visitor
42064200
(get_ty_params_of_current_frame())
42074201
CLONE_none dst_cell dst_slot
42084202
src_cell src_ty;
4209-
([], [(dst_cell, dst_slot)]) (* irrefutable *)
4203+
[] (* irrefutable *)
42104204

4211-
| Ast.PAT_wild -> ([], []) (* irrefutable *)
4205+
| Ast.PAT_wild -> [] (* irrefutable *)
42124206
in
42134207

42144208
let (lval_cell, lval_ty) = trans_lval at.Ast.alt_tag_lval in
4215-
let (next_jumps, bindings) = trans_pat pat lval_cell lval_ty in
4209+
let next_jumps = trans_pat pat lval_cell lval_ty in
42164210
trans_block block;
4217-
4218-
(* Drop any slots we initialized in the leaf slot bindings of
4219-
* this arm's pattern.
4220-
*
4221-
* FIXME: Is `None` really correct to pass as the curr_iso?
4222-
*)
4223-
List.iter
4224-
(fun (cell, slot) -> drop_slot_in_current_frame cell slot None)
4225-
bindings;
4226-
42274211
let last_jump = mark() in
42284212
emit (Il.jmp Il.JMP Il.CodeNone);
42294213
List.iter patch next_jumps;

trunk/src/boot/me/typestate.ml

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ let lifecycle_visitor
12971297
let (live_block_slots:(node_id, unit) Hashtbl.t) = Hashtbl.create 0 in
12981298
let (frame_blocks:frame_block_slots_stack) = Stack.create () in
12991299

1300-
let (implicit_init_block_slots:(node_id,node_id) Hashtbl.t) =
1300+
let (implicit_init_block_slots:(node_id,node_id list) Hashtbl.t) =
13011301
Hashtbl.create 0
13021302
in
13031303

@@ -1315,9 +1315,12 @@ let lifecycle_visitor
13151315
begin
13161316
match htab_search implicit_init_block_slots b.id with
13171317
None -> ()
1318-
| Some slot ->
1319-
push_slot slot;
1320-
mark_slot_live slot
1318+
| Some slots ->
1319+
List.iter
1320+
(fun slot ->
1321+
push_slot slot;
1322+
mark_slot_live slot)
1323+
slots
13211324
end;
13221325
inner.Walk.visit_block_pre b
13231326
in
@@ -1425,7 +1428,7 @@ let lifecycle_visitor
14251428
Hashtbl.replace cx.ctxt_stmt_is_init s.id ();
14261429
htab_put implicit_init_block_slots
14271430
f.Ast.for_body.id
1428-
(fst f.Ast.for_slot).id
1431+
[ (fst f.Ast.for_slot).id ]
14291432

14301433
| Ast.STMT_for_each f ->
14311434
log cx "noting implicit init for slot %d in for_each-block %d"
@@ -1434,9 +1437,36 @@ let lifecycle_visitor
14341437
Hashtbl.replace cx.ctxt_stmt_is_init s.id ();
14351438
htab_put implicit_init_block_slots
14361439
f.Ast.for_each_body.id
1437-
(fst f.Ast.for_each_slot).id
1438-
1439-
1440+
[ (fst f.Ast.for_each_slot).id ]
1441+
1442+
| Ast.STMT_alt_tag { Ast.alt_tag_arms = arms } ->
1443+
let note_slot block slot_id =
1444+
log cx
1445+
"noting implicit init for slot %d in pattern-alt block %d"
1446+
(int_of_node slot_id)
1447+
(int_of_node block.id);
1448+
in
1449+
let rec all_pat_slot_ids block pat =
1450+
match pat with
1451+
Ast.PAT_slot ({ id = slot_id }, _) ->
1452+
[ slot_id ]
1453+
| Ast.PAT_tag (_, pats) ->
1454+
List.concat
1455+
(Array.to_list
1456+
(Array.map (all_pat_slot_ids block) pats))
1457+
| Ast.PAT_lit _
1458+
| Ast.PAT_wild -> []
1459+
in
1460+
Array.iter
1461+
begin
1462+
fun { node = (pat, block) } ->
1463+
let slot_ids = all_pat_slot_ids block pat in
1464+
List.iter (note_slot block) slot_ids;
1465+
htab_put implicit_init_block_slots
1466+
block.id
1467+
slot_ids
1468+
end
1469+
arms
14401470
| _ -> ()
14411471
end;
14421472
inner.Walk.visit_stmt_pre s

0 commit comments

Comments
 (0)