Use only one comparison in closcall macros

This improves performance a bit since these macros are called after almost every C function.
This commit is contained in:
Justin Ethier 2016-07-04 22:42:35 -04:00
parent 84ecf2ac22
commit 199b685de3
3 changed files with 6 additions and 3 deletions

View file

@ -90,6 +90,9 @@ enum object_tag {
, vector_tag // 19
};
#define type_is_pair_prim(clo) \
(type_of(clo) >= pair_tag)
// Define the size of object tags
typedef unsigned char tag_type;

View file

@ -79,7 +79,7 @@ void Cyc_check_bounds(void *data, const char *label, int len, int index)
/* These macros are hardcoded here to support functions in this module. */
#define closcall1(td, clo, a1) \
if (type_of(clo) == pair_tag || prim(clo)) { \
if (type_is_pair_prim(clo)) { \
Cyc_apply(td, 0, (closure)(a1), clo); \
} else { \
((clo)->fn)(td, 1, clo, a1);\
@ -96,7 +96,7 @@ if (type_of(clo) == pair_tag || prim(clo)) { \
} \
}
#define closcall2(td, clo, a1, a2) \
if (type_of(clo) == pair_tag || prim(clo)) { \
if (type_is_pair_prim(clo)) { \
Cyc_apply(td, 1, (closure)(a1), clo,a2); \
} else { \
((clo)->fn)(td, 2, clo, a1, a2);\

View file

@ -160,7 +160,7 @@
(wrap (lambda (s) (if (> num-args 0) s ""))))
(string-append
"#define closcall" n "(td, clo" args ") \\\n"
(wrap (string-append "if (type_of(clo) == pair_tag || prim(clo)) { \\\n"
(wrap (string-append "if (type_is_pair_prim(clo)) { \\\n"
" Cyc_apply(td, " n-1 ", (closure)(a1), clo" (if (> num-args 1) (substring args 3 (string-length args)) "") "); \\\n"
"}"))
(wrap " else { \\\n")