Skip to content

Commit 5215218

Browse files
committed
WIP: external clean up
1 parent 6a11909 commit 5215218

File tree

263 files changed

+3294
-3705
lines changed

Some content is hidden

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

263 files changed

+3294
-3705
lines changed

jscomp/core/js_exp_make.ml

+10-5
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ let rec triple_equal ?comment (e0 : t) (e1 : t ) : t =
627627
| Bool _ | Number _ | Typeof _
628628
| Fun _ | Array _ | Caml_block _ )
629629
when no_side_effect e1 ->
630-
false_ (* TODO: rename it as [caml_false] *)
630+
false_
631631
|
632632
(Char_of_int _ | Char_to_int _
633633
| Bool _ | Number _ | Typeof _
@@ -985,22 +985,26 @@ let rec int_comp (cmp : Lam_compat.comparison) ?comment (e0 : t) (e1 : t) =
985985
expression_desc =
986986
Var (Qualified
987987
({kind = Runtime},
988-
Some ("caml_int_compare"))); _},
988+
Some ("int_compare"))); _},
989989
[l;r], _),
990990
Number (Int {i = 0l})
991991
-> int_comp cmp l r (* = 0 > 0 < 0 *)
992992
| Ceq, Call ({
993993
expression_desc =
994994
Var (Qualified
995995
({id = _; kind = Runtime} as iid,
996-
Some ("caml_compare"))); _} as fn,
996+
Some ("compare"))); _} as fn,
997997
([_;_] as args), call_info),
998998
Number (Int {i = 0l})
999999
->
1000+
(* This is now generalized for runtime modules
1001+
`RuntimeModule.compare x y = 0 ` -->
1002+
`RuntimeModule.equal x y`
1003+
*)
10001004
{e0 with expression_desc =
10011005
Call(
10021006
{fn with expression_desc =
1003-
Var(Qualified (iid, Some "caml_equal"))
1007+
Var(Qualified (iid, Some "equal"))
10041008
} , args, call_info)}
10051009
| Ceq, Optional_block _, Undefined
10061010
| Ceq, Undefined, Optional_block _
@@ -1426,7 +1430,8 @@ let resolve_and_apply
14261430
(runtime_call
14271431
Js_runtime_modules.external_polyfill
14281432
"resolve"
1429-
[str s ]
1433+
[str
1434+
(if s.[0] = '?' then String.sub s 1 (String.length s - 1) else s) ]
14301435
) args
14311436

14321437
let make_exception (s : string) =

jscomp/core/lam_analysis.ml

+12-13
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,23 @@ let rec no_side_effects (lam : Lam.t) : bool =
4747
| Pccall {prim_name } ->
4848
begin
4949
match prim_name,args with
50-
| ("caml_register_named_value"
50+
| (
5151
(* register to c runtime does not make sense in ocaml *)
52-
| "caml_int64_float_of_bits"
52+
"caml_int64_float_of_bits"
5353
(* more safe to check if arguments are constant *)
5454
(* non-observable side effect *)
55-
| "caml_sys_get_config"
56-
| "caml_sys_get_argv" (* should be fine *)
57-
| "caml_string_repeat"
58-
| "caml_make_vect"
59-
| "caml_create_bytes"
60-
| "caml_obj_dup"
55+
| "?sys_get_argv" (* should be fine *)
56+
| "?string_repeat"
57+
| "?make_vect"
58+
| "?create_bytes"
59+
| "?obj_dup"
6160
| "caml_array_dup"
6261

63-
| "nativeint_add"
64-
| "nativeint_div"
65-
| "nativeint_mod"
66-
| "nativeint_lsr"
67-
| "nativeint_mul"
62+
| "?nativeint_add"
63+
| "?nativeint_div"
64+
| "?nativeint_mod"
65+
| "?nativeint_lsr"
66+
| "?nativeint_mul"
6867

6968
), _ -> true
7069
| "caml_ml_open_descriptor_in", [Lconst ( (Const_int {i = 0l}))] -> true

jscomp/core/lam_compile_primitive.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ let translate loc
504504
[E.str "BS"] Immutable
505505
)
506506
| Pduprecord (Record_regular| Record_extension| Record_inlined _ ) ->
507-
Lam_dispatch_primitive.translate loc "caml_obj_dup" args
507+
Lam_dispatch_primitive.translate loc "?obj_dup" args
508508

509509
| Plazyforce
510510
(* FIXME: we don't inline lazy force or at least

0 commit comments

Comments
 (0)