@@ -63727,145 +63727,6 @@ let find_cmj file =
63727
63727
63728
63728
63729
63729
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
-
63869
63730
end
63870
63731
module Js_call_info : sig
63871
63732
#1 "js_call_info.mli"
@@ -79281,7 +79142,7 @@ val query_and_add_if_not_exist :
79281
79142
'a t -> not_found:(unit -> 'b) ->
79282
79143
found:('a -> 'b) -> 'b
79283
79144
79284
- val add_js_module : ?id:Ident.t -> string -> Ident.t
79145
+ val add_js_module : ?hint_name:string -> string -> Ident.t
79285
79146
(** add third party dependency *)
79286
79147
79287
79148
(* The other dependencies are captured by querying
@@ -79300,7 +79161,7 @@ val add_js_module : ?id:Ident.t -> string -> Ident.t
79300
79161
79301
79162
val reset : unit -> unit
79302
79163
79303
- val is_pure : Lam_module_ident.t -> bool
79164
+ val is_pure_module : Lam_module_ident.t -> bool
79304
79165
79305
79166
val get_package_path_from_cmj :
79306
79167
Lam_module_ident.system -> Lam_module_ident.t ->
@@ -79313,7 +79174,7 @@ val get_package_path_from_cmj :
79313
79174
val get_requried_modules :
79314
79175
Env.t ->
79315
79176
Lam_module_ident.t list ->
79316
- Lam_module_ident.t Hash_set_poly .t ->
79177
+ Lam_module_ident.Hash_set .t ->
79317
79178
Lam_module_ident.t list
79318
79179
79319
79180
end = struct
@@ -79402,13 +79263,17 @@ let reset () =
79402
79263
Translmod.reset ();
79403
79264
Lam_module_ident.Hash.clear cached_tbl
79404
79265
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
79407
79272
=
79408
79273
let id =
79409
- match id with
79274
+ match hint_name with
79410
79275
| 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
79412
79277
let lam_module_ident =
79413
79278
Lam_module_ident.of_external id module_name in
79414
79279
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)
79553
79418
end
79554
79419
79555
79420
(* Conservative interface *)
79556
- let is_pure id =
79421
+ let is_pure_module id =
79557
79422
query_and_add_if_not_exist id No_env
79558
79423
~not_found:(fun _ -> false)
79559
79424
~found:(fun x -> x.effect = None)
@@ -79572,19 +79437,15 @@ let get_package_path_from_cmj module_system ( id : Lam_module_ident.t) =
79572
79437
let get_requried_modules env
79573
79438
(extras : module_id list )
79574
79439
(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 =
79580
79441
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 ;
79583
79444
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
79586
79447
) extras;
79587
- Hash_set_poly .elements hard_dependencies
79448
+ Lam_module_ident.Hash_set .elements hard_dependencies
79588
79449
79589
79450
end
79590
79451
module Ext_pp : sig
@@ -82467,7 +82328,8 @@ module Js_fold_basic : sig
82467
82328
82468
82329
val depends_j : J.expression -> Ident_set.t -> Ident_set.t
82469
82330
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
82471
82333
82472
82334
end = struct
82473
82335
#1 "js_fold_basic.ml"
@@ -82527,21 +82389,23 @@ class count_deps (add : Ident.t -> unit ) =
82527
82389
method! ident x = add x ; self
82528
82390
end
82529
82391
82392
+ let add_lam_module_ident = Lam_module_ident.Hash_set.add
82393
+ let create = Lam_module_ident.Hash_set.create
82530
82394
class count_hard_dependencies =
82531
82395
object(self)
82532
82396
inherit Js_fold.fold as super
82533
- val hard_dependencies = Hash_set_poly. create 17
82397
+ val hard_dependencies = create 17
82534
82398
method! vident vid =
82535
82399
match vid with
82536
82400
| 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
82538
82402
| Id id -> self
82539
82403
method! expression x =
82540
82404
match x with
82541
82405
| {expression_desc = Call (_,_, {arity = NA}); _}
82542
82406
(* see [Js_exp_make.runtime_var_dot] *)
82543
82407
->
82544
- Hash_set_poly.add hard_dependencies
82408
+ add_lam_module_ident hard_dependencies
82545
82409
(Lam_module_ident.of_runtime (Ext_ident.create_js Js_config.curry));
82546
82410
super#expression x
82547
82411
| {expression_desc = Caml_block(_,_, tag, tag_info); _}
@@ -82554,7 +82418,7 @@ class count_hard_dependencies =
82554
82418
-> ()
82555
82419
| _, _
82556
82420
->
82557
- Hash_set_poly.add hard_dependencies
82421
+ add_lam_module_ident hard_dependencies
82558
82422
(Lam_module_ident.of_runtime (Ext_ident.create_js Js_config.block));
82559
82423
end;
82560
82424
super#expression x
@@ -91398,7 +91262,10 @@ end = struct
91398
91262
module E = Js_exp_make
91399
91263
91400
91264
91401
-
91265
+ (**
91266
+ [bind_name] is a hint to the compiler to generate
91267
+ better names for external module
91268
+ *)
91402
91269
let handle_external
91403
91270
({bundle ; bind_name} : Ast_external_attributes.external_module_name)
91404
91271
: Ident.t * string
@@ -91408,7 +91275,8 @@ let handle_external
91408
91275
Lam_compile_env.add_js_module bundle , bundle
91409
91276
| Some bind_name ->
91410
91277
Lam_compile_env.add_js_module
91411
- ~id:(Ext_ident.create_js_module bind_name) bundle,
91278
+ ~hint_name:bind_name
91279
+ bundle,
91412
91280
bundle
91413
91281
91414
91282
let handle_external_opt
@@ -96928,8 +96796,8 @@ let simplify_alias
96928
96796
| Ltrywith (l1, v, l2) -> Lam.try_ (simpl l1) v (simpl l2)
96929
96797
96930
96798
| 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 *)
96933
96801
| Lsequence(l1, l2)
96934
96802
-> Lam.seq (simpl l1) (simpl l2)
96935
96803
| Lwhile(l1, l2)
0 commit comments