Skip to content

Commit 7dd10d7

Browse files
committed
Use new representaiton where args are strings not numbers.
Instead of using 0, 1, 2 for variant arguments, use "Arg0", "Arg1", "Arg2". This avoids the perf issues with `record_bench.js`, in fact the test becomes faster.
1 parent 45924dc commit 7dd10d7

File tree

338 files changed

+57809
-45008
lines changed

Some content is hidden

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

338 files changed

+57809
-45008
lines changed

jscomp/core/js_exp_make.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,16 @@ let make_block ?comment
186186
let name = match Lam_compile_util.comment_of_tag_info tag_info with
187187
| Some s -> s
188188
| None -> assert false in
189-
{
189+
(* {
190190
expression_desc = Caml_block( es, mutable_flag, str name, tag_info) ;
191191
comment
192-
}
193-
(* let comment = Some "constructor" in
192+
} *)
193+
let comment = Some "constructor" in
194194
let property_map = [
195195
("tag", str name);
196196
]
197-
@ List.mapi (fun n e -> (string_of_int n, e)) es in
198-
{expression_desc = Object property_map; comment} *)
197+
@ List.mapi (fun n e -> ("Arg" ^ string_of_int n, e)) es in
198+
{expression_desc = Object property_map; comment}
199199
| _ ->
200200
let comment =
201201
match comment with

jscomp/core/js_of_lam_block.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ let field (field_info : Lam_compat.field_dbg_info) e i =
6161
-> E.array_index_by_int ~comment e i
6262
| Fld_module name
6363
-> E.module_access e name i
64+
| Fld_arg pos
65+
-> E.dot e ("Arg" ^ string_of_int pos)
6466
let field_by_exp e i =
6567
E.array_index e i
6668

jscomp/core/js_of_lam_float_record.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ module E = Js_exp_make
3131

3232
let get_double_feild (field_info : Lam_compat.field_dbg_info) e i =
3333
match field_info with
34-
| Fld_na ->
34+
| Fld_na
35+
| Fld_arg _ ->
3536
E.array_index_by_int e i
3637
#if OCAML_VERSION =~ ">4.03.0" then
3738
| Fld_record_inline s

jscomp/core/js_of_lam_record.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ module E = Js_exp_make
4343

4444
let field (field_info : Lam_compat.field_dbg_info) e i =
4545
match field_info with
46-
| Fld_na ->
46+
| Fld_na
47+
| Fld_arg _ ->
4748
E.array_index_by_int e i
4849
#if OCAML_VERSION =~ ">4.03.0" then
4950
| Fld_record_inline s

jscomp/core/lam_compat.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ type meth_kind = Lambda.meth_kind
185185
type field_dbg_info = Lambda.field_dbg_info =
186186
| Fld_na
187187
| Fld_record of string
188-
| Fld_module of string
188+
| Fld_module of string
189+
| Fld_arg of int
189190
#if OCAML_VERSION =~ ">4.03.0" then
190191
| Fld_record_inline of string
191192
| Fld_record_extension of string

jscomp/core/lam_compat.mli

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ type meth_kind = Lambda.meth_kind
8686
type field_dbg_info = Lambda.field_dbg_info =
8787
| Fld_na
8888
| Fld_record of string
89-
| Fld_module of string
89+
| Fld_module of string
90+
| Fld_arg of int
9091
#if OCAML_VERSION =~ ">4.03.0" then
9192
| Fld_record_inline of string
9293
| Fld_record_extension of string

jscomp/core/lam_print.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ let primitive ppf (prim : Lam_primitive.t) = match prim with
153153
-> fprintf ppf "field %s/%i" s n
154154
| Pfield (n, Fld_na)
155155
-> fprintf ppf "field %i" n
156+
| Pfield (n, Fld_arg _)
157+
-> fprintf ppf "field_arg %i" n
156158
| Pfield_computed ->
157159
fprintf ppf "field_computed"
158160
| Psetfield_computed ->

