Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-and-itasks
sapl-interpreter
Commits
31b4810d
Commit
31b4810d
authored
Jan 11, 2016
by
Laszlo Domoszlai
Browse files
stub for general tail call optimization
parent
659d419d
Changes
5
Hide whitespace changes
Inline
Side-by-side
interpreter/Makefile
View file @
31b4810d
TARGET
=
main
LIBS
=
CC
=
clang++
CFLAGS
=
-
O3
-x
c++
-Wno-write-strings
# -g -pg -fstack-usage
CFLAGS
=
-
g
-x
c++
-Wno-write-strings
# -g -pg -fstack-usage
.PHONY
:
default all clean
...
...
@@ -17,7 +17,7 @@ HEADERS = $(wildcard *.h)
.PRECIOUS
:
$(TARGET) $(OBJECTS)
$(TARGET)
:
$(OBJECTS)
$(CC)
$(OBJECTS)
-static
-static-libgcc
-static-libstdc
++
-Wl
,--stack,16777216
-Wall
$(LIBS)
-o
$@
# -pg -g
$(CC)
$(OBJECTS)
-static
-static-libgcc
-static-libstdc
++
-Wl
,--stack,16777216
-Wall
-g
$(LIBS)
-o
$@
# -pg -g
clean
:
-
rm
-f
*
.o
...
...
interpreter/code.c
View file @
31b4810d
...
...
@@ -145,6 +145,13 @@ void set_create_thunk_fun(Code* code)
}
}
// eval: frame_ptr, frame_ptr
// start: stack_top_a, stack_top_a
// otherwise: frame_ptr, stack_top_a
// frame_ptr: first arguments
// root_frame_ptr: place of the result
void
exec
(
Code
*
expr
,
int
frame_ptr
,
int
root_frame_ptr
)
{
if
(
heap_curr
>
gc_trigger
)
gc
();
...
...
@@ -655,6 +662,7 @@ void eval_fun()
}
exec
(((
FunEntry
*
)
thunk
->
desc
)
->
body
,
frame_ptr
,
frame_ptr
);
//stack_a[frame_ptr] = stack_a[stack_top_a];
}
void
eval_prim
()
...
...
interpreter/main.c
View file @
31b4810d
...
...
@@ -29,7 +29,7 @@ int main ( int argc, char *argv[] )
init_desc
();
init_prim
();
char
*
input
=
"..
\\
tests
\\
Adjoxo
.bsapl"
;
char
*
input
=
"..
\\
tests
\\
queens2
.bsapl"
;
if
(
argc
==
2
)
{
...
...
interpreter/parse.c
View file @
31b4810d
...
...
@@ -632,6 +632,8 @@ Code* parseTerm(char **ptr) {
return
(
Code
*
)
parseApp
(
ptr
,
false
,
false
);
case
'T'
:
// Tail recursive application
return
(
Code
*
)
parseApp
(
ptr
,
false
,
true
);
case
't'
:
// Tail call application
return
(
Code
*
)
parseApp
(
ptr
,
false
,
true
);
case
'D'
:
// Dynamic application
return
(
Code
*
)
parseApp
(
ptr
,
true
,
false
);
case
'S'
:
// Select
...
...
precompiler/precompiler.icl
View file @
31b4810d
...
...
@@ -105,7 +105,8 @@ isLocalVar ctx var = member (unpackVar var) ctx.vars
appType
ctx
var
|
isLocalVar
ctx
var
=
"D"
appType
{
inspine
,
currentFun
}
var
=
if
(
inspine
&&
unpackVar
var
==
currentFun
)
"T"
"A"
// T: tail recursive
appType
{
inspine
=
True
,
currentFun
}
var
=
if
(
unpackVar
var
==
currentFun
)
"T"
"A"
// T: tail recursive / TODO: "t: tail call "
appType
_
_
=
"A"
// A: normal call
sLetDef
ctx
(
SaplLetDef
var
binding
)
a
=
a
<++
sVarFlag
ctx
(
Local
0
(
typeInfo
var
))
<++
sTerm
ctx
binding
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment