bpt/guile.git
15 years agodon't truncate .go files, do an atomic rename to prevent SIGBUS
Andy Wingo [Sat, 9 Aug 2008 12:11:35 +0000 (14:11 +0200)]
don't truncate .go files, do an atomic rename to prevent SIGBUS

* module/system/base/compile.scm (call-with-output-file/atomic): New
  proc, outputs to a tempfile then does an atomic rename. Prevents SIGBUS
  if a compiled file is truncated and rewritten, as the file's objcode is
  mmap'd in.
  (compile-file): Use the new helper.

15 years agofix source location reporting for compiled code
Andy Wingo [Sat, 9 Aug 2008 11:41:23 +0000 (13:41 +0200)]
fix source location reporting for compiled code

* module/system/repl/repl.scm (default-catch-handler): Cosmetic
  improvements on VM error backtraces.

* module/system/vm/frame.scm (print-frame): Cosmetic improvements.
  (frame-line-number): source:line operates on the handle, not the cdr.
  (print-frame-chain-as-backtrace): Cosmetic improvements.

15 years agoheapify the bootstrap program
Andy Wingo [Fri, 8 Aug 2008 15:05:41 +0000 (17:05 +0200)]
heapify the bootstrap program

* src/vm_engine.c (vm_run):
* src/programs.c (scm_c_make_program): If the holder is #f, malloc *and*
  copy the bytecode.

* module/system/vm/frame.scm (bootstrap-frame?): Now that we actually
  heapify the bootstrap program, we can check for `halt' in the bytecode.

15 years agoMore relevant VM backtrace
Andy Wingo [Fri, 8 Aug 2008 11:19:49 +0000 (13:19 +0200)]
More relevant VM backtrace

* module/system/repl/repl.scm: Remove a useless print in the backtrace
  handler.

* module/system/vm/debug.scm (vm-backtrace): s/reverse!/reverse/

* module/system/vm/frame.scm (bootstrap-frame?): A heuristic to see if a
  frame is a bootstrap frame, the one allocated on the stack in
  vm_engine.c; need to have a better solution for this.
  (make-frame-chain): Don't include bootstrap frames, they add no
  information.
  (print-frame-chain-as-backtrace): Remove a pk.

* src/vm_engine.c (vm_run): Add a fixme about the bootstrap prograp.

15 years agoimprove source loc info in nonlocal exits and backtraces
Andy Wingo [Fri, 8 Aug 2008 10:55:57 +0000 (12:55 +0200)]
improve source loc info in nonlocal exits and backtraces

* module/system/il/compile.scm (codegen): The currently-executing
  instruction is actually the one right before the instruction pointer;
  so for purposes of assv to find a source location for an ip, put the
  source after the code, as it was before.

* module/system/vm/debug.scm (vm-backtrace): Move more code to frame.scm.

* module/system/vm/frame.scm (make-frame-chain): Include all frames, even
  the bootstrap one. For a reentrant backtrace we'll have boostrap
  programs anyway. Probably should check for objcode[2] == scm_op_halt,
  to not show those frames in the trace.
  (frame-line-number, frame-file): New helpers.
  (print-frame): Print out the line number too.
  (frame-call-representation): Code from print-frame-call moved here.
  (print-frame-chain-as-backtrace): A backtrace printer, yays.
  (program-name): Check link validity before calling frame-address on it.

* module/system/vm/program.scm (source:addr, source:line, source:column)
  (source:file): New accessors for the elements of program-sources.

* module/system/vm/vm.scm (vm:last-ip): New export.
  (vm-last-frame-chain): Use vm:last-ip in making the frame chain.

* src/vm.h (struct scm_vm):
* src/vm.c (make_vm, scm_vm_last_ip, scm_vm_save_stack): Save the last
  instruction pointer when saving the stack. Really though, we should be
  saving all of the stack data on a spaghetti stack.

* src/vm_system.c (late-variable-ref): Pointless s/REGISTER/BEFORE_GC/.

15 years agofix bug in variable-set instruction; ,x prints out program metadata
Andy Wingo [Thu, 7 Aug 2008 22:26:17 +0000 (00:26 +0200)]
fix bug in variable-set instruction; ,x prints out program metadata

* module/system/vm/disasm.scm (disassemble-program, disassemble-meta):
  Disassemble program meta information too, if it's there.

* src/vm_system.c (variable-set): Don't try to proxy name information;
  maybe we can do this later, but the code as it was was calling SCM_CAR
  on a variable, which is for the lose.

15 years agoFix build failure on Debian hppa architecture (bad stack growth detection)
Neil Jerram [Thu, 7 Aug 2008 21:24:31 +0000 (23:24 +0200)]
Fix build failure on Debian hppa architecture (bad stack growth detection)

* configure.in (SCM_I_GSC_STACK_GROWS_UP): Remove use of
AC_CACHE_CHECK, which was inadvertently causing
SCM_I_GSC_STACK_GROWS_UP _always_ to be 0.

15 years agofix stack corruption on vm-save-stack; more robust with nonlocal exits
Andy Wingo [Thu, 7 Aug 2008 17:04:25 +0000 (19:04 +0200)]
fix stack corruption on vm-save-stack; more robust with nonlocal exits

* module/system/repl/command.scm: Coerce rationals to floats.

* module/system/vm/program.scm (program-documentation): Fix a typo, doh!

* src/vm.c (vm_reset_stack, struct vm_unwind_data): Add unwind handler to
  reset vp->sp, vp->fp, and vp->this_frame when performing a nonlocal
  exit from a vm_run.
  (vm_heapify_frames_1): Don't repack the stack, it causes stack
  corruption. I think we need spaghetti stacks to handle continuations,
  not separate heap frames. I don't think call/cc is working now.
  (vm-save-stack): Don't call heapify_frames, that modifies the stack
  that we're copying. Instead call its helper, heapify_1.

* src/vm_engine.c (vm_run): Set up the vm_reset_stack unwind handler.

* src/vm_engine.h (IP_REG, SP_REG, FP_REG): If we got through all of the
  checks without having these macros defined, define them as empty.
  Happens on x86-64.

* src/vm_system.c (halt): End the dynwind before we return from the VM.

* src/vm_scheme.c (REL): Sync the regs before calling scm_lt_p et al,
  cause they can do a nonlocal exit.

15 years agovm backtrace improvements
Andy Wingo [Thu, 7 Aug 2008 11:51:45 +0000 (13:51 +0200)]
vm backtrace improvements

* module/system/repl/repl.scm (default-pre-unwind-handler): Save the VM
  stack in addition to the interpreter stack. At some point these
  functions should know about each other, I guess.
  (default-catch-handler): Show the VM stack too. Needs a bit of work.

* module/system/vm/frame.scm: Export make-frame-chain.

* module/system/vm/vm.scm: Export vm-save-stack.

* src/vm.c (scm_vm_save_stack): New function, heapifies the current
  stack, saving it to vm->last_frame.

* src/vm_engine.c (vm_run:vm_error): Don't heapify frames here, because
  nonlocal exits avoid this code entirely. Instead rely on the user
  saving the stack with a pre-unwind handler, as the repl does.

15 years agobuild fixes
Andy Wingo [Thu, 7 Aug 2008 11:29:15 +0000 (13:29 +0200)]
build fixes

* benchmark/measure.scm: Update for module changes.

* module/system/vm/Makefile.am: Update the set of modules needing
  compilation.

* src/guile-vm.c: Bootstrap the VM, now that we have a function for it.

* testsuite/Makefile.am:
* testsuite/run-vm-tests.scm: Update to fix make check, broken since we
  merged with Guile.

15 years agobig reorg of scheme modules -- e.g. programs.c -> (system vm program)
Andy Wingo [Thu, 7 Aug 2008 11:11:27 +0000 (13:11 +0200)]
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.

15 years agosync registers before calling c functions, really
Andy Wingo [Tue, 5 Aug 2008 22:13:31 +0000 (00:13 +0200)]
sync registers before calling c functions, really

* src/vm_loader.c:
* src/vm_scheme.c: Use SYNC_REGISTER, although it's the same as
  SYNC_BEFORE_GC. A style issue?

* src/vm_system.c (call, tail-call): Explicitly do a SYNC_REGISTER, not
  relying on POP_LIST to do it for us, because POP_LIST won't do it if
  there are 0 arguments. The way that this manifested itself to me was
  badness after the second (read) call in a repl session. I wish I
  understood more about this problem.

15 years agosave vm's state before calling out to c procedures
Andy Wingo [Tue, 5 Aug 2008 21:08:58 +0000 (23:08 +0200)]
save vm's state before calling out to c procedures

* .gitignore: Ignore .go files.

* src/vm_loader.c:
* src/vm_scheme.c:
* src/vm_system.c: Sync the VM's state before calling out to C
  procedures that might cons or cause a nonlocal exit.

15 years agodisable trampoline "optimizations"
Andy Wingo [Tue, 5 Aug 2008 19:56:29 +0000 (21:56 +0200)]
disable trampoline "optimizations"

* src/vm_system.c: Disable those trampoline "optimizations", as they
  actually slowed down benchmark/measure.scm '(fibo 30)'. They were
  edifying, in that now I have an appreciation of the need for
  SYNC_ALL().

15 years agore-enable computed goto; fix ,help in the repl; subr dispatch optimizations
Andy Wingo [Mon, 4 Aug 2008 23:03:17 +0000 (01:03 +0200)]
re-enable computed goto; fix ,help in the repl; subr dispatch optimizations

* m4/labels-as-values.m4: New file, checks for computed goto.

* configure.in: Use AC_C_LABELS_AS_VALUES.

* module/system/repl/command.scm (procedure-documentation): Extend the
  core's procedure-documentation in an ad-hoc way, so that ,help works.

* module/system/vm/core.scm (program-properties): New function.
  (program-documentation): New function.

* src/vm_engine.h (DROP, DROPN): Decrement sp before checking for
  underflow.

* src/vm_system.c (call, tail-call): Add some optimized dispatch for some
  C functions, so that we can avoid consing and the interpreter if
  possible. However currently it seems that I'm always getting the
  scm_call_* trampolines back.

15 years agoAdd docstring support
Andy Wingo [Sun, 3 Aug 2008 12:33:02 +0000 (14:33 +0200)]
Add docstring support

* module/language/scheme/translate.scm (translate): Adapt to lambda
  having a `meta' slot now.
  (primitive-syntax-table, parse-lambda-meta): Parse out a docstring from
  lambda forms, putting in the <ghil-lambda>'s meta slot.

