Skip to content

Commit 9e336db

Browse files
committed
clean up
1 parent bd89614 commit 9e336db

File tree

245 files changed

+748
-876
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

245 files changed

+748
-876
lines changed

jscomp/all.depend

+5-6
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ core/lam_stats.cmi : core/lam_module_ident.cmi core/lam.cmi \
253253
core/config_util.cmi : core/js_cmj_format.cmi
254254
core/lam_compile_defs.cmi : core/lam_stats.cmi core/j.cmx ext/ident_map.cmi
255255
core/js_fold_basic.cmi : core/lam_module_ident.cmi core/j.cmx \
256-
ext/ident_set.cmi ext/hash_set_poly.cmi
256+
ext/ident_set.cmi
257257
core/js_pass_scope.cmi : core/j.cmx ext/ident_set.cmi
258258
core/js_op_util.cmi : core/js_op.cmx core/j.cmx
259259
core/js_analyzer.cmi : core/j.cmx ext/ident_set.cmi
@@ -283,7 +283,7 @@ core/js_pass_flatten_and_mark_dead.cmi : core/j.cmx
283283
core/js_ast_util.cmi : core/j.cmx
284284
core/lam_dce.cmi : core/lam_group.cmi
285285
core/lam_compile_env.cmi : core/lam_module_ident.cmi core/lam.cmi \
286-
common/js_config.cmi core/js_cmj_format.cmi ext/hash_set_poly.cmi
286+
common/js_config.cmi core/js_cmj_format.cmi
287287
core/lam_stats_util.cmi : core/lam_stats.cmi core/lam.cmi
288288
core/lam_stats_export.cmi : core/lam_stats.cmi core/lam_module_ident.cmi \
289289
core/lam.cmi core/js_cmj_format.cmi ext/ident_map.cmi
@@ -363,8 +363,8 @@ core/lam_compile_defs.cmx : core/lam_stats.cmx core/j.cmx ext/ident_map.cmx \
363363
core/js_map.cmx : core/j.cmx
364364
core/js_fold.cmx : core/j.cmx
365365
core/js_fold_basic.cmx : core/lam_module_ident.cmx core/js_fold.cmx \
366-
common/js_config.cmx core/j.cmx ext/ident_set.cmx ext/hash_set_poly.cmx \
367-
ext/ext_ident.cmx core/js_fold_basic.cmi
366+
common/js_config.cmx core/j.cmx ext/ident_set.cmx ext/ext_ident.cmx \
367+
core/js_fold_basic.cmi
368368
core/js_pass_scope.cmx : core/js_fun_env.cmx core/js_fold.cmx \
369369
core/js_closure.cmx ext/ident_set.cmx common/ext_log.cmx \
370370
core/js_pass_scope.cmi
@@ -433,8 +433,7 @@ core/lam_group_pass.cmx : core/lam.cmx
433433
core/lam_compile_env.cmx : core/type_util.cmx ext/string_map.cmx \
434434
core/lam_module_ident.cmx core/lam.cmx core/js_stmt_make.cmx \
435435
core/js_exp_make.cmx common/js_config.cmx core/js_cmj_format.cmx \
436-
ext/hash_set_poly.cmx ext/ext_ident.cmx core/config_util.cmx \
437-
core/lam_compile_env.cmi
436+
ext/ext_ident.cmx core/config_util.cmx core/lam_compile_env.cmi
438437
core/lam_stats_util.cmx : core/lam_stats.cmx core/lam_compile_env.cmx \
439438
core/lam.cmx ext/ident_hashtbl.cmx ext/ext_list.cmx \
440439
core/lam_stats_util.cmi

jscomp/bin/whole_compiler.d

-2
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,6 @@ bin/whole_compiler.ml : core/js_cmj_format.ml
175175
bin/whole_compiler.ml : core/js_cmj_format.mli
176176
bin/whole_compiler.ml : core/config_util.ml
177177
bin/whole_compiler.ml : core/config_util.mli
178-
bin/whole_compiler.ml : ext/hash_set_poly.ml
179-
bin/whole_compiler.ml : ext/hash_set_poly.mli
180178
bin/whole_compiler.ml : core/js_call_info.ml
181179
bin/whole_compiler.ml : core/js_call_info.mli
182180
bin/whole_compiler.ml : core/js_closure.ml

jscomp/bin/whole_compiler.ml

+34-166
Original file line numberDiff line numberDiff line change
@@ -63727,145 +63727,6 @@ let find_cmj file =
6372763727

6372863728

6372963729

63730-
end
63731-
module Hash_set_poly : sig
63732-
#1 "hash_set_poly.mli"
63733-
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
63734-
*
63735-
* This program is free software: you can redistribute it and/or modify
63736-
* it under the terms of the GNU Lesser General Public License as published by
63737-
* the Free Software Foundation, either version 3 of the License, or
63738-
* (at your option) any later version.
63739-
*
63740-
* In addition to the permissions granted to you by the LGPL, you may combine
63741-
* or link a "work that uses the Library" with a publicly distributed version
63742-
* of this file to produce a combined library or application, then distribute
63743-
* that combined work under the terms of your choosing, with no requirement
63744-
* to comply with the obligations normally placed on you by section 4 of the
63745-
* LGPL version 3 (or the corresponding section of a later version of the LGPL
63746-
* should you choose to use a later version).
63747-
*
63748-
* This program is distributed in the hope that it will be useful,
63749-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
63750-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63751-
* GNU Lesser General Public License for more details.
63752-
*
63753-
* You should have received a copy of the GNU Lesser General Public License
63754-
* along with this program; if not, write to the Free Software
63755-
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
63756-
63757-
63758-
type 'a t
63759-
63760-
val create : int -> 'a t
63761-
63762-
val clear : 'a t -> unit
63763-
63764-
val reset : 'a t -> unit
63765-
63766-
val copy : 'a t -> 'a t
63767-
63768-
val add : 'a t -> 'a -> unit
63769-
val remove : 'a t -> 'a -> unit
63770-
63771-
val mem : 'a t -> 'a -> bool
63772-
63773-
val iter : ('a -> unit) -> 'a t -> unit
63774-
63775-
val elements : 'a t -> 'a list
63776-
63777-
val length : 'a t -> int
63778-
63779-
val stats: 'a t -> Hashtbl.statistics
63780-
63781-
end = struct
63782-
#1 "hash_set_poly.ml"
63783-
# 1 "ext/hash_set.cppo.ml"
63784-
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
63785-
*
63786-
* This program is free software: you can redistribute it and/or modify
63787-
* it under the terms of the GNU Lesser General Public License as published by
63788-
* the Free Software Foundation, either version 3 of the License, or
63789-
* (at your option) any later version.
63790-
*
63791-
* In addition to the permissions granted to you by the LGPL, you may combine
63792-
* or link a "work that uses the Library" with a publicly distributed version
63793-
* of this file to produce a combined library or application, then distribute
63794-
* that combined work under the terms of your choosing, with no requirement
63795-
* to comply with the obligations normally placed on you by section 4 of the
63796-
* LGPL version 3 (or the corresponding section of a later version of the LGPL
63797-
* should you choose to use a later version).
63798-
*
63799-
* This program is distributed in the hope that it will be useful,
63800-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
63801-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63802-
* GNU Lesser General Public License for more details.
63803-
*
63804-
* You should have received a copy of the GNU Lesser General Public License
63805-
* along with this program; if not, write to the Free Software
63806-
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
63807-
# 51
63808-
external seeded_hash_param :
63809-
int -> int -> int -> 'a -> int = "caml_hash" "noalloc"
63810-
let key_index (h : _ Hash_set_gen.t ) (key : 'a) =
63811-
seeded_hash_param 10 100 0 key land (Array.length h.data - 1)
63812-
let eq_key = (=)
63813-
type 'a t = 'a Hash_set_gen.t
63814-
63815-
63816-
# 62
63817-
let create = Hash_set_gen.create
63818-
let clear = Hash_set_gen.clear
63819-
let reset = Hash_set_gen.reset
63820-
let copy = Hash_set_gen.copy
63821-
let iter = Hash_set_gen.iter
63822-
let fold = Hash_set_gen.fold
63823-
let length = Hash_set_gen.length
63824-
let stats = Hash_set_gen.stats
63825-
let elements = Hash_set_gen.elements
63826-
63827-
63828-
63829-
let remove (h : _ Hash_set_gen.t) key =
63830-
let i = key_index h key in
63831-
let h_data = h.data in
63832-
let old_h_size = h.size in
63833-
let new_bucket = Hash_set_gen.remove_bucket eq_key key h (Array.unsafe_get h_data i) in
63834-
if old_h_size <> h.size then
63835-
Array.unsafe_set h_data i new_bucket
63836-
63837-
63838-
63839-
let add (h : _ Hash_set_gen.t) key =
63840-
let i = key_index h key in
63841-
let h_data = h.data in
63842-
let old_bucket = (Array.unsafe_get h_data i) in
63843-
if not (Hash_set_gen.small_bucket_mem eq_key key old_bucket) then
63844-
begin
63845-
Array.unsafe_set h_data i (key :: old_bucket);
63846-
h.size <- h.size + 1 ;
63847-
if h.size > Array.length h_data lsl 1 then Hash_set_gen.resize key_index h
63848-
end
63849-
63850-
let check_add (h : _ Hash_set_gen.t) key =
63851-
let i = key_index h key in
63852-
let h_data = h.data in
63853-
let old_bucket = (Array.unsafe_get h_data i) in
63854-
if not (Hash_set_gen.small_bucket_mem eq_key key old_bucket) then
63855-
begin
63856-
Array.unsafe_set h_data i (key :: old_bucket);
63857-
h.size <- h.size + 1 ;
63858-
if h.size > Array.length h_data lsl 1 then Hash_set_gen.resize key_index h;
63859-
true
63860-
end
63861-
else false
63862-
63863-
63864-
let mem (h : _ Hash_set_gen.t) key =
63865-
Hash_set_gen.small_bucket_mem eq_key key (Array.unsafe_get h.data (key_index h key))
63866-
63867-
63868-
6386963730
end
6387063731
module Js_call_info : sig
6387163732
#1 "js_call_info.mli"
@@ -79281,7 +79142,7 @@ val query_and_add_if_not_exist :
7928179142
'a t -> not_found:(unit -> 'b) ->
7928279143
found:('a -> 'b) -> 'b
7928379144

79284-
val add_js_module : ?id:Ident.t -> string -> Ident.t
79145+
val add_js_module : ?hint_name:string -> string -> Ident.t
7928579146
(** add third party dependency *)
7928679147

7928779148
(* The other dependencies are captured by querying
@@ -79300,7 +79161,7 @@ val add_js_module : ?id:Ident.t -> string -> Ident.t
7930079161

7930179162
val reset : unit -> unit
7930279163

79303-
val is_pure : Lam_module_ident.t -> bool
79164+
val is_pure_module : Lam_module_ident.t -> bool
7930479165

7930579166
val get_package_path_from_cmj :
7930679167
Lam_module_ident.system -> Lam_module_ident.t ->
@@ -79313,7 +79174,7 @@ val get_package_path_from_cmj :
7931379174
val get_requried_modules :
7931479175
Env.t ->
7931579176
Lam_module_ident.t list ->
79316-
Lam_module_ident.t Hash_set_poly.t ->
79177+
Lam_module_ident.Hash_set.t ->
7931779178
Lam_module_ident.t list
7931879179

7931979180
end = struct
@@ -79402,13 +79263,17 @@ let reset () =
7940279263
Translmod.reset ();
7940379264
Lam_module_ident.Hash.clear cached_tbl
7940479265

79405-
(* FIXME: JS external instead *)
79406-
let add_js_module ?id module_name : Ident.t
79266+
(**
79267+
Any [id] put in the [cached_tbl] should be always valid,
79268+
since it is already used in the code gen,
79269+
the older will have higher precedence
79270+
*)
79271+
let add_js_module ?hint_name module_name : Ident.t
7940779272
=
7940879273
let id =
79409-
match id with
79274+
match hint_name with
7941079275
| None -> Ext_ident.create_js_module module_name
79411-
| Some id -> id in
79276+
| Some hint_name -> Ext_ident.create_js_module hint_name in
7941279277
let lam_module_ident =
7941379278
Lam_module_ident.of_external id module_name in
7941479279
match Lam_module_ident.Hash.find_key_opt cached_tbl lam_module_ident with
@@ -79553,7 +79418,7 @@ let query_and_add_if_not_exist (type u)
7955379418
end
7955479419

7955579420
(* Conservative interface *)
79556-
let is_pure id =
79421+
let is_pure_module id =
7955779422
query_and_add_if_not_exist id No_env
7955879423
~not_found:(fun _ -> false)
7955979424
~found:(fun x -> x.effect = None)
@@ -79572,19 +79437,15 @@ let get_package_path_from_cmj module_system ( id : Lam_module_ident.t) =
7957279437
let get_requried_modules env
7957379438
(extras : module_id list )
7957479439
(hard_dependencies
79575-
: _ Hash_set_poly.t) : module_id list =
79576-
79577-
let mem (x : Lam_module_ident.t) =
79578-
not (is_pure x ) || Hash_set_poly.mem hard_dependencies x
79579-
in
79440+
: Lam_module_ident.Hash_set.t) : module_id list =
7958079441
Lam_module_ident.Hash.iter (fun (id : module_id) _ ->
79581-
if mem id
79582-
then Hash_set_poly.add hard_dependencies id) cached_tbl ;
79442+
if not @@ is_pure_module id
79443+
then Lam_module_ident.Hash_set.add hard_dependencies id) cached_tbl ;
7958379444
List.iter (fun id ->
79584-
if mem id
79585-
then Hash_set_poly.add hard_dependencies id
79445+
if not @@ is_pure_module id
79446+
then Lam_module_ident.Hash_set.add hard_dependencies id
7958679447
) extras;
79587-
Hash_set_poly.elements hard_dependencies
79448+
Lam_module_ident.Hash_set.elements hard_dependencies
7958879449

