aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ChangeLog8
-rw-r--r--src/interp/g-opt.boot28
-rw-r--r--src/interp/g-util.boot2
-rw-r--r--src/interp/lisp-backend.boot1
4 files changed, 19 insertions, 20 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index de3d39a2..0a8c4aaa 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,7 +1,13 @@
2011-12-17 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ * interp/g-opt.boot (removeScope!): New.
+ (optimize!): Call it.
+ (optimizeFunctionDef): Simplify.
+
+2011-12-17 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
* interp/compiler.boot (compColon): Handle multiple declarations
- properly.
+ properly.
2011-12-17 Gabriel Dos Reis <gdr@cs.tamu.edu>
diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot
index 7816eafb..75d358da 100644
--- a/src/interp/g-opt.boot
+++ b/src/interp/g-opt.boot
@@ -371,14 +371,22 @@ cleanLoop! x == prefixWalk!(x,function f) where
xs.first := g(first xs,tag)
x
+removeScope! x == prefixWalk!(x,function f) where
+ f x ==
+ x is ['%scope,g,y] =>
+ hasNoLeave?(y,g) => resetTo(x,f y)
+ x
+ x
+
++ Transform an intermediate form (output of the elaborator) to
++ a lower intermediate form, applying several transformations
++ generaly intended to improve quality and efficiency.
optimize! x ==
x := spliceSeq! packWhen! transformIF! removeLeave! cleanLoop! x
changeVariableDefinitionToStore(x,nil)
- simplifyVMForm cancelScopeLeave! spliceSeq! packWhen! inlineLocals!
- groupTranscients! cancelScopeLeave! removeJunk! reduceXLAM! x
+ simplifyVMForm removeScope! cancelScopeLeave! spliceSeq! packWhen!
+ inlineLocals! groupTranscients! cancelScopeLeave!
+ removeJunk! reduceXLAM! x
++ A non-mutating version of `optimize!'.
optimize x ==
@@ -395,22 +403,6 @@ optimizeFunctionDef(def) ==
sayBrightlyI bright '"Intermediate VM code:"
pp expr
- expr.absBody :=
- removeTopLevelLabel expr.absBody where
- removeTopLevelLabel body ==
- body is ['%scope,g,u] =>
- removeTopLevelLabel replaceLeaveByReturn(u,g)
- body
- replaceLeaveByReturn(x,g) ==
- fn(x,g)
- x
- fn(x,g) ==
- x is ['%leave,=g,:u] =>
- x.first := "RETURN"
- x.rest := replaceLeaveByReturn(u,g)
- x isnt [.,:.] => nil
- replaceLeaveByReturn(first x,g)
- replaceLeaveByReturn(rest x,g)
[first def,expr]
resetTo(x,y) ==
diff --git a/src/interp/g-util.boot b/src/interp/g-util.boot
index 4404d105..bceb53b9 100644
--- a/src/interp/g-util.boot
+++ b/src/interp/g-util.boot
@@ -55,8 +55,8 @@ abstraction? x ==
x is [op,:.] and ident? op and abstractionOperator? op
hasNoLeave?(expr,g) ==
+ atomic? expr => true
expr is ['%leave, =g,:.] => false
- expr isnt [.,:.] => true
hasNoLeave?(first expr,g) and hasNoLeave?(rest expr,g)
mkScope(tag,expr) ==
diff --git a/src/interp/lisp-backend.boot b/src/interp/lisp-backend.boot
index fb1e012b..8dac4ce9 100644
--- a/src/interp/lisp-backend.boot
+++ b/src/interp/lisp-backend.boot
@@ -649,6 +649,7 @@ for x in [
['%lambda, :'LAMBDA],
['%exit, :'EXIT],
['%when, :'COND],
+ ['%scope, :'BLOCK],
-- I/O stream functions
['%writeString, :'WRITE_-STRING],