Skip to content

Commit 3eedc37

Browse files
committed
Remove opaque full apply entirely.
Opaque full apply was still used in the case of partial application `foo(x, ...)`. With the last use gone, the `Js.Internal` module can be removed. One less piece of magic.
1 parent 55aed66 commit 3eedc37

29 files changed

+160
-340
lines changed

jscomp/core/lam_convert.ml

+1-11
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ let unit = Lam.unit
161161
let lam_prim ~primitive:(p : Lambda.primitive) ~args loc : Lam.t =
162162
match p with
163163
| Pidentity -> Ext_list.singleton_exn args
164-
| Puncurried_apply | Pccall _ -> assert false
164+
| Pccall _ -> assert false
165165
| Prevapply -> assert false
166166
| Pdirapply -> assert false
167167
| Ploc _ -> assert false (* already compiled away here*)
@@ -584,16 +584,6 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) :
584584
may_depend may_depends (Lam_module_ident.of_ml ~dynamic_import id);
585585
assert (args = []);
586586
Lam.global_module ~dynamic_import id)
587-
| Lprim
588-
( Puncurried_apply,
589-
[ Lapply { ap_func; ap_args } ],
590-
loc ) ->
591-
let ap_func = convert_aux ap_func in
592-
let ap_args = Ext_list.map ap_args convert_aux in
593-
prim ~primitive:Pfull_apply ~args:(ap_func :: ap_args) loc
594-
(* There may be some optimization opportunities here
595-
for cases like `(fun [@bs] a b -> a + b ) 1 2 [@bs]` *)
596-
| Lprim (Puncurried_apply, _, _) -> assert false
597587
| Lprim (primitive, args, loc) ->
598588
let args = Ext_list.map args (convert_aux ~dynamic_import) in
599589
lam_prim ~primitive ~args loc

jscomp/frontend/ast_literal.ml

-4
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ module Lid = struct
4949

5050
let type_bool : t = Lident "bool" (* use *predef* *)
5151

52-
(* TODO should be renamed in to {!Js.fn} *)
53-
(* TODO should be moved into {!Js.t} Later *)
54-
let js_internal : t = Ldot (Lident "Js", "Internal")
55-
5652
let js_oo : t = Lident "Js_OO"
5753

5854
let js_meth_callback : t = Ldot (js_oo, "Callback")

jscomp/frontend/ast_literal.mli

-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ module Lid : sig
5656
val js_null_undefined : t
5757

5858
val js_re_id : t
59-
60-
val js_internal : t
6159
end
6260

6361
type expression_lit = Parsetree.expression lit

jscomp/ml/lambda.ml

-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ type primitive =
266266
| Pasrbint of boxed_integer
267267
| Pbintcomp of boxed_integer * comparison
268268
| Pctconst of compile_time_constant
269-
| Puncurried_apply
270269
| Pcreate_extension of string
271270
and comparison =
272271
Ceq | Cneq | Clt | Cgt | Cle | Cge

jscomp/ml/lambda.mli

-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ type primitive =
233233
| Pasrbint of boxed_integer
234234
| Pbintcomp of boxed_integer * comparison
235235
| Pctconst of compile_time_constant
236-
| Puncurried_apply
237236
| Pcreate_extension of string
238237
and comparison =
239238
Ceq | Cneq | Clt | Cgt | Cle | Cge

jscomp/ml/printlambda.ml

-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ let print_taginfo ppf = function
121121
-> fprintf ppf "[%s]" (String.concat ";" (Array.to_list ss) )
122122

123123
let primitive ppf = function
124-
| Puncurried_apply -> fprintf ppf "@app"
125124
| Pidentity -> fprintf ppf "id"
126125
| Pbytes_to_string -> fprintf ppf "bytes_to_string"
127126
| Pignore -> fprintf ppf "ignore"
@@ -253,7 +252,6 @@ let primitive ppf = function
253252
| Pbintcomp(bi, Cge) -> print_boxed_integer ">=" ppf bi
254253
| Pcreate_extension s -> fprintf ppf "extension[%s]" s
255254
let name_of_primitive = function
256-
| Puncurried_apply -> "Puncurried_apply"
257255
| Pidentity -> "Pidentity"
258256
| Pbytes_to_string -> "Pbytes_to_string"
259257
| Pignore -> "Pignore"