* module/system/il/compile.scm (optimize, codegen): Passthrough for the
  `meta' slot to the <glil-asm> object.

* module/system/il/ghil.scm (<ghil-lambda>): Add meta slot.

* module/system/il/glil.scm (<glil-asm>): Add meta slot.
  (unparse): Unparse meta.

* module/system/vm/assemble.scm (preprocess): Pass through the meta slot.
  (codegen): So, set the bytespec's meta slot as a list: bindings, source
  info, then the tail is the meta-info, which should be an alist.
  Currently the only defined key is `documentation', but `name' could
  come in the future.

* module/system/vm/core.scm (program-sources): Sources are now in the
  cadr...
  (program-property): And here we have access to the cddr.

15 years agofix recording of source locations
Andy Wingo [Sun, 3 Aug 2008 12:03:47 +0000 (14:03 +0200)]
fix recording of source locations

* module/language/scheme/translate.scm (translate, trans)
  (make-pmatch-transformers): When recursing into subexpressions, get the
  appropriate source location information.
  (location): Include the source filename in the location information.

* module/system/il/compile.scm (codegen): Record source locations in more
  cases. (This information ends up being part of the procedure metadata,
  not the actual codepath.)

* module/system/il/glil.scm (unparse): Don't destructure the source
  locations (it's a vector now).

15 years agoFix misleading output from `(help rationalize)'
Neil Jerram [Sat, 2 Aug 2008 23:18:33 +0000 (00:18 +0100)]
Fix misleading output from `(help rationalize)'

* numbers.c (scm_rationalize): Update docstring to match the
manual (which is more correct).  Change argument "err" to "eps",
also to match the manual.

15 years agoonly pass symbols to module-ref & c
Andy Wingo [Sat, 2 Aug 2008 10:46:14 +0000 (12:46 +0200)]
only pass symbols to module-ref & c

* module/language/scheme/translate.scm: Make sure that we're actually
  passing symbols to module-ref et al.

15 years agoadd compile-toplevel and evaluate conditions to eval-case
Andy Wingo [Mon, 19 May 2008 10:26:20 +0000 (12:26 +0200)]
add compile-toplevel and evaluate conditions to eval-case

* ice-9/boot-9.scm (eval-case): Define two more conditions:
  compile-toplevel and evaluate, as common lisp and chez scheme do.
  (defmacro, define-option-interface, define-macro, define-syntax-macro)
  (define-module, use-modules, use-syntax, define-public)
  (defmacro-public, export, re-export): Add `compile-toplevel' to all
  uses of eval-case.

15 years agomake has-suffix? use string-suffix?
Andy Wingo [Mon, 19 May 2008 10:23:46 +0000 (12:23 +0200)]
make has-suffix? use string-suffix?

* ice-9/boot-9.scm (has-suffix?): Use the core / srfi-13's
  string-suffix?.

15 years agoSupport loading of compiled syncase macros
Andy Wingo [Mon, 19 May 2008 10:19:28 +0000 (12:19 +0200)]
Support loading of compiled syncase macros

* ice-9/syncase.scm (current-eval-closure): New procedure.
  (env->eval-closure): Don't default to the root module: if we have no
  environment, we default to the current module via the logic in
  current-eval-closure. This is because psyntax's compilation mode
  doesn't know about guile modules, and thus won't dump the code to
  twiddle the current eval closure.
  (putprop, getprop, guile-macro): Use `current-eval-closure'.
  At the end, leave the expansion-eval-closure set to #f.

15 years agosupport thunks as prompts, as readline does.
Andy Wingo [Fri, 9 May 2008 14:42:44 +0000 (16:42 +0200)]
support thunks as prompts, as readline does.

* ice-9/boot-9.scm (repl-reader): Support thunks as prompts.

15 years agomake readline's `repl-reader' impl check the current-reader fluid
Andy Wingo [Sat, 2 Aug 2008 10:29:07 +0000 (12:29 +0200)]
make readline's `repl-reader' impl check the current-reader fluid

* guile-readline/ice-9/readline.scm (activate-readline): Use the current
  binding of the current-reader fluid, if it is available.

15 years agoFixes to make guile-vm compile in guile source tree
Andy Wingo [Sat, 2 Aug 2008 10:17:27 +0000 (12:17 +0200)]
Fixes to make guile-vm compile in guile source tree

* INSTALL: Updated.
* m4/gnulib-cache.m4: Regenerated.

* Makefile.am: Spelling fix.

* guilec.mk:
* src/Makefile.am:
* src/vm.c: Update to actually work inside a guile source tree.

* libguile/Makefile.am: Don't error on warnings in the flex-generated
  c-tokenize function.

15 years agomerge guile-vm to guile
Andy Wingo [Sat, 2 Aug 2008 09:40:32 +0000 (11:40 +0200)]
merge guile-vm to guile

An attempt to pull in the original history from guile-vm into guile itself.

15 years agoSingle stepping through code from Emacs
Neil Jerram [Fri, 11 Jul 2008 16:53:43 +0000 (17:53 +0100)]
Single stepping through code from Emacs

When you use GDS to evaluate Scheme code from Emacs, you can now use
`C-u' to indicate that you want to single step through that code. See
`Evaluating Scheme Code' in the manual for more details.

* scheme-using.texi (Evaluating Scheme Code): Document use of
        `C-u' prefix with evaluation commands.

        * gds-scheme.el (gds-eval-region, gds-eval-expression)
        (gds-eval-defun, gds-eval-last-sexp): Support `C-u' prefix,
        meaning that user wants to single step through the code.

        * gds-client.scm (handle-nondebug-protocol): Add support for
        setting a trap on code that is about to be evaluated.

15 years agoChangeLog for "Improve stack direction test"
Neil Jerram [Thu, 17 Jul 2008 21:03:49 +0000 (22:03 +0100)]
ChangeLog for "Improve stack direction test"

15 years agoChangeLog for "Improved MIPS/Linux gc_os_dep.c definitions"
Neil Jerram [Thu, 17 Jul 2008 21:02:01 +0000 (22:02 +0100)]
ChangeLog for "Improved MIPS/Linux gc_os_dep.c definitions"

15 years agoHandle lack of `struct dirent64' and `readdir64_r ()' on HP-UX 11.11.
Ludovic Courtès [Wed, 16 Jul 2008 22:17:56 +0000 (00:17 +0200)]
Handle lack of `struct dirent64' and `readdir64_r ()' on HP-UX 11.11.

15 years agoImprove stack direction test
Neil Jerram [Fri, 11 Jul 2008 22:30:19 +0000 (23:30 +0100)]
Improve stack direction test

* configure.in: Update stack direction test to be like that in
Autoconf _AC_LIBOBJ_ALLOCA and Gnulib; specifically in involving a
function calling itself.

15 years agoImproved MIPS/Linux gc_os_dep.c definitions
Neil Jerram [Sat, 12 Jul 2008 18:22:59 +0000 (19:22 +0100)]
Improved MIPS/Linux gc_os_dep.c definitions

From Thiemo Seufer <ths@networkno.de>:

* gc_os_dep.c (CPP_WORDSZ, ALIGN_DOUBLE, DATAEND,
DYNAMIC_LOADING): Added #defines.
(_fdata, _end): Added declarations.
(DATASTART): Use _fdata instead of __data_start.
(STACKBOTTOM): Changed from 0x80000000 to 0x7fff8000.

15 years agoUse `-q' when running standalone tests.
Ludovic Courtès [Sun, 6 Jul 2008 21:58:15 +0000 (23:58 +0200)]
Use `-q' when running standalone tests.

15 years agoUpdate `INSTALL'.
Ludovic Courtès [Sun, 6 Jul 2008 17:55:18 +0000 (19:55 +0200)]
Update `INSTALL'.

15 years agoUpdate to Autoconf 2.61.
Ludovic Courtès [Sun, 6 Jul 2008 17:53:49 +0000 (19:53 +0200)]
Update to Autoconf 2.61.

15 years agoUpdate Gnulib files.
Ludovic Courtès [Sat, 5 Jul 2008 18:24:51 +0000 (20:24 +0200)]
Update Gnulib files.

15 years agoAdd `scm_c_symbol_length ()'.
Ludovic Courtès [Sat, 5 Jul 2008 18:10:44 +0000 (20:10 +0200)]
Add `scm_c_symbol_length ()'.

15 years agoDon't declare `scm_i_locale_mutex' as `SCM_INTERNAL'.
Ludovic Courtès [Fri, 4 Jul 2008 20:22:06 +0000 (22:22 +0200)]
Don't declare `scm_i_locale_mutex' as `SCM_INTERNAL'.

15 years agoUpdate `THANKS'.
Ludovic Courtès [Fri, 4 Jul 2008 20:03:08 +0000 (22:03 +0200)]
Update `THANKS'.

15 years agoFix `SCM_INTERNAL' with GCC 4.3.
Ludovic Courtès [Fri, 4 Jul 2008 20:02:56 +0000 (22:02 +0200)]
Fix `SCM_INTERNAL' with GCC 4.3.

15 years agoAdd `NEWS' entry for SRFI-18.
Ludovic Courtès [Mon, 30 Jun 2008 17:48:50 +0000 (19:48 +0200)]
Add `NEWS' entry for SRFI-18.

15 years agosrfi-modules.texi (SRFI-18): New sections.
Julian Graham [Sat, 21 Jun 2008 04:55:17 +0000 (00:55 -0400)]
srfi-modules.texi (SRFI-18): New sections.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
15 years agoModernize Automake files.
Ludovic Courtès [Sat, 28 Jun 2008 20:00:44 +0000 (22:00 +0200)]
Modernize Automake files.

15 years agoFix doc typo regarding `use-syntax' and "syntax transformers".
Ludovic Courtès [Sat, 28 Jun 2008 18:37:21 +0000 (20:37 +0200)]
Fix doc typo regarding `use-syntax' and "syntax transformers".

15 years agoFix harmless typo in SRFI-19.
Ludovic Courtès [Sat, 28 Jun 2008 18:32:17 +0000 (20:32 +0200)]
Fix harmless typo in SRFI-19.

15 years agoDisable type-checking of `SCM_UNPACK' for the broken HP compilers.
Ludovic Courtès [Sat, 28 Jun 2008 18:31:01 +0000 (20:31 +0200)]
Disable type-checking of `SCM_UNPACK' for the broken HP compilers.

16 years agoUpdate `THANKS'.
Ludovic Courtès [Mon, 2 Jun 2008 19:47:53 +0000 (21:47 +0200)]
Update `THANKS'.

16 years agoguile-config: Show `-L$libdir' before `-lguile'.
Ludovic Courtès [Mon, 2 Jun 2008 19:47:41 +0000 (21:47 +0200)]
guile-config: Show `-L$libdir' before `-lguile'.

16 years agoWork around `#define except' on Tru64.
Ludovic Courtès [Mon, 2 Jun 2008 19:43:07 +0000 (21:43 +0200)]
Work around `#define except' on Tru64.

16 years agoSupport systems whose <inttypes.h> doesn't define `PRIiMAX'.
Ludovic Courtès [Mon, 2 Jun 2008 19:34:57 +0000 (21:34 +0200)]
Support systems whose <inttypes.h> doesn't define `PRIiMAX'.

16 years agoFix SRFI-88 URL in the manual.
Ludovic Courtès [Sun, 1 Jun 2008 11:09:36 +0000 (13:09 +0200)]
Fix SRFI-88 URL in the manual.

16 years agoUpdate `NEWS'.
Ludovic Courtès [Sat, 31 May 2008 21:19:55 +0000 (23:19 +0200)]
Update `NEWS'.

16 years agoAdd `SCM_INTERNAL' macro, use it.
Ludovic Courtès [Wed, 14 May 2008 03:20:47 +0000 (05:20 +0200)]
Add `SCM_INTERNAL' macro, use it.

16 years agoUpdated loop disassembly
Andy Wingo [Sun, 25 May 2008 11:43:26 +0000 (13:43 +0200)]
Updated loop disassembly

* benchmark/lib.scm: Update loop disassembly, with inlining. Neat!

16 years agoadd inline macros for zero? and 1-
Andy Wingo [Sun, 25 May 2008 11:38:17 +0000 (13:38 +0200)]
add inline macros for zero? and 1-

* module/system/il/inline.scm (zero?, 1-): New inlines. Neat :) The loop
  benchmark speedup is now up to 5x.

