Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Effects: double translation of functions and dynamic switching between direct-style and CPS code #1461

Open
wants to merge 81 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
120f235
Effects: double translation of functions and
OlivierNicole Mar 9, 2023
38f0462
Add caml_assume_no_effects primitive and tests
OlivierNicole Jun 11, 2024
7f769be
CR: Fix non-raised Unhandled with assume_no_perform
OlivierNicole Nov 20, 2024
0192c16
CR: Commit suggestion for compiler/lib/driver.ml
OlivierNicole Nov 20, 2024
10f8752
Fix runtime deps, add missing test
OlivierNicole Nov 20, 2024
92e41d8
CR
OlivierNicole Nov 22, 2024
de30b43
CR
OlivierNicole Nov 22, 2024
77c2331
Runtime format
OlivierNicole Nov 22, 2024
22584e4
Factorize substitution logic
OlivierNicole Nov 27, 2024
370a0b0
CR: make caml_callback an alias of caml_call_gen...
OlivierNicole Nov 28, 2024
e980a1b
Promote tests
OlivierNicole Nov 28, 2024
55cbe59
CR: Fix caml_trampoline_cps and rename it to caml_resume
OlivierNicole Nov 28, 2024
ef3bc27
CR: First fixes to Lambda_lifting_simple
OlivierNicole Nov 28, 2024
c2f39d3
Simplify and clarify Lambda_lifting_simple
OlivierNicole Nov 29, 2024
21c955b
Format runtime
OlivierNicole Nov 29, 2024
5ed1a30
Fix bug: functions inside CPS functions were not lambda-lifted
OlivierNicole Nov 29, 2024
efb7892
Runtime: fix caml_uncaught_effect_handler
vouillon Nov 29, 2024
5b7c9e4
Runtime: the trampoline now distinguish direct and CPS calls
vouillon Nov 29, 2024
1d34f2b
Fix unregistered test and add one for nested handler
OlivierNicole Dec 3, 2024
425e526
Uses 'tests' dune stanza
OlivierNicole Dec 3, 2024
f605852
Reformat dune files and remove leftover files
OlivierNicole Dec 3, 2024
9586742
CR: Fixes in Lambda_lifting_simple
OlivierNicole Dec 3, 2024
b62ba9a
CR: remove unnecessary conditionals in Effects
OlivierNicole Dec 3, 2024
ffa361b
CR: Remove duplicate instruction
OlivierNicole Dec 4, 2024
d5cb751
CR: Apply suggested simplifications
OlivierNicole Dec 4, 2024
49ca07e
Add test for lambda-lifting of mutually recursive functions
OlivierNicole Dec 4, 2024
13ede20
CR
OlivierNicole Dec 4, 2024
68b1334
Revert addition of no longer necessary Freevars functions
OlivierNicole Dec 4, 2024
cf89d76
Add wasm mode to double translation tests
OlivierNicole Dec 4, 2024
d874120
CR: Add missing Wasm stubs
OlivierNicole Dec 4, 2024
259973a
Revert "Add wasm mode to double translation tests"
OlivierNicole Dec 5, 2024
64a6beb
Update dune.inc
OlivierNicole Dec 5, 2024
028027a
CR
OlivierNicole Dec 5, 2024
17a051f
CR
OlivierNicole Dec 5, 2024
1ff3b10
Use copy_file rather than duplicate tests
OlivierNicole Dec 6, 2024
f5ed63b
Update comment
OlivierNicole Dec 6, 2024
0807507
CR: Factorize some code
OlivierNicole Dec 6, 2024
21e750a
CR
OlivierNicole Dec 6, 2024
b734492
CR: simplify
OlivierNicole Dec 6, 2024
343f270
Simplify function rewrite_instr
vouillon Dec 9, 2024
28690a7
Function assume_no_perform makes perform fail for all effect implemen…
vouillon Dec 9, 2024
43eb25b
CR: Add --effects option
OlivierNicole Dec 10, 2024
0835a69
Fix Dynlink and limit use of --enable=effects
OlivierNicole Dec 11, 2024
29c6a82
Reformat
OlivierNicole Dec 12, 2024
b8a3799
CR
OlivierNicole Dec 12, 2024
733f4dc
CR
OlivierNicole Dec 12, 2024
618bc52
CR: add missing bound check
OlivierNicole Dec 12, 2024
244267e
CR: Simplification in compiler/lib/effects.ml
OlivierNicole Dec 12, 2024
b705214
CR: simplify closure allocation
OlivierNicole Dec 12, 2024
f1441bc
Javascript runtime: stop using 'arguments'
OlivierNicole Dec 12, 2024
4107e24
Fix too early effects backend setting
OlivierNicole Dec 12, 2024
9b8a90b
Fix uses of `--enable=effects` in lib-wasm/
vouillon Dec 12, 2024
cc38500
Move assume_no_perform to Jsoo_runtime
OlivierNicole Dec 12, 2024
31be126
Fix: move C primitive
OlivierNicole Dec 12, 2024
26a2b6d
CR
OlivierNicole Dec 13, 2024
f736e33
CR: rephrase comment
OlivierNicole Dec 16, 2024
68d02df
CR: Move effects backend choice logic
OlivierNicole Dec 16, 2024
35b27b0
CR: simplify
OlivierNicole Dec 16, 2024
12adc93
Docs: document double translation better
OlivierNicole Dec 16, 2024
b778d47
Fix warning
OlivierNicole Dec 16, 2024
1910866
Fix another warning
OlivierNicole Dec 16, 2024
6536533
Update manual/effects.wiki
OlivierNicole Dec 16, 2024
cfdca94
CR: revert some changes in docs
OlivierNicole Dec 16, 2024
f914e22
Don't set effects_backend in _cmd_arg_ modules
hhugo Dec 17, 2024
865f90e
Fix compilation
OlivierNicole Dec 17, 2024
9c28e19
CR
OlivierNicole Dec 17, 2024
b025490
CR: add CONFIG macro
OlivierNicole Dec 17, 2024
796e973
Re-export Jsoo_runtime from the js_of_ocaml library
OlivierNicole Dec 19, 2024
dded0e8
Fix spurious free var warning over CONFIG macro
OlivierNicole Dec 19, 2024
c4e594f
CR: Update compiler/lib/driver.ml
OlivierNicole Dec 19, 2024
6bb65e4
Remove duplicate effects flag
OlivierNicole Dec 20, 2024
6391bd6
CR: more explicit type for effects backend
OlivierNicole Dec 21, 2024
51b3d50
CR: doc phrasing
OlivierNicole Dec 22, 2024
3109620
CR: revert obsolete change
OlivierNicole Dec 22, 2024
821537d
Fix assertion
OlivierNicole Dec 22, 2024
3a52728
CR: comment to justify constant
OlivierNicole Dec 22, 2024
5541f1b
reformat
OlivierNicole Dec 22, 2024
01595fc
Fixes
OlivierNicole Dec 22, 2024
7066f6b
Fix assert failure
OlivierNicole Dec 23, 2024
0eeaafe
reformat
OlivierNicole Dec 23, 2024
7161b7e
Merge branch 'master' into optim_effects
hhugo Dec 28, 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
Prev Previous commit
Next Next commit
Fix runtime deps, add missing test
  • Loading branch information
