aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/interp/g-opt.boot15
2 files changed, 19 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index b1d41d6d..56d3b90b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,11 @@
2010-06-12 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ * interp/g-opt.boot (replaceableTemporary?): New.
+ (optSEQ) [getRidOfTemps]: Use it to decide when to safely inline a
+ temporary variable definition.
+
+2010-06-12 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
* interp/compiler.boot (compIterate): Rewrite.
(compRepeatOrCollect): Tidy. Bind $loopBodyTag.
diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot
index be39629b..119da259 100644
--- a/src/interp/g-opt.boot
+++ b/src/interp/g-opt.boot
@@ -330,7 +330,18 @@ optCONDtail l ==
optPredicateIfTrue p => [[$true,c]]
null rest l => [frst,[$true,["CondError"]]]
[frst,:optCONDtail l']
-
+
+++ Determine whether the symbol `g' is the name of a temporary that
+++ can be replaced in the form `x', if it is of linear usage and not
+++ the name of a program point. The latter occurs when THROW forms
+++ are changed to %LET form followed by a GO form -- see optCatch.
+replaceableTemporary?(g,x) ==
+ GENSYMP g and numOfOccurencesOf(g,x) < 2 and not jumpTarget?(g,x) where
+ jumpTarget?(g,x) ==
+ isAtomicForm x => false
+ x is ['GO,=g] => true
+ or/[jumpTarget?(g,x') for x' in x]
+
optSEQ ["SEQ",:l] ==
tryToRemoveSEQ SEQToCOND getRidOfTemps splicePROGN l where
splicePROGN l ==
@@ -339,7 +350,7 @@ optSEQ ["SEQ",:l] ==
l.rest := splicePROGN rest l
getRidOfTemps l ==
null l => nil
- l is [["%LET",g,x,:.],:r] and GENSYMP g and 2>numOfOccurencesOf(g,r) =>
+ l is [["%LET",g,x],:r] and replaceableTemporary?(g,r) =>
getRidOfTemps substitute(x,g,r)
first l="/throwAway" => getRidOfTemps rest l
--this gets rid of unwanted labels generated by declarations in SEQs