16 years agoSpeed up the self-tail-recursive case (1x->2x)
Andy Wingo [Sun, 25 May 2008 11:34:50 +0000 (13:34 +0200)]
Speed up the self-tail-recursive case (1x->2x)

* benchmark/lib.scm: Add a comment, update the loop disassembly. Loop is
  now faster in the VM, thankfully.

* src/vm_engine.h (CACHE_PROGRAM): Only release and regrab the object
  array handle if the program changed. That is to say, optimize the
  self-tail-recursive case. But perhaps the thing to optimize here are
  the procedure calls themselves. Worth looking at in the future.

16 years agoenable inlining; speed!
Andy Wingo [Sun, 25 May 2008 11:13:15 +0000 (13:13 +0200)]
enable inlining; speed!

* module/system/il/inline.scm: New module, implements generic inlining of
  scheme functions. It even does the right thing regarding (define
  arity:nopt caddr) and such. So now there are many more inlines: the
  arithmetics, `apply', the caddr family, etc. This makes the benchmarks
  *much* faster.

* module/language/scheme/translate.scm (trans): Remove the
  %scheme-primitives code in favor of the generic (scheme il inline)
  code. Adds inlining for +, -, =, etc.

* src/vm.c (vm_puts): Fix to work.

* module/system/base/compile.scm (system): Export load/compile also.

* module/system/il/compile.scm (optimize): Further debitrotting, but I
  haven't tried this function yet. It seems that <ghil-inst> was what
  <ghil-inline> is.

* module/system/il/ghil.scm (*core-primitives*, *macro-module*)
  (ghil-primitive-macro?, ghil-macro-expander, ghil-primitive?): Remove
  these unused things.

* module/system/il/macros.scm: Removed, replaced with inline.scm.

* module/system/vm/assemble.scm (stack->bytes): Before, the final
  serialization code did an (apply u8vector (apply append (map
  u8vector->list ...))). Aside from the misspelling of append-map, this
  ends up pushing all elements of the u8vector on the stack -- assuredly
  not what you want. But besides even that, I think that pushing more
  than 32k arguments on the stack brings out some other bug that I think
  was hidden before, because now we actually use the `apply' VM
  instruction. Further testing is needed here, I think. Fixed the code to
  be more efficient, which fixes the manifestation of this particular
  bug: a failure to self-compile after inlining was enabled.

* module/system/vm/bootstrap.scm: New module, serves to bootstrap
  boot-9's `load-compiled'. That way when we load (system vm core), we're
  loading compiled code already.

* module/system/vm/core.scm: Use (system vm bootstrap).

* src/guilec.in: Use the bootstrap code, so that we really are compiling
  with an entirely compiled compiler.

* module/system/repl/repl.scm (default-catch-handler): An attempt at
  making the repl print a backtrace; more work needed here.

* module/system/vm/frame.scm (make-frame-chain): Fix some misspellings --
  I think, anyway.

16 years agoScheme SRFI-18 implementation and tests file
Julian Graham [Thu, 15 May 2008 04:50:50 +0000 (00:50 -0400)]
Scheme SRFI-18 implementation and tests file

16 years agoupdate news
Andy Wingo [Tue, 20 May 2008 11:30:21 +0000 (13:30 +0200)]
update news

* NEWS: Update news for 0.7 release

16 years agodistcheck works now
Andy Wingo [Tue, 20 May 2008 10:54:14 +0000 (12:54 +0200)]
distcheck works now

* guilec.mk: New file, to be included when building .go files.

* module/language/scheme/Makefile.am:
* module/system/base/Makefile.am:
* module/system/il/Makefile.am:
* module/system/repl/Makefile.am:
* module/system/vm/Makefile.am: Use guilec.mk.

* module/system/base/compile.scm (compiled-file-name): Work on the
  basename of a file, so that we always create files in the directory
  where we run. Perhaps should add a -o option to guilec in the future.

* Makefile.am: Actually recurse into module/ in a normal build.

16 years agoinclude local copy of guile.m4
Andy Wingo [Tue, 20 May 2008 10:21:40 +0000 (12:21 +0200)]
include local copy of guile.m4

* acinclude.m4: Add guile.m4 to this, because I really can't be arsed
  with aclocal.

* autogen.sh: More better vanilla.

16 years agoautotooling, version bump to 0.7
Andy Wingo [Tue, 20 May 2008 10:10:18 +0000 (12:10 +0200)]
autotooling, version bump to 0.7

* acconfig.h: Removed.

* acinclude.m4: Use the extended AC_DEFINE for HAVE_LABELS_AS_VALUES, so
  as to remove the need for acconfig.h.

* autogen.sh: Use autoreconf.

