summaryrefslogtreecommitdiff
path: root/libguile/vm-i-system.c
AgeCommit message (Collapse)AuthorFilesLines
2013-11-08Remove stack programs, objcode, and the old VM.Andy Wingo1-1656/+0
* libguile/Makefile.am: * libguile/vm-i-loader.c: * libguile/vm-i-scheme.c: * libguile/vm-i-system.c: Remove the old VM files, and the rules to build the .i files. * libguile/vm-engine.c: * libguile/vm.c: Remove the old VM. Woot! * libguile/_scm.h (SCM_OBJCODE_COOKIE, SCM_OBJCODE_ENDIANNESS_OFFSET) (SCM_OBJCODE_WORD_SIZE_OFFSET): Remove. * libguile/evalext.c (scm_self_evaluating_p): Remove objcode and program cases. * libguile/frames.c (scm_frame_num_locals, scm_frame_previous): Remove program cases. * libguile/gc.c (scm_i_tag_name): Remove objcode case. * libguile/goops.c (scm_class_of, create_standard_classes): Remove objcode and program cases. * libguile/instructions.h: * libguile/instructions.c (scm_instruction_list, scm_instruction_p) (scm_instruction_length, scm_instruction_pops, scm_instruction_pushes) (scm_instruction_to_opcode, scm_opcode_to_instruction): Remove old VM code. * libguile/objcodes.h: * libguile/objcodes.c: Remove the objcode data type, and handling for objcode files. * libguile/print.c: Remove objcode and program printers. * libguile/procprop.c: Remove program cases. * libguile/procs.c: * libguile/programs.h: * libguile/programs.c: Remove old program code. * libguile/smob.c: Remove objcodes include. * libguile/snarf.h: Remove static program defines. * libguile/stacks.c: Remove program case. * libguile/tags.h: Remove program and objcode tc7s. * module/ice-9/session.scm (procedure-arguments) * module/language/tree-il/analyze.scm (validate-arity) * module/statprof.scm (get-call-data, procedure=?) * module/system/vm/frame.scm (frame-bindings) (frame-call-representation): Remove old program cases. * module/system/repl/debug.scm (frame->module): Add a FIXME. * module/system/vm/instruction.scm: Remove old exports. * module/system/vm/program.scm: Remove old program code.
2013-10-27Partial continuations are RTL stubsAndy Wingo1-1/+3
* libguile/control.c: Implement partial continuations as RTL programs. * libguile/programs.c (scm_i_rtl_program_minimum_arity): Add partial continuation case. * libguile/vm-engine.c (compose-continuation): Fix to look for vm_cont from the free variables. * libguile/vm-i-system.c (abort): Poison continuations captured in the stack VM, as the can't be rewound by the RTL stubs.
2013-10-14Refactor vm_abortAndy Wingo1-3/+7
* libguile/vm.c (vm_abort): * libguile/vm-i-system.c (abort): Refactor abort interface so that it is more amenable to the RTL VM.
2013-10-14Add SCM_F_DYNSTACK_PROMPT_PUSH_NARGS prompt flagAndy Wingo1-0/+1
* libguile/dynstack.h (scm_t_dynstack_prompt_flags): New flag, SCM_F_DYNSTACK_PROMPT_PUSH_NARGS, set if the continuation expects the number of args to be pushed on the top of the stack. * libguile/control.c (scm_c_abort): Only push nargs if requested. * libguile/eval.c (eval): * libguile/throw.c (pre_init_catch): * libguile/vm-i-system.c (prompt): Set SCM_F_DYNSTACK_PROMPT_PUSH_NARGS.
2013-07-16Merge remote-tracking branch 'origin/stable-2.0'Mark H Weaver1-2/+2
Conflicts: libguile/keywords.c libguile/vm.c
2013-06-28Simplify dynstack API to only wind one fluid at a timeAndy Wingo1-4/+4
* libguile/dynstack.h (SCM_DYNSTACK_TYPE_WITH_FLUID): Rename from with-fluids. * libguile/dynstack.c (scm_dynstack_push_fluid): (scm_dynstack_unwind_fluid): Change API to only wind/unwind one fluid binding. (WITH_FLUID_WORDS): New define, always 2 words (fluid and value box). (WITH_FLUID_FLUID, WITH_FLUID_VALUE_BOX): New macros to get offsets of fluid and value box. (scm_dynstack_push_rewinder, scm_dynstack_push_unwinder): Use WINDER_WORDS. (scm_dynstack_push_dynwind): Use DYNWIND_WORDS. (scm_dynstack_wind_1): Update for scm_swap_fluid API change. * libguile/fluids.h: * libguile/fluids.c (scm_prepare_fluids): Remove; no longer needed. (scm_swap_fluid): Update to just swap one fluid binding. (scm_c_with_fluids, scm_c_with_fluid): Update to use scm_dynstack_push_fluid. * libguile/memoize.c (do_push_fluid, do_pop_fluid): Adapt to API change. * libguile/vm-engine.c (rtl_vm_engine): Change wind-fluids / unwind-fluids to push-fluid / pop-fluid, and actually enable. Woo! * libguile/vm-i-system.c (push-fluid, pop-fluid): Update to new API.
2013-06-28Remove with-fluids; replaced by with-fluid* and inlined push-fluid primopsAndy Wingo1-8/+5
* libguile/vm-i-system.c (push-fluid, pop-fluid): * doc/ref/vm.texi (Dynamic Environment Instructions): Rename wind-fluids to push-fluid, and unwind-fluids to pop-fluid. They now only work on one fluid binding at a time. * module/ice-9/boot-9.scm (with-fluid*): Implement in Scheme in terms of primcalls to push-fluid and pop-fluid. (custom-throw-handler, catch, with-throw-handler): Use with-fluid* instead of with-fluids, as with-fluids is no longer available before psyntax is loaded. (with-fluids): Define in Scheme in terms of with-fluid*. * libguile/fluids.c (scm_with_fluid): Rename from scm_with_fluids, and don't expose to Scheme. * libguile/eval.c (eval): Remove SCM_M_WITH_FLUIDS case. * libguile/expand.c (expand_with_fluids): Remove with-fluids syntax. (DYNLET): Remove, no longer defining dynlet in the %expanded-vtables. * libguile/expand.h: Remove dynlet definitions. * module/ice-9/eval.scm (primitive-eval): Remove with-fluids case. * libguile/memoize.c (do_push_fluid, do_pop_fluid): New primitive helpers, like wind and unwind. (memoize): Memoize wind and unwind primcalls. Don't memoize dynlet to with-fluids. (scm_init_memoize): Initialize push_fluid and pop_fluid here. * libguile/memoize.h (SCM_M_WITH_FLUIDS): Remove definition. * module/ice-9/psyntax.scm (build-dynlet): Remove; this just supported with-fluids, which is now defined in boot-9. * module/ice-9/psyntax-pp.scm: Regenerate. * doc/ref/compiler.texi (Tree-IL): * module/language/tree-il.scm: * module/language/tree-il/analyze.scm: * module/language/tree-il/canonicalize.scm: * module/language/tree-il/compile-glil.scm: * module/language/tree-il/cse.scm: * module/language/tree-il/debug.scm: * module/language/tree-il/effects.scm: Remove <dynlet>. Add cases for primcalls to push-fluid and pop-fluid in compile-glil.scm and effects.scm. * module/language/tree-il/peval.scm (peval): Factor out with-temporaries; probably a bad idea, but works for now. Factor out make-begin0 (a better idea). Inline primcalls to with-fluid*, and remove dynlet cases. * module/language/tree-il/primitives.scm (*interesting-primitive-names*): Add with-fluid*.
2013-06-04Print the faulty object upon invalid-keyword errors.Ludovic Courtès1-2/+2
* libguile/vm.c (vm_error_kwargs_invalid_keyword, vm_error_kwargs_unrecognized_keyword): Add parameter. Pass it enclosed in a list as the last argument to `scm_error_scm'. * libguile/vm-i-system.c (bind_kwargs): Adjust accordingly. * libguile/eval.c (error_invalid_keyword, error_unrecognized_keyword): Add parameter. (prepare_boot_closure_env_for_apply): Adjust accordingly. * module/ice-9/eval.scm (primitive-eval): Likewise. * libguile/error.c (scm_error_scm): Mention `keyword-argument-error' in docstring. * module/ice-9/boot-9.scm (keyword-error-printer): New procedure; use it. * test-suite/tests/optargs.test (c&e, with-test-prefix/c&e): Remove. ("define*")["unrecognized keyword"]: Test the value passed along the `keyword-argument-error' exception. ["invalid keyword"]: New test. * doc/ref/api-control.texi (Error Reporting): Update `scm-error' description.
2013-05-27cpp hygiene in the vmAndy Wingo1-0/+3
* libguile/vm-engine.c: * libguile/vm-i-scheme.c: * libguile/vm-i-system.c: CPP hygiene: the code that #defines, #undefs. Makes things cleaner given the multiple inclusion dance we do.
2013-05-27pop-continuation abort-continuation hooks pass return vals directlyAndy Wingo1-2/+2
* doc/ref/api-debug.texi (VM Hooks): Update documentation. * libguile/vm.c (vm_dispatch_hook): * libguile/vm-engine.c: Rework the hook machinery so that they can receive an arbitrary number of arguments. The return and abort hooks will pass the values that they return to their continuations. (vm_engine): Adapt to ABORT_CONTINUATION_HOOK change. * libguile/vm-i-system.c (return, return/values): Adapt to POP_CONTINUATION_HOOK change. * module/system/vm/frame.scm (frame-return-values): Remove. The pop-continuation-hook will pass the values directly. * module/system/vm/trace.scm (print-return): (trace-calls-to-procedure): (trace-calls-in-procedure): Update to receive return values directly. * module/system/vm/traps.scm (trap-in-procedure) (trap-in-dynamic-extent): Ignore return values. (trap-frame-finish, trap-calls-in-dynamic-extent) (trap-calls-to-procedure): Pass return values to the handlers.
2013-05-23remove CONS macro in VM; use scm_cons insteadAndy Wingo1-2/+4
* libguile/vm-engine.c (CONS): Remove. Callers should use scm_cons instead, syncing registers beforehand. (POP_LIST): Adapt, only synchronizing once. (POP_LIST_MARK, POP_CONS_MARK): Remove unused macros. * libguile/vm-i-scheme.c (cons): * libguile/vm-i-system.c (push-rest, bind-rest): Adapt.
2013-01-23merge stable-2.0Andy Wingo1-1/+58
There are some bugs with command-line handling that will be sorted out with the next commit.
2013-01-14case-lambda* clauses fail to match if too many positionalsAndy Wingo1-1/+57
* doc/ref/api-procedures.texi (Case-lambda): Expand case-lambda* documentation. * module/ice-9/eval.scm (primitive-eval): * libguile/eval.c (prepare_boot_closure_env_for_apply): Dispatch to the next case-lambda clause if there are too many positionals. * doc/ref/vm.texi (Function Prologue Instructions): * libguile/vm-i-system.c (bind-optionals/shuffle-or-br): New instruction, like bind-optionals/shuffle but can dispatch to the next clause if there are too many positionals. * module/language/assembly/disassemble.scm (code-annotation): * module/language/assembly/decompile-bytecode.scm (decode-load-program): * module/language/assembly/compile-bytecode.scm (compile-bytecode): Add case for bind-optionals/shuffle-or-br. * module/language/glil/compile-assembly.scm (glil->assembly): If there is an alternate, use bind-optionals/shuffle-or-br instead of bind-optionals/shuffle. * test-suite/tests/optargs.test ("case-lambda*"): Add tests.
2012-05-23Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-3/+1
This commit removes code that was newly deprecated in stable-2.0. Conflicts: libguile/deprecated.c libguile/deprecated.h libguile/modules.c module/ice-9/boot-9.scm module/ice-9/deprecated.scm
2012-05-23deprecate scm_sym2varAndy Wingo1-3/+1
* libguile/deprecated.h: * libguile/deprecated.c (scm_sym2var): Deprecate this function. * libguile/modules.h: * libguile/modules.c (scm_module_ensure_local_variable): New public function, replacing scm_sym2var with a true definep, without going through eval closures (which are deprecated). (scm_current_module): Rework to do something sensible before modules are booted. (scm_module_lookup, scm_lookup): Refactor to use scm_module_variable. (scm_module_define, scm_define): Refactor to use scm_module_ensure_local_variable. * libguile/vm-i-system.c (define!): Use scm_define. * libguile/vm.c (resolve_variable): Use scm_module_lookup. * libguile/macros.c (scm_make_syntax_transformer): Use scm_module_variable. * libguile/gdbint.c (gdb_binding): Use scm_define. * doc/ref/api-modules.texi (Accessing Modules from C): Add docs for scm_module_ensure_local_variable.
2012-05-10Merge remote-tracking branch 'local-2.0/stable-2.0'Andy Wingo1-101/+44
Conflicts: libguile/vm-engine.c libguile/vm-i-system.c libguile/vm.c
2012-05-10refactor vm application of non-programs; boot continuation refactorAndy Wingo1-101/+44
* libguile/frames.c (scm_frame_instruction_pointer): * module/system/vm/frame.scm (frame-bindings): (frame-next-source, frame-call-representation): Fix a few locations that thought that the frame-procedure will always be a VM procedure. This will not not be the case when traversing the stack of an application of a non-procedure. * libguile/vm-i-system.c (call, tail-call, mv-call): Instead of special-casing structs and smobs at these call sites, just set up the stack, and jump to a generic apply loop if the proc is not a program. * libguile/vm-engine.c: The generic apply loop is here. Also, the boot program is now simply a boot continuation, and can handle any number of arguments. * libguile/vm.c (make_boot_program): Update the code that makes the boot continuation.
2012-05-08Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-0/+1
Conflicts: libguile/ports.c libguile/ports.h libguile/read.c libguile/vm-i-system.c
2012-05-07Add a missing SYNC_ALL in variable-refAndy Wingo1-0/+1
* libguile/vm-i-system.c (variable-ref): Add a missing SYNC_ALL.
2012-05-05Correct typing of assertion in the `wind' instruction.Ludovic Courtès1-2/+4
* libguile/vm-i-system.c (wind): Check `scm_to_bool (scm_thunk_p (x))' instead of `scm_thunk_p'.
2012-04-30Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-85/+66
Conflicts: libguile/vm-engine.c libguile/vm-i-system.c
2012-04-30push error handlers out of line in the vmAndy Wingo1-95/+68
* libguile/vm.c: (vm_error): (vm_error_bad_instruction): (vm_error_unbound): (vm_error_unbound_fluid): (vm_error_not_a_variable): (vm_error_not_a_thunk): (vm_error_apply_to_non_list): (vm_error_kwargs_length_not_even): (vm_error_kwargs_invalid_keyword): (vm_error_kwargs_unrecognized_keyword): (vm_error_too_many_args): (vm_error_wrong_num_args): (vm_error_wrong_type_apply): (vm_error_stack_overflow): (vm_error_stack_underflow): (vm_error_improper_list): (vm_error_not_a_pair): (vm_error_not_a_bytevector): (vm_error_not_a_struct): (vm_error_no_values): (vm_error_not_enough_values): (vm_error_continuation_not_rewindable): (vm_error_bad_wide_string_length): (vm_error_invalid_address): (vm_error_object): (vm_error_free_variable): New internal helpers, implementing VM error handling. * libguile/vm-engine.h (VM_ASSERT): New helper macro. (ASSERT, CHECK_OBJECT, CHECK_FREE_VARIABLE): (PRE_CHECK_UNDERFLOW, PUSH_LIST): Use the new helper. * libguile/vm-i-loader.c: * libguile/vm-i-scheme.c: * libguile/vm-i-system.c: Use VM_ASSERT and the out-of-line error handlers. * libguile/vm-engine.c (vm_engine): Remove inline error handlers, and remove a couple of local vars. Use VM_ASSERT. Have halt handle the return itself.
2012-03-18make applicable smob calls cheaper, and fix a memory leakAndy Wingo1-7/+7
* libguile/vm.c (prepare_smob_call): New helper. Now, instead of making a per-smob trampoline, we will shuffle the smob into the args and use a gsubr. This prevents a memory leak in which the trampolines, which were values in a weak-key table, were preventing the smobs from being collected. * libguile/vm-i-system.c (call, tail-call, mv-call): Adapt to new smob application mechanism. (smob-call): Remove this instruction. * libguile/smob.h (scm_smob_descriptor): Rename apply_trampoline_objcode to apply_trampoline. * libguile/smob.c: Remove our own objcode trampolines in favor of using scm_c_make_gsubr. (scm_smob_prehistory): No more trampoline weak map. * libguile/procprop.c (scm_i_procedure_arity): Adapt to applicable smob representation change.
2012-03-18make applicable smob calls cheaper, and fix a memory leakAndy Wingo1-52/+7
* libguile/vm.c (prepare_smob_call): New helper. Now, instead of making a per-smob trampoline, we will shuffle the smob into the args and use a gsubr. This prevents a memory leak in which the trampolines, which were values in a weak-key table, were preventing the smobs from being collected. * libguile/vm-i-system.c (call, tail-call, mv-call): Adapt to new smob application mechanism. (smob-call): Remove this instruction. * libguile/smob.h (scm_smob_descriptor): Rename apply_trampoline_objcode to apply_trampoline. * libguile/smob.c: Remove our own objcode trampolines in favor of using scm_c_make_gsubr. (scm_smob_prehistory): No more trampoline weak map. * libguile/procprop.c (scm_i_procedure_arity): Adapt to applicable smob representation change.
2012-03-07dynstack: pushing a prompt no longer allocates memoryAndy Wingo1-59/+6
* 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-05Merge branch 'bt/elisp'BT Templeton1-54/+66
Conflicts: am/guilec libguile/_scm.h libguile/vm-i-scheme.c module/language/elisp/compile-tree-il.scm module/language/elisp/runtime.scm module/language/elisp/runtime/macros.scm module/language/tree-il/compile-glil.scm module/language/tree-il/primitives.scm
2012-03-03optimize dynamic-wind when we know winders are thunksAndy Wingo1-11/+3
* libguile/vm-i-system.c (wind): * module/language/tree-il/compile-glil.scm (flatten-lambda-case): Instead of making `wind' call `scm_thunk_p' on the winder and unwinder at runtime, make it the responsibility of the compiler to emit code to call thunk? and error, but only if the compiler cannot prove them to be thunks. * libguile/vm-engine.c (vm_engine): Remove a now-unused error block.
2012-03-03the dynamic stack is really a stack now, instead of a listAndy Wingo1-29/+57
* 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-02-03add `nil?' primitiveBT Templeton1-54/+66
* libguile/boolean.c (scm_nil_p): New function. * libguile/vm-i-scheme.c (nilp, not_nilp): * libguile/vm-i-system.c (br_if_nil, br_if_not_nil): New instructions. Renumber other ops. * libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Increment. * module/language/assembly/compile-bytecode.scm (compile-bytecode): Add support for writing `br-if-nil' and `br-if-not-nil' instructions. * module/language/assembly/disassemble.scm (code-annotation): Add `br-if-nil' and `br-if-not-nil' to the list of branch instructions. * module/language/tree-il/compile-glil.scm: Add `nil?' to `*primcall-ops*'. (flatten): Use the new branch instructions for `nil?' conditionals. * module/language/tree-il/primitives.scm: Add `nil?' to `*interesting-primitive-names*', `*effect-free-primitives', and `*effect+exception-free-primitives*'.
2012-01-30Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-21/+4
Conflicts: libguile/debug.h module/ice-9/psyntax-pp.scm module/ice-9/psyntax.scm module/language/tree-il/peval.scm module/language/tree-il/primitives.scm
2012-01-30Merge commit '3d51e57cfb0404db568a6adfde2a346d3fd9907e'Andy Wingo1-4/+21
Conflicts: libguile/foreign.c libguile/hashtab.c module/ice-9/psyntax-pp.scm module/language/tree-il/compile-glil.scm
2012-01-29Revert "attempt to clear stale references on VM C stack"Andy Wingo1-94/+6
This reverts commit 04b2d773548c57b6eadd1808a8d15cce47af9630. Since it wasn't fixing the "lexical vars are collectable" test, it added complexity with no benefit.
2012-01-29Revert "Work around instruction reordering on SPARC and HPPA in the VM."Ludovic Courtès1-21/+4
This reverts commit 2b264d7e4fb649955ade1814527b6eb6f34f4e18, which is unnecessary after commit f5ea0499a411309014475dc7f7983e827f431af2 ("Build with `-fno-strict-aliasing' when available.").
2012-01-27attempt to clear stale references on VM C stackAndy Wingo1-6/+94
* libguile/vm-engine.h (DEAD): New macro, nulls out a value. * libguile/vm-i-system.c: * libguile/vm-i-loader.c: * libguile/vm-i-scheme.c: Use DEAD when variables become dead. Later we can #ifdef this out, but I want to give the buildbots a try with this patch to make sure it's correct.
2012-01-24Work around instruction reordering on SPARC and HPPA in the VM.Ludovic Courtès1-4/+21
Fixes part of <http://bugs.gnu.org/10520>. Reported by Bruno Haible <bruno@clisp.org>. * libguile/vm-i-system.c (COMPILER_BARRIER): New macro. (halt, return, return_values): Insert compiler barrier after each assignment to `fp'.
2011-12-01Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-0/+2
Conflicts: configure.ac libguile/fluids.c libguile/gc.c libguile/gc.h libguile/objcodes.c libguile/procprop.c libguile/vm.c module/ice-9/psyntax-pp.scm module/ice-9/psyntax.scm
2011-11-23optional default-value arg to make-fluidAndy Wingo1-0/+2
* libguile/fluids.c (grow_dynamic_state, new_fluid): Arrange for the default value in the dynamic-state vector to be SCM_UNDEFINED instead of SCM_BOOL_F. If the value in the dynamic-state is #f, default to a value attached to the fluid instead. This allows useful default values. (scm_make_fluid_with_default): New function, allows the user to specify a default value for the fluid. Defaults to #f. Bound to `make-fluid' on the Scheme side. (scm_make_unbound_fluid): Use SCM_UNDEFINED as the default in all threads. (scm_fluid_unset_x): Also unset the default value. Not sure if this is the right thing. (fluid_ref): Update to the new default-value strategy. * libguile/threads.c (scm_i_reset_fluid): Reset to SCM_UNDEFINED. * libguile/threads.h: Remove extra arg to scm_i_reset_fluid. * libguile/vm-i-system.c (fluid-ref): Update to new default-value strategy. * module/ice-9/vlist.scm (block-growth-factor): Default to 2 in all threads. Fixes http://debbugs.gnu.org/10093.
2011-10-24refactor tc7 and tc16 checksAndy Wingo1-3/+3
* libguile/tags.h (SCM_HAS_TYP7, SCM_HAS_TYP7S, SCM_HAS_TYP16): New macros. * libguile/bytevectors.h (SCM_BYTEVECTOR_P): * libguile/control.h (SCM_PROMPT_P): * libguile/filesys.h (SCM_DIRP): * libguile/fluids.h (SCM_WITH_FLUIDS_P, SCM_FLUID_P) (SCM_I_DYNAMIC_STATE_P): * libguile/foreign.h (SCM_POINTER_P): * libguile/fports.h (SCM_FPORTP): * libguile/frames.h (SCM_VM_FRAME_P): * libguile/hashtab.h (SCM_HASHTABLE_P): * libguile/inline.h (scm_get_byte_or_eof): * libguile/numbers.h (SCM_REALP, SCM_BIGP, SCM_COMPLEXP, SCM_FRACTIONP): * libguile/objcodes.h (SCM_OBJCODE_P): * libguile/ports.h (SCM_OUTPUT_PORT_P): * libguile/programs.h (SCM_PROGRAM_P): * libguile/smob.h (SCM_SMOB_PREDICATE): * libguile/srfi-14.h (SCM_CHARSETP): * libguile/strings.c (IS_STRING): * libguile/strports.h (SCM_STRPORTP): * libguile/symbols.h (scm_is_symbol): * libguile/variable.h (SCM_VARIABLEP): * libguile/vectors.h (SCM_I_IS_VECTOR, SCM_I_IS_NONWEAK_VECTOR): * libguile/vm-i-system.c (call, tail-call, mv-call) * libguile/vm.h (SCM_VM_P, SCM_VM_CONT_P): * libguile/weak-set.c (SCM_WEAK_SET_P): * libguile/weak-table.c (SCM_WEAK_TABLE_P): * libguile/weak-vector.h (SCM_I_WVECTP): Use them.
2011-05-13more care regarding SCM_PACK and SCM_UNPACKAndy Wingo1-6/+6
* libguile/control.c (reify_partial_continuation): * libguile/eval.c (RETURN_BOOT_CLOSURE): * libguile/frames.c (scm_frame_num_locals, scm_frame_local_ref) (scm_frame_local_set_x) * libguile/frames.h (SCM_FRAME_SET_RETURN_ADDRESS): (SCM_FRAME_SET_MV_RETURN_ADDRESS, SCM_FRAME_SET_DYNAMIC_LINK): * libguile/goops.c (scm_class_of, scm_primitive_generic_generic) (scm_c_extend_primitive_generic, compute_getters_n_setters) (scm_sys_initialize_object): * libguile/guardians.c (finalize_guarded): * libguile/list.c (SCM_I_CONS): * libguile/macros.c (scm_i_make_primitive_macro) (scm_make_syntax_transformer): * libguile/memoize.c (MAKMEMO, SCM_MAKE_MEMOIZER) (SCM_MAKE_REST_MEMOIZER): * libguile/modules.c (scm_module_reverse_lookup) * libguile/print.c (iprin1): * libguile/promises.c (scm_make_promise) * libguile/srcprop.c (scm_make_srcprops): * libguile/vectors.c (scm_c_vector_ref): * libguile/vm-engine.c (vm_engine) * libguile/vm-i-scheme.c (REL, add1, sub1): * libguile/vm-i-system.c (new_frame, call_cc) * libguile/weaks.h (SCM_WEAK_PAIR_WORD_DELETED_P): Be more careful about SCM_PACK / SCM_UNPACK.
2011-05-13scm_is_eq for SCM vals, not == or !=Andy Wingo1-10/+4
* libguile/bytevectors.c (scm_make_bytevector, STRING_TO_UTF) (UTF_TO_STRING): * libguile/continuations.c (scm_i_check_continuation): * libguile/expand.h (SCM_EXPANDED_P): * libguile/fluids.c (scm_i_make_with_fluids): * libguile/generalized-vectors.c (scm_make_generalized_vector): * libguile/goops.c (SCM_GOOPS_UNBOUNDP, slot_definition_using_name): (scm_c_extend_primitive_generic, more_specificp, scm_make) * libguile/i18n.c (SCM_VALIDATE_OPTIONAL_LOCALE_COPY): (scm_locale_string_to_integer) * libguile/modules.c (resolve_duplicate_binding): (scm_module_reverse_lookup) * libguile/posix.c (scm_to_resource): * libguile/r6rs-ports.c (scm_put_bytevector): * libguile/socket.c (scm_connect, scm_bind, scm_sendto * libguile/stacks.c (find_prompt): * libguile/variable.c (scm_variable_ref, scm_variable_bound_p): * libguile/vm-engine.h (ASSERT_BOUND_VARIABLE, ASSERT_BOUND) * libguile/vm-i-system.c (VARIABLE_BOUNDP, local_bound) (long_local_bound, fluid_ref): Use scm_is_eq to compare, not == / !=.
2011-05-06avoid tls gets when handling interrupts in the vmAndy Wingo1-4/+4
* libguile/__scm.h (SCM_ASYNC_TICK_WITH_CODE): Redefine to take a scm_i_thread* as well. OK to do because it's within a BUILDING_LIBGUILE block. * libguile/vm-engine.c (vm_engine): Cache the scm_i_thread* instead of the dynstate, so we can use the thread for ticks. * libguile/vm-engine.h (VM_HANDLE_INTERRUPTS): Tick with the scm_i_thread* local var, to avoid excessive tls calls. * libguile/vm-i-system.c: Fix dynstate users to use current_thread->dynamic_state.
2011-05-05VM tweaksAndy Wingo1-23/+29
* libguile/vm-engine.c (VM_CHECK_OBJECT, VM_CHECK_FREE_VARIABLES): Set to 0 for both engines. These are really internal debugging variables, which don't affect user-visible features, provided that the compiler is correct of course. (VM_CHECK_UNDERFLOW): New var, also off by default: whether to check for stack underflow when popping values. (vm_engine): Don't declare object_count if we are not checking object table accesses. * libguile/vm-engine.h (CACHE_PROGRAM): Don't muck with object_count if we are not checking object table accesses. (CHECK_UNDERFLOW, PRE_CHECK_UNDERFLOW): Nop out if we are not checking underflow. (POP2, POP3): New macros which check for underflow before popping more than one value. * libguile/vm-i-loader.c (load_array): * libguile/vm-i-scheme.c (set_car, set_cdr, vector_set, slot_set) (BV_SET_WITH_ENDIANNESS, BV_FIXABLE_INT_SET, BV_INT_SET) (BV_FLOAT_SET): * libguile/vm-i-system.c (partial_cont_call, fix_closure, prompt) (fluid_set): Use POP2 / POP3. (local_set, long_local_set): Pop to locals instead of using values on the stack then dropping; allows for underflow to be checked before the value is accessed. (BR): Don't NULLSTACK or DROP after the operation. (br_if, br_if_not, br_if_eq, br_if_not_eq, br_if_null) (br_if_not_null): Pop to locals before doing the compare and jump.
2011-03-19fix new-frame push in call/ccAndy Wingo1-1/+1
* libguile/vm-i-system.c (call/cc): Whoops, fix the new-frame push here. A little birdie tells me a test case is coming soon.
2011-03-15fix frame dynamic linkage in the face of partial continuation applicationAndy Wingo1-13/+36
* libguile/vm-i-system.c (new-frame): Though it was appealing to set the dynamic link here on the incomplete frame, we no longer do that, for the reasons mentioned in the code. (call, mv-call): Adapt to set the frame's dynamic link. * libguile/vm-engine.c (vm_engine): Don't set dynamic link here, even for boot program. * libguile/frames.c (scm_frame_num_locals, scm_frame_local_ref) (scm_frame_local_set_x): Fix up not-yet-active frame detection.
2011-01-27fix error handling in variable-ref family of instructionsAndy Wingo1-5/+27
* libguile/vm-i-system.c (variable-ref, variable-set, variable-bound?): Check that the argument is actually a variable. Thanks to Kevin Holmes for the report. * libguile/vm-engine.c (vm_engine): Error handling down here. * THANKS: Update.
2010-12-07unbound fluidsBrian Templeton1-1/+9
* libguile/fluids.c (scm_make_undefined_fluid, scm_fluid_unset_x) (scm_fluid_bound_p): New functions. (fluid_ref): New function; like scm_fluid_ref, but will not throw an error for unbound fluids. (scm_fluid_ref, swap_fluid): Use `fluid_ref'. * libguile/fluids.h (scm_make_undefined_fluid, scm_fluid_unset_x) (scm_fluid_bound_p): New prototypes. * libguile/vm-i-system.c (fluid_ref): If fluid is unbound, jump to `vm_error_unbound_fluid'. * libguile/vm-engine.c (VM_NAME)[vm_error_unbound_fluid]: New error message. * test-suite/tests/fluids.test ("unbound fluids")["fluid-ref of unbound fluid", "fluid-bound? of bound fluid", "fluid-bound? of unbound fluid", "unbound fluids can be set", "bound fluids can be unset"]: New tests.
2010-12-07better unbound variable errors in the vmAndy Wingo1-3/+3
* libguile/vm-i-system.c (variable-ref, toplevel-ref) (long-toplevel-ref): Fixup callers. * libguile/vm-engine.c (vm_error_unbound): Don't use vm-error for unbound vars, use misc-error. Don't include VM: in the string. Take the name directly in finish_args, not as a list.
2010-10-14Unresolved var errors don't work for top-level varsMichael Gran1-8/+10
* libguile/vm-i-system.c (toplevel_ref, long_toplevel_ref): modified
2010-10-13fix bug in with-fluids in a non-tail positionAndy Wingo1-4/+5
* libguile/vm-i-system.c (VM_DEFINE_INSTRUCTION): Drop the stack items corresponding the the with-fluids object. Thanks very much to Stefan Israelsson Tampe for the fix.
2010-10-08inline symbol? and vector? to opcodes, and a psyntax inlining tweakAndy Wingo1-92/+92
* libguile/vm-i-scheme.c (symbol?, vector?): New instructions. Renumbered the rest. * libguile/vm-i-system.c: Renumber instructions. * libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump. * module/ice-9/psyntax.scm (binding-type, binding-value): Define using macros so that we inline to car and cdr opcodes. Oh, for an inliner :) * module/language/tree-il/compile-glil.scm (*primcall-ops*) * module/language/tree-il/primitives.scm (*interesting-primitive-names*, *effect-free-primitives*) (*effect+exception-free-primitives*): Add symbol? and vector? inlines.