Skip to content

Commit 70aac7f

Browse files
vouillonhhugo
authored andcommitted
Double translation: fix stack overflow issue
The CPS code can still be deeply nested, so we need to perform a lambda lifting after the translation.
1 parent ac2affe commit 70aac7f

File tree

5 files changed

+5
-32
lines changed

5 files changed

+5
-32
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Runtime: fix path normalization (#1848)
1414
* Runtime: fix reading from the pseudo-filesystem (#1859)
1515
* Runtime: fix initialization of standard streams under Windows (#1849)
16+
* Compiler: fix stack overflow issues with double translation (#1869)
1617

1718
# 6.0.1 (2025-02-07) - Lille
1819

compiler/lib/driver.ml

+2-7
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ let map_fst f (x, y, z) = f x, y, z
9999

100100
let effects ~deadcode_sentinal p =
101101
match Config.effects () with
102-
| (`Cps | `Double_translation) as effects ->
102+
| `Cps | `Double_translation ->
103103
if debug () then Format.eprintf "Effects...@.";
104104
let p, live_vars = Deadcode.f p in
105105
let p = Effects.remove_empty_blocks ~live_vars p in
@@ -112,12 +112,7 @@ let effects ~deadcode_sentinal p =
112112
Deadcode.f p
113113
else p, live_vars
114114
in
115-
p
116-
|> Effects.f ~flow_info:info ~live_vars
117-
|> map_fst
118-
(match effects with
119-
| `Double_translation -> Fun.id
120-
| `Cps -> Lambda_lifting.f)
115+
p |> Effects.f ~flow_info:info ~live_vars |> map_fst Lambda_lifting.f
121116
| `Disabled | `Jspi ->
122117
( p
123118
, (Code.Var.Set.empty : Effects.trampolined_calls)

tools/dune

+1-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
11
(executable
22
(name node_wrapper)
3-
(modules node_wrapper node_wrapper_per_profile)
3+
(modules node_wrapper)
44
(libraries unix))
55

6-
(executable
7-
(name gen_node_wrapper_per_profile)
8-
(modules gen_node_wrapper_per_profile))
9-
10-
(rule
11-
(target node_wrapper_per_profile.ml)
12-
(action
13-
(with-stdout-to
14-
%{target}
15-
(run ./gen_node_wrapper_per_profile.exe %{profile}))))
16-
176
(executable
187
(name ci_setup)
198
(modules ci_setup)

tools/gen_node_wrapper_per_profile.ml

-12
This file was deleted.

tools/node_wrapper.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ let extra_args_for_wasoo =
44
; "--stack-size=10000"
55
]
66

7-
let extra_args_for_jsoo = [] @ Node_wrapper_per_profile.args
7+
let extra_args_for_jsoo = []
88

99
let env = Unix.environment ()
1010

0 commit comments

Comments
 (0)