Skip to content

Commit 3b6e2a6

Browse files
committed
Beging more conservative about lambda equivalence
1 parent 8da6979 commit 3b6e2a6

File tree

5 files changed

+83
-15
lines changed

5 files changed

+83
-15
lines changed

jscomp/core/lam_primitive.ml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ type t =
179179

180180

181181

182+
let eq_field_dbg_info (x : Lam_compat.field_dbg_info) (y : Lam_compat.field_dbg_info) =
183+
x = y (* save it to avoid conditional compilation, fix it later *)
184+
185+
let eq_set_field_dbg_info (x : Lam_compat.set_field_dbg_info) (y : Lam_compat.set_field_dbg_info) =
186+
x = y (* save it to avoid conditional compilation, fix it later *)
182187

183188
let eq_record_representation ( p : record_representation) ( p1 : record_representation) =
184189
match p with
@@ -267,12 +272,19 @@ let eq_primitive_approx ( lhs : t) (rhs : t) =
267272
| Pccall {prim_name = n1; prim_native_name = nn1; _}
268273
-> n0 = n1 && nn0 = nn1
269274
| _ -> false )
270-
| Pfield (n0, _dbg_info0) -> (match rhs with Pfield (n1, _dbg_info1) -> n0 = n1 | _ -> false )
271-
| Psetfield(i0, _dbg_info0) -> (match rhs with Psetfield(i1, _dbg_info1) -> i0 = i1 | _ -> false)
275+
| Pfield (n0, info0) ->
276+
(match rhs with Pfield (n1, info1) -> n0 = n1 && eq_field_dbg_info info0 info1 | _ -> false )
277+
| Pfloatfield (i0, info0) ->
278+
(match rhs with Pfloatfield (i1,info1) -> i0 = i1 && eq_field_dbg_info info0 info1 | _ -> false)
279+
| Psetfield(i0, info0) ->
280+
(match rhs with Psetfield(i1, info1) -> i0 = i1 && eq_set_field_dbg_info info0 info1 | _ -> false)
281+
| Psetfloatfield (i0, info0) ->
282+
(match rhs with Psetfloatfield(i1,info1) -> i0 = i1 && eq_set_field_dbg_info info0 info1 | _ -> false)
283+
| Pmakeblock (i, info0, flag0) ->
284+
(match rhs with Pmakeblock(i1,info1,flag1) ->
285+
i = i1 && flag0 = flag1 && info0 = info1 | _ -> false)
286+
272287
| Pglobal_exception ident -> (match rhs with Pglobal_exception ident2 -> Ident.same ident ident2 | _ -> false )
273-
| Pmakeblock (i, _tag_info, mutable_flag) -> (match rhs with Pmakeblock(i1,_,mutable_flag1) -> i = i1 && mutable_flag = mutable_flag1 | _ -> false)
274-
| Pfloatfield (i0,_dbg_info) -> (match rhs with Pfloatfield (i1,_) -> i0 = i1 | _ -> false)
275-
| Psetfloatfield (i0,_dbg_info) -> (match rhs with Psetfloatfield(i1,_) -> i0 = i1 | _ -> false)
276288
| Pduprecord (record_repesentation0,i1) -> (match rhs with Pduprecord(record_repesentation1,i2) -> eq_record_representation record_repesentation0 record_repesentation1 && i1 = i2 | _ -> false)
277289
| Pjs_call (prim_name, arg_types, ffi) -> ( match rhs with Pjs_call(prim_name1, arg_types1,ffi1) -> prim_name = prim_name1 && arg_types = arg_types1 && ffi = ffi1 | _ -> false)
278290
| Pjs_object_create obj_create -> (match rhs with Pjs_object_create obj_create1 -> obj_create = obj_create1 | _ -> false )