OlivierNicole committed Dec 17, 2024
commit 10f8752a83b4504e30fc700ffc14c618be06f787
26 changes: 26 additions & 0 deletions compiler/tests-ocaml/lib-effects/assume_no_perform_unhandled.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
open Printf
open Effect
open Effect.Deep

type _ Effect.t += Dummy : unit t

let must_raise () =
try_with
(fun () ->
Js_of_ocaml.Js.Effect.assume_no_perform (fun () ->
(* Should raise [Effect.Unhandled] despite the installed handler *)
perform Dummy
)
)
()
{ effc =
(fun (type a) (e : a Effect.t) ->
match e with
| Dummy -> Some (fun (k : (a, _) continuation) -> continue k ())
| _ -> None)
}

let () =
try
must_raise (); print_endline "failed"; exit 2
with Effect.Unhandled Dummy -> print_endline "ok"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
open Printf
open Effect
open Effect.Deep

type _ Effect.t += Dummy : unit t

let must_raise () =
try_with
(fun () ->
Js_of_ocaml.Js.Effect.assume_no_perform (fun () ->
(* Should raise [Effect.Unhandled] despite the installed handler *)
perform Dummy
)
)
()
{ effc =
(fun (type a) (e : a Effect.t) ->
match e with
| Dummy -> Some (fun (k : (a, _) continuation) -> continue k ())
| _ -> None)
}

