Skip to content

Commit 74ac5bc

Browse files
authored
Merge pull request #2709 from BuckleScript/own_record_transl
take ownership of transl_record (for debug mode)
2 parents b48b85c + ae9c9de commit 74ac5bc

21 files changed

+1654
-728
lines changed

jscomp/core/lam.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ type primitive =
7878
(* Operations on heap blocks *)
7979
| Pmakeblock of int * tag_info * mutable_flag
8080
| Pfield of int * field_dbg_info
81-
| Psetfield of int * bool * set_field_dbg_info
81+
| Psetfield of int * set_field_dbg_info
8282
(* could have field info at least for record *)
8383
| Pfloatfield of int * field_dbg_info
8484
| Psetfloatfield of int * set_field_dbg_info
@@ -1555,7 +1555,7 @@ let lam_prim ~primitive:( p : Lambda.primitive) ~args loc : t =
15551555
-> prim ~primitive:(Pfield (id,info)) ~args loc
15561556

15571557
| Psetfield (id,b,info)
1558-
-> prim ~primitive:(Psetfield (id,b,info)) ~args loc
1558+
-> prim ~primitive:(Psetfield (id,info)) ~args loc
15591559

15601560
| Pfloatfield (id,info)
15611561
-> prim ~primitive:(Pfloatfield (id,info)) ~args loc
@@ -1857,7 +1857,7 @@ let convert exports lam : _ * _ =
18571857
| "#makemutablelist" ->
18581858
Pmakeblock(0,Lambda.Blk_constructor("::",1),Mutable)
18591859
| "#setfield1" ->
1860-
Psetfield(1, true, Fld_set_na)
1860+
Psetfield(1, Fld_set_na)
18611861
| "#undefined_to_opt" -> Pundefined_to_opt
18621862
| "#null_undefined_to_opt" -> Pnull_undefined_to_opt
18631863
| "#null_to_opt" -> Pnull_to_opt

jscomp/core/lam.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ type primitive =
7575
| Pglobal_exception of ident
7676
| Pmakeblock of int * Lambda.tag_info * Asttypes.mutable_flag
7777
| Pfield of int * Lambda.field_dbg_info
78-
| Psetfield of int * bool * Lambda.set_field_dbg_info
78+
| Psetfield of int * Lambda.set_field_dbg_info
7979
| Pfloatfield of int * Lambda.field_dbg_info
8080
| Psetfloatfield of int * Lambda.set_field_dbg_info
8181
| Pduprecord of Types.record_representation * int

jscomp/core/lam_analysis.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ and eq_primitive ( lhs : Lam.primitive) (rhs : Lam.primitive) =
546546
| Pcaml_obj_set_length -> rhs = Pcaml_obj_set_length
547547
| Pccall {prim_name = n0 ; prim_native_name = nn0} -> (match rhs with Pccall {prim_name = n1; prim_native_name = nn1} -> n0 = n1 && nn0 = nn1 | _ -> false )
548548
| Pfield (n0, _dbg_info0) -> (match rhs with Pfield (n1, _dbg_info1) -> n0 = n1 | _ -> false )
549-
| Psetfield(i0, b0, _dbg_info0) -> (match rhs with Psetfield(i1, b1, _dbg_info1) -> i0 = i1 && b0 = b1 | _ -> false)
549+
| Psetfield(i0, _dbg_info0) -> (match rhs with Psetfield(i1, _dbg_info1) -> i0 = i1 | _ -> false)
550550
| Pglobal_exception ident -> (match rhs with Pglobal_exception ident2 -> Ident.same ident ident2 | _ -> false )
551551
| Pmakeblock (i, _tag_info, mutable_flag) -> (match rhs with Pmakeblock(i1,_,mutable_flag1) -> i = i1 && mutable_flag = mutable_flag1 | _ -> false)
552552
| Pfloatfield (i0,_dbg_info) -> (match rhs with Pfloatfield (i1,_) -> i0 = i1 | _ -> false)

jscomp/core/lam_compile_primitive.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ let translate loc
609609
| [e] -> E.array_length e
610610
| _ -> assert false
611611
end
612-
| Psetfield (i, _, field_info) ->
612+
| Psetfield (i, field_info) ->
613613
begin match args with
614614
| [e0;e1] -> (** RUNTIME *)
615615
decorate_side_effect cxt

