* 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.
(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)
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;
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 ();