7958979450
end
7959079451
module Ext_pp : sig
@@ -82467,7 +82328,8 @@ module Js_fold_basic : sig
8246782328

8246882329
val depends_j : J.expression -> Ident_set.t -> Ident_set.t
8246982330

82470-
val calculate_hard_dependencies : J.block -> Lam_module_ident.t Hash_set_poly.t
82331+
(** TODO: {!Ordered_hash_set} for better ordering *)
82332+
val calculate_hard_dependencies : J.block -> Lam_module_ident.Hash_set.t
8247182333

8247282334
end = struct
8247382335
#1 "js_fold_basic.ml"
@@ -82527,21 +82389,23 @@ class count_deps (add : Ident.t -> unit ) =
8252782389
method! ident x = add x ; self
8252882390
end
8252982391

82392+
let add_lam_module_ident = Lam_module_ident.Hash_set.add
82393+
let create = Lam_module_ident.Hash_set.create
8253082394
class count_hard_dependencies =
8253182395
object(self)
8253282396
inherit Js_fold.fold as super
82533-
val hard_dependencies = Hash_set_poly.create 17
82397+
val hard_dependencies = create 17
8253482398
method! vident vid =
8253582399
match vid with
8253682400
| Qualified (id,kind,_) ->
82537-
Hash_set_poly.add hard_dependencies (Lam_module_ident.mk kind id); self
82401+
add_lam_module_ident hard_dependencies (Lam_module_ident.mk kind id); self
8253882402
| Id id -> self
8253982403
method! expression x =
8254082404
match x with
8254182405
| {expression_desc = Call (_,_, {arity = NA}); _}
8254282406
(* see [Js_exp_make.runtime_var_dot] *)
8254382407
->
82544-
Hash_set_poly.add hard_dependencies
82408+
add_lam_module_ident hard_dependencies
8254582409
(Lam_module_ident.of_runtime (Ext_ident.create_js Js_config.curry));
8254682410
super#expression x
8254782411
| {expression_desc = Caml_block(_,_, tag, tag_info); _}
@@ -82554,7 +82418,7 @@ class count_hard_dependencies =
8255482418
-> ()
8255582419
| _, _
8255682420
->
82557-
Hash_set_poly.add hard_dependencies
82421+
add_lam_module_ident hard_dependencies
8255882422
(Lam_module_ident.of_runtime (Ext_ident.create_js Js_config.block));
8255982423
end;
8256082424
super#expression x
@@ -91398,7 +91262,10 @@ end = struct
9139891262
module E = Js_exp_make
9139991263

9140091264

91401-
91265+
(**
91266+
[bind_name] is a hint to the compiler to generate
91267+
better names for external module
91268+
*)
9140291269
let handle_external
9140391270
({bundle ; bind_name} : Ast_external_attributes.external_module_name)
9140491271
: Ident.t * string
@@ -91408,7 +91275,8 @@ let handle_external
9140891275
Lam_compile_env.add_js_module bundle , bundle
9140991276
| Some bind_name ->
9141091277
Lam_compile_env.add_js_module
91411-
~id:(Ext_ident.create_js_module bind_name) bundle,
91278+
~hint_name:bind_name
91279+
bundle,
9141291280
bundle
9141391281

9141491282
let handle_external_opt
@@ -96928,8 +96796,8 @@ let simplify_alias
9692896796
| Ltrywith (l1, v, l2) -> Lam.try_ (simpl l1) v (simpl l2)
9692996797

9693096798
| Lsequence (Lprim {primitive = Pgetglobal (id); args = []}, l2)
96931-
when Lam_compile_env.is_pure (Lam_module_ident.of_ml id)
96932-
-> simpl l2
96799+
when Lam_compile_env.is_pure_module (Lam_module_ident.of_ml id)
96800+
-> simpl l2 (** TODO: apply in the beginning *)
9693396801
| Lsequence(l1, l2)
9693496802
-> Lam.seq (simpl l1) (simpl l2)
9693596803
| Lwhile(l1, l2)

