2012-12-12 17:37:44 +01:00
|
|
|
|
/* Copyright (C) 2001, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
|
2000-08-22 15:54:19 +00:00
|
|
|
|
*
|
2009-05-26 22:23:44 +02:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
|
|
* as published by the Free Software Foundation; either version 3 of
|
|
|
|
|
|
* the License, or (at your option) any later version.
|
2000-08-22 15:54:19 +00:00
|
|
|
|
*
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* This library is distributed in the hope that it will be useful, but
|
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
2009-05-26 22:23:44 +02:00
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
* Lesser General Public License for more details.
|
2000-08-22 15:54:19 +00:00
|
|
|
|
*
|
2009-05-26 22:23:44 +02:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
|
|
* 02110-1301 USA
|
2009-05-26 22:23:44 +02:00
|
|
|
|
*/
|
2000-08-22 15:54:19 +00:00
|
|
|
|
|
2008-05-20 11:46:52 +02:00
|
|
|
|
#if HAVE_CONFIG_H
|
|
|
|
|
|
# include <config.h>
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2009-04-05 20:15:11 +02:00
|
|
|
|
#include <stdlib.h>
|
enable multiple vm engines (regular, debug, ...)
* libguile/vm-engine.c (VM_USE_HOOKS, VM_USE_CLOCK, VM_CHECK_EXTERNAL)
(VM_CHECK_OBJECT): Update to define these here, before including
vm-engine.h.
(vm_run): Change so that we can make different engines. Also, we take
an array of arguments, and the struct scm_vm directly, so as to avoid
any need to cons.
* libguile/vm-engine.h (CHECK_EXTERNAL, CHECK_OBJECT): Add some UNLIKELY
bits; don't seem to help.
* libguile/vm.c (vm_dispatch_hook): Change to not pass the VP. This needs
some love, and perhaps we revert to the old way.
(VM_ENGINE): Actually make two engines, vm_regular_engine and
vm_debug_engine. Probably there is room for improvement here. Actually
their speeds are the same at the moment.
(make_vm): Choose which engine to run; currently the debug engine by
default.
(scm_c_vm_run): A thin wrapper to invoke a VM without consing.
(scm_vm_apply): Use scm_c_vm_run.
(scm_load_compiled_with_vm): Use scm_c_vm_run.
2009-02-04 23:47:56 +01:00
|
|
|
|
#include <alloca.h>
|
2010-06-01 00:40:00 +02:00
|
|
|
|
#include <alignof.h>
|
2001-04-01 05:03:41 +00:00
|
|
|
|
#include <string.h>
|
2010-10-13 01:31:19 +02:00
|
|
|
|
#include <stdint.h>
|
2009-08-20 01:56:47 +02:00
|
|
|
|
|
2009-09-13 15:59:31 +02:00
|
|
|
|
#include "libguile/bdw-gc.h"
|
2009-08-20 01:56:47 +02:00
|
|
|
|
#include <gc/gc_mark.h>
|
|
|
|
|
|
|
2009-05-26 22:23:44 +02:00
|
|
|
|
#include "_scm.h"
|
2010-02-02 22:59:55 +01:00
|
|
|
|
#include "control.h"
|
2001-04-22 02:13:48 +00:00
|
|
|
|
#include "frames.h"
|
2001-04-01 05:03:41 +00:00
|
|
|
|
#include "instructions.h"
|
2001-04-16 03:43:48 +00:00
|
|
|
|
#include "objcodes.h"
|
2001-04-22 02:13:48 +00:00
|
|
|
|
#include "programs.h"
|
2000-08-22 15:54:19 +00:00
|
|
|
|
#include "vm.h"
|
|
|
|
|
|
|
2012-12-12 17:37:44 +01:00
|
|
|
|
#include "private-gc.h" /* scm_getenv_int */
|
|
|
|
|
|
|
2010-09-28 09:22:38 +02:00
|
|
|
|
static int vm_default_engine = SCM_VM_REGULAR_ENGINE;
|
2010-09-27 21:06:24 +02:00
|
|
|
|
|
|
|
|
|
|
/* Unfortunately we can't snarf these: snarfed things are only loaded up from
|
|
|
|
|
|
(system vm vm), which might not be loaded before an error happens. */
|
|
|
|
|
|
static SCM sym_vm_run;
|
|
|
|
|
|
static SCM sym_vm_error;
|
|
|
|
|
|
static SCM sym_keyword_argument_error;
|
|
|
|
|
|
static SCM sym_regular;
|
|
|
|
|
|
static SCM sym_debug;
|
2000-08-22 15:54:19 +00:00
|
|
|
|
|
precise stack marking, fix some missed references, still imperfect
* libguile/vm-engine.h (CHECK_STACK_LEAK, NULLSTACK): Add a new mode,
VM_ENABLE_STACK_NULLING, that tries to ensure that all stack data past
the top of the stack is NULL. This helps to verify the VM's
consistency. If VM_ENABLE_STACK_NULLING is not defined, there is no
overhead.
(DROP, DROPN): Hook into NULLSTACK.
(POP_LIST): Hoo, fix a good bug: if CONS triggered a GC, the elements
of the list that had not yet been consed would not be marked, because
the sp was already below them.
(NEXT): Hook into CHECK_STACK_LEAK.
(INIT_ARGS): Add a note that consing the rest arg can cause GC.
(NEW_FRAME): Cons up the external data after initializing the frame, so
that if GC is triggered, the precise marker sees a well-formed frame.
* libguile/vm-i-loader.c (load-program): In the four-integers case, use
the POP macro so that we can hook into NULLSTACK (if necessary).
* libguile/vm-i-scheme.c (ARGS2, ARGS3): Hook into NULLSTACK.
* libguile/vm-i-system.c (halt): Null the nvalues. Rework some asserts
into using ASSERT, and null the stack when we free the frame.
(variable-set): Use DROPN instead of sp -= 2.
(BR): Hook into NULLSTACK.
(goto/args): Hook into NULLSTACK. In the non-self case, delay updating
the frame until after INIT_ARGS so that GC sees a well-formed frame.
Delay consing the externals until after the frame is set up, as in
NEW_FRAME.
(call/cc): Add some asserts.
(return): Rework some asserts into ASSERT, and hook into NULLSTACK.
(return/values): Hook into NULLSTACK, and use ASSERT.
(return/values*) Use ASSERT.
* libguile/vm.c (VM_ENABLE_ASSERTIONS, VM_ENABLE_STACK_NULLING): These
are the variables that control assertions and nulling. Perhaps we can
do these per-engine when we start compiling the debug engine separate
from a speedy engine.
(vm_mark_stack): Add a precise stack marker. Yay!
(vm_cont_mark): Mark the continuation stack precisely.
(capture_vm_cont): Record the difference from the vp's stack_base too,
so that we can translate the dynamic links when marking the
continuation stack. Memset the stack to NULL if we are doing nulling.
(reinstate_vm_cont): If we are nulling, null out the relevant part
of the stack.
(vm_reset_stack): When resetting sp due to a nonlocal exit, null out
the stack too.
(vm_mark): If we are nulling, assert that there are no extra values on
the stack. Mark the stack precisely.
2008-10-03 16:00:30 +02:00
|
|
|
|
/* The VM has a number of internal assertions that shouldn't normally be
|
|
|
|
|
|
necessary, but might be if you think you found a bug in the VM. */
|
|
|
|
|
|
#define VM_ENABLE_ASSERTIONS
|
|
|
|
|
|
|
|
|
|
|
|
/* We can add a mode that ensures that all stack items above the stack pointer
|
|
|
|
|
|
are NULL. This is useful for checking the internal consistency of the VM's
|
|
|
|
|
|
assumptions and its operators, but isn't necessary for normal operation. It
|
2009-01-12 22:37:29 +01:00
|
|
|
|
will ensure that assertions are enabled. Slows down the VM by about 30%. */
|
2009-02-04 00:09:38 +01:00
|
|
|
|
/* NB! If you enable this, search for NULLING in throw.c */
|
2009-01-12 22:37:29 +01:00
|
|
|
|
/* #define VM_ENABLE_STACK_NULLING */
|
precise stack marking, fix some missed references, still imperfect
* libguile/vm-engine.h (CHECK_STACK_LEAK, NULLSTACK): Add a new mode,
VM_ENABLE_STACK_NULLING, that tries to ensure that all stack data past
the top of the stack is NULL. This helps to verify the VM's
consistency. If VM_ENABLE_STACK_NULLING is not defined, there is no
overhead.
(DROP, DROPN): Hook into NULLSTACK.
(POP_LIST): Hoo, fix a good bug: if CONS triggered a GC, the elements
of the list that had not yet been consed would not be marked, because
the sp was already below them.
(NEXT): Hook into CHECK_STACK_LEAK.
(INIT_ARGS): Add a note that consing the rest arg can cause GC.
(NEW_FRAME): Cons up the external data after initializing the frame, so
that if GC is triggered, the precise marker sees a well-formed frame.
* libguile/vm-i-loader.c (load-program): In the four-integers case, use
the POP macro so that we can hook into NULLSTACK (if necessary).
* libguile/vm-i-scheme.c (ARGS2, ARGS3): Hook into NULLSTACK.
* libguile/vm-i-system.c (halt): Null the nvalues. Rework some asserts
into using ASSERT, and null the stack when we free the frame.
(variable-set): Use DROPN instead of sp -= 2.
(BR): Hook into NULLSTACK.
(goto/args): Hook into NULLSTACK. In the non-self case, delay updating
the frame until after INIT_ARGS so that GC sees a well-formed frame.
Delay consing the externals until after the frame is set up, as in
NEW_FRAME.
(call/cc): Add some asserts.
(return): Rework some asserts into ASSERT, and hook into NULLSTACK.
(return/values): Hook into NULLSTACK, and use ASSERT.
(return/values*) Use ASSERT.
* libguile/vm.c (VM_ENABLE_ASSERTIONS, VM_ENABLE_STACK_NULLING): These
are the variables that control assertions and nulling. Perhaps we can
do these per-engine when we start compiling the debug engine separate
from a speedy engine.
(vm_mark_stack): Add a precise stack marker. Yay!
(vm_cont_mark): Mark the continuation stack precisely.
(capture_vm_cont): Record the difference from the vp's stack_base too,
so that we can translate the dynamic links when marking the
continuation stack. Memset the stack to NULL if we are doing nulling.
(reinstate_vm_cont): If we are nulling, null out the relevant part
of the stack.
(vm_reset_stack): When resetting sp due to a nonlocal exit, null out
the stack too.
(vm_mark): If we are nulling, assert that there are no extra values on
the stack. Mark the stack precisely.
2008-10-03 16:00:30 +02:00
|
|
|
|
|
static opcodes; refactor program/objcode division; use new assembly pipeline
* gdbinit: Untested attempts to get the stack fondling macros to deal
with the new program representation.
* libguile/frames.c (scm_vm_frame_arguments, scm_vm_frame_source)
(scm_vm_frame_local_ref, scm_vm_frame_local_set_x): SCM_PROGRAM_DATA is
a struct scm_objcode*.
* libguile/instructions.h:
* libguile/instructions.c: Hide the instruction table and the struct
scm_instruction structure; all access to instructions now goes through
procedures. This is because instructions are no longer in a packed
array indexed by opcode. Also, declare a mask that all instructions
should fit in.
* libguile/objcodes.h:
* libguile/objcodes.c: Rewrite so that object code directly maps its
arity and length from its bytecode. This makes it unnecessary to keep
this information in programs, allowing programs to be simple conses
between the code (objcodes) and data (the object table and the closure
variables).
* libguile/programs.c (scm_make_program): Rework so that make-program
takes objcode, an object table, and externals as arguments. It's much
clearer this way, and we avoid malloc().
* libguile/stacks.c (is_vm_bootstrap_frame): Update for program/objcode
changes.
* libguile/vm-engine.c (vm_run): Initialize the jump table on the first
run, with the opcodes declared in the instruction sources, and with bad
instructions raising an error instead of wandering off into the
Unknown.
* libguile/vm-engine.h (FETCH_LENGTH): Always represent lengths as 3
bytes. The old code was too error-prone.
(NEXT_JUMP): Mask the instruction with SCM_VM_INSTRUCTION_MASK.
(NEW_FRAME): Update for program/objcode changes.
* libguile/vm-expand.h (VM_DEFINE_FUNCTION, VM_DEFINE_INSTRUCTION)
(VM_DEFINE_LOADER): Update so that we explicitly specify opcodes, so
that we have a stable bytecode API.
* libguile/vm-i-loader.c: Update license to LGPLv2+. Explicitly declare
opcodes.
(load-integer): Use an int instead of a long as the accumulator; still
need to revisit this code at some point, I think.
(load-program): Simplify, thankfully!! Just creates the objcode slice
and rolls with it.
* libguile/vm-i-scheme.c: Number the opcodes explicitly.
* libguile/vm-i-system.c: Update license to LGPLv2+. Explicitly declare
opcodes.
(make-closure): Update for new program API.
* libguile/vm.c (vm_make_boot_program): Update for new program/objcode
API. Still a bit ugly.
(scm_load_compiled_with_vm): Update for new program/objcode API.
* module/language/assembly.scm (byte-length): Fix byte-length calculation
for loaders, and load-program.
(code-pack, code-unpack): Start to move things from (system vm conv)
here.
(object->code, code->object): More things from conv.scm.
* module/language/glil.scm (<glil-program>): Add a new field,
closure-level.
(make-glil-program, compute-closure-level): Calculate the "closure
level" when making a glil program. This is the maximum depth of
external binding refs in this closure.
(unparse-glil): Fix label serialization.
* module/language/glil/compile-assembly.scm (make-meta): Prepend #f for
the meta's object table, though maybe in the future we can avoid
creating assembly in the first place.
(assoc-ref-or-acons, object-index-and-alist): GRRR! Caught again by the
different sets of arguments to assoc and assoc-ref!
(glil->assembly): Attempt to make the <glil-program> case more
readable, and fix the bugs. Sorry I don't know how to comment this
change any more than this.
(glil->assembly): For <glil-module> serialize the whole key, not just
the name.
(dump-object): subprogram-code is already a list. Serialize integers as
strings, not u8vectors. Fix the order of lists and vectors.
* module/language/glil/spec.scm (glil): Switch orders, so we prefer glil
-> assembly -> objcode. Actually glil->objcode doesn't work any more,
needs to be removed I think.
* module/language/objcode/spec.scm (objcode->value):
s/objcode->program/make-program/.
* module/language/scheme/inline.scm: Add acons inline.
* module/system/vm/conv.scm (make-byte-decoder): Skip the first 8 bytes,
they are header. Handle subprograms properly. Still needs help though.
(decode-length): Lengths are always 3 bytes now.
* module/system/vm/disasm.scm: Superficial changes to keep things
working. I'd like to fix this better in the future.
* module/system/vm/frame.scm (bootstrap-frame?): Fixes for
program-bytecode.
* module/system/vm/program.scm: Export make-program. It's program-objcode
now, no more program-bytecode.
* module/system/vm/vm.scm (vm-load): Use make-program.
* test-suite/tests/asm-to-bytecode.test: New test, very minimal.
* module/system/vm/objcode.scm: Export word-size, byte-order, and
write-objcode.
2009-01-29 21:09:04 +01:00
|
|
|
|
/* #define VM_ENABLE_PARANOID_ASSERTIONS */
|
|
|
|
|
|
|
precise stack marking, fix some missed references, still imperfect
* libguile/vm-engine.h (CHECK_STACK_LEAK, NULLSTACK): Add a new mode,
VM_ENABLE_STACK_NULLING, that tries to ensure that all stack data past
the top of the stack is NULL. This helps to verify the VM's
consistency. If VM_ENABLE_STACK_NULLING is not defined, there is no
overhead.
(DROP, DROPN): Hook into NULLSTACK.
(POP_LIST): Hoo, fix a good bug: if CONS triggered a GC, the elements
of the list that had not yet been consed would not be marked, because
the sp was already below them.
(NEXT): Hook into CHECK_STACK_LEAK.
(INIT_ARGS): Add a note that consing the rest arg can cause GC.
(NEW_FRAME): Cons up the external data after initializing the frame, so
that if GC is triggered, the precise marker sees a well-formed frame.
* libguile/vm-i-loader.c (load-program): In the four-integers case, use
the POP macro so that we can hook into NULLSTACK (if necessary).
* libguile/vm-i-scheme.c (ARGS2, ARGS3): Hook into NULLSTACK.
* libguile/vm-i-system.c (halt): Null the nvalues. Rework some asserts
into using ASSERT, and null the stack when we free the frame.
(variable-set): Use DROPN instead of sp -= 2.
(BR): Hook into NULLSTACK.
(goto/args): Hook into NULLSTACK. In the non-self case, delay updating
the frame until after INIT_ARGS so that GC sees a well-formed frame.
Delay consing the externals until after the frame is set up, as in
NEW_FRAME.
(call/cc): Add some asserts.
(return): Rework some asserts into ASSERT, and hook into NULLSTACK.
(return/values): Hook into NULLSTACK, and use ASSERT.
(return/values*) Use ASSERT.
* libguile/vm.c (VM_ENABLE_ASSERTIONS, VM_ENABLE_STACK_NULLING): These
are the variables that control assertions and nulling. Perhaps we can
do these per-engine when we start compiling the debug engine separate
from a speedy engine.
(vm_mark_stack): Add a precise stack marker. Yay!
(vm_cont_mark): Mark the continuation stack precisely.
(capture_vm_cont): Record the difference from the vp's stack_base too,
so that we can translate the dynamic links when marking the
continuation stack. Memset the stack to NULL if we are doing nulling.
(reinstate_vm_cont): If we are nulling, null out the relevant part
of the stack.
(vm_reset_stack): When resetting sp due to a nonlocal exit, null out
the stack too.
(vm_mark): If we are nulling, assert that there are no extra values on
the stack. Mark the stack precisely.
2008-10-03 16:00:30 +02:00
|
|
|
|
#if defined (VM_ENABLE_STACK_NULLING) && !defined (VM_ENABLE_ASSERTIONS)
|
|
|
|
|
|
#define VM_ENABLE_ASSERTIONS
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2009-08-20 01:56:47 +02:00
|
|
|
|
/* When defined, arrange so that the GC doesn't scan the VM stack beyond its
|
|
|
|
|
|
current SP. This should help avoid excess data retention. See
|
|
|
|
|
|
http://thread.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/3001
|
|
|
|
|
|
for a discussion. */
|
|
|
|
|
|
#define VM_ENABLE_PRECISE_STACK_GC_SCAN
|
|
|
|
|
|
|
2010-05-26 23:00:58 +02:00
|
|
|
|
/* Size in SCM objects of the stack reserve. The reserve is used to run
|
|
|
|
|
|
exception handling code in case of a VM stack overflow. */
|
|
|
|
|
|
#define VM_STACK_RESERVE_SIZE 512
|
|
|
|
|
|
|
2009-08-20 01:56:47 +02:00
|
|
|
|
|
2000-08-22 15:54:19 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* VM Continuation
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2010-01-05 19:45:56 +01:00
|
|
|
|
void
|
|
|
|
|
|
scm_i_vm_cont_print (SCM x, SCM port, scm_print_state *pstate)
|
|
|
|
|
|
{
|
2011-11-08 00:36:48 +01:00
|
|
|
|
scm_puts_unlocked ("#<vm-continuation ", port);
|
2010-01-05 19:45:56 +01:00
|
|
|
|
scm_uintprint (SCM_UNPACK (x), 16, port);
|
2011-11-08 00:36:48 +01:00
|
|
|
|
scm_puts_unlocked (">", port);
|
2010-01-05 19:45:56 +01:00
|
|
|
|
}
|
2001-04-01 05:03:41 +00:00
|
|
|
|
|
continuations return multiple values on the stack
* libguile/vm.h (struct scm_vm_cont): Instead of saving the "IP", save
"RA" and "MVRA". That is, save singly-valued and multiply-valued
return addresses, so that we can return multiple values on the stack.
(scm_i_vm_reinstate_continuation): Remove.
* libguile/vm.c (vm_capture_continuation): Rename from capture_vm_cont,
and change the prototype so we can capture the RA and MVRA, and so
that tail calls to call/cc can capture a continuation without the
call/cc application frame.
(vm_return_to_continuation): Rename from reinstate_vm_cont, and take
arguments to return to the continuation. Handles returning to single
or multiple-value RA.
(scm_i_vm_capture_continuation): Change to invoke
vm_capture_continuation. Kept around for the benefit of make-stack.
* libguile/vm-i-system.c (continuation-call): Handle reinstatement of
the VM stack, with arguments.
(call/cc, tail-call/cc): Adapt to new vm_capture_continuation
prototype. tail-call/cc captures tail continuations.
* libguile/stacks.c (scm_make_stack): Update for scm_vm_cont structure
change.
* libguile/continuations.h (struct scm_contregs): Remove throw_value
member, which was used to return a value to a continuation.
(scm_i_check_continuation): New internal function, checks that a
continuation may be reinstated.
(scm_i_reinstate_continuation): Replaces scm_i_continuation_call; just
reinstates the C stack.
(scm_i_contregs_vm, scm_i_contregs_vm_cont): New internal accessors.
* libguile/continuations.c (scm_i_make_continuation): Return
SCM_UNDEFINED if we are returning again.
(grow_stack, copy_stack_and_call, scm_dynthrow): Remove extra arg, as
vm opcodes handle value returns.
(copy_stack): No need to instate VM continuation.
(scm_i_reinstate_continuation): Adapt.
2010-02-08 22:59:25 +01:00
|
|
|
|
/* In theory, a number of vm instances can be active in the call trace, and we
|
|
|
|
|
|
only want to reify the continuations of those in the current continuation
|
|
|
|
|
|
root. I don't see a nice way to do this -- ideally it would involve dynwinds,
|
|
|
|
|
|
and previous values of the *the-vm* fluid within the current continuation
|
|
|
|
|
|
root. But we don't have access to continuation roots in the dynwind stack.
|
|
|
|
|
|
So, just punt for now, we just capture the continuation for the current VM.
|
|
|
|
|
|
|
|
|
|
|
|
While I'm on the topic, ideally we could avoid copying the C stack if the
|
|
|
|
|
|
continuation root is inside VM code, and call/cc was invoked within that same
|
|
|
|
|
|
call to vm_run; but that's currently not implemented.
|
|
|
|
|
|
*/
|
2010-02-22 23:00:19 +01:00
|
|
|
|
SCM
|
|
|
|
|
|
scm_i_vm_capture_stack (SCM *stack_base, SCM *fp, SCM *sp, scm_t_uint8 *ra,
|
the dynamic stack is really a stack now, instead of a list
* libguile/dynstack.h:
* libguile/dynstack.c: New files, implementing the dynamic stack as a
true stack instead of a linked list. This lowers the cost of
dynwinds: frames, winders, prompts, with-fluids, and dynamic-wind.
For the most part, we allocate these items directly on the stack.
* libguile/dynwinds.h:
* libguile/dynwinds.c: Adapt all manipulators of the wind stack to use
interfaces from dynstack.c. Remove heap-allocated winder and frame
object types.
(scm_dowinds, scm_i_dowinds): Remove these. The first was exported,
but it was not a public interface.
* libguile/continuations.c:
* libguile/continuations.h (scm_t_contregs): Continuation objects
reference scm_t_dynstack* values now. Adapt to the new interfaces.
* libguile/control.c:
* libguile/control.h: There is no longer a scm_tc7_prompt kind of object
that can be allocated on the heap. Instead, the prompt flags, key,
and registers are pushed on the dynwind stack. (The registers are
still on the heap.) Also, since the vm_cont will reference the
dynwinds, make the partial continuation stub take just one extra arg,
instead of storing the intwinds separately in the object table.
* libguile/fluids.c:
* libguile/fluids.h: No more with-fluids objects; instead, the fluids go
on the dynstack. The values still have to be on the heap, though.
(scm_prepare_fluids, scm_swap_fluids): New internal functions,
replacing scm_i_make_with_fluids and scm_i_swap_with_fluids.
* libguile/print.c: Remove prompt and with-fluids printers.
* libguile/tags.h: Revert prompt and with-fluids tc7 values to what they
were before they were allocated.
* libguile/vm-i-system.c (partial_cont_call): Just pop the vmcont, the
intwinds will not be passed as a second arg. Rewind the dynamic stack
from within the VM, so that any rewinder sees valid prompt entries.
(call_cc, tail_call_cc): Adapt to pass the dynstack to
scm_i_vm_capture_stack.
(prompt, wind, unwind, wind_fluids, unwind_fluids): Adapt to the new
interfaces.
* libguile/vm.h (scm_i_capture_current_stack): Rename from
scm_i_vm_capture_continuation.
(scm_i_vm_capture_stack): Take a dynstack as an argument.
* libguile/vm.c (vm_reinstate_partial_continuation): Don't wind here, as
that could result in winders seeing invalid prompts.
* libguile/eval.c:
* libguile/root.c:
* libguile/stacks.c:
* libguile/threads.c:
* libguile/threads.h:
* libguile/throw.c: Adapt other users of dynwinds to use the dynstack.
2012-03-03 17:01:16 +01:00
|
|
|
|
scm_t_uint8 *mvra, scm_t_dynstack *dynstack,
|
|
|
|
|
|
scm_t_uint32 flags)
|
2000-08-22 15:54:19 +00:00
|
|
|
|
{
|
continuations return multiple values on the stack
* libguile/vm.h (struct scm_vm_cont): Instead of saving the "IP", save
"RA" and "MVRA". That is, save singly-valued and multiply-valued
return addresses, so that we can return multiple values on the stack.
(scm_i_vm_reinstate_continuation): Remove.
* libguile/vm.c (vm_capture_continuation): Rename from capture_vm_cont,
and change the prototype so we can capture the RA and MVRA, and so
that tail calls to call/cc can capture a continuation without the
call/cc application frame.
(vm_return_to_continuation): Rename from reinstate_vm_cont, and take
arguments to return to the continuation. Handles returning to single
or multiple-value RA.
(scm_i_vm_capture_continuation): Change to invoke
vm_capture_continuation. Kept around for the benefit of make-stack.
* libguile/vm-i-system.c (continuation-call): Handle reinstatement of
the VM stack, with arguments.
(call/cc, tail-call/cc): Adapt to new vm_capture_continuation
prototype. tail-call/cc captures tail continuations.
* libguile/stacks.c (scm_make_stack): Update for scm_vm_cont structure
change.
* libguile/continuations.h (struct scm_contregs): Remove throw_value
member, which was used to return a value to a continuation.
(scm_i_check_continuation): New internal function, checks that a
continuation may be reinstated.
(scm_i_reinstate_continuation): Replaces scm_i_continuation_call; just
reinstates the C stack.
(scm_i_contregs_vm, scm_i_contregs_vm_cont): New internal accessors.
* libguile/continuations.c (scm_i_make_continuation): Return
SCM_UNDEFINED if we are returning again.
(grow_stack, copy_stack_and_call, scm_dynthrow): Remove extra arg, as
vm opcodes handle value returns.
(copy_stack): No need to instate VM continuation.
(scm_i_reinstate_continuation): Adapt.
2010-02-08 22:59:25 +01:00
|
|
|
|
struct scm_vm_cont *p;
|
|
|
|
|
|
|
|
|
|
|
|
p = scm_gc_malloc (sizeof (*p), "capture_vm_cont");
|
|
|
|
|
|
p->stack_size = sp - stack_base + 1;
|
2005-04-22 16:00:33 +00:00
|
|
|
|
p->stack_base = scm_gc_malloc (p->stack_size * sizeof (SCM),
|
|
|
|
|
|
"capture_vm_cont");
|
continuations return multiple values on the stack
* libguile/vm.h (struct scm_vm_cont): Instead of saving the "IP", save
"RA" and "MVRA". That is, save singly-valued and multiply-valued
return addresses, so that we can return multiple values on the stack.
(scm_i_vm_reinstate_continuation): Remove.
* libguile/vm.c (vm_capture_continuation): Rename from capture_vm_cont,
and change the prototype so we can capture the RA and MVRA, and so
that tail calls to call/cc can capture a continuation without the
call/cc application frame.
(vm_return_to_continuation): Rename from reinstate_vm_cont, and take
arguments to return to the continuation. Handles returning to single
or multiple-value RA.
(scm_i_vm_capture_continuation): Change to invoke
vm_capture_continuation. Kept around for the benefit of make-stack.
* libguile/vm-i-system.c (continuation-call): Handle reinstatement of
the VM stack, with arguments.
(call/cc, tail-call/cc): Adapt to new vm_capture_continuation
prototype. tail-call/cc captures tail continuations.
* libguile/stacks.c (scm_make_stack): Update for scm_vm_cont structure
change.
* libguile/continuations.h (struct scm_contregs): Remove throw_value
member, which was used to return a value to a continuation.
(scm_i_check_continuation): New internal function, checks that a
continuation may be reinstated.
(scm_i_reinstate_continuation): Replaces scm_i_continuation_call; just
reinstates the C stack.
(scm_i_contregs_vm, scm_i_contregs_vm_cont): New internal accessors.
* libguile/continuations.c (scm_i_make_continuation): Return
SCM_UNDEFINED if we are returning again.
(grow_stack, copy_stack_and_call, scm_dynthrow): Remove extra arg, as
vm opcodes handle value returns.
(copy_stack): No need to instate VM continuation.
(scm_i_reinstate_continuation): Adapt.
2010-02-08 22:59:25 +01:00
|
|
|
|
#if defined(VM_ENABLE_STACK_NULLING) && 0
|
|
|
|
|
|
/* Tail continuations leave their frame on the stack for subsequent
|
|
|
|
|
|
application, but don't capture the frame -- so there are some elements on
|
|
|
|
|
|
the stack then, and this check doesn't work, so disable it for now. */
|
|
|
|
|
|
if (sp >= vp->stack_base)
|
2008-10-09 14:44:43 +02:00
|
|
|
|
if (!vp->sp[0] || vp->sp[1])
|
|
|
|
|
|
abort ();
|
precise stack marking, fix some missed references, still imperfect
* libguile/vm-engine.h (CHECK_STACK_LEAK, NULLSTACK): Add a new mode,
VM_ENABLE_STACK_NULLING, that tries to ensure that all stack data past
the top of the stack is NULL. This helps to verify the VM's
consistency. If VM_ENABLE_STACK_NULLING is not defined, there is no
overhead.
(DROP, DROPN): Hook into NULLSTACK.
(POP_LIST): Hoo, fix a good bug: if CONS triggered a GC, the elements
of the list that had not yet been consed would not be marked, because
the sp was already below them.
(NEXT): Hook into CHECK_STACK_LEAK.
(INIT_ARGS): Add a note that consing the rest arg can cause GC.
(NEW_FRAME): Cons up the external data after initializing the frame, so
that if GC is triggered, the precise marker sees a well-formed frame.
* libguile/vm-i-loader.c (load-program): In the four-integers case, use
the POP macro so that we can hook into NULLSTACK (if necessary).
* libguile/vm-i-scheme.c (ARGS2, ARGS3): Hook into NULLSTACK.
* libguile/vm-i-system.c (halt): Null the nvalues. Rework some asserts
into using ASSERT, and null the stack when we free the frame.
(variable-set): Use DROPN instead of sp -= 2.
(BR): Hook into NULLSTACK.
(goto/args): Hook into NULLSTACK. In the non-self case, delay updating
the frame until after INIT_ARGS so that GC sees a well-formed frame.
Delay consing the externals until after the frame is set up, as in
NEW_FRAME.
(call/cc): Add some asserts.
(return): Rework some asserts into ASSERT, and hook into NULLSTACK.
(return/values): Hook into NULLSTACK, and use ASSERT.
(return/values*) Use ASSERT.
* libguile/vm.c (VM_ENABLE_ASSERTIONS, VM_ENABLE_STACK_NULLING): These
are the variables that control assertions and nulling. Perhaps we can
do these per-engine when we start compiling the debug engine separate
from a speedy engine.
(vm_mark_stack): Add a precise stack marker. Yay!
(vm_cont_mark): Mark the continuation stack precisely.
(capture_vm_cont): Record the difference from the vp's stack_base too,
so that we can translate the dynamic links when marking the
continuation stack. Memset the stack to NULL if we are doing nulling.
(reinstate_vm_cont): If we are nulling, null out the relevant part
of the stack.
(vm_reset_stack): When resetting sp due to a nonlocal exit, null out
the stack too.
(vm_mark): If we are nulling, assert that there are no extra values on
the stack. Mark the stack precisely.
2008-10-03 16:00:30 +02:00
|
|
|
|
memset (p->stack_base, 0, p->stack_size * sizeof (SCM));
|
|
|
|
|
|
#endif
|
continuations return multiple values on the stack
* libguile/vm.h (struct scm_vm_cont): Instead of saving the "IP", save
"RA" and "MVRA". That is, save singly-valued and multiply-valued
return addresses, so that we can return multiple values on the stack.
(scm_i_vm_reinstate_continuation): Remove.
* libguile/vm.c (vm_capture_continuation): Rename from capture_vm_cont,
and change the prototype so we can capture the RA and MVRA, and so
that tail calls to call/cc can capture a continuation without the
call/cc application frame.
(vm_return_to_continuation): Rename from reinstate_vm_cont, and take
arguments to return to the continuation. Handles returning to single
or multiple-value RA.
(scm_i_vm_capture_continuation): Change to invoke
vm_capture_continuation. Kept around for the benefit of make-stack.
* libguile/vm-i-system.c (continuation-call): Handle reinstatement of
the VM stack, with arguments.
(call/cc, tail-call/cc): Adapt to new vm_capture_continuation
prototype. tail-call/cc captures tail continuations.
* libguile/stacks.c (scm_make_stack): Update for scm_vm_cont structure
change.
* libguile/continuations.h (struct scm_contregs): Remove throw_value
member, which was used to return a value to a continuation.
(scm_i_check_continuation): New internal function, checks that a
continuation may be reinstated.
(scm_i_reinstate_continuation): Replaces scm_i_continuation_call; just
reinstates the C stack.
(scm_i_contregs_vm, scm_i_contregs_vm_cont): New internal accessors.
* libguile/continuations.c (scm_i_make_continuation): Return
SCM_UNDEFINED if we are returning again.
(grow_stack, copy_stack_and_call, scm_dynthrow): Remove extra arg, as
vm opcodes handle value returns.
(copy_stack): No need to instate VM continuation.
(scm_i_reinstate_continuation): Adapt.
2010-02-08 22:59:25 +01:00
|
|
|
|
p->ra = ra;
|
|
|
|
|
|
p->mvra = mvra;
|
|
|
|
|
|
p->sp = sp;
|
|
|
|
|
|
p->fp = fp;
|
|
|
|
|
|
memcpy (p->stack_base, stack_base, (sp + 1 - stack_base) * sizeof (SCM));
|
|
|
|
|
|
p->reloc = p->stack_base - stack_base;
|
the dynamic stack is really a stack now, instead of a list
* libguile/dynstack.h:
* libguile/dynstack.c: New files, implementing the dynamic stack as a
true stack instead of a linked list. This lowers the cost of
dynwinds: frames, winders, prompts, with-fluids, and dynamic-wind.
For the most part, we allocate these items directly on the stack.
* libguile/dynwinds.h:
* libguile/dynwinds.c: Adapt all manipulators of the wind stack to use
interfaces from dynstack.c. Remove heap-allocated winder and frame
object types.
(scm_dowinds, scm_i_dowinds): Remove these. The first was exported,
but it was not a public interface.
* libguile/continuations.c:
* libguile/continuations.h (scm_t_contregs): Continuation objects
reference scm_t_dynstack* values now. Adapt to the new interfaces.
* libguile/control.c:
* libguile/control.h: There is no longer a scm_tc7_prompt kind of object
that can be allocated on the heap. Instead, the prompt flags, key,
and registers are pushed on the dynwind stack. (The registers are
still on the heap.) Also, since the vm_cont will reference the
dynwinds, make the partial continuation stub take just one extra arg,
instead of storing the intwinds separately in the object table.
* libguile/fluids.c:
* libguile/fluids.h: No more with-fluids objects; instead, the fluids go
on the dynstack. The values still have to be on the heap, though.
(scm_prepare_fluids, scm_swap_fluids): New internal functions,
replacing scm_i_make_with_fluids and scm_i_swap_with_fluids.
* libguile/print.c: Remove prompt and with-fluids printers.
* libguile/tags.h: Revert prompt and with-fluids tc7 values to what they
were before they were allocated.
* libguile/vm-i-system.c (partial_cont_call): Just pop the vmcont, the
intwinds will not be passed as a second arg. Rewind the dynamic stack
from within the VM, so that any rewinder sees valid prompt entries.
(call_cc, tail_call_cc): Adapt to pass the dynstack to
scm_i_vm_capture_stack.
(prompt, wind, unwind, wind_fluids, unwind_fluids): Adapt to the new
interfaces.
* libguile/vm.h (scm_i_capture_current_stack): Rename from
scm_i_vm_capture_continuation.
(scm_i_vm_capture_stack): Take a dynstack as an argument.
* libguile/vm.c (vm_reinstate_partial_continuation): Don't wind here, as
that could result in winders seeing invalid prompts.
* libguile/eval.c:
* libguile/root.c:
* libguile/stacks.c:
* libguile/threads.c:
* libguile/threads.h:
* libguile/throw.c: Adapt other users of dynwinds to use the dynstack.
2012-03-03 17:01:16 +01:00
|
|
|
|
p->dynstack = dynstack;
|
2010-02-22 23:00:19 +01:00
|
|
|
|
p->flags = flags;
|
2010-01-05 19:45:56 +01:00
|
|
|
|
return scm_cell (scm_tc7_vm_cont, (scm_t_bits)p);
|
2000-08-22 15:54:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
continuations return multiple values on the stack
* libguile/vm.h (struct scm_vm_cont): Instead of saving the "IP", save
"RA" and "MVRA". That is, save singly-valued and multiply-valued
return addresses, so that we can return multiple values on the stack.
(scm_i_vm_reinstate_continuation): Remove.
* libguile/vm.c (vm_capture_continuation): Rename from capture_vm_cont,
and change the prototype so we can capture the RA and MVRA, and so
that tail calls to call/cc can capture a continuation without the
call/cc application frame.
(vm_return_to_continuation): Rename from reinstate_vm_cont, and take
arguments to return to the continuation. Handles returning to single
or multiple-value RA.
(scm_i_vm_capture_continuation): Change to invoke
vm_capture_continuation. Kept around for the benefit of make-stack.
* libguile/vm-i-system.c (continuation-call): Handle reinstatement of
the VM stack, with arguments.
(call/cc, tail-call/cc): Adapt to new vm_capture_continuation
prototype. tail-call/cc captures tail continuations.
* libguile/stacks.c (scm_make_stack): Update for scm_vm_cont structure
change.
* libguile/continuations.h (struct scm_contregs): Remove throw_value
member, which was used to return a value to a continuation.
(scm_i_check_continuation): New internal function, checks that a
continuation may be reinstated.
(scm_i_reinstate_continuation): Replaces scm_i_continuation_call; just
reinstates the C stack.
(scm_i_contregs_vm, scm_i_contregs_vm_cont): New internal accessors.
* libguile/continuations.c (scm_i_make_continuation): Return
SCM_UNDEFINED if we are returning again.
(grow_stack, copy_stack_and_call, scm_dynthrow): Remove extra arg, as
vm opcodes handle value returns.
(copy_stack): No need to instate VM continuation.
(scm_i_reinstate_continuation): Adapt.
2010-02-08 22:59:25 +01:00
|
|
|
|
vm_return_to_continuation (SCM vm, SCM cont, size_t n, SCM *argv)
|
2000-08-22 15:54:19 +00:00
|
|
|
|
{
|
continuations return multiple values on the stack
* libguile/vm.h (struct scm_vm_cont): Instead of saving the "IP", save
"RA" and "MVRA". That is, save singly-valued and multiply-valued
return addresses, so that we can return multiple values on the stack.
(scm_i_vm_reinstate_continuation): Remove.
* libguile/vm.c (vm_capture_continuation): Rename from capture_vm_cont,
and change the prototype so we can capture the RA and MVRA, and so
that tail calls to call/cc can capture a continuation without the
call/cc application frame.
(vm_return_to_continuation): Rename from reinstate_vm_cont, and take
arguments to return to the continuation. Handles returning to single
or multiple-value RA.
(scm_i_vm_capture_continuation): Change to invoke
vm_capture_continuation. Kept around for the benefit of make-stack.
* libguile/vm-i-system.c (continuation-call): Handle reinstatement of
the VM stack, with arguments.
(call/cc, tail-call/cc): Adapt to new vm_capture_continuation
prototype. tail-call/cc captures tail continuations.
* libguile/stacks.c (scm_make_stack): Update for scm_vm_cont structure
change.
* libguile/continuations.h (struct scm_contregs): Remove throw_value
member, which was used to return a value to a continuation.
(scm_i_check_continuation): New internal function, checks that a
continuation may be reinstated.
(scm_i_reinstate_continuation): Replaces scm_i_continuation_call; just
reinstates the C stack.
(scm_i_contregs_vm, scm_i_contregs_vm_cont): New internal accessors.
* libguile/continuations.c (scm_i_make_continuation): Return
SCM_UNDEFINED if we are returning again.
(grow_stack, copy_stack_and_call, scm_dynthrow): Remove extra arg, as
vm opcodes handle value returns.
(copy_stack): No need to instate VM continuation.
(scm_i_reinstate_continuation): Adapt.
2010-02-08 22:59:25 +01:00
|
|
|
|
struct scm_vm *vp;
|
|
|
|
|
|
struct scm_vm_cont *cp;
|
|
|
|
|
|
SCM *argv_copy;
|
|
|
|
|
|
|
|
|
|
|
|
argv_copy = alloca (n * sizeof(SCM));
|
|
|
|
|
|
memcpy (argv_copy, argv, n * sizeof(SCM));
|
|
|
|
|
|
|
|
|
|
|
|
vp = SCM_VM_DATA (vm);
|
|
|
|
|
|
cp = SCM_VM_CONT_DATA (cont);
|
|
|
|
|
|
|
|
|
|
|
|
if (n == 0 && !cp->mvra)
|
|
|
|
|
|
scm_misc_error (NULL, "Too few values returned to continuation",
|
|
|
|
|
|
SCM_EOL);
|
|
|
|
|
|
|
|
|
|
|
|
if (vp->stack_size < cp->stack_size + n + 1)
|
2010-02-24 18:51:25 +01:00
|
|
|
|
scm_misc_error ("vm-engine", "not enough space to reinstate continuation",
|
|
|
|
|
|
scm_list_2 (vm, cont));
|
|
|
|
|
|
|
precise stack marking, fix some missed references, still imperfect
* libguile/vm-engine.h (CHECK_STACK_LEAK, NULLSTACK): Add a new mode,
VM_ENABLE_STACK_NULLING, that tries to ensure that all stack data past
the top of the stack is NULL. This helps to verify the VM's
consistency. If VM_ENABLE_STACK_NULLING is not defined, there is no
overhead.
(DROP, DROPN): Hook into NULLSTACK.
(POP_LIST): Hoo, fix a good bug: if CONS triggered a GC, the elements
of the list that had not yet been consed would not be marked, because
the sp was already below them.
(NEXT): Hook into CHECK_STACK_LEAK.
(INIT_ARGS): Add a note that consing the rest arg can cause GC.
(NEW_FRAME): Cons up the external data after initializing the frame, so
that if GC is triggered, the precise marker sees a well-formed frame.
* libguile/vm-i-loader.c (load-program): In the four-integers case, use
the POP macro so that we can hook into NULLSTACK (if necessary).
* libguile/vm-i-scheme.c (ARGS2, ARGS3): Hook into NULLSTACK.
* libguile/vm-i-system.c (halt): Null the nvalues. Rework some asserts
into using ASSERT, and null the stack when we free the frame.
(variable-set): Use DROPN instead of sp -= 2.
(BR): Hook into NULLSTACK.
(goto/args): Hook into NULLSTACK. In the non-self case, delay updating
the frame until after INIT_ARGS so that GC sees a well-formed frame.
Delay consing the externals until after the frame is set up, as in
NEW_FRAME.
(call/cc): Add some asserts.
(return): Rework some asserts into ASSERT, and hook into NULLSTACK.
(return/values): Hook into NULLSTACK, and use ASSERT.
(return/values*) Use ASSERT.
* libguile/vm.c (VM_ENABLE_ASSERTIONS, VM_ENABLE_STACK_NULLING): These
are the variables that control assertions and nulling. Perhaps we can
do these per-engine when we start compiling the debug engine separate
from a speedy engine.
(vm_mark_stack): Add a precise stack marker. Yay!
(vm_cont_mark): Mark the continuation stack precisely.
(capture_vm_cont): Record the difference from the vp's stack_base too,
so that we can translate the dynamic links when marking the
continuation stack. Memset the stack to NULL if we are doing nulling.
(reinstate_vm_cont): If we are nulling, null out the relevant part
of the stack.
(vm_reset_stack): When resetting sp due to a nonlocal exit, null out
the stack too.
(vm_mark): If we are nulling, assert that there are no extra values on
the stack. Mark the stack precisely.
2008-10-03 16:00:30 +02:00
|
|
|
|
#ifdef VM_ENABLE_STACK_NULLING
|
|
|
|
|
|
{
|
continuations return multiple values on the stack
* libguile/vm.h (struct scm_vm_cont): Instead of saving the "IP", save
"RA" and "MVRA". That is, save singly-valued and multiply-valued
return addresses, so that we can return multiple values on the stack.
(scm_i_vm_reinstate_continuation): Remove.
* libguile/vm.c (vm_capture_continuation): Rename from capture_vm_cont,
and change the prototype so we can capture the RA and MVRA, and so
that tail calls to call/cc can capture a continuation without the
call/cc application frame.
(vm_return_to_continuation): Rename from reinstate_vm_cont, and take
arguments to return to the continuation. Handles returning to single
or multiple-value RA.
(scm_i_vm_capture_continuation): Change to invoke
vm_capture_continuation. Kept around for the benefit of make-stack.
* libguile/vm-i-system.c (continuation-call): Handle reinstatement of
the VM stack, with arguments.
(call/cc, tail-call/cc): Adapt to new vm_capture_continuation
prototype. tail-call/cc captures tail continuations.
* libguile/stacks.c (scm_make_stack): Update for scm_vm_cont structure
change.
* libguile/continuations.h (struct scm_contregs): Remove throw_value
member, which was used to return a value to a continuation.
(scm_i_check_continuation): New internal function, checks that a
continuation may be reinstated.
(scm_i_reinstate_continuation): Replaces scm_i_continuation_call; just
reinstates the C stack.
(scm_i_contregs_vm, scm_i_contregs_vm_cont): New internal accessors.
* libguile/continuations.c (scm_i_make_continuation): Return
SCM_UNDEFINED if we are returning again.
(grow_stack, copy_stack_and_call, scm_dynthrow): Remove extra arg, as
vm opcodes handle value returns.
(copy_stack): No need to instate VM continuation.
(scm_i_reinstate_continuation): Adapt.
2010-02-08 22:59:25 +01:00
|
|
|
|
scm_t_ptrdiff nzero = (vp->sp - cp->sp);
|
precise stack marking, fix some missed references, still imperfect
* libguile/vm-engine.h (CHECK_STACK_LEAK, NULLSTACK): Add a new mode,
VM_ENABLE_STACK_NULLING, that tries to ensure that all stack data past
the top of the stack is NULL. This helps to verify the VM's
consistency. If VM_ENABLE_STACK_NULLING is not defined, there is no
overhead.
(DROP, DROPN): Hook into NULLSTACK.
(POP_LIST): Hoo, fix a good bug: if CONS triggered a GC, the elements
of the list that had not yet been consed would not be marked, because
the sp was already below them.
(NEXT): Hook into CHECK_STACK_LEAK.
(INIT_ARGS): Add a note that consing the rest arg can cause GC.
(NEW_FRAME): Cons up the external data after initializing the frame, so
that if GC is triggered, the precise marker sees a well-formed frame.
* libguile/vm-i-loader.c (load-program): In the four-integers case, use
the POP macro so that we can hook into NULLSTACK (if necessary).
* libguile/vm-i-scheme.c (ARGS2, ARGS3): Hook into NULLSTACK.
* libguile/vm-i-system.c (halt): Null the nvalues. Rework some asserts
into using ASSERT, and null the stack when we free the frame.
(variable-set): Use DROPN instead of sp -= 2.
(BR): Hook into NULLSTACK.
(goto/args): Hook into NULLSTACK. In the non-self case, delay updating
the frame until after INIT_ARGS so that GC sees a well-formed frame.
Delay consing the externals until after the frame is set up, as in
NEW_FRAME.
(call/cc): Add some asserts.
(return): Rework some asserts into ASSERT, and hook into NULLSTACK.
(return/values): Hook into NULLSTACK, and use ASSERT.
(return/values*) Use ASSERT.
* libguile/vm.c (VM_ENABLE_ASSERTIONS, VM_ENABLE_STACK_NULLING): These
are the variables that control assertions and nulling. Perhaps we can
do these per-engine when we start compiling the debug engine separate
from a speedy engine.
(vm_mark_stack): Add a precise stack marker. Yay!
(vm_cont_mark): Mark the continuation stack precisely.
(capture_vm_cont): Record the difference from the vp's stack_base too,
so that we can translate the dynamic links when marking the
continuation stack. Memset the stack to NULL if we are doing nulling.
(reinstate_vm_cont): If we are nulling, null out the relevant part
of the stack.
(vm_reset_stack): When resetting sp due to a nonlocal exit, null out
the stack too.
(vm_mark): If we are nulling, assert that there are no extra values on
the stack. Mark the stack precisely.
2008-10-03 16:00:30 +02:00
|
|
|
|
if (nzero > 0)
|
continuations return multiple values on the stack
* libguile/vm.h (struct scm_vm_cont): Instead of saving the "IP", save
"RA" and "MVRA". That is, save singly-valued and multiply-valued
return addresses, so that we can return multiple values on the stack.
(scm_i_vm_reinstate_continuation): Remove.
* libguile/vm.c (vm_capture_continuation): Rename from capture_vm_cont,
and change the prototype so we can capture the RA and MVRA, and so
that tail calls to call/cc can capture a continuation without the
call/cc application frame.
(vm_return_to_continuation): Rename from reinstate_vm_cont, and take
arguments to return to the continuation. Handles returning to single
or multiple-value RA.
(scm_i_vm_capture_continuation): Change to invoke
vm_capture_continuation. Kept around for the benefit of make-stack.
* libguile/vm-i-system.c (continuation-call): Handle reinstatement of
the VM stack, with arguments.
(call/cc, tail-call/cc): Adapt to new vm_capture_continuation
prototype. tail-call/cc captures tail continuations.
* libguile/stacks.c (scm_make_stack): Update for scm_vm_cont structure
change.
* libguile/continuations.h (struct scm_contregs): Remove throw_value
member, which was used to return a value to a continuation.
(scm_i_check_continuation): New internal function, checks that a
continuation may be reinstated.
(scm_i_reinstate_continuation): Replaces scm_i_continuation_call; just
reinstates the C stack.
(scm_i_contregs_vm, scm_i_contregs_vm_cont): New internal accessors.
* libguile/continuations.c (scm_i_make_continuation): Return
SCM_UNDEFINED if we are returning again.
(grow_stack, copy_stack_and_call, scm_dynthrow): Remove extra arg, as
vm opcodes handle value returns.
(copy_stack): No need to instate VM continuation.
(scm_i_reinstate_continuation): Adapt.
2010-02-08 22:59:25 +01:00
|
|
|
|
memset (vp->stack_base + cp->stack_size, 0, nzero * sizeof (SCM));
|
2008-10-09 14:44:43 +02:00
|
|
|
|
/* actually nzero should always be negative, because vm_reset_stack will
|
|
|
|
|
|
unwind the stack to some point *below* this continuation */
|
precise stack marking, fix some missed references, still imperfect
* libguile/vm-engine.h (CHECK_STACK_LEAK, NULLSTACK): Add a new mode,
VM_ENABLE_STACK_NULLING, that tries to ensure that all stack data past
the top of the stack is NULL. This helps to verify the VM's
consistency. If VM_ENABLE_STACK_NULLING is not defined, there is no
overhead.
(DROP, DROPN): Hook into NULLSTACK.
(POP_LIST): Hoo, fix a good bug: if CONS triggered a GC, the elements
of the list that had not yet been consed would not be marked, because
the sp was already below them.
(NEXT): Hook into CHECK_STACK_LEAK.
(INIT_ARGS): Add a note that consing the rest arg can cause GC.
(NEW_FRAME): Cons up the external data after initializing the frame, so
that if GC is triggered, the precise marker sees a well-formed frame.
* libguile/vm-i-loader.c (load-program): In the four-integers case, use
the POP macro so that we can hook into NULLSTACK (if necessary).
* libguile/vm-i-scheme.c (ARGS2, ARGS3): Hook into NULLSTACK.
* libguile/vm-i-system.c (halt): Null the nvalues. Rework some asserts
into using ASSERT, and null the stack when we free the frame.
(variable-set): Use DROPN instead of sp -= 2.
(BR): Hook into NULLSTACK.
(goto/args): Hook into NULLSTACK. In the non-self case, delay updating
the frame until after INIT_ARGS so that GC sees a well-formed frame.
Delay consing the externals until after the frame is set up, as in
NEW_FRAME.
(call/cc): Add some asserts.
(return): Rework some asserts into ASSERT, and hook into NULLSTACK.
(return/values): Hook into NULLSTACK, and use ASSERT.
(return/values*) Use ASSERT.
* libguile/vm.c (VM_ENABLE_ASSERTIONS, VM_ENABLE_STACK_NULLING): These
are the variables that control assertions and nulling. Perhaps we can
do these per-engine when we start compiling the debug engine separate
from a speedy engine.
(vm_mark_stack): Add a precise stack marker. Yay!
(vm_cont_mark): Mark the continuation stack precisely.
(capture_vm_cont): Record the difference from the vp's stack_base too,
so that we can translate the dynamic links when marking the
continuation stack. Memset the stack to NULL if we are doing nulling.
(reinstate_vm_cont): If we are nulling, null out the relevant part
of the stack.
(vm_reset_stack): When resetting sp due to a nonlocal exit, null out
the stack too.
(vm_mark): If we are nulling, assert that there are no extra values on
the stack. Mark the stack precisely.
2008-10-03 16:00:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
#endif
|
continuations return multiple values on the stack
* libguile/vm.h (struct scm_vm_cont): Instead of saving the "IP", save
"RA" and "MVRA". That is, save singly-valued and multiply-valued
return addresses, so that we can return multiple values on the stack.
(scm_i_vm_reinstate_continuation): Remove.
* libguile/vm.c (vm_capture_continuation): Rename from capture_vm_cont,
and change the prototype so we can capture the RA and MVRA, and so
that tail calls to call/cc can capture a continuation without the
call/cc application frame.
(vm_return_to_continuation): Rename from reinstate_vm_cont, and take
arguments to return to the continuation. Handles returning to single
or multiple-value RA.
(scm_i_vm_capture_continuation): Change to invoke
vm_capture_continuation. Kept around for the benefit of make-stack.
* libguile/vm-i-system.c (continuation-call): Handle reinstatement of
the VM stack, with arguments.
(call/cc, tail-call/cc): Adapt to new vm_capture_continuation
prototype. tail-call/cc captures tail continuations.
* libguile/stacks.c (scm_make_stack): Update for scm_vm_cont structure
change.
* libguile/continuations.h (struct scm_contregs): Remove throw_value
member, which was used to return a value to a continuation.
(scm_i_check_continuation): New internal function, checks that a
continuation may be reinstated.
(scm_i_reinstate_continuation): Replaces scm_i_continuation_call; just
reinstates the C stack.
(scm_i_contregs_vm, scm_i_contregs_vm_cont): New internal accessors.
* libguile/continuations.c (scm_i_make_continuation): Return
SCM_UNDEFINED if we are returning again.
(grow_stack, copy_stack_and_call, scm_dynthrow): Remove extra arg, as
vm opcodes handle value returns.
(copy_stack): No need to instate VM continuation.
(scm_i_reinstate_continuation): Adapt.
2010-02-08 22:59:25 +01:00
|
|
|
|
vp->sp = cp->sp;
|
|
|
|
|
|
vp->fp = cp->fp;
|
|
|
|
|
|
memcpy (vp->stack_base, cp->stack_base, cp->stack_size * sizeof (SCM));
|
2008-09-24 17:04:14 +02:00
|
|
|
|
|
continuations return multiple values on the stack
* libguile/vm.h (struct scm_vm_cont): Instead of saving the "IP", save
"RA" and "MVRA". That is, save singly-valued and multiply-valued
return addresses, so that we can return multiple values on the stack.
(scm_i_vm_reinstate_continuation): Remove.
* libguile/vm.c (vm_capture_continuation): Rename from capture_vm_cont,
and change the prototype so we can capture the RA and MVRA, and so
that tail calls to call/cc can capture a continuation without the
call/cc application frame.
(vm_return_to_continuation): Rename from reinstate_vm_cont, and take
arguments to return to the continuation. Handles returning to single
or multiple-value RA.
(scm_i_vm_capture_continuation): Change to invoke
vm_capture_continuation. Kept around for the benefit of make-stack.
* libguile/vm-i-system.c (continuation-call): Handle reinstatement of
the VM stack, with arguments.
(call/cc, tail-call/cc): Adapt to new vm_capture_continuation
prototype. tail-call/cc captures tail continuations.
* libguile/stacks.c (scm_make_stack): Update for scm_vm_cont structure
change.
* libguile/continuations.h (struct scm_contregs): Remove throw_value
member, which was used to return a value to a continuation.
(scm_i_check_continuation): New internal function, checks that a
continuation may be reinstated.
(scm_i_reinstate_continuation): Replaces scm_i_continuation_call; just
reinstates the C stack.
(scm_i_contregs_vm, scm_i_contregs_vm_cont): New internal accessors.
* libguile/continuations.c (scm_i_make_continuation): Return
SCM_UNDEFINED if we are returning again.
(grow_stack, copy_stack_and_call, scm_dynthrow): Remove extra arg, as
vm opcodes handle value returns.
(copy_stack): No need to instate VM continuation.
(scm_i_reinstate_continuation): Adapt.
2010-02-08 22:59:25 +01:00
|
|
|
|
if (n == 1 || !cp->mvra)
|
|
|
|
|
|
{
|
|
|
|
|
|
vp->ip = cp->ra;
|
|
|
|
|
|
vp->sp++;
|
|
|
|
|
|
*vp->sp = argv_copy[0];
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
size_t i;
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
vp->sp++;
|
|
|
|
|
|
*vp->sp = argv_copy[i];
|
|
|
|
|
|
}
|
|
|
|
|
|
vp->sp++;
|
|
|
|
|
|
*vp->sp = scm_from_size_t (n);
|
|
|
|
|
|
vp->ip = cp->mvra;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2008-09-24 17:04:14 +02:00
|
|
|
|
|
|
|
|
|
|
SCM
|
the dynamic stack is really a stack now, instead of a list
* libguile/dynstack.h:
* libguile/dynstack.c: New files, implementing the dynamic stack as a
true stack instead of a linked list. This lowers the cost of
dynwinds: frames, winders, prompts, with-fluids, and dynamic-wind.
For the most part, we allocate these items directly on the stack.
* libguile/dynwinds.h:
* libguile/dynwinds.c: Adapt all manipulators of the wind stack to use
interfaces from dynstack.c. Remove heap-allocated winder and frame
object types.
(scm_dowinds, scm_i_dowinds): Remove these. The first was exported,
but it was not a public interface.
* libguile/continuations.c:
* libguile/continuations.h (scm_t_contregs): Continuation objects
reference scm_t_dynstack* values now. Adapt to the new interfaces.
* libguile/control.c:
* libguile/control.h: There is no longer a scm_tc7_prompt kind of object
that can be allocated on the heap. Instead, the prompt flags, key,
and registers are pushed on the dynwind stack. (The registers are
still on the heap.) Also, since the vm_cont will reference the
dynwinds, make the partial continuation stub take just one extra arg,
instead of storing the intwinds separately in the object table.
* libguile/fluids.c:
* libguile/fluids.h: No more with-fluids objects; instead, the fluids go
on the dynstack. The values still have to be on the heap, though.
(scm_prepare_fluids, scm_swap_fluids): New internal functions,
replacing scm_i_make_with_fluids and scm_i_swap_with_fluids.
* libguile/print.c: Remove prompt and with-fluids printers.
* libguile/tags.h: Revert prompt and with-fluids tc7 values to what they
were before they were allocated.
* libguile/vm-i-system.c (partial_cont_call): Just pop the vmcont, the
intwinds will not be passed as a second arg. Rewind the dynamic stack
from within the VM, so that any rewinder sees valid prompt entries.
(call_cc, tail_call_cc): Adapt to pass the dynstack to
scm_i_vm_capture_stack.
(prompt, wind, unwind, wind_fluids, unwind_fluids): Adapt to the new
interfaces.
* libguile/vm.h (scm_i_capture_current_stack): Rename from
scm_i_vm_capture_continuation.
(scm_i_vm_capture_stack): Take a dynstack as an argument.
* libguile/vm.c (vm_reinstate_partial_continuation): Don't wind here, as
that could result in winders seeing invalid prompts.
* libguile/eval.c:
* libguile/root.c:
* libguile/stacks.c:
* libguile/threads.c:
* libguile/threads.h:
* libguile/throw.c: Adapt other users of dynwinds to use the dynstack.
2012-03-03 17:01:16 +01:00
|
|
|
|
scm_i_capture_current_stack (void)
|
2008-09-24 17:04:14 +02:00
|
|
|
|
{
|
the dynamic stack is really a stack now, instead of a list
* libguile/dynstack.h:
* libguile/dynstack.c: New files, implementing the dynamic stack as a
true stack instead of a linked list. This lowers the cost of
dynwinds: frames, winders, prompts, with-fluids, and dynamic-wind.
For the most part, we allocate these items directly on the stack.
* libguile/dynwinds.h:
* libguile/dynwinds.c: Adapt all manipulators of the wind stack to use
interfaces from dynstack.c. Remove heap-allocated winder and frame
object types.
(scm_dowinds, scm_i_dowinds): Remove these. The first was exported,
but it was not a public interface.
* libguile/continuations.c:
* libguile/continuations.h (scm_t_contregs): Continuation objects
reference scm_t_dynstack* values now. Adapt to the new interfaces.
* libguile/control.c:
* libguile/control.h: There is no longer a scm_tc7_prompt kind of object
that can be allocated on the heap. Instead, the prompt flags, key,
and registers are pushed on the dynwind stack. (The registers are
still on the heap.) Also, since the vm_cont will reference the
dynwinds, make the partial continuation stub take just one extra arg,
instead of storing the intwinds separately in the object table.
* libguile/fluids.c:
* libguile/fluids.h: No more with-fluids objects; instead, the fluids go
on the dynstack. The values still have to be on the heap, though.
(scm_prepare_fluids, scm_swap_fluids): New internal functions,
replacing scm_i_make_with_fluids and scm_i_swap_with_fluids.
* libguile/print.c: Remove prompt and with-fluids printers.
* libguile/tags.h: Revert prompt and with-fluids tc7 values to what they
were before they were allocated.
* libguile/vm-i-system.c (partial_cont_call): Just pop the vmcont, the
intwinds will not be passed as a second arg. Rewind the dynamic stack
from within the VM, so that any rewinder sees valid prompt entries.
(call_cc, tail_call_cc): Adapt to pass the dynstack to
scm_i_vm_capture_stack.
(prompt, wind, unwind, wind_fluids, unwind_fluids): Adapt to the new
interfaces.
* libguile/vm.h (scm_i_capture_current_stack): Rename from
scm_i_vm_capture_continuation.
(scm_i_vm_capture_stack): Take a dynstack as an argument.
* libguile/vm.c (vm_reinstate_partial_continuation): Don't wind here, as
that could result in winders seeing invalid prompts.
* libguile/eval.c:
* libguile/root.c:
* libguile/stacks.c:
* libguile/threads.c:
* libguile/threads.h:
* libguile/throw.c: Adapt other users of dynwinds to use the dynstack.
2012-03-03 17:01:16 +01:00
|
|
|
|
scm_i_thread *thread;
|
|
|
|
|
|
SCM vm;
|
|
|
|
|
|
struct scm_vm *vp;
|
|
|
|
|
|
|
|
|
|
|
|
thread = SCM_I_CURRENT_THREAD;
|
|
|
|
|
|
vm = scm_the_vm ();
|
|
|
|
|
|
vp = SCM_VM_DATA (vm);
|
|
|
|
|
|
|
|
|
|
|
|
return scm_i_vm_capture_stack (vp->stack_base, vp->fp, vp->sp, vp->ip, NULL,
|
|
|
|
|
|
scm_dynstack_capture_all (&thread->dynstack),
|
|
|
|
|
|
0);
|
2000-08-22 15:54:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-05-23 15:07:37 +02:00
|
|
|
|
static void vm_dispatch_hook (SCM vm, int hook_num,
|
|
|
|
|
|
SCM *argv, int n) SCM_NOINLINE;
|
|
|
|
|
|
|
remove heap links in VM frames, incorporate vm frames into normal backtraces
* doc/ref/vm.texi (Stack Layout): Update to remove references to the
"heap link".
* gdbinit: Update for "heap link" removal.
* libguile/frames.c:
* libguile/frames.h: Update macros and diagram for removal of "heap
link". As part of this, we also remove "heap frames", replacing them
with "vm frames", which are much like the interpreter's debug objects,
but for VM stacks. That is to say, they don't actually hold the stack
themselves, just the pointers into stack that's held by a continuation
(either captured or current).
* libguile/stacks.c (stack_depth, read_frames): Since a "stack" object is
really a copy of information that comes from somewhere else, it makes
sense to copy over info from the VM, just as `make-stack' does from the
evaluator. The tricky bit is to figure out how to interleave VM and
interpreter frames. We do that by starting in the interpreter, and
whenever the current frame's procedure is actually a program, we switch
to the VM stack, switching back when we reach a "bootstrap frame". The
last bit is hacky, but it does work...
(is_vm_bootstrap_frame): Hacky predicate to see if a VM frame is a
bootstrap frame.
(scm_make_stack): Accept a VM frame in addition to debug frames.
Probably has some bugs in this case. But in the case that the arg is
#t (a common case), do the right thing, capturing the top VM frame as
well, and interleaving those frames appropriately on the stack.
As an accident, we lost the ability to limit the number of frames in
the backtrace. We could add that back, but personally I always want
*all* frames in the trace... Narrowing still works fine, though there
are some hiccups sometimes -- e.g. an outer cut to a procedure that
does a tail-call in VM code will never find the cut, as it no longer
exists in the continuation.
* libguile/vm.h (struct scm_vm): So! Now that we have switched to save
stacks in the normal make-stack, there's no more need for `this_frame'
or `last_frame'. On the other hand, we can take this opportunity to fix
tracing: when we're in a trace hook, we set `trace_frame' on the VM,
so we know not to fire hooks when we're already in a hook.
(struct scm_vm_cont): Expose this, as make-stack needs it to make VM
frames from VM continuations.
* libguile/vm.c (scm_vm_trace_frame): New function, gets the current
trace frame.
(vm_mark, make_vm): Hook up the trace frame.
(vm_dispatch_hook): New hook dispatcher, with a dynwind so it does the
right thing if the hook exits nonlocally.
* libguile/vm-engine.c (vm_run): No more this_frame in the wind data.
* libguile/vm-engine.h (RUN_HOOK): Run hooks through the dispatcher.
(ALIGN_AS_NON_IMMEDIATE, POP_LIST_ON_STACK): Remove unused code.
(NEW_FRAME): Adapt for no HL in the frame.
* libguile/vm-i-system.c (goto/args, mv-call, return, return/values):
Adapt for no HL in the frame.
* module/system/vm/frame.scm:
* module/system/vm/vm.scm: Beginnings of some reworkings, needs more
thought.
2008-12-26 17:59:46 +01:00
|
|
|
|
static void
|
2013-05-23 15:07:37 +02:00
|
|
|
|
vm_dispatch_hook (SCM vm, int hook_num, SCM *argv, int n)
|
remove heap links in VM frames, incorporate vm frames into normal backtraces
* doc/ref/vm.texi (Stack Layout): Update to remove references to the
"heap link".
* gdbinit: Update for "heap link" removal.
* libguile/frames.c:
* libguile/frames.h: Update macros and diagram for removal of "heap
link". As part of this, we also remove "heap frames", replacing them
with "vm frames", which are much like the interpreter's debug objects,
but for VM stacks. That is to say, they don't actually hold the stack
themselves, just the pointers into stack that's held by a continuation
(either captured or current).
* libguile/stacks.c (stack_depth, read_frames): Since a "stack" object is
really a copy of information that comes from somewhere else, it makes
sense to copy over info from the VM, just as `make-stack' does from the
evaluator. The tricky bit is to figure out how to interleave VM and
interpreter frames. We do that by starting in the interpreter, and
whenever the current frame's procedure is actually a program, we switch
to the VM stack, switching back when we reach a "bootstrap frame". The
last bit is hacky, but it does work...
(is_vm_bootstrap_frame): Hacky predicate to see if a VM frame is a
bootstrap frame.
(scm_make_stack): Accept a VM frame in addition to debug frames.
Probably has some bugs in this case. But in the case that the arg is
#t (a common case), do the right thing, capturing the top VM frame as
well, and interleaving those frames appropriately on the stack.
As an accident, we lost the ability to limit the number of frames in
the backtrace. We could add that back, but personally I always want
*all* frames in the trace... Narrowing still works fine, though there
are some hiccups sometimes -- e.g. an outer cut to a procedure that
does a tail-call in VM code will never find the cut, as it no longer
exists in the continuation.
* libguile/vm.h (struct scm_vm): So! Now that we have switched to save
stacks in the normal make-stack, there's no more need for `this_frame'
or `last_frame'. On the other hand, we can take this opportunity to fix
tracing: when we're in a trace hook, we set `trace_frame' on the VM,
so we know not to fire hooks when we're already in a hook.
(struct scm_vm_cont): Expose this, as make-stack needs it to make VM
frames from VM continuations.
* libguile/vm.c (scm_vm_trace_frame): New function, gets the current
trace frame.
(vm_mark, make_vm): Hook up the trace frame.
(vm_dispatch_hook): New hook dispatcher, with a dynwind so it does the
right thing if the hook exits nonlocally.
* libguile/vm-engine.c (vm_run): No more this_frame in the wind data.
* libguile/vm-engine.h (RUN_HOOK): Run hooks through the dispatcher.
(ALIGN_AS_NON_IMMEDIATE, POP_LIST_ON_STACK): Remove unused code.
(NEW_FRAME): Adapt for no HL in the frame.
* libguile/vm-i-system.c (goto/args, mv-call, return, return/values):
Adapt for no HL in the frame.
* module/system/vm/frame.scm:
* module/system/vm/vm.scm: Beginnings of some reworkings, needs more
thought.
2008-12-26 17:59:46 +01:00
|
|
|
|
{
|
rework vm tracing
* libguile/vm-engine.c (VM_NAME): Engines take the VM itself (not the
vp), so they can pass the VM to hooks. No more hook args, we dispatch
without them.
* libguile/vm-engine.h (RUN_HOOK): Dispatch the hook if the trace level
is positive (instead of if the hook is there). Don't cache registers
on return from the dispatch.
* libguile/vm.h:
* libguile/vm.c (vm_dispatch_hook): Don't bother with a dynwind; instead
decrement the trace level when going into a hook, and if we have a
nonlocal exit, the trace level never gets incremented again. Worse is
better.
(make_vm, scm_vm_trace_level, scm_set_vm_trace_level_x): New concept,
trace level. If positive, we run the hooks, otherwise we don't. Should
work. Removed scm_vm_trace_frame, I don't think that was the right way
to do it.
* module/system/vm/vm.scm: Replace vm-trace-frame with vm-trace-level
and set-vm-trace-level!; the hooks actually get the frame as an
argument now.
2009-12-21 21:57:20 +01:00
|
|
|
|
struct scm_vm *vp;
|
|
|
|
|
|
SCM hook;
|
2010-04-21 01:05:42 +02:00
|
|
|
|
struct scm_frame c_frame;
|
2010-09-26 16:24:35 +02:00
|
|
|
|
scm_t_cell *frame;
|
2010-09-17 10:59:36 +02:00
|
|
|
|
int saved_trace_level;
|
remove heap links in VM frames, incorporate vm frames into normal backtraces
* doc/ref/vm.texi (Stack Layout): Update to remove references to the
"heap link".
* gdbinit: Update for "heap link" removal.
* libguile/frames.c:
* libguile/frames.h: Update macros and diagram for removal of "heap
link". As part of this, we also remove "heap frames", replacing them
with "vm frames", which are much like the interpreter's debug objects,
but for VM stacks. That is to say, they don't actually hold the stack
themselves, just the pointers into stack that's held by a continuation
(either captured or current).
* libguile/stacks.c (stack_depth, read_frames): Since a "stack" object is
really a copy of information that comes from somewhere else, it makes
sense to copy over info from the VM, just as `make-stack' does from the
evaluator. The tricky bit is to figure out how to interleave VM and
interpreter frames. We do that by starting in the interpreter, and
whenever the current frame's procedure is actually a program, we switch
to the VM stack, switching back when we reach a "bootstrap frame". The
last bit is hacky, but it does work...
(is_vm_bootstrap_frame): Hacky predicate to see if a VM frame is a
bootstrap frame.
(scm_make_stack): Accept a VM frame in addition to debug frames.
Probably has some bugs in this case. But in the case that the arg is
#t (a common case), do the right thing, capturing the top VM frame as
well, and interleaving those frames appropriately on the stack.
As an accident, we lost the ability to limit the number of frames in
the backtrace. We could add that back, but personally I always want
*all* frames in the trace... Narrowing still works fine, though there
are some hiccups sometimes -- e.g. an outer cut to a procedure that
does a tail-call in VM code will never find the cut, as it no longer
exists in the continuation.
* libguile/vm.h (struct scm_vm): So! Now that we have switched to save
stacks in the normal make-stack, there's no more need for `this_frame'
or `last_frame'. On the other hand, we can take this opportunity to fix
tracing: when we're in a trace hook, we set `trace_frame' on the VM,
so we know not to fire hooks when we're already in a hook.
(struct scm_vm_cont): Expose this, as make-stack needs it to make VM
frames from VM continuations.
* libguile/vm.c (scm_vm_trace_frame): New function, gets the current
trace frame.
(vm_mark, make_vm): Hook up the trace frame.
(vm_dispatch_hook): New hook dispatcher, with a dynwind so it does the
right thing if the hook exits nonlocally.
* libguile/vm-engine.c (vm_run): No more this_frame in the wind data.
* libguile/vm-engine.h (RUN_HOOK): Run hooks through the dispatcher.
(ALIGN_AS_NON_IMMEDIATE, POP_LIST_ON_STACK): Remove unused code.
(NEW_FRAME): Adapt for no HL in the frame.
* libguile/vm-i-system.c (goto/args, mv-call, return, return/values):
Adapt for no HL in the frame.
* module/system/vm/frame.scm:
* module/system/vm/vm.scm: Beginnings of some reworkings, needs more
thought.
2008-12-26 17:59:46 +01:00
|
|
|
|
|
rework vm tracing
* libguile/vm-engine.c (VM_NAME): Engines take the VM itself (not the
vp), so they can pass the VM to hooks. No more hook args, we dispatch
without them.
* libguile/vm-engine.h (RUN_HOOK): Dispatch the hook if the trace level
is positive (instead of if the hook is there). Don't cache registers
on return from the dispatch.
* libguile/vm.h:
* libguile/vm.c (vm_dispatch_hook): Don't bother with a dynwind; instead
decrement the trace level when going into a hook, and if we have a
nonlocal exit, the trace level never gets incremented again. Worse is
better.
(make_vm, scm_vm_trace_level, scm_set_vm_trace_level_x): New concept,
trace level. If positive, we run the hooks, otherwise we don't. Should
work. Removed scm_vm_trace_frame, I don't think that was the right way
to do it.
* module/system/vm/vm.scm: Replace vm-trace-frame with vm-trace-level
and set-vm-trace-level!; the hooks actually get the frame as an
argument now.
2009-12-21 21:57:20 +01:00
|
|
|
|
vp = SCM_VM_DATA (vm);
|
|
|
|
|
|
hook = vp->hooks[hook_num];
|
remove heap links in VM frames, incorporate vm frames into normal backtraces
* doc/ref/vm.texi (Stack Layout): Update to remove references to the
"heap link".
* gdbinit: Update for "heap link" removal.
* libguile/frames.c:
* libguile/frames.h: Update macros and diagram for removal of "heap
link". As part of this, we also remove "heap frames", replacing them
with "vm frames", which are much like the interpreter's debug objects,
but for VM stacks. That is to say, they don't actually hold the stack
themselves, just the pointers into stack that's held by a continuation
(either captured or current).
* libguile/stacks.c (stack_depth, read_frames): Since a "stack" object is
really a copy of information that comes from somewhere else, it makes
sense to copy over info from the VM, just as `make-stack' does from the
evaluator. The tricky bit is to figure out how to interleave VM and
interpreter frames. We do that by starting in the interpreter, and
whenever the current frame's procedure is actually a program, we switch
to the VM stack, switching back when we reach a "bootstrap frame". The
last bit is hacky, but it does work...
(is_vm_bootstrap_frame): Hacky predicate to see if a VM frame is a
bootstrap frame.
(scm_make_stack): Accept a VM frame in addition to debug frames.
Probably has some bugs in this case. But in the case that the arg is
#t (a common case), do the right thing, capturing the top VM frame as
well, and interleaving those frames appropriately on the stack.
As an accident, we lost the ability to limit the number of frames in
the backtrace. We could add that back, but personally I always want
*all* frames in the trace... Narrowing still works fine, though there
are some hiccups sometimes -- e.g. an outer cut to a procedure that
does a tail-call in VM code will never find the cut, as it no longer
exists in the continuation.
* libguile/vm.h (struct scm_vm): So! Now that we have switched to save
stacks in the normal make-stack, there's no more need for `this_frame'
or `last_frame'. On the other hand, we can take this opportunity to fix
tracing: when we're in a trace hook, we set `trace_frame' on the VM,
so we know not to fire hooks when we're already in a hook.
(struct scm_vm_cont): Expose this, as make-stack needs it to make VM
frames from VM continuations.
* libguile/vm.c (scm_vm_trace_frame): New function, gets the current
trace frame.
(vm_mark, make_vm): Hook up the trace frame.
(vm_dispatch_hook): New hook dispatcher, with a dynwind so it does the
right thing if the hook exits nonlocally.
* libguile/vm-engine.c (vm_run): No more this_frame in the wind data.
* libguile/vm-engine.h (RUN_HOOK): Run hooks through the dispatcher.
(ALIGN_AS_NON_IMMEDIATE, POP_LIST_ON_STACK): Remove unused code.
(NEW_FRAME): Adapt for no HL in the frame.
* libguile/vm-i-system.c (goto/args, mv-call, return, return/values):
Adapt for no HL in the frame.
* module/system/vm/frame.scm:
* module/system/vm/vm.scm: Beginnings of some reworkings, needs more
thought.
2008-12-26 17:59:46 +01:00
|
|
|
|
|
rework vm tracing
* libguile/vm-engine.c (VM_NAME): Engines take the VM itself (not the
vp), so they can pass the VM to hooks. No more hook args, we dispatch
without them.
* libguile/vm-engine.h (RUN_HOOK): Dispatch the hook if the trace level
is positive (instead of if the hook is there). Don't cache registers
on return from the dispatch.
* libguile/vm.h:
* libguile/vm.c (vm_dispatch_hook): Don't bother with a dynwind; instead
decrement the trace level when going into a hook, and if we have a
nonlocal exit, the trace level never gets incremented again. Worse is
better.
(make_vm, scm_vm_trace_level, scm_set_vm_trace_level_x): New concept,
trace level. If positive, we run the hooks, otherwise we don't. Should
work. Removed scm_vm_trace_frame, I don't think that was the right way
to do it.
* module/system/vm/vm.scm: Replace vm-trace-frame with vm-trace-level
and set-vm-trace-level!; the hooks actually get the frame as an
argument now.
2009-12-21 21:57:20 +01:00
|
|
|
|
if (SCM_LIKELY (scm_is_false (hook))
|
|
|
|
|
|
|| scm_is_null (SCM_HOOK_PROCEDURES (hook)))
|
|
|
|
|
|
return;
|
2010-04-21 01:05:42 +02:00
|
|
|
|
|
2010-09-17 10:59:36 +02:00
|
|
|
|
saved_trace_level = vp->trace_level;
|
|
|
|
|
|
vp->trace_level = 0;
|
2010-04-21 01:05:42 +02:00
|
|
|
|
|
|
|
|
|
|
/* Allocate a frame object on the stack. This is more efficient than calling
|
|
|
|
|
|
`scm_c_make_frame ()' to allocate on the heap, but it forces hooks to not
|
|
|
|
|
|
capture frame objects.
|
|
|
|
|
|
|
|
|
|
|
|
At the same time, procedures such as `frame-procedure' make sense only
|
|
|
|
|
|
while the stack frame represented by the frame object is visible, so it
|
|
|
|
|
|
seems reasonable to limit the lifetime of frame objects. */
|
|
|
|
|
|
|
|
|
|
|
|
c_frame.stack_holder = vm;
|
|
|
|
|
|
c_frame.fp = vp->fp;
|
|
|
|
|
|
c_frame.sp = vp->sp;
|
|
|
|
|
|
c_frame.ip = vp->ip;
|
|
|
|
|
|
c_frame.offset = 0;
|
2010-09-26 16:24:35 +02:00
|
|
|
|
|
|
|
|
|
|
/* Arrange for FRAME to be 8-byte aligned, like any other cell. */
|
|
|
|
|
|
frame = alloca (sizeof (*frame) + 8);
|
|
|
|
|
|
frame = (scm_t_cell *) ROUND_UP ((scm_t_uintptr) frame, 8UL);
|
|
|
|
|
|
|
|
|
|
|
|
frame->word_0 = SCM_PACK (scm_tc7_frame);
|
2011-10-24 17:58:22 +02:00
|
|
|
|
frame->word_1 = SCM_PACK_POINTER (&c_frame);
|
2010-04-21 01:05:42 +02:00
|
|
|
|
|
2013-05-23 15:07:37 +02:00
|
|
|
|
if (n == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM args[1];
|
|
|
|
|
|
|
|
|
|
|
|
args[0] = SCM_PACK_POINTER (frame);
|
|
|
|
|
|
scm_c_run_hookn (hook, args, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (n == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM args[2];
|
|
|
|
|
|
|
|
|
|
|
|
args[0] = SCM_PACK_POINTER (frame);
|
|
|
|
|
|
args[1] = argv[0];
|
|
|
|
|
|
scm_c_run_hookn (hook, args, 2);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM args = SCM_EOL;
|
|
|
|
|
|
|
|
|
|
|
|
while (n--)
|
|
|
|
|
|
args = scm_cons (argv[n], args);
|
|
|
|
|
|
scm_c_run_hook (hook, scm_cons (SCM_PACK_POINTER (frame), args));
|
|
|
|
|
|
}
|
2010-04-21 01:05:42 +02:00
|
|
|
|
|
2010-09-17 10:59:36 +02:00
|
|
|
|
vp->trace_level = saved_trace_level;
|
remove heap links in VM frames, incorporate vm frames into normal backtraces
* doc/ref/vm.texi (Stack Layout): Update to remove references to the
"heap link".
* gdbinit: Update for "heap link" removal.
* libguile/frames.c:
* libguile/frames.h: Update macros and diagram for removal of "heap
link". As part of this, we also remove "heap frames", replacing them
with "vm frames", which are much like the interpreter's debug objects,
but for VM stacks. That is to say, they don't actually hold the stack
themselves, just the pointers into stack that's held by a continuation
(either captured or current).
* libguile/stacks.c (stack_depth, read_frames): Since a "stack" object is
really a copy of information that comes from somewhere else, it makes
sense to copy over info from the VM, just as `make-stack' does from the
evaluator. The tricky bit is to figure out how to interleave VM and
interpreter frames. We do that by starting in the interpreter, and
whenever the current frame's procedure is actually a program, we switch
to the VM stack, switching back when we reach a "bootstrap frame". The
last bit is hacky, but it does work...
(is_vm_bootstrap_frame): Hacky predicate to see if a VM frame is a
bootstrap frame.
(scm_make_stack): Accept a VM frame in addition to debug frames.
Probably has some bugs in this case. But in the case that the arg is
#t (a common case), do the right thing, capturing the top VM frame as
well, and interleaving those frames appropriately on the stack.
As an accident, we lost the ability to limit the number of frames in
the backtrace. We could add that back, but personally I always want
*all* frames in the trace... Narrowing still works fine, though there
are some hiccups sometimes -- e.g. an outer cut to a procedure that
does a tail-call in VM code will never find the cut, as it no longer
exists in the continuation.
* libguile/vm.h (struct scm_vm): So! Now that we have switched to save
stacks in the normal make-stack, there's no more need for `this_frame'
or `last_frame'. On the other hand, we can take this opportunity to fix
tracing: when we're in a trace hook, we set `trace_frame' on the VM,
so we know not to fire hooks when we're already in a hook.
(struct scm_vm_cont): Expose this, as make-stack needs it to make VM
frames from VM continuations.
* libguile/vm.c (scm_vm_trace_frame): New function, gets the current
trace frame.
(vm_mark, make_vm): Hook up the trace frame.
(vm_dispatch_hook): New hook dispatcher, with a dynwind so it does the
right thing if the hook exits nonlocally.
* libguile/vm-engine.c (vm_run): No more this_frame in the wind data.
* libguile/vm-engine.h (RUN_HOOK): Run hooks through the dispatcher.
(ALIGN_AS_NON_IMMEDIATE, POP_LIST_ON_STACK): Remove unused code.
(NEW_FRAME): Adapt for no HL in the frame.
* libguile/vm-i-system.c (goto/args, mv-call, return, return/values):
Adapt for no HL in the frame.
* module/system/vm/frame.scm:
* module/system/vm/vm.scm: Beginnings of some reworkings, needs more
thought.
2008-12-26 17:59:46 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2010-01-30 15:45:37 +01:00
|
|
|
|
static void
|
dynstack: pushing a prompt no longer allocates memory
* libguile/control.h: Remove scm_t_prompt_registers and
scm_c_make_prompt_registers.
(scm_c_abort): Take a pointer to a jmpbuf instead of a cookie. It
will serve the same purpose.
* libguile/control.c (reify_partial_continuation, scm_at_abort): Adapt
to new prompt representation.
* libguile/dynstack.h:
* libguile/dynstack.c (scm_dynstack_push_prompt): Prompts now have 5
words instead of 2, as they now push the fp, sp, ip, and jmpbuf on the
stack separately. This avoids allocation.
(scm_dynstack_find_prompt): Likewise, add return values for fp, sp,
etc.
(scm_dynstack_wind_prompt): Replaces scm_dynstack_relocate_prompt.
* libguile/eval.c (eval):
* libguile/stacks.c (find_prompt):
* libguile/throw.c (pre_init_catch): Adapt to the new prompt mechanism.
* libguile/vm-engine.c (vm_engine): Setjmp an on-stack jmpbuf every time
the VM enters. We can then re-use that jmpbuf for all prompts in that
invocation.
* libguile/vm-i-system.c (partial_cont_call): Adapt to change in prompt
representation. We don't need to wind here any more, since we pass in
the prompt's jmpbuf.
(prompt): Adapt to scm_dynstack_push_prompt change.
(abort): Adapt to vm_abort change.
* libguile/vm.h (struct scm_vm): No more cookie.
* libguile/vm.c (vm_abort): Adapt to scm_c_abort change.
(vm_reinstate_partial_continuation): Rewind the dynamic stack here,
now that we do have a valid jmpbuf.
(make_vm): No need to initialize a cookie.
2012-03-07 10:27:16 +01:00
|
|
|
|
vm_abort (SCM vm, size_t n, scm_i_jmp_buf *current_registers) SCM_NORETURN;
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
vm_abort (SCM vm, size_t n, scm_i_jmp_buf *current_registers)
|
2010-01-30 15:45:37 +01:00
|
|
|
|
{
|
2010-02-19 16:55:36 +01:00
|
|
|
|
size_t i;
|
abort always dispatches to VM bytecode, to detect same-invocation aborts
* libguile/control.h:
* libguile/control.c (scm_c_make_prompt): Take an extra arg, a cookie.
Continuations will be rewindable only if the abort has the same cookie
as the prompt.
(scm_at_abort): Redefine from scm_abort, and instead of taking rest
args, take the abort values as a list directly. Also, don't allow
rewinding, because we won't support rewinding the C stack with
delimited continuations.
* libguile/eval.c (eval): Adapt to scm_c_make_prompt change.
* libguile/vm-engine.c (vm_engine): Use vp->cookie to get a unique value
corresponding to this VM invocation.
* libguile/vm-i-system.c (prompt): Pass the cookie to scm_c_make_prompt.
(abort): Take an additional tail arg.
* libguile/vm.c (vm_abort): Parse out the abort tail arg. This is for
the @abort case, or the (apply abort ...) case.
(make_vm): Initialize the cookie to 0.
* libguile/vm.h (struct scm_vm): Add cookie.
* module/ice-9/boot-9.scm (abort): Define here as a trampoline to
@abort. Needed to make sure that a call to abort dispatches to a VM
opcode, so the cookie will be the same.
* module/language/tree-il.scm (<tree-il>): Add a "tail" field to
<abort>, for the (apply abort ...) case, or (@abort tag args). Should
be #<const ()> in the normal case. Add support throughout.
* module/language/tree-il/analyze.scm (analyze-lexicals): Add abort-tail
support here too.
* module/language/tree-il/compile-glil.scm (flatten): Compile the tail
argument appropriately.
* module/language/tree-il/primitives.scm (*primitive-expand-table*): Fix
@abort and abort cases to pass the tail arg to make-abort.
2010-02-22 21:53:24 +01:00
|
|
|
|
ssize_t tail_len;
|
|
|
|
|
|
SCM tag, tail, *argv;
|
2010-02-19 16:55:36 +01:00
|
|
|
|
|
abort always dispatches to VM bytecode, to detect same-invocation aborts
* libguile/control.h:
* libguile/control.c (scm_c_make_prompt): Take an extra arg, a cookie.
Continuations will be rewindable only if the abort has the same cookie
as the prompt.
(scm_at_abort): Redefine from scm_abort, and instead of taking rest
args, take the abort values as a list directly. Also, don't allow
rewinding, because we won't support rewinding the C stack with
delimited continuations.
* libguile/eval.c (eval): Adapt to scm_c_make_prompt change.
* libguile/vm-engine.c (vm_engine): Use vp->cookie to get a unique value
corresponding to this VM invocation.
* libguile/vm-i-system.c (prompt): Pass the cookie to scm_c_make_prompt.
(abort): Take an additional tail arg.
* libguile/vm.c (vm_abort): Parse out the abort tail arg. This is for
the @abort case, or the (apply abort ...) case.
(make_vm): Initialize the cookie to 0.
* libguile/vm.h (struct scm_vm): Add cookie.
* module/ice-9/boot-9.scm (abort): Define here as a trampoline to
@abort. Needed to make sure that a call to abort dispatches to a VM
opcode, so the cookie will be the same.
* module/language/tree-il.scm (<tree-il>): Add a "tail" field to
<abort>, for the (apply abort ...) case, or (@abort tag args). Should
be #<const ()> in the normal case. Add support throughout.
* module/language/tree-il/analyze.scm (analyze-lexicals): Add abort-tail
support here too.
* module/language/tree-il/compile-glil.scm (flatten): Compile the tail
argument appropriately.
* module/language/tree-il/primitives.scm (*primitive-expand-table*): Fix
@abort and abort cases to pass the tail arg to make-abort.
2010-02-22 21:53:24 +01:00
|
|
|
|
/* FIXME: VM_ENABLE_STACK_NULLING */
|
|
|
|
|
|
tail = *(SCM_VM_DATA (vm)->sp--);
|
|
|
|
|
|
/* NULLSTACK (1) */
|
|
|
|
|
|
tail_len = scm_ilength (tail);
|
|
|
|
|
|
if (tail_len < 0)
|
2010-02-24 18:51:25 +01:00
|
|
|
|
scm_misc_error ("vm-engine", "tail values to abort should be a list",
|
|
|
|
|
|
scm_list_1 (tail));
|
|
|
|
|
|
|
2010-02-19 16:55:36 +01:00
|
|
|
|
tag = SCM_VM_DATA (vm)->sp[-n];
|
abort always dispatches to VM bytecode, to detect same-invocation aborts
* libguile/control.h:
* libguile/control.c (scm_c_make_prompt): Take an extra arg, a cookie.
Continuations will be rewindable only if the abort has the same cookie
as the prompt.
(scm_at_abort): Redefine from scm_abort, and instead of taking rest
args, take the abort values as a list directly. Also, don't allow
rewinding, because we won't support rewinding the C stack with
delimited continuations.
* libguile/eval.c (eval): Adapt to scm_c_make_prompt change.
* libguile/vm-engine.c (vm_engine): Use vp->cookie to get a unique value
corresponding to this VM invocation.
* libguile/vm-i-system.c (prompt): Pass the cookie to scm_c_make_prompt.
(abort): Take an additional tail arg.
* libguile/vm.c (vm_abort): Parse out the abort tail arg. This is for
the @abort case, or the (apply abort ...) case.
(make_vm): Initialize the cookie to 0.
* libguile/vm.h (struct scm_vm): Add cookie.
* module/ice-9/boot-9.scm (abort): Define here as a trampoline to
@abort. Needed to make sure that a call to abort dispatches to a VM
opcode, so the cookie will be the same.
* module/language/tree-il.scm (<tree-il>): Add a "tail" field to
<abort>, for the (apply abort ...) case, or (@abort tag args). Should
be #<const ()> in the normal case. Add support throughout.
* module/language/tree-il/analyze.scm (analyze-lexicals): Add abort-tail
support here too.
* module/language/tree-il/compile-glil.scm (flatten): Compile the tail
argument appropriately.
* module/language/tree-il/primitives.scm (*primitive-expand-table*): Fix
@abort and abort cases to pass the tail arg to make-abort.
2010-02-22 21:53:24 +01:00
|
|
|
|
argv = alloca ((n + tail_len) * sizeof (SCM));
|
2010-02-19 16:55:36 +01:00
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
|
|
argv[i] = SCM_VM_DATA (vm)->sp[-(n-1-i)];
|
abort always dispatches to VM bytecode, to detect same-invocation aborts
* libguile/control.h:
* libguile/control.c (scm_c_make_prompt): Take an extra arg, a cookie.
Continuations will be rewindable only if the abort has the same cookie
as the prompt.
(scm_at_abort): Redefine from scm_abort, and instead of taking rest
args, take the abort values as a list directly. Also, don't allow
rewinding, because we won't support rewinding the C stack with
delimited continuations.
* libguile/eval.c (eval): Adapt to scm_c_make_prompt change.
* libguile/vm-engine.c (vm_engine): Use vp->cookie to get a unique value
corresponding to this VM invocation.
* libguile/vm-i-system.c (prompt): Pass the cookie to scm_c_make_prompt.
(abort): Take an additional tail arg.
* libguile/vm.c (vm_abort): Parse out the abort tail arg. This is for
the @abort case, or the (apply abort ...) case.
(make_vm): Initialize the cookie to 0.
* libguile/vm.h (struct scm_vm): Add cookie.
* module/ice-9/boot-9.scm (abort): Define here as a trampoline to
@abort. Needed to make sure that a call to abort dispatches to a VM
opcode, so the cookie will be the same.
* module/language/tree-il.scm (<tree-il>): Add a "tail" field to
<abort>, for the (apply abort ...) case, or (@abort tag args). Should
be #<const ()> in the normal case. Add support throughout.
* module/language/tree-il/analyze.scm (analyze-lexicals): Add abort-tail
support here too.
* module/language/tree-il/compile-glil.scm (flatten): Compile the tail
argument appropriately.
* module/language/tree-il/primitives.scm (*primitive-expand-table*): Fix
@abort and abort cases to pass the tail arg to make-abort.
2010-02-22 21:53:24 +01:00
|
|
|
|
for (; i < n + tail_len; i++, tail = scm_cdr (tail))
|
|
|
|
|
|
argv[i] = scm_car (tail);
|
|
|
|
|
|
/* NULLSTACK (n + 1) */
|
2010-02-19 16:55:36 +01:00
|
|
|
|
SCM_VM_DATA (vm)->sp -= n + 1;
|
|
|
|
|
|
|
dynstack: pushing a prompt no longer allocates memory
* libguile/control.h: Remove scm_t_prompt_registers and
scm_c_make_prompt_registers.
(scm_c_abort): Take a pointer to a jmpbuf instead of a cookie. It
will serve the same purpose.
* libguile/control.c (reify_partial_continuation, scm_at_abort): Adapt
to new prompt representation.
* libguile/dynstack.h:
* libguile/dynstack.c (scm_dynstack_push_prompt): Prompts now have 5
words instead of 2, as they now push the fp, sp, ip, and jmpbuf on the
stack separately. This avoids allocation.
(scm_dynstack_find_prompt): Likewise, add return values for fp, sp,
etc.
(scm_dynstack_wind_prompt): Replaces scm_dynstack_relocate_prompt.
* libguile/eval.c (eval):
* libguile/stacks.c (find_prompt):
* libguile/throw.c (pre_init_catch): Adapt to the new prompt mechanism.
* libguile/vm-engine.c (vm_engine): Setjmp an on-stack jmpbuf every time
the VM enters. We can then re-use that jmpbuf for all prompts in that
invocation.
* libguile/vm-i-system.c (partial_cont_call): Adapt to change in prompt
representation. We don't need to wind here any more, since we pass in
the prompt's jmpbuf.
(prompt): Adapt to scm_dynstack_push_prompt change.
(abort): Adapt to vm_abort change.
* libguile/vm.h (struct scm_vm): No more cookie.
* libguile/vm.c (vm_abort): Adapt to scm_c_abort change.
(vm_reinstate_partial_continuation): Rewind the dynamic stack here,
now that we do have a valid jmpbuf.
(make_vm): No need to initialize a cookie.
2012-03-07 10:27:16 +01:00
|
|
|
|
scm_c_abort (vm, tag, n + tail_len, argv, current_registers);
|
2010-02-22 23:00:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
dynstack: pushing a prompt no longer allocates memory
* libguile/control.h: Remove scm_t_prompt_registers and
scm_c_make_prompt_registers.
(scm_c_abort): Take a pointer to a jmpbuf instead of a cookie. It
will serve the same purpose.
* libguile/control.c (reify_partial_continuation, scm_at_abort): Adapt
to new prompt representation.
* libguile/dynstack.h:
* libguile/dynstack.c (scm_dynstack_push_prompt): Prompts now have 5
words instead of 2, as they now push the fp, sp, ip, and jmpbuf on the
stack separately. This avoids allocation.
(scm_dynstack_find_prompt): Likewise, add return values for fp, sp,
etc.
(scm_dynstack_wind_prompt): Replaces scm_dynstack_relocate_prompt.
* libguile/eval.c (eval):
* libguile/stacks.c (find_prompt):
* libguile/throw.c (pre_init_catch): Adapt to the new prompt mechanism.
* libguile/vm-engine.c (vm_engine): Setjmp an on-stack jmpbuf every time
the VM enters. We can then re-use that jmpbuf for all prompts in that
invocation.
* libguile/vm-i-system.c (partial_cont_call): Adapt to change in prompt
representation. We don't need to wind here any more, since we pass in
the prompt's jmpbuf.
(prompt): Adapt to scm_dynstack_push_prompt change.
(abort): Adapt to vm_abort change.
* libguile/vm.h (struct scm_vm): No more cookie.
* libguile/vm.c (vm_abort): Adapt to scm_c_abort change.
(vm_reinstate_partial_continuation): Rewind the dynamic stack here,
now that we do have a valid jmpbuf.
(make_vm): No need to initialize a cookie.
2012-03-07 10:27:16 +01:00
|
|
|
|
static void
|
|
|
|
|
|
vm_reinstate_partial_continuation (SCM vm, SCM cont, size_t n, SCM *argv,
|
|
|
|
|
|
scm_t_dynstack *dynstack,
|
|
|
|
|
|
scm_i_jmp_buf *registers)
|
2010-02-22 23:00:19 +01:00
|
|
|
|
{
|
2010-02-24 16:56:45 +01:00
|
|
|
|
struct scm_vm *vp;
|
|
|
|
|
|
struct scm_vm_cont *cp;
|
|
|
|
|
|
SCM *argv_copy, *base;
|
the dynamic stack is really a stack now, instead of a list
* libguile/dynstack.h:
* libguile/dynstack.c: New files, implementing the dynamic stack as a
true stack instead of a linked list. This lowers the cost of
dynwinds: frames, winders, prompts, with-fluids, and dynamic-wind.
For the most part, we allocate these items directly on the stack.
* libguile/dynwinds.h:
* libguile/dynwinds.c: Adapt all manipulators of the wind stack to use
interfaces from dynstack.c. Remove heap-allocated winder and frame
object types.
(scm_dowinds, scm_i_dowinds): Remove these. The first was exported,
but it was not a public interface.
* libguile/continuations.c:
* libguile/continuations.h (scm_t_contregs): Continuation objects
reference scm_t_dynstack* values now. Adapt to the new interfaces.
* libguile/control.c:
* libguile/control.h: There is no longer a scm_tc7_prompt kind of object
that can be allocated on the heap. Instead, the prompt flags, key,
and registers are pushed on the dynwind stack. (The registers are
still on the heap.) Also, since the vm_cont will reference the
dynwinds, make the partial continuation stub take just one extra arg,
instead of storing the intwinds separately in the object table.
* libguile/fluids.c:
* libguile/fluids.h: No more with-fluids objects; instead, the fluids go
on the dynstack. The values still have to be on the heap, though.
(scm_prepare_fluids, scm_swap_fluids): New internal functions,
replacing scm_i_make_with_fluids and scm_i_swap_with_fluids.
* libguile/print.c: Remove prompt and with-fluids printers.
* libguile/tags.h: Revert prompt and with-fluids tc7 values to what they
were before they were allocated.
* libguile/vm-i-system.c (partial_cont_call): Just pop the vmcont, the
intwinds will not be passed as a second arg. Rewind the dynamic stack
from within the VM, so that any rewinder sees valid prompt entries.
(call_cc, tail_call_cc): Adapt to pass the dynstack to
scm_i_vm_capture_stack.
(prompt, wind, unwind, wind_fluids, unwind_fluids): Adapt to the new
interfaces.
* libguile/vm.h (scm_i_capture_current_stack): Rename from
scm_i_vm_capture_continuation.
(scm_i_vm_capture_stack): Take a dynstack as an argument.
* libguile/vm.c (vm_reinstate_partial_continuation): Don't wind here, as
that could result in winders seeing invalid prompts.
* libguile/eval.c:
* libguile/root.c:
* libguile/stacks.c:
* libguile/threads.c:
* libguile/threads.h:
* libguile/throw.c: Adapt other users of dynwinds to use the dynstack.
2012-03-03 17:01:16 +01:00
|
|
|
|
scm_t_ptrdiff reloc;
|
2010-02-24 16:56:45 +01:00
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
|
|
|
|
argv_copy = alloca (n * sizeof(SCM));
|
|
|
|
|
|
memcpy (argv_copy, argv, n * sizeof(SCM));
|
|
|
|
|
|
|
|
|
|
|
|
vp = SCM_VM_DATA (vm);
|
|
|
|
|
|
cp = SCM_VM_CONT_DATA (cont);
|
|
|
|
|
|
base = SCM_FRAME_UPPER_ADDRESS (vp->fp) + 1;
|
the dynamic stack is really a stack now, instead of a list
* libguile/dynstack.h:
* libguile/dynstack.c: New files, implementing the dynamic stack as a
true stack instead of a linked list. This lowers the cost of
dynwinds: frames, winders, prompts, with-fluids, and dynamic-wind.
For the most part, we allocate these items directly on the stack.
* libguile/dynwinds.h:
* libguile/dynwinds.c: Adapt all manipulators of the wind stack to use
interfaces from dynstack.c. Remove heap-allocated winder and frame
object types.
(scm_dowinds, scm_i_dowinds): Remove these. The first was exported,
but it was not a public interface.
* libguile/continuations.c:
* libguile/continuations.h (scm_t_contregs): Continuation objects
reference scm_t_dynstack* values now. Adapt to the new interfaces.
* libguile/control.c:
* libguile/control.h: There is no longer a scm_tc7_prompt kind of object
that can be allocated on the heap. Instead, the prompt flags, key,
and registers are pushed on the dynwind stack. (The registers are
still on the heap.) Also, since the vm_cont will reference the
dynwinds, make the partial continuation stub take just one extra arg,
instead of storing the intwinds separately in the object table.
* libguile/fluids.c:
* libguile/fluids.h: No more with-fluids objects; instead, the fluids go
on the dynstack. The values still have to be on the heap, though.
(scm_prepare_fluids, scm_swap_fluids): New internal functions,
replacing scm_i_make_with_fluids and scm_i_swap_with_fluids.
* libguile/print.c: Remove prompt and with-fluids printers.
* libguile/tags.h: Revert prompt and with-fluids tc7 values to what they
were before they were allocated.
* libguile/vm-i-system.c (partial_cont_call): Just pop the vmcont, the
intwinds will not be passed as a second arg. Rewind the dynamic stack
from within the VM, so that any rewinder sees valid prompt entries.
(call_cc, tail_call_cc): Adapt to pass the dynstack to
scm_i_vm_capture_stack.
(prompt, wind, unwind, wind_fluids, unwind_fluids): Adapt to the new
interfaces.
* libguile/vm.h (scm_i_capture_current_stack): Rename from
scm_i_vm_capture_continuation.
(scm_i_vm_capture_stack): Take a dynstack as an argument.
* libguile/vm.c (vm_reinstate_partial_continuation): Don't wind here, as
that could result in winders seeing invalid prompts.
* libguile/eval.c:
* libguile/root.c:
* libguile/stacks.c:
* libguile/threads.c:
* libguile/threads.h:
* libguile/throw.c: Adapt other users of dynwinds to use the dynstack.
2012-03-03 17:01:16 +01:00
|
|
|
|
reloc = cp->reloc + (base - cp->stack_base);
|
2010-02-24 16:56:45 +01:00
|
|
|
|
|
2012-01-22 23:20:50 +01:00
|
|
|
|
#define RELOC(scm_p) \
|
the dynamic stack is really a stack now, instead of a list
* libguile/dynstack.h:
* libguile/dynstack.c: New files, implementing the dynamic stack as a
true stack instead of a linked list. This lowers the cost of
dynwinds: frames, winders, prompts, with-fluids, and dynamic-wind.
For the most part, we allocate these items directly on the stack.
* libguile/dynwinds.h:
* libguile/dynwinds.c: Adapt all manipulators of the wind stack to use
interfaces from dynstack.c. Remove heap-allocated winder and frame
object types.
(scm_dowinds, scm_i_dowinds): Remove these. The first was exported,
but it was not a public interface.
* libguile/continuations.c:
* libguile/continuations.h (scm_t_contregs): Continuation objects
reference scm_t_dynstack* values now. Adapt to the new interfaces.
* libguile/control.c:
* libguile/control.h: There is no longer a scm_tc7_prompt kind of object
that can be allocated on the heap. Instead, the prompt flags, key,
and registers are pushed on the dynwind stack. (The registers are
still on the heap.) Also, since the vm_cont will reference the
dynwinds, make the partial continuation stub take just one extra arg,
instead of storing the intwinds separately in the object table.
* libguile/fluids.c:
* libguile/fluids.h: No more with-fluids objects; instead, the fluids go
on the dynstack. The values still have to be on the heap, though.
(scm_prepare_fluids, scm_swap_fluids): New internal functions,
replacing scm_i_make_with_fluids and scm_i_swap_with_fluids.
* libguile/print.c: Remove prompt and with-fluids printers.
* libguile/tags.h: Revert prompt and with-fluids tc7 values to what they
were before they were allocated.
* libguile/vm-i-system.c (partial_cont_call): Just pop the vmcont, the
intwinds will not be passed as a second arg. Rewind the dynamic stack
from within the VM, so that any rewinder sees valid prompt entries.
(call_cc, tail_call_cc): Adapt to pass the dynstack to
scm_i_vm_capture_stack.
(prompt, wind, unwind, wind_fluids, unwind_fluids): Adapt to the new
interfaces.
* libguile/vm.h (scm_i_capture_current_stack): Rename from
scm_i_vm_capture_continuation.
(scm_i_vm_capture_stack): Take a dynstack as an argument.
* libguile/vm.c (vm_reinstate_partial_continuation): Don't wind here, as
that could result in winders seeing invalid prompts.
* libguile/eval.c:
* libguile/root.c:
* libguile/stacks.c:
* libguile/threads.c:
* libguile/threads.h:
* libguile/throw.c: Adapt other users of dynwinds to use the dynstack.
2012-03-03 17:01:16 +01:00
|
|
|
|
(((SCM *) (scm_p)) + reloc)
|
2010-02-24 16:56:45 +01:00
|
|
|
|
|
|
|
|
|
|
if ((base - vp->stack_base) + cp->stack_size + n + 1 > vp->stack_size)
|
2010-02-24 18:51:25 +01:00
|
|
|
|
scm_misc_error ("vm-engine",
|
|
|
|
|
|
"not enough space to instate partial continuation",
|
|
|
|
|
|
scm_list_2 (vm, cont));
|
2010-02-24 16:56:45 +01:00
|
|
|
|
|
|
|
|
|
|
memcpy (base, cp->stack_base, cp->stack_size * sizeof (SCM));
|
|
|
|
|
|
|
|
|
|
|
|
/* now relocate frame pointers */
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM *fp;
|
|
|
|
|
|
for (fp = RELOC (cp->fp);
|
|
|
|
|
|
SCM_FRAME_LOWER_ADDRESS (fp) > base;
|
|
|
|
|
|
fp = SCM_FRAME_DYNAMIC_LINK (fp))
|
|
|
|
|
|
SCM_FRAME_SET_DYNAMIC_LINK (fp, RELOC (SCM_FRAME_DYNAMIC_LINK (fp)));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
vp->sp = base - 1 + cp->stack_size;
|
|
|
|
|
|
vp->fp = RELOC (cp->fp);
|
|
|
|
|
|
vp->ip = cp->mvra;
|
|
|
|
|
|
|
|
|
|
|
|
/* now push args. ip is in a MV context. */
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
vp->sp++;
|
|
|
|
|
|
*vp->sp = argv_copy[i];
|
|
|
|
|
|
}
|
|
|
|
|
|
vp->sp++;
|
|
|
|
|
|
*vp->sp = scm_from_size_t (n);
|
2010-02-24 17:43:02 +01:00
|
|
|
|
|
dynstack: pushing a prompt no longer allocates memory
* libguile/control.h: Remove scm_t_prompt_registers and
scm_c_make_prompt_registers.
(scm_c_abort): Take a pointer to a jmpbuf instead of a cookie. It
will serve the same purpose.
* libguile/control.c (reify_partial_continuation, scm_at_abort): Adapt
to new prompt representation.
* libguile/dynstack.h:
* libguile/dynstack.c (scm_dynstack_push_prompt): Prompts now have 5
words instead of 2, as they now push the fp, sp, ip, and jmpbuf on the
stack separately. This avoids allocation.
(scm_dynstack_find_prompt): Likewise, add return values for fp, sp,
etc.
(scm_dynstack_wind_prompt): Replaces scm_dynstack_relocate_prompt.
* libguile/eval.c (eval):
* libguile/stacks.c (find_prompt):
* libguile/throw.c (pre_init_catch): Adapt to the new prompt mechanism.
* libguile/vm-engine.c (vm_engine): Setjmp an on-stack jmpbuf every time
the VM enters. We can then re-use that jmpbuf for all prompts in that
invocation.
* libguile/vm-i-system.c (partial_cont_call): Adapt to change in prompt
representation. We don't need to wind here any more, since we pass in
the prompt's jmpbuf.
(prompt): Adapt to scm_dynstack_push_prompt change.
(abort): Adapt to vm_abort change.
* libguile/vm.h (struct scm_vm): No more cookie.
* libguile/vm.c (vm_abort): Adapt to scm_c_abort change.
(vm_reinstate_partial_continuation): Rewind the dynamic stack here,
now that we do have a valid jmpbuf.
(make_vm): No need to initialize a cookie.
2012-03-07 10:27:16 +01:00
|
|
|
|
/* The prompt captured a slice of the dynamic stack. Here we wind
|
|
|
|
|
|
those entries onto the current thread's stack. We also have to
|
|
|
|
|
|
relocate any prompts that we see along the way. */
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_t_bits *walk;
|
|
|
|
|
|
|
|
|
|
|
|
for (walk = SCM_DYNSTACK_FIRST (cp->dynstack);
|
|
|
|
|
|
SCM_DYNSTACK_TAG (walk);
|
|
|
|
|
|
walk = SCM_DYNSTACK_NEXT (walk))
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_t_bits tag = SCM_DYNSTACK_TAG (walk);
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_DYNSTACK_TAG_TYPE (tag) == SCM_DYNSTACK_TYPE_PROMPT)
|
|
|
|
|
|
scm_dynstack_wind_prompt (dynstack, walk, reloc, registers);
|
|
|
|
|
|
else
|
|
|
|
|
|
scm_dynstack_wind_1 (dynstack, walk);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2010-02-26 13:05:25 +01:00
|
|
|
|
#undef RELOC
|
2010-01-30 15:45:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2001-04-01 05:03:41 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* VM Internal functions
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2010-01-05 19:45:56 +01:00
|
|
|
|
void
|
|
|
|
|
|
scm_i_vm_print (SCM x, SCM port, scm_print_state *pstate)
|
|
|
|
|
|
{
|
2010-04-14 23:46:41 +02:00
|
|
|
|
const struct scm_vm *vm;
|
|
|
|
|
|
|
|
|
|
|
|
vm = SCM_VM_DATA (x);
|
|
|
|
|
|
|
2011-11-08 00:36:48 +01:00
|
|
|
|
scm_puts_unlocked ("#<vm ", port);
|
2010-04-14 23:46:41 +02:00
|
|
|
|
switch (vm->engine)
|
|
|
|
|
|
{
|
|
|
|
|
|
case SCM_VM_REGULAR_ENGINE:
|
2011-11-08 00:36:48 +01:00
|
|
|
|
scm_puts_unlocked ("regular-engine ", port);
|
2010-04-14 23:46:41 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case SCM_VM_DEBUG_ENGINE:
|
2011-11-08 00:36:48 +01:00
|
|
|
|
scm_puts_unlocked ("debug-engine ", port);
|
2010-04-14 23:46:41 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
2011-11-08 00:36:48 +01:00
|
|
|
|
scm_puts_unlocked ("unknown-engine ", port);
|
2010-04-14 23:46:41 +02:00
|
|
|
|
}
|
2010-01-05 19:45:56 +01:00
|
|
|
|
scm_uintprint (SCM_UNPACK (x), 16, port);
|
2011-11-08 00:36:48 +01:00
|
|
|
|
scm_puts_unlocked (">", port);
|
2010-01-05 19:45:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2012-04-30 20:25:53 +02:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* VM Error Handling
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static void vm_error (const char *msg, SCM arg) SCM_NORETURN;
|
2012-04-30 21:34:58 +02:00
|
|
|
|
static void vm_error_bad_instruction (scm_t_uint32 inst) SCM_NORETURN SCM_NOINLINE;
|
|
|
|
|
|
static void vm_error_unbound (SCM proc, SCM sym) SCM_NORETURN SCM_NOINLINE;
|
|
|
|
|
|
static void vm_error_unbound_fluid (SCM proc, SCM fluid) SCM_NORETURN SCM_NOINLINE;
|
|
|
|
|
|
static void vm_error_not_a_variable (const char *func_name, SCM x) SCM_NORETURN SCM_NOINLINE;
|
|
|
|
|
|
static void vm_error_apply_to_non_list (SCM x) SCM_NORETURN SCM_NOINLINE;
|
|
|
|
|
|
static void vm_error_kwargs_length_not_even (SCM proc) SCM_NORETURN SCM_NOINLINE;
|
2013-07-16 01:33:27 -04:00
|
|
|
|
static void vm_error_kwargs_invalid_keyword (SCM proc, SCM obj) SCM_NORETURN SCM_NOINLINE;
|
|
|
|
|
|
static void vm_error_kwargs_unrecognized_keyword (SCM proc, SCM kw) SCM_NORETURN SCM_NOINLINE;
|
2012-04-30 21:34:58 +02:00
|
|
|
|
static void vm_error_too_many_args (int nargs) SCM_NORETURN SCM_NOINLINE;
|
|
|
|
|
|
static void vm_error_wrong_num_args (SCM proc) SCM_NORETURN SCM_NOINLINE;
|
|
|
|
|
|
static void vm_error_wrong_type_apply (SCM proc) SCM_NORETURN SCM_NOINLINE;
|
|
|
|
|
|
static void vm_error_stack_overflow (struct scm_vm *vp) SCM_NORETURN SCM_NOINLINE;
|
|
|
|
|
|
static void vm_error_stack_underflow (void) SCM_NORETURN SCM_NOINLINE;
|
|
|
|
|
|
static void vm_error_improper_list (SCM x) SCM_NORETURN SCM_NOINLINE;
|
|
|
|
|
|
static void vm_error_not_a_pair (const char *subr, SCM x) SCM_NORETURN SCM_NOINLINE;
|
|
|
|
|
|
static void vm_error_not_a_bytevector (const char *subr, SCM x) SCM_NORETURN SCM_NOINLINE;
|
|
|
|
|
|
static void vm_error_not_a_struct (const char *subr, SCM x) SCM_NORETURN SCM_NOINLINE;
|
|
|
|
|
|
static void vm_error_no_values (void) SCM_NORETURN SCM_NOINLINE;
|
|
|
|
|
|
static void vm_error_not_enough_values (void) SCM_NORETURN SCM_NOINLINE;
|
2013-10-14 16:09:43 +02:00
|
|
|
|
static void vm_error_wrong_number_of_values (scm_t_uint32 expected) SCM_NORETURN SCM_NOINLINE;
|
2012-04-30 21:34:58 +02:00
|
|
|
|
static void vm_error_continuation_not_rewindable (SCM cont) SCM_NORETURN SCM_NOINLINE;
|
|
|
|
|
|
static void vm_error_bad_wide_string_length (size_t len) SCM_NORETURN SCM_NOINLINE;
|
2012-04-30 20:25:53 +02:00
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
vm_error (const char *msg, SCM arg)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_throw (sym_vm_error,
|
|
|
|
|
|
scm_list_3 (sym_vm_run, scm_from_latin1_string (msg),
|
|
|
|
|
|
SCM_UNBNDP (arg) ? SCM_EOL : scm_list_1 (arg)));
|
|
|
|
|
|
abort(); /* not reached */
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
vm_error_bad_instruction (scm_t_uint32 inst)
|
|
|
|
|
|
{
|
|
|
|
|
|
vm_error ("VM: Bad instruction: ~s", scm_from_uint32 (inst));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
vm_error_unbound (SCM proc, SCM sym)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_error_scm (scm_misc_error_key, proc,
|
|
|
|
|
|
scm_from_latin1_string ("Unbound variable: ~s"),
|
|
|
|
|
|
scm_list_1 (sym), SCM_BOOL_F);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
vm_error_unbound_fluid (SCM proc, SCM fluid)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_error_scm (scm_misc_error_key, proc,
|
|
|
|
|
|
scm_from_latin1_string ("Unbound fluid: ~s"),
|
|
|
|
|
|
scm_list_1 (fluid), SCM_BOOL_F);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
vm_error_not_a_variable (const char *func_name, SCM x)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_error (scm_arg_type_key, func_name, "Not a variable: ~S",
|
|
|
|
|
|
scm_list_1 (x), scm_list_1 (x));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
vm_error_apply_to_non_list (SCM x)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_error (scm_arg_type_key, "apply", "Apply to non-list: ~S",
|
|
|
|
|
|
scm_list_1 (x), scm_list_1 (x));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
vm_error_kwargs_length_not_even (SCM proc)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_error_scm (sym_keyword_argument_error, proc,
|
|
|
|
|
|
scm_from_latin1_string ("Odd length of keyword argument list"),
|
|
|
|
|
|
SCM_EOL, SCM_BOOL_F);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2013-06-04 00:29:59 +02:00
|
|
|
|
vm_error_kwargs_invalid_keyword (SCM proc, SCM obj)
|
2012-04-30 20:25:53 +02:00
|
|
|
|
{
|
|
|
|
|
|
scm_error_scm (sym_keyword_argument_error, proc,
|
|
|
|
|
|
scm_from_latin1_string ("Invalid keyword"),
|
2013-06-04 00:29:59 +02:00
|
|
|
|
SCM_EOL, scm_list_1 (obj));
|
2012-04-30 20:25:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2013-06-04 00:29:59 +02:00
|
|
|
|
vm_error_kwargs_unrecognized_keyword (SCM proc, SCM kw)
|
2012-04-30 20:25:53 +02:00
|
|
|
|
{
|
|
|
|
|
|
scm_error_scm (sym_keyword_argument_error, proc,
|
|
|
|
|
|
scm_from_latin1_string ("Unrecognized keyword"),
|
2013-06-04 00:29:59 +02:00
|
|
|
|
SCM_EOL, scm_list_1 (kw));
|
2012-04-30 20:25:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
vm_error_too_many_args (int nargs)
|
|
|
|
|
|
{
|
|
|
|
|
|
vm_error ("VM: Too many arguments", scm_from_int (nargs));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
vm_error_wrong_num_args (SCM proc)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_wrong_num_args (proc);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
vm_error_wrong_type_apply (SCM proc)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_error (scm_arg_type_key, NULL, "Wrong type to apply: ~S",
|
|
|
|
|
|
scm_list_1 (proc), scm_list_1 (proc));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
vm_error_stack_overflow (struct scm_vm *vp)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (vp->stack_limit < vp->stack_base + vp->stack_size)
|
|
|
|
|
|
/* There are VM_STACK_RESERVE_SIZE bytes left. Make them available so
|
|
|
|
|
|
that `throw' below can run on this VM. */
|
|
|
|
|
|
vp->stack_limit = vp->stack_base + vp->stack_size;
|
|
|
|
|
|
else
|
|
|
|
|
|
/* There is no space left on the stack. FIXME: Do something more
|
|
|
|
|
|
sensible here! */
|
|
|
|
|
|
abort ();
|
|
|
|
|
|
vm_error ("VM: Stack overflow", SCM_UNDEFINED);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
vm_error_stack_underflow (void)
|
|
|
|
|
|
{
|
|
|
|
|
|
vm_error ("VM: Stack underflow", SCM_UNDEFINED);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
vm_error_improper_list (SCM x)
|
|
|
|
|
|
{
|
|
|
|
|
|
vm_error ("Expected a proper list, but got object with tail ~s", x);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
vm_error_not_a_pair (const char *subr, SCM x)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_wrong_type_arg_msg (subr, 1, x, "pair");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
vm_error_not_a_bytevector (const char *subr, SCM x)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_wrong_type_arg_msg (subr, 1, x, "bytevector");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
vm_error_not_a_struct (const char *subr, SCM x)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_wrong_type_arg_msg (subr, 1, x, "struct");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
vm_error_no_values (void)
|
|
|
|
|
|
{
|
|
|
|
|
|
vm_error ("Zero values returned to single-valued continuation",
|
|
|
|
|
|
SCM_UNDEFINED);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
vm_error_not_enough_values (void)
|
|
|
|
|
|
{
|
|
|
|
|
|
vm_error ("Too few values returned to continuation", SCM_UNDEFINED);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-10-14 16:09:43 +02:00
|
|
|
|
static void
|
|
|
|
|
|
vm_error_wrong_number_of_values (scm_t_uint32 expected)
|
|
|
|
|
|
{
|
|
|
|
|
|
vm_error ("Wrong number of values returned to continuation (expected ~a)",
|
|
|
|
|
|
scm_from_uint32 (expected));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2012-04-30 20:25:53 +02:00
|
|
|
|
static void
|
|
|
|
|
|
vm_error_continuation_not_rewindable (SCM cont)
|
|
|
|
|
|
{
|
|
|
|
|
|
vm_error ("Unrewindable partial continuation", cont);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
vm_error_bad_wide_string_length (size_t len)
|
|
|
|
|
|
{
|
|
|
|
|
|
vm_error ("VM: Bad wide string length: ~S", scm_from_size_t (len));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-07-26 12:56:11 +02:00
|
|
|
|
|
2012-05-10 12:43:33 +02:00
|
|
|
|
static SCM boot_continuation;
|
move module and meta inside programs' object tables
* libguile/programs.h (struct scm_program): Remove the module and meta
fields.
* libguile/programs.c (scm_c_make_program): Add a new argument, `objs'.
If it's a vector, we'll look for the module and the metadata in there,
instead of having them in the scm_program structure.
(scm_c_make_closure, program_mark, scm_program_meta)
(scm_c_program_source, scm_program_module): Adapt to the new program
representation.
* libguile/objcodes.c (scm_objcode_to_program): Pass #f as the object
table when making the program.
* libguile/vm-engine.h (CACHE_PROGRAM):
* libguile/vm-engine.c (vm_run): Rework to use the simple vector API for
getting the current object table. Call the helper,
vm_make_boot_program, to make the boot program.
* libguile/vm-i-loader.c (load-program): Set the current module and the
meta in the object vector, which we pass to scm_c_make_program.
* libguile/vm-i-system.c (toplevel-ref, toplevel-set): Adapt to the new
program representation.
* module/language/glil/compile-objcode.scm (codegen): Clarify.
2009-01-17 16:42:53 +01:00
|
|
|
|
|
2013-05-23 14:52:29 +02:00
|
|
|
|
static SCM rtl_boot_continuation;
|
|
|
|
|
|
static SCM rtl_apply;
|
|
|
|
|
|
static SCM rtl_values;
|
|
|
|
|
|
|
|
|
|
|
|
static const scm_t_uint32 rtl_boot_continuation_code[] = {
|
2013-07-20 20:05:13 +02:00
|
|
|
|
SCM_PACK_RTL_24 (scm_rtl_op_halt, 0)
|
2013-05-23 14:52:29 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static const scm_t_uint32 rtl_apply_code[] = {
|
2013-08-17 05:37:45 -04:00
|
|
|
|
SCM_PACK_RTL_24 (scm_rtl_op_tail_apply, 0) /* proc in r1, args from r2, nargs set */
|
2013-05-23 14:52:29 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static const scm_t_uint32 rtl_values_code[] = {
|
Various RTL VM and calling convention tweaks
* libguile/instructions.c (FOR_EACH_INSTRUCTION_WORD_TYPE): Allow for
five-word instructions, and for new instruction word types.
* libguile/vm-engine.c (RETURN_ONE_VALUE): Instead of returning the
value in the fixed part of the call frame, return it in the same place
multiple-value returns go: from slot 1.
(BR_ARITHMETIC): Allow arithmetic tests to be negated.
(rtl_vm_engine): Change calling convention to use the same location
for single and multiple-value returns. Renumber all instructions.
(halt, halt/values): Fold into a single instruction (halt).
(call): Take the location of the procedure instead of the location of
the call frame. Also take the number of args, and reset the sp before
jumping to the procedure, so as to indicate the number of arguments.
(call/values): Remove, as the new calling convention has RA == MVRA.
(tail-call): Require the procedure to be shuffled down already, and
take "nlocals" as an arg instead of "nargs".
(receive, receive-values): New instructions, for receiving returned
values from calls.
(return-values): Rename from return/values. Remove "values".
(alloc-frame): Rename from reserve-locals.
(reset-frame): New instruction.
(drop-locals): Remove.
(br-if-=, br-if-<, br-if-<=): Allow these instructions to be
negatable.
(br-if->, br-if->=): Remove. Probably a bad idea, given NaN.
(box-ref): Don't bother trying to do a reverse lookup -- the
toplevel-box, module-box, and resolve instructions should handle
that.
(resolve): Add arg to check that the variable is bound.
(toplevel-box, module-box): New instructions, replacing toplevel-ref,
toplevel-set, module-ref, and module-set.
* libguile/vm.c (rtl_boot_continuation_code, rtl_values_code): Adapt to
instruction set changes.
* module/Makefile.am: Make the assembler and disassembler dependent on
vm-operations.h.
* module/system/vm/assembler.scm:
* module/system/vm/disassembler.scm: Adapt to instruction changes and
new instruction word kinds.
* test-suite/tests/rtl.test: Adapt to instruction set changes.
2013-08-11 16:42:06 +02:00
|
|
|
|
SCM_PACK_RTL_24 (scm_rtl_op_return_values, 0) /* vals from r1 */
|
2013-05-23 14:52:29 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-08-22 15:54:19 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* VM
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2009-06-05 11:47:19 +02:00
|
|
|
|
static SCM
|
2012-05-28 12:25:43 +02:00
|
|
|
|
resolve_variable (SCM what, SCM module)
|
2009-06-05 11:47:19 +02:00
|
|
|
|
{
|
2009-11-25 23:46:17 +01:00
|
|
|
|
if (SCM_LIKELY (scm_is_symbol (what)))
|
2009-06-05 11:47:19 +02:00
|
|
|
|
{
|
2012-05-28 12:25:43 +02:00
|
|
|
|
if (scm_is_true (module))
|
|
|
|
|
|
return scm_module_lookup (module, what);
|
2009-06-05 11:47:19 +02:00
|
|
|
|
else
|
2012-05-23 11:46:30 +02:00
|
|
|
|
return scm_module_lookup (scm_the_root_module (), what);
|
2009-06-05 11:47:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2012-05-28 12:25:43 +02:00
|
|
|
|
SCM modname, sym, public;
|
|
|
|
|
|
|
|
|
|
|
|
modname = SCM_CAR (what);
|
|
|
|
|
|
sym = SCM_CADR (what);
|
|
|
|
|
|
public = SCM_CADDR (what);
|
|
|
|
|
|
|
|
|
|
|
|
if (scm_is_true (public))
|
|
|
|
|
|
return scm_public_lookup (modname, sym);
|
|
|
|
|
|
else
|
|
|
|
|
|
return scm_private_lookup (modname, sym);
|
2009-06-05 11:47:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2012-12-12 17:37:44 +01:00
|
|
|
|
#define VM_MIN_STACK_SIZE (1024)
|
2009-07-24 12:05:54 +02:00
|
|
|
|
#define VM_DEFAULT_STACK_SIZE (64 * 1024)
|
2012-12-12 17:37:44 +01:00
|
|
|
|
static size_t vm_stack_size = VM_DEFAULT_STACK_SIZE;
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
initialize_default_stack_size (void)
|
|
|
|
|
|
{
|
|
|
|
|
|
int size = scm_getenv_int ("GUILE_STACK_SIZE", vm_stack_size);
|
|
|
|
|
|
if (size >= VM_MIN_STACK_SIZE)
|
|
|
|
|
|
vm_stack_size = size;
|
|
|
|
|
|
}
|
2001-04-01 05:03:41 +00:00
|
|
|
|
|
|
|
|
|
|
#define VM_NAME vm_regular_engine
|
2013-05-23 14:52:29 +02:00
|
|
|
|
#define RTL_VM_NAME rtl_vm_regular_engine
|
enable multiple vm engines (regular, debug, ...)
* libguile/vm-engine.c (VM_USE_HOOKS, VM_USE_CLOCK, VM_CHECK_EXTERNAL)
(VM_CHECK_OBJECT): Update to define these here, before including
vm-engine.h.
(vm_run): Change so that we can make different engines. Also, we take
an array of arguments, and the struct scm_vm directly, so as to avoid
any need to cons.
* libguile/vm-engine.h (CHECK_EXTERNAL, CHECK_OBJECT): Add some UNLIKELY
bits; don't seem to help.
* libguile/vm.c (vm_dispatch_hook): Change to not pass the VP. This needs
some love, and perhaps we revert to the old way.
(VM_ENGINE): Actually make two engines, vm_regular_engine and
vm_debug_engine. Probably there is room for improvement here. Actually
their speeds are the same at the moment.
(make_vm): Choose which engine to run; currently the debug engine by
default.
(scm_c_vm_run): A thin wrapper to invoke a VM without consing.
(scm_vm_apply): Use scm_c_vm_run.
(scm_load_compiled_with_vm): Use scm_c_vm_run.
2009-02-04 23:47:56 +01:00
|
|
|
|
#define FUNC_NAME "vm-regular-engine"
|
|
|
|
|
|
#define VM_ENGINE SCM_VM_REGULAR_ENGINE
|
2008-08-21 18:39:30 -07:00
|
|
|
|
#include "vm-engine.c"
|
2001-04-01 05:03:41 +00:00
|
|
|
|
#undef VM_NAME
|
2013-05-23 14:52:29 +02:00
|
|
|
|
#undef RTL_VM_NAME
|
enable multiple vm engines (regular, debug, ...)
* libguile/vm-engine.c (VM_USE_HOOKS, VM_USE_CLOCK, VM_CHECK_EXTERNAL)
(VM_CHECK_OBJECT): Update to define these here, before including
vm-engine.h.
(vm_run): Change so that we can make different engines. Also, we take
an array of arguments, and the struct scm_vm directly, so as to avoid
any need to cons.
* libguile/vm-engine.h (CHECK_EXTERNAL, CHECK_OBJECT): Add some UNLIKELY
bits; don't seem to help.
* libguile/vm.c (vm_dispatch_hook): Change to not pass the VP. This needs
some love, and perhaps we revert to the old way.
(VM_ENGINE): Actually make two engines, vm_regular_engine and
vm_debug_engine. Probably there is room for improvement here. Actually
their speeds are the same at the moment.
(make_vm): Choose which engine to run; currently the debug engine by
default.
(scm_c_vm_run): A thin wrapper to invoke a VM without consing.
(scm_vm_apply): Use scm_c_vm_run.
(scm_load_compiled_with_vm): Use scm_c_vm_run.
2009-02-04 23:47:56 +01:00
|
|
|
|
#undef FUNC_NAME
|
2001-04-01 05:03:41 +00:00
|
|
|
|
#undef VM_ENGINE
|
|
|
|
|
|
|
|
|
|
|
|
#define VM_NAME vm_debug_engine
|
2013-05-23 14:52:29 +02:00
|
|
|
|
#define RTL_VM_NAME rtl_vm_debug_engine
|
enable multiple vm engines (regular, debug, ...)
* libguile/vm-engine.c (VM_USE_HOOKS, VM_USE_CLOCK, VM_CHECK_EXTERNAL)
(VM_CHECK_OBJECT): Update to define these here, before including
vm-engine.h.
(vm_run): Change so that we can make different engines. Also, we take
an array of arguments, and the struct scm_vm directly, so as to avoid
any need to cons.
* libguile/vm-engine.h (CHECK_EXTERNAL, CHECK_OBJECT): Add some UNLIKELY
bits; don't seem to help.
* libguile/vm.c (vm_dispatch_hook): Change to not pass the VP. This needs
some love, and perhaps we revert to the old way.
(VM_ENGINE): Actually make two engines, vm_regular_engine and
vm_debug_engine. Probably there is room for improvement here. Actually
their speeds are the same at the moment.
(make_vm): Choose which engine to run; currently the debug engine by
default.
(scm_c_vm_run): A thin wrapper to invoke a VM without consing.
(scm_vm_apply): Use scm_c_vm_run.
(scm_load_compiled_with_vm): Use scm_c_vm_run.
2009-02-04 23:47:56 +01:00
|
|
|
|
#define FUNC_NAME "vm-debug-engine"
|
|
|
|
|
|
#define VM_ENGINE SCM_VM_DEBUG_ENGINE
|
2008-08-21 18:39:30 -07:00
|
|
|
|
#include "vm-engine.c"
|
2001-04-01 05:03:41 +00:00
|
|
|
|
#undef VM_NAME
|
2013-05-23 14:52:29 +02:00
|
|
|
|
#undef RTL_VM_NAME
|
enable multiple vm engines (regular, debug, ...)
* libguile/vm-engine.c (VM_USE_HOOKS, VM_USE_CLOCK, VM_CHECK_EXTERNAL)
(VM_CHECK_OBJECT): Update to define these here, before including
vm-engine.h.
(vm_run): Change so that we can make different engines. Also, we take
an array of arguments, and the struct scm_vm directly, so as to avoid
any need to cons.
* libguile/vm-engine.h (CHECK_EXTERNAL, CHECK_OBJECT): Add some UNLIKELY
bits; don't seem to help.
* libguile/vm.c (vm_dispatch_hook): Change to not pass the VP. This needs
some love, and perhaps we revert to the old way.
(VM_ENGINE): Actually make two engines, vm_regular_engine and
vm_debug_engine. Probably there is room for improvement here. Actually
their speeds are the same at the moment.
(make_vm): Choose which engine to run; currently the debug engine by
default.
(scm_c_vm_run): A thin wrapper to invoke a VM without consing.
(scm_vm_apply): Use scm_c_vm_run.
(scm_load_compiled_with_vm): Use scm_c_vm_run.
2009-02-04 23:47:56 +01:00
|
|
|
|
#undef FUNC_NAME
|
2001-04-01 05:03:41 +00:00
|
|
|
|
#undef VM_ENGINE
|
|
|
|
|
|
|
enable multiple vm engines (regular, debug, ...)
* libguile/vm-engine.c (VM_USE_HOOKS, VM_USE_CLOCK, VM_CHECK_EXTERNAL)
(VM_CHECK_OBJECT): Update to define these here, before including
vm-engine.h.
(vm_run): Change so that we can make different engines. Also, we take
an array of arguments, and the struct scm_vm directly, so as to avoid
any need to cons.
* libguile/vm-engine.h (CHECK_EXTERNAL, CHECK_OBJECT): Add some UNLIKELY
bits; don't seem to help.
* libguile/vm.c (vm_dispatch_hook): Change to not pass the VP. This needs
some love, and perhaps we revert to the old way.
(VM_ENGINE): Actually make two engines, vm_regular_engine and
vm_debug_engine. Probably there is room for improvement here. Actually
their speeds are the same at the moment.
(make_vm): Choose which engine to run; currently the debug engine by
default.
(scm_c_vm_run): A thin wrapper to invoke a VM without consing.
(scm_vm_apply): Use scm_c_vm_run.
(scm_load_compiled_with_vm): Use scm_c_vm_run.
2009-02-04 23:47:56 +01:00
|
|
|
|
static const scm_t_vm_engine vm_engines[] =
|
|
|
|
|
|
{ vm_regular_engine, vm_debug_engine };
|
|
|
|
|
|
|
2009-08-20 01:56:47 +02:00
|
|
|
|
#ifdef VM_ENABLE_PRECISE_STACK_GC_SCAN
|
|
|
|
|
|
|
|
|
|
|
|
/* The GC "kind" for the VM stack. */
|
|
|
|
|
|
static int vm_stack_gc_kind;
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2000-08-22 15:54:19 +00:00
|
|
|
|
static SCM
|
2001-04-01 05:03:41 +00:00
|
|
|
|
make_vm (void)
|
|
|
|
|
|
#define FUNC_NAME "make_vm"
|
2000-08-22 15:54:19 +00:00
|
|
|
|
{
|
2001-04-01 05:03:41 +00:00
|
|
|
|
int i;
|
2009-11-17 01:26:25 +01:00
|
|
|
|
struct scm_vm *vp;
|
2009-02-04 00:09:38 +01:00
|
|
|
|
|
2009-11-17 01:26:25 +01:00
|
|
|
|
vp = scm_gc_malloc (sizeof (struct scm_vm), "vm");
|
2005-04-22 16:00:33 +00:00
|
|
|
|
|
2012-12-12 17:37:44 +01:00
|
|
|
|
vp->stack_size= vm_stack_size;
|
2009-08-20 01:56:47 +02:00
|
|
|
|
|
|
|
|
|
|
#ifdef VM_ENABLE_PRECISE_STACK_GC_SCAN
|
2010-01-09 15:06:20 +01:00
|
|
|
|
vp->stack_base = (SCM *)
|
|
|
|
|
|
GC_generic_malloc (vp->stack_size * sizeof (SCM), vm_stack_gc_kind);
|
2009-08-20 01:56:47 +02:00
|
|
|
|
|
|
|
|
|
|
/* Keep a pointer to VP so that `vm_stack_mark ()' can know what the stack
|
|
|
|
|
|
top is. */
|
2011-10-24 17:58:22 +02:00
|
|
|
|
*vp->stack_base = SCM_PACK_POINTER (vp);
|
2009-08-20 01:56:47 +02:00
|
|
|
|
vp->stack_base++;
|
|
|
|
|
|
vp->stack_size--;
|
|
|
|
|
|
#else
|
2005-04-22 16:00:33 +00:00
|
|
|
|
vp->stack_base = scm_gc_malloc (vp->stack_size * sizeof (SCM),
|
|
|
|
|
|
"stack-base");
|
2009-08-20 01:56:47 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
|
2008-10-11 11:54:12 +02:00
|
|
|
|
#ifdef VM_ENABLE_STACK_NULLING
|
|
|
|
|
|
memset (vp->stack_base, 0, vp->stack_size * sizeof (SCM));
|
|
|
|
|
|
#endif
|
2010-05-26 23:00:58 +02:00
|
|
|
|
vp->stack_limit = vp->stack_base + vp->stack_size - VM_STACK_RESERVE_SIZE;
|
2001-04-07 09:39:38 +00:00
|
|
|
|
vp->ip = NULL;
|
|
|
|
|
|
vp->sp = vp->stack_base - 1;
|
|
|
|
|
|
vp->fp = NULL;
|
2010-09-27 21:06:24 +02:00
|
|
|
|
vp->engine = vm_default_engine;
|
rework vm tracing
* libguile/vm-engine.c (VM_NAME): Engines take the VM itself (not the
vp), so they can pass the VM to hooks. No more hook args, we dispatch
without them.
* libguile/vm-engine.h (RUN_HOOK): Dispatch the hook if the trace level
is positive (instead of if the hook is there). Don't cache registers
on return from the dispatch.
* libguile/vm.h:
* libguile/vm.c (vm_dispatch_hook): Don't bother with a dynwind; instead
decrement the trace level when going into a hook, and if we have a
nonlocal exit, the trace level never gets incremented again. Worse is
better.
(make_vm, scm_vm_trace_level, scm_set_vm_trace_level_x): New concept,
trace level. If positive, we run the hooks, otherwise we don't. Should
work. Removed scm_vm_trace_frame, I don't think that was the right way
to do it.
* module/system/vm/vm.scm: Replace vm-trace-frame with vm-trace-level
and set-vm-trace-level!; the hooks actually get the frame as an
argument now.
2009-12-21 21:57:20 +01:00
|
|
|
|
vp->trace_level = 0;
|
2001-04-01 05:03:41 +00:00
|
|
|
|
for (i = 0; i < SCM_VM_NUM_HOOKS; i++)
|
2001-04-06 00:17:39 +00:00
|
|
|
|
vp->hooks[i] = SCM_BOOL_F;
|
2010-01-05 19:45:56 +01:00
|
|
|
|
return scm_cell (scm_tc7_vm, (scm_t_bits)vp);
|
2000-08-22 15:54:19 +00:00
|
|
|
|
}
|
2001-04-01 05:03:41 +00:00
|
|
|
|
#undef FUNC_NAME
|
2000-08-22 15:54:19 +00:00
|
|
|
|
|
2009-08-20 01:56:47 +02:00
|
|
|
|
#ifdef VM_ENABLE_PRECISE_STACK_GC_SCAN
|
|
|
|
|
|
|
|
|
|
|
|
/* Mark the VM stack region between its base and its current top. */
|
|
|
|
|
|
static struct GC_ms_entry *
|
|
|
|
|
|
vm_stack_mark (GC_word *addr, struct GC_ms_entry *mark_stack_ptr,
|
|
|
|
|
|
struct GC_ms_entry *mark_stack_limit, GC_word env)
|
|
|
|
|
|
{
|
|
|
|
|
|
GC_word *word;
|
|
|
|
|
|
const struct scm_vm *vm;
|
|
|
|
|
|
|
|
|
|
|
|
/* The first word of the VM stack should contain a pointer to the
|
|
|
|
|
|
corresponding VM. */
|
|
|
|
|
|
vm = * ((struct scm_vm **) addr);
|
|
|
|
|
|
|
2009-09-15 00:40:00 +02:00
|
|
|
|
if (vm == NULL
|
2010-05-26 23:00:58 +02:00
|
|
|
|
|| (SCM *) addr != vm->stack_base - 1)
|
2009-08-20 01:56:47 +02:00
|
|
|
|
/* ADDR must be a pointer to a free-list element, which we must ignore
|
|
|
|
|
|
(see warning in <gc/gc_mark.h>). */
|
|
|
|
|
|
return mark_stack_ptr;
|
|
|
|
|
|
|
|
|
|
|
|
for (word = (GC_word *) vm->stack_base; word <= (GC_word *) vm->sp; word++)
|
|
|
|
|
|
mark_stack_ptr = GC_MARK_AND_PUSH ((* (GC_word **) word),
|
|
|
|
|
|
mark_stack_ptr, mark_stack_limit,
|
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
|
|
return mark_stack_ptr;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* VM_ENABLE_PRECISE_STACK_GC_SCAN */
|
|
|
|
|
|
|
|
|
|
|
|
|
enable multiple vm engines (regular, debug, ...)
* libguile/vm-engine.c (VM_USE_HOOKS, VM_USE_CLOCK, VM_CHECK_EXTERNAL)
(VM_CHECK_OBJECT): Update to define these here, before including
vm-engine.h.
(vm_run): Change so that we can make different engines. Also, we take
an array of arguments, and the struct scm_vm directly, so as to avoid
any need to cons.
* libguile/vm-engine.h (CHECK_EXTERNAL, CHECK_OBJECT): Add some UNLIKELY
bits; don't seem to help.
* libguile/vm.c (vm_dispatch_hook): Change to not pass the VP. This needs
some love, and perhaps we revert to the old way.
(VM_ENGINE): Actually make two engines, vm_regular_engine and
vm_debug_engine. Probably there is room for improvement here. Actually
their speeds are the same at the moment.
(make_vm): Choose which engine to run; currently the debug engine by
default.
(scm_c_vm_run): A thin wrapper to invoke a VM without consing.
(scm_vm_apply): Use scm_c_vm_run.
(scm_load_compiled_with_vm): Use scm_c_vm_run.
2009-02-04 23:47:56 +01:00
|
|
|
|
SCM
|
2009-02-05 00:51:34 +01:00
|
|
|
|
scm_c_vm_run (SCM vm, SCM program, SCM *argv, int nargs)
|
enable multiple vm engines (regular, debug, ...)
* libguile/vm-engine.c (VM_USE_HOOKS, VM_USE_CLOCK, VM_CHECK_EXTERNAL)
(VM_CHECK_OBJECT): Update to define these here, before including
vm-engine.h.
(vm_run): Change so that we can make different engines. Also, we take
an array of arguments, and the struct scm_vm directly, so as to avoid
any need to cons.
* libguile/vm-engine.h (CHECK_EXTERNAL, CHECK_OBJECT): Add some UNLIKELY
bits; don't seem to help.
* libguile/vm.c (vm_dispatch_hook): Change to not pass the VP. This needs
some love, and perhaps we revert to the old way.
(VM_ENGINE): Actually make two engines, vm_regular_engine and
vm_debug_engine. Probably there is room for improvement here. Actually
their speeds are the same at the moment.
(make_vm): Choose which engine to run; currently the debug engine by
default.
(scm_c_vm_run): A thin wrapper to invoke a VM without consing.
(scm_vm_apply): Use scm_c_vm_run.
(scm_load_compiled_with_vm): Use scm_c_vm_run.
2009-02-04 23:47:56 +01:00
|
|
|
|
{
|
2009-02-05 00:51:34 +01:00
|
|
|
|
struct scm_vm *vp = SCM_VM_DATA (vm);
|
2010-10-01 16:47:39 +02:00
|
|
|
|
SCM_CHECK_STACK;
|
rework vm tracing
* libguile/vm-engine.c (VM_NAME): Engines take the VM itself (not the
vp), so they can pass the VM to hooks. No more hook args, we dispatch
without them.
* libguile/vm-engine.h (RUN_HOOK): Dispatch the hook if the trace level
is positive (instead of if the hook is there). Don't cache registers
on return from the dispatch.
* libguile/vm.h:
* libguile/vm.c (vm_dispatch_hook): Don't bother with a dynwind; instead
decrement the trace level when going into a hook, and if we have a
nonlocal exit, the trace level never gets incremented again. Worse is
better.
(make_vm, scm_vm_trace_level, scm_set_vm_trace_level_x): New concept,
trace level. If positive, we run the hooks, otherwise we don't. Should
work. Removed scm_vm_trace_frame, I don't think that was the right way
to do it.
* module/system/vm/vm.scm: Replace vm-trace-frame with vm-trace-level
and set-vm-trace-level!; the hooks actually get the frame as an
argument now.
2009-12-21 21:57:20 +01:00
|
|
|
|
return vm_engines[vp->engine](vm, program, argv, nargs);
|
enable multiple vm engines (regular, debug, ...)
* libguile/vm-engine.c (VM_USE_HOOKS, VM_USE_CLOCK, VM_CHECK_EXTERNAL)
(VM_CHECK_OBJECT): Update to define these here, before including
vm-engine.h.
(vm_run): Change so that we can make different engines. Also, we take
an array of arguments, and the struct scm_vm directly, so as to avoid
any need to cons.
* libguile/vm-engine.h (CHECK_EXTERNAL, CHECK_OBJECT): Add some UNLIKELY
bits; don't seem to help.
* libguile/vm.c (vm_dispatch_hook): Change to not pass the VP. This needs
some love, and perhaps we revert to the old way.
(VM_ENGINE): Actually make two engines, vm_regular_engine and
vm_debug_engine. Probably there is room for improvement here. Actually
their speeds are the same at the moment.
(make_vm): Choose which engine to run; currently the debug engine by
default.
(scm_c_vm_run): A thin wrapper to invoke a VM without consing.
(scm_vm_apply): Use scm_c_vm_run.
(scm_load_compiled_with_vm): Use scm_c_vm_run.
2009-02-04 23:47:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2000-08-22 15:54:19 +00:00
|
|
|
|
/* Scheme interface */
|
|
|
|
|
|
|
2010-09-24 15:14:11 +02:00
|
|
|
|
SCM_DEFINE (scm_the_vm, "the-vm", 0, 0, 0,
|
|
|
|
|
|
(void),
|
|
|
|
|
|
"Return the current thread's VM.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_the_vm
|
|
|
|
|
|
{
|
2010-09-27 21:06:24 +02:00
|
|
|
|
scm_i_thread *t = SCM_I_CURRENT_THREAD;
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_UNLIKELY (scm_is_false (t->vm)))
|
|
|
|
|
|
t->vm = make_vm ();
|
|
|
|
|
|
|
|
|
|
|
|
return t->vm;
|
2010-09-24 15:14:11 +02:00
|
|
|
|
}
|
2001-04-06 05:00:10 +00:00
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-08-22 15:54:19 +00:00
|
|
|
|
SCM_DEFINE (scm_vm_p, "vm?", 1, 0, 0,
|
|
|
|
|
|
(SCM obj),
|
2001-04-01 05:03:41 +00:00
|
|
|
|
"")
|
2000-08-22 15:54:19 +00:00
|
|
|
|
#define FUNC_NAME s_scm_vm_p
|
|
|
|
|
|
{
|
2009-11-25 23:46:17 +01:00
|
|
|
|
return scm_from_bool (SCM_VM_P (obj));
|
2000-08-22 15:54:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_make_vm, "make-vm", 0, 0, 0,
|
2001-04-01 05:03:41 +00:00
|
|
|
|
(void),
|
|
|
|
|
|
"")
|
|
|
|
|
|
#define FUNC_NAME s_scm_make_vm,
|
2000-08-22 15:54:19 +00:00
|
|
|
|
{
|
2001-04-01 05:03:41 +00:00
|
|
|
|
return make_vm ();
|
2000-08-22 15:54:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
2001-04-01 05:03:41 +00:00
|
|
|
|
SCM_DEFINE (scm_vm_ip, "vm:ip", 1, 0, 0,
|
2000-08-22 15:54:19 +00:00
|
|
|
|
(SCM vm),
|
2001-04-01 05:03:41 +00:00
|
|
|
|
"")
|
|
|
|
|
|
#define FUNC_NAME s_scm_vm_ip
|
2000-08-22 15:54:19 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM_VALIDATE_VM (1, vm);
|
2010-11-18 22:30:27 +01:00
|
|
|
|
return scm_from_unsigned_integer ((scm_t_bits) SCM_VM_DATA (vm)->ip);
|
2000-08-22 15:54:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_vm_sp, "vm:sp", 1, 0, 0,
|
|
|
|
|
|
(SCM vm),
|
2001-04-01 05:03:41 +00:00
|
|
|
|
"")
|
2000-08-22 15:54:19 +00:00
|
|
|
|
#define FUNC_NAME s_scm_vm_sp
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_VALIDATE_VM (1, vm);
|
2010-11-18 22:30:27 +01:00
|
|
|
|
return scm_from_unsigned_integer ((scm_t_bits) SCM_VM_DATA (vm)->sp);
|
2000-08-22 15:54:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_vm_fp, "vm:fp", 1, 0, 0,
|
|
|
|
|
|
(SCM vm),
|
2001-04-01 05:03:41 +00:00
|
|
|
|
"")
|
2000-08-22 15:54:19 +00:00
|
|
|
|
#define FUNC_NAME s_scm_vm_fp
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_VALIDATE_VM (1, vm);
|
2010-11-18 22:30:27 +01:00
|
|
|
|
return scm_from_unsigned_integer ((scm_t_bits) SCM_VM_DATA (vm)->fp);
|
2000-08-22 15:54:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
2001-04-01 05:03:41 +00:00
|
|
|
|
#define VM_DEFINE_HOOK(n) \
|
|
|
|
|
|
{ \
|
2001-04-06 00:17:39 +00:00
|
|
|
|
struct scm_vm *vp; \
|
2001-04-01 05:03:41 +00:00
|
|
|
|
SCM_VALIDATE_VM (1, vm); \
|
2001-04-06 00:17:39 +00:00
|
|
|
|
vp = SCM_VM_DATA (vm); \
|
2009-11-28 22:52:16 +01:00
|
|
|
|
if (scm_is_false (vp->hooks[n])) \
|
2005-04-28 15:45:59 +00:00
|
|
|
|
vp->hooks[n] = scm_make_hook (SCM_I_MAKINUM (1)); \
|
2001-04-06 00:17:39 +00:00
|
|
|
|
return vp->hooks[n]; \
|
2001-04-01 05:03:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2010-09-16 12:14:55 +02:00
|
|
|
|
SCM_DEFINE (scm_vm_apply_hook, "vm-apply-hook", 1, 0, 0,
|
2001-04-01 05:03:41 +00:00
|
|
|
|
(SCM vm),
|
|
|
|
|
|
"")
|
2010-09-16 12:14:55 +02:00
|
|
|
|
#define FUNC_NAME s_scm_vm_apply_hook
|
2000-08-22 15:54:19 +00:00
|
|
|
|
{
|
2010-09-16 12:14:55 +02:00
|
|
|
|
VM_DEFINE_HOOK (SCM_VM_APPLY_HOOK);
|
2000-08-22 15:54:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
2010-09-16 12:14:55 +02:00
|
|
|
|
SCM_DEFINE (scm_vm_push_continuation_hook, "vm-push-continuation-hook", 1, 0, 0,
|
2001-04-01 05:03:41 +00:00
|
|
|
|
(SCM vm),
|
|
|
|
|
|
"")
|
2010-09-16 12:14:55 +02:00
|
|
|
|
#define FUNC_NAME s_scm_vm_push_continuation_hook
|
2000-08-22 15:54:19 +00:00
|
|
|
|
{
|
2010-09-16 12:14:55 +02:00
|
|
|
|
VM_DEFINE_HOOK (SCM_VM_PUSH_CONTINUATION_HOOK);
|
2000-08-22 15:54:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
2010-09-16 12:14:55 +02:00
|
|
|
|
SCM_DEFINE (scm_vm_pop_continuation_hook, "vm-pop-continuation-hook", 1, 0, 0,
|
2000-08-22 15:54:19 +00:00
|
|
|
|
(SCM vm),
|
2001-04-01 05:03:41 +00:00
|
|
|
|
"")
|
2010-09-16 12:14:55 +02:00
|
|
|
|
#define FUNC_NAME s_scm_vm_pop_continuation_hook
|
2000-08-22 15:54:19 +00:00
|
|
|
|
{
|
2010-09-16 12:14:55 +02:00
|
|
|
|
VM_DEFINE_HOOK (SCM_VM_POP_CONTINUATION_HOOK);
|
2000-08-22 15:54:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
2010-09-16 12:14:55 +02:00
|
|
|
|
SCM_DEFINE (scm_vm_next_hook, "vm-next-hook", 1, 0, 0,
|
2000-08-22 15:54:19 +00:00
|
|
|
|
(SCM vm),
|
2001-04-01 05:03:41 +00:00
|
|
|
|
"")
|
2010-09-16 12:14:55 +02:00
|
|
|
|
#define FUNC_NAME s_scm_vm_next_hook
|
2000-08-22 15:54:19 +00:00
|
|
|
|
{
|
2010-09-16 12:14:55 +02:00
|
|
|
|
VM_DEFINE_HOOK (SCM_VM_NEXT_HOOK);
|
2000-08-22 15:54:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
2010-09-16 12:48:41 +02:00
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_vm_abort_continuation_hook, "vm-abort-continuation-hook", 1, 0, 0,
|
|
|
|
|
|
(SCM vm),
|
|
|
|
|
|
"")
|
|
|
|
|
|
#define FUNC_NAME s_scm_vm_abort_continuation_hook
|
|
|
|
|
|
{
|
|
|
|
|
|
VM_DEFINE_HOOK (SCM_VM_ABORT_CONTINUATION_HOOK);
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_vm_restore_continuation_hook, "vm-restore-continuation-hook", 1, 0, 0,
|
|
|
|
|
|
(SCM vm),
|
|
|
|
|
|
"")
|
|
|
|
|
|
#define FUNC_NAME s_scm_vm_restore_continuation_hook
|
|
|
|
|
|
{
|
|
|
|
|
|
VM_DEFINE_HOOK (SCM_VM_RESTORE_CONTINUATION_HOOK);
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
2000-08-22 15:54:19 +00:00
|
|
|
|
|
rework vm tracing
* libguile/vm-engine.c (VM_NAME): Engines take the VM itself (not the
vp), so they can pass the VM to hooks. No more hook args, we dispatch
without them.
* libguile/vm-engine.h (RUN_HOOK): Dispatch the hook if the trace level
is positive (instead of if the hook is there). Don't cache registers
on return from the dispatch.
* libguile/vm.h:
* libguile/vm.c (vm_dispatch_hook): Don't bother with a dynwind; instead
decrement the trace level when going into a hook, and if we have a
nonlocal exit, the trace level never gets incremented again. Worse is
better.
(make_vm, scm_vm_trace_level, scm_set_vm_trace_level_x): New concept,
trace level. If positive, we run the hooks, otherwise we don't. Should
work. Removed scm_vm_trace_frame, I don't think that was the right way
to do it.
* module/system/vm/vm.scm: Replace vm-trace-frame with vm-trace-level
and set-vm-trace-level!; the hooks actually get the frame as an
argument now.
2009-12-21 21:57:20 +01:00
|
|
|
|
SCM_DEFINE (scm_vm_trace_level, "vm-trace-level", 1, 0, 0,
|
2001-04-01 05:03:41 +00:00
|
|
|
|
(SCM vm),
|
|
|
|
|
|
"")
|
rework vm tracing
* libguile/vm-engine.c (VM_NAME): Engines take the VM itself (not the
vp), so they can pass the VM to hooks. No more hook args, we dispatch
without them.
* libguile/vm-engine.h (RUN_HOOK): Dispatch the hook if the trace level
is positive (instead of if the hook is there). Don't cache registers
on return from the dispatch.
* libguile/vm.h:
* libguile/vm.c (vm_dispatch_hook): Don't bother with a dynwind; instead
decrement the trace level when going into a hook, and if we have a
nonlocal exit, the trace level never gets incremented again. Worse is
better.
(make_vm, scm_vm_trace_level, scm_set_vm_trace_level_x): New concept,
trace level. If positive, we run the hooks, otherwise we don't. Should
work. Removed scm_vm_trace_frame, I don't think that was the right way
to do it.
* module/system/vm/vm.scm: Replace vm-trace-frame with vm-trace-level
and set-vm-trace-level!; the hooks actually get the frame as an
argument now.
2009-12-21 21:57:20 +01:00
|
|
|
|
#define FUNC_NAME s_scm_vm_trace_level
|
2000-08-22 15:54:19 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM_VALIDATE_VM (1, vm);
|
rework vm tracing
* libguile/vm-engine.c (VM_NAME): Engines take the VM itself (not the
vp), so they can pass the VM to hooks. No more hook args, we dispatch
without them.
* libguile/vm-engine.h (RUN_HOOK): Dispatch the hook if the trace level
is positive (instead of if the hook is there). Don't cache registers
on return from the dispatch.
* libguile/vm.h:
* libguile/vm.c (vm_dispatch_hook): Don't bother with a dynwind; instead
decrement the trace level when going into a hook, and if we have a
nonlocal exit, the trace level never gets incremented again. Worse is
better.
(make_vm, scm_vm_trace_level, scm_set_vm_trace_level_x): New concept,
trace level. If positive, we run the hooks, otherwise we don't. Should
work. Removed scm_vm_trace_frame, I don't think that was the right way
to do it.
* module/system/vm/vm.scm: Replace vm-trace-frame with vm-trace-level
and set-vm-trace-level!; the hooks actually get the frame as an
argument now.
2009-12-21 21:57:20 +01:00
|
|
|
|
return scm_from_int (SCM_VM_DATA (vm)->trace_level);
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_set_vm_trace_level_x, "set-vm-trace-level!", 2, 0, 0,
|
|
|
|
|
|
(SCM vm, SCM level),
|
|
|
|
|
|
"")
|
|
|
|
|
|
#define FUNC_NAME s_scm_set_vm_trace_level_x
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_VALIDATE_VM (1, vm);
|
|
|
|
|
|
SCM_VM_DATA (vm)->trace_level = scm_to_int (level);
|
|
|
|
|
|
return SCM_UNSPECIFIED;
|
2000-08-22 15:54:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
2010-09-27 21:06:24 +02:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* VM engines
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
|
symbol_to_vm_engine (SCM engine, const char *FUNC_NAME)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (scm_is_eq (engine, sym_regular))
|
|
|
|
|
|
return SCM_VM_REGULAR_ENGINE;
|
|
|
|
|
|
else if (scm_is_eq (engine, sym_debug))
|
|
|
|
|
|
return SCM_VM_DEBUG_ENGINE;
|
|
|
|
|
|
else
|
|
|
|
|
|
SCM_MISC_ERROR ("Unknown VM engine: ~a", scm_list_1 (engine));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
vm_engine_to_symbol (int engine, const char *FUNC_NAME)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (engine)
|
|
|
|
|
|
{
|
|
|
|
|
|
case SCM_VM_REGULAR_ENGINE:
|
|
|
|
|
|
return sym_regular;
|
|
|
|
|
|
case SCM_VM_DEBUG_ENGINE:
|
|
|
|
|
|
return sym_debug;
|
|
|
|
|
|
default:
|
|
|
|
|
|
/* ? */
|
|
|
|
|
|
SCM_MISC_ERROR ("Unknown VM engine: ~a",
|
|
|
|
|
|
scm_list_1 (scm_from_int (engine)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_vm_engine, "vm-engine", 1, 0, 0,
|
|
|
|
|
|
(SCM vm),
|
|
|
|
|
|
"")
|
|
|
|
|
|
#define FUNC_NAME s_scm_vm_engine
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_VALIDATE_VM (1, vm);
|
|
|
|
|
|
return vm_engine_to_symbol (SCM_VM_DATA (vm)->engine, FUNC_NAME);
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
scm_c_set_vm_engine_x (SCM vm, int engine)
|
|
|
|
|
|
#define FUNC_NAME "set-vm-engine!"
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_VALIDATE_VM (1, vm);
|
|
|
|
|
|
|
|
|
|
|
|
if (engine < 0 || engine >= SCM_VM_NUM_ENGINES)
|
|
|
|
|
|
SCM_MISC_ERROR ("Unknown VM engine: ~a",
|
|
|
|
|
|
scm_list_1 (scm_from_int (engine)));
|
|
|
|
|
|
|
|
|
|
|
|
SCM_VM_DATA (vm)->engine = engine;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_set_vm_engine_x, "set-vm-engine!", 2, 0, 0,
|
|
|
|
|
|
(SCM vm, SCM engine),
|
|
|
|
|
|
"")
|
|
|
|
|
|
#define FUNC_NAME s_scm_set_vm_engine_x
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_c_set_vm_engine_x (vm, symbol_to_vm_engine (engine, FUNC_NAME));
|
|
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
scm_c_set_default_vm_engine_x (int engine)
|
|
|
|
|
|
#define FUNC_NAME "set-default-vm-engine!"
|
|
|
|
|
|
{
|
|
|
|
|
|
if (engine < 0 || engine >= SCM_VM_NUM_ENGINES)
|
|
|
|
|
|
SCM_MISC_ERROR ("Unknown VM engine: ~a",
|
|
|
|
|
|
scm_list_1 (scm_from_int (engine)));
|
|
|
|
|
|
|
|
|
|
|
|
vm_default_engine = engine;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_set_default_vm_engine_x, "set-default-vm-engine!", 1, 0, 0,
|
|
|
|
|
|
(SCM engine),
|
|
|
|
|
|
"")
|
|
|
|
|
|
#define FUNC_NAME s_scm_set_default_vm_engine_x
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_c_set_default_vm_engine_x (symbol_to_vm_engine (engine, FUNC_NAME));
|
|
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
static void reinstate_vm (SCM vm)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_i_thread *t = SCM_I_CURRENT_THREAD;
|
|
|
|
|
|
t->vm = vm;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_call_with_vm, "call-with-vm", 2, 0, 1,
|
|
|
|
|
|
(SCM vm, SCM proc, SCM args),
|
|
|
|
|
|
"Apply @var{proc} to @var{args} in a dynamic extent in which\n"
|
|
|
|
|
|
"@var{vm} is the current VM.\n\n"
|
|
|
|
|
|
"As an implementation restriction, if @var{vm} is not the same\n"
|
|
|
|
|
|
"as the current thread's VM, continuations captured within the\n"
|
|
|
|
|
|
"call to @var{proc} may not be reinstated once control leaves\n"
|
|
|
|
|
|
"@var{proc}.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_call_with_vm
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM prev_vm, ret;
|
|
|
|
|
|
SCM *argv;
|
|
|
|
|
|
int i, nargs;
|
|
|
|
|
|
scm_t_wind_flags flags;
|
|
|
|
|
|
scm_i_thread *t = SCM_I_CURRENT_THREAD;
|
|
|
|
|
|
|
|
|
|
|
|
SCM_VALIDATE_VM (1, vm);
|
|
|
|
|
|
SCM_VALIDATE_PROC (2, proc);
|
|
|
|
|
|
|
|
|
|
|
|
nargs = scm_ilength (args);
|
|
|
|
|
|
if (SCM_UNLIKELY (nargs < 0))
|
|
|
|
|
|
scm_wrong_type_arg_msg (FUNC_NAME, 3, args, "list");
|
|
|
|
|
|
|
|
|
|
|
|
argv = alloca (nargs * sizeof(SCM));
|
|
|
|
|
|
for (i = 0; i < nargs; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
argv[i] = SCM_CAR (args);
|
|
|
|
|
|
args = SCM_CDR (args);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
prev_vm = t->vm;
|
|
|
|
|
|
|
|
|
|
|
|
/* Reentry can happen via invokation of a saved continuation, but
|
|
|
|
|
|
continuations only save the state of the VM that they are in at
|
|
|
|
|
|
capture-time, which might be different from this one. So, in the
|
|
|
|
|
|
case that the VMs are different, set up a non-rewindable frame to
|
|
|
|
|
|
prevent reinstating an incomplete continuation. */
|
|
|
|
|
|
flags = scm_is_eq (prev_vm, vm) ? 0 : SCM_F_WIND_EXPLICITLY;
|
|
|
|
|
|
if (flags)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_dynwind_begin (0);
|
|
|
|
|
|
scm_dynwind_unwind_handler_with_scm (reinstate_vm, prev_vm, flags);
|
|
|
|
|
|
t->vm = vm;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ret = scm_c_vm_run (vm, proc, argv, nargs);
|
|
|
|
|
|
|
|
|
|
|
|
if (flags)
|
|
|
|
|
|
scm_dynwind_end ();
|
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
2000-08-22 15:54:19 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
2001-04-01 05:03:41 +00:00
|
|
|
|
* Initialize
|
2000-08-22 15:54:19 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
big reorg of scheme modules -- e.g. programs.c -> (system vm program)
This reorganization kills the ugly module-export-all hacks in
bootstrap.scm and core.scm. In fact, it gets rid of core.scm entirely,
breaking out its functionality into separate files.
* module/system/vm/trace.scm:
* module/system/vm/profile.scm:
* module/system/vm/disasm.scm:
* module/system/vm/debug.scm:
* module/system/vm/conv.scm:
* module/system/vm/assemble.scm:
* module/system/repl/repl.scm:
* module/system/repl/common.scm:
* module/system/base/compile.scm:
* module/system/repl/command.scm: Update for changes, and fix a bug in
procedure-documentation.
* module/system/vm/bootstrap.scm: Just call scm_bootstrap_vm, which
handles setting load-compiled for us.
* module/system/vm/core.scm: Removed, functionality folded into other
modules.
* module/system/vm/frame.scm: Export the C frame procedures here; also
move scheme functions from core.scm here.
* module/system/vm/instruction.scm: New file, exports procedures from
instructions.c.
* module/system/vm/objcode.scm: New file, exports procedures from
objcodes.c.
* module/system/vm/program.scm: New file, exports procedures from
programs.c, and some scheme functions originally from core.scm.
* module/system/vm/vm.scm: New file, from vm.c and core.scm.
* src/Makefile.am (libguile_vm_la_SOURCES): Add bootstrap.h.
* src/bootstrap.h: New file, prototypes scm_bootstrap_vm (), which the
scm_init_* functions call.
* src/frames.h:
* src/frames.c (scm_init_frames):
* src/frames.c (scm_bootstrap_frames):
* src/vm.h:
* src/instructions.h:
* src/instructions.c (scm_init_instructions):
* src/instructions.c (scm_bootstrap_instructions):
* src/objcodes.h:
* src/objcodes.c (scm_bootstrap_objcodes):
* src/objcodes.c (scm_init_objcodes):
* src/programs.h:
* src/programs.c (scm_bootstrap_programs):
* src/programs.c (scm_init_programs):
* src/vm.c (scm_bootstrap_vm):
* src/vm.c (scm_init_vm): Call scm_bootstrap_vm() before doing anything
in an init function. Bootstrap_vm will call bootstrap_instructions(),
etc to initialize types, then set load-compiled to point to
load-compiled/vm.
* src/vm.c (scm_load_compiled_with_vm): Code to load .go files, if
they're present.
2008-08-07 13:11:27 +02:00
|
|
|
|
SCM scm_load_compiled_with_vm (SCM file)
|
|
|
|
|
|
{
|
2012-06-22 13:35:55 +02:00
|
|
|
|
SCM program = scm_load_thunk_from_file (file);
|
|
|
|
|
|
|
2009-02-05 00:51:34 +01:00
|
|
|
|
return scm_c_vm_run (scm_the_vm (), program, NULL, 0);
|
big reorg of scheme modules -- e.g. programs.c -> (system vm program)
This reorganization kills the ugly module-export-all hacks in
bootstrap.scm and core.scm. In fact, it gets rid of core.scm entirely,
breaking out its functionality into separate files.
* module/system/vm/trace.scm:
* module/system/vm/profile.scm:
* module/system/vm/disasm.scm:
* module/system/vm/debug.scm:
* module/system/vm/conv.scm:
* module/system/vm/assemble.scm:
* module/system/repl/repl.scm:
* module/system/repl/common.scm:
* module/system/base/compile.scm:
* module/system/repl/command.scm: Update for changes, and fix a bug in
procedure-documentation.
* module/system/vm/bootstrap.scm: Just call scm_bootstrap_vm, which
handles setting load-compiled for us.
* module/system/vm/core.scm: Removed, functionality folded into other
modules.
* module/system/vm/frame.scm: Export the C frame procedures here; also
move scheme functions from core.scm here.
* module/system/vm/instruction.scm: New file, exports procedures from
instructions.c.
* module/system/vm/objcode.scm: New file, exports procedures from
objcodes.c.
* module/system/vm/program.scm: New file, exports procedures from
programs.c, and some scheme functions originally from core.scm.
* module/system/vm/vm.scm: New file, from vm.c and core.scm.
* src/Makefile.am (libguile_vm_la_SOURCES): Add bootstrap.h.
* src/bootstrap.h: New file, prototypes scm_bootstrap_vm (), which the
scm_init_* functions call.
* src/frames.h:
* src/frames.c (scm_init_frames):
* src/frames.c (scm_bootstrap_frames):
* src/vm.h:
* src/instructions.h:
* src/instructions.c (scm_init_instructions):
* src/instructions.c (scm_bootstrap_instructions):
* src/objcodes.h:
* src/objcodes.c (scm_bootstrap_objcodes):
* src/objcodes.c (scm_init_objcodes):
* src/programs.h:
* src/programs.c (scm_bootstrap_programs):
* src/programs.c (scm_init_programs):
* src/vm.c (scm_bootstrap_vm):
* src/vm.c (scm_init_vm): Call scm_bootstrap_vm() before doing anything
in an init function. Bootstrap_vm will call bootstrap_instructions(),
etc to initialize types, then set load-compiled to point to
load-compiled/vm.
* src/vm.c (scm_load_compiled_with_vm): Code to load .go files, if
they're present.
2008-08-07 13:11:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2012-05-10 12:43:33 +02:00
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
make_boot_program (void)
|
|
|
|
|
|
{
|
|
|
|
|
|
struct scm_objcode *bp;
|
|
|
|
|
|
size_t bp_size;
|
|
|
|
|
|
SCM u8vec, ret;
|
2012-05-10 13:02:11 +02:00
|
|
|
|
|
|
|
|
|
|
const scm_t_uint8 text[] = {
|
2012-05-10 12:43:33 +02:00
|
|
|
|
scm_op_make_int8_1,
|
|
|
|
|
|
scm_op_halt
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
bp_size = sizeof (struct scm_objcode) + sizeof (text);
|
|
|
|
|
|
bp = scm_gc_malloc_pointerless (bp_size, "boot-program");
|
|
|
|
|
|
memcpy (SCM_C_OBJCODE_BASE (bp), text, sizeof (text));
|
|
|
|
|
|
bp->len = sizeof(text);
|
|
|
|
|
|
bp->metalen = 0;
|
|
|
|
|
|
|
2012-05-10 13:02:11 +02:00
|
|
|
|
u8vec = scm_c_take_gc_bytevector ((scm_t_int8*)bp, bp_size, SCM_BOOL_F);
|
2012-06-22 13:35:55 +02:00
|
|
|
|
ret = scm_make_program (scm_bytecode_to_objcode (u8vec, SCM_UNDEFINED),
|
2012-05-10 12:43:33 +02:00
|
|
|
|
SCM_BOOL_F, SCM_BOOL_F);
|
|
|
|
|
|
SCM_SET_CELL_WORD_0 (ret, (SCM_CELL_WORD_0 (ret) | SCM_F_PROGRAM_IS_BOOT));
|
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2001-04-01 05:03:41 +00:00
|
|
|
|
void
|
big reorg of scheme modules -- e.g. programs.c -> (system vm program)
This reorganization kills the ugly module-export-all hacks in
bootstrap.scm and core.scm. In fact, it gets rid of core.scm entirely,
breaking out its functionality into separate files.
* module/system/vm/trace.scm:
* module/system/vm/profile.scm:
* module/system/vm/disasm.scm:
* module/system/vm/debug.scm:
* module/system/vm/conv.scm:
* module/system/vm/assemble.scm:
* module/system/repl/repl.scm:
* module/system/repl/common.scm:
* module/system/base/compile.scm:
* module/system/repl/command.scm: Update for changes, and fix a bug in
procedure-documentation.
* module/system/vm/bootstrap.scm: Just call scm_bootstrap_vm, which
handles setting load-compiled for us.
* module/system/vm/core.scm: Removed, functionality folded into other
modules.
* module/system/vm/frame.scm: Export the C frame procedures here; also
move scheme functions from core.scm here.
* module/system/vm/instruction.scm: New file, exports procedures from
instructions.c.
* module/system/vm/objcode.scm: New file, exports procedures from
objcodes.c.
* module/system/vm/program.scm: New file, exports procedures from
programs.c, and some scheme functions originally from core.scm.
* module/system/vm/vm.scm: New file, from vm.c and core.scm.
* src/Makefile.am (libguile_vm_la_SOURCES): Add bootstrap.h.
* src/bootstrap.h: New file, prototypes scm_bootstrap_vm (), which the
scm_init_* functions call.
* src/frames.h:
* src/frames.c (scm_init_frames):
* src/frames.c (scm_bootstrap_frames):
* src/vm.h:
* src/instructions.h:
* src/instructions.c (scm_init_instructions):
* src/instructions.c (scm_bootstrap_instructions):
* src/objcodes.h:
* src/objcodes.c (scm_bootstrap_objcodes):
* src/objcodes.c (scm_init_objcodes):
* src/programs.h:
* src/programs.c (scm_bootstrap_programs):
* src/programs.c (scm_init_programs):
* src/vm.c (scm_bootstrap_vm):
* src/vm.c (scm_init_vm): Call scm_bootstrap_vm() before doing anything
in an init function. Bootstrap_vm will call bootstrap_instructions(),
etc to initialize types, then set load-compiled to point to
load-compiled/vm.
* src/vm.c (scm_load_compiled_with_vm): Code to load .go files, if
they're present.
2008-08-07 13:11:27 +02:00
|
|
|
|
scm_bootstrap_vm (void)
|
2001-04-01 05:03:41 +00:00
|
|
|
|
{
|
2010-03-16 21:18:12 +01:00
|
|
|
|
scm_c_register_extension ("libguile-" SCM_EFFECTIVE_VERSION,
|
|
|
|
|
|
"scm_init_vm",
|
2009-03-27 18:40:15 -07:00
|
|
|
|
(scm_t_extension_init_func)scm_init_vm, NULL);
|
|
|
|
|
|
|
2012-12-12 17:37:44 +01:00
|
|
|
|
initialize_default_stack_size ();
|
|
|
|
|
|
|
2011-01-07 09:08:58 -08:00
|
|
|
|
sym_vm_run = scm_from_latin1_symbol ("vm-run");
|
|
|
|
|
|
sym_vm_error = scm_from_latin1_symbol ("vm-error");
|
|
|
|
|
|
sym_keyword_argument_error = scm_from_latin1_symbol ("keyword-argument-error");
|
|
|
|
|
|
sym_regular = scm_from_latin1_symbol ("regular");
|
|
|
|
|
|
sym_debug = scm_from_latin1_symbol ("debug");
|
2010-02-24 23:32:04 +01:00
|
|
|
|
|
2012-05-10 12:43:33 +02:00
|
|
|
|
boot_continuation = make_boot_program ();
|
|
|
|
|
|
|
2009-08-20 01:56:47 +02:00
|
|
|
|
#ifdef VM_ENABLE_PRECISE_STACK_GC_SCAN
|
|
|
|
|
|
vm_stack_gc_kind =
|
|
|
|
|
|
GC_new_kind (GC_new_free_list (),
|
|
|
|
|
|
GC_MAKE_PROC (GC_new_proc (vm_stack_mark), 0),
|
|
|
|
|
|
0, 1);
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
big reorg of scheme modules -- e.g. programs.c -> (system vm program)
This reorganization kills the ugly module-export-all hacks in
bootstrap.scm and core.scm. In fact, it gets rid of core.scm entirely,
breaking out its functionality into separate files.
* module/system/vm/trace.scm:
* module/system/vm/profile.scm:
* module/system/vm/disasm.scm:
* module/system/vm/debug.scm:
* module/system/vm/conv.scm:
* module/system/vm/assemble.scm:
* module/system/repl/repl.scm:
* module/system/repl/common.scm:
* module/system/base/compile.scm:
* module/system/repl/command.scm: Update for changes, and fix a bug in
procedure-documentation.
* module/system/vm/bootstrap.scm: Just call scm_bootstrap_vm, which
handles setting load-compiled for us.
* module/system/vm/core.scm: Removed, functionality folded into other
modules.
* module/system/vm/frame.scm: Export the C frame procedures here; also
move scheme functions from core.scm here.
* module/system/vm/instruction.scm: New file, exports procedures from
instructions.c.
* module/system/vm/objcode.scm: New file, exports procedures from
objcodes.c.
* module/system/vm/program.scm: New file, exports procedures from
programs.c, and some scheme functions originally from core.scm.
* module/system/vm/vm.scm: New file, from vm.c and core.scm.
* src/Makefile.am (libguile_vm_la_SOURCES): Add bootstrap.h.
* src/bootstrap.h: New file, prototypes scm_bootstrap_vm (), which the
scm_init_* functions call.
* src/frames.h:
* src/frames.c (scm_init_frames):
* src/frames.c (scm_bootstrap_frames):
* src/vm.h:
* src/instructions.h:
* src/instructions.c (scm_init_instructions):
* src/instructions.c (scm_bootstrap_instructions):
* src/objcodes.h:
* src/objcodes.c (scm_bootstrap_objcodes):
* src/objcodes.c (scm_init_objcodes):
* src/programs.h:
* src/programs.c (scm_bootstrap_programs):
* src/programs.c (scm_init_programs):
* src/vm.c (scm_bootstrap_vm):
* src/vm.c (scm_init_vm): Call scm_bootstrap_vm() before doing anything
in an init function. Bootstrap_vm will call bootstrap_instructions(),
etc to initialize types, then set load-compiled to point to
load-compiled/vm.
* src/vm.c (scm_load_compiled_with_vm): Code to load .go files, if
they're present.
2008-08-07 13:11:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
scm_init_vm (void)
|
|
|
|
|
|
{
|
2001-04-01 05:03:41 +00:00
|
|
|
|
#ifndef SCM_MAGIC_SNARFER
|
2009-03-16 23:39:29 +01:00
|
|
|
|
#include "libguile/vm.x"
|
2001-04-01 05:03:41 +00:00
|
|
|
|
#endif
|
2013-05-23 14:52:29 +02:00
|
|
|
|
|
|
|
|
|
|
rtl_boot_continuation = scm_i_make_rtl_program (rtl_boot_continuation_code);
|
|
|
|
|
|
rtl_apply = scm_i_make_rtl_program (rtl_apply_code);
|
|
|
|
|
|
rtl_values = scm_i_make_rtl_program (rtl_values_code);
|
2000-08-22 15:54:19 +00:00
|
|
|
|
}
|
2001-04-01 05:03:41 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|