aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog13
-rw-r--r--src/interp/c-util.boot31
-rw-r--r--src/interp/define.boot2
3 files changed, 30 insertions, 16 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index f033da2f..cc069516 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,16 @@
+2011-11-30 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * interp/c-util.boot (clearReplacement): Clear redex replacement.
+ (registerRedexForm): New.
+ (redexForm): Likewise.
+ (inlineDirectCall): Inline functions with known redex forms.
+ (foldExportedFunctionReferences): Compute redex forms.
+ (backendCompileILAM): Remove as unused.
+ (backendCompile2): Adjust.
+ (massageBackendCode): Likeiwse.
+ * interp/define.boot (compDefineCapsuleFunction): Clear
+ replacement info.
+
2011-11-29 Gabriel Dos Reis <gdr@cs.tamu.edu>
* boot/tokens.boot (absKind, absParms, absBody): New selectors.
diff --git a/src/interp/c-util.boot b/src/interp/c-util.boot
index 5cd74206..093d46e8 100644
--- a/src/interp/c-util.boot
+++ b/src/interp/c-util.boot
@@ -1281,11 +1281,21 @@ getFunctionReplacement name ==
++ remove any replacement info possibly associated with `name'.
clearReplacement name ==
property(name,"SPADreplace") := nil
+ property(name,'%redex) := nil
++ Register the inlinable form of a function.
registerFunctionReplacement(name,body) ==
LAM_,EVALANDFILEACTQ ["PUT",MKQ name,MKQ "SPADreplace",quoteMinimally body]
+++ Remember the redex form of this function
+registerRedexForm(name,parms,body) ==
+ LAM_,EVALANDFILEACTQ
+ ["PUT",quote name,quote '%redex,quote ['ILAM,parms,body]]
+
+++ Retrieve the redex form of the function `name'.
+redexForm name ==
+ property(name,'%redex)
+
++ Attempt to resolve the indirect reference to a constant form
++ `[spadConstant,$,n]' to a simpler expression
resolveConstantForm form ==
@@ -1304,6 +1314,7 @@ mutateArgumentList(args,fun) ==
args
inlineDirectCall call ==
+ x := redexForm call.op => doInlineCall(call.args,x.absParms,x.absBody)
fun := getFunctionReplacement call.op or return call
-- the renaming case
symbol? fun =>
@@ -1410,12 +1421,15 @@ expandableDefinition?(vars,body) ==
foldExportedFunctionReferences defs ==
for fun in defs repeat
fun isnt [name,lamex] => nil
+ getFunctionReplacement name => nil
lamex isnt ["LAM",vars,body] => nil
body := replaceSimpleFunctions body
form := expandableDefinition?(vars,body) =>
registerFunctionReplacement(name,form)
- fun.rest.first := ["LAM",vars,["DECLARE",["IGNORE",last vars]],body]
- lamex.rest.rest.first := body
+ second(fun) := ["LAM",vars,["DECLARE",["IGNORE",last vars]],body]
+ if sideEffectFree? body then
+ registerRedexForm(name,vars,body)
+ lamex.absBody := body
defs
++ record optimizations permitted at level `level'.
@@ -1469,15 +1483,6 @@ proclaimCapsuleFunction(op,sig) ==
d
[first d, :[normalize(first args,false) for args in tails rest d]]
-++ Lisp back end compiler for ILAM with `name', formal `args', and `body'.
-backendCompileILAM: (%Symbol,%List %Symbol, %Code) -> %Symbol
-backendCompileILAM(name,args,body) ==
- args' := [gensym() for . in 1..#args]
- body' := applySubst!(pairList(args,args'),body)
- property(name,'ILAM) := true
- symbolValue(name) := ["LAMBDA",args',:body']
- name
-
$CLOSEDFNS := nil
MAKE_-CLOSEDFN_-NAME() ==
@@ -1575,7 +1580,6 @@ backendCompile2 code ==
type = "SLAM" => backendCompileSLAM(name,args,body)
symbolTarget(name,$clamList) => compClam(name,args,body,$clamList)
type = "SPADSLAM" => backendCompileSPADSLAM(name,args,body)
- type = "ILAM" => backendCompileILAM(name,args,body)
body := [name,[type,args,:body]]
if $PrettyPrint then PRETTYPRINT body
if not $COMPILE then SAY '"No Compilation"
@@ -1644,9 +1648,6 @@ massageBackendCode x ==
-- special variable.
u is 'SETQ and isLispSpecialVariable second x =>
noteSpecialVariable second x
- ident? u and property(u,"ILAM") ~= nil =>
- x.first := eval u
- massageBackendCode x
u in '(LET LET_*) =>
oldVars := $LocalVars
vars := nil
diff --git a/src/interp/define.boot b/src/interp/define.boot
index 44ace682..c79d4d16 100644
--- a/src/interp/define.boot
+++ b/src/interp/define.boot
@@ -1904,6 +1904,7 @@ compDefineCapsuleFunction(db,df is ['DEF,form,signature,body],
-- Let the backend know about this function's type
if $optProclaim then
proclaimCapsuleFunction(op',signature)
+ clearReplacement op' -- Make sure we have fresh info
-- Finally, build a lambda expression for this function.
fun :=
catchTag := MKQ gensym()
@@ -2031,7 +2032,6 @@ spadCompileOrSetq(db,form is [nam,[lam,vl,body]]) ==
renameParameter() ==
integer? v or ident? v or string? v => v
gensym '"flag"
- clearReplacement nam -- Make sure we have fresh info
if $optReplaceSimpleFunctions then
body := replaceSimpleFunctions body