Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
95f1411
Compiler: typo
hhugo Oct 25, 2024
fea3899
Compiler: remove some deadcode
hhugo Oct 25, 2024
450ddbb
Compiler: revert 1647
hhugo Oct 26, 2024
4e12aea
Misc: upgrade sedlex
hhugo Nov 1, 2024
d11b87f
Misc: Move the runtime files under runtime/js (#1727)
vouillon Nov 4, 2024
60526e6
Lib: Add `detailsElement` and `toggleEvent` objects. (#1728)
SylvainBoilard Nov 6, 2024
e67805e
Fix compare function (#1729)
vouillon Nov 6, 2024
3fa88ec
Runtime: precompute prng lxm constants (#1730)
TyOverby Nov 6, 2024
b553b6d
Tests: small cleanup
hhugo Nov 6, 2024
55fca34
Compiler: small fix
hhugo Nov 6, 2024
71a509c
Misc: Typos (#1732)
vouillon Nov 8, 2024
9570d4a
Runtime: add caml_blake2_bytes
hhugo Nov 18, 2024
6d8d865
Runtime: missing array primitives
hhugo Nov 18, 2024
02a7c22
Runtime: runtime_events primitive
hhugo Nov 18, 2024
941dcd1
Tests: check-prim uses dynlink.js
hhugo Nov 18, 2024
147b784
Tests: recursive value compilation
hhugo Nov 18, 2024
46fbbcc
Tests: promote with new compilation strategy
hhugo Nov 18, 2024
1ded1bc
Runtime: add caml_signbit
hhugo Nov 18, 2024
a1c6cc9
Runtime: add is_digit_normalized
hhugo Nov 18, 2024
2143524
Runtime: adjust runtime for 5.1
hhugo Nov 18, 2024
b7903e8
Runtime: adjust runtime for 5.0
hhugo Nov 18, 2024
c9b00c0
Runtime: adjust runtime for 4.14
hhugo Nov 18, 2024
d5f2f62
Runtime: adjust domain.js
hhugo Nov 18, 2024
be27f2f
Runtime: adjust spacetime prims
hhugo Nov 18, 2024
7f8a239
Runtime: adjust str prims
hhugo Nov 18, 2024
1bbb485
Runtime: adjust marshal prims
hhugo Nov 18, 2024
5ee1b72
Runtime: adjust obj prims
hhugo Nov 19, 2024
46a5d08
Runtime: adjust nat prims
hhugo Nov 19, 2024
329a9e6
Runtime: adjust hash prims
hhugo Nov 19, 2024
9196200
Runtime: adjust io prims
hhugo Nov 19, 2024
d414b70
Runtime: adjust toplevel prims
hhugo Nov 19, 2024
4411974
Runtime: adjust dynlink prims
hhugo Nov 19, 2024
3e33f3d
Runtime: adjust mlbytes prims
hhugo Nov 19, 2024
c8524eb
Runtime: remove caml_new_string
hhugo Nov 19, 2024
6d9e874
Runtime: adjust gc prims
hhugo Nov 19, 2024
0fe8005
Runtime: adjust effects prims
hhugo Nov 19, 2024
63f9d75
Changes
hhugo Nov 19, 2024
493c064
Runtime: fmt
hhugo Nov 19, 2024
d4be1c0
Fix CI with macos runners (#1737)
hhugo Nov 20, 2024
1189e53
CI: move
hhugo Nov 20, 2024
d1566a4
Release 5.9 (#1735)
hhugo Nov 22, 2024
5220982
Misc: adjust opam constraint (#1742)
hhugo Nov 23, 2024
3785e99
Lib: small refactoring around js exception printing (#1743)
hhugo Nov 25, 2024
3e12e52
CI: move
hhugo Nov 20, 2024
ae1284b
Fix ci mac (#1744)
hhugo Nov 25, 2024
825941b
Tests: recursive value compilation
hhugo Nov 18, 2024
e16f8e3
Misc: remove macos CI fix
hhugo Nov 26, 2024
285376a
Tests: promote with new compilation strategy
hhugo Nov 18, 2024
be634ad
Merge branch 'master' of github.com:ocsigen/js_of_ocaml into jsoo-merge
vouillon Nov 26, 2024
5e25815
CI: explicitly set version of all jsoo packages
vouillon Nov 25, 2024
1f11a80
Formatting
vouillon Nov 25, 2024
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
44 changes: 2 additions & 42 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:
- run: opam install . --best-effort
if: ${{ matrix.skip-test }}

- run: cat VERSION | xargs opam pin wasm_of_ocaml-compiler . -n --with-version
- run: cat VERSION | xargs opam pin . -n --with-version
if: ${{ !matrix.skip-test }}
shell: bash

Expand Down Expand Up @@ -164,44 +164,4 @@ jobs:
branch: wikidoc
folder: doc-dev
clean: true
target-folder: doc/dev/

lint-opam:
runs-on: ubuntu-latest
steps:
- name: Checkout tree
uses: actions/checkout@v4
- name: Set-up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: "5.2"
dune-cache: true
- name: Pin dune
run: |
opam pin add -n dune.3.17 https://github.com/ocaml/dune.git
- uses: ocaml/setup-ocaml/lint-opam@v3

lint-fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout tree
uses: actions/checkout@v4
- name: Set-up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: "5.2"
dune-cache: true
- name: Pin dune
run: |
opam pin add -n dune.3.17 https://github.com/ocaml/dune.git
- uses: ocaml/setup-ocaml/lint-fmt@v3

lint-runtime:
runs-on: ubuntu-latest
steps:
- name: Checkout tree
uses: actions/checkout@v4
- name: Set-up Biome
uses: biomejs/setup-biome@v2
- name: Run biome
run: biome ci
target-folder: doc/dev/
48 changes: 48 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: lint

on:
pull_request:
push:
branches:
- master

jobs:
lint-opam:
runs-on: ubuntu-latest
steps:
- name: Checkout tree
uses: actions/checkout@v4
- name: Set-up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: "5.2"
dune-cache: true
- name: Pin dune
run: |
opam pin add -n dune.3.17 https://github.com/ocaml/dune.git
- uses: ocaml/setup-ocaml/lint-opam@v3

lint-fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout tree
uses: actions/checkout@v4
- name: Set-up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: "5.2"
dune-cache: true
- name: Pin dune
run: |
opam pin add -n dune.3.17 https://github.com/ocaml/dune.git
- uses: ocaml/setup-ocaml/lint-fmt@v3

lint-runtime:
runs-on: ubuntu-latest
steps:
- name: Checkout tree
uses: actions/checkout@v4
- name: Set-up Biome
uses: biomejs/setup-biome@v2
- name: Run biome
run: biome ci
10 changes: 6 additions & 4 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# dev
# 5.9.0 (2024-11-22) - Lille

## Features/Changes
* Misc: update testsuite to OCaml 5.2
* Misc: CI uses opam.2.2 and no longer use sunset repo
* Misc: yojson is no longer optional
* Misc: reduce the diff with the wasm_of_ocaml fork
* Misc: finalize support for OCaml 5.3
* Compiler: speedup global_flow/global_deadcode pass on large bytecode
* Compiler: improved global dead code elimination (#2206)
* Compiler: speedup json parsing, relying on Yojson.Raw (#1640)
* Compiler: Decode sourcemap mappings only when necessary (#1664)
* Compiler: make indirect call using sequence instead of using the call method
[f.call(null, args)] becomes [(0,f)(args)]
* Compiler: mark [TextEncoder] as reserved
* Compiler: add support for the Wasm backend in parts of the pipeline, in
prevision for the merge of wasm_of_ocaml
Expand All @@ -21,12 +20,15 @@
* Compiler: Emit index source_map to avoid changing mappings (#1714, #1715)
* Compiler: improved source map generation (#1716)
* Runtime: change Sys.os_type on windows (Cygwin -> Win32)
* Runtime: backtraces are really expensive, they need to be be explicitly
* Runtime: backtraces are really expensive, they need to be explicitly
requested at compile time (--enable with-js-error) or at startup (OCAMLRUNPARAM=b=1)
* Runtime: allow dynlink of precompiled js with separate compilation (#1676)
* Runtime: reimplement the runtime of weak and ephemeron (#1707)
* Lib: Modify Typed_array API for compatibility with WebAssembly
* Lib: add details element and toggle event (#1728)
* Toplevel: no longer set globals for toplevel initialization
* Runtime: precompute constants used in `caml_lxm_next` (#1730)
* Runtime: cleanup runtime

## Bug fixes
* Runtime: fix parsing of unsigned integers (0u2147483648) (#1633, #1666)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.8.2
5.9.0
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://biomejs.dev/schemas/1.9.1/schema.json",
"files": {
"include": ["runtime"],
"ignore": ["runtime/zstd.ts"]
"ignore": ["runtime/js/zstd.ts"]
},
"formatter": {
"enabled": true,
Expand Down
4 changes: 2 additions & 2 deletions compiler/bin-js_of_ocaml/cmd_arg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ let options =
in
let no_sourcemap =
let doc =
"Don't generate source map. All other source map related flags will be be ignored."
"Don't generate source map. All other source map related flags will be ignored."
in
Arg.(value & flag & info [ "no-sourcemap"; "no-source-map" ] ~doc)
in
Expand Down Expand Up @@ -395,7 +395,7 @@ let options_runtime_only =
in
let no_sourcemap =
let doc =
"Don't generate source map. All other source map related flags will be be ignored."
"Don't generate source map. All other source map related flags will be ignored."
in
Arg.(value & flag & info [ "no-sourcemap"; "no-source-map" ] ~doc)
in
Expand Down
2 changes: 1 addition & 1 deletion compiler/bin-js_of_ocaml/link.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let options =
in
let no_sourcemap =
let doc =
"Don't generate source map. All other source map related flags will be be ignored."
"Don't generate source map. All other source map related flags will be ignored."
in
Arg.(value & flag & info [ "no-sourcemap"; "no-source-map" ] ~doc)
in
Expand Down
2 changes: 1 addition & 1 deletion compiler/lib-runtime-files/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
(target files.ml)
(deps
gen/gen.exe
(glob_files ../../runtime/*.js))
(glob_files ../../runtime/js/*.js))
(action
(with-stdout-to
%{target}
Expand Down
4 changes: 2 additions & 2 deletions compiler/lib/flow_lexer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -832,9 +832,9 @@ let backquote env lexbuf =

let wrap f =
let f env =
let start, _ = Sedlexing.lexing_positions env.Lex_env.lex_lb in
let start = Sedlexing.lexing_position_start env.Lex_env.lex_lb in
let t = f env env.Lex_env.lex_lb in
let _, stop = Sedlexing.lexing_positions env.Lex_env.lex_lb in
let stop = Sedlexing.lexing_position_curr env.Lex_env.lex_lb in
t, Loc.create ~last_line:(Loc.line_end' !(env.lex_last_loc)) start stop
in
let rec helper comments env =
Expand Down
3 changes: 2 additions & 1 deletion compiler/lib/generate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,8 @@ let apply_fun_raw ctx f params exact trampolined loc =
(* Make sure we are performing a regular call, not a (slower)
method call *)
match f with
| J.EAccess _ | J.EDot _ -> J.call (J.ESeq (int 0, f)) params loc
| J.EAccess _ | J.EDot _ ->
J.call (J.dot f (Utf8_string.of_string_exn "call")) (s_var "null" :: params) loc
| _ -> J.call f params loc
in
let apply =
Expand Down
78 changes: 26 additions & 52 deletions compiler/lib/parse_bytecode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ module Debug : sig

val create : include_cmis:bool -> bool -> t

val fold : t -> (Code.Addr.t -> Instruct.debug_event -> 'a -> 'a) -> 'a -> 'a

val paths : t -> units:StringSet.t -> StringSet.t
end = struct
open Instruct
Expand Down Expand Up @@ -315,9 +313,6 @@ end = struct
| [], [] -> ()
| _ -> assert false

let fold t f acc =
Int_table.fold (fun k { event; _ } acc -> f k event acc) t.events_by_pc acc

let paths t ~units =
let paths =
Hashtbl.fold
Expand All @@ -333,66 +328,56 @@ end
module Blocks : sig
type t

val analyse : Debug.t -> bytecode -> t

val add : t -> int -> t

type u

val finish_analysis : t -> u
val analyse : bytecode -> t

val next : u -> int -> int
val next : t -> int -> int

val is_empty : u -> bool
val is_empty : t -> bool
end = struct
type t = Addr.Set.t

type u = int array
type t = int array

let add blocks pc = Addr.Set.add pc blocks

let rec scan debug blocks code pc len =
let rec scan blocks code pc len =
if pc < len
then
match (get_instr_exn code pc).kind with
| KNullary -> scan debug blocks code (pc + 1) len
| KUnary -> scan debug blocks code (pc + 2) len
| KBinary -> scan debug blocks code (pc + 3) len
| KNullaryCall -> scan debug blocks code (pc + 1) len
| KUnaryCall -> scan debug blocks code (pc + 2) len
| KBinaryCall -> scan debug blocks code (pc + 3) len
| KNullary -> scan blocks code (pc + 1) len
| KUnary -> scan blocks code (pc + 2) len
| KBinary -> scan blocks code (pc + 3) len
| KNullaryCall -> scan blocks code (pc + 1) len
| KUnaryCall -> scan blocks code (pc + 2) len
| KBinaryCall -> scan blocks code (pc + 3) len
| KJump ->
let offset = gets code (pc + 1) in
let blocks = Addr.Set.add (pc + offset + 1) blocks in
scan debug blocks code (pc + 2) len
scan blocks code (pc + 2) len
| KCond_jump ->
let offset = gets code (pc + 1) in
let blocks = Addr.Set.add (pc + offset + 1) blocks in
scan debug blocks code (pc + 2) len
scan blocks code (pc + 2) len
| KCmp_jump ->
let offset = gets code (pc + 2) in
let blocks = Addr.Set.add (pc + offset + 2) blocks in
scan debug blocks code (pc + 3) len
scan blocks code (pc + 3) len
| KSwitch ->
let sz = getu code (pc + 1) in
let blocks = ref blocks in
for i = 0 to (sz land 0xffff) + (sz lsr 16) - 1 do
let offset = gets code (pc + 2 + i) in
blocks := Addr.Set.add (pc + offset + 2) !blocks
done;
scan debug !blocks code (pc + 2 + (sz land 0xffff) + (sz lsr 16)) len
scan !blocks code (pc + 2 + (sz land 0xffff) + (sz lsr 16)) len
| KClosurerec ->
let nfuncs = getu code (pc + 1) in
scan debug blocks code (pc + nfuncs + 3) len
| KClosure -> scan debug blocks code (pc + 3) len
| KStop n -> scan debug blocks code (pc + n + 1) len
scan blocks code (pc + nfuncs + 3) len
| KClosure -> scan blocks code (pc + 3) len
| KStop n -> scan blocks code (pc + n + 1) len
| K_will_not_happen -> assert false
else (
assert (pc = len);
blocks)

let finish_analysis blocks = Array.of_list (Addr.Set.elements blocks)

(* invariant: a.(i) <= x < a.(j) *)
let rec find a i j x =
assert (i < j);
Expand All @@ -406,17 +391,13 @@ end = struct

let is_empty x = Array.length x <= 1

let analyse debug_data code =
let debug_data =
if Debug.enabled debug_data
then debug_data
else Debug.create ~include_cmis:false false
in
let analyse code =
let blocks = Addr.Set.empty in
let len = String.length code / 4 in
let blocks = add blocks 0 in
let blocks = add blocks len in
scan debug_data blocks code 0 len
let blocks = scan blocks code 0 len in
Array.of_list (Addr.Set.elements blocks)
end

(* Parse constants *)
Expand Down Expand Up @@ -806,7 +787,7 @@ let method_cache_id = ref 1
let clo_offset_3 = if new_closure_repr then 3 else 2

type compile_info =
{ blocks : Blocks.u
{ blocks : Blocks.t
; code : string
; limit : int
; debug : Debug.t
Expand Down Expand Up @@ -1865,7 +1846,7 @@ and compile infos pc state (instrs : instr list) =

if debug_parser ()
then (
Format.printf "%a = ccal \"%s\" (" Var.print x prim;
Format.printf "%a = ccall \"%s\" (" Var.print x prim;
for i = 0 to nargs - 1 do
if i > 0 then Format.printf ", ";
Format.printf "%a" Var.print (List.nth args i)
Expand All @@ -1885,7 +1866,7 @@ and compile infos pc state (instrs : instr list) =

if debug_parser ()
then (
Format.printf "%a = ccal \"%s\" (" Var.print x prim;
Format.printf "%a = ccall \"%s\" (" Var.print x prim;
for i = 0 to nargs - 1 do
if i > 0 then Format.printf ", ";
Format.printf "%a" Var.print (List.nth args i)
Expand All @@ -1905,7 +1886,7 @@ and compile infos pc state (instrs : instr list) =

if debug_parser ()
then (
Format.printf "%a = ccal \"%s\" (" Var.print x prim;
Format.printf "%a = ccall \"%s\" (" Var.print x prim;
for i = 0 to nargs - 1 do
if i > 0 then Format.printf ", ";
Format.printf "%a" Var.print (List.nth args i)
Expand Down Expand Up @@ -2465,14 +2446,7 @@ type one =
let parse_bytecode code globals debug_data =
let state = State.initial globals in
Code.Var.reset ();
let blocks = Blocks.analyse debug_data code in
let blocks =
(* Disabled. [pc] might not be an appropriate place to split blocks *)
if false && Debug.enabled debug_data
then Debug.fold debug_data (fun pc _ blocks -> Blocks.add blocks pc) blocks
else blocks
in
let blocks' = Blocks.finish_analysis blocks in
let blocks' = Blocks.analyse code in
let p =
if not (Blocks.is_empty blocks')
then (
Expand Down
2 changes: 1 addition & 1 deletion compiler/lib/parse_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ end = struct
Option.iter filename ~f:(Sedlexing.set_filename l);
create ?report_error l

let curr_pos lexbuf = snd (Sedlexing.lexing_positions lexbuf.l)
let curr_pos lexbuf = Sedlexing.lexing_position_curr lexbuf.l

let report_errors t res =
match Flow_lexer.Lex_result.errors res with
Expand Down
Loading
Loading