Skip to content

Commit 7f6d70e

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 c892cfb commit 7f6d70e

File tree

337 files changed

+57808
-45007
lines changed

Some content is hidden

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

337 files changed

+57808
-45007
lines changed

jscomp/core/js_exp_make.ml

+5-5
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

+2
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

+2-1
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

+2-1
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

+2-1
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

+2-1
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

+2
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

+8
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

+1-1
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

+14-13
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

jscomp/test/a_list_test.js

+118-98
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,130 @@
11
'use strict';
22

33
var Mt = require("./mt.js");
4-
var Block = require("../../lib/js/block.js");
54
var Ext_list_test = require("./ext_list_test.js");
65

7-
var suites_000 = /* tuple */[
8-
"drop",
9-
(function (param) {
10-
return Block.__("Eq", [
11-
Ext_list_test.drop(3, Block.__("::", [
12-
0,
13-
Block.__("::", [
14-
1,
15-
Block.__("::", [
16-
2,
17-
"[]"
18-
])
19-
])
20-
])),
21-
"[]"
22-
]);
23-
})
24-
];
25-
26-
var suites_001 = Block.__("::", [
27-
/* tuple */[
6+
var suites = /* constructor */{
7+
tag: "::",
8+
Arg0: /* tuple */[
9+
"drop",
10+
(function (param) {
11+
return /* constructor */{
12+
tag: "Eq",
13+
Arg0: Ext_list_test.drop(3, /* constructor */{
14+
tag: "::",
15+
Arg0: 0,
16+
Arg1: /* constructor */{
17+
tag: "::",
18+
Arg0: 1,
19+
Arg1: /* constructor */{
20+
tag: "::",
21+
Arg0: 2,
22+
Arg1: "[]"
23+
}
24+
}
25+
}),
26+
Arg1: "[]"
27+
};
28+
})
29+
],
30+
Arg1: /* constructor */{
31+
tag: "::",
32+
Arg0: /* tuple */[
2833
"drop1",
2934
(function (param) {
30-
return Block.__("Eq", [
31-
Ext_list_test.drop(2, Block.__("::", [
32-
0,
33-
Block.__("::", [
34-
1,
35-
Block.__("::", [
36-
2,
37-
"[]"
38-
])
39-
])
40-
])),
41-
Block.__("::", [
42-
2,
43-
"[]"
44-
])
45-
]);
35+
return /* constructor */{
36+
tag: "Eq",
37+
Arg0: Ext_list_test.drop(2, /* constructor */{
38+
tag: "::",
39+
Arg0: 0,
40+
Arg1: /* constructor */{
41+
tag: "::",
42+
Arg0: 1,
43+
Arg1: /* constructor */{
44+
tag: "::",
45+
Arg0: 2,
46+
Arg1: "[]"
47+
}
48+
}
49+
}),
50+
Arg1: /* constructor */{
51+
tag: "::",
52+
Arg0: 2,
53+
Arg1: "[]"
54+
}
55+
};
4656
})
4757
],
48-
Block.__("::", [
49-
/* tuple */[
50-
"flat_map",
51-
(function (param) {
52-
return Block.__("Eq", [
53-
Block.__("::", [
54-
0,
55-
Block.__("::", [
56-
0,
57-
Block.__("::", [
58-
1,
59-
Block.__("::", [
60-
1,
61-
Block.__("::", [
62-
0,
63-
"[]"
64-
])
65-
])
66-
])
67-
])
68-
]),
69-
Ext_list_test.flat_map((function (x) {
70-
if (x % 2 === 0) {
71-
return Block.__("::", [
72-
0,
73-
"[]"
74-
]);
75-
} else {
76-
return Block.__("::", [
77-
1,
78-
Block.__("::", [
79-
1,
80-
"[]"
81-
])
82-
]);
83-
}
84-
}), Block.__("::", [
85-
0,
86-
Block.__("::", [
87-
0,
88-
Block.__("::", [
89-
3,
90-
Block.__("::", [
91-
0,
92-
"[]"
93-
])
94-
])
95-
])
96-
]))
97-
]);
98-
})
99-
],
100-
"[]"
101-
])
102-
]);
103-
104-
var suites = Block.__("::", [
105-
suites_000,
106-
suites_001
107-
]);
58+
Arg1: /* constructor */{
59+
tag: "::",
60+
Arg0: /* tuple */[
61+
"flat_map",
62+
(function (param) {
63+
return /* constructor */{
64+
tag: "Eq",
65+
Arg0: /* constructor */{
66+
tag: "::",
67+
Arg0: 0,
68+
Arg1: /* constructor */{
69+
tag: "::",
70+
Arg0: 0,
71+
Arg1: /* constructor */{
72+
tag: "::",
73+
Arg0: 1,
74+
Arg1: /* constructor */{
75+
tag: "::",
76+
Arg0: 1,
77+
Arg1: /* constructor */{
78+
tag: "::",
79+
Arg0: 0,
80+
Arg1: "[]"
81+
}
82+
}
83+
}
84+
}
85+
},
86+
Arg1: Ext_list_test.flat_map((function (x) {
87+
if (x % 2 === 0) {
88+
return /* constructor */{
89+
tag: "::",
90+
Arg0: 0,
91+
Arg1: "[]"
92+
};
93+
} else {
94+
return /* constructor */{
95+
tag: "::",
96+
Arg0: 1,
97+
Arg1: /* constructor */{
98+
tag: "::",
99+
Arg0: 1,
100+
Arg1: "[]"
101+
}
102+
};
103+
}
104+
}), /* constructor */{
105+
tag: "::",
106+
Arg0: 0,
107+
Arg1: /* constructor */{
108+
tag: "::",
109+
Arg0: 0,
110+
Arg1: /* constructor */{
111+
tag: "::",
112+
Arg0: 3,
113+
Arg1: /* constructor */{
114+
tag: "::",
115+
Arg0: 0,
116+
Arg1: "[]"
117+
}
118+
}
119+
}
120+
})
121+
};
122+
})
123+
],
124+
Arg1: "[]"
125+
}
126+
}
127+
};
108128

109129
Mt.from_pair_suites("A_list_test", suites);
110130

0 commit comments

Comments
 (0)