summaryrefslogtreecommitdiff
path: root/libguile
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2009-02-01 09:19:24 +0100
committerAndy Wingo <wingo@pobox.com>2009-02-01 09:19:24 +0100
commit9aeaabdc4571b5a2319c88e02904bd8996d5ac01 (patch)
treeebc106e1e56e3a34fa6049b9f2bfbb69661d782e /libguile
parentd2d7acd5c11c6573dad62b0a77ace7bb6603e425 (diff)
downloadguile-9aeaabdc4571b5a2319c88e02904bd8996d5ac01.tar.gz
add metalen field to bytecode serialization
* libguile/objcodes.h (struct scm_objcode): Add a new field, metalen, in preparation for embedding metadata within a program. (SCM_OBJCODE_META_LEN, SCM_OBJCODE_TOTAL_LEN): New defines. * libguile/vm.c (really_make_boot_program): * module/language/assembly.scm (*program-header-len*, byte-length): * module/language/assembly/compile-bytecode.scm (write-bytecode): * module/language/assembly/decompile-bytecode.scm (decode-load-program): * module/language/assembly/disassemble.scm (disassemble-load-program): * module/language/glil/compile-assembly.scm (glil->assembly): * test-suite/tests/asm-to-bytecode.test ("compiler"): Update for metalen addition.
Diffstat (limited to 'libguile')
-rw-r--r--libguile/objcodes.h4
-rw-r--r--libguile/vm.c5
2 files changed, 7 insertions, 2 deletions
diff --git a/libguile/objcodes.h b/libguile/objcodes.h
index 6b3c2aec9..7480a03c1 100644
--- a/libguile/objcodes.h
+++ b/libguile/objcodes.h
@@ -51,6 +51,8 @@ struct scm_objcode {
scm_t_uint8 nlocs;
scm_t_uint8 nexts;
scm_t_uint32 len; /* the maximum index of base[] */
+ scm_t_uint32 metalen; /* well, i lie. this many bytes at the end of
+ base[] for metadata */
scm_t_uint8 base[0];
};
@@ -65,6 +67,8 @@ extern scm_t_bits scm_tc16_objcode;
#define SCM_VALIDATE_OBJCODE(p,x) SCM_MAKE_VALIDATE (p, x, OBJCODE_P)
#define SCM_OBJCODE_LEN(x) (SCM_OBJCODE_DATA (x)->len)
+#define SCM_OBJCODE_META_LEN(x) (SCM_OBJCODE_DATA (x)->metalen)
+#define SCM_OBJCODE_TOTAL_LEN(x) (SCM_OBJCODE_LEN (x) + SCM_OBJCODE_META_LEN (x))
#define SCM_OBJCODE_NARGS(x) (SCM_OBJCODE_DATA (x)->nargs)
#define SCM_OBJCODE_NREST(x) (SCM_OBJCODE_DATA (x)->nrest)
#define SCM_OBJCODE_NLOCS(x) (SCM_OBJCODE_DATA (x)->nlocs)
diff --git a/libguile/vm.c b/libguile/vm.c
index 9e5e9dbe6..ffb14384e 100644
--- a/libguile/vm.c
+++ b/libguile/vm.c
@@ -272,11 +272,12 @@ really_make_boot_program (long nargs)
{
scm_byte_t bytes[] = {0, 0, 0, 0,
0, 0, 0, 0,
+ 0, 0, 0, 0,
scm_op_mv_call, 0, 0, 1, scm_op_make_int8_1, scm_op_halt};
- ((scm_t_uint32*)bytes)[1] = 6; /* set len in current endianness */
+ ((scm_t_uint32*)bytes)[1] = 6; /* set len in current endianness, no meta */
if (SCM_UNLIKELY (nargs > 255 || nargs < 0))
abort ();
- bytes[9] = (scm_byte_t)nargs;
+ bytes[13] = (scm_byte_t)nargs;
return scm_make_program (scm_bytecode_to_objcode (make_u8vector (bytes, sizeof(bytes))),
SCM_BOOL_F, SCM_EOL);
}