* configure.in: Update info, don't warn about non-gnu make, bump version
  to 0.7.

* doc/texinfo.tex: Automagically updated. (Should this be in VCS?)

16 years agofix distcheck
Andy Wingo [Tue, 20 May 2008 09:54:05 +0000 (11:54 +0200)]
fix distcheck

* src/Makefile.am (AM_CFLAGS, libguile_vm_la_LDFLAGS): Don't build with
  -pg. (There are better profilers out there.)
  (CLEANFILES): Add guilev and guile-disasm.

* testsuite/Makefile.am (GUILE_VM): s/srcdir/builddir/.

16 years agoproperly include config.h in source files, not headers
Andy Wingo [Tue, 20 May 2008 09:46:52 +0000 (11:46 +0200)]
properly include config.h in source files, not headers

* src/Makefile.am: Add $(DEFAULT_INCLUDES) to a couple of our custom
  rules so we pick up the -I for config.h.

* src/*.[ch]: Include the config.h in the C files, not in the headers.

16 years agoguile-vm is completely self-compiling now!
Andy Wingo [Tue, 20 May 2008 09:33:28 +0000 (11:33 +0200)]
guile-vm is completely self-compiling now!

* module/language/scheme/translate.scm (*the-compile-toplevel-symbol*):
  Reset to compile-toplevel, which requires a patch to guile.

* module/system/base/compile.scm (compile-file): Some foo so that we load
  up the scheme language before call-with-output-file. Fixes compilation
  of (language scheme) modules.

* module/system/base/language.scm (define-language): Don't unquote in
  make-language; refer to it by name instead, and export it.

* module/system/repl/Makefile.am (vm_DATA): Don't compile describe.scm,
  because we really can't deal with goops yet.

* module/system/repl/repl.scm (compile-toplevel): If we're compiling, put
  in a stub definition of start-stack, which is closely tied to the
  interpreter.

* src/vm_loader.c (load-program): Fix a very tricky corruption bug!

16 years agofix syntax error in describe.scm
Andy Wingo [Mon, 19 May 2008 19:38:09 +0000 (21:38 +0200)]
fix syntax error in describe.scm

* module/system/repl/describe.scm (format-documentation): Remove bad
  string syntax. This file doesn't compile though, due to define-macro
  being a procedure->syntax macro.

16 years agofix immediate linkage, some other fixes to allow vm/ to compile
Andy Wingo [Mon, 19 May 2008 19:29:18 +0000 (21:29 +0200)]
fix immediate linkage, some other fixes to allow vm/ to compile

* module/language/scheme/translate.scm (lookup-transformer): Allow for
  undefined variables when doing the transformation -- it's possible that
  they come from a module definition's forward declaration.

* module/system/repl/command.scm (import): Make into legal Scheme, caught
  by the compiler :-)

* module/system/vm/assemble.scm (<vlink-now>): Remove the module field.
  Immediate bindings will now always be relative to the current module.
  Fixes some mess about process-define-module not being defined when
  loading modules, probably because we destructively modified the
  ghil-env.
  (codegen, dump-object!): Don't dump a module name.

* src/vm_loader.c (link-now): Just use scm_lookup.

16 years agobind all module-level variables lazily
Andy Wingo [Mon, 19 May 2008 17:37:39 +0000 (19:37 +0200)]
bind all module-level variables lazily

comments in ghil-lookup are pertinent.

* module/system/il/compile.scm (make-glil-var): Require that ghil vars
  have environments. Remove the 'unresolved case -- we'll treat all
  module-level variables as late bound.

* module/system/il/ghil.scm (ghil-lookup): Treat all module level vars as
  late bound.

* module/system/vm/assemble.scm: Instead of vlink and vlate-bound, have
  vlink-now and vlink-later.
  (codegen): Add a bunch of crap to get the various cases right.
  (object-assoc, dump-object!): Handle the new cases, remove the old
  cases.

* src/vm_loader.c (link-now, link-later): Change from link and lazy-bind.
  Include the module in which the link is to be done, so that callers
  from other modules get the right behavior.

* src/vm_system.c (late-variable-ref, late-variable-set): Instead of a
  sym, the unbound representation is a module name / symbol pair.

* testsuite/run-vm-tests.scm (run-vm-tests): Remove some debugging.

16 years agoAdd instructions for doing very late binding
Andy Wingo [Mon, 19 May 2008 15:46:05 +0000 (17:46 +0200)]
Add instructions for doing very late binding

Fixes the mutually-recursive toplevel definitions case. This could be
fixed by rewriting bodies as letrecs, as r6 does, but that's not really
repl-compatible.

* module/system/il/ghil.scm (ghil-lookup): Ok, if we can't locate a
  variable, mark it as unresolved.

* module/system/il/compile.scm (make-glil-var): Compile unresolved
  variables as <glil-late-bound> objects.

* module/system/il/glil.scm: Add <glil-late-bound> definition.

* module/system/vm/assemble.scm (codegen): And, finally, when we see a
  <vlate-bound> object, allocate a slot for it in the object vector,
  setting it to a symbol. Add a new pair of instructions to resolve that
  symbol to a variable at the last minute.

* src/vm_loader.c (load-number): Bugfix: the radix argument should be
  SCM_UNDEFINED in order to default to 10.
  (late-bind): Add an unresolved symbol to the object vector. Could be
  replaced with load-symbol I guess.

* src/vm_system.c (late-variable-ref, late-variable-set): New
  instructions to do late symbol binding.

* testsuite/Makefile.am (vm_test_files):
* testsuite/t-mutual-toplevel-defines.scm: New test, failing for some
  reason involving the core even? and odd? definitions.

16 years agocompile all of base/; some arbitrary changes; more "fixes" to `link'
Andy Wingo [Mon, 19 May 2008 10:57:48 +0000 (12:57 +0200)]
compile all of base/; some arbitrary changes; more "fixes" to `link'

* module/language/scheme/translate.scm (lookup-transformer): When
  expanding syncase macros, use the eval closure from the ghil-env.
  Probably doesn't make any difference whatsoever.

* module/system/base/Makefile.am (SOURCES): Compile pmatch.scm, now that
  it works :-))

* module/system/base/compile.scm (compile-in): Compile inside a
  save-module-excursion, so that side effects of evaluation don't leak
  out.

* module/system/base/pmatch.scm: Change from :use-syntax/:export-syntax
  to simply :use-modules/:export. Also probably has no effect.

* module/system/il/ghil.scm (fix-ghil-mod!): Suppress warnings resulting
  from compilation of define-module.

* src/vm_loader.c (link): So, referencing variables defined but not
  exported from the current module didn't work. Fixed that, but it's
  hacky. There are still some uncaught cases.

16 years agosyncase macros compiling!
Andy Wingo [Mon, 19 May 2008 08:38:18 +0000 (10:38 +0200)]
syncase macros compiling!

* module/system/base/compile.scm: Also import load-objcode from (system
  vm core).

* module/language/scheme/translate.scm (lookup-transformer): Use
  sc-expand3 in compilation mode when compiling macros. Yay, syncase
  macros compile!

16 years agorudimentary syncase support; some dash symbol syncase removal
Andy Wingo [Thu, 15 May 2008 21:38:52 +0000 (23:38 +0200)]
rudimentary syncase support; some dash symbol syncase removal

* module/system/vm/assemble.scm (dump-object!):
* src/vm_loader.c (VM_DEFINE_LOADER): Use scm_from_locale_keywordn, not
  the krazy dash symbol stuff.

* module/language/scheme/translate.scm (lookup-transformer): Add a
  special case for syncase macros.

16 years agoavoid zealous unquotation
Andy Wingo [Thu, 15 May 2008 16:57:33 +0000 (18:57 +0200)]
avoid zealous unquotation

* module/system/base/syntax.scm (define-record): Again, don't unquote in
  actual objects, because this is uncompilable. Ah well. At least now all
  of base/ is compiling.

* module/system/vm/assemble.scm (dump-object!): More debug info.

16 years agofix else in cond, letrec env corruption, syntax.scm compile, define-module side effects
Andy Wingo [Thu, 15 May 2008 16:48:22 +0000 (18:48 +0200)]
fix else in cond, letrec env corruption, syntax.scm compile, define-module side effects

* module/language/scheme/translate.scm (primitive-syntax-table):
  Translate the `else' clause of a cond as (begin ...). We used to use
  trans-body, which processes internal defines, which are not legal
  syntax here.

* module/system/base/syntax.scm (define-record): Unfortunately, we can't
  unquote in the actual procedure for `%compute-initargs', because that
  doesn't work with compilation. So reference %compute-initargs by name,
  and export it.

* module/system/il/ghil.scm (apopq!): Gaaaaar. The order of the arguments
  to assq-remove! was reversed, which was the badness, causing corruption
  to the env after calling call-with-ghil-bindings. Grrrrrr.

  (fix-ghil-mod!, ghil-lookup, ghil-define): As amply commented in the
  code, deal with compile-time side effects to the current module by
  lazily noticing and patching up the compile-time environment. A hacky
  solution until such a time as we special-case something for
  `define-module'.

16 years ago`link' instruction links to symbols by module
Andy Wingo [Thu, 15 May 2008 11:55:33 +0000 (13:55 +0200)]
`link' instruction links to symbols by module

* module/system/il/compile.scm (make-glil-var): Only dump the module if
  we actually have one.

* module/system/il/ghil.scm (ghil-define): Make sure that ghil-var-env is
  a ghil-env.

* src/vm_loader.c (link):
* module/system/vm/assemble.scm (dump-object!): Rewrite `link' to take
  two Scheme arguments on the stack: the symbol, as before, and the
  module in which the symbol was found at compile time. This introduces
  some undesireable early binding, but it does let the vm load up
  modules, and (potentially) have multiple modules in one .go file. On a
  practical level, I can now compile modules and have their .go files
  load up the modules' dependencies as necessary.

16 years agoremove some debugging info
Andy Wingo [Thu, 15 May 2008 11:03:47 +0000 (13:03 +0200)]
remove some debugging info

* module/system/vm/assemble.scm: remove a pk

16 years agopush the module resolution info for variables down into glil
Andy Wingo [Thu, 15 May 2008 11:03:10 +0000 (13:03 +0200)]
push the module resolution info for variables down into glil

* module/system/il/compile.scm (make-glil-var): Make the :mod of the
  glil-var actually a guile module, not a ghil-env.

* module/system/il/ghil.scm (module-lookup, ghil-lookup): For module
  variables, encode the location where we found the variable in the
  ghil-var.

16 years agofix dumping of #:keywords
Andy Wingo [Thu, 15 May 2008 10:20:18 +0000 (12:20 +0200)]
fix dumping of #:keywords

* module/language/scheme/translate.scm (trans):
* module/system/il/compile.scm (codegen): When making records where a
  value can be a keyword, make sure to use the keyword initialization
  form, so that the record initializer doesn't interpret the keyword as a
  slot name.

* module/system/base/Makefile.am (vm_DATA): For now, don't compile
  pmatch.

16 years agoallow interpretation of load-toplevel as compile-toplevel
Andy Wingo [Thu, 15 May 2008 09:17:00 +0000 (11:17 +0200)]
allow interpretation of load-toplevel as compile-toplevel

* module/language/scheme/translate.scm (*the-compile-toplevel-symbol*)
  (primitive-syntax-table): Existing eval-case invocations in boot-9.scm
  only have `load-toplevel', not `load-toplevel' and `compile-toplevel'
  as they should. Allow for interpreting `load-toplevel' as
  `compile-toplevel'.

16 years agoDelete trailing whitespace.
Neil Jerram [Wed, 14 May 2008 23:00:57 +0000 (00:00 +0100)]
Delete trailing whitespace.

16 years agoChangeLog updates for latest set of SRFI-18 changes
Julian Graham [Mon, 14 Apr 2008 00:31:18 +0000 (20:31 -0400)]
ChangeLog updates for latest set of SRFI-18 changes

16 years agoDelete trailing whitespace.
Neil Jerram [Wed, 14 May 2008 22:52:49 +0000 (23:52 +0100)]
Delete trailing whitespace.

16 years agorework eval-case handling to be like cl's eval-when
Andy Wingo [Wed, 14 May 2008 22:38:31 +0000 (00:38 +0200)]
rework eval-case handling to be like cl's eval-when

* module/language/scheme/translate.scm (trans): Remove the hacky case for
  the unspecified value, not needed any more.
  (primitive-syntax-table): Rework eval-case to understand
  compile-toplevel and evaluate contexts, as in common lisp's eval-when:
  http://www.lisp.org/HyperSpec/Body/speope_eval-when.html
  This is the Right Thing.

16 years agolatest set of SRFI-18 support changes to core threads
Julian Graham [Sun, 13 Apr 2008 23:51:23 +0000 (19:51 -0400)]
latest set of SRFI-18 support changes to core threads

16 years agofix use-syntax / use-modules confusion -- fixes testsuites
Andy Wingo [Wed, 14 May 2008 12:54:52 +0000 (14:54 +0200)]
fix use-syntax / use-modules confusion -- fixes testsuites

* testsuite/t-match.scm:
* testsuite/t-records.scm: While the attempt to redefine use-syntax as
  being "use during compilation" was cute, it does not reflect the
  historical usage of use-syntax, nor does it correspond to existing code
  that includes other modules and uses them during compilation.

  So use-syntax has been replaced with use-modules. The test suites now
  pass. In the future, compilation phases should be done on whole
  modules, I think; r5rs-style computation does not have phases.

16 years agofix macro compilation via hooking into eval-case
Andy Wingo [Wed, 14 May 2008 12:47:29 +0000 (14:47 +0200)]
fix macro compilation via hooking into eval-case

* module/language/scheme/translate.scm (eval-at-compile-time)
  (&compile-time-module, expand-macro): Remove this attempt at dealing
  with macros. Instead, we're going to rely on macros being first-class,
  and just catch eval-case at the bottom.
  (lookup-transformer): Lookup all syntax transformers in the module's
  eval closure. We catch the primitive-macros, compiling them to ghil,
  and expand the rest.
  (lookup-transformer): Fold in trans-pair here. Add a hacky case for the
  unspecified value; the problem shows up when compiling e.g.
  (define-macro (plus! x) `(set! ,x (1+ x))), as a fallout from
  eval-case.
  (make-pmatch-transformers, primitive-syntax-table): Define the
  primitive syntax transformers as a data-driven table instead of a
  function. There's a bit of syntax, too. Eval-case was rewritten to use
  pmatch.

* module/system/base/compile.scm (scheme): Define as a thunk instead
  of a value, so as to allow (language scheme translate) to be imported
  in the repl. Still, a hack.

16 years ago(void) -> (begin)
Andy Wingo [Wed, 14 May 2008 09:19:06 +0000 (11:19 +0200)]
(void) -> (begin)

* module/language/scheme/translate.scm (expand-macro, trans-pair): Remove
  support for the scheme form, '(void). Replace it by (begin). What was
  Keisuke thinking? :)

16 years agoremove x.foo.bar -> (slot x 'foo 'bar) compile-time translation
Andy Wingo [Wed, 14 May 2008 09:13:00 +0000 (11:13 +0200)]
remove x.foo.bar -> (slot x 'foo 'bar) compile-time translation

* module/language/scheme/translate.scm (trans): Remove compile-time dot
  expansion.

16 years agoExpand DEFFROM and DEFTO macros in discouraged.c
Neil Jerram [Mon, 12 May 2008 23:00:34 +0000 (00:00 +0100)]
Expand DEFFROM and DEFTO macros in discouraged.c

* discouraged.c: Expand DEFFROM and DEFTO macros, to avoid
compiler warnings about excess semicolons.  (Reported by Didier
Godefroy.)

16 years agoFix continuation problems on IA64.
Neil Jerram [Wed, 7 May 2008 23:29:53 +0000 (00:29 +0100)]
Fix continuation problems on IA64.

* Specific problems in IA64 make check

** test-unwind

Representation of the relevant dynamic context:

                  non-rewindable
           catch      frame       make cont.
  o----o-----a----------b-------------c
        \
         \             call cont.
          o-----o-----------d

A continuation is captured at (c), with a non-rewindable frame in the
dynamic context at (b).  If a rewind through that frame was attempted,
Guile would throw to the catch at (a).  Then the context unwinds back
past (a), then winds forwards again, and the captured continuation is
called at (d).

We should end up at the catch at (a).  On ia64, we get an "illegal
instruction".

The problem is that Guile does not restore the ia64 register backing
store (RBS) stack (which is saved off when the continuation is
captured) until all the unwinding and rewinding is done.  Therefore,
when the rewind code (scm_i_dowinds) hits the non-rewindable frame at
(b), the RBS stack hasn't yet been restored.  The throw finds the
jmp_buf (for the catch at (a)) correctly from the dynamic context, and
jumps back to (a), but the RBS stack is invalid, hence the illegal
instruction.

This could be fixed by restoring the RBS stack earlier, at the same
point (copy_stack) where the normal stack is restored.  But that
causes a problem in the next test...

** continuations.test

The dynamic context diagram for this case is similar:

                   non-rewindable
  catch                 frame       make cont.
    a----x-----o----------b-------------c
          \
           \    call cont.
            o-------d

The only significant difference is that the catch point (a) is
upstream of where the dynamic context forks.  This means that the RBS
stack at (d) already contains the correct RBS contents for throwing
back to (a), so it doesn't matter whether the RBS stack that was saved
off with the continuation gets restored.

This test passes with the Guile 1.8.4 code, but fails (with an
"illegal instruction") when the code is changed to restore the RBS
stack earlier as described above.

The problem now is that the RBS stack is being restored _too_ early;
specifically when there is still stuff to do that relies on the old
RBS contents.  When a continuation is called, the sequence of relevant
events is:

  (1) Grow the (normal) stack until it is bigger than the (normal)
      stack saved off in the continuation.  (scm_dynthrow, grow_stack)

  (2) scm_i_dowinds calls itself recursively, such that

      (2.1) for each rewind (from (x) to (c)) that will be needed,
            another frame is added to the stack (both normal and RBS),
            with local variables specifying the required rewind; the
            rewinds don't actually happen yet, they will happen when
            the stack unwinds again through these frames

      (2.2) required unwinds - back from where the continuation was
            called (d) to the fork point (x) - are done immediately.

  (3) The normal (i.e. non-RBS) stack that was stored in the
      continuation is restored (i.e. copied on top of the actual
      stack).

      Note that this doesn't overwrite the frames that were added in
      (2.1), because the growth in (1) ensures that the added frames
      are beyond the end of the restored stack.

  (4) ? Restore the RBS stack here too ?

  (5) Return (from copy_stack) through the (2.1) frames, which means
      that the rewinds now happen.

  (6) setcontext (or longjmp) to the context (c) where the
      continuation was captured.

The trouble is that step (1) does not create space in the RBS stack in
the same kind of way that it does for the normal stack.  Therefore, if
the saved (in the continuation) RBS stack is big enough, it can
overwrite the RBS of the (2.1) frames that still need to complete.
This causes an illegal instruction when we return through those frames
and try to perform the rewinds.

* Fix

The key to the fix is that the saved RBS stack only needs to be
restored at some point before the next setcontext call, and that doing
it as close to the setcontext call as possible will avoid bad
interactions with the pre-setcontext stack.  Therefore we do the
restoration at the last possible point, immediately before the next
setcontext call.

The situation is complicated by there being two ways that the next
setcontext call can happen.

  - If the unwinding and rewinding is all successful, the next
    setcontext will be the one from step (6) above.  This is the
    "normal" continuation invocation case.

  - If one of the rewinds throws an error, the next setcontext will
    come from the throw implementation code.  (And the one in step (6)
    will never happen.)  This is the rewind error case.

In the rewind error case, the code calling setcontext knows nothing
about the continuation.  So to cover both cases, we:

  - copy (in step (4) above) the address and length of the
    continuation's saved RBS stack to the current thread state
    (SCM_I_CURRENT_THREAD)

  - modify all setcontext callers so that they check the current
    thread state for a saved RBS stack, and restore it if so before
    calling setcontext.

* Notes

** I think rewinders cannot rely on using any stack data

Unless it can be guaranteed that the data won't go into a register.
I'm not 100% sure about this, but I think it follows from the fact
that the RBS stack is not restored until after the rewinds have
happened.

Note that this isn't a regression caused by the current fix.  In Guile
1.8.4, the RBS stack was restored _after_ the rewinds, and this is
still the case now.

** Most setcontext calls for `throw' don't need to change the RBS stack

In the absence of continuation invocation, the setcontext call in the
throw implementation code always sets context to a place higher up the
same stack (both normal and RBS), hence no stack restoration is
needed.

* Other changes

** Using setcontext for all non-local jumps (for __ia64__)

Along the way, I read a claim somewhere that setcontext was more
reliable than longjmp, in cases where the stack has been manipulated.

I don't now have any reason to believe this, but it seems reasonable
anyway to leave the __ia64__ code using getcontext/setcontext, instead
of setjmp/longjmp.

(I think the only possible argument against this would be performance -
if getcontext was significantly slower than setjmp.  It that proves to
be the case, we should revisit this.)

** Capping RBS base for non-main threads

Somewhere else along the way, I hit a problem in GC, involving the RBS
stack of a non-main thread.  The problem was, in
SCM_MARK_BACKING_STORE, that scm_ia64_register_backing_store_base was
returning a value that was massively greater than the value of
scm_ia64_ar_bsp, leading to a seg fault.  This is because the
implementation of scm_ia64_register_backing_store_base is only valid
for the main thread.  I couldn't find a neat way of getting the true
RBS base of a non-main thread, but one idea is simply to call
scm_ia64_ar_bsp when guilifying a thread, and use the value returned
as an upper bound for that thread's RBS base.  (Note that the RBS
stack grows upwards.)

(Were it not for scm_init_guile, we could be much more definitive
about this.  We could take the value of scm_ia64_ar_bsp as a
definitive base address for the part of the RBS stack that Guile cares
about.  We could also then discard
scm_ia64_register_backing_store_base.)

16 years agofix env script
Andy Wingo [Mon, 12 May 2008 22:13:56 +0000 (00:13 +0200)]
fix env script

* env: Fix env script to find $top_srcdir correctly

16 years agoUpdate Makefile.am's; remove slib import
Andy Wingo [Mon, 12 May 2008 22:07:40 +0000 (00:07 +0200)]
Update Makefile.am's; remove slib import

* Makefile.am:
* module/Makefile.am:
* module/language/scheme/Makefile.am:
* module/system/Makefile.am:
* module/system/base/Makefile.am:
* module/system/il/Makefile.am:
* module/system/repl/Makefile.am:
* module/system/vm/Makefile.am: Cleaned up to be more complete, if not
  completely working.

* module/guile/slib.scm:
* module/slib/: Removed the slib import; it's a bit out of place here,
  and bitrotten at that.

16 years agoadd env script
Andy Wingo [Mon, 12 May 2008 21:39:25 +0000 (23:39 +0200)]
add env script

* env: New file, run as ./env guile

16 years agocatch errors in the repl, with poor backtraces
Andy Wingo [Mon, 12 May 2008 21:27:14 +0000 (23:27 +0200)]
catch errors in the repl, with poor backtraces

* module/system/repl/repl.scm (default-pre-unwind-handler)
  (default-catch-handler): New procedures, to do some error handling in
  the repl.
  (start-repl): Catch errors in the repl loop.

16 years agoreplace cenv with things in <repl> and fluids; remove the `use' meta-command
Andy Wingo [Mon, 12 May 2008 20:26:31 +0000 (22:26 +0200)]
replace cenv with things in <repl> and fluids; remove the `use' meta-command

* module/system/base/compile.scm (<cenv>): No more cenv, it was a useless
  data structure.

* module/system/repl/command.scm (*command-table*): Remove `use', it's
  the same as `import'. Otherwise in this file, adapt to the repl having
  direct pointers to the vm and the language, and to the module being in
  the current-module fluid.

* module/system/repl/repl.scm (prompting-meta-read):
* module/system/repl/common.scm (<repl>): The repl now has a direct
  pointer to the vm and language. Adapt accordingly.

16 years agofixes so that typing asdfadfasff in the repl doesn't error
Andy Wingo [Sun, 11 May 2008 22:22:36 +0000 (00:22 +0200)]
fixes so that typing asdfadfasff in the repl doesn't error

Before:

> ,c (set! x 3)
   0    (make-int8 3)                   ;; 3
   2    (link "x")
   5    (variable-set)

> ,c (define x 3)
   0    (make-int8 3)                   ;; 3
   2    (link "x")
   5    (variable-set)

After:
> ,c (define x 3)
   0    (make-int8 3)                   ;; 3
   2    (define "x")
   5    (variable-set)

* src/vm_loader.c (link): `link' now errors if the variable is undefined.
  This corresponds with desired behavior, for both `ref' and `set'
  operations, for scheme. It's not what elisp wants, though. Perhaps
  elisp linking needs another instruction.
  (define): New instruction, the same as calling scm_define(), basically.

* module/language/scheme/translate.scm (trans-pair): Don't try to look up
  an existing variable definition when translating `define'; instead use
  the special-purpose lookup from ghil.scm's `ghil-define'.

* module/system/il/compile.scm (codegen): Compile to a different kind of
  variable access from `set!', specifically via passing 'define as the op
  to `make-glil-var'.

* module/system/il/ghil.scm (ghil-lookup): Don't add to the module table
  when compiling variable sets via `set!'.
  (ghil-define): New procedure, for looking up variables for `define'.

* module/system/vm/assemble.scm (<vdefine>): New record: a new
  instruction type.
  (codegen): Compile `define' module vars into <vdefine>.
  (dump-object!): <vdefine> == `define'.

16 years agoonly allow `define' at toplevel
Andy Wingo [Sun, 11 May 2008 20:37:35 +0000 (22:37 +0200)]
only allow `define' at toplevel

* module/language/scheme/translate.scm (trans-pair): Add a guard to only
  allow `define' at the top level; other defines are already filtered out
  via trans-body.

* module/system/il/ghil.scm (ghil-env-toplevel?): Export, and fix.

16 years agoremove define-private
Andy Wingo [Sun, 11 May 2008 20:03:50 +0000 (22:03 +0200)]
remove define-private

* module/language/scheme/translate.scm: Remove define-private.

16 years agoexplicitly list exports instead of using define-public
Andy Wingo [Sun, 11 May 2008 20:00:34 +0000 (22:00 +0200)]
explicitly list exports instead of using define-public

* module/system/base/compile.scm:
* module/system/il/ghil.scm:
* module/system/repl/describe.scm:
* module/system/vm/core.scm:
* module/system/vm/frame.scm:
* module/system/vm/trace.scm: Explicitly list exports in the module
  declaration instead of using define-public.

16 years ago<foo>? -> foo?; some exports cleanups
Andy Wingo [Sun, 11 May 2008 19:48:10 +0000 (21:48 +0200)]
<foo>? -> foo?; some exports cleanups

* module/system/base/compile.scm: Export cenv? also.

* module/system/base/syntax.scm: Clean up vestiges of the old structure
  code. Make accessors defined as foo? instead of <foo>?.

* module/system/il/glil.scm:
* module/system/il/ghil.scm: Remove <foo>-1 accessors, since we have
  named accessors.