summaryrefslogtreecommitdiff
path: root/libguile/vm.c
AgeCommit message (Collapse)AuthorFilesLines
2010-05-07Attempt to guarantee 8-byte alignment of on-stack frame objects.Ludovic Courtès1-3/+7
* libguile/vm.c (vm_dispatch_hook): Make FRAME a union with a `double' member.
2010-05-07Allocate frame objects on the stack when invoking VM hooks.Ludovic Courtès1-4/+24
* libguile/vm.c (vm_dispatch_hook): Don't call `scm_c_make_frame ()'. Instead, allocate FRAME on the stack.
2010-05-07When printing a VM, show the type of engine being used.Ludovic Courtès1-0/+17
* libguile/vm.c (scm_i_vm_print): Print the engine type.
2010-04-09remove libguile/lang.h, deprecate %nil (in favor of #nil)Andy Wingo1-1/+0
* libguile/Makefile.am: * libguile/init.c: * libguile/lang.c: * libguile/lang.h: Remove lang.c and lang.h. * libguile/pairs.h (SCM_NIL_P, SCM_NULL_OR_NIL_P): Moved here. * module/ice-9/deprecated.scm (%nil): %nil definition moved here. * libguile/alist.c: * libguile/async.c: * libguile/backtrace.c: * libguile/boolean.c: * libguile/dynl.c: * libguile/eval.c: * libguile/filesys.c: * libguile/fluids.c: * libguile/list.c: * libguile/load.c: * libguile/options.c: * libguile/posix.c: * libguile/print.c: * libguile/promises.c: * libguile/sort.c: * libguile/throw.c: * libguile/trees.c: * libguile/vectors.c: * libguile/vm.c: * libguile/weaks.c: * srfi/srfi-1.c: <libguile/lang.h> references removed.
2010-03-16rename libguile to libguile-@EFFECTIVE_VERSION@, currently libguile-2.0Andy Wingo1-1/+2
* libguile/Makefile.am (lib_LTLIBRARIES): Instead of just "libguile.la", make "libguile-@EFFECTIVE_VERSION@.la". This allows multiple versions of Guile to be installed at once. See http://www106.pair.com/rhp/parallel.html for a rationale. (libguile_@GUILE_EFFECTIVE_VERSION@_la_CFLAGS): (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): (EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): (libguile_@GUILE_EFFECTIVE_VERSION@_la_DEPENDENCIES): (libguile_@GUILE_EFFECTIVE_VERSION@_la_LIBADD): (libguile_@GUILE_EFFECTIVE_VERSION@_la_LDFLAGS): Fixup automake vars to include the effective version. (guile_LDADD): Fix up the spelling of libguile. * libguile/bytevectors.c (scm_bootstrap_bytevectors): * libguile/foreign.c (scm_register_foreign): * libguile/i18n.c (scm_bootstrap_i18n): * libguile/instructions.c (scm_bootstrap_instructions): * libguile/objcodes.c (scm_bootstrap_objcodes): * libguile/programs.c (scm_bootstrap_programs): * libguile/vm.c (scm_bootstrap_vm): Register extensions using e.g. "libguile-2.0" as the libname -- i.e., including the effective version in the libname. * module/ice-9/i18n.scm: * module/rnrs/bytevector.scm: * module/rnrs/io/ports.scm: * module/system/foreign.scm: * module/system/vm/instruction.scm: * module/system/vm/objcode.scm: * module/system/vm/program.scm: * module/system/vm/vm.scm: When doing a load-extension for something in Guile, use the effective version also. * meta/guile-2.0-uninstalled.pc.in (Libs): * meta/guile-2.0.pc.in (Libs): Use -lguile-@EFFECTIVE_VERSION@. This change should mean that code built against Guile should not be affected by the libguile rename. * guile-readline/Makefile.am (libguilereadline_v_@LIBGUILEREADLINE_MAJOR@_la_LIBADD): * srfi/Makefile.am (libguile_srfi_srfi_1_v_@LIBGUILE_SRFI_SRFI_1_MAJOR@_la_LIBADD): (libguile_srfi_srfi_4_v_@LIBGUILE_SRFI_SRFI_4_MAJOR@_la_LIBADD): (libguile_srfi_srfi_13_14_v_@LIBGUILE_SRFI_SRFI_13_14_MAJOR@_la_LIBADD): (libguile_srfi_srfi_60_v_@LIBGUILE_SRFI_SRFI_60_MAJOR@_la_LIBADD): * test-suite/standalone/Makefile.am (test_num2integral_LDADD): (test_round_LDADD): (libtest_asmobs_la_LIBADD): (libtest_ffi_la_LIBADD): (test_list_LDADD): (test_unwind_LDADD): (test_conversion_LDADD): (test_loose_ends_LDADD): (test_scm_c_read_LDADD): (test_scm_take_locale_symbol_LDADD): (test_scm_take_u8vector_LDADD): (libtest_extensions_la_LIBADD): (test_with_guile_module_LDADD): (test_scm_with_guile_LDADD): Fix up the spelling of libguile.la.
2010-03-09%start-stack in Scheme, in terms of promptsAndy Wingo1-6/+0
* libguile/debug.h: * libguile/debug.c (scm_sys_start_stack): Removed, we implement this in Scheme now. * libguile/vm.h: * libguile/vm.c (scm_vm_call_with_new_stack): Likewise removed. * module/ice-9/boot-9.scm (%start-stack): Implement in terms of prompts. (%stacks): New fluid, for tracking active stacks. (start-stack): Implement using syntax-rules.
2010-02-26rewinding prompts worksAndy Wingo1-5/+21
* libguile/control.h (SCM_PROMPT_HANDLER): Remove, it was unused. (SCM_PROMPT_DYNWINDS): Rename from SCM_PROMPT_DYNENV. * libguile/control.c: (scm_c_make_prompt): Take another arg, the winds that are to be in place for the prompt. Fix allocation to be 4 words instead of 5 (the handler was never used). * libguile/eval.c (eval): * libguile/throw.c (pre_init_catch): Adapt to scm_c_make_prompt change. * libguile/vm-i-system.c (partial-cont-call): Grovel the new elements of the wind list in order to call setjmp() on the new prompts. Pass cookie to vm_reinstate_partial_continuation. (prompt): Adapt to scm_c_make_prompt change. * libguile/vm.c (vm_reinstate_partial_continuation): Take a cookie arg, used when winding captured prompts onto the stack. Winding a prompt implies making a new prompt, actually -- with new registers, a new jump buffer, new winds, etc. * test-suite/tests/control.test ("rewinding prompts"): Add a test for rewinding prompts.
2010-02-25fix embarrassing bugAndy Wingo1-4/+4
* libguile/vm.c: Fix embarrassing error regarding the symbolitude of vm-error and friends.
2010-02-24fix symbol initialization in vm.cAndy Wingo1-4/+8
* libguile/vm.c (scm_bootstrap_vm): Fix case in which some symbols wouldn't be initialized by the time they were needed.
2010-02-24turn abort() calls in vm.c into exceptionsAndy Wingo1-10/+12
* libguile/vm.c (vm_return_to_continuation, vm_abort): (vm_reinstate_partial_continuation, really_make_boot_program): Turn some abort()s into scm_misc_errors.
2010-02-24rewind the dynamic state when entering a partial continuationAndy Wingo1-1/+10
* libguile/control.c (cont_objcode): * libguile/vm-i-system.c (partial-cont-call): * libguile/vm.c (vm_reinstate_partial_continuation): Don't keep the "external winds" in a partial continuation, as they aren't logically part of the continuation. Reinstate the "internal winds" when entering a partial continuation. Things seem to work!
2010-02-24partial-cont-call worksAndy Wingo1-3/+47
* libguile/vm-i-system.c (partial-cont-call): Sync registers before splatting a partial continuation, and cache them back afterwards. * libguile/vm.c (vm_reinstate_partial_continuation): Actually implement, except dynamic-wind.
2010-02-22actually capture partial continuationsAndy Wingo1-7/+15
* libguile/control.c (cont_objcode): Along with a bunch of boilerplate that certainly needs to go in some central place, define this continuation-calling trampoline. (reify_partial_continuation): New function, returns a procedure that when called will reinstate a partial continuation. (scm_c_abort): Take an extra arg, the cookie. Actually reify a continuation. (scm_at_abort): Adapt to scm_c_abort change. * libguile/control.h: Declare scm_c_abort change. * libguile/vm-i-system.c (partial_cont_call): New instruction. (call/cc, tail-call/cc): Adapt to scm_i_vm_capture_stack change. (abort): Pass vm_cookie to abort. * libguile/vm.h (SCM_F_VM_CONT_PARTIAL, SCM_F_VM_CONT_REWINDABLE): New flags. (struct scm_vm_cont): Add flags field. (SCM_VM_CONT_PARTIAL_P, SCM_VM_CONT_REWINDABLE_P): New predicates. * libguile/vm.c (scm_i_vm_capture_stack): Rename from vm_capture_continuation, and make internal instead of static. Take a flags argument. (scm_i_vm_capture_continuation): Adapt to scm_i_vm_capture_stack change. (vm_abort): Plumb cookie to scm_c_abort. (vm_reinstate_partial_continuation): New stub.
2010-02-22abort always dispatches to VM bytecode, to detect same-invocation abortsAndy Wingo1-3/+14
* 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-19add scm_c_abort, wire it up to the abort opcodeAndy Wingo1-9/+12
* libguile/control.h: * libguile/control.c (scm_c_abort): Add an implementation of `abort', but it doesn't reify the continuation yet. * libguile/vm-i-system.c (abort): * libguile/vm.c (vm_abort): Wire up the call to `abort', avoiding consing the args into a list. * module/language/tree-il/compile-glil.scm (flatten): Add some compily bits that can allow the abort to be resumed.
2010-02-19rename <control> to <abort>Andy Wingo1-2/+2
* libguile/vm-i-system.c (abort): Rename instruction from `throw'. * libguile/vm.c (vm_abort): Rename from vm_throw. * module/language/tree-il.scm (<abort>, make-abort, abort-src, abort-tag, abort-args: Rename from <control> & company. * module/language/tree-il/analyze.scm: * module/language/tree-il/compile-glil.scm: * module/language/tree-il/primitives.scm: Fix all callers.
2010-02-08continuations return multiple values on the stackAndy Wingo1-37/+70
* 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-08scm_i_make_continuation takes vm and vm_cont args explicitlyAndy Wingo1-6/+4
* libguile/continuations.h: * libguile/continuations.c (scm_i_make_continuation): Take VM and VM continuation arguments as well; I'm not convinced that saving all VM continuations was the right thing, and in any case we only ever saved the latest. Running a new VM should create a continuation barrier. * libguile/stacks.c (scm_make_stack): * libguile/vm-i-system.c (call/cc, tail-call/cc): Adapt callers. * libguile/vm.h (scm_i_vm_capture_continuation) (scm_i_vm_reinstate_continuation): Change to be internal, and to only capture and reinstate continuations for a particular VM.
2010-02-08connect a few more wires to promptensteinAndy Wingo1-8/+1
* libguile/tags.h (scm_tc7_prompt): Allocate a tc7 for prompt objects. * libguile/control.h (SCM_F_PROMPT_INLINE, SCM_F_PROMPT_ESCAPE) (SCM_PROMPT_P, SCM_PROMPT_FLAGS, SCM_PROMPT_INLINE_P) (SCM_PROMPT_ESCAPE_P, SCM_PROMPT_TAG, SCM_PROMPT_REGISTERS) (SCM_PROMPT_DYNENV, SCM_PROMPT_HANDLER) (SCM_PROMPT_PRE_UNWIND_HANDLER, SCM_PROMPT_SETJMP) (struct scm_prompt_registers): * libguile/control.c (scm_c_make_prompt): Flesh out a simple prompts implementation. * libguile/vm-i-system.c (prompt): Wire up the implementation. * libguile/vm.c: Add a needed #include.
2010-01-31initial VM support for delimited continuations and dynamic-windAndy Wingo1-0/+21
* libguile/vm-i-system.c (prompt, wind, throw, unwind): New instructions, for implementing dynamic-wind and delimited continuations. * libguile/vm.c: Add some stub support for the new instructions. * libguile/vm-engine.c: Some new error conditions.
2010-01-14vm.c uses scm_c_take_bytevector instead of scm_take_u8vectorAndy Wingo1-2/+2
* libguile/vm.c (really_make_boot_program): Use scm_c_take_bytevector to avoid loading srfi-4 at boot time.
2010-01-09Add cast in `make_vm' to silence compiler warning.Thien-Thi Nguyen1-2/+2
* libguile/vm.c (make_vm): Add cast for .stack_base assignment. Signed-off-by: Thien-Thi Nguyen <ttn@gnuvola.org>
2010-01-09smobs are applied with vm trampoline proceduresAndy Wingo1-33/+0
* libguile/smob.c: Instead of having special evaluator support for applying smobs, we use the same strategy that gsubr uses, that smob application should happen via a trampoline VM procedure, which uses a special opcode (smob-apply). So statically allocate all of the desired trampoline procedures here. (scm_i_smob_apply_trampoline): Unfortunately there's no real place to put the trampoline, so instead use a weak-key hash. It's nasty, but I think the benefits of speeding up procedure calls in the general case are worth it. * libguile/smob.h (scm_smob_descriptor): Remove fields apply_0, apply_1, apply_2, and apply_3; these were never public. Also remove the gsubr_type field. Instead cache the trampoline objcode here. (SCM_SMOB_APPLY_0, SCM_SMOB_APPLY_1, SCM_SMOB_APPLY_2, SCM_SMOB_APPLY_3): Just go through scm_call_0, etc here. * libguile/vm-i-system.c (call, tail-call, mv-call): Simplify. All procedure calls are VM calls now. (smob-call): New instruction, used in smob trampoline procedures. * libguile/vm.c (apply_foreign): Remove. Yay! * libguile/procprop.c (scm_i_procedure_arity): Refactor a bit for the smob changes.
2010-01-07remove scm_tc7_gsubrAndy Wingo1-2/+0
* libguile/tags.h (scm_tc7_gsubr): Return to the pool of unused tc7s, as there are no more gsubrs. Yay :) * libguile/programs.h (SCM_F_PROGRAM_IS_PRIMITIVE): (SCM_PROGRAM_IS_PRIMITIVE): New flag and accessor. * libguile/gsubr.c (create_gsubr): * libguile/snarf.h (SCM_STATIC_PROGRAM): Give subrs a PRIMITIVE flag. * libguile/smob.h: * libguile/smob.c (scm_i_smob_arity): New internal procedure. Uses the old GSUBR type macros, local to the file. * libguile/procprop.c (scm_i_procedure_arity): Call out to scm_i_smob_arity, and remove a gsubr case. * libguile/gc.c (scm_i_tag_name): * libguile/evalext.c (scm_self_evaluating_p): * libguile/goops.c (scm_class_of): * libguile/vm.c (apply_foreign): * libguile/hash.c (scm_hasher): * libguile/debug.c (scm_procedure_name): * libguile/print.c (iprin1): Remove gsubr cases. * libguile/gsubr.h (SCM_PRIMITIVE_P): Fix to work with the new VM program regimen. (SCM_GSUBR_TYPE, SCM_GSUBR_MAKTYPE, SCM_GSUBR_MAX, SCM_GSUBR_REQ) (SCM_GSUBR_OPT, SCM_GSUBR_REST): Remove these macros, that are no longer useful. * libguile/gsubr.c (scm_i_gsubr_apply, scm_i_gsubr_apply_list) (scm_i_gsubr_apply_array): Remove internal gsubr application functions.
2010-01-07tc7 tags for vm-related dataAndy Wingo1-16/+21
* libguile/tags.h (scm_tc7_frame, scm_tc7_objcode, scm_tc7_vm) (scm_tc7_vm_cont): Take more tc7s for VM-related data structures. * libguile/evalext.c (scm_self_evaluating_p): * libguile/gc.c (scm_i_tag_name): * libguile/goops.c (scm_class_of, create_standard_classes): * libguile/print.c (iprin1): Add cases for the new tc7s. * libguile/frames.c: * libguile/frames.h: * libguile/objcodes.c: * libguile/objcodes.h: * libguile/vm.c: * libguile/vm.h: Desmobify. * libguile/vm.c (scm_vm_apply): Export to Scheme, because VM objects are no longer applicable. * module/system/repl/command.scm (profile): * module/system/vm/trace.scm (vm-trace): * module/system/vm/vm.scm (vm-load): Call vm-apply to run a program in a VM instead of treating the VM as applicable.
2010-01-07properly integrate vm bootstrapping into init.cAndy Wingo1-20/+1
* libguile/Makefile.am (modinclude_HEADERS): * libguile/vm-bootstrap.h: Remove vm-bootstrap.h. * libguile/frames.c: No more vm-bootstrap.h. * libguile/instructions.c (scm_init_instructions): * libguile/objcodes.c (scm_init_objcodes): * libguile/programs.c (scm_init_programs): No need to call scm_bootstrap_vm, init.c does that for us. * libguile/vm.c (scm_bootstrap_vm): No need call e.g. scm_bootstrap_frames, init.c does that. Remove a twice-calling guard, should be unnecessary. Don't define the load-compiled subr here. * libguile/load.c (scm_init_load): Define the load-compiled subr here. * libguile/vm.h: Declare scm_bootstrap_vm here. * libguile/init.c (scm_i_init_guile): Properly integrate VM bootstrapping into this file.
2009-12-23keyword arg errors throw to 'keyword-argument-errorAndy Wingo1-7/+4
* libguile/vm-engine.c (VM_NAME): Keyword arg errors are now thrown to 'keyword-argument-error. * libguile/vm.c: Define sym_keyword_argument_error, and statically allocate some other symbols. * module/ice-9/optargs.scm (parse-lambda-case): Throw to 'keyword-argument-error in kwarg error cases. * module/ice-9/psyntax.scm (build-lambda-case): Remove a couple workarounds for the old memoizer. Throw to 'wrong-number-of-args if the lambda-case fails to parse. * module/ice-9/psyntax-pp.scm: Regenerated. * test-suite/tests/optargs.test: Update expected exceptions.
2009-12-21rework vm tracingAndy Wingo1-21/+30
* 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-15Remove unneeded #include <assert.h>.Ludovic Courtès1-1/+0
* libguile/backtrace.c, libguile/eval.c, libguile/gc.c, libguile/goops.c, libguile/memoize.c, libguile/threads.c, libguile/uniform.c, libguile/vm.c, test-suite/standalone/test-conversion.c, test-suite/standalone/test-list.c: Don't include <assert.h>.
2009-12-15Don't use GCC zero-length arrays.Ludovic Courtès1-1/+1
* libguile/frames.c, libguile/objcodes.c, libguile/programs.c, libguile/vm-engine.c, libguile/vm-i-system.c, libguile/vm.c: Use `SCM_C_OBJCODE_BASE ()' instead of accessing the `base' field of `struct scm_objcode'. * libguile/objcodes.h (struct scm_objcode)[base]: Remove.
2009-12-11vm no longer measures bogoclock or times, relies on os for thatAndy Wingo1-21/+0
* libguile/vm.h (struct scm_vm): Remove "time" and "clock" members. The time was bogusly measured, and the "clock" measured instructions retired, which is not a very useful measurement, and it was causing lots of memory accesses. Not that I have done a proper profile, though... (scm_vm_stats): Remove this procedure, which provided access to "time" and "clock". * libguile/vm.c: * libguile/vm-engine.h: * libguile/vm-engine.c: * libguile/vm-i-system.c: Adapt to scm_vm changes and scm_vm_stats removal. * module/system/repl/command.scm: * module/system/vm/vm.scm: Adapt to vm-stats removal by removing vm-stats from <repl>.
2009-12-05remove a bunch of needless scm_permanent_object callsAndy Wingo1-4/+4
* libguile/array-handle.c: * libguile/bytevectors.c: * libguile/deprecated.c: * libguile/eval.c: * libguile/feature.c: * libguile/filesys.c: * libguile/gc.c: * libguile/gdbint.c: * libguile/goops.c: * libguile/instructions.c: * libguile/load.c: * libguile/modules.c: * libguile/numbers.c: * libguile/options.c: * libguile/ports.c: * libguile/scmsigs.c: * libguile/srcprop.c: * libguile/srfi-4.c: * libguile/stacks.c: * libguile/threads.c: * libguile/vm.c: Remove calls to scm_permanent_object, as they are no longer needed with the BDW GC.
2009-12-04eval.c closures are now applicable smobs, not tc3sAndy Wingo1-8/+0
* libguile/debug.c (scm_procedure_name): Remove a SCM_CLOSUREP case and some dead code. (scm_procedure_module): Remove. This was introduced a few months ago for the hygienic expander, but now it is no longer needed, as the expander keeps track of this information itself. * libguile/debug.h: Remove scm_procedure_module. * libguile/eval.c: Instead of using tc3 closures, define a "boot closure" applicable smob type, and represent closures with that. The advantage is that after eval.scm is compiled, boot closures take up no address space (besides a smob number) in the runtime, and require no special cases in procedure dispatch. * libguile/eval.h: Remove the internal functions scm_i_call_closure_0 and scm_closure_apply, and the public function scm_closure. * libguile/gc.c (scm_storage_prehistory): No tc3_closure displacement registration. (scm_i_tag_name): Remove closure case, and a dead cclo case. * libguile/vm.c (apply_foreign): * libguile/print.c (iprin1): * libguile/procs.c (scm_procedure_p, scm_procedure_documentation); * libguile/evalext.c (scm_self_evaluating_p): * libguile/goops.c (scm_class_of): Remove tc3_closure/tcs_closure cases. * libguile/hash.c (scm_hasher): * libguile/hooks.c (scm_add_hook_x): Use new scm_i_procedure_arity. * libguile/macros.c (macro_print): Print all macros using the same code. (scm_macro_transformer): Return any procedure, not just programs. * libguile/procprop.h: * libguile/procprop.c (scm_i_procedure_arity): Instead of returning a list that the caller has to parse, have the same prototype as scm_i_program_arity. An incompatible change, but it's an internal function anyway. (scm_procedure_properties, scm_set_procedure_properties) (scm_procedure_property, scm_set_procedure_property): Remove closure cases, and use scm_i_program_arity for arity. * libguile/procs.h (SCM_CLOSUREP, SCM_CLOSCAR, SCM_CODE) (SCM_CLOSURE_NUM_REQUIRED_ARGS, SCM_CLOSURE_HAS_REST_ARGS) (SCM_CLOSURE_BODY, SCM_PROCPROPS, SCM_SETPROCPROPS, SCM_ENV) (SCM_TOP_LEVEL): Remove these macros that pertain to boot closures only. Only eval.c should know abut boot closures. * libguile/procs.c (scm_closure_p): Remove this function. There is a simple stub in deprecated.scm now. (scm_thunk_p): Use scm_i_program_arity. * libguile/tags.h (scm_tc3_closure): Remove. Yay, another tc3 to play with! (scm_tcs_closures): Remove. * libguile/validate.h (SCM_VALIDATE_CLOSURE): Remove. * module/ice-9/deprecated.scm (closure?): Add stub. * module/ice-9/documentation.scm (object-documentation) * module/ice-9/session.scm (help-doc, arity) * module/oop/goops.scm (compute-getters-n-setters) * module/oop/goops/describe.scm (describe) * module/system/repl/describe.scm (display-object, display-type): Remove calls to closure?.
2009-12-04remove cxrsAndy Wingo1-3/+0
* libguile/pairs.h: * libguile/pairs.c: Previously scm_cdadr et al were implemented as #defines that called scm_i_chase_pairs, and the Scheme-exposed functions themselves were cxr subrs, which got special help in the interpreter. Since now the special help is unnecessary (because the compiler inlines and expands calls to car, cdadr, etc), the complexity is a loss. So just implement cdadr etc using normal functions. There's an advantage too, in that the compiler can unroll the cxring, reducing branches. * libguile/tags.h (scm_tc7_cxr): Remove this tag. (scm_tcs_subrs): Now there's only one kind of subr, yay! * libguile/debug.c (scm_procedure_name) * libguile/evalext.c (scm_self_evaluating_p) * libguile/gc.c (scm_i_tag_name) * libguile/goops.c (scm_class_of) * libguile/hash.c (scm_hasher) * libguile/print.c (iprin1) * libguile/procprop.c (scm_i_procedure_arity) * libguile/procs.c (scm_procedure_p, scm_subr_p) (scm_make_procedure_with_setter) * libguile/vm.c (apply_foreign): Remove cxr cases. Replace uses of scm_tcs_subrs with scm_tc7_gsubr.
2009-12-04remove rpsubrsAndy Wingo1-10/+0
* libguile/tags.h: Remove rpsubrs (I chose to interpret the terse name as "recursive predicate subrs"). Just use gsubrs with rest arguments, or do a fold yourself. * libguile/array-map.c (scm_i_array_equal_p): Do the comparison in order, why not. * libguile/chars.c: * libguile/eq.c: * libguile/numbers.c: * libguile/strorder.c: Add 0,2,1 gsubr wrappers for rpsubrs like eq?, <, etc. * libguile/goops.c (scm_class_of) * libguile/procprop.c (scm_i_procedure_arity) * libguile/procs.c (scm_thunk_p) * libguile/vm.c (apply_foreign): Remove rpsubr cases. * test-suite/tests/numbers.test ("=", "<"): Turn a couple xfails into passes.
2009-12-03remove asubrsAndy Wingo1-10/+0
* libguile/tags.h (scm_tcs_subrs, scm_tc7_asubr): Remove definitions. * libguile/goops.c (scm_class_of) * libguile/procprop.c (scm_i_procedure_arity) * libguile/procs.c (scm_thunk_p) * libguile/vm.c (apply_foreign): Remove cases for asubrs. * libguile/array-map.c: Gut all of the optimizations, because there are no more asubrs, soon won't be rpsubrs, and all of this should happen on the Scheme level, ideally.
2009-12-03simplify apply_foreignAndy Wingo1-26/+8
* libguile/vm.c (apply_foreign): Simplify.
2009-12-03remove scm_tc7_dsubrAndy Wingo1-12/+0
* libguile/tags.h: Remove scm_tc7_dsubr. There are no more users of this. * libguile/array-map.c: * libguile/eval.c: * libguile/eval.i.c: * libguile/goops.c: * libguile/procprop.c: * libguile/procs.h: Remove all dsubr cases.
2009-12-03remove tc7_subr_* and tc7_lsubr_*Andy Wingo1-33/+0
* libguile/tags.h: Remove tc7 #defines for subrs, replacing them with placeholders. These were public, but hopfully unused. I don't see how to usefully deprecate them. * libguile/array-map.c (scm_array_map_x): Remove special cases for certain subr types. This might make things slower for the moment, otoh, native compilation should moot that question. * libguile/eval.i.c: * libguile/eval.c: Remove subr-handling cases. To regain this speed and more won't have to wait for native compilation, though -- this change smooths the way for subr dispatch in the VM. * libguile/gsubr.c (scm_i_gsubr_apply): Fix a bug in which we didn't detect too-many-arguments. This would only show up when using ceval, as only ceval called this function. * test-suite/tests/ramap.test ("array-map!"): Change the expected exception if passed a procedure of the wrong arity. It now gives wrong-num-args. more won't have to wait for native compilation, though -- this change smooths the way for subr dispatch in the VM. * libguile/goops.c (scm_class_of): Remove subr cases. No speed implication. * libguile/objects.c (scm_valid_object_procedure_p): Remove this public but undocumented, and useless, function. I do not think this will affect anyone at all. (scm_set_object_procedure_x): Replace a call to scm_valid_object_procedure_p with scm_procedure_p, and actually wrap with a scm_is_true. * module/oop/goops.scm (initialize-object-procedure): Don't call valid-object-procedure?.
2009-12-03replace frame implementation with VM framesAndy Wingo1-1/+1
* libguile/stacks.h: Rework so that a stack doesn't copy information out of VM frames, it just holds onto a VM frame, along with the stack id and length. VM frames are now the only representation of frames in Guile. (scm_t_info_frame, SCM_FRAME_N_SLOTS, SCM_FRAME_REF, SCM_FRAME_NUMBER) (SCM_FRAME_FLAGS, SCM_FRAME_SOURCE, SCM_FRAME_PROC, SCM_FRAME_ARGS) (SCM_FRAME_PREV, SCM_FRAME_NEXT) (SCM_FRAMEF_VOID, SCM_FRAMEF_REAL, SCM_FRAMEF_PROC) (SCM_FRAMEF_EVAL_ARGS, SCM_FRAMEF_OVERFLOW) (SCM_FRAME_VOID_P, SCM_FRAME_REAL_P, SCM_FRAME_PROC_P) (SCM_FRAME_EVAL_ARGS_P, SCM_FRAME_OVERFLOW_P): Remove these macros corresponding to the old frame implementation. (scm_frame_p scm_frame_source, scm_frame_procedure) (scm_frame_arguments): These definitions are now in frames.h. (scm_last_stack_frame): Remove declaration of previously-removed constructor. Probably should re-instate it though. (scm_frame_number, scm_frame_previous, scm_frame_next) (scm_frame_real_p, scm_frame_procedure_p, scm_frame_evaluating_args_p) (scm_frame_overflow_p) : Remove these procedures corresponding to the old stack implementation. * libguile/stacks.c: Update for new frames implementation. * libguile/frames.h: * libguile/frames.c: Rename functions operating on VM frames to have a scm_frame prefix, not scm_vm_frame -- because they really are the only frames we have. Rename corresponding Scheme functions too, from vm-frame-foo to frame-foo. * libguile/deprecated.h: Remove scm_stack and scm_info_frame data types. * libguile/vm.c (vm_dispatch_hook): Adapt to scm_c_make_frame name change. * module/system/vm/frame.scm: No need to export functions provided frames.c now, as we load those procedures into the default environment now. Rename functions, and remove a couple of outdated, unused functions. The bottom half of this file is still bitrotten, though. * libguile/backtrace.c: Rework to operate on the new frame representation. Also fix a bug displaying file names for compiled procedures. * libguile/init.c: Load the VM much earlier, just because we can. Also it allows us to have frames.[ch] loaded in time for stacks to be initialized, so that scm_frame_arguments can do the right thing.
2009-12-03remove debug framesAndy Wingo1-0/+6
* libguile/debug.h (scm_t_debug_frame): Remove this type, as it was internal to the old evaluator. (SCM_EVALFRAME, SCM_APPLYFRAME, SCM_VOIDFRAME, SCM_MACROEXPF) (SCM_TAILREC, SCM_TRACED_FRAME, SCM_ARGS_READY, SCM_DOVERFLOW) (SCM_MAX_FRAME_SIZE, SCM_FRAMETYPE) (SCM_EVALFRAMEP, SCM_APPLYFRAMEP, SCM_VOIDFRAMEP, SCM_MACROEXPFP) (SCM_TAILRECP, SCM_TRACED_FRAME_P, SCM_ARGS_READY_P, SCM_OVERFLOWP) (SCM_SET_MACROEXP, SCM_SET_TAILREC, SCM_SET_TRACED_FRAME) (SCM_SET_ARGSREADY, SCM_SET_OVERFLOW) (SCM_CLEAR_MACROEXP, SCM_CLEAR_TRACED_FRAME, SCM_CLEAR_ARGSREADY): Remove macro accessors to scm_t_debug_frame. (SCM_DEBUGOBJP, SCM_DEBUGOBJ_FRAME, SCM_SET_DEBUGOBJ_FRAME): (scm_debug_object_p, scm_make_debugobj): Remove debugobj accessors. (scm_i_unmemoize_expr): Remove unused declaration. * libguile/debug.c (scm_debug_options): No more max limit on frame sizes. (scm_start_stack): Just call out to scm_vm_call_with_new_stack. (scm_debug_object_p, scm_make_debugobj, scm_init_debug): No more debugobj smob type. * libguile/deprecated.h: * libguile/deprecated.c (scm_i_deprecated_last_debug_frame) (scm_last_debug_frame): Remove deprecated debug-frame bits. * libguile/stacks.c (scm_make_stack): Rework this function and its dependents to only walk VM frames. (scm_stack_id): Call out to the holder of the VM frame in question, which should be a VM or a VM continuation, for the stack ID. Currently this bit is stubbed out. (scm_last_stack_frame): Removed. It seems this is mainly useful for a debugger, and we need to rewrite the debugger to work on the Scheme level. * test-suite/tests/continuations.test ("continuations"): Remove test for last-stack-frame. * libguile/continuations.h (struct scm_t_contregs): * libguile/continuations.c (scm_make_continuation): (copy_stack_and_call, scm_i_with_continuation_barrier): No need to save and restore debug frames. * libguile/threads.h (scm_i_thread): Don't track debug frames. (scm_i_last_debug_frame, scm_i_set_last_debug_frame): Remove macro accessors. * libguile/threads.c (guilify_self_1): Don't track debug frames. * libguile/throw.c: No need to track debug frames in a jmpbuf. * libguile/vm-engine.c (vm_engine, VM_PUSH_DEBUG_FRAMES): Don't push debug frames. * libguile/vm.h: * libguile/vm.c (scm_vm_call_with_new_stack): New function. Currently stubbed out though.
2009-12-01apply goes to the vm, not the interpreterAndy Wingo1-1/+1
* libguile/eval.c (eval): Call scm_vm_apply instead of apply. (apply): Deleted, no longer referenced. Heh. (scm_apply): Call scm_vm_apply. * libguile/init.c (scm_i_init_guile): Bootstrap the VM before the evaluator. * libguile/vm.c (scm_vm_apply): Actually it's not necessary that the procedure is a program; so that's cool, relax the check.
2009-12-01first step to make the vm stop calling the interpreterAndy Wingo1-0/+128
* libguile/eval.h: * libguile/eval.c (scm_closure_apply): New function, applies a closure. Won't be necessary in the future, but for now here it is, with internal linkage. * libguile/gsubr.h: * libguile/gsubr.c (scm_i_gsubr_apply_array): New function, applies a gsubr to an array of values, potentially extending that array for optional arguments and rest arguments and such. * libguile/vm.c (apply_foreign): New function, applies a foreign function to arguments on the stack, in place. * libguile/vm-i-system.c (call): Add a case for procedures-with-setters (will go away when they are applicable structs). Instead of calling the evaluator for foreign functions, call apply_foreign.
2009-11-28Remove remaining uses of discouraged constructs, really.Ludovic Courtès1-2/+2
* libguile/throw.c, libguile/vm-engine.h, libguile/vm-i-system.c, libguile/vm.c: Replace uses of discouraged constructs by their current counterparts.
2009-11-28Remove remaining uses of discouraged constructs.Ludovic Courtès1-1/+1
* libguile/frames.c, libguile/instructions.c, libguile/objcodes.c, libguile/programs.c, libguile/throw.c, libguile/vm-i-scheme.c, libguile/vm.c: Replace uses of discouraged constructs by their current counterparts.
2009-11-25Remove uses of discouraged constructs.Ludovic Courtès1-4/+4
* libguile/vm-i-scheme.c, libguile/vm-i-system.c, libguile/vm.c: Replace uses of discouraged constructs by their current counterparts.
2009-11-17Fix C99-style declarations after statements.Ludovic Courtès1-1/+2
* libguile/eval.i.c (ceval): Move declarations before statements. * libguile/read.c (scm_read_extended_symbol): Likewise. * libguile/struct.c (scm_make_struct_layout): Likewise. * libguile/threads.c (fat_mutex_unlock): Likewise. * libguile/vm-i-system.c (br_if_nargs_ne, br_if_nargs_lt): Likewise. * libguile/vm.c (make_vm): Likewise.
2009-11-08Fix C99-style comments.Ludovic Courtès1-1/+1
* libguile/generalized-vectors.c, libguile/programs.c, libguile/vm.c: Replace C99-style comments by plain old C89 comments.
2009-10-23de-nargs struct scm_objcode; procedure-property refactorAndy Wingo1-4/+0
* libguile/objcodes.h (struct scm_objcode): Remove nargs, nrest, and nlocs, as they are no longer needed. Also obviates the need for a padding word. * libguile/procs.c (scm_thunk_p): Use scm_i_program_arity for programs. * libguile/procprop.c (scm_i_procedure_arity): Use scm_i_program_arity for programs. (scm_procedure_properties, scm_set_procedure_properties_x) (scm_procedure_property, scm_set_procedure_property_x): Rework so that non-closure properties are stored directly in a weak hash, instead of needing a weak hash of "stand-in" closures to hold the properties. Fix docstrings also. * libguile/root.h (scm_stand_in_procs): Remove from the scm_sys_protects set. Actually with libGC, we should be able to store the elements of scm_sys_protects directly as global variables. * libguile/gc.c (scm_init_storage): Remove scm_stand_in_procs initialization. * libguile/programs.c (scm_i_program_arity): New private accessor, tries to determine the "minimum arity" of a program. * libguile/vm.c (really_make_boot_program): Adapt to changes in struct scm_objcode. * module/language/assembly.scm (*program-header-len*, byte-length): * module/language/assembly/compile-bytecode.scm (write-bytecode): * module/language/assembly/decompile-bytecode.scm (decode-load-program): * module/language/assembly/disassemble.scm (disassemble-load-program): Adapt to changes in objcode. * module/system/xref.scm (program-callee-rev-vars): Adapt to changes in assembly. * module/language/glil.scm: Remove nargs, nrest, and nlocs from glil-program. * module/language/glil/compile-assembly.scm (make-meta, glil->assembly): * module/language/glil/decompile-assembly.scm (decompile-toplevel): (decompile-load-program): Adapt to changes in GLIL and assembly. * module/language/tree-il/compile-glil.scm (flatten-lambda): Adapt to changes in GLIL. * test-suite/tests/asm-to-bytecode.test: Adapt to assembly and bytecode changes. * test-suite/tests/tree-il.test: Adapt to GLIL changes.
2009-10-16jumps encoded using 24 bits, not 19; blocks no longer alignedAndy Wingo1-3/+2
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump. * libguile/vm-i-system.c (FETCH_OFFSET, BR): Labels are no longer 8-byte aligned; instead, jumps are encoded into 3 bytes instead of 2. (br, br-if, br-if-not, br-if-eq, br-if-not-eq, br-if-null) (br-if-not-null, mv-call): Adapt for new length of br instructions (3 bytes instead of 2). * libguile/vm.c (really_make_boot_program): Adapt hand-coded bytecode for new offset regime. * module/language/assembly.scm (align-block): No alignment necessary. * module/language/assembly/compile-bytecode.scm (write-bytecode): Write out breaks as 24-bit relative jumps. * module/language/assembly/decompile-bytecode.scm (decode-load-program): Decompile break instructions.