jscomp/core/lam_pass_eliminate_ref.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ let rec eliminate_ref id (lam : Lam.t) =
4949
TODO: we can refine analysis in later
5050
*)
5151
(* Lfunction(kind, params, eliminate_ref id body) *)
52-
| Lprim {primitive = Psetfield(0, _,_);
52+
| Lprim {primitive = Psetfield(0,_);
5353
args = [Lvar v; e]} when Ident.same v id ->
5454
Lam.assign id (eliminate_ref id e)
5555
| Lprim {primitive = Poffsetref delta ;

jscomp/core/lam_print.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ let primitive ppf (prim : Lam.primitive) = match prim with
139139
| Pmakeblock(tag, _, Immutable) -> fprintf ppf "makeblock %i" tag
140140
| Pmakeblock(tag, _, Mutable) -> fprintf ppf "makemutable %i" tag
141141
| Pfield (n,_) -> fprintf ppf "field %i" n
142-
| Psetfield(n, ptr, _) ->
143-
let instr = if ptr then "setfield_ptr " else "setfield_imm " in
142+
| Psetfield(n, _) ->
143+
let instr = "setfield " in
144144
fprintf ppf "%s%i" instr n
145145
| Pfloatfield (n,_) -> fprintf ppf "floatfield %i" n
146146
| Psetfloatfield (n,_) -> fprintf ppf "setfloatfield %i" n
@@ -418,7 +418,7 @@ let lambda use_env env ppf v =
418418
fprintf ppf "%s.%s/%d" id.name (get_string (id,n) env) n
419419

420420
| Lprim {
421-
primitive = Psetfield (n,_,_);
421+
primitive = Psetfield (n,_);
422422
args = [ Lglobal_module id ;
423423
e ]
424424
; _} when use_env ->

jscomp/test/bigarray_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ function sum() {
1414

1515
function init(v) {
1616
for(var i = 0 ,i_finish = Caml_missing_polyfill.not_implemented("caml_ba_dim_1") - 1 | 0; i <= i_finish; ++i){
17-
v[i] = /* array */[
18-
Caml_int32.imul(i, i),
19-
Caml_int32.imul(Caml_int32.imul(i, i), i)
17+
v[i] = /* record */[
18+
/* re */Caml_int32.imul(i, i),
19+
/* im */Caml_int32.imul(Caml_int32.imul(i, i), i)
2020
];
2121
}
2222
return /* () */0;

jscomp/test/complex_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ var suites_000 = /* tuple */[
88
"basic_add",
99
(function () {
1010
return /* Eq */Block.__(0, [
11-
/* array */[
12-
2,
13-
2
11+
/* record */[
12+
/* re */2,
13+
/* im */2
1414
],
1515
Complex.add(Complex.add(Complex.add(Complex.one, Complex.one), Complex.i), Complex.i)
1616
]);

jscomp/test/flow_parser_reg_test.js

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4467,9 +4467,21 @@ function mem(x, _param) {
44674467

44684468
function create$1(lex_env, mode) {
44694469
var lexbuf = lex_env[/* lex_lb */1];
4470-
var newrecord = lexbuf.slice();
4471-
newrecord[/* lex_buffer */1] = lexbuf[/* lex_buffer */1];
4472-
var lex_env$1 = with_lexbuf(newrecord, lex_env);
4470+
var lexbuf$1 = /* record */[
4471+
/* refill_buff */lexbuf[/* refill_buff */0],
4472+
/* lex_buffer */lexbuf[/* lex_buffer */1],
4473+
/* lex_buffer_len */lexbuf[/* lex_buffer_len */2],
4474+
/* lex_abs_pos */lexbuf[/* lex_abs_pos */3],
4475+
/* lex_start_pos */lexbuf[/* lex_start_pos */4],
4476+
/* lex_curr_pos */lexbuf[/* lex_curr_pos */5],
4477+
/* lex_last_pos */lexbuf[/* lex_last_pos */6],
4478+
/* lex_last_action */lexbuf[/* lex_last_action */7],
4479+
/* lex_eof_reached */lexbuf[/* lex_eof_reached */8],
4480+
/* lex_mem */lexbuf[/* lex_mem */9],
4481+
/* lex_start_p */lexbuf[/* lex_start_p */10],
4482+
/* lex_curr_p */lexbuf[/* lex_curr_p */11]
4483+
];
4484+
var lex_env$1 = with_lexbuf(lexbuf$1, lex_env);
44734485
return /* record */[
44744486
/* la_results : array */[],
44754487
/* la_num_lexed */0,
@@ -4537,9 +4549,21 @@ function lex(t) {
45374549
}
45384550
var lex_env$1 = match$1[0];
45394551
var lexbuf = lex_env$1[/* lex_lb */1];
4540-
var newrecord = lexbuf.slice();
4541-
newrecord[/* lex_buffer */1] = lexbuf[/* lex_buffer */1];
4542-
var cloned_env = with_lexbuf(newrecord, lex_env$1);
4552+
var lexbuf$1 = /* record */[
4553+
/* refill_buff */lexbuf[/* refill_buff */0],
4554+
/* lex_buffer */lexbuf[/* lex_buffer */1],
4555+
/* lex_buffer_len */lexbuf[/* lex_buffer_len */2],
4556+
/* lex_abs_pos */lexbuf[/* lex_abs_pos */3],
4557+
/* lex_start_pos */lexbuf[/* lex_start_pos */4],
4558+
/* lex_curr_pos */lexbuf[/* lex_curr_pos */5],
4559+
/* lex_last_pos */lexbuf[/* lex_last_pos */6],
4560+
/* lex_last_action */lexbuf[/* lex_last_action */7],
4561+
/* lex_eof_reached */lexbuf[/* lex_eof_reached */8],
4562+
/* lex_mem */lexbuf[/* lex_mem */9],
4563+
/* lex_start_p */lexbuf[/* lex_start_p */10],
4564+
/* lex_curr_p */lexbuf[/* lex_curr_p */11]
4565+
];
4566+
var cloned_env = with_lexbuf(lexbuf$1, lex_env$1);
45434567
t[/* la_lex_env */3] = lex_env$1;
45444568
Caml_array.caml_array_set(t[/* la_results */0], t[/* la_num_lexed */1], /* Some */[/* tuple */[
45454569
cloned_env,

jscomp/test/mario_game.js

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -694,9 +694,9 @@ var Sprite = /* module */[
694694
];
695695

696696
function pair_to_xy(pair) {
697-
return /* array */[
698-
pair[0],
699-
pair[1]
697+
return /* record */[
698+
/* x */pair[0],
699+
/* y */pair[1]
700700
];
701701
}
702702

@@ -850,13 +850,13 @@ function make$2($staropt$star, $staropt$star$1, spawnable, context, param) {
850850
var id$1 = id ? id[0] : new_id(/* () */0);
851851
var obj = /* record */[
852852
/* params */params,
853-
/* pos : array */[
854-
param[0],
855-
param[1]
853+
/* pos : record */[
854+
/* x */param[0],
855+
/* y */param[1]
856856
],
857-
/* vel : array */[
858-
0.0,
859-
0.0
857+
/* vel : record */[
858+
/* x */0.0,
859+
/* y */0.0
860860
],
861861
/* id */id$1,
862862
/* jumping */false,
@@ -1221,13 +1221,13 @@ function get_aabb(obj) {
12211221
var sy = match$1[1];
12221222
var sx = match$1[0];
12231223
return /* record */[
1224-
/* center : array */[
1225-
box + sx / 2,
1226-
boy + sy / 2
1224+
/* center : record */[
1225+
/* x */box + sx / 2,
1226+
/* y */boy + sy / 2
12271227
],
1228-
/* half : array */[
1229-
sx / 2,
1230-
sy / 2
1228+
/* half : record */[
1229+
/* x */sx / 2,
1230+
/* y */sy / 2
12311231
]
12321232
];
12331233
}
@@ -1512,17 +1512,17 @@ var Draw = /* module */[
15121512

15131513
function make$3(param, param$1) {
15141514
return /* record */[
1515-
/* pos : array */[
1516-
0,
1517-
0
1515+
/* pos : record */[
1516+
/* x */0,
1517+
/* y */0
15181518
],
1519-
/* v_dim : array */[
1520-
param[0],
1521-
param[1]
1519+
/* v_dim : record */[
1520+
/* x */param[0],
1521+
/* y */param[1]
15221522
],
1523-
/* m_dim : array */[
1524-
param$1[0],
1525-
param$1[1]
1523+
/* m_dim : record */[
1524+
/* x */param$1[0],
1525+
/* y */param$1[1]
15261526
]
15271527
];
15281528
}
@@ -1552,18 +1552,18 @@ function out_of_viewport_below(v, y) {
15521552
}
15531553

15541554
function coord_to_viewport(viewport, coord) {
1555-
return /* array */[
1556-
coord[/* x */0] - viewport[/* pos */0][/* x */0],
1557-
coord[/* y */1] - viewport[/* pos */0][/* y */1]
1555+
return /* record */[
1556+
/* x */coord[/* x */0] - viewport[/* pos */0][/* x */0],
1557+
/* y */coord[/* y */1] - viewport[/* pos */0][/* y */1]
15581558
];
15591559
}
15601560

15611561
function update(vpt, ctr) {
15621562
var new_x = calc_viewport_point(ctr[/* x */0], vpt[/* v_dim */1][/* x */0], vpt[/* m_dim */2][/* x */0]);
15631563
var new_y = calc_viewport_point(ctr[/* y */1], vpt[/* v_dim */1][/* y */1], vpt[/* m_dim */2][/* y */1]);
1564-
var pos = /* array */[
1565-
new_x,
1566-
new_y
1564+
var pos = /* record */[
1565+
/* x */new_x,
1566+
/* y */new_y
15671567
];
15681568
return /* record */[
15691569
/* pos */pos,
@@ -2234,18 +2234,26 @@ function update_loop(canvas, param, map_dim) {
22342234
if (player$1[2][/* kill */8] === true) {
22352235
return game_loss(state[/* ctx */1]);
22362236
} else {
2237-
var newrecord = state.slice();
2238-
newrecord[/* vpt */2] = update(state[/* vpt */2], player$1[2][/* pos */1]);
2237+
var state$1 = /* record */[
2238+
/* bgd */state[/* bgd */0],
2239+
/* ctx */state[/* ctx */1],
2240+
/* vpt */update(state[/* vpt */2], player$1[2][/* pos */1]),
2241+
/* map */state[/* map */3],
2242+
/* score */state[/* score */4],
2243+
/* coins */state[/* coins */5],
2244+
/* multiplier */state[/* multiplier */6],
2245+
/* game_over */state[/* game_over */7]
2246+
];
22392247
List.iter((function (obj) {
2240-
run_update_collid(newrecord, obj, objs);
2248+
run_update_collid(state$1, obj, objs);
22412249
return /* () */0;
22422250
}), objs);
22432251
List.iter((function (part) {
2244-
var state = newrecord;
2252+
var state$2 = state$1;
22452253
var part$1 = part;
22462254
$$process(part$1);
2247-
var x = part$1[/* pos */2][/* x */0] - state[/* vpt */2][/* pos */0][/* x */0];
2248-
var y = part$1[/* pos */2][/* y */1] - state[/* vpt */2][/* pos */0][/* y */1];
2255+
var x = part$1[/* pos */2][/* x */0] - state$2[/* vpt */2][/* pos */0][/* x */0];
2256+
var y = part$1[/* pos */2][/* y */1] - state$2[/* vpt */2][/* pos */0][/* y */1];
22492257
render(part$1[/* params */0][/* sprite */0], /* tuple */[
22502258
x,
22512259
y
@@ -2261,9 +2269,9 @@ function update_loop(canvas, param, map_dim) {
22612269
}
22622270
}), parts);
22632271
fps(canvas, fps$1);
2264-
hud(canvas, newrecord[/* score */4], newrecord[/* coins */5]);
2272+
hud(canvas, state$1[/* score */4], state$1[/* coins */5]);
22652273
requestAnimationFrame((function (t) {
2266-
return update_helper(t, newrecord, player$1, collid_objs[0], particles[0]);
2274+
return update_helper(t, state$1, player$1, collid_objs[0], particles[0]);
22672275
}));
22682276
return /* () */0;
22692277
}

0 commit comments

Comments
 (0)