Skip to content

Commit be634ad

Browse files
committed
Merge branch 'master' of github.com:ocsigen/js_of_ocaml into jsoo-merge
2 parents 285376a + e16f8e3 commit be634ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+366
-642
lines changed

.github/workflows/lint.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ jobs:
1717
with:
1818
ocaml-compiler: "5.2"
1919
dune-cache: true
20+
- name: Pin dune
21+
run: |
22+
opam pin add -n dune.3.17 https://github.com/ocaml/dune.git
2023
- uses: ocaml/setup-ocaml/lint-opam@v3
2124

2225
lint-fmt:
@@ -29,6 +32,9 @@ jobs:
2932
with:
3033
ocaml-compiler: "5.2"
3134
dune-cache: true
35+
- name: Pin dune
36+
run: |
37+
opam pin add -n dune.3.17 https://github.com/ocaml/dune.git
3238
- uses: ocaml/setup-ocaml/lint-fmt@v3
3339

3440
lint-runtime:

CHANGES.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
# dev
1+
# 5.9.0 (2024-11-22) - Lille
22

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

3133
## Bug fixes
3234
* Runtime: fix parsing of unsigned integers (0u2147483648) (#1633, #1666)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.8.2
1+
5.9.0

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "https://biomejs.dev/schemas/1.9.1/schema.json",
33
"files": {
44
"include": ["runtime"],
5-
"ignore": ["runtime/zstd.ts"]
5+
"ignore": ["runtime/js/zstd.ts"]
66
},
77
"formatter": {
88
"enabled": true,

compiler/bin-js_of_ocaml/cmd_arg.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ let options =
130130
in
131131
let no_sourcemap =
132132
let doc =
133-
"Don't generate source map. All other source map related flags will be be ignored."
133+
"Don't generate source map. All other source map related flags will be ignored."
134134
in
135135
Arg.(value & flag & info [ "no-sourcemap"; "no-source-map" ] ~doc)
136136
in
@@ -395,7 +395,7 @@ let options_runtime_only =
395395
in
396396
let no_sourcemap =
397397
let doc =
398-
"Don't generate source map. All other source map related flags will be be ignored."
398+
"Don't generate source map. All other source map related flags will be ignored."
399399
in
400400
Arg.(value & flag & info [ "no-sourcemap"; "no-source-map" ] ~doc)
401401
in

compiler/bin-js_of_ocaml/link.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ let options =
3939
in
4040
let no_sourcemap =
4141
let doc =
42-
"Don't generate source map. All other source map related flags will be be ignored."
42+
"Don't generate source map. All other source map related flags will be ignored."
4343
in
4444
Arg.(value & flag & info [ "no-sourcemap"; "no-source-map" ] ~doc)
4545
in

compiler/lib-runtime-files/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
(target files.ml)
88
(deps
99
gen/gen.exe
10-
(glob_files ../../runtime/*.js))
10+
(glob_files ../../runtime/js/*.js))
1111
(action
1212
(with-stdout-to
1313
%{target}

compiler/lib/flow_lexer.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,9 +832,9 @@ let backquote env lexbuf =
832832

833833
let wrap f =
834834
let f env =
835-
let start, _ = Sedlexing.lexing_positions env.Lex_env.lex_lb in
835+
let start = Sedlexing.lexing_position_start env.Lex_env.lex_lb in
836836
let t = f env env.Lex_env.lex_lb in
837-
let _, stop = Sedlexing.lexing_positions env.Lex_env.lex_lb in
837+
let stop = Sedlexing.lexing_position_curr env.Lex_env.lex_lb in
838838
t, Loc.create ~last_line:(Loc.line_end' !(env.lex_last_loc)) start stop
839839
in
840840
let rec helper comments env =

compiler/lib/generate.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,8 @@ let apply_fun_raw ctx f params exact trampolined loc =
898898
(* Make sure we are performing a regular call, not a (slower)
899899
method call *)
900900
match f with
901-
| J.EAccess _ | J.EDot _ -> J.call (J.ESeq (int 0, f)) params loc
901+
| J.EAccess _ | J.EDot _ ->
902+
J.call (J.dot f (Utf8_string.of_string_exn "call")) (s_var "null" :: params) loc
902903
| _ -> J.call f params loc
903904
in
904905
let apply =

compiler/lib/parse_bytecode.ml

Lines changed: 26 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ module Debug : sig
8888

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

91-
val fold : t -> (Code.Addr.t -> Instruct.debug_event -> 'a -> 'a) -> 'a -> 'a
92-
9391
val paths : t -> units:StringSet.t -> StringSet.t
9492
end = struct
9593
open Instruct
@@ -315,9 +313,6 @@ end = struct
315313
| [], [] -> ()
316314
| _ -> assert false
317315

318-
let fold t f acc =
319-
Int_table.fold (fun k { event; _ } acc -> f k event acc) t.events_by_pc acc
320-
321316
let paths t ~units =
322317
let paths =
323318
Hashtbl.fold
@@ -333,66 +328,56 @@ end
333328
module Blocks : sig
334329
type t
335330

336-
val analyse : Debug.t -> bytecode -> t
337-
338-
val add : t -> int -> t
339-
340-
type u
341-
342-
val finish_analysis : t -> u
331+
val analyse : bytecode -> t
343332

344-
val next : u -> int -> int
333+
val next : t -> int -> int
345334

346-
val is_empty : u -> bool
335+
val is_empty : t -> bool
347336
end = struct
348-
type t = Addr.Set.t
349-
350-
type u = int array
337+
type t = int array
351338

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

354-
let rec scan debug blocks code pc len =
341+
let rec scan blocks code pc len =
355342
if pc < len
356343
then
357344
match (get_instr_exn code pc).kind with
358-
| KNullary -> scan debug blocks code (pc + 1) len
359-
| KUnary -> scan debug blocks code (pc + 2) len
360-
| KBinary -> scan debug blocks code (pc + 3) len
361-
| KNullaryCall -> scan debug blocks code (pc + 1) len
362-
| KUnaryCall -> scan debug blocks code (pc + 2) len
363-
| KBinaryCall -> scan debug blocks code (pc + 3) len
345+
| KNullary -> scan blocks code (pc + 1) len
346+
| KUnary -> scan blocks code (pc + 2) len
347+
| KBinary -> scan blocks code (pc + 3) len
348+
| KNullaryCall -> scan blocks code (pc + 1) len
349+
| KUnaryCall -> scan blocks code (pc + 2) len
350+
| KBinaryCall -> scan blocks code (pc + 3) len
364351
| KJump ->
365352
let offset = gets code (pc + 1) in
366353
let blocks = Addr.Set.add (pc + offset + 1) blocks in
367-
scan debug blocks code (pc + 2) len
354+
scan blocks code (pc + 2) len
368355
| KCond_jump ->
369356
let offset = gets code (pc + 1) in
370357
let blocks = Addr.Set.add (pc + offset + 1) blocks in
371-
scan debug blocks code (pc + 2) len
358+
scan blocks code (pc + 2) len
372359
| KCmp_jump ->
373360
let offset = gets code (pc + 2) in
374361
let blocks = Addr.Set.add (pc + offset + 2) blocks in
375-
scan debug blocks code (pc + 3) len
362+
scan blocks code (pc + 3) len
376363
| KSwitch ->
377364
let sz = getu code (pc + 1) in
378365
let blocks = ref blocks in
379366
for i = 0 to (sz land 0xffff) + (sz lsr 16) - 1 do
380367
let offset = gets code (pc + 2 + i) in
381368
blocks := Addr.Set.add (pc + offset + 2) !blocks
382369
done;
383-
scan debug !blocks code (pc + 2 + (sz land 0xffff) + (sz lsr 16)) len
370+
scan !blocks code (pc + 2 + (sz land 0xffff) + (sz lsr 16)) len
384371
| KClosurerec ->
385372
let nfuncs = getu code (pc + 1) in
386-
scan debug blocks code (pc + nfuncs + 3) len
387-
| KClosure -> scan debug blocks code (pc + 3) len
388-
| KStop n -> scan debug blocks code (pc + n + 1) len
373+
scan blocks code (pc + nfuncs + 3) len
374+
| KClosure -> scan blocks code (pc + 3) len
375+
| KStop n -> scan blocks code (pc + n + 1) len
389376
| K_will_not_happen -> assert false
390377
else (
391378
assert (pc = len);
392379
blocks)
393380

394-
let finish_analysis blocks = Array.of_list (Addr.Set.elements blocks)
395-
396381
(* invariant: a.(i) <= x < a.(j) *)
397382
let rec find a i j x =
398383
assert (i < j);
@@ -406,17 +391,13 @@ end = struct
406391

407392
let is_empty x = Array.length x <= 1
408393

409-
let analyse debug_data code =
410-
let debug_data =
411-
if Debug.enabled debug_data
412-
then debug_data
413-
else Debug.create ~include_cmis:false false
414-
in
394+
let analyse code =
415395
let blocks = Addr.Set.empty in
416396
let len = String.length code / 4 in
417397
let blocks = add blocks 0 in
418398
let blocks = add blocks len in
419-
scan debug_data blocks code 0 len
399+
let blocks = scan blocks code 0 len in
400+
Array.of_list (Addr.Set.elements blocks)
420401
end
421402

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

808789
type compile_info =
809-
{ blocks : Blocks.u
790+
{ blocks : Blocks.t
810791
; code : string
811792
; limit : int
812793
; debug : Debug.t
@@ -1865,7 +1846,7 @@ and compile infos pc state (instrs : instr list) =
18651846

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

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

19061887
if debug_parser ()
19071888
then (
1908-
Format.printf "%a = ccal \"%s\" (" Var.print x prim;
1889+
Format.printf "%a = ccall \"%s\" (" Var.print x prim;
19091890
for i = 0 to nargs - 1 do
19101891
if i > 0 then Format.printf ", ";
19111892
Format.printf "%a" Var.print (List.nth args i)
@@ -2465,14 +2446,7 @@ type one =
24652446
let parse_bytecode code globals debug_data =
24662447
let state = State.initial globals in
24672448
Code.Var.reset ();
2468-
let blocks = Blocks.analyse debug_data code in
2469-
let blocks =
2470-
(* Disabled. [pc] might not be an appropriate place to split blocks *)
2471-
if false && Debug.enabled debug_data
2472-
then Debug.fold debug_data (fun pc _ blocks -> Blocks.add blocks pc) blocks
2473-
else blocks
2474-
in
2475-
let blocks' = Blocks.finish_analysis blocks in
2449+
let blocks' = Blocks.analyse code in
24762450
let p =
24772451
if not (Blocks.is_empty blocks')
24782452
then (

0 commit comments

Comments
 (0)