jscomp/others/belt_List.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,20 @@ external mutableCell :
7373
*)
7474
external unsafeMutateTail :
7575
'a t -> 'a t -> unit = "#setfield1"
76+
let unsafeMutateTail0 = fun%raw l x -> {|
77+
l.Arg1 = x;
78+
|}
79+
let unsafeMutateTail : 'a t -> 'a t -> unit = unsafeMutateTail0
7680
(*
7781
- the cell is not empty
7882
- it is mutated
7983
*)
8084
external unsafeTail :
8185
'a t -> 'a t = "%field1"
86+
let unsafeTail0 = fun%raw l -> {|
87+
return l.Arg1
88+
|}
89+
let unsafeTail : 'a t -> 'a t = unsafeTail0
8290
(*
8391
- the cell is not empty
8492
*)

jscomp/runtime/release.ninja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ build runtime/caml_int32.cmj : cc_cmi runtime/caml_int32.ml | runtime/caml_built
4040
build runtime/caml_int32.cmi : cc runtime/caml_int32.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
4141
build runtime/caml_int64.cmj : cc_cmi runtime/caml_int64.ml | runtime/caml_builtin_exceptions.cmj runtime/caml_char.cmj runtime/caml_float.cmj runtime/caml_float_extern.cmj runtime/caml_int32.cmj runtime/caml_int64.cmi runtime/caml_nativeint_extern.cmj runtime/caml_primitive.cmj runtime/caml_string_extern.cmj runtime/caml_utils.cmj runtime/js.cmj
4242
build runtime/caml_int64.cmi : cc runtime/caml_int64.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
43-
build runtime/caml_io.cmj : cc_cmi runtime/caml_io.ml | runtime/block.cmj runtime/caml_io.cmi runtime/caml_string_extern.cmj runtime/caml_undefined_extern.cmj runtime/curry.cmj runtime/js.cmj
43+
build runtime/caml_io.cmj : cc_cmi runtime/caml_io.ml | runtime/caml_io.cmi runtime/caml_string_extern.cmj runtime/caml_undefined_extern.cmj runtime/curry.cmj runtime/js.cmj
4444
build runtime/caml_io.cmi : cc runtime/caml_io.mli | runtime/bs_stdlib_mini.cmi runtime/caml_undefined_extern.cmj runtime/js.cmi runtime/js.cmj
4545
build runtime/caml_lexer.cmj : cc_cmi runtime/caml_lexer.ml | runtime/caml_builtin_exceptions.cmj runtime/caml_lexer.cmi
4646
build runtime/caml_lexer.cmi : cc runtime/caml_lexer.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj

jscomp/test/a_filename_test.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
var Mt = require("./mt.js");
44
var $$Array = require("../../lib/js/array.js");
5-
var Block = require("../../lib/js/block.js");
65
var Ext_filename_test = require("./ext_filename_test.js");
76

87
var suites = /* record */[/* contents */"[]"];
@@ -11,18 +10,20 @@ var test_id = /* record */[/* contents */0];
1110

1211
function eq(loc, x, y) {
1312
test_id[0] = test_id[0] + 1 | 0;
14-
suites[0] = Block.__("::", [
15-
/* tuple */[
16-
loc + (" id " + String(test_id[0])),
17-
(function (param) {
18-
return Block.__("Eq", [
19-
x,
20-
y
21-
]);
22-
})
23-
],
24-
suites[0]
25-
]);
13+
suites[0] = /* constructor */{
14+
tag: "::",
15+
Arg0: /* tuple */[
16+
loc + (" id " + String(test_id[0])),
17+
(function (param) {
18+
return /* constructor */{
19+
tag: "Eq",
20+
Arg0: x,
21+
Arg1: y
22+
};
23+
})
24+
],
25+
Arg1: suites[0]
26+
};
2627
return /* () */0;
2728
}
2829

0 commit comments

Comments
 (0)