jscomp/test/ocaml_proto_test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2898,7 +2898,17 @@ function gen_sig(and_, t, sc) {
28982898
var tmp;
28992899
switch (match.tag | 0) {
29002900
case 0 :
2901+
tmp = /* tuple */[
2902+
f(match[0][/* r_name */0]),
2903+
true
2904+
];
2905+
break;
29012906
case 1 :
2907+
tmp = /* tuple */[
2908+
f(match[0][/* v_name */0]),
2909+
true
2910+
];
2911+
break;
29022912
case 2 :
29032913
tmp = /* tuple */[
29042914
f(match[0][/* cv_name */0]),
@@ -3407,7 +3417,11 @@ function gen_sig$1(and_, t, sc) {
34073417
var match = t[/* spec */1];
34083418
switch (match.tag | 0) {
34093419
case 0 :
3420+
f(match[0][/* r_name */0]);
3421+
break;
34103422
case 1 :
3423+
f(match[0][/* v_name */0]);
3424+
break;
34113425
case 2 :
34123426
f(match[0][/* cv_name */0]);
34133427
break;
@@ -5535,7 +5549,17 @@ function gen_sig$3(and_, t, sc) {
55355549
var tmp;
55365550
switch (match.tag | 0) {
55375551
case 0 :
5552+
tmp = /* tuple */[
5553+
f(match[0][/* r_name */0]),
5554+
true
5555+
];
5556+
break;
55385557
case 1 :
5558+
tmp = /* tuple */[
5559+
f(match[0][/* v_name */0]),
5560+
true
5561+
];
5562+
break;
55395563
case 2 :
55405564
tmp = /* tuple */[
55415565
f(match[0][/* cv_name */0]),
@@ -6178,6 +6202,11 @@ function gen_sig$4(and_, t, sc) {
61786202
];
61796203
break;
61806204
case 1 :
6205+
tmp = /* tuple */[
6206+
f(match[0][/* v_name */0]),
6207+
true
6208+
];
6209+
break;
61816210
case 2 :
61826211
tmp = /* tuple */[
61836212
f(match[0][/* cv_name */0]),

jscomp/test/ocaml_typedtree_test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47376,8 +47376,11 @@ register_error_of_exn((function (param) {
4737647376
function get_location(ti) {
4737747377
switch (ti.tag | 0) {
4737847378
case 0 :
47379+
return ti[0][/* pat_loc */1];
4737947380
case 1 :
47381+
return ti[0][/* exp_loc */1];
4738047382
case 2 :
47383+
return ti[0][/* cl_loc */1];
4738147384
case 3 :
4738247385
return ti[0][/* mod_loc */1];
4738347386
case 4 :

lib/4.02.3/unstable/js_compiler.ml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73927,6 +73927,11 @@ type t =
7392773927

7392873928

7392973929

73930+
let eq_field_dbg_info (x : Lam_compat.field_dbg_info) (y : Lam_compat.field_dbg_info) =
73931+
x = y (* save it to avoid conditional compilation, fix it later *)
73932+
73933+
let eq_set_field_dbg_info (x : Lam_compat.set_field_dbg_info) (y : Lam_compat.set_field_dbg_info) =
73934+
x = y (* save it to avoid conditional compilation, fix it later *)
7393073935

7393173936
let eq_record_representation ( p : record_representation) ( p1 : record_representation) =
7393273937
match p with
@@ -74004,12 +74009,19 @@ let eq_primitive_approx ( lhs : t) (rhs : t) =
7400474009
| Pccall {prim_name = n1; prim_native_name = nn1; _}
7400574010
-> n0 = n1 && nn0 = nn1
7400674011
| _ -> false )
74007-
| Pfield (n0, _dbg_info0) -> (match rhs with Pfield (n1, _dbg_info1) -> n0 = n1 | _ -> false )
74008-
| Psetfield(i0, _dbg_info0) -> (match rhs with Psetfield(i1, _dbg_info1) -> i0 = i1 | _ -> false)
74012+
| Pfield (n0, info0) ->
74013+
(match rhs with Pfield (n1, info1) -> n0 = n1 && eq_field_dbg_info info0 info1 | _ -> false )
74014+
| Pfloatfield (i0, info0) ->
74015+
(match rhs with Pfloatfield (i1,info1) -> i0 = i1 && eq_field_dbg_info info0 info1 | _ -> false)
74016+
| Psetfield(i0, info0) ->
74017+
(match rhs with Psetfield(i1, info1) -> i0 = i1 && eq_set_field_dbg_info info0 info1 | _ -> false)
74018+
| Psetfloatfield (i0, info0) ->
74019+
(match rhs with Psetfloatfield(i1,info1) -> i0 = i1 && eq_set_field_dbg_info info0 info1 | _ -> false)
74020+
| Pmakeblock (i, info0, flag0) ->
74021+
(match rhs with Pmakeblock(i1,info1,flag1) ->
74022+
i = i1 && flag0 = flag1 && info0 = info1 | _ -> false)
74023+
7400974024
| Pglobal_exception ident -> (match rhs with Pglobal_exception ident2 -> Ident.same ident ident2 | _ -> false )
74010-
| Pmakeblock (i, _tag_info, mutable_flag) -> (match rhs with Pmakeblock(i1,_,mutable_flag1) -> i = i1 && mutable_flag = mutable_flag1 | _ -> false)
74011-
| Pfloatfield (i0,_dbg_info) -> (match rhs with Pfloatfield (i1,_) -> i0 = i1 | _ -> false)
74012-
| Psetfloatfield (i0,_dbg_info) -> (match rhs with Psetfloatfield(i1,_) -> i0 = i1 | _ -> false)
7401374025
| Pduprecord (record_repesentation0,i1) -> (match rhs with Pduprecord(record_repesentation1,i2) -> eq_record_representation record_repesentation0 record_repesentation1 && i1 = i2 | _ -> false)
7401474026
| Pjs_call (prim_name, arg_types, ffi) -> ( match rhs with Pjs_call(prim_name1, arg_types1,ffi1) -> prim_name = prim_name1 && arg_types = arg_types1 && ffi = ffi1 | _ -> false)
7401574027
| Pjs_object_create obj_create -> (match rhs with Pjs_object_create obj_create1 -> obj_create = obj_create1 | _ -> false )

lib/4.02.3/whole_compiler.ml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65500,6 +65500,11 @@ type t =
6550065500

6550165501

6550265502

65503+
let eq_field_dbg_info (x : Lam_compat.field_dbg_info) (y : Lam_compat.field_dbg_info) =
65504+
x = y (* save it to avoid conditional compilation, fix it later *)
65505+
65506+
let eq_set_field_dbg_info (x : Lam_compat.set_field_dbg_info) (y : Lam_compat.set_field_dbg_info) =
65507+
x = y (* save it to avoid conditional compilation, fix it later *)
6550365508

6550465509
let eq_record_representation ( p : record_representation) ( p1 : record_representation) =
6550565510
match p with
@@ -65577,12 +65582,19 @@ let eq_primitive_approx ( lhs : t) (rhs : t) =
6557765582
| Pccall {prim_name = n1; prim_native_name = nn1; _}
6557865583
-> n0 = n1 && nn0 = nn1
6557965584
| _ -> false )
65580-
| Pfield (n0, _dbg_info0) -> (match rhs with Pfield (n1, _dbg_info1) -> n0 = n1 | _ -> false )
65581-
| Psetfield(i0, _dbg_info0) -> (match rhs with Psetfield(i1, _dbg_info1) -> i0 = i1 | _ -> false)
65585+
| Pfield (n0, info0) ->
65586+
(match rhs with Pfield (n1, info1) -> n0 = n1 && eq_field_dbg_info info0 info1 | _ -> false )
65587+
| Pfloatfield (i0, info0) ->
65588+
(match rhs with Pfloatfield (i1,info1) -> i0 = i1 && eq_field_dbg_info info0 info1 | _ -> false)
65589+
| Psetfield(i0, info0) ->
65590+
(match rhs with Psetfield(i1, info1) -> i0 = i1 && eq_set_field_dbg_info info0 info1 | _ -> false)
65591+
| Psetfloatfield (i0, info0) ->
65592+
(match rhs with Psetfloatfield(i1,info1) -> i0 = i1 && eq_set_field_dbg_info info0 info1 | _ -> false)
65593+
| Pmakeblock (i, info0, flag0) ->
65594+
(match rhs with Pmakeblock(i1,info1,flag1) ->
65595+
i = i1 && flag0 = flag1 && info0 = info1 | _ -> false)
65596+
6558265597
| Pglobal_exception ident -> (match rhs with Pglobal_exception ident2 -> Ident.same ident ident2 | _ -> false )
65583-
| Pmakeblock (i, _tag_info, mutable_flag) -> (match rhs with Pmakeblock(i1,_,mutable_flag1) -> i = i1 && mutable_flag = mutable_flag1 | _ -> false)
65584-
| Pfloatfield (i0,_dbg_info) -> (match rhs with Pfloatfield (i1,_) -> i0 = i1 | _ -> false)
65585-
| Psetfloatfield (i0,_dbg_info) -> (match rhs with Psetfloatfield(i1,_) -> i0 = i1 | _ -> false)
6558665598
| Pduprecord (record_repesentation0,i1) -> (match rhs with Pduprecord(record_repesentation1,i2) -> eq_record_representation record_repesentation0 record_repesentation1 && i1 = i2 | _ -> false)
6558765599
| Pjs_call (prim_name, arg_types, ffi) -> ( match rhs with Pjs_call(prim_name1, arg_types1,ffi1) -> prim_name = prim_name1 && arg_types = arg_types1 && ffi = ffi1 | _ -> false)
6558865600
| Pjs_object_create obj_create -> (match rhs with Pjs_object_create obj_create1 -> obj_create = obj_create1 | _ -> false )

0 commit comments

Comments
 (0)