File tree Expand file tree Collapse file tree 2 files changed +40
-31
lines changed Expand file tree Collapse file tree 2 files changed +40
-31
lines changed Original file line number Diff line number Diff line change @@ -608,29 +608,31 @@ let simplify_js js =
608
608
609
609
let collects_shapes p =
610
610
let l = ref StringMap. empty in
611
- let t = Timer. make () in
612
- let _, info = Flow. f p in
613
- let pure = Pure_fun. f p in
614
- let return_values = Code. return_values p in
615
- Code.Addr.Map. iter
616
- (fun _ block ->
617
- List. iter block.Code. body ~f: (fun i ->
618
- match i with
619
- | Code. Let
620
- ( _
621
- , Prim
622
- ( Extern " caml_register_global"
623
- , [ _code; Pv block; Pc (NativeString name) ] ) ) ->
624
- let shape = Flow. the_shape_of ~return_values ~pure info block in
625
- let name =
626
- match name with
627
- | Byte s -> s
628
- | Utf (Utf8 s ) -> s
629
- in
630
- l := StringMap. add name shape ! l
631
- | _ -> () ))
632
- p.blocks;
633
- if times () then Format. eprintf " shapes: %a@." Timer. print t;
611
+ if true
612
+ then (
613
+ let t = Timer. make () in
614
+ let _, info = Flow. f p in
615
+ let pure = Pure_fun. f p in
616
+ let return_values = Code. return_values p in
617
+ Code.Addr.Map. iter
618
+ (fun _ block ->
619
+ List. iter block.Code. body ~f: (fun i ->
620
+ match i with
621
+ | Code. Let
622
+ ( _
623
+ , Prim
624
+ ( Extern " caml_register_global"
625
+ , [ _code; Pv block; Pc (NativeString name) ] ) ) ->
626
+ let shape = Flow. the_shape_of ~return_values ~pure info block in
627
+ let name =
628
+ match name with
629
+ | Byte s -> s
630
+ | Utf (Utf8 s ) -> s
631
+ in
632
+ l := StringMap. add name shape ! l
633
+ | _ -> () ))
634
+ p.blocks;
635
+ if times () then Format. eprintf " shapes: %a@." Timer. print t);
634
636
! l
635
637
636
638
let configure formatter =
Original file line number Diff line number Diff line change @@ -132,27 +132,34 @@ module Store = struct
132
132
end
133
133
134
134
module State = struct
135
- type nonrec t = t Code.Var.Hashtbl .t
135
+ type nonrec t =
136
+ { table : t Code.Var.Hashtbl .t
137
+ ; cache : BitSet .t
138
+ }
136
139
137
- let t : t = Code.Var.Hashtbl. create 17
140
+ let t : t = { table = Code.Var.Hashtbl. create 17 ; cache = BitSet. create () }
138
141
139
- let assign x shape = Code.Var.Hashtbl. replace t x shape
142
+ let assign x shape =
143
+ Code.Var.Hashtbl. replace t.table x shape;
144
+ BitSet. set t.cache (Code.Var. idx x)
140
145
141
146
let propagate x offset target =
142
- match Code.Var.Hashtbl. find_opt t x with
147
+ match Code.Var.Hashtbl. find_opt t.table x with
143
148
| None -> ()
144
149
| Some (Top _ | Function _ ) -> ()
145
150
| Some (Block l ) -> assign target (List. nth l offset)
146
151
147
- let get x = Code.Var.Hashtbl. find_opt t x
152
+ let get x = Code.Var.Hashtbl. find_opt t.table x
148
153
149
- let mem x = Code.Var.Hashtbl. mem t x
154
+ let mem x = BitSet. mem t.cache ( Code.Var. idx x)
150
155
151
156
let is_pure_fun x =
152
- match Code.Var.Hashtbl. find_opt t x with
157
+ match Code.Var.Hashtbl. find_opt t.table x with
153
158
| None -> false
154
159
| Some (Top _ | Block _ ) -> false
155
160
| Some (Function { pure; _ } ) -> pure
156
161
157
- let reset () = Code.Var.Hashtbl. clear t
162
+ let reset () =
163
+ Code.Var.Hashtbl. clear t.table;
164
+ BitSet. clear t.cache
158
165
end
You can’t perform that action at this time.
0 commit comments