jscomp/core/js_fold_basic.ml

+6-4
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,23 @@ class count_deps (add : Ident.t -> unit ) =
5454
method! ident x = add x ; self
5555
end
5656

57+
let add_lam_module_ident = Lam_module_ident.Hash_set.add
58+
let create = Lam_module_ident.Hash_set.create
5759
class count_hard_dependencies =
5860
object(self)
5961
inherit Js_fold.fold as super
60-
val hard_dependencies = Hash_set_poly.create 17
62+
val hard_dependencies = create 17
6163
method! vident vid =
6264
match vid with
6365
| Qualified (id,kind,_) ->
64-
Hash_set_poly.add hard_dependencies (Lam_module_ident.mk kind id); self
66+
add_lam_module_ident hard_dependencies (Lam_module_ident.mk kind id); self
6567
| Id id -> self
6668
method! expression x =
6769
match x with
6870
| {expression_desc = Call (_,_, {arity = NA}); _}
6971
(* see [Js_exp_make.runtime_var_dot] *)
7072
->
71-
Hash_set_poly.add hard_dependencies
73+
add_lam_module_ident hard_dependencies
7274
(Lam_module_ident.of_runtime (Ext_ident.create_js Js_config.curry));
7375
super#expression x
7476
| {expression_desc = Caml_block(_,_, tag, tag_info); _}
@@ -81,7 +83,7 @@ class count_hard_dependencies =
8183
-> ()
8284
| _, _
8385
->
84-
Hash_set_poly.add hard_dependencies
86+
add_lam_module_ident hard_dependencies
8587
(Lam_module_ident.of_runtime (Ext_ident.create_js Js_config.block));
8688
end;
8789
super#expression x

jscomp/core/js_fold_basic.mli

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@
3333

3434
val depends_j : J.expression -> Ident_set.t -> Ident_set.t
3535

36-
val calculate_hard_dependencies : J.block -> Lam_module_ident.t Hash_set_poly.t
36+
(** TODO: {!Ordered_hash_set} for better ordering *)
37+
val calculate_hard_dependencies : J.block -> Lam_module_ident.Hash_set.t

0 commit comments

Comments
 (0)