Skip to content

Remove uncurried application entirely #6902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
12 changes: 1 addition & 11 deletions jscomp/core/lam_convert.ml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ let unit = Lam.unit
let lam_prim ~primitive:(p : Lambda.primitive) ~args loc : Lam.t =
match p with
| Pidentity -> Ext_list.singleton_exn args
| Puncurried_apply | Pccall _ -> assert false
| Pccall _ -> assert false
| Prevapply -> assert false
| Pdirapply -> assert false
| Ploc _ -> assert false (* already compiled away here*)
Expand Down Expand Up @@ -584,16 +584,6 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) :
may_depend may_depends (Lam_module_ident.of_ml ~dynamic_import id);
assert (args = []);
Lam.global_module ~dynamic_import id)
| Lprim
( Puncurried_apply,
[ Lapply { ap_func; ap_args } ],
loc ) ->
let ap_func = convert_aux ap_func in
let ap_args = Ext_list.map ap_args convert_aux in
prim ~primitive:Pfull_apply ~args:(ap_func :: ap_args) loc
(* There may be some optimization opportunities here
for cases like `(fun [@bs] a b -> a + b ) 1 2 [@bs]` *)
| Lprim (Puncurried_apply, _, _) -> assert false
| Lprim (primitive, args, loc) ->
let args = Ext_list.map args (convert_aux ~dynamic_import) in
lam_prim ~primitive ~args loc
Expand Down
4 changes: 0 additions & 4 deletions jscomp/frontend/ast_literal.ml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ module Lid = struct

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

(* TODO should be renamed in to {!Js.fn} *)
(* TODO should be moved into {!Js.t} Later *)
let js_internal : t = Ldot (Lident "Js", "Internal")

let js_oo : t = Lident "Js_OO"

let js_meth_callback : t = Ldot (js_oo, "Callback")
Expand Down
2 changes: 0 additions & 2 deletions jscomp/frontend/ast_literal.mli
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ module Lid : sig
val js_null_undefined : t

val js_re_id : t

val js_internal : t
end

type expression_lit = Parsetree.expression lit
Expand Down
1 change: 0 additions & 1 deletion jscomp/ml/lambda.ml
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ type primitive =
| Pasrbint of boxed_integer
| Pbintcomp of boxed_integer * comparison
| Pctconst of compile_time_constant
| Puncurried_apply
| Pcreate_extension of string
and comparison =
Ceq | Cneq | Clt | Cgt | Cle | Cge
Expand Down
1 change: 0 additions & 1 deletion jscomp/ml/lambda.mli
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ type primitive =
| Pasrbint of boxed_integer
| Pbintcomp of boxed_integer * comparison
| Pctconst of compile_time_constant
| Puncurried_apply
| Pcreate_extension of string
and comparison =
Ceq | Cneq | Clt | Cgt | Cle | Cge
Expand Down
2 changes: 0 additions & 2 deletions jscomp/ml/printlambda.ml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ let print_taginfo ppf = function
-> fprintf ppf "[%s]" (String.concat ";" (Array.to_list ss) )

let primitive ppf = function
| Puncurried_apply -> fprintf ppf "@app"
| Pidentity -> fprintf ppf "id"
| Pbytes_to_string -> fprintf ppf "bytes_to_string"
| Pignore -> fprintf ppf "ignore"
Expand Down Expand Up @@ -253,7 +252,6 @@ let primitive ppf = function
| Pbintcomp(bi, Cge) -> print_boxed_integer ">=" ppf bi
| Pcreate_extension s -> fprintf ppf "extension[%s]" s
let name_of_primitive = function
| Puncurried_apply -> "Puncurried_apply"
| Pidentity -> "Pidentity"
| Pbytes_to_string -> "Pbytes_to_string"
| Pignore -> "Pignore"
Expand Down
4 changes: 1 addition & 3 deletions jscomp/ml/translcore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,6 @@ let primitives_table =
("%int64_to_int32", Pcvtbint (Pint64, Pint32));
("%int64_of_bigint", Pcvtbint (Pbigint, Pint64));
("%int64_to_bigint", Pcvtbint (Pint64, Pbigint));
("%uncurried_apply", Puncurried_apply);
]

let find_primitive prim_name = Hashtbl.find primitives_table prim_name
Expand Down Expand Up @@ -1101,11 +1100,10 @@ and transl_apply ?(inlined = Default_inline) ?(uncurried_partial_application=Non
let extra_args = Ext_list.map extra_ids (fun id -> Lvar id) in
let ap_args = args @ extra_args in
let l0 = Lapply { ap_func = lam; ap_args; ap_inlined = inlined; ap_loc = loc } in
let l1 = Lprim (Puncurried_apply, [l0], loc) in
Lfunction
{
params = List.rev_append !none_ids extra_ids ;
body = l1;
body = l0;
attr = default_function_attribute;
loc;
}
Expand Down
12 changes: 0 additions & 12 deletions jscomp/ml/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2153,18 +2153,6 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg=Rejected) env sexp ty
end_def ();
unify_var env (newvar()) funct.exp_type;

let mk_exp ?(loc=Location.none) exp_desc exp_type =
{ exp_desc;
exp_loc = loc; exp_extra = [];
exp_type;
exp_attributes = [];
exp_env = env } in
let _apply_internal name e =
let lid:Longident.t = Ldot (Ldot (Lident "Js", "Internal"), name) in
let (path, desc) = Env.lookup_value lid env in
let id = mk_exp (Texp_ident(path, {txt=lid; loc=Location.none}, desc)) desc.val_type in
mk_exp ~loc:e.exp_loc (Texp_apply(id, [(Nolabel, Some e)])) e.exp_type in

let mk_apply funct args =
rue {
exp_desc = Texp_apply(funct, args);
Expand Down
7 changes: 0 additions & 7 deletions jscomp/others/js.res
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,6 @@ Prefer `Js.Array2` over `Js.Array`, `Js.String2` over `Js.String`, etc. The latt
/** JS object type */
type t<'a> = {..} as 'a

module Internal = {
external opaqueFullApply: 'a => 'a = "%uncurried_apply"

/* Use opaque instead of [._n] to prevent some optimizations happening */
external run: ((. unit) => 'a) => 'a = "#run"
}

/**
Nullable value of this type can be either null or 'a. This type is equivalent to Js.Null.t.
*/
Expand Down
7 changes: 0 additions & 7 deletions jscomp/runtime/js.res
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,6 @@ Prefer `Js.Array2` over `Js.Array`, `Js.String2` over `Js.String`, etc. The latt
/** JS object type */
type t<'a> = {..} as 'a

module Internal = {
external opaqueFullApply: 'a => 'a = "%uncurried_apply"

/* Use opaque instead of [._n] to prevent some optimizations happening */
external run: ((. unit) => 'a) => 'a = "#run"
}

/**
Nullable value of this type can be either null or 'a. This type is equivalent to Js.Null.t.
*/
Expand Down
3 changes: 2 additions & 1 deletion jscomp/test/PartialApplicationNoRuntimeCurry.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion jscomp/test/UncurriedAlways.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jscomp/test/bs_abstract_test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading