diff options
author | dos-reis <gdr@axiomatics.org> | 2011-02-11 22:44:17 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2011-02-11 22:44:17 +0000 |
commit | f80c643a39ac6a3870e6a3b7cc967b8e6a3d0915 (patch) | |
tree | 674890116c0e16a70e970e51338adbf789cfe295 | |
parent | 8ecbf7e6da63799ae070e1b81a048a7b7790000f (diff) | |
download | open-axiom-f80c643a39ac6a3870e6a3b7cc967b8e6a3d0915.tar.gz |
* interp/g-opt.boot (dependentVars): New.
(canInlineVarDefinition): Use it to safely inline vardefs.
-rw-r--r-- | src/ChangeLog | 5 | ||||
-rw-r--r-- | src/interp/g-opt.boot | 22 |
2 files changed, 24 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 90ca0eab..339c91ac 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2011-02-11 Gabriel Dos Reis <gdr@cs.tamu.edu> + * interp/g-opt.boot (dependentVars): New. + (canInlineVarDefinition): Use it to safely inline vardefs. + +2011-02-11 Gabriel Dos Reis <gdr@cs.tamu.edu> + * interp/compiler.boot (canReturn): Don't check for LET*. * interp/g-opt.boot (optLET*): Remove as we now generate only %bind forms. diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot index fd5010a0..d777bc58 100644 --- a/src/interp/g-opt.boot +++ b/src/interp/g-opt.boot @@ -490,15 +490,31 @@ varIsAssigned(var,form) == var' is [.,=var] -- only part of it is modified or/[varIsAssigned(var,f) for f in form] + +++ Return the list of variables referenced in `expr'. +dependentVars expr == main(expr,nil) where + main(x,vars) == + IDENTP x => + MEMQ(x,vars) => vars + [x,:vars] + atomic? x => vars + x' := + cons? x.op => x + x.args + for y in x' repeat + vars := main(y,vars) + vars + ++ Subroutine of optLET and optBind. Return true if the variable `var' locally ++ defined in a binding form can be safely replaced by its initalization ++ `expr' in the `body' of the binding form. canInlineVarDefinition(var,expr,body) == + -- FIXME: We should not be inlining a side-effecting initializer. -- If the variable is assigned to, that is a no no. varIsAssigned(var,body) => false - -- Similarly, if the variable is initialized from a variable that - -- is latter assigned, it is a no no. - IDENTP expr and varIsAssigned(expr,body) => false + -- Similarly, if the initial value depends on variables that are + -- side-effected latter, it is alos a no no. + or/[varIsAssigned(x,body) for x in dependentVars expr] => false -- Conversatively preserve order of inialization body is ['%bind,:.] => false -- Linearly used internal temporaries should be replaced, and |