summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2009-01-31 21:54:59 +0100
committerAndy Wingo <wingo@pobox.com>2009-01-31 21:54:59 +0100
commitd2d7acd5c11c6573dad62b0a77ace7bb6603e425 (patch)
tree4fb9b186136353f788c77752080cc2e3fe635740
parent9bb8012dd63869682edf2af5f708430646eabef5 (diff)
downloadguile-d2d7acd5c11c6573dad62b0a77ace7bb6603e425.tar.gz
cache 8 boot programs
* libguile/vm.c (vm_make_boot_program): Cache boot programs for nargs < 8.
-rw-r--r--libguile/vm.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/libguile/vm.c b/libguile/vm.c
index 8ca2ada6e..9e5e9dbe6 100644
--- a/libguile/vm.c
+++ b/libguile/vm.c
@@ -268,7 +268,7 @@ static SCM make_u8vector (const scm_t_uint8 *bytes, size_t len)
}
static SCM
-vm_make_boot_program (long nargs)
+really_make_boot_program (long nargs)
{
scm_byte_t bytes[] = {0, 0, 0, 0,
0, 0, 0, 0,
@@ -280,6 +280,24 @@ vm_make_boot_program (long nargs)
return scm_make_program (scm_bytecode_to_objcode (make_u8vector (bytes, sizeof(bytes))),
SCM_BOOL_F, SCM_EOL);
}
+#define NUM_BOOT_PROGS 8
+static SCM
+vm_make_boot_program (long nargs)
+{
+ static SCM programs[NUM_BOOT_PROGS] = { 0, };
+
+ if (SCM_UNLIKELY (!programs[0]))
+ {
+ int i;
+ for (i = 0; i < NUM_BOOT_PROGS; i++)
+ programs[i] = scm_permanent_object (really_make_boot_program (i));
+ }
+
+ if (SCM_LIKELY (nargs < NUM_BOOT_PROGS))
+ return programs[nargs];
+ else
+ return really_make_boot_program (nargs);
+}
/*