github ocsigen/js_of_ocaml 6.5.0_beta1
6.5.0~beta1

pre-release4 hours ago

CHANGES:

Features/Changes

OCaml versions

  • Compiler/Runtime: support for OCaml 5.6: use the optimization hints
    recorded in the bytecode, support the bit counting primitives and
    Sys.filepath_exists, Weak.get_copy no longer copies
    (#1721, #2227, #2469, #2488, #2493, #2494)
  • Compiler/Runtime: OxCaml: block index and small-int string-like indexing
    primitives; OxCaml-specific primitives are gated on //If: oxcaml
    (#2342, #2463)
  • Compiler/Runtime: support building with Introcaml (OCaml fork with runtime
    introspection), gated by the introspect flag (#2409)

Compiler

  • Compiler: require sedlex 3.8.1 (#2503)
  • Compiler: faster compilation (about 25% faster than 6.4.1 on large
    programs): new Int_trie and Int_set data structures,
    sharing-preserving Subst and Js_traverse.map, Js_traverse.free as
    an iterator, circular-buffer worklists, faster JavaScript printer and
    lexer (#2445, #2446, #2447, #2448, #2449, #2452, #2454, #2512)
  • Compiler: keep the name of function expressions that do not refer to
    themselves; the unused-js-vars warning now reports such names (#2449)
  • Compiler: emit large binary string constants as base64 literals, which are
    much smaller than \xNN-escaped literals (-14% on the toplevel example)
    (#2432)
  • Compiler: report JavaScript syntax errors as file:line:col followed by
    the offending line; columns start from 1 (#2464, #2471, #2491)
  • Compiler: the JavaScript parser accepts source phase imports
    (import source x from "m") (#2523)
  • Compiler: drop redundant breaks out of labelled blocks, turning the
    blocks into if/else statements or conditional expressions; the nesting
    this introduces is bounded by --set=break_sink_depth, and the
    merge_node_max parameter is renamed label_depth (#2513)
  • Compiler: simplify the generated JavaScript (!x for negated
    conditions, no empty if branches) (#2500)
  • Compiler: omit the | 0 coercion after an unsigned right shift by a
    constant (#2531)
  • Compiler: inline pending expressions at the end of a try body, avoiding
    temporaries such as try{var c = f(x); return c;} (#2532)
  • Compiler: bind identical literals of a bytecode program to a single
    variable, which shrinks the generated code and speeds up compilation of
    programs with many duplicated constants; identical literals may now be
    physically equal (==) (#2547)
  • Compiler: fold if (c) return a; return b into return c ? a : b
    (#2533)
  • Compiler: test integers against 0 by truthiness (!x rather than
    0 === x) when the result is only used as a condition (#2538)
  • Compiler: simplify !c ? a : b into c ? b : a (#2538)
  • Compiler: compare integers directly rather than comparing the result
    of compare with 0 (#2529)
  • Compiler: faster reading of debug events, used with --pretty and
    --debug-info (#2541, #2548)

Effects

  • Compiler: with --effects={cps,double-translation}, specialize calls to
    known functions before the CPS transformation (#2458)
  • Compiler: with --effects=double-translation, only generate a CPS version
    of the functions that may run below an effect handler (#2441)
  • Compiler/Wasm: with --effects=cps, no longer turn mutually recursive
    functions into CPS, since Wasm has proper tail calls (#2441)
  • Runtime: specialize one- and two-argument partial applications in
    double-translation mode (#2437)

Wasm

  • Compiler/Wasm: intern string constants (program-wide with whole-program
    compilation, per compilation unit otherwise) (#2436)
  • Compiler/Wasm: small code generation improvements (negation, physical
    equality on JavaScript values, bigarray dimensions, result types of
    runtime primitives, masking of i31 values, range checks in the runtime)
    (#2472, #2475, #2529)
  • Compiler/Wasm: add --setenv, matching js_of_ocaml (#2415)
  • Compiler/Wasm: emit a sourcemap mapping at the start of each function, for
    the Chrome profiler (#2417)
  • Compiler/Wasm: the linker supports the wide arithmetic and custom
    descriptor instructions (#2515)
  • Compiler/Wasm: store more long-lived toplevel variables in globals; fix a
    crash when one of them is assigned in a try body (#2516)
  • Runtime/Wasm: faster caml_hash, compare, lexer engines, Str
    searches and output_value sharing detection (with WASI, output_value
    now shares boxed numbers with equal contents); single bound check in
    fixed-width Bytes accesses (#2470, #2505)

Libraries

  • Lib: add WebGL2 bindings; the webgl example uses WebGL2 and a new
    webgl2_particles example demonstrates transform feedback (#1226, #2388)
  • Lib: add Crypto (Web Crypto API) bindings (#2380)
  • Lib: add Notification and Clipboard bindings (#2379)
  • Lib: add Service Worker, MessageChannel/MessagePort and Cache API
    bindings (#2381)
  • Lib: add FontFace (CSS Font Loading API) bindings (#2255)
  • Lib: add the Pointer Capture API to Dom_html.element, and
    getPredictedEvents, altitudeAngle and azimuthAngle to pointerEvent
    (#2403)
  • Lib: consolidate the duplicate messageEvent class types into
    ('target, 'data) Dom_html.messageEvent; the old ones are deprecated
    aliases (#2382, #2390)
  • Lib: add Lwt_js_events.mutation/mutations (MutationObserver) (#250)
  • Lib: Lwt_js_events.load/error/abort accept any element, not only
    images (#2404)
  • Lib (breaking): Typed_array.float32Array_fromArray and
    float64Array_fromArray take a number_t js_array t, as required by
    wasm_of_ocaml (#2416)
  • Lib (breaking): remove js_of_ocaml-lwt.logger, as lwt_log is
    deprecated (#2378)
  • Lib: the native stubs of the JavaScript primitives are weak symbols, so
    that they can be overridden (#2435)

Toplevel

  • Toplevel: new Wrapped and Async APIs, and protocol, worker and
    worker_lwt_client sublibraries to run the toplevel in a WebWorker
    (#66, #833, #2377)

Bug fixes

Compiler

  • Compiler: fix two reference unboxing bugs (#2426, #2489)
  • Compiler: fix an invariant violation with recursive inlining
    (#2482, #2495)
  • Compiler: fix variable coalescing with ES classes (#2462)
  • Compiler: fix unsound corner cases of the JavaScript simplification
    passes: || fusion of effectful conditions, dropped var declarations
    when folding an if, catch-parameter destructuring defaults (#2393)
  • Compiler: fix the printing of JavaScript code: parentheses around optional
    chains, no ES2021 logical assignments, keep the braces around a single
    block-scoped declaration (#2465, #2502)
  • Compiler: keep static on the same line as the class element it modifies
    (Safari 17 misparsed static class fields) (#2420, #2421)
  • Compiler: fix the JavaScript lexer on out-of-range unicode escapes, on
    CR, U+2028 and U+2029 inside strings and templates, on numeric separators
    in the integer part of a float, and on an HTML close comment --> after a
    multi-line comment (#2503, #2524)

Effects

  • Compiler: with --effects=cps or double-translation, fix mutable local
    variables in try bodies and exception handlers (#2484)
  • Compiler: with --effects=double-translation, fix over-applications of
    functions that do not perform effects (#2455)
  • Compiler/Wasm: with --effects=cps, fix an assertion failure on a try
    whose body modifies a local reference, when compiled without -g (#2519)
  • Wasm: unhandled effects raise Effect.Unhandled (--effects=native) or
    Failure (--effects=disabled) instead of failing with a runtime error;
    handlers installed inside assume_no_perform work; --effects=cps no
    longer runs on a JSPI stack (#2434, #2441)

Wasm

  • Compiler/Wasm: x land y was wrongly assumed to fit in 31 bits when only
    a negative operand did (#2490)
  • Compiler/Wasm: fix specialized Bigarray.Genarray.get/set accesses,
    and check the number of indices (#2427, #2505)
  • Compiler/Wasm: fix several bugs of the Wasm linker (#2504)
  • Compiler/Wasm: fix sourcemaps and toplevels on Windows (#2397, #2418)
  • Wasm: embed cmis when building a toplevel with separate compilation
    (#2227)
  • Wasm: the runtime (zstd, blake2, wasi libc) uses a single linear memory,
    as Safari does not support modules with several memories (#2405)
  • Wasm: resolve .wasm assets relative to the runtime file, so that
    required programs work (#2389)

Runtime

  • Runtime: on Windows, the console device names (CON, CONIN$, CONOUT$)
    can be opened from node; they were resolved against the current directory
    (#2525)
  • Runtime: output_value marshals forced lazy values as their value, and
    caml_hash (Wasm) follows forwarded values, as native code (#2486)
  • Runtime: the functions creating arrays of arbitrary length check
    Sys.max_array_length (#2499)
  • Runtime: fix Str.string_partial_match (OSEC-2026-21) (#2492)
  • Runtime: caml_alloc_dummy_mixed takes two arguments (OxCaml) (#2461)
  • Runtime: fix two nat bugs with 32-bit digits (#2460)
  • Runtime: fix comparison between an immediate and a custom block (#2391)
  • Runtime: preserve leading BOMs when converting strings to JavaScript
    (#2414)
  • Runtime: fix the toplevel relocation of unit names with use-js-string
    disabled (#2429)

Libraries

  • Toplevel: keep /static/cmis on the load path across
    Toploop.initialize_toplevel_env (#833, #2377)
  • Tyxml: keep the first of repeated attributes, as browsers do (#968, #2383)
  • Lib: Form.form_elements and Form.get_form_contents skip
    <input type="button">, as a native form submission does; a named one
    was sent as a field with its value (#2466)

Don't miss a new js_of_ocaml release

NewReleases is sending notifications on new releases.