diff options
author | Andy Wingo <wingo@pobox.com> | 2008-08-08 17:05:41 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2008-08-08 17:05:41 +0200 |
commit | 29711eb918794ea47999928c0817be6d1be6247f (patch) | |
tree | a6b2c29afd9f1ca1ec5d940e090a2e054aca5191 | |
parent | e15f47740b754276960c7b8cc38da14ae0ac9a83 (diff) |
heapify the bootstrap program
* src/vm_engine.c (vm_run):
* src/programs.c (scm_c_make_program): If the holder is #f, malloc *and*
copy the bytecode.
* module/system/vm/frame.scm (bootstrap-frame?): Now that we actually
heapify the bootstrap program, we can check for `halt' in the bytecode.
-rw-r--r-- | module/system/vm/frame.scm | 5 | ||||
-rw-r--r-- | src/programs.c | 7 | ||||
-rw-r--r-- | src/vm_engine.c | 3 |
3 files changed, 9 insertions, 6 deletions
diff --git a/module/system/vm/frame.scm b/module/system/vm/frame.scm index f827930eb..3c45e8961 100644 --- a/module/system/vm/frame.scm +++ b/module/system/vm/frame.scm @@ -45,8 +45,9 @@ (define (bootstrap-frame? frame) (let ((code (program-bytecode (frame-program frame)))) - ;; XXX: need to fix the bootstrap prog, its code is on the C stack - (and (= (uniform-vector-length code) 3)))) + (and (= (uniform-vector-length code) 3) + (= (uniform-vector-ref code 2) + (instruction->opcode 'halt))))) (define (make-frame-chain frame addr) (define (make-rest) diff --git a/src/programs.c b/src/programs.c index 9f0bde738..dfe6c3faa 100644 --- a/src/programs.c +++ b/src/programs.c @@ -71,8 +71,11 @@ scm_c_make_program (void *addr, size_t size, SCM holder) p->holder = holder; /* If nobody holds bytecode's address, then allocate a new memory */ - if (SCM_FALSEP (holder)) - p->base = scm_gc_malloc (size, "program-base"); + if (SCM_FALSEP (holder)) + { + p->base = scm_gc_malloc (size, "program-base"); + memcpy (p->base, addr, size); + } else p->base = addr; diff --git a/src/vm_engine.c b/src/vm_engine.c index a7f58b8e3..1b568eb0a 100644 --- a/src/vm_engine.c +++ b/src/vm_engine.c @@ -100,10 +100,9 @@ vm_run (SCM vm, SCM program, SCM args) SCM prog = program; /* Boot program */ - /* FIXME: heap program object points to objcode on the stack. Badness! */ scm_byte_t bytes[3] = {scm_op_call, 0, scm_op_halt}; bytes[1] = scm_ilength (args); /* FIXME: argument overflow */ - program = scm_c_make_program (bytes, 3, SCM_BOOL_T); + program = scm_c_make_program (bytes, 3, SCM_BOOL_F); /* Initial frame */ CACHE_REGISTER (); |