jscomp/ml/translcore.ml

+1-3
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,6 @@ let primitives_table =
422422
("%int64_to_int32", Pcvtbint (Pint64, Pint32));
423423
("%int64_of_bigint", Pcvtbint (Pbigint, Pint64));
424424
("%int64_to_bigint", Pcvtbint (Pint64, Pbigint));
425-
("%uncurried_apply", Puncurried_apply);
426425
]
427426

428427
let find_primitive prim_name = Hashtbl.find primitives_table prim_name
@@ -1101,11 +1100,10 @@ and transl_apply ?(inlined = Default_inline) ?(uncurried_partial_application=Non
11011100
let extra_args = Ext_list.map extra_ids (fun id -> Lvar id) in
11021101
let ap_args = args @ extra_args in
11031102
let l0 = Lapply { ap_func = lam; ap_args; ap_inlined = inlined; ap_loc = loc } in
1104-
let l1 = Lprim (Puncurried_apply, [l0], loc) in
11051103
Lfunction
11061104
{
11071105
params = List.rev_append !none_ids extra_ids ;
1108-
body = l1;
1106+
body = l0;
11091107
attr = default_function_attribute;
11101108
loc;
11111109
}

jscomp/ml/typecore.ml

-12
Original file line numberDiff line numberDiff line change
@@ -2153,18 +2153,6 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg=Rejected) env sexp ty
21532153
end_def ();
21542154
unify_var env (newvar()) funct.exp_type;
21552155

2156-
let mk_exp ?(loc=Location.none) exp_desc exp_type =
2157-
{ exp_desc;
2158-
exp_loc = loc; exp_extra = [];
2159-
exp_type;
2160-
exp_attributes = [];
2161-
exp_env = env } in
2162-
let _apply_internal name e =
2163-
let lid:Longident.t = Ldot (Ldot (Lident "Js", "Internal"), name) in
2164-
let (path, desc) = Env.lookup_value lid env in
2165-
let id = mk_exp (Texp_ident(path, {txt=lid; loc=Location.none}, desc)) desc.val_type in
2166-
mk_exp ~loc:e.exp_loc (Texp_apply(id, [(Nolabel, Some e)])) e.exp_type in
2167-
21682156
let mk_apply funct args =
21692157
rue {
21702158
exp_desc = Texp_apply(funct, args);

jscomp/others/js.res

-7
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,6 @@ Prefer `Js.Array2` over `Js.Array`, `Js.String2` over `Js.String`, etc. The latt
7777
/** JS object type */
7878
type t<'a> = {..} as 'a
7979

80-
module Internal = {
81-
external opaqueFullApply: 'a => 'a = "%uncurried_apply"
82-
83-
/* Use opaque instead of [._n] to prevent some optimizations happening */
84-
external run: ((. unit) => 'a) => 'a = "#run"
85-
}
86-
8780
/**
8881
Nullable value of this type can be either null or 'a. This type is equivalent to Js.Null.t.
8982
*/

jscomp/runtime/js.res

-7
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,6 @@ Prefer `Js.Array2` over `Js.Array`, `Js.String2` over `Js.String`, etc. The latt
7777
/** JS object type */
7878
type t<'a> = {..} as 'a
7979

80-
module Internal = {
81-
external opaqueFullApply: 'a => 'a = "%uncurried_apply"
82-
83-
/* Use opaque instead of [._n] to prevent some optimizations happening */
84-
external run: ((. unit) => 'a) => 'a = "#run"
85-
}
86-
8780
/**
8881
Nullable value of this type can be either null or 'a. This type is equivalent to Js.Null.t.
8982
*/

jscomp/test/PartialApplicationNoRuntimeCurry.js

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/UncurriedAlways.js

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/bs_abstract_test.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/bs_array_test.js

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)