Skip to content

Commit 7c7d6d2

Browse files
authored
Merge branch 'master' into more-lambda-lifting
2 parents b7f36ae + b3671f0 commit 7c7d6d2

File tree

11 files changed

+128
-17
lines changed

11 files changed

+128
-17
lines changed

.github/workflows/wasm_of_ocaml.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ jobs:
115115
working-directory: ./wasm_of_ocaml
116116
run: opam pin . -n --with-version dev
117117

118+
- name: Pin dune
119+
run: opam pin add dune https://github.com/ocaml/dune.git
120+
118121
- name: Checkout Jane Street packages
119122
if: matrix.jane_street_tests
120123
run: |

CHANGES.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#dev
22

33
## Features/Changes
4-
* Compiler/wasm: omit code pointer from closures when not used (#2059)
4+
* Compiler/wasm: omit code pointer from closures when not used (#2059, #2093)
55
* Compiler: add optional full lambda lifting for the Javascript compiler (#1886)
66

7+
## Bug fixes
8+
* Compiler: fix purity of comparison functions (again) (#2092)
9+
* Runtime/wasm: fix Unix.times (#2096)
10+
711
# 6.2.0 (2025-07-30) - Lille
812

913
## Features/Changes

compiler/lib-wasm/call_graph_analysis.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ let block_deps ~info ~non_escaping ~ambiguous ~blocks pc =
1515
let block = Addr.Map.find pc blocks in
1616
List.iter block.body ~f:(fun i ->
1717
match i with
18-
| Let (_, Apply { f; _ }) -> (
18+
| Let (_, Apply { f; exact; _ }) -> (
1919
match get_approx info f with
2020
| Top -> ()
2121
| Values { known; others } ->
22-
if others || Var.Set.cardinal known > 1
22+
if (not exact) || others || Var.Set.cardinal known > 1
2323
then Var.Set.iter (fun x -> Var.Hashtbl.replace ambiguous x ()) known;
2424
if debug ()
2525
then

compiler/tests-full/stdlib.cma.expected.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@
350350

351351
//# unitInfo: Provides: Stdlib
352352
//# unitInfo: Requires: CamlinternalFormatBasics
353-
//# shape: Stdlib:[F(1),F(1),N,N,N,N,N,N,N,N,N,N,N,N,N,F(2)*,F(2)*,F(1)*,N,N,F(1)*,N,N,N,N,N,N,F(2)*,F(1),F(1)*,F(1)*,F(1),F(1)*,F(1),F(1),F(1),F(2),N,N,N,F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(3),F(1),F(1),F(2),F(2),F(2),F(4),F(4),F(2),F(2),F(2),F(2),F(1),F(1),F(1),F(1),F(2),F(1),F(1),F(3),F(1),F(1),F(4),F(4),F(2),F(1),F(1),F(1),F(2),F(1),F(1),F(1),F(1),F(2),N,F(1)*,F(2),F(1),F(1),F(1),F(4),F(1),N]
353+
//# shape: Stdlib:[F(1),F(1),N,N,N,N,N,N,N,N,N,N,N,N,N,F(2),F(2),F(1)*,N,N,F(1)*,N,N,N,N,N,N,F(2)*,F(1),F(1)*,F(1)*,F(1),F(1)*,F(1),F(1),F(1),F(2),N,N,N,F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(3),F(1),F(1),F(2),F(2),F(2),F(4),F(4),F(2),F(2),F(2),F(2),F(1),F(1),F(1),F(1),F(2),F(1),F(1),F(3),F(1),F(1),F(4),F(4),F(2),F(1),F(1),F(1),F(2),F(1),F(1),F(1),F(1),F(2),N,F(1)*,F(2),F(1),F(1),F(1),F(4),F(1),N]
354354
(function
355355
(globalThis){
356356
"use strict";
@@ -9077,7 +9077,7 @@
90779077

90789078
//# unitInfo: Provides: Stdlib__Int32
90799079
//# unitInfo: Requires: Stdlib, Stdlib__Sys
9080-
//# shape: Stdlib__Int32:[N,N,N,F(2),F(2),F(1)*,F(1)*,F(1)*,N,N,F(1)*,F(1)*,F(1),F(1)*,F(2)*,F(2)*,F(2)*,F(2)*,F(2)*,F(2)*,F(1)*]
9080+
//# shape: Stdlib__Int32:[N,N,N,F(2),F(2),F(1)*,F(1)*,F(1),N,N,F(1)*,F(1),F(1),F(1)*,F(2)*,F(2)*,F(2),F(2),F(2),F(2)*,F(1)*]
90819081
(function
90829082
(globalThis){
90839083
"use strict";
@@ -9213,7 +9213,7 @@
92139213

92149214
//# unitInfo: Provides: Stdlib__Int64
92159215
//# unitInfo: Requires: Stdlib
9216-
//# shape: Stdlib__Int64:[N,N,N,F(2),F(2),F(1)*,F(1)*,F(1)*,N,N,F(1)*,F(1)*,F(1),F(1)*,F(2)*,F(2)*,F(2)*,F(2)*,F(2)*,F(2)*,F(1)*]
9216+
//# shape: Stdlib__Int64:[N,N,N,F(2),F(2),F(1)*,F(1)*,F(1),N,N,F(1)*,F(1),F(1),F(1)*,F(2)*,F(2)*,F(2),F(2),F(2),F(2)*,F(1)*]
92179217
(function
92189218
(globalThis){
92199219
"use strict";
@@ -9362,7 +9362,7 @@
93629362

93639363
//# unitInfo: Provides: Stdlib__Nativeint
93649364
//# unitInfo: Requires: Stdlib, Stdlib__Sys
9365-
//# shape: Stdlib__Nativeint:[N,N,N,F(2),F(2),F(1)*,F(1)*,F(1)*,N,N,N,F(1)*,F(1)*,F(1),F(1)*,F(2)*,F(2)*,F(2)*,F(2)*,F(2)*,F(2)*,F(1)*]
9365+
//# shape: Stdlib__Nativeint:[N,N,N,F(2),F(2),F(1)*,F(1)*,F(1),N,N,N,F(1)*,F(1),F(1),F(1)*,F(2)*,F(2)*,F(2)*,F(2),F(2),F(2)*,F(1)*]
93669366
(function
93679367
(globalThis){
93689368
"use strict";

compiler/tests-wasm_of_ocaml/dune

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,12 @@
55
(flags :standard --disable optcall --no-inline))
66
(wasm_of_ocaml
77
(flags :standard --disable optcall --no-inline)))
8+
9+
(tests
10+
(names gh2093)
11+
(modes wasm)
12+
(enabled_if
13+
(>= %{ocaml_version} 5))
14+
(wasm_of_ocaml
15+
(compilation_mode whole_program)
16+
(flags :standard)))
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
IN
2+
peform E
3+
OUT
4+
handled E
5+
IN
6+
peform E
7+
OUT
8+
handled E
9+
IN
10+
done
11+
OUT
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
(*
2+
Copyright (c) 2015, KC Sivaramakrishnan <sk826@cl.cam.ac.uk>
3+
4+
Permission to use, copy, modify, and/or distribute this software for any
5+
purpose with or without fee is hereby granted, provided that the above
6+
copyright notice and this permission notice appear in all copies.
7+
8+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15+
*)
16+
17+
(* User-land dynamic wind:
18+
http://okmij.org/ftp/continuations/implementations.html#dynamic-wind *)
19+
open Effect
20+
open Effect.Deep
21+
22+
let dynamic_wind before_thunk thunk after_thunk =
23+
before_thunk ();
24+
let res =
25+
match_with
26+
thunk
27+
()
28+
{ retc = Fun.id
29+
; exnc =
30+
(fun e ->
31+
after_thunk ();
32+
raise e)
33+
; effc =
34+
(fun (type a) (e : a Effect.t) ->
35+
Some
36+
(fun (k : (a, _) continuation) ->
37+
after_thunk ();
38+
let res' = perform e in
39+
before_thunk ();
40+
continue k res'))
41+
}
42+
in
43+
after_thunk ();
44+
res
45+
46+
type _ Effect.t += E : unit Effect.t
47+
48+
let () =
49+
let bt () = Printf.printf "IN\n" in
50+
let at () = Printf.printf "OUT\n" in
51+
let foo () =
52+
Printf.printf "peform E\n";
53+
perform E;
54+
Printf.printf "peform E\n";
55+
perform E;
56+
Printf.printf "done\n"
57+
in
58+
try_with
59+
(dynamic_wind bt foo)
60+
at
61+
{ effc =
62+
(fun (type a) (e : a Effect.t) ->
63+
match e with
64+
| E ->
65+
Some
66+
(fun (k : (a, _) continuation) ->
67+
Printf.printf "handled E\n";
68+
continue k ())
69+
| _ -> None)
70+
}

dune-project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
(ocaml (>= 4.13))
4646
(js_of_ocaml (= :version))
4747
(js_of_ocaml-ppx (= :version))
48-
(lwt (>= 2.4.4))
48+
(lwt (and (>= 2.4.4) (<> 5.9.2)))
4949
(num :with-test)
5050
(ppx_expect (and (>= v0.14.2) :with-test))
5151
(re (and (>= 1.9.0) :with-test)))

js_of_ocaml-lwt.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ depends: [
1616
"ocaml" {>= "4.13"}
1717
"js_of_ocaml" {= version}
1818
"js_of_ocaml-ppx" {= version}
19-
"lwt" {>= "2.4.4"}
19+
"lwt" {>= "2.4.4" & != "5.9.2"}
2020
"num" {with-test}
2121
"ppx_expect" {>= "v0.14.2" & with-test}
2222
"re" {>= "1.9.0" & with-test}

runtime/js/compare.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,9 @@ function caml_compare_val(a, b, total) {
251251
b = b[i];
252252
}
253253
}
254-
//Provides: caml_compare mutable (const, const)
254+
255+
// May raise
256+
//Provides: caml_compare (const, const)
255257
//Requires: caml_compare_val
256258
function caml_compare(a, b) {
257259
return caml_compare_val(a, b, true);
@@ -265,32 +267,44 @@ function caml_int_compare(a, b) {
265267
if (a === b) return 0;
266268
return 1;
267269
}
268-
//Provides: caml_equal mutable (const, const)
270+
271+
// May raise
272+
//Provides: caml_equal (const, const)
269273
//Requires: caml_compare_val
270274
function caml_equal(x, y) {
271275
return +(caml_compare_val(x, y, false) === 0);
272276
}
273-
//Provides: caml_notequal mutable (const, const)
277+
278+
// May raise
279+
//Provides: caml_notequal (const, const)
274280
//Requires: caml_compare_val
275281
function caml_notequal(x, y) {
276282
return +(caml_compare_val(x, y, false) !== 0);
277283
}
278-
//Provides: caml_greaterequal mutable (const, const)
284+
285+
// May raise
286+
//Provides: caml_greaterequal (const, const)
279287
//Requires: caml_compare_val
280288
function caml_greaterequal(x, y) {
281289
return +(caml_compare_val(x, y, false) >= 0);
282290
}
283-
//Provides: caml_greaterthan mutable (const, const)
291+
292+
// May raise
293+
//Provides: caml_greaterthan (const, const)
284294
//Requires: caml_compare_val
285295
function caml_greaterthan(x, y) {
286296
return +(caml_compare_val(x, y, false) > 0);
287297
}
288-
//Provides: caml_lessequal mutable (const, const)
298+
299+
// May raise
300+
//Provides: caml_lessequal (const, const)
289301
//Requires: caml_compare_val
290302
function caml_lessequal(x, y) {
291303
return +(caml_compare_val(x, y, false) <= 0);
292304
}
293-
//Provides: caml_lessthan mutable (const, const)
305+
306+
// May raise
307+
//Provides: caml_lessthan (const, const)
294308
//Requires: caml_compare_val
295309
function caml_lessthan(x, y) {
296310
return +(caml_compare_val(x, y, false) < 0);

0 commit comments

Comments
 (0)