let () =
try
must_raise (); print_endline "failed"; exit 2
with Effect.Unhandled Dummy -> print_endline "ok"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ok
6 changes: 2 additions & 4 deletions runtime/js/effect.js
Original file line number Diff line number Diff line change
@@ -76,7 +76,6 @@ function caml_pop_trap() {
//Provides: caml_raise_unhandled
//Requires: caml_named_value, caml_raise_with_arg, caml_raise_constant, caml_string_of_jsbytes, caml_fresh_oo_id
//If: effects
//If: doubletranslate
function caml_raise_unhandled(eff) {
var exn = caml_named_value("Effect.Unhandled");
if (exn) caml_raise_with_arg(exn, eff);
@@ -90,11 +89,10 @@ function caml_raise_unhandled(eff) {
}
}

//Provides: caml_uncaught_effect_handler
//Provides: uncaught_effect_handler
//Requires: caml_resume_stack, caml_raise_unhandled
//If: effects
//If: doubletranslate
function caml_uncaught_effect_handler(eff, k, ms) {
function uncaught_effect_handler(eff, k, ms) {
// Resumes the continuation k by raising exception Unhandled.
caml_resume_stack(k[1], ms);
caml_raise_unhandled(eff);
8 changes: 4 additions & 4 deletions runtime/js/jslib.js
Original file line number Diff line number Diff line change
@@ -85,15 +85,15 @@ var caml_callback = caml_call_gen;
//Provides: caml_callback
//If: effects
//If: !doubletranslate
//Requires:caml_stack_depth, caml_call_gen, caml_exn_stack, caml_fiber_stack, caml_wrap_exception, caml_uncaught_effect_handler
//Requires:caml_stack_depth, caml_call_gen, caml_exn_stack, caml_fiber_stack, caml_wrap_exception, uncaught_effect_handler
function caml_callback(f, args) {
var saved_stack_depth = caml_stack_depth;
var saved_exn_stack = caml_exn_stack;
var saved_fiber_stack = caml_fiber_stack;
try {
caml_exn_stack = 0;
caml_fiber_stack = {
h: [0, 0, 0, caml_uncaught_effect_handler],
h: [0, 0, 0, uncaught_effect_handler],
r: { k: 0, x: 0, e: 0 },
};
var res = {
@@ -125,7 +125,7 @@ function caml_callback(f, args) {
//Provides: caml_callback
//If: effects
//If: doubletranslate
//Requires:caml_stack_depth, caml_call_gen, caml_exn_stack, caml_fiber_stack, caml_uncaught_effect_handler
//Requires:caml_stack_depth, caml_call_gen, caml_exn_stack, caml_fiber_stack, uncaught_effect_handler
//Requires: caml_raise_constant
function caml_callback(f, args) {
OlivierNicole marked this conversation as resolved.
Show resolved Hide resolved
var saved_stack_depth = caml_stack_depth;
@@ -134,7 +134,7 @@ function caml_callback(f, args) {
try {
caml_exn_stack = 0;
caml_fiber_stack = {
h: [0, 0, 0, caml_uncaught_effect_handler],
h: [0, 0, 0, uncaught_effect_handler],
r: { k: 0, x: 0, e: 0 },
};
return caml_call_gen(f, args);