diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 1998-04-30 12:12:28 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 1998-04-30 12:12:28 +0000 |
commit | baa58a54a938a07810e2fa201448ea277da7dae1 (patch) | |
tree | e3f07040ed8a0f29ab4ba915177d7c5ae56c206a | |
parent | bdcbaa96025eb71f9aaeaef1573ca234b79fd846 (diff) |
Ajout du let_kind Variable, pour aider les transformations ulterieures (e.g. propagation des constantes entieres dans Closure)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1944 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | bytecomp/lambda.ml | 2 | ||||
-rw-r--r-- | bytecomp/lambda.mli | 11 | ||||
-rw-r--r-- | bytecomp/simplif.ml | 4 |
3 files changed, 13 insertions, 4 deletions
diff --git a/bytecomp/lambda.ml b/bytecomp/lambda.ml index e346adb5d..d1f1f5f86 100644 --- a/bytecomp/lambda.ml +++ b/bytecomp/lambda.ml @@ -70,7 +70,7 @@ type structured_constant = type function_kind = Curried | Tupled -type let_kind = Strict | Alias | StrictOpt +type let_kind = Strict | Alias | StrictOpt | Variable type shared_code = (int * int) list diff --git a/bytecomp/lambda.mli b/bytecomp/lambda.mli index 8a7472945..8a6244bb7 100644 --- a/bytecomp/lambda.mli +++ b/bytecomp/lambda.mli @@ -70,7 +70,16 @@ type structured_constant = type function_kind = Curried | Tupled -type let_kind = Strict | Alias | StrictOpt +type let_kind = Strict | Alias | StrictOpt | Variable +(* Meaning of kinds for let x = e in e': + Strict: e may have side-effets; always evaluate e first + (If e is a simple expression, e.g. a variable or constant, + we may still substitute e'[x/e].) + Alias: e is pure, we can substitute e'[x/e] if x has 0 or 1 occurrences + in e' + StrictOpt: e does not have side-effects, but depend on the store; + we can discard e if x does not appear in e' + Variable: the variable x is assigned later in e' *) type shared_code = (int * int) list (* stack size -> code label *) diff --git a/bytecomp/simplif.ml b/bytecomp/simplif.ml index 3a00812e0..b3d07d136 100644 --- a/bytecomp/simplif.ml +++ b/bytecomp/simplif.ml @@ -156,11 +156,10 @@ let simplify_lambda lam = let slinit = simplif linit in let slbody = simplif lbody in begin try - Llet(Strict, v, slinit, eliminate_ref v slbody) + Llet(Variable, v, slinit, eliminate_ref v slbody) with Real_reference -> Llet(Strict, v, Lprim(Pmakeblock(0, Mutable), [slinit]), slbody) end - | Llet(Strict, v, l1, l2) -> Llet(Strict, v, simplif l1, simplif l2) | Llet(Alias, v, l1, l2) -> begin match count_var v with 0 -> simplif l2 @@ -172,6 +171,7 @@ let simplify_lambda lam = 0 -> simplif l2 | n -> Llet(Alias, v, simplif l1, simplif l2) end + | Llet(kind, v, l1, l2) -> Llet(kind, v, simplif l1, simplif l2) | Lletrec(bindings, body) -> Lletrec(List.map (fun (v, l) -> (v, simplif l)) bindings, simplif body) | Lprim(p, ll) -> Lprim(p, List.map simplif ll) |