Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* Compiler: improve debug/sourcemap location of closures (#1947)
* Compiler: improve tailcall optimization (#1943)
* Compiler: improve deadcode optimization (#1963, #1962, #1967)
* Compiler: improve coloring optimization (#1971)
* Runtime: use Dataview to convert between floats and bit representation
* Compiler: speed-up compilation by improving the scheduling of optimization passes (#1962)

Expand Down
16 changes: 13 additions & 3 deletions compiler/lib/js_assign.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module type Strategy = sig

val record_block : t -> Js_traverse.t -> Js_traverse.block -> unit

val allocate_variables : t -> count:int Javascript.IdentMap.t -> string array
val allocate_variables : t -> count:int array -> string array
end

module Min : Strategy = struct
Expand Down Expand Up @@ -117,7 +117,7 @@ while compiling the OCaml toplevel:
let create nv = { constr = Array.make nv []; parameters = [| [] |]; constraints = [] }

let allocate_variables t ~count =
let weight v = try IdentMap.find (V (Var.of_idx v)) count with Not_found -> 0 in
let weight v = count.(v) in
let constr = t.constr in
let len = Array.length constr in
let idx = Array.make len 0 in
Expand Down Expand Up @@ -383,7 +383,17 @@ let program' (module Strategy : Strategy) p =
in
let has_free_var = IdentSet.cardinal free <> 0 in
let unallocated_names = ref Var.Set.empty in
let names = Strategy.allocate_variables state ~count:mapper#get_count in
let count =
let a = Array.make nv 0 in
Javascript.IdentMap.iter
(fun k i ->
match k with
| S _ -> ()
| V v -> a.(Var.idx v) <- i)
mapper#get_count;
a
in
let names = Strategy.allocate_variables state ~count in
(* ignore the choosen name for escaping/free [V _] variables *)
IdentSet.iter
(function
Expand Down
Loading