aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/interp/g-opt.boot25
2 files changed, 26 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 2a2a5186..bbab7ecb 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2011-12-13 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * interp/g-opt.boot (removeJunk!): Rename from removeSeq!
+ (cancelScopeLeave!): New.
+ (inlineLocals!): Tidy.
+ (optimize!): Run cancelScopeLeave! right after removeJunk!.
+
2011-12-12 Gabriel Dos Reis <gdr@cs.tamu.edu>
* interp/g-opt.boot: Rework. Schedule conditional splitting
diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot
index 20b1b962..851e7eb6 100644
--- a/src/interp/g-opt.boot
+++ b/src/interp/g-opt.boot
@@ -214,9 +214,12 @@ reduceXLAM! x == walkWith!(x,function f) where
resetTo(x,doInlineCall(args,y.absParms,copyTree y.absBody))
x
-++ Splice in all %seq subforms, remove throw away expressions,
-++ and remove unnecessary %seq boxes around singleton expressions.
-removeSeq! x == walkWith!(x,function f) where
+++ Remove throw-away expressions, inline one-time temporaries
+++ abstracting conditionals (generated by the parser) and remove
+++ unnecessary %seq boxes around singleton expressions.
+++ NOTES: this transformation must be run before any grouping
+++ of intermediate result bindings.
+removeJunk! x == walkWith!(x,function f) where
f x ==
x is ['%seq,:.] =>
x.args := g x.args
@@ -227,6 +230,8 @@ removeSeq! x == walkWith!(x,function f) where
xs = nil => nil
x := first xs
x is "/throwAway" => g rest xs -- skip garbages
+ x is ['%LET,y,u] and gensym? y and numOfOccurencesOf(y,rest xs) = 1 =>
+ g substitute!(u,y,rest xs)
x is ['%seq,:.] => -- splice sub-sequences
ys := x.args =>
lastNode(ys).rest := rest xs
@@ -239,12 +244,12 @@ removeSeq! x == walkWith!(x,function f) where
inlineLocals! x == walkWith!(x,function f) where
f x ==
- x is ['%bind,[[y,a]],z] and gensym? y and numOfOccurencesOf(y,z) = 1 =>
- resetTo(x,f substitute!(a,y,z))
x is ['%bind,inits,:.] =>
kept := nil
while inits is [u,:inits] repeat
[y,z] := u
+ gensym? y and numOfOccurencesOf(y,x.absBody) = 1 =>
+ x.absBody := substitute!(z,y,x.absBody)
usedSymbol?(y,z) or usedSymbol?(y,inits) => kept := [u,:kept]
or/[usedSymbol?(v,z) for [v,.] in kept] => kept := [u,:kept]
canInlineVarDefinition(y,z,x.absBody) =>
@@ -314,6 +319,14 @@ spliceSeq! x == walkWith!(x,function f) where
x.args := spliceSeqArgs x.args
x
+++ Remove superfluous cancel/scope pairs exposed by running
+++ removeJunk!.
+cancelScopeLeave! x == walkWith!(x,function f) where
+ f x ==
+ x is ['%scope,g,['%leave,=g,y]] and hasNoLeave?(y,g) =>
+ resetTo(x,f y)
+ x
+
++ Transform an intermediate form (output of the elaborator) to
++ a lower intermediate form, applying several transformations
++ generaly intended to improve quality and efficiency.
@@ -321,7 +334,7 @@ optimize! x ==
x := spliceSeq! packWhen! transformIF! x
changeVariableDefinitionToStore(x,nil)
simplifyVMForm spliceSeq! packWhen! inlineLocals!
- groupTranscients! removeSeq! reduceXLAM! x
+ groupTranscients! cancelScopeLeave! removeJunk! reduceXLAM! x
++ A non-mutating version of `optimize!'.
optimize x ==