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.
Andy Wingo [Thu, 25 Sep 2008 09:07:54 +0000 (11:07 +0200)]
compile call/cc, yee ha
* libguile/vm-i-system.c (call, goto/args): Add a FIXME for handling the
case in which a call to the interpreter returns a values object.
(call/cc, goto/cc): Flesh out, and handle full continuations (with the
C stack also).
* module/language/scheme/translate.scm (custom-transformer-table):
Compile call-with-current-continuation. This is necessary so that the
called procedure is called in tail position.
* module/system/il/compile.scm (codegen): Translate apply to goto/apply,
call/cc to goto/cc, etc when in tail position.
Andy Wingo [Thu, 25 Sep 2008 09:04:35 +0000 (11:04 +0200)]
fix bug introduced in the fluid commit
* libguile/vm.c (the-vm): If the dynamic binding of *the-vm* is false,
make a new vm. Fixes multiple threads with the vm since the *the-vm*
fluid changes.
Andy Wingo [Wed, 24 Sep 2008 15:04:14 +0000 (17:04 +0200)]
make call/cc capture and restore the vm stacks
* libguile/continuations.c (scm_make_continuation): Capture VM
continuations as well, as their stack is outside the C stack.
(copy_stack): Reinstate VM stacks with the C stack.
* libguile/continuations.h (scm_t_contregs): Add a pointer for VM stacks.
A binary-incompatible change -- hopefully not too many people were
messing around with this struct, though.
* libguile/vm-engine.c (vm_run): Add a note about possibly maintaining a
stack of vms.
* libguile/vm.c (struct scm_vm_cont): New struct, distinct from scm_vm.
(vm_cont_mark, vm_cont_free, capture_vm_cont, reinstate_vm_cont):
Reorder some code, and fix some bad assumptions about what part of the
stack to copy; obviously this code was never used.
* libguile/vm.h:
* libguile/vm.c (scm_vm_capture_continuations)
(scm_vm_reinstate_continuations): New public functions, used by
continuations.c.
Andy Wingo [Wed, 24 Sep 2008 09:47:25 +0000 (11:47 +0200)]
the vm is a fluid
* module/system/vm/vm.scm:
* libguile/vm.h:
* libguile/vm.c: Make the `the-vm' procedure access a fluid, `*the-vm*'.
Export that fluid from vm.h and vm.scm.
Ludovic Courtès [Mon, 22 Sep 2008 21:03:20 +0000 (23:03 +0200)]
Make literal strings (i.e., returned by `read') read-only.
* libguile/read.c (scm_read_string): Use `scm_i_make_read_only_string ()' to
return a read-only string, as mandated by R5RS. Reported by Bill
Schottstaedt <bil@ccrma.Stanford.EDU>.
* libguile/strings.c (scm_i_make_read_only_string): New function.
(scm_i_shared_substring_read_only): Special-case the empty string
so that the read-only and read-write empty strings are `eq?'. This
optimization is relied on by the `substring/shared' `empty string'
test case in `srfi-13.test'.
* libguile/strings.h (scm_i_make_read_only_string): New declaration.
* test-suite/tests/strings.test ("string-set!")["literal string"]: New test.
* NEWS: Update.
Ludovic Courtès [Mon, 22 Sep 2008 20:51:36 +0000 (22:51 +0200)]
Make `symbol->string' return a read-only string.
* libguile/strings.c (scm_i_symbol_substring): Return a read-only string
since R5RS requires `symbol->string' to return a read-only string.
Reported by Bill Schottstaedt <bil@ccrma.Stanford.EDU>.
* test-suite/tests/symbols.test: Add `define-module' clause.
(exception:immutable-string): Adjust to current exception.
("symbol->string")["result is an immutable string"]: Use
`pass-if-exception' instead of `expect-fail-exception'.
* NEWS: Update.
Neil Jerram [Wed, 17 Sep 2008 20:46:40 +0000 (21:46 +0100)]
Fix for incorrect (gcd -2) => -2; should give 2.
(reported by Bill Schottstaedt)
* libguile/numbers.c (scm_gcd): When only one arg given, use scm_abs
to ensure that result is non-negative.
* test-suite/tests/numbers.test ("gcd"): New test, (gcd -2).
Ludovic Courtès [Thu, 18 Sep 2008 21:13:42 +0000 (23:13 +0200)]
Fix `strftime' documentation wrt. `%Z'.
* doc/ref/posix.texi (Time)[strftime]: Remove erroneous note saying
that `%Z' ignores `tm:zone'. Reported by Neil Jerram.
Andy Wingo [Thu, 18 Sep 2008 21:04:58 +0000 (23:04 +0200)]
don't poke installed scm, go, etc files when running pre-inst-guile
* libguile/load.c (scm_init_load_path): If GUILE_SYSTEM_PATH is set, use
that instead of the compiled-in suffix to the load path. And, as a
special case, GUILE_SYSTEM_PATH= is interpreted as '(). A bit nasty.
* pre-inst-guile-env.in (top_builddir): Set GUILE_SYSTEM_PATH to the
empty string, if it is not set.
Andy Wingo [Thu, 18 Sep 2008 20:49:55 +0000 (22:49 +0200)]
lambda-lifting for (lambda () ...) as consumer of call-with-values
* libguile/vm-engine.c (vm_run): Add new error case,
vm_error_not_enough_values.
* libguile/vm-i-system.c (goto/nargs, call/nargs): So, in these cases, if
we get too many values, we don't truncate the values like we do in the
single-value continuation case, or in the mvbind case. What to do? I
guess we either truncate them here, or only allow the correct number of
values. Dunno. Mark the code as a fixme.
(truncate-values): New instruction, for mv-bind: checks that the number
of values on the stack is compatible with the number of bindings we
have arranged for them, truncating if necessary.
* module/language/scheme/translate.scm (custom-transformer-table):
Compile receive as a primary form -- not so much because it is a
primary form, but more to test the mv-bind machinery. Also it's more
efficient, I think.
* module/system/il/compile.scm (lift-variables!): New helper, factored
out of `optimize'.
(optimize): Add a few more cases. Adapt `lambda' optimization, which
isn't much. I'm not happy with ghil as a mungeable language.
Add a case for call-with-values with the second argument is
a lambda: lift the lambda. Untested.
(codegen): Refactor the push-bindings! code. Compile mv-bind.
* module/system/il/ghil.scm (<ghil-mv-bind>): Add mv-bind construct,
along with its procedures.
* module/system/il/glil.scm (<glil-mv-bind>): Add mv-bind construct,
different from the high-level one. It makes sense in the source, I
think.
* module/system/vm/assemble.scm (codegen): Assemble glil-mv-bind by
pushing onto the bindings list, and actually push some code to truncate
the values.
Ludovic Courtès [Tue, 16 Sep 2008 21:16:00 +0000 (23:16 +0200)]
Fix first-time compilation
Hello!
The attached patch fixes first-time compilation, by ensuring SRFI
modules are built before "guile-tools compile" is ever run.
Thanks,
Ludo'.
From
691a111c440a26c021f52b4027b0d9772f8e04cc Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Tue, 16 Sep 2008 23:13:38 +0200
Subject: [PATCH] Fix compilation order of the sub-directories.
* Makefile.am (SUBDIRS): Move `ice-9' past `srfi' and friends, so that
the SRFI modules needed by the compiler are built before "guile-tools
compile" is used.
Andy Wingo [Thu, 18 Sep 2008 18:05:23 +0000 (20:05 +0200)]
fix case in which we can fail to exit the repl cleanly
* module/system/repl/repl.scm (next-char): Don't throw if we get an EOF,
just return the EOF object. Fixes a case in which we fail to exit
cleanly.
Andy Wingo [Mon, 15 Sep 2008 22:26:22 +0000 (00:26 +0200)]
compile call-with-values, woot!
* libguile/vm-engine.c (vm_run): Add another byte onto the bootstrap
program, as the offset passed to mv-call now takes two bytes.
* module/system/vm/frame.scm (bootstrap-frame?): Update for the new
bootstrap length. Really we should just check for 'halt though.
* libguile/vm-i-system.c (FETCH_OFFSET): New helper, used in BR().
(goto/nargs, call/nargs): Versions of goto/args and call, respectively,
that take the number of arguments from a value on the top of the stack.
(mv-call): Call FETCH_OFFSET to get the offset.
* module/language/scheme/translate.scm (custom-transformer-table):
Compile call-with-values to <ghil-mv-call>. There is some trickery
because of the r4rs.scm call-with-values trampolines.
* module/system/il/ghil.scm: Add <ghil-mv-call> and accessors.
* module/system/il/compile.scm (codegen): Compile <ghil-mv-call>.
* module/system/il/glil.scm: Add <glil-mv-call>, which needs some special
assembly because of the label. Fix some typos.
* module/system/vm/assemble.scm (byte-length): New helper, factored out
and made more general.
(codegen): Assemble mv-call, including the label.
(check-length): New helper, makes sure that the addressing is
consistent within the produced object code.
(stack->bytes): Rewrite to be more generic -- now `br' instructions
aren't the only ones jumping around in the instruction stream.
* module/system/vm/conv.scm (make-byte-decoder): Return two values in the
#f case.
* module/system/vm/disasm.scm (disassemble-bytecode): Rewrite, because
the previous implementation depended on a guile interpreter quirk:
namely, that multiple values could be represented within one value, and
destructured later.
Neil Jerram [Sun, 14 Sep 2008 23:25:25 +0000 (00:25 +0100)]
Make multi-byte reads on unbuffered ports more efficient.
Idea and original patch were by Ludovic Courtès, this is Neil Jerram's
reworking of it.
* libguile/srfi-4.c (scm_uniform_vector_read_x): Use scm_c_read,
instead of equivalent code here.
* libguile/ports.c (scm_fill_input): Add assertion that read
buffer is empty when called.
(port_and_swap_buffer, swap_buffer): New, for...
(scm_c_read): Use caller's buffer for reading, to avoid making N
1-byte low-level read calls, in the case where the port is
unbuffered (or has a very small buffer).
Ludovic Courtès [Sun, 1 Jun 2008 17:31:36 +0000 (19:31 +0200)]
Add `uniform-vector-read!' benchmark.
Andy Wingo [Sun, 14 Sep 2008 22:04:34 +0000 (00:04 +0200)]
add special case for (apply values ...)
* libguile/vm-engine.c (vm_run): Move nvalues to the top level, to avoid
(spurious, it seems) gcc warnings about it being used uninitialized.
* libguile/vm-i-system.c (halt, return/values): Adapt to gcc silliness.
Deindent some of return/values.
(return/values*): New instruction, does what (apply values . args)
would do.
* module/language/scheme/translate.scm (custom-transformer-table): Move
the apply and @apply cases here from inline.scm, because we need some
more cleverness when dealing with cases like (apply values . args).
(lookup-apply-transformer): Define an eval transformer for `values',
turning it into ghil-values*.
* module/system/il/compile.scm (codegen): Compile <ghil-values*> into
return/values*.
* module/system/il/ghil.scm: Add <ghil-values*> and accessors.
(ghil-lookup): Add optional argument, define?, which if false tells us
not to actually cache the binding if it is not found in the toplevel.
* module/system/il/inline.scm: Remove apply clauses.
* module/system/vm/frame.scm (bootstrap-frame?): Update heuristic for
bootstrap-frame?, as the bootstrap frame is now 5 bytes since it
accepts multiple values.
Andy Wingo [Sun, 14 Sep 2008 15:06:52 +0000 (17:06 +0200)]
add multiple values support to the vm
* libguile/vm-engine.c (vm_run): The bootstrap program now uses mv_call,
so as to allow multiple values out of the VM. (It did before, because
multiple values were represented internally as single scm_values
objects, but now that values go on the stack, we need to note the boot
frame as accepting multiple values.)
(vm_error_no_values): New error, happens if you pass no values into a
single-value continuation. Passing more than one is OK though, it just
takes the first one.
* libguile/vm-i-system.c (halt): Assume that someone has pushed the
number of values onto the stack, and package up that number of values
as a scm_values() object, for communication with the interpreter.
(mv-call): New instruction, calls a procedure with a multiple-value
continuation, even handling calls out to the interpreter.
(return/values): New instruction, returns multiple values to the
continuation. If the continuation is single-valued, takes the first
value or errors if there are no values. Otherwise it returns to the
multiple-value return address, pushing the number of values on top of
the values.
* module/system/il/compile.scm (codegen): Compile <ghil-values> forms.
* module/system/il/ghil.scm (<ghil-values>) Add new GHIL data structure
and associated procedures.
* module/language/scheme/translate.scm (custom-transformer-table):
Compile (values .. ) forms into <ghil-values>.
Andy Wingo [Sun, 14 Sep 2008 12:26:29 +0000 (14:26 +0200)]
look up scheme translators by value, not by name
* module/language/scheme/translate.scm (custom-transformer-table): Rename
from `primitive-syntax-table', because now it will handle procedural
values as well.
(lookup-transformer): Update for renaming. Look up custom transformers
by value, not name.
(make-pmatch-transformers): Key the transformer table by value, not
name.
Ludovic Courtès [Sat, 13 Sep 2008 18:09:08 +0000 (20:09 +0200)]
Include <config.h> in standalone tests.
* test-suite/standalone/Makefile.am (test_cflags): Add `-I$(top_builddir)' so
that <config.h> can be found.
(snarfcppopts): Likewise.
* test-suite/standalone/*.c: Include <config.h>.
Andy Wingo [Sat, 13 Sep 2008 17:19:10 +0000 (19:19 +0200)]
rename tail-call to goto/args, add some more tail instructions
* libguile/vm-i-system.c (call): Rename continuation invocation from
`vm_call_cc' to `vm_call_continuation', because that's what it really
does. Add a note that it doesn't handle multiple values at the moment.
(goto/arg): Renamed from tail-call, in deference to the progenitors, on
Dale Smith's suggestion.
(goto/apply): New instruction, for `apply' in a tail context. Not yet
used, or vetted for that matter.
(call/cc): No need to pop the program, I don't think; although this
isn't tested either.
(goto/cc): New instruction, for call/cc in a tail context.
* module/language/scheme/translate.scm (*forbidden-primitives*): Rename
from %forbidden-primitives.
* module/system/il/compile.scm (codegen): Adapt to goto/args instead of
tail-call.
* module/system/il/inline.scm: Start inlining some macros used in
r4rs.scm -- not yet fully tested.
* ice-9/boot-9.scm: Allow load of a compiled r4rs file.
Andy Wingo [Sat, 13 Sep 2008 17:15:20 +0000 (19:15 +0200)]
add a multiple values return address to stack frames
* libguile/frames.c (frame-mv-return-address): New accessor.
* libguile/frames.h: Update frame diagram.
(SCM_FRAME_UPPER_ADDRESS): Update for data area
growing by one pointer.
(SCM_FRAME_MV_RETURN_ADDRESS): New macro.
* libguile/vm-engine.h (NEW_FRAME): Update for frame getting bigger by a
pointer. In a normal NEW_FRAME, set the MV return address to NULL, to
indicate that this continuation does not accept multiple values.
* libguile/vm-i-system.c (tail-call): Update frame replacement code to
understand the MV return address.
(return): Make room for the MVRA.
Andy Wingo [Sat, 13 Sep 2008 13:41:43 +0000 (15:41 +0200)]
inline frame replacement in tail-call
* libguile/programs.c (program_print): Only try to lookup write-program
if the module system is booted.
* libguile/vm-engine.h (FREE_FRAME): Remove, it's now inlined everywhere.
* libguile/vm-i-system.c (tail-call): Inline FREE_FRAME, and implement
the calling bits here. Will make things more hackable.
Ludovic Courtès [Sat, 13 Sep 2008 13:35:27 +0000 (15:35 +0200)]
Include <config.h> in all C files; use `#ifdef HAVE_CONFIG_H' rather than `#if'.
Andy Wingo [Sat, 13 Sep 2008 12:40:27 +0000 (14:40 +0200)]
inline FREE_FRAME in halt
* libguile/vm-i-system.c (halt): Inline FREE_FRAME, specialized for the
halt case.
Andy Wingo [Sat, 13 Sep 2008 12:30:57 +0000 (14:30 +0200)]
inline FREE_FRAME in return, sync stack_base in CACHE_REGISTER
* libguile/vm-engine.h (CACHE_REGISTER): Sync stack_base too.
* libguile/vm-i-system.c (return): Inline FREE_FRAME here,
micro-optimizing a wee bit. Sounds silly, but it's to enable some
refactoring.
Andy Wingo [Thu, 11 Sep 2008 17:30:15 +0000 (19:30 +0200)]
clean up NEW_FRAME macro
* libguile/vm-engine.h (NEW_FRAME): Clean up this macro.
Andy Wingo [Sat, 13 Sep 2008 12:14:20 +0000 (14:14 +0200)]
readability improvement in vm-i-scheme
* libguile/vm-engine.h:
* libguile/vm-i-scheme.c: Move some helper macros closer to their use
sites.
Andy Wingo [Sat, 13 Sep 2008 11:14:45 +0000 (13:14 +0200)]
tweaks for printing programs
* module/system/vm/program.scm (program-bindings-as-lambda-list): Handle
the bindings-is-null case too -- not sure how it comes about, though. A
thunk with no let, perhaps.
(write-program): Another default for the name: the source location at
which it was defined.
* libguile/programs.c (program_print): Add some "logic" to stop doing
detailed prints if one print had a nonlocal exit -- preventing
exceptions in backtraces.
Andy Wingo [Fri, 12 Sep 2008 21:14:46 +0000 (23:14 +0200)]
programs can now get at their names, and print nicely
* module/system/vm/frame.scm (frame-call-representation)
(frame-program-name): Rename program-name to frame-program-name, and
use the program-name if it is available.
* module/system/vm/program.scm (program-bindings): Return #f if there are
no bindings.
(program-name): New public procedure.
(program-bindings-as-lambda-list, write-program): A more useful writer
for programs.
* libguile/programs.c (scm_bootstrap_programs, program_print): Add a smob
printer for programs, which dispatches to `write-program'.
Andy Wingo [Fri, 12 Sep 2008 21:11:09 +0000 (23:11 +0200)]
(define (foo ...) ...) actually gives the lambda a name
* module/language/scheme/translate.scm (primitive-syntax-table): In forms
like (define x y) where y is a lambda, and the lambda has no name yet,
set the lambda's name in its metadata.
Andy Wingo [Fri, 12 Sep 2008 21:09:45 +0000 (23:09 +0200)]
fix confusion in disassemble-bindings
* module/system/vm/disasm.scm (disassemble-bindings): Fix external/local
confusion when printing args and locals.
Andy Wingo [Sat, 13 Sep 2008 12:13:13 +0000 (14:13 +0200)]
fix *another* bug in compiling `or'. incredible.
* module/system/il/compile.scm (codegen): Fix *another* bug in compiling
`or' -- in the case in which the value was being discarded, as in `or'
used as a control structure, we were sometimes leaving a value on the
stack.
* testsuite/t-or.scm: Add another test case for `or'.
Ludovic Courtès [Fri, 12 Sep 2008 19:46:32 +0000 (21:46 +0200)]
Add `ChangeLog-2008' files to the distribution.
Ludovic Courtès [Fri, 12 Sep 2008 19:48:04 +0000 (21:48 +0200)]
Rename `ChangeLog' files to `ChangeLog-2008'.
Andy Wingo [Fri, 12 Sep 2008 15:59:59 +0000 (17:59 +0200)]
untabify process-define-module
* ice-9/boot-9.scm (process-define-module): Untabify.
Andy Wingo [Fri, 12 Sep 2008 15:55:33 +0000 (17:55 +0200)]
correctly disassemble program bindings (arguments, locals, externals)
* module/system/vm/disasm.scm (disassemble-bindings): New function,
properly disassembles the bindings data. Neat!
Ludovic Courtès [Fri, 12 Sep 2008 09:30:04 +0000 (11:30 +0200)]
doc: Correct the default value of `%load-path'.
* doc/ref/api-options.texi (Build Config): Remove "." from the default value
of `%load-path'. Reported by David Séverin <david@altosw.be>.