Andy Wingo [Fri, 26 Dec 2008 16:59:46 +0000 (17:59 +0100)]
remove heap links in VM frames, incorporate vm frames into normal backtraces
* doc/ref/vm.texi (Stack Layout): Update to remove references to the
"heap link".
* gdbinit: Update for "heap link" removal.
* libguile/frames.c:
* libguile/frames.h: Update macros and diagram for removal of "heap
link". As part of this, we also remove "heap frames", replacing them
with "vm frames", which are much like the interpreter's debug objects,
but for VM stacks. That is to say, they don't actually hold the stack
themselves, just the pointers into stack that's held by a continuation
(either captured or current).
* libguile/stacks.c (stack_depth, read_frames): Since a "stack" object is
really a copy of information that comes from somewhere else, it makes
sense to copy over info from the VM, just as `make-stack' does from the
evaluator. The tricky bit is to figure out how to interleave VM and
interpreter frames. We do that by starting in the interpreter, and
whenever the current frame's procedure is actually a program, we switch
to the VM stack, switching back when we reach a "bootstrap frame". The
last bit is hacky, but it does work...
(is_vm_bootstrap_frame): Hacky predicate to see if a VM frame is a
bootstrap frame.
(scm_make_stack): Accept a VM frame in addition to debug frames.
Probably has some bugs in this case. But in the case that the arg is
#t (a common case), do the right thing, capturing the top VM frame as
well, and interleaving those frames appropriately on the stack.
As an accident, we lost the ability to limit the number of frames in
the backtrace. We could add that back, but personally I always want
*all* frames in the trace... Narrowing still works fine, though there
are some hiccups sometimes -- e.g. an outer cut to a procedure that
does a tail-call in VM code will never find the cut, as it no longer
exists in the continuation.
* libguile/vm.h (struct scm_vm): So! Now that we have switched to save
stacks in the normal make-stack, there's no more need for `this_frame'
or `last_frame'. On the other hand, we can take this opportunity to fix
tracing: when we're in a trace hook, we set `trace_frame' on the VM,
so we know not to fire hooks when we're already in a hook.
(struct scm_vm_cont): Expose this, as make-stack needs it to make VM
frames from VM continuations.
* libguile/vm.c (scm_vm_trace_frame): New function, gets the current
trace frame.
(vm_mark, make_vm): Hook up the trace frame.
(vm_dispatch_hook): New hook dispatcher, with a dynwind so it does the
right thing if the hook exits nonlocally.
* libguile/vm-engine.c (vm_run): No more this_frame in the wind data.
* libguile/vm-engine.h (RUN_HOOK): Run hooks through the dispatcher.
(ALIGN_AS_NON_IMMEDIATE, POP_LIST_ON_STACK): Remove unused code.
(NEW_FRAME): Adapt for no HL in the frame.
* libguile/vm-i-system.c (goto/args, mv-call, return, return/values):
Adapt for no HL in the frame.
* module/system/vm/frame.scm:
* module/system/vm/vm.scm: Beginnings of some reworkings, needs more
thought.
Andy Wingo [Fri, 26 Dec 2008 15:44:02 +0000 (16:44 +0100)]
repl.scm relies on `display-backtrace' to do everything, some naming tweaks
* module/ice-9/boot-9.scm (default-pre-unwind-handler): Rename from
default-lazy-handler.
(pre-unwind-handler-dispatch): Rename from lazy-hadler-dispatch.
(error-catching-loop): Adjust caller.
* module/system/repl/repl.scm (default-pre-unwind-handler): Remove this
definition, in favor of the default one in boot-9.
(default-catch-handler): Don't do a vm-backtrace, as we will soon be
relying on core machinery to do that for us.
(call-with-backtrace): Start a new stack for the thunk.
(with-backtrace): Macro version of call-with-backtrace.
(start-repl): Use with-backtrace for brevity. Start a stack with #t as
the tag instead of repl-eval, because all traces of repl-eval are gone
after it does a tail-call.
* module/ice-9/debugger.scm:
* module/ice-9/debugging/traps.scm:
* module/ice-9/stack-catch.scm: Adapt to s/lazy/pre-unwind/ in
boot-9.scm.
Andy Wingo [Fri, 26 Dec 2008 15:36:53 +0000 (16:36 +0100)]
add scm_c_program_source
* libguile/programs.h:
* libguile/programs.c (scm_c_program_source): New helper for getting
source information from C.
Andy Wingo [Fri, 26 Dec 2008 15:35:43 +0000 (16:35 +0100)]
backtrace.c: allow vectors for SCM_FRAME_SOURCE (frame)
* libguile/backtrace.c (display_backtrace_get_file_line): If the source
is a vector, treat it as a #(line column file) vector, as emitted by
the VM. Needs subsequent patches to make sense.
Andy Wingo [Fri, 26 Dec 2008 15:33:33 +0000 (16:33 +0100)]
fix doc typo
* doc/ref/data-rep.texi (Non-immediate objects): Fix a typo, thanks to
Dale Smith.
Andy Wingo [Fri, 19 Dec 2008 10:50:43 +0000 (11:50 +0100)]
remove the `late-bind' instruction
* doc/ref/vm.texi: Minor fixes.
* libguile/vm-i-loader.c: Remove the unused `late-bind' instruction.
Andy Wingo [Fri, 19 Dec 2008 10:24:44 +0000 (11:24 +0100)]
write history.texi
* doc/ref/vm.texi: Flesh out the VM documentation, adding a rationale.
* doc/ref/history.texi: Write the Guile history.
* doc/ref/guile.texi (Top): Some tweaks.
Andy Wingo [Thu, 20 Nov 2008 12:45:27 +0000 (13:45 +0100)]
late-variable-{ref,set} -> toplevel-{ref,set}
* benchmark/lib.scm:
* libguile/vm-i-system.c (toplevel-ref, toplevel-set):
* module/system/vm/assemble.scm (codegen):
* module/system/vm/disasm.scm (code-annotation):
s/late-variable/toplevel/. It's just a better name.
Andy Wingo [Thu, 20 Nov 2008 12:44:22 +0000 (13:44 +0100)]
merge vm docs into guile reference (as yet unfinished)
* doc/ref/compiler.texi: A new empty section on the compiler.
* doc/ref/data-rep.texi: Made to be a section of a chapter instead of an
appendix. The beginnings of some revision, but not there yet.
* doc/ref/guile.texi: Put the "Data Representation" essay into the new
"History and Implementation Details" chapter.
* doc/ref/history.texi: New empty section on Guile history.
* doc/ref/libguile-concepts.texi:
* doc/ref/libguile-smobs.texi: Fix up some xrefs.
* doc/ref/vm.texi: New section documenting the VM. Not done yet.
Andy Wingo [Fri, 14 Nov 2008 21:42:31 +0000 (22:42 +0100)]
nifty generic compiler infrastructure -- no more hardcoded passes
* module/system/base/language.scm (<language>): Rework so that instead of
hardcoding passes in the language, we define compilers that translate
from one language to another. Add `parser' to the language fields, a
bit of a hack but useful for languages with s-expression external
representations but with record internal representations.
(define-language, *compilation-cache*, invalidate-compilation-cache!)
(compute-compilation-order, lookup-compilation-order): Add an algorithm
that does a depth-first search for a translation path from a source
language to a target language, caching the result in a lookup table.
* module/language/scheme/spec.scm:
* module/language/ghil/spec.scm: Update to the new language format.
* module/language/glil/spec.scm: Add a language specification for GLIL,
with a compiler to objcode. Also there are parsers and printers, for
repl usage, but for some reason this doesn't work yet.
* module/language/objcode/spec.scm: Define a language specification for
object code. There is some sleight of hand here, in the "compiler" to
values; but there is method behind the madness, because this way we
higher levels can pass environments (a module + externals pair) to
objcode->program.
* module/language/value/spec.scm: Define a language specification for
values. There is something intellectually dishonest about this, but it
does serve its purpose as a foundation for the language hierarchy.
* configure.in:
* module/language/Makefile.am
* module/language/ghil/Makefile.am
* module/language/glil/Makefile.am
* module/language/objcode/Makefile.am
* module/language/value/Makefile.am:
Autotomfoolery for the ghil, glil, objcode, and value languages.
* module/language/scheme/translate.scm (translate): Import the bits that
understand `compile-time-environment' here, and pass on the relevant
portions of the environment to the next compiler pass.
* module/system/base/compile.scm (current-language): New procedure, refs
the current language fluid, or lazily sets it to scheme.
(call-once, call-with-output-file/atomic): Refactor these bits to use
with-throw-handler. No functional change.
(compile-file, compile-and-load, compile-passes, compile-fold)
(compile): Refactor the public interface of the compiler to be generic
and simple. Uses `lookup-compilation-order' to find a path from the
source language to the target language.
* module/system/base/syntax.scm (define-type): Adapt to changes in
define-record.
(define-record): Instead of expecting all slots in the first form,
expect them in the body, and let the first form hold the options.
* module/system/il/compile.scm (compile): Adapt to the compilation pass
API (three in and two out).
* module/system/il/ghil.scm (<ghil-var>, <ghil-env>)
(<ghil-toplevel-env>): Adapt to define-record changes.
* module/system/il/glil.scm (<glil-vars>): Adapt to define-record
changes.
(<glil>, print-glil): Add a GLIL record printer that uses unparse.
(parse-glil, unparse-glil): Update unparse (formerly known as pprint),
and write a parse function.
* module/system/repl/common.scm (<repl>): Adapt to define-record changes.
(repl-parse): New function, parses the read form using the current
language. Something of a hack.
(repl-compile): Adapt to changes in `compile'.
(repl-eval): Fix up the does-the-language-have-a-compiler check for
changes in <language>.
* module/system/repl/repl.scm (start-repl): Parse the form before eval.
* module/system/repl/command.scm (describe): Parse.
(compile): Be more generic.
(compile-file): Adapt to changes in compile-file.
(disassemble, time, profile, trace): Parse.
* module/system/vm/debug.scm:
* module/system/vm/assemble.scm: Adapt to define-record changes.
* module/language/scheme/translate.scm (receive): Fix an important bug
that gave `receive' letrec semantics instead of let semantics. Whoops!
Andy Wingo [Tue, 11 Nov 2008 23:29:45 +0000 (00:29 +0100)]
more ghil parsing fixen
* module/system/il/ghil.scm (parse-ghil): Fix a typo for values*
(unparse-ghil): Only output (quote foo) if the object is a symbol.
(unparse-ghil): Fix some missing ,@.
Andy Wingo [Tue, 11 Nov 2008 22:12:39 +0000 (23:12 +0100)]
fix unparse-ghil errors with quasiquote
* module/system/il/ghil.scm (unparse-ghil): Fix some issues with
quasiquote and unquote[-splicing]. Doh!
Andy Wingo [Tue, 11 Nov 2008 22:11:27 +0000 (23:11 +0100)]
rashly bump stack limit to 40k words
* libguile/eval.c (scm_debug_opts): Whereas, today's machines are larger
than yesterday's; GCC consumes more words per stack frame than it used
to; and you can get quite some recursion in a halfway-compiled system,
be it resolved: let's bump up the C stack limit to 40k words (160 kB /
320 kB, depending on word size).
Andy Wingo [Tue, 11 Nov 2008 21:52:24 +0000 (22:52 +0100)]
add parsers and unparser for ghil; ,language ghil works now
* module/system/repl/common.scm (repl-print): Slightly refine the meaning
of "language-printer": a language printer prints an expression of a
language, not the result of evaluation. `write' prints values.
* module/language/ghil/spec.scm (ghil): Define a language printer, and a
translator for turning s-expressions (not scheme, mind you) into GHIL.
* module/language/scheme/translate.scm (quote, quasiquote): Add some
#:keyword action, so that we can (quote #:keywords).
* module/system/base/language.scm (<language>):
* module/system/base/compile.scm (read-file-in): Don't require that a
language have a read-file; instead error when read-file is called.
(compile-passes, compile-in): Refactor to call a helper method to turn
the language + set of options into a set of compiler passes.
* module/system/base/syntax.scm (define-type): Allow the type to be a
list, with the car being the name and the cdr being keyword options.
Interpret #:printer as a printer, and pass it down to...
(define-record): Here.
* module/system/il/ghil.scm (print-ghil, <ghil>): New printer for GHIL,
yay!
(parse-ghil, unparse-ghil): New lovely functions. Will document them in
the manual.
Andy Wingo [Mon, 10 Nov 2008 11:17:18 +0000 (12:17 +0100)]
remove .cvsignore files
Andy Wingo [Sun, 2 Nov 2008 00:37:00 +0000 (01:37 +0100)]
proper printing of thunks, reduced disasm verbosity
* module/system/vm/disasm.scm (disassemble-program): Don't print the
nargs= nrest= etc line, it's redundant.
* module/system/vm/program.scm (program-bindings-as-lambda-list): If the
program bindings is null, then that's that.
Andy Wingo [Sat, 1 Nov 2008 19:31:57 +0000 (20:31 +0100)]
define macros before functions using macros; more MV fixen in srfi-69
* module/srfi/srfi-69.scm: Move the macros up before the functions that
use them, so that the compiler can do its job.
(hash-table-walk): While it is true about what I said about R5RS
before, it seems that for R6 this will have to change. Anyway. In the
meantime, since the test suite checks that hash-table-walk procedures'
return values and number of return values are ignored, call that
procedure within a call-with-values.
Andy Wingo [Sat, 1 Nov 2008 17:37:48 +0000 (18:37 +0100)]
fix for (apply values '(1))
* libguile/vm-i-system.c (return/values): In the
multiple-values-to-a-single-value-continuation (or MV but where N=1),
null out the correct number of values from the stack. Fixes aborts on
(apply values '(1)).
* testsuite/t-values.scm (call-with-values): Add a test.
Andy Wingo [Sat, 1 Nov 2008 17:19:19 +0000 (18:19 +0100)]
fix multiple values coming from interpreted or C procedures
* libguile/vm-i-system.c (call, goto/args): Handle the case in which a
non-program (i.e. interpreted program or a subr) returns multiple
values.
* testsuite/t-values.scm: Add test case that exhibited this problem.
Andy Wingo [Sat, 1 Nov 2008 16:12:23 +0000 (17:12 +0100)]
make-procedure-with-setter inherits name from getter
* libguile/procs.c (scm_make_procedure_with_setter): Patch through the
getter's procedure name to the procedure-with-setter. Fixes part of the
srfi-17 test, as the VM doesn't set procedure-name on define -- but
perhaps that is the bug that should be fixed. In any case this patching
is cheap.
* test-suite/tests/eval.test: Change so that (define name pws) is
initially passed an anonymous procedure-with-setter, as was the case
before the procs.c change.
Andy Wingo [Sat, 1 Nov 2008 13:25:53 +0000 (14:25 +0100)]
avoid delivering 0 values to 1-valued continuations in srfi-19
* module/srfi/srfi-19.scm: Some parts of this code used a strange idiom,
`(values)', to indicate that a procedure did nothing. However, quoth
R5RS:
Except for continuations created by the `call-with-values'
procedure, all continuations take exactly one value.
Indeed the VM indicated this error. I reworked the code to avoid these
cases.
Andy Wingo [Sat, 1 Nov 2008 12:49:23 +0000 (13:49 +0100)]
move scm srfi files to module/srfi, and compile them.
* .gitignore: Add gdb-pre-inst-guile.
* configure.in: Add module/srfi/Makefile.
* module/Makefile.am: Add srfi/.
* module/srfi/: SRFI scheme files moved here, and compiled.
* srfi/Makefile.am: Remove the bits about the scheme files.
Andy Wingo [Sat, 1 Nov 2008 12:05:10 +0000 (13:05 +0100)]
move guilec.mk to am/guilec
* am/Makefile.am:
* am/guilec: guilec moved here from /guilec.mk.
All includers of guilec adapted.
Andy Wingo [Sat, 1 Nov 2008 11:53:37 +0000 (12:53 +0100)]
remove stale env script, clean up gdb-pre-inst-guile
* env: Removed (a vestige of the guile-vm merge).
* gdb-pre-inst-guile.in: Make a bit more robust (using libtool
--mode=execute).
Andy Wingo [Sat, 1 Nov 2008 11:44:21 +0000 (12:44 +0100)]
move ice-9/ and oop/ under module/
Moved ice-9/ and oop/ under module/, with the idea being that we have
only scheme under module/. Adjusted configure.in and Makefile.am
appropriately. Put oop/ at the end of the compilation order.
Andy Wingo [Fri, 31 Oct 2008 17:30:27 +0000 (18:30 +0100)]
compile goops accessors. woot!
* oop/goops.scm: Define compiler hooks for dealing with @slot-ref and
@slot-set!.
(make-bound-check-get, make-get, make-set): Compile these indexed
accessors instead of having them be closures. Probably slower for the
memoizer, but faster for the vm... not sure what the perfect solution
is.
* test-suite/tests/goops.test ("defining classes"): Add a test that
defining a class with accessors works (it didn't until I figured out
that (@ (system base compile) compile) thing).
Andy Wingo [Fri, 31 Oct 2008 13:09:01 +0000 (14:09 +0100)]
new ops: slot-ref, slot-set. remove and recompile your .go files
* libguile/vm-i-scheme.c (slot-ref, slot-set): New ops.
Andy Wingo [Fri, 31 Oct 2008 13:07:11 +0000 (14:07 +0100)]
fix bug in define-scheme-translator
* module/language/scheme/translate.scm (define-scheme-translator): Fix a
bug in this macro for the syntax-error case.
Andy Wingo [Fri, 31 Oct 2008 12:28:06 +0000 (13:28 +0100)]
pass backtraces through the compiler
* module/system/base/compile.scm (call-with-nonlocal-exit-protect): New
helper, like unwind-protect but only for nonlocal exits.
(call-with-output-file/atomic): Use call-with-nonlocal-exit-protect so
that we don't mess up backtraces by catching all and then rethrowing.
Should fix this more comprehensively somewhere, though.
Andy Wingo [Fri, 31 Oct 2008 12:26:48 +0000 (13:26 +0100)]
make define-inline more usable from external modules
* module/system/il/inline.scm (define-inline): Use @ when accessing
module vars so that other modules don't need to import all of our
modules. However case-lambda is still needed.
Andy Wingo [Fri, 31 Oct 2008 12:25:11 +0000 (13:25 +0100)]
rework the scheme translator so it's extensible by external modules
* module/language/scheme/translate.scm (*translate-table*)
(define-scheme-translator): Rework the translator to have the clauses
defined separately via the define-scheme-translator macro, so that
external modules can define their own translators. Should be no
functional change in this commit, though.
Andy Wingo [Fri, 31 Oct 2008 10:35:47 +0000 (11:35 +0100)]
compile goops submodules, goops.test now passes again
* libguile/goops.c (get_slot_value, set_slot_value): While keeping the
inlined getter/setter dispatch for closures, allow the getters and
setters to be any kind of procedure.
* oop/goops.scm (compute-getters-n-setters): Relax the checks on
getter/setter procedures, so that if a getter is a procedure but not a
closure, we don't try to poke its arity.
* oop/goops/Makefile.am (SOURCES): Compile all the goops submodules!
* oop/goops/old-define-method.scm: Removed, in an act of housekeeping.
* oop/goops/compile.scm:
* oop/goops/dispatch.scm: Break a circular module dependency by making
sure that (oop goops) is loaded when we go to compile submodules.
* oop/goops/compile.scm (compile-method/memoizer)
(compile-method/memoizer+next): Allow a procedure without source
through. This can happen with getter and setter lambdas that were
compiled, and in that case there is no next-method call anyway. Ideally
we should be able to specify compile-method for accessor methods...
Andy Wingo [Fri, 31 Oct 2008 09:14:49 +0000 (10:14 +0100)]
fix chaining up from interpreted to compiled methods; allow compiled init-thunk
* libguile/goops.c (scm_sys_initialize_object): Don't assume that an init
thunk is a closure; just go through scm_call_0 instead.
* oop/goops/compile.scm (make-make-next-method/memoizer): Allow for the
case that the next method is compiled.
Andy Wingo [Thu, 30 Oct 2008 23:07:04 +0000 (00:07 +0100)]
compile goops
The pending task is to make the accessors compiled too, and also to
compile compile.scm and dispatch.scm, and to integrate dispatch into the
VM.
* oop/Makefile.am (SOURCES): VM-ify the makefile, so we compile goops.scm
by default.
* oop/goops.scm (load-toplevel): Load goops builtins when compiling too.
(method): Fix a literal #<unspecified> in the generated procedure (for
an empty body).
(internal-add-method!): Cleverness when bootstrapping add-method!.
Neat!
(initialize for <generic>): Use the `method' macro so we get
compilation support.
* oop/goops/dispatch.scm (cache-methods): Don't assume entries are pairs.
Andy Wingo [Thu, 30 Oct 2008 14:53:11 +0000 (15:53 +0100)]
compile occam-channel
* ice-9/Makefile.am (SOURCES): Compile the goops-using occam-channel.scm.
Andy Wingo [Thu, 30 Oct 2008 14:50:48 +0000 (15:50 +0100)]
fix up some assumptions that cmethods were lists
* libguile/eval.i.c (type_dispatch, apply_vm_cmethod)
(apply_memoized_cmethod): Tweak the nastiness a bit more so as to deal
with the '(no-method) empty entries. I would like to stop the search if
the cdr isn't a pair, but currently with the inlined memoized bits, the
cdr is a pair. The fix would be to make the memoizer return a procedure
and not the already-inlined bits -- slightly slower but the vm will be
faster anyway.
* libguile/objects.c (scm_mcache_lookup_cmethod): Same fixes here.
* oop/goops/dispatch.scm (cache-hashval, cache-try-hash!): Allow non-list
cmethod tails.
Andy Wingo [Thu, 30 Oct 2008 12:42:40 +0000 (13:42 +0100)]
runtime byte compilation of goops methods, whooooo
* ice-9/boot-9.scm (make-modules-in): Change to make sure that we are
making modules in modules; that is, that a global binding of `compile'
doesn't prevent a module from importing a submodule named `compile'.
(resolve-module): Clean up a bit, and serialize the logic.
* libguile/objects.c (scm_mcache_lookup_cmethod, scm_apply_generic):
* libguile/eval.i.c (CEVAL): Now that cmethod entries can have a program
as their tail instead of a memoized proc, we have to change the halting
condition on the method cache search, in both places: the one that's
inlined into eval.i.c and the one in objects.c. If the cmethod isn't a
pair, apply it.
* libguile/goops.c (make): In the `make' procedure that's used before
GOOPS is booted, bind #:formals, #:body, and #:compile-env on methods.
* oop/goops/compile.scm (compute-entry-with-cmethod): There was a
terrible trick here that involved putting a dummy pair in the cache,
then modifying it in place with the result of memoization. The note
claimed that this was to cut recursion short, or something. I can't see
how it could recurse, given that `methods' is changing each time. Also,
the pair trick doesn't work with byte-compiled methods. So, remove it.
(compile-method): Dispatch to the appropriate method compiler, based on
whether the method was defined with the interpreter or with the
compiler.
(make-next-method): New function, generically computes a `next-method'
procedure, though the caller has to supply the arguments.
(compile-method/vm): Exciting method byte compiler!
(make-make-next-method/memoizer, compile-method/memoizer): Add the
/memoizer suffix, and move all this code to the bottom of the file.
Andy Wingo [Thu, 30 Oct 2008 09:57:36 +0000 (10:57 +0100)]
recompiling with compile environments, fluid languages, cleanups
* ice-9/boot-9.scm (compile-time-environment): Remove definition from
boot-9 -- instead, autoload it and `compile' from (system base
compile).
* libguile/objcodes.h:
* libguile/objcodes.c (scm_objcode_to_program): Add an optional argument,
`external', the external list to set on the returned program.
* libguile/vm-i-system.c (externals): New instruction, returns the
external list. Only used by (compile-time-environment).
* libguile/vm.c (scm_load_compiled_with_vm): Adapt to
scm_objcode_to_program change.
* module/language/scheme/translate.scm (translate): Actually pay
attention to the environment passed as an argument.
(custom-transformer-table): Expand out (compile-time-environment) to
something that can be passed to `compile'.
* module/system/base/compile.scm (*current-language*): Instead of
hard-coding `scheme' in various places, use a current language fluid,
initialized to `scheme'.
(compile-file, load-source-file): Adapt to *current-language*.
(load-source-file): Ada
(scheme-eval): Removed, no one used this.
(compiled-file-name): Don't hard-code "scm" and "go"; instead use the
%load-extensions and %load-compiled-extensions.
(cenv-module, cenv-ghil-env, cenv-externals): Some accessors for
compile-time environments.
(compile-time-environment): Here we define (compile-time-environment)
to something that will return #f; the compiler however produces
different code as noted above.
(compile): New function, compiles an expression into a thunk, then runs
the thunk to get the value. Useful for procedures. The optional second
argument can be either a module or a compile-time-environment; in the
latter case, we can recompile even with lexical bindings.
(compile-in): If the env specifies a module, set that module for the
duration of the compilation.
* module/system/base/syntax.scm (%compute-initargs): Fix a bug where the
default value for a field would always replace a user-supplied value.
Whoops.
* module/system/il/ghil.scm (ghil-env-dereify): New function, takes the
result of ghil-env-reify and turns it back into a GHIL environment.
* scripts/compile (compile): Remove some of the tricky error handling, as
the library procedures handle this for us.
* test-suite/tests/compiler.test: Add a test for the dynamic compilation
bits.
Andy Wingo [Fri, 24 Oct 2008 09:56:31 +0000 (11:56 +0200)]
add `formals', `body', and `compile-env' slots to <method>
* ice-9/boot-9.scm (compile-time-environment): Return #f instead of
erroring under the interpreter, a bit more sane.
* libguile/goops.c (create_standard_classes):
* libguile/goops.h (scm_si_formals, scm_si_body, scm_si_compile_env):
* oop/goops.scm (method, initialize): Add `formals', `body', and
`compile-env' slots to <method>.
Andy Wingo [Fri, 24 Oct 2008 09:38:32 +0000 (11:38 +0200)]
defmacroize (oop goops accessors), (oop goops save)
* oop/goops/accessors.scm (define-class-with-accessors)
(define-class-with-accessors-keywords): Turn into defmacros.
* oop/goops/save.scm (readable, restore, write-component): Turn into
defmacros.
Both of these changes are untested, unfortunately.
Andy Wingo [Fri, 24 Oct 2008 09:36:59 +0000 (11:36 +0200)]
add `compile-time-environment'
* ice-9/boot-9.scm (compile-time-environment): New function, with
documentation. The trick is that the compiler recognizes calls to
(compile-time-environment) and replaces it with a representation of the
*available* lexicals. Note that this might not be all the lexicals;
only the heap-allocated ones are returned.
* module/language/scheme/translate.scm (custom-transformer-table):
Compile `compile-time-environment' to <ghil-reified-env>.
* module/system/il/compile.scm (codegen): Add <ghil-reified-env> clause,
which calls ghil-env-reify.
* module/system/il/ghil.scm (ghil-env-reify): New procedure, returns a
list of (NAME . EXTERNAL-INDEX).
(<ghil>): Add <ghil-reified-env> object.
Andy Wingo [Fri, 24 Oct 2008 09:09:43 +0000 (11:09 +0200)]
define-type no longer expects `|' subform
* module/system/base/syntax.scm (define-type): Rework to not require the
`|', which confuses Emacs.
* module/system/il/ghil.scm (<ghil>):
* module/system/il/glil.scm (<glil>): Adapt to define-type changes.
Neil Jerram [Wed, 22 Oct 2008 07:45:42 +0000 (08:45 +0100)]
Fix hang in srfi-18.test
* libguile/threads.h (held_mutex): New field.
* libguile/threads.c (enqueue, remqueue, dequeue): Use critical
section to protect access to the queue.
(guilify_self_1): Initialize held_mutex field.
(on_thread_exit): If held_mutex non-null, unlock it.
(fat_mutex_unlock, fat_cond_free, scm_make_condition_variable,
fat_cond_signal, fat_cond_broadcast): Delete now unnecessary uses
of c->lock.
(fat_mutex_unlock): Pass m->lock to block_self() instead of
c->lock; move scm_i_pthread_mutex_unlock(m->lock) call from before
block_self() to after.
(scm_pthread_cond_wait, scm_pthread_cond_timedwait,
scm_i_thread_sleep_for_gc): Set held_mutex before pthread call;
reset it afterwards.
I was seeing a hang in srfi-18.test, when running make check in master,
in the "exception handler installation is thread-safe" test. It wasn't
100% reproducible, so looked like a race.
The problem is that wait-condition-variable is not actually
atomic in the way that it is supposed to be. It unlocks the mutex,
then starts waiting on the cond var. So it is possible for another
thread to lock the same mutex, and signal the cond var, before the
wait-condition-variable thread starts waiting.
In order for wait-condition-variable to be atomic - e.g. in a race
where thread A holds (Scheme-level) mutex M, and calls
(wait-condition-variable C M), and thread B calls (begin (lock-mutex
M) (signal-condition-variable C)) - it needs to call pthread_cond_wait
with the same underlying mutex as is involved in the `lock-mutex'
call. In terms of the threads.c code, this means that it has to use
M->lock, not C->lock.
block_self() used its mutex arg for two purposes: for protecting
access and changes to the wait queue, and for the pthread_cond_wait
call. But it wouldn't work reliably to use M->lock to protect C's
wait queue, because in theory two threads can call
(wait-condition-variable C M1) and (wait-condition-variable C M2)
concurrently, with M1 and M2 different. So we either have to pass
both C->lock and M->lock into block_self(), or use some other mutex to
protect the wait queue. For this patch, I switched to using the
critical section mutex, because that is a global and so easily
available. (If that turns out to be a problem for performance, we
could make each queue structure have its own mutex, but there's no
reason to believe yet that it is a problem, because the critical
section mutex isn't used much overall.)
So then we call block_self() with M->lock, and move where M->lock is
unlocked to after the block_self() call, instead of before.
That solves the first hang, but introduces a new one, when a SRFI-18
thread is terminated (`thread-terminate!') between being launched
(`make-thread') and started (`thread-start!'). The problem now is
that pthread_cond_wait is a cancellation point (see man
pthread_cancel), so the pthread_cond_wait call is one of the few
places where a thread-terminate! call can take effect. If the thread
is cancelled at that point, M->lock ends up still being locked, and
then when do_thread_exit() tries to lock M->lock again, it hangs.
The fix for that is a new `held_mutex' field in scm_i_thread, which is
set to point to the mutex just before a pthread_cond_(timed)wait call,
and set to NULL again afterwards. If on_thread_exit() finds that
held_mutex is non-NULL, it unlocks that mutex.
A detail is that checking and unlocking held_mutex must be done before
on_thread_exit() calls scm_i_ensure_signal_delivery_thread(), because
the innards of scm_i_ensure_signal_delivery_thread() can do another
pthread_cond_wait() call and so overwrite held_mutex. But that's OK,
because it's fine for the mutex check and unlock to happen outside
Guile mode.
Lastly, C->lock is then not needed, so I've removed it.
Andy Wingo [Thu, 23 Oct 2008 13:00:19 +0000 (15:00 +0200)]
method is a defmacro.
* oop/goops.scm (method): Make into a defmacro.
Andy Wingo [Thu, 23 Oct 2008 12:56:17 +0000 (14:56 +0200)]
define-method is a defmacro
* oop/goops.scm (define-method): Make into a defmacro -- didn't change
any of the logic, but the logic is a bit dodgy (see the note in the
source).
Andy Wingo [Thu, 23 Oct 2008 12:24:57 +0000 (14:24 +0200)]
define-generic, define-accessor are defmacros too
* oop/goops.scm (define-generic, define-accessor): Define as defmacros. I
find their semantics to be a bit odd, though -- but the test case
checks for this behavior, so we'll follow the test cases.
Andy Wingo [Thu, 23 Oct 2008 12:03:51 +0000 (14:03 +0200)]
make `define-class' and `class' into defmacros
* oop/goops.scm: Use srfi-1, as util.scm already does.
(kw-do-map): New helper for processing keyword args.
(define-class-pre-definition, define-class): Rework so that
define-class is a defmacro without side effects. There are two
functional differences: we don't check that define-class is called only
at the toplevel, because defining a lexical class might makes sense,
and defmacros don't give us the toplevel check that we would want.
Second in the redefinition case, we don't do a `define', as we don't
actually need a new variable.
(class): Similarly, make `class' a defmacro.
Andy Wingo [Sat, 18 Oct 2008 17:42:37 +0000 (19:42 +0200)]
fix typo in assembler
* module/system/vm/assemble.scm (dump-object!): Whoops, spell `nexts'
correctly.
Andy Wingo [Sat, 18 Oct 2008 17:21:44 +0000 (19:21 +0200)]
fix bug in self-tail-recursion with "external" variables; other sundries
* gdbinit (pp, inst): New commands.
* libguile/vm-engine.c (vm_error_not_a_pair): New error case.
* libguile/vm-i-scheme.c (VM_VALIDATE_CONS): New macro -- use this
instead of SCM_VALIDATE_* because SCM_VALIDATE will exit nonlocally
before we have a chance to sync the regs.
(car, cdr, set-car, set-cdr): Use VM_VALIDATE_CONS.
* libguile/vm-i-system.c (goto/args): Bugfix: when doing a
self-tail-recursion, allocate fresh externals. Fixes use of match.go.
* module/system/vm/assemble.scm (dump-object!): Add some checks that we
aren't dumping out values that the VM can't handle.
* module/system/vm/disasm.scm (disassemble-externals): Fix rotten call to
`print-info'.
* oop/goops/dispatch.scm: Add a FIXME.
* testsuite/Makefile.am (vm_test_files):
* testsuite/t-closure4.scm (extract-symbols): New test, distilled with
much effort out of match.scm.
* ice-9/Makefile.am (NOCOMP_SOURCES): Re-enable compilation of match.scm.
Yay!
Andy Wingo [Sat, 18 Oct 2008 14:06:43 +0000 (16:06 +0200)]
bug fix to enable code "packing"
* module/system/vm/conv.scm (code-pack): Fix so that we actually
recognize (make-int8 1) and turn it into (make-int8:1).
Andy Wingo [Thu, 16 Oct 2008 12:16:53 +0000 (14:16 +0200)]
elisp.test: apply to nil-terminated list is UNRESOLVED with compiled boot-9
* test-suite/tests/elisp.test: If running the '(apply foo nil) test
fails with a vm-error, throw UNRESOLVED. This allows the test suite to
pass in the compiled boot-9.scm while still keeping the elisp apply
issue open.
Andy Wingo [Thu, 16 Oct 2008 11:58:59 +0000 (13:58 +0200)]
run the elisp test with a larger stack limit
* test-suite/tests/elisp.test: Enlarge the stack for the duration of the
elisp test. It's a hack, but it at least allows the test to run with a
compiled ice-9.
Andy Wingo [Thu, 16 Oct 2008 11:56:41 +0000 (13:56 +0200)]
fix backtraces, broken since the program-bindings format change
* module/system/vm/frame.scm (frame-bindings): Fix for new binding
format; actually use the bindings accessors.
(frame-lookup-binding): Clarify.
Andy Wingo [Thu, 16 Oct 2008 11:49:57 +0000 (13:49 +0200)]
fix use of `binding' data abstraction
* module/system/vm/assemble.scm (make-temp-binding, btemp:name)
(btemp:extp, btemp:index): Don't abuse program.scm's make-binding to
make something that actually isn't a binding.
(codegen): Do use program.scm's make-binding to make something that
actually is a binding.
* module/system/vm/program.scm (binding:start, binding:end): New
accessors.
(make-binding): Expand to have the start and end arguments in the
constructor.
Andy Wingo [Thu, 16 Oct 2008 11:24:39 +0000 (13:24 +0200)]
ensure that lists pushed onto the stack are proper
I saw this problem when running elisp.test -- it tries to apply a
function to an arglist ending in nil, which obviously is not null.
* libguile/vm-engine.h (PUSH_LIST): New helper macro, pushes the elements
of a list onto the stack. Checks to make sure that the list is proper.
* libguile/vm-i-system.c (list-break, mv-call, apply, goto/apply)
(goto/cc): Use LIST_BREAK.
* libguile/vm-engine.c (vm_error_improper_list): New error case.
Andy Wingo [Thu, 16 Oct 2008 10:55:27 +0000 (12:55 +0200)]
fix asyncs running in the vm; re-enable popen.scm compilation
* libguile/vm-i-system.c (goto/args): Sync the registers before doing the
SCM_TICK. We probably need a different SCM_TICK that saves the regs
only if necessary. This fixes GC problems with a compiled popen.scm.
* ice-9/Makefile.am: Re-enable popen.scm compilation.
Andy Wingo [Wed, 15 Oct 2008 20:44:37 +0000 (22:44 +0200)]
fix `(help)'
* ice-9/session.scm (help): Return valid scheme forms in the no-arg and
no-regex cases.
Andy Wingo [Wed, 15 Oct 2008 20:42:51 +0000 (22:42 +0200)]
fix mv-call disasm bug
* module/system/vm/disasm.scm (code-annotation): Fix bug with mv-call.
Andy Wingo [Wed, 15 Oct 2008 20:30:47 +0000 (22:30 +0200)]
fix disasm bugs, add some more instruction annotations
* module/system/vm/disasm.scm (disassemble-program): Fix misunderstanding
of nlocs: the *actual* number of locals is nlocs + nargs, even if the
arg is heap-allocated -- because our calling convention always puts the
initial val on the stack. Also: don't disassemble the objects, they are
now woven into the text.
(code-annotation): Fix external-{ref,set} handling to allow for
referencing externals from enclosed stack frames. Really this should be
statically determined, though. Add late-variable-{ref,set} handling.
Andy Wingo [Sun, 12 Oct 2008 20:49:24 +0000 (22:49 +0200)]
make disassembly better -- a more woven text.
* module/system/vm/assemble.scm (pop): Define a pop here too.
(codegen): Rework how bindings are represented in a program's
meta-info, so they declare their range in the binding list instead of
you having to figure out when they end.
* module/system/vm/conv.scm (make-byte-decoder): Return the end-address
as well; requires a change to callers.
* module/system/vm/disasm.scm (disassemble-objcode, disassemble-program)
(disassemble-bytecode, disassemble-objects, disassemble-externals)
(disassemble-meta, source->string, make-int16, code-annotation)
(print-info): Rework to display my domination of `format', and, more
seriously, start to integrate the "subsections" of the disassembly into
the main disassembly text.
* module/system/vm/program.scm (program-bindings-as-lambda-list): Update
for new bindings format; should be more correct.
Andy Wingo [Sat, 11 Oct 2008 16:55:44 +0000 (18:55 +0200)]
simplify disassembly annotations a bit
* module/system/vm/disasm.scm (original-value): Simplify a bit to
normally dispatch on the instruction, only trying code->object at the
end.
Andy Wingo [Sat, 11 Oct 2008 13:03:00 +0000 (15:03 +0200)]
make each invocation of `while' throw to different keys
* ice-9/boot-9.scm (while): Further fixes to while, brought out by the
test suite. Also updated documentary comments.
Andy Wingo [Sat, 11 Oct 2008 10:01:25 +0000 (12:01 +0200)]
relax an assertion -- the test suite completes without aborting, whee
* libguile/vm-i-system.c (call/cc, goto/cc): Don't assert that ip matches
vp->ip, because vp->ip is not restored by vm_reset_stack, and indeed
it's re-set to 0 by `halt'. But still, perhaps reset_stack and halt
should indeed reset vp->ip.
Andy Wingo [Sat, 11 Oct 2008 09:54:12 +0000 (11:54 +0200)]
truly thread-local vms; don't compile popen.scm
* ice-9/Makefile.am: Don't compile popen.scm, its behaviour at runtime
is not consistent -- seems to miss some GC references? I suspect a bug
in the compiler. In any case without popen.scm being compiled,
continuations.test, r4rs.tes, and r5rs_pitfall.test do pass.
* libguile/threads.h (scm_i_thread):
* libguile/threads.c (thread_mark, guilify_self_2): Add a field for the
thread's vm. Previously I had this as a fluid, but it seems that newly
created threads share their fluid values from the creator thread; as
expected, I guess. In any case one VM should not be active in two
threads.
* libguile/vm.c (scm_the_vm): Change to access the thread-local vm,
instead of accessing a fluid.
(scm_the_vm_fluid): Removed.
* module/system/vm/vm.scm: Removed *the-vm*.
Andy Wingo [Thu, 9 Oct 2008 12:44:43 +0000 (14:44 +0200)]
NULLSTACK fixes for nonlocal exits in reentrant pre-wind handlers
* libguile/vm-i-system.c (goto/cc): Add some asserts here.
* libguile/vm.c (capture_vm_cont): Add some asserts here too.
(reinstate_vm_cont): Null the correct number of bytes. Add a FIXME.
(vm_reset_stack): Make the code a bit clearer. Null the correct number
of bytes.
* libguile/vm-engine.h (NULLSTACK_FOR_NONLOCAL_EXIT): New macro, handles
a very tricky case that took me days to find! Amply commented. Expands
to nothing in the normal case.
* libguile/vm-i-system.c (call, goto/args, mv-call): Call
NULLSTACK_FOR_NONLOCAL_EXIT in the right places. Fixes
continuations.test.
Andy Wingo [Thu, 9 Oct 2008 10:17:51 +0000 (12:17 +0200)]
sundries: side effects in interpreted repl, wrong-num-args in vm, self-checks
* libguile/vm-engine.c (vm_error_wrong_num_args): Sync the registers
before calling scm_wrong_num_args. (The other cases are handled more
uniformly.)
* libguile/vm.c (vm_heapify_frames_1): Add a FIXME: I don't think we
should be modifying the stack.
(scm_vm_save_stack): If stack nulling is enabled, verify the stack here
before reifying it.
* module/language/scheme/spec.scm (scheme): Use primitive-eval here
instead of eval, because at the repl we do want to allow evaluations to
have side effects like setting the current module.
Andy Wingo [Thu, 9 Oct 2008 09:10:25 +0000 (11:10 +0200)]
handle throws to unknown keys in the repl
* module/system/repl/repl.scm (default-catch-handler): Don't rethrow if
we don't know the key, just print an error.
Andy Wingo [Thu, 9 Oct 2008 09:09:43 +0000 (11:09 +0200)]
fix dynwind + nonlocal entrance/exit + programs bug
* libguile/dynwind.c (scm_i_dowinds): Invoke guard procedures when
entering and exiting nonlocally. Previously this procedure was
program-racist.
Andy Wingo [Fri, 3 Oct 2008 14:00:30 +0000 (16:00 +0200)]
precise stack marking, fix some missed references, still imperfect
* libguile/vm-engine.h (CHECK_STACK_LEAK, NULLSTACK): Add a new mode,
VM_ENABLE_STACK_NULLING, that tries to ensure that all stack data past
the top of the stack is NULL. This helps to verify the VM's
consistency. If VM_ENABLE_STACK_NULLING is not defined, there is no
overhead.
(DROP, DROPN): Hook into NULLSTACK.
(POP_LIST): Hoo, fix a good bug: if CONS triggered a GC, the elements
of the list that had not yet been consed would not be marked, because
the sp was already below them.
(NEXT): Hook into CHECK_STACK_LEAK.
(INIT_ARGS): Add a note that consing the rest arg can cause GC.
(NEW_FRAME): Cons up the external data after initializing the frame, so
that if GC is triggered, the precise marker sees a well-formed frame.
* libguile/vm-i-loader.c (load-program): In the four-integers case, use
the POP macro so that we can hook into NULLSTACK (if necessary).
* libguile/vm-i-scheme.c (ARGS2, ARGS3): Hook into NULLSTACK.
* libguile/vm-i-system.c (halt): Null the nvalues. Rework some asserts
into using ASSERT, and null the stack when we free the frame.
(variable-set): Use DROPN instead of sp -= 2.
(BR): Hook into NULLSTACK.
(goto/args): Hook into NULLSTACK. In the non-self case, delay updating
the frame until after INIT_ARGS so that GC sees a well-formed frame.
Delay consing the externals until after the frame is set up, as in
NEW_FRAME.
(call/cc): Add some asserts.
(return): Rework some asserts into ASSERT, and hook into NULLSTACK.
(return/values): Hook into NULLSTACK, and use ASSERT.
(return/values*) Use ASSERT.
* libguile/vm.c (VM_ENABLE_ASSERTIONS, VM_ENABLE_STACK_NULLING): These
are the variables that control assertions and nulling. Perhaps we can
do these per-engine when we start compiling the debug engine separate
from a speedy engine.
(vm_mark_stack): Add a precise stack marker. Yay!
(vm_cont_mark): Mark the continuation stack precisely.
(capture_vm_cont): Record the difference from the vp's stack_base too,
so that we can translate the dynamic links when marking the
continuation stack. Memset the stack to NULL if we are doing nulling.
(reinstate_vm_cont): If we are nulling, null out the relevant part
of the stack.
(vm_reset_stack): When resetting sp due to a nonlocal exit, null out
the stack too.
(vm_mark): If we are nulling, assert that there are no extra values on
the stack. Mark the stack precisely.
Andy Wingo [Fri, 3 Oct 2008 13:07:09 +0000 (15:07 +0200)]
remove repl.scm's start-stack definition
* module/system/repl/repl.scm: Now that we actually compile start-stack,
no need to provide our own definition here.
Andy Wingo [Fri, 3 Oct 2008 13:06:03 +0000 (15:06 +0200)]
add gdb-pre-inst-guile
* configure.in:
* gdb-pre-inst-guile.in: Add gdb-pre-inst-guile, because I'm tired of
typos. You can run it just like Guile. For compiling, you might try
GUILE=./gdb-pre-inst-guile scripts/compile foo.scm.
Andy Wingo [Thu, 2 Oct 2008 09:00:55 +0000 (11:00 +0200)]
be more like the interpreter in signalling wrong-num-args
* libguile/vm-engine.c: Call scm_wrong_num_args in the wrong-num-args
case, to be more like the interpreter.
* libguile/vm-engine.h (ASSERT): New macro.
* libguile/vm-i-system.c (apply, goto/apply): Assert that nargs >= 2,
because the compiler should always feed us correct instructions.
(call/cc): If no values are returned to the continuation, signal
no_values instead of wrong_num_args.
Andy Wingo [Tue, 30 Sep 2008 21:57:13 +0000 (23:57 +0200)]
load the i18n extension when compiling i18n.scm
* ice-9/i18n.scm: Load the i18n extension when compiling too, so that the
macros that depend on (provided? 'nl-langinfo) actually have
nl-langinfo. Fixes the i18n test.
Andy Wingo [Tue, 30 Sep 2008 21:41:16 +0000 (23:41 +0200)]
fix compilation of quasiquote with splicing and improper lists
* libguile/vm-engine.h (POP_CONS_MARK): New macro, analagous to
POP_LIST_MARK; used in quasiquote on improper lists.
* libguile/vm-i-system.c (cons-mark): New instruction. You know the
drill, remove all your .go files please.
* module/system/il/compile.scm (codegen): Compile quasiquoted improper
lists with splices correctly. Additionally check that we don't have
slices in the CDR of an improper list.
* testsuite/t-quasiquote.scm: Add a test for unquote-splicing in improper
lists.
Andy Wingo [Tue, 30 Sep 2008 20:50:48 +0000 (22:50 +0200)]
fix some missed references when calling C functions
* gdbinit: Update to be a bit more useful.
* libguile/vm-i-system.c: Make sure that arguments to C procedures are
visible on the stack so they get marked. Could be a source for the
missed references.
Andy Wingo [Tue, 30 Sep 2008 19:12:16 +0000 (21:12 +0200)]
Merge commit 'origin/master' into vm
Conflicts:
doc/Makefile.am
ice-9/Makefile.am
libguile/gc.c
Andy Wingo [Tue, 30 Sep 2008 18:29:35 +0000 (20:29 +0200)]
(oop goops) works again, after (the-environment) removal
* oop/goops.scm: Update so as not to use (the-environment), which no
longer exists. I think that the speed characteristics are the same,
broadly speaking.
Andy Wingo [Tue, 30 Sep 2008 18:18:57 +0000 (20:18 +0200)]
object-documentation knows about programs
* ice-9/documentation.scm (object-documentation): Add hooks for getting
documentation for compiled procedures, too. (Goops would be helpful
here.)
Andy Wingo [Mon, 29 Sep 2008 22:40:36 +0000 (00:40 +0200)]
don't require users of users of optargs to have used optargs
* ice-9/optargs.scm: Do the compile-friendly equivalent of unquoting in a
value into the macro: use @@.
Andy Wingo [Mon, 29 Sep 2008 22:31:17 +0000 (00:31 +0200)]
compile @ and @@
* libguile/vm-engine.c (vm_run): Add new error case for resolving @ or @@
references, but there is no such module. Possible if
module-public-interface returns #f.
* libguile/vm-i-loader.c (link-now): Allow the stack arg to be a sym, as
before, or a list, indicating an absolute reference. Could be two
separate instructions, but I'm lazy.
* libguile/vm-i-system.c (late-variable-ref, late-variable-set): As in
link-now, allow the lazy reference to be a list, for @ and @@.
* module/language/scheme/translate.scm (custom-transformer-table):
Compile @ and @@, and set! forms for both of them. This will ease the
non-hygienic pain for exported macros.
* module/system/il/compile.scm (make-glil-var): Translate public and
private module variable references into glil-module variables.
* module/system/il/ghil.scm (ghil-var-at-module!): New function, resolves
a variable for @ or @@.
* module/system/il/glil.scm (<glil-module>): Revival of <glil-module>,
this time with the semantics that it really links to a particular
module.
* module/system/vm/assemble.scm (<vlink-now>, <vlink-later>): Redefine as
taking a "key" as the argument, which may be a sym or a list; see the
notes on link-now for more details.
(codegen): Compile <glil-module> appropriately. Some duplication here,
probably could use some cleanup later.
Andy Wingo [Mon, 29 Sep 2008 21:20:10 +0000 (23:20 +0200)]
call toplevel variables "toplevel", not "module"
* module/system/il/ghil.scm (ghil-var-for-set!, ghil-var-for-ref!)
(ghil-var-define!): ghil-var-kind of a toplevel var is now 'toplevel.
* module/system/il/glil.scm: Renamve <glil-module> to <glil-toplevel>.
Remove the unused `module' field. Remove the unused <glil-late-bound>
type.
* module/system/il/compile.scm (make-glil-var): s/toplevel/module/
* module/system/vm/assemble.scm (<vlink-later>, <vdefine>): Remove the
unused `module' parameters from these two types.
(codegen, dump-object!): Adapt to module/toplevel name changes.
Andy Wingo [Mon, 29 Sep 2008 20:52:36 +0000 (22:52 +0200)]
remove `type' and `value' fields from <ghil-var>
* module/system/il/ghil.scm (<ghil-var>): Remove `type' and `value'
fields, as they were not used.
Andy Wingo [Mon, 29 Sep 2008 19:36:25 +0000 (21:36 +0200)]
move module-public-interface to C, and expose it as C API
* libguile/modules.h:
* libguile/modules.c:
* ice-9/boot-9.scm (module-public-interface): Move definition of
module-public-interface to C, where it is now available as
scm_module_public_interface ().
Han-Wen Nienhuys [Sat, 13 Sep 2008 03:19:23 +0000 (00:19 -0300)]
Remove GH and its traces.
Andy Wingo [Sun, 28 Sep 2008 21:09:11 +0000 (23:09 +0200)]
allocate variables that are set! on the heap
* module/system/il/ghil.scm (ghil-lookup): So, it turns out this function
needed to be split into three:
(ghil-var-is-bound?, ghil-var-for-ref!, ghil-var-for-set!): The
different facets of ghil-lookup. Amply commented in the source. The
difference being that we now allocate variables that are set! on the
heap, so that other continuations see their possibly-modified values.
(force-heap-allocation!): New helper.
* testsuite/Makefile.am:
* testsuite/t-call-cc.scm: New test, that variables that are set! are
allocated on the heap, so that subsequent modifications are still
seen by the continuation. The test was distilled from test 7.3 in
r5rs_pitfall.test.
Andy Wingo [Sun, 28 Sep 2008 21:08:14 +0000 (23:08 +0200)]
revert part of
7ff017002ddc980 that caused missed references
* libguile/programs.c (scm_c_make_closure): If the program is actually
not a program, abort. This can happen if GC misses a reference, as
currently seems to happen.
* libguile/vm.c (vm_mark): Revert part of
7ff017002ddc980f684120653549a10c6c7cde5c, which changed the call to
scm_mark_locations. I'm 99% *sure* this is wrong, but it seems to
prevent missed references when recompiling the .go files in guile
itself. Needs revisiting soon, but for the time being we can go back to
where we were a couple of days ago.
* libguile/vm-i-system.c (halt, vector, vector-mark): Sync the registers
before calling into C, as it may GC.
Andy Wingo [Sun, 28 Sep 2008 16:24:20 +0000 (18:24 +0200)]
don't compile psyntax.scm
* ice-9/Makefile.am: Don't try to compile psyntax.scm
Andy Wingo [Fri, 26 Sep 2008 15:35:37 +0000 (17:35 +0200)]
rename psyntax.ss to psyntax.scm to hack around makefile foo
* ice-9/Makefile.am (SOURCES):
* ice-9/syncase.scm:
* ice-9/psyntax.scm: Renamve psyntax.ss to psyntax.scm. This way the
guilec rules won't delete it on a make clean. Doh!
Andy Wingo [Fri, 26 Sep 2008 11:42:09 +0000 (13:42 +0200)]
Fix continuation marking, and some tests.
* libguile/continuations.c (continuation_mark): Mark the vm
continuations.
* libguile/vm.c (vm_cont_mark): Fix the marking function.
(vm_mark): Fix this one too -- the size is a number of STACKITEMS,
which we foolishly assume are the same size as SCM.
* test-suite/tests/ftw.test: Make our stat hacks verifyable without
assuming that they are interpreted.
* test-suite/tests/r5rs_pitfall.test: Re-indent.
Andy Wingo [Fri, 26 Sep 2008 10:03:36 +0000 (12:03 +0200)]
actually compile start-stack to something useful
* ice-9/boot-9.scm (start-stack): Define as a defmacro instead of an acro
in C. We have a way to delay evaluation of the exp, after all: putting
it in a thunk is sufficient.
* libguile/debug.h:
* libguile/debug.c (scm_sys_start_stack): Renamed from scm_start_stack,
and exposed to the user. Takes a thunk instead of an expression +
environment.
(scm_m_start_stack): Remove this acro.
* module/language/scheme/translate.scm (custom-transformer-table): Remove
the start-stack special case.
Ludovic Courtès [Thu, 25 Sep 2008 19:36:14 +0000 (21:36 +0200)]
Enclose `regexp.test' in a module.
* test-suite/tests/regexp.test: Add `define-module' clause.
Ludovic Courtès [Thu, 25 Sep 2008 19:07:06 +0000 (21:07 +0200)]
Fix handling of the FLAGS argument in `fold-matches'.
* ice-9/regex.scm (fold-matches): If FLAGS is non-null, use
`(car flags)', not `flags'.
* test-suite/tests/regexp.test ("fold-matches"): New test prefix.
* NEWS: Update.
Andy Wingo [Thu, 25 Sep 2008 15:17:02 +0000 (17:17 +0200)]
further compilation fixes -- all files compile fine now
* ice-9/runq.scm (strip-sequence): Remove use of obtuse guile `define'
extension.
* ice-9/boot-9.scm (while): Redefine so as not to unquote in a procedure.
Less hygienic. Perhaps we should switch to syncase at some point.
* ice-9/session.scm (help): Redefine as a normal macro, so that it can be
compiled. Not very useful though -- further effort should go into
(system repl ...).
(system-module): Removed, it didn't work, and is not useful as far as I
can tell.
* ice-9/string-fun.scm (string-prefix-predicate): Remove guile define
extension usage. Compilation also fixed by `while' compilation fix.
* ice-9/threads.scm (par-mapper): Remove guile define extension usage.
Andy Wingo [Thu, 25 Sep 2008 14:50:21 +0000 (16:50 +0200)]
compile `delay' into `make-promise' with a thunk
* module/language/scheme/translate.scm (custom-transformer-table):
Translate `delay' into `make-promise'.
Andy Wingo [Thu, 25 Sep 2008 14:16:35 +0000 (16:16 +0200)]
export `make-promise' to scheme
* libguile/eval.h:
* libguile/eval.c (scm_make_promise): Rename from `scm_makprom', and
export as the scheme procedure, `make-promise'.
* libguile/eval.i.c (CEVAL): s/makprom/make_promise/.
Andy Wingo [Thu, 25 Sep 2008 11:54:54 +0000 (13:54 +0200)]
enable compilation of more modules
* ice-9/Makefile.am: Compile most modules. There are still a couple that
fail to compile.
Andy Wingo [Thu, 25 Sep 2008 11:46:09 +0000 (13:46 +0200)]
a number of small compilation fixes
* ice-9/boot-9.scm: Allow a compiled load of posix, networking, and
deprecated files.
* module/language/scheme/translate.scm (lookup-transformer): Lookup the
sc-macro by value, not by name. Works around the fact that compiled
macros don't have names, which is probably a bug.
* module/system/base/compile.scm (syntax-error)
(call-with-compile-error-catch): Throw and catch a key that's not used
by anyone else. Write error messages to the error port.
* module/system/repl/repl.scm (default-catch-handler): Call display-error
with the correct number of arguments.
* module/system/vm/frame.scm (frame-program-name): Guard against unbound
variables.
* ice-9/optargs.scm (let-keywords-template): Don't unquote in a helper
procedure. A bit irritating. I suppose we should fix the modules +
syncase situation at some point, and then switch to syncase.
Andy Wingo [Thu, 25 Sep 2008 11:40:13 +0000 (13:40 +0200)]
compile psyntax-pp
* ice-9/Makefile.am: Compile psyntax-pp.scm, which is the new name of
psyntax.pp.
* ice-9/syncase.scm: Load the pre-processed source as psyntax-pp so that
we load up a .go file if available.
Andy Wingo [Thu, 25 Sep 2008 10:08:54 +0000 (12:08 +0200)]
fix handling of multiple values from c functions
* libguile/vm-i-system.c (mv-call, goto/cc): Fix handling of values
returns from C or interpreted functions.
Andy Wingo [Thu, 25 Sep 2008 10:07:52 +0000 (12:07 +0200)]
add gdbinit for debugging the vm
* gdbinit: Add my gdbinit. The most useful commands are gwrite and
vmstack.