1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 14:00:21 +02:00

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.
This commit is contained in:
Andy Wingo 2008-08-08 17:05:41 +02:00
parent e15f47740b
commit 29711eb918
3 changed files with 9 additions and 6 deletions

View file

@ -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)

View file

@ -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;

View file

@ -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 ();