diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 8 | ||||
-rw-r--r-- | src/interp/compiler.boot | 37 | ||||
-rw-r--r-- | src/interp/g-opt.boot | 17 |
3 files changed, 26 insertions, 36 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index d4af37a2..b82acad7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,13 @@ 2011-12-15 Gabriel Dos Reis <gdr@cs.tamu.edu> + * interp/g-opt.boot (removeLoopExitTag!): New. + (optimize!): Run it first. + * interp/compiler.boot (nullifyTargetingLeaves): Remove. + (massageLoop): Likewise. + (compRepeatOrCollect): Don't call it anymore. + +2011-12-15 Gabriel Dos Reis <gdr@cs.tamu.edu> + * interp/compiler.boot: Rename %loop to %repeat. Propagate. * interp/g-opt.boot: Likewise. * interp/i-map.boot: Likewise. diff --git a/src/interp/compiler.boot b/src/interp/compiler.boot index b93ccd4e..a6c3cf02 100644 --- a/src/interp/compiler.boot +++ b/src/interp/compiler.boot @@ -2452,39 +2452,6 @@ localReferenceIfThere(m,e) == idx := assocIndex(constructorDB currentConstructor e,m) => ['%tref,'$,idx] quote m -++ We are processing a loop with entrypoint labelled `tag'. -++ Attempt to nullify targets of all enclosed %leave forms -++ that designate `tag'. -++ NOTES: A %leave form with null target exits the innermost -++ enclosing labelled expression. -nullifyTargetingLeaves(x,tag) == - atomic? x => nil - x is ['%leave,=tag,expr] => - nullifyTargetingLeaves(expr,tag) - -- Avoid redundant %leave for return-expressions. - expr is ['TAGGEDreturn,:.] => - x.op := expr.op - x.args := expr.args - second(x) := nil - for x' in x repeat - nullifyTargetingLeaves(x',tag) - - -massageLoop x == main x where - main x == - x isnt ['%scope,tag,['REPEAT,:iters,body]] => x - nullifyTargetingLeaves(body,tag) - containsNonLocalControl?(body,nil) => systemErrorHere ['massageLoop,x] - ['%scope,tag,['%repeat,:iters,body,'%nil]] - containsNonLocalControl?(x,tags) == - atomic? x => false - x is ['%leave,tag,x'] => - tag = nil => false -- see NOTES in nullifyTargetingLeaves. - not symbolMember?(tag,tags) or containsNonLocalControl?(x',tags) - x is ['%scope,tag,x'] => - containsNonLocalControl?(x',[tag,:tags]) - or/[containsNonLocalControl?(x',tags) for x' in x] - compRepeatOrCollect(form,m,e) == fn(form,[m,:$exitModeStack],[#$exitModeStack,:$leaveLevelStack],$formalArgList ,e) where @@ -2529,14 +2496,14 @@ compRepeatOrCollect(form,m,e) == ["%CollectV",localReferenceIfThere(m',e'),:itl',body'] -- We are phasing out use of LISP macros COLLECT and REPEAT. $loopKind = "COLLECT" => ['%collect,:itl',body'] - [$loopKind,:itl',body'] + ['%repeat,:itl',body','%nil] m'' := aggr is [c,.] and c in '(List PrimitiveArray Vector) => [c,m'] m' T := coerceExit([form',m'',e'],targetMode) or return nil -- iterator variables and other variables declared in -- in a loop are local to the loop. - [massageLoop T.expr,T.mode,oldEnv] + [T.expr,T.mode,oldEnv] --constructByModemap([x,source,e],target) == -- u:= diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot index 453ebbba..37087c9b 100644 --- a/src/interp/g-opt.boot +++ b/src/interp/g-opt.boot @@ -345,11 +345,26 @@ removeLeave! x == walkWith!(x,function f) where x is ['%leave,.,y] and y is ['%return,:.] => resetTo(x,y) x +removeLoopExitTag! x == walkWith!(x,function f) where + f x == + x is ['%scope,tag,['%repeat,:itl,body,val]] => + resetTo(x,['%repeat,:itl,g(body,tag),g(val,tag)]) + x + g(x,tag) == + atomic? x => x + x is ['%leave,=tag,y] => + first(x.args) := nil + second(x.args) := g(y,tag) + x + for xs in tails x repeat + xs.first := g(first xs,tag) + 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! x + x := spliceSeq! packWhen! transformIF! removeLeave! removeLoopExitTag! x changeVariableDefinitionToStore(x,nil) simplifyVMForm cancelScopeLeave! spliceSeq! packWhen! inlineLocals! groupTranscients! cancelScopeLeave! removeJunk! reduceXLAM! x |