Skip to content

Commit 1c76aeb

Browse files
committed
Rectify some outdated comments
1 parent e0c3c22 commit 1c76aeb

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

compiler/lib/effects.ml

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -830,16 +830,9 @@ let cps_block ~st ~k ~lifter_functions ~orig_pc block =
830830
; branch = last
831831
}
832832

833-
(* Modify all function applications and closure creations to take into account
834-
the fact that closures are turned (direct style, CPS) closure pairs. Also
835-
rewrite the effect primitives to switch to the CPS version of functions (for
836-
resume) or fail (for perform).
837-
For each closure created in the original code, two closures are now created.
838-
The parameters of the CPS closure are duplicated from the original one.
839-
However, we need to maintain the invariant that all variables are bound
840-
exactly once. This is done by creating fresh arguments for each CPS closure
841-
and returning a substitution from the original parameters to the new ones,
842-
that must be applied to all code that might use the original parameters. *)
833+
(* Modify all function applications and closure creations to take into account the fact
834+
that some closures must now have a CPS version. Also rewrite the effect primitives to
835+
switch to the CPS version of functions (for resume) or fail (for perform). *)
843836
let rewrite_direct_block ~cps_needed ~closure_info ~ident_fn ~pc ~lifter_functions block =
844837
debug_print "@[<v>rewrite_direct_block %d@,@]" pc;
845838
let rewrite_instr = function
@@ -1021,12 +1014,10 @@ let cps_transform ~lifter_functions ~live_vars ~flow_info ~cps_needed p =
10211014
());
10221015
let blocks, free_pc, bound_subst, param_subst, new_blocks =
10231016
(* For every block in the closure,
1024-
1. add its CPS translation to the block map at a fresh address, if
1025-
needed
1026-
2. keep the direct-style block but modify all function applications
1027-
to take into account the fact that some closure are turned into
1028-
(direct style closure, CPS closure) pairs, and modify uses of the
1029-
%resume and %perform primitives. *)
1017+
1. add its CPS translation to the block map at a fresh address, if needed
1018+
2. keep the direct-style block but modify function definitions to add the CPS
1019+
version where needed, and turn uses of %resume and %perform into switchings
1020+
to CPS. *)
10301021
let param_subst, transform_block =
10311022
if function_needs_cps
10321023
then (
@@ -1086,9 +1077,9 @@ let cps_transform ~lifter_functions ~live_vars ~flow_info ~cps_needed p =
10861077
st.blocks
10871078
in
10881079
let new_blocks_this_clos, free_pc = st.new_blocks in
1089-
(* Substitute all variables bound in the CPS version with fresh
1090-
variables to avoid clashing with the definitions in the original
1091-
blocks. *)
1080+
(* All variables bound in the CPS version will have to be subst with fresh ones
1081+
to avoid clashing with the definitions in the original blocks (the actual
1082+
substitution is done later). *)
10921083
let bound =
10931084
Addr.Map.fold
10941085
(fun _ block bound ->

0 commit comments

Comments
 (0)