Repository activity
40458 results across all weeks
Compiler: call functions in blocks without Function.prototype.call
Exact calls to functions stored in blocks (module fields of other compilation units, records of closures) were emitted as M[i].call(null, x) (de272311e8, part of #1397), to avoid a method call. On V8 this prevents inlining: TurboFan's ReduceFunctionPrototypeCall rewrites it into a call of M[i] marked CallFeedbackRelation::kUnrelated, and ReduceJSCall then ig…
hhugoCompiler: do not fold integer operations on non-integer literals
The JavaScript code generator simplifies integer additions, subtractions and shifts whose operands are number literals, parsing the literals as integers. With GADTs, such an operation can be applied to a float constant in dead code, once a function is inlined:
Jérôme Vouillon (@vouillon)Compiler: evaluate the function and arguments of a call once with callgen
When the arity check of a call is inlined (--enable callgen, and for trampolined calls or calls in CPS with double translation), the function expression appears in the arity check and in both branches, and the arguments in both branches. These expressions can be inlined function calls or closures, so:
Jérôme Vouillon (@vouillon)Compiler: fix --enable callgen
With --enable callgen, applications are inlined instead of going through caml_callN, and the inlined code repeats the function and the arguments:
hhugoCompiler: fix float constants when the compiler runs in JavaScript
When js_of_ocaml is itself compiled to JavaScript, floats are unboxed numbers, which Obj.is_block takes for integers. Float constants nested in structured constants were thus parsed as integers and truncated by Targetint (0.2888 became 0, -0. became 0, 1e100 became 0, 2147483648. became -2147483648), with an "integer-overflow" warning. Compiling the lexifi-g…
Jérôme Vouillon (@vouillon)Compiler: link the base64 decoder in build-fs output
Since #2432, large binary strings are emitted as base64 literals decoded by caml_jsbytes_of_base64. This also applies to the files embedded by build-fs.
Romain Beauxis (@toots)Compiler: read f.cps once in CPS calls with double translation
With --effects=double-translation, a call in CPS reads f.cps up to six times. It is now bound to a variable first, and called through that variable. In the shared helpers (caml_trampoline_cps_callN, caml_exact_trampoline_cps_call, ...):
hhugoCompiler: trampoline mutually recursive direct-style functions with double translation
With --effects=double-translation, Generate_closure only trampolined the tail calls of mutually recursive functions with a CPS version, leaving the other recursive groups unchanged. But functions which do not need CPS also have no CPS version: this is common in whole-program compilation, where all calls are known (with separate compilation, exported function…
Jérôme Vouillon (@vouillon)Double rounding fixes
This PR fixes several cases where a floating-point result is rounded twice, and can therefore be wrong in the last bit. The first rounding (to a double, or to a normal double before scaling into the subnormal range) can land exactly halfway between two representable results. The second rounding then breaks the tie to even, which may be the wrong direction.
Jérôme Vouillon (@vouillon)Faster float formating and parsing
This PR speeds up float formatting in both runtimes, and float parsing and integer formatting in the Wasm runtime. Before, the Wasm runtime called into JavaScript to format every float, and did most of the string work on the JavaScript side.
Jérôme Vouillon (@vouillon)Faster float16 <-> double conversions
Faster conversions between float16 and doubles.
Jérôme Vouillon (@vouillon)Improve variable naming (Js_assign)
hhugo
Jérôme Vouillon (@vouillon)Optimize the placement of conversions: (un)boxing, (un)tagging, normalization
Jérôme Vouillon (@vouillon)Prepare next release
[x] clean up changelog
hhugoRFC: move ppx_optcomp_light and ppx_expect_light to their own repo (ocsigen/ocsippx)
js_of_ocaml contains two small ppxes that I think would be useful outside of this repo. I would like to move them to their own repository under the ocsigen organisation. This issue describes the plan so we can gather feedback before doing it.
hhugoRange analysis
Jérôme Vouillon (@vouillon)Runtime/JS: faster Random (LXM step on 32-bit halves)
caml_lxm_next used boxed Int64 values, allocating one object per arithmetic operation, and caml_ba_get_1/caml_ba_set_1, which allocate an index array. It now reads the state from the bigarray's Int32Array as (low, high) pairs and does the 64-bit arithmetic on these with Math.imul; only the result is allocated. The output is identical to native on 10000 value…
Jérôme Vouillon (@vouillon)Runtime/JS: faster nextafter
caml_nextafter_float went through three Int64 objects (bits_of_float, add or sub, float_of_bits). Instead, add one to or subtract one from the two 32-bit halves of the bit pattern in jsoo_dataview.
Jérôme Vouillon (@vouillon)Runtime/Wasm: compute mod_float in Wasm
fmod was imported from JavaScript as (x, y) => x % y, which V8 cannot call directly the way it calls Math functions. It is now computed exactly in the runtime with integer arithmetic: with x = mx * 2^ex and y = my * 2^ey, the result is (mx * 2^(ex - ey) mod my) * 2^ey, the shift being done up to 63 bits at a time with i64.rem_u (after removing the trailing z…
Jérôme Vouillon (@vouillon)Runtime: accurate erf and erfc
The JavaScript and Wasm runtimes computed erf with the Abramowitz-Stegun formula 7.1.26, good to 1.5e-7 in absolute terms only, and erfc as 1 - erf: erf 0 was 1e-9, erf 1e-10 was ten times too large, and erfc returned 0 above x ~ 6 (erfc 10 is 2.1e-45).
Jérôme Vouillon (@vouillon)