From 05e0d43a6021eefccbf2ba0f68c1d72089a102b1 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Sun, 10 May 2009 14:25:56 +0000 Subject: * interp/g-opt.boot (emitIndirectCall): New. (optCall): Use it. (optSpecialCall): Likewise. (optSPADCALL): Tidy. --- src/interp/g-opt.boot | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'src/interp') diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot index e78ceb7a..dd8c04e0 100644 --- a/src/interp/g-opt.boot +++ b/src/interp/g-opt.boot @@ -39,6 +39,22 @@ namespace BOOT $optimizableConstructorNames := $SystemInlinableConstructorNames +--% + +++ return the template of the instantiating functor for +++ the domain form `dom'. +getDomainTemplate dom == + atom dom => nil + getInfovec first dom + +++ Emit code for an indirect call to domain-wide Spad function. +++ This is usually the case for exported functions. +emitIndirectCall(fn,args,x) == + rplac(first x, "SPADCALL") + rplac(first fn,"getShellEntry") + rplac(rest x, [:args,fn]) + x + --% OPTIMIZER optimizeFunctionDef(def) == @@ -133,10 +149,8 @@ optCatch (x is ["CATCH",g,a]) == optSPADCALL(form is ['SPADCALL,:argl]) == null $InteractiveMode => form -- last arg is function/env, but may be a form - argl is [:argl,fun] => - fun is ['ELT,dom,slot] => - optCall ['call,['ELT,dom,slot],:argl] - form + argl is [:argl,fun] and fun is ["ELT",dom,slot] => + optCall ['call,['ELT,dom,slot],:argl] form optCall (x is ["call",:u]) == @@ -150,14 +164,8 @@ optCall (x is ["call",:u]) == (RPLAC(first x,"SPADCALL"); RPLAC(rest x,[:a,name]); x) fn is [q,R,n] and MEMQ(q,'(getShellEntry ELT QREFELT CONST)) => not $bootStrapMode and (w:= optCallSpecially(q,x,n,R)) => w - q="CONST" => ---+ - ["spadConstant",R,n] - --putInLocalDomainReferences will change this to ELT or QREFELT - RPLAC(first x,"SPADCALL") - RPLACA(fn,"getShellEntry") - RPLAC(rest x,[:a,fn]) - x + q="CONST" => ["spadConstant",R,n] + emitIndirectCall(fn,a,x) systemErrorHere ["optCall",x] optCallSpecially(q,x,n,R) == @@ -211,10 +219,7 @@ optSpecialCall(x,y,n) == --DEF-EQUAL is really an optimiser x [fn,:a]:= first x - RPLAC(first x,"SPADCALL") - RPLACA(fn,"getShellEntry") - RPLAC(rest x,[:a,fn]) - x + emitIndirectCall(fn,a,x) compileTimeBindingOf u == NULL(name:= BPINAME u) => keyedSystemError("S2OO0001",[u]) -- cgit v1.2.3