Skip to content

experimental work to make bundler happier #4934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2021
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
5 changes: 5 additions & 0 deletions jscomp/core/js_exp_make.ml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ let runtime_call ?comment module_name fn_name args =
~info:Js_call_info.builtin_runtime_call
(runtime_var_dot module_name fn_name) args

let pure_runtime_call module_name fn_name args =
call ~comment:Literals.pure
~info:Js_call_info.builtin_runtime_call
(runtime_var_dot module_name fn_name) args

let runtime_ref module_name fn_name =
runtime_var_dot module_name fn_name

Expand Down
6 changes: 6 additions & 0 deletions jscomp/core/js_exp_make.mli
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ val runtime_call :
t list -> (* args *)
t

val pure_runtime_call :
string -> (* module_name *)
string -> (* fn_name *)
t list -> (* args *)
t

val runtime_ref :
string ->
string ->
Expand Down
2 changes: 1 addition & 1 deletion jscomp/core/js_long.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ let of_const (v : Int64.t) =
| -9223372036854775808L ->
E.runtime_var_dot Js_runtime_modules.int64 "min_int"
| _ ->
E.runtime_call Js_runtime_modules.int64 "mk"
E.pure_runtime_call Js_runtime_modules.int64 "mk"
[
E.int (Int64.to_int32 v );
E.int (Int64.to_int32 (Int64.shift_right v 32))
Expand Down
2 changes: 1 addition & 1 deletion jscomp/core/js_of_lam_exception.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module E = Js_exp_make
about the correctness of inlining more difficult
*)
let make exception_str : J.expression =
E.runtime_call Js_runtime_modules.exceptions Literals.create [exception_str]
E.pure_runtime_call Js_runtime_modules.exceptions Literals.create [exception_str]



2 changes: 2 additions & 0 deletions jscomp/ext/literals.ml
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,5 @@ let tl = "tl"

let lazy_done = "LAZY_DONE"
let lazy_val = "VAL"

let pure = "@__PURE__"
2 changes: 1 addition & 1 deletion jscomp/test/406_primitive_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ eq("File \"406_primitive_test.ml\", line 29, characters 6-13", backend_type, /*
});

function f(param) {
var A = Caml_exceptions.create("A");
var A = /* @__PURE__ */Caml_exceptions.create("A");
try {
for(var i = 0; i <= 200; ++i){
if (i === 10) {
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/array_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var Caml_exceptions = require("../../lib/js/caml_exceptions.js");
var Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js");

function starts_with(xs, prefix, p) {
var H = Caml_exceptions.create("H");
var H = /* @__PURE__ */Caml_exceptions.create("H");
var len1 = xs.length;
var len2 = prefix.length;
if (len2 > len1) {
Expand Down
4 changes: 2 additions & 2 deletions jscomp/test/bs_min_max_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ var f5_max = Caml_obj.caml_max;

b("File \"bs_min_max_test.ml\", line 28, characters 4-11", Caml_int64.eq(Caml_int64.min(Caml_int64.zero, Caml_int64.one), Caml_int64.zero));

b("File \"bs_min_max_test.ml\", line 29, characters 4-11", Caml_int64.eq(Caml_int64.max(Caml_int64.mk(22, 0), Caml_int64.one), Caml_int64.mk(22, 0)));
b("File \"bs_min_max_test.ml\", line 29, characters 4-11", Caml_int64.eq(Caml_int64.max(/* @__PURE__ */Caml_int64.mk(22, 0), Caml_int64.one), /* @__PURE__ */Caml_int64.mk(22, 0)));

b("File \"bs_min_max_test.ml\", line 30, characters 4-11", Caml_int64.eq(Caml_int64.max(Caml_int64.mk(-3, -1), Caml_int64.mk(3, 0)), Caml_int64.mk(3, 0)));
b("File \"bs_min_max_test.ml\", line 30, characters 4-11", Caml_int64.eq(Caml_int64.max(/* @__PURE__ */Caml_int64.mk(-3, -1), /* @__PURE__ */Caml_int64.mk(3, 0)), /* @__PURE__ */Caml_int64.mk(3, 0)));

eq("File \"bs_min_max_test.ml\", line 31, characters 5-12", Caml_obj.caml_min(undefined, 3), undefined);

Expand Down
48 changes: 24 additions & 24 deletions jscomp/test/caml_format_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2085,7 +2085,7 @@ var int64_suites_1 = {
_3: /* End_of_format */0
},
_1: "%Ld"
}), Caml_int64.mk(3, 0)),
}), /* @__PURE__ */Caml_int64.mk(3, 0)),
_1: "3"
};
})
Expand All @@ -2105,7 +2105,7 @@ var int64_suites_1 = {
_3: /* End_of_format */0
},
_1: "%Lx"
}), Caml_int64.mk(33, 0)),
}), /* @__PURE__ */Caml_int64.mk(33, 0)),
_1: "21"
};
})
Expand All @@ -2125,7 +2125,7 @@ var int64_suites_1 = {
_3: /* End_of_format */0
},
_1: "%Li"
}), Caml_int64.mk(33, 0)),
}), /* @__PURE__ */Caml_int64.mk(33, 0)),
_1: "33"
};
})
Expand All @@ -2145,7 +2145,7 @@ var int64_suites_1 = {
_3: /* End_of_format */0
},
_1: "%LX"
}), Caml_int64.mk(44, 0)),
}), /* @__PURE__ */Caml_int64.mk(44, 0)),
_1: "2C"
};
})
Expand All @@ -2165,7 +2165,7 @@ var int64_suites_1 = {
_3: /* End_of_format */0
},
_1: "%Lx"
}), Caml_int64.mk(44, 0)),
}), /* @__PURE__ */Caml_int64.mk(44, 0)),
_1: "2c"
};
})
Expand All @@ -2188,7 +2188,7 @@ var int64_suites_1 = {
_3: /* End_of_format */0
},
_1: "%*Lx"
}), 5, Caml_int64.mk(44, 0)),
}), 5, /* @__PURE__ */Caml_int64.mk(44, 0)),
_1: " 2c"
};
})
Expand All @@ -2199,7 +2199,7 @@ var int64_suites_1 = {
(function (param) {
return {
TAG: /* Eq */0,
_0: Caml_int64.to_string(Caml_int64.mk(3333, 0)),
_0: Caml_int64.to_string(/* @__PURE__ */Caml_int64.mk(3333, 0)),
_1: "3333"
};
})
Expand Down Expand Up @@ -2229,7 +2229,7 @@ var int64_suites_1 = {
}
},
_1: "%Ld%018Ld"
}), Caml_int64.mk(3, 0), Caml_int64.mk(3, 0)),
}), /* @__PURE__ */Caml_int64.mk(3, 0), /* @__PURE__ */Caml_int64.mk(3, 0)),
_1: "3000000000000000003"
};
})
Expand Down Expand Up @@ -2259,7 +2259,7 @@ var int64_suites_1 = {
}
},
_1: "%Ld%018Ld"
}), Caml_int64.mk(1548746752, 107288), Caml_int64.zero),
}), /* @__PURE__ */Caml_int64.mk(1548746752, 107288), Caml_int64.zero),
_1: "460800000000000000000000000000000"
};
})
Expand Down Expand Up @@ -2319,7 +2319,7 @@ var int64_suites_1 = {
_3: /* End_of_format */0
},
_1: "%Ld"
}), Caml_int64.mk(-11111, -1)),
}), /* @__PURE__ */Caml_int64.mk(-11111, -1)),
_1: "-11111"
};
})
Expand Down Expand Up @@ -2439,7 +2439,7 @@ var int64_suites_1 = {
_3: /* End_of_format */0
},
_1: "%Lu"
}), Caml_int64.mk(-100, -1)),
}), /* @__PURE__ */Caml_int64.mk(-100, -1)),
_1: "18446744073709551516"
};
})
Expand Down Expand Up @@ -2479,7 +2479,7 @@ var int64_suites_1 = {
_3: /* End_of_format */0
},
_1: "%Lu"
}), Caml_int64.mk(-10000, -1)),
}), /* @__PURE__ */Caml_int64.mk(-10000, -1)),
_1: "18446744073709541616"
};
})
Expand Down Expand Up @@ -2543,7 +2543,7 @@ var int64_suites_1 = {
_3: /* End_of_format */0
},
_1: "%12Lx"
}), Caml_int64.mk(3, 0)),
}), /* @__PURE__ */Caml_int64.mk(3, 0)),
_1: " 3"
};
})
Expand All @@ -2563,7 +2563,7 @@ var int64_suites_1 = {
_3: /* End_of_format */0
},
_1: "%LX"
}), Caml_int64.mk(1163551168, 1859194407)),
}), /* @__PURE__ */Caml_int64.mk(1163551168, 1859194407)),
_1: "6ED10E27455A61C0"
};
})
Expand All @@ -2587,7 +2587,7 @@ var int64_suites_1 = {
}
},
_1: "%Ld\n"
}), Caml_int64.mk(32, 0)),
}), /* @__PURE__ */Caml_int64.mk(32, 0)),
_1: "32\n"
};
})
Expand All @@ -2612,7 +2612,7 @@ var int64_suites_1 = {
}
},
_1: "%Ld\n"
}), Caml_int64.mk(32, 0)), $$Buffer.contents(buf)),
}), /* @__PURE__ */Caml_int64.mk(32, 0)), $$Buffer.contents(buf)),
_1: "32\n"
};
})
Expand Down Expand Up @@ -2657,31 +2657,31 @@ var of_string_data = [
"0"
],
[
Caml_int64.mk(3, 0),
/* @__PURE__ */Caml_int64.mk(3, 0),
"3"
],
[
Caml_int64.mk(33, 0),
/* @__PURE__ */Caml_int64.mk(33, 0),
"33"
],
[
Caml_int64.mk(333, 0),
/* @__PURE__ */Caml_int64.mk(333, 0),
"33_3"
],
[
Caml_int64.mk(33333, 0),
/* @__PURE__ */Caml_int64.mk(33333, 0),
"33_33_3"
],
[
Caml_int64.mk(-1674115755, 77),
/* @__PURE__ */Caml_int64.mk(-1674115755, 77),
"333333333333"
],
[
Caml_int64.neg_one,
"0xffff_ffff_ffff_ffff"
],
[
Caml_int64.mk(113, 0),
/* @__PURE__ */Caml_int64.mk(113, 0),
"0b01110001"
],
[
Expand Down Expand Up @@ -2756,9 +2756,9 @@ var float_suites = {
tl: /* [] */0
};

var hh = Caml_int64.mk(-858993460, 214748364);
var hh = /* @__PURE__ */Caml_int64.mk(-858993460, 214748364);

var hhh = Caml_int64.mk(0, 268435456);
var hhh = /* @__PURE__ */Caml_int64.mk(0, 268435456);

exports.of_string = of_string;
exports.from_float_of_string = from_float_of_string;
Expand Down
4 changes: 2 additions & 2 deletions jscomp/test/div_by_zero_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ add([
return {
TAG: /* ThrowAny */7,
_0: (function (param) {
Caml_int64.div(Caml_int64.mk(3, 0), Caml_int64.zero);
Caml_int64.div(/* @__PURE__ */Caml_int64.mk(3, 0), Caml_int64.zero);

})
};
Expand All @@ -109,7 +109,7 @@ add([
return {
TAG: /* ThrowAny */7,
_0: (function (param) {
Caml_int64.mod_(Caml_int64.mk(3, 0), Caml_int64.zero);
Caml_int64.mod_(/* @__PURE__ */Caml_int64.mk(3, 0), Caml_int64.zero);

})
};
Expand Down
6 changes: 3 additions & 3 deletions jscomp/test/equal_exception_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function is_exception(param) {
}

function is_normal_exception(_x) {
var A = Caml_exceptions.create("A");
var A = /* @__PURE__ */Caml_exceptions.create("A");
var v = {
RE_EXN_ID: A,
_1: 3
Expand All @@ -86,7 +86,7 @@ function is_normal_exception(_x) {
}

function is_arbitrary_exception(param) {
var A = Caml_exceptions.create("A");
var A = /* @__PURE__ */Caml_exceptions.create("A");
try {
throw {
RE_EXN_ID: A,
Expand Down Expand Up @@ -136,7 +136,7 @@ function eq(param) {
return param.RE_EXN_ID === "Not_found";
}

var Not_found = Caml_exceptions.create("Equal_exception_test.Not_found");
var Not_found = /* @__PURE__ */Caml_exceptions.create("Equal_exception_test.Not_found");

if (Caml_obj.caml_equal(e, {
RE_EXN_ID: Not_found
Expand Down
14 changes: 7 additions & 7 deletions jscomp/test/exception_def.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ function eq(loc, x, y) {
return Mt.eq_suites(test_id, suites, loc, x, y);
}

var A = Caml_exceptions.create("Exception_def.A");
var A = /* @__PURE__ */Caml_exceptions.create("Exception_def.A");

var A$1 = Caml_exceptions.create("Exception_def.U.A");
var A$1 = /* @__PURE__ */Caml_exceptions.create("Exception_def.U.A");

var U = {
A: A$1
};

var H = {};

var Bx = Caml_exceptions.create("Exception_def.Bx");
var Bx = /* @__PURE__ */Caml_exceptions.create("Exception_def.Bx");

var u = {
RE_EXN_ID: Bx
};

var Ax = Caml_exceptions.create("Exception_def.Ax");
var Ax = /* @__PURE__ */Caml_exceptions.create("Exception_def.Ax");

var XXX = Caml_exceptions.create("Exception_def.XXX");
var XXX = /* @__PURE__ */Caml_exceptions.create("Exception_def.XXX");

var Aa = "Match_failure";

Expand All @@ -51,9 +51,9 @@ var v = {

var H0 = "Not_found";

var H1 = Caml_exceptions.create("Exception_def.H1");
var H1 = /* @__PURE__ */Caml_exceptions.create("Exception_def.H1");

var H2 = Caml_exceptions.create("Exception_def.H2");
var H2 = /* @__PURE__ */Caml_exceptions.create("Exception_def.H2");

var h2 = {
RE_EXN_ID: H2
Expand Down
12 changes: 6 additions & 6 deletions jscomp/test/exception_raise_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ var Pervasives = require("../../lib/js/pervasives.js");
var Caml_exceptions = require("../../lib/js/caml_exceptions.js");
var Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js");

var Local = Caml_exceptions.create("Exception_raise_test.Local");
var Local = /* @__PURE__ */Caml_exceptions.create("Exception_raise_test.Local");

var B = Caml_exceptions.create("Exception_raise_test.B");
var B = /* @__PURE__ */Caml_exceptions.create("Exception_raise_test.B");

var C = Caml_exceptions.create("Exception_raise_test.C");
var C = /* @__PURE__ */Caml_exceptions.create("Exception_raise_test.C");

var D = Caml_exceptions.create("Exception_raise_test.D");
var D = /* @__PURE__ */Caml_exceptions.create("Exception_raise_test.D");

function appf(g, x) {
var A = Caml_exceptions.create("A");
var A = /* @__PURE__ */Caml_exceptions.create("A");
try {
return Curry._1(g, x);
}
Expand Down Expand Up @@ -58,7 +58,7 @@ function appf(g, x) {
}
}

var A = Caml_exceptions.create("Exception_raise_test.A");
var A = /* @__PURE__ */Caml_exceptions.create("Exception_raise_test.A");

var f;

Expand Down
Loading