Skip to content
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
4 changes: 3 additions & 1 deletion jscomp/core/lam_analysis.ml
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ let rec no_side_effects (lam : Lam.t) : bool =
*)
exception Too_big_to_inline

let really_big () = raise Too_big_to_inline
let really_big () = raise_notrace Too_big_to_inline

let big_lambda = 1000

Expand All @@ -278,6 +278,8 @@ let rec size (lam : Lam.t) =
| Lprim {primitive = Praise ; args = [l ]; _}
-> size l
| Lam.Lglobal_module _ -> 1
| Lprim {primitive = Praw_js_code_exp _ | Praw_js_code_stmt _} ->
really_big ()
| Lprim {args = ll; _} -> size_lams 1 ll

(** complicated
Expand Down
1 change: 1 addition & 0 deletions jscomp/test/.depend
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ gpr_2633_test.cmj :
gpr_2642_test.cmj :
gpr_2652_test.cmj : ../others/node.cmj ../stdlib/buffer.cmj
gpr_2700_test.cmj :
gpr_2731_test.cmj :
gpr_405_test.cmj : ../stdlib/hashtbl.cmj gpr_405_test.cmi
gpr_441.cmj :
gpr_459_test.cmj : mt.cmj
Expand Down
1 change: 1 addition & 0 deletions jscomp/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ OTHERS := test_literals a test_ari test_export2 test_internalOO test_obj_simple_
gpr_2652_test\
gpr_2614_test\
gpr_2700_test\
gpr_2731_test\
# bs_uncurry_test
# needs Lam to get rid of Uncurry arity first
# simple_derive_test
Expand Down
26 changes: 26 additions & 0 deletions jscomp/test/gpr_2731_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';


function f(x) {
return x + (1) | 0;
}

var a = f(1);

var b = f(2);

function g() {
return (1);
}

var c = g(/* () */0);

var d = g(/* () */0);

exports.f = f;
exports.a = a;
exports.b = b;
exports.g = g;
exports.c = c;
exports.d = d;
/* a Not a pure module */
17 changes: 17 additions & 0 deletions jscomp/test/gpr_2731_test.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@



let f x = x + [%raw{|1|}]




let a = f 1
let b = f 2

let g () =
[%raw{|1|}]


let c = g ()
let d = g ()
4 changes: 3 additions & 1 deletion lib/whole_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -86560,7 +86560,7 @@ let rec no_side_effects (lam : Lam.t) : bool =
*)
exception Too_big_to_inline

let really_big () = raise Too_big_to_inline
let really_big () = raise_notrace Too_big_to_inline

let big_lambda = 1000

Expand All @@ -86578,6 +86578,8 @@ let rec size (lam : Lam.t) =
| Lprim {primitive = Praise ; args = [l ]; _}
-> size l
| Lam.Lglobal_module _ -> 1
| Lprim {primitive = Praw_js_code_exp _ | Praw_js_code_stmt _} ->
really_big ()
| Lprim {args = ll; _} -> size_lams 1 ll

(** complicated
Expand Down