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
2adde4a4
Commit
2adde4a4
authored
Aug 30, 2015
by
Laszlo Domoszlai
Browse files
remove unnecessary conditions in thunk creation
parent
a9f0c3a6
Changes
4
Hide whitespace changes
Inline
Side-by-side
interpreter/code.c
View file @
2adde4a4
...
...
@@ -27,7 +27,7 @@ struct Thunk* create_thunk(Code* expr, int frame_ptr)
get_slice
(
basethunk
->
desc
->
type
==
FT_SLICE
?
((
SliceEntry
*
)
basethunk
->
desc
)
->
forward_ptr
:
basethunk
->
desc
,
basethunk
->
desc
->
arity
+
expr
->
nr_args
);
Thunk
*
thunk
=
upd
ateF
(
NULL
,
slice
);
Thunk
*
thunk
=
cre
ateF
(
slice
);
assert
(
thunk
->
desc
->
arity
==
basethunk
->
desc
->
arity
+
expr
->
nr_args
);
...
...
@@ -44,7 +44,7 @@ struct Thunk* create_thunk(Code* expr, int frame_ptr)
}
else
{
Thunk
*
thunk
=
upd
ateF
(
NULL
,
get_slice
(
var
->
f
,
expr
->
nr_args
));
Thunk
*
thunk
=
cre
ateF
(
get_slice
(
var
->
f
,
expr
->
nr_args
));
assert
(
thunk
->
desc
->
arity
==
expr
->
nr_args
);
...
...
@@ -57,12 +57,12 @@ struct Thunk* create_thunk(Code* expr, int frame_ptr)
}
case
CT_VAR
:
if
(
expr
->
local_type
==
VAR_LOCAL
)
{
return
forward_to
(
NULL
,
local
(
frame_ptr
,
((
VarEntry
*
)
expr
)
->
index
)
)
;
return
local
(
frame_ptr
,
((
VarEntry
*
)
expr
)
->
index
);
}
else
{
return
upd
ateF
(
NULL
,
get_slice
(((
VarEntry
*
)
expr
)
->
f
,
0
));
return
cre
ateF
(
get_slice
(((
VarEntry
*
)
expr
)
->
f
,
0
));
}
case
CT_LIT
:
return
upd
ateT
(
NULL
,
&
((
LitEntry
*
)
expr
)
->
thunk
);
return
cre
ateT
(
&
((
LitEntry
*
)
expr
)
->
thunk
);
}
}
...
...
interpreter/debug.h
View file @
2adde4a4
#ifndef DEBUG_H
#define DEBUG_H
// Adjoxo: 2200
//#define DEBUG
#define BENCHMARK
//
#define BENCHMARK
#ifndef DEBUG
#define NDEBUG
...
...
interpreter/thunk.c
View file @
2adde4a4
...
...
@@ -113,6 +113,20 @@ struct Thunk* updateF(Thunk* target, Desc* f) {
return
thunk
;
}
struct
Thunk
*
createF
(
Desc
*
f
)
{
assert
(
f
!=
NULL
);
Thunk
*
thunk
=
(
Thunk
*
)
alloc_heap
(
max
(
sizeof
(
Thunk
),
sizeof
(
Desc
*
)
+
sizeof
(
Thunk
*
)
*
f
->
arity
));
thunk
->
desc
=
f
;
return
thunk
;
}
struct
Thunk
*
createT
(
Thunk
*
source
)
{
Thunk
*
target
=
(
Thunk
*
)
alloc_heap
(
sizeof
(
Thunk
));
memcpy
(
target
,
source
,
sizeof
(
Thunk
));
return
target
;
}
bool
is_hnf
(
Thunk
*
thunk
)
{
return
!
(
thunk
->
desc
->
type
==
FT_FUN
||
thunk
->
desc
->
type
==
FT_PRIM
);
...
...
interpreter/thunk.h
View file @
2adde4a4
...
...
@@ -46,6 +46,9 @@ struct Thunk* updateB(Thunk* target, int b);
struct
Thunk
*
updateT
(
Thunk
*
target
,
Thunk
*
source
);
struct
Thunk
*
updateF
(
Thunk
*
target
,
Desc
*
f
);
struct
Thunk
*
createT
(
Thunk
*
source
);
struct
Thunk
*
createF
(
Desc
*
f
);
bool
is_hnf
(
Thunk
*
thunk
);
struct
Thunk
*
eval
(
Thunk
*
thunk
);
...
...
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