* benchmark/lib.scm: Add a comment, update the loop disassembly. Loop is
now faster in the VM, thankfully.
* src/vm_engine.h (CACHE_PROGRAM): Only release and regrab the object
array handle if the program changed. That is to say, optimize the
self-tail-recursive case. But perhaps the thing to optimize here are
the procedure calls themselves. Worth looking at in the future.
* module/system/il/inline.scm: New module, implements generic inlining of
scheme functions. It even does the right thing regarding (define
arity:nopt caddr) and such. So now there are many more inlines: the
arithmetics, `apply', the caddr family, etc. This makes the benchmarks
*much* faster.
* module/language/scheme/translate.scm (trans): Remove the
%scheme-primitives code in favor of the generic (scheme il inline)
code. Adds inlining for +, -, =, etc.
* src/vm.c (vm_puts): Fix to work.
* module/system/base/compile.scm (system): Export load/compile also.
* module/system/il/compile.scm (optimize): Further debitrotting, but I
haven't tried this function yet. It seems that <ghil-inst> was what
<ghil-inline> is.
* module/system/il/ghil.scm (*core-primitives*, *macro-module*)
(ghil-primitive-macro?, ghil-macro-expander, ghil-primitive?): Remove
these unused things.
* module/system/il/macros.scm: Removed, replaced with inline.scm.
* module/system/vm/assemble.scm (stack->bytes): Before, the final
serialization code did an (apply u8vector (apply append (map
u8vector->list ...))). Aside from the misspelling of append-map, this
ends up pushing all elements of the u8vector on the stack -- assuredly
not what you want. But besides even that, I think that pushing more
than 32k arguments on the stack brings out some other bug that I think
was hidden before, because now we actually use the `apply' VM
instruction. Further testing is needed here, I think. Fixed the code to
be more efficient, which fixes the manifestation of this particular
bug: a failure to self-compile after inlining was enabled.
* module/system/vm/bootstrap.scm: New module, serves to bootstrap
boot-9's `load-compiled'. That way when we load (system vm core), we're
loading compiled code already.
* module/system/vm/core.scm: Use (system vm bootstrap).
* src/guilec.in: Use the bootstrap code, so that we really are compiling
with an entirely compiled compiler.
* module/system/repl/repl.scm (default-catch-handler): An attempt at
making the repl print a backtrace; more work needed here.
* module/system/vm/frame.scm (make-frame-chain): Fix some misspellings --
I think, anyway.
* guilec.mk: New file, to be included when building .go files.
* module/language/scheme/Makefile.am:
* module/system/base/Makefile.am:
* module/system/il/Makefile.am:
* module/system/repl/Makefile.am:
* module/system/vm/Makefile.am: Use guilec.mk.
* module/system/base/compile.scm (compiled-file-name): Work on the
basename of a file, so that we always create files in the directory
where we run. Perhaps should add a -o option to guilec in the future.
* Makefile.am: Actually recurse into module/ in a normal build.
* acconfig.h: Removed.
* acinclude.m4: Use the extended AC_DEFINE for HAVE_LABELS_AS_VALUES, so
as to remove the need for acconfig.h.
* autogen.sh: Use autoreconf.
* configure.in: Update info, don't warn about non-gnu make, bump version
to 0.7.
* doc/texinfo.tex: Automagically updated. (Should this be in VCS?)
* src/Makefile.am: Add $(DEFAULT_INCLUDES) to a couple of our custom
rules so we pick up the -I for config.h.
* src/*.[ch]: Include the config.h in the C files, not in the headers.
* module/language/scheme/translate.scm (*the-compile-toplevel-symbol*):
Reset to compile-toplevel, which requires a patch to guile.
* module/system/base/compile.scm (compile-file): Some foo so that we load
up the scheme language before call-with-output-file. Fixes compilation
of (language scheme) modules.
* module/system/base/language.scm (define-language): Don't unquote in
make-language; refer to it by name instead, and export it.
* module/system/repl/Makefile.am (vm_DATA): Don't compile describe.scm,
because we really can't deal with goops yet.
* module/system/repl/repl.scm (compile-toplevel): If we're compiling, put
in a stub definition of start-stack, which is closely tied to the
interpreter.
* src/vm_loader.c (load-program): Fix a very tricky corruption bug!
* module/system/repl/describe.scm (format-documentation): Remove bad
string syntax. This file doesn't compile though, due to define-macro
being a procedure->syntax macro.
* module/language/scheme/translate.scm (lookup-transformer): Allow for
undefined variables when doing the transformation -- it's possible that
they come from a module definition's forward declaration.
* module/system/repl/command.scm (import): Make into legal Scheme, caught
by the compiler :-)
* module/system/vm/assemble.scm (<vlink-now>): Remove the module field.
Immediate bindings will now always be relative to the current module.
Fixes some mess about process-define-module not being defined when
loading modules, probably because we destructively modified the
ghil-env.
(codegen, dump-object!): Don't dump a module name.
* src/vm_loader.c (link-now): Just use scm_lookup.
comments in ghil-lookup are pertinent.
* module/system/il/compile.scm (make-glil-var): Require that ghil vars
have environments. Remove the 'unresolved case -- we'll treat all
module-level variables as late bound.
* module/system/il/ghil.scm (ghil-lookup): Treat all module level vars as
late bound.
* module/system/vm/assemble.scm: Instead of vlink and vlate-bound, have
vlink-now and vlink-later.
(codegen): Add a bunch of crap to get the various cases right.
(object-assoc, dump-object!): Handle the new cases, remove the old
cases.
* src/vm_loader.c (link-now, link-later): Change from link and lazy-bind.
Include the module in which the link is to be done, so that callers
from other modules get the right behavior.
* src/vm_system.c (late-variable-ref, late-variable-set): Instead of a
sym, the unbound representation is a module name / symbol pair.
* testsuite/run-vm-tests.scm (run-vm-tests): Remove some debugging.
Fixes the mutually-recursive toplevel definitions case. This could be
fixed by rewriting bodies as letrecs, as r6 does, but that's not really
repl-compatible.
* module/system/il/ghil.scm (ghil-lookup): Ok, if we can't locate a
variable, mark it as unresolved.
* module/system/il/compile.scm (make-glil-var): Compile unresolved
variables as <glil-late-bound> objects.
* module/system/il/glil.scm: Add <glil-late-bound> definition.
* module/system/vm/assemble.scm (codegen): And, finally, when we see a
<vlate-bound> object, allocate a slot for it in the object vector,
setting it to a symbol. Add a new pair of instructions to resolve that
symbol to a variable at the last minute.
* src/vm_loader.c (load-number): Bugfix: the radix argument should be
SCM_UNDEFINED in order to default to 10.
(late-bind): Add an unresolved symbol to the object vector. Could be
replaced with load-symbol I guess.
* src/vm_system.c (late-variable-ref, late-variable-set): New
instructions to do late symbol binding.
* testsuite/Makefile.am (vm_test_files):
* testsuite/t-mutual-toplevel-defines.scm: New test, failing for some
reason involving the core even? and odd? definitions.
* module/language/scheme/translate.scm (lookup-transformer): When
expanding syncase macros, use the eval closure from the ghil-env.
Probably doesn't make any difference whatsoever.
* module/system/base/Makefile.am (SOURCES): Compile pmatch.scm, now that
it works :-))
* module/system/base/compile.scm (compile-in): Compile inside a
save-module-excursion, so that side effects of evaluation don't leak
out.
* module/system/base/pmatch.scm: Change from :use-syntax/:export-syntax
to simply :use-modules/:export. Also probably has no effect.
* module/system/il/ghil.scm (fix-ghil-mod!): Suppress warnings resulting
from compilation of define-module.
* src/vm_loader.c (link): So, referencing variables defined but not
exported from the current module didn't work. Fixed that, but it's
hacky. There are still some uncaught cases.
* module/system/base/compile.scm: Also import load-objcode from (system
vm core).
* module/language/scheme/translate.scm (lookup-transformer): Use
sc-expand3 in compilation mode when compiling macros. Yay, syncase
macros compile!
* module/system/vm/assemble.scm (dump-object!):
* src/vm_loader.c (VM_DEFINE_LOADER): Use scm_from_locale_keywordn, not
the krazy dash symbol stuff.
* module/language/scheme/translate.scm (lookup-transformer): Add a
special case for syncase macros.
* module/system/base/syntax.scm (define-record): Again, don't unquote in
actual objects, because this is uncompilable. Ah well. At least now all
of base/ is compiling.
* module/system/vm/assemble.scm (dump-object!): More debug info.
* module/language/scheme/translate.scm (primitive-syntax-table):
Translate the `else' clause of a cond as (begin ...). We used to use
trans-body, which processes internal defines, which are not legal
syntax here.
* module/system/base/syntax.scm (define-record): Unfortunately, we can't
unquote in the actual procedure for `%compute-initargs', because that
doesn't work with compilation. So reference %compute-initargs by name,
and export it.
* module/system/il/ghil.scm (apopq!): Gaaaaar. The order of the arguments
to assq-remove! was reversed, which was the badness, causing corruption
to the env after calling call-with-ghil-bindings. Grrrrrr.
(fix-ghil-mod!, ghil-lookup, ghil-define): As amply commented in the
code, deal with compile-time side effects to the current module by
lazily noticing and patching up the compile-time environment. A hacky
solution until such a time as we special-case something for
`define-module'.
* module/system/il/compile.scm (make-glil-var): Only dump the module if
we actually have one.
* module/system/il/ghil.scm (ghil-define): Make sure that ghil-var-env is
a ghil-env.
* src/vm_loader.c (link):
* module/system/vm/assemble.scm (dump-object!): Rewrite `link' to take
two Scheme arguments on the stack: the symbol, as before, and the
module in which the symbol was found at compile time. This introduces
some undesireable early binding, but it does let the vm load up
modules, and (potentially) have multiple modules in one .go file. On a
practical level, I can now compile modules and have their .go files
load up the modules' dependencies as necessary.
* module/system/il/compile.scm (make-glil-var): Make the :mod of the
glil-var actually a guile module, not a ghil-env.
* module/system/il/ghil.scm (module-lookup, ghil-lookup): For module
variables, encode the location where we found the variable in the
ghil-var.
* module/language/scheme/translate.scm (trans):
* module/system/il/compile.scm (codegen): When making records where a
value can be a keyword, make sure to use the keyword initialization
form, so that the record initializer doesn't interpret the keyword as a
slot name.
* module/system/base/Makefile.am (vm_DATA): For now, don't compile
pmatch.
* module/language/scheme/translate.scm (*the-compile-toplevel-symbol*)
(primitive-syntax-table): Existing eval-case invocations in boot-9.scm
only have `load-toplevel', not `load-toplevel' and `compile-toplevel'
as they should. Allow for interpreting `load-toplevel' as
`compile-toplevel'.
* module/language/scheme/translate.scm (trans): Remove the hacky case for
the unspecified value, not needed any more.
(primitive-syntax-table): Rework eval-case to understand
compile-toplevel and evaluate contexts, as in common lisp's eval-when:
http://www.lisp.org/HyperSpec/Body/speope_eval-when.html
This is the Right Thing.
* testsuite/t-match.scm:
* testsuite/t-records.scm: While the attempt to redefine use-syntax as
being "use during compilation" was cute, it does not reflect the
historical usage of use-syntax, nor does it correspond to existing code
that includes other modules and uses them during compilation.
So use-syntax has been replaced with use-modules. The test suites now
pass. In the future, compilation phases should be done on whole
modules, I think; r5rs-style computation does not have phases.
* module/language/scheme/translate.scm (eval-at-compile-time)
(&compile-time-module, expand-macro): Remove this attempt at dealing
with macros. Instead, we're going to rely on macros being first-class,
and just catch eval-case at the bottom.
(lookup-transformer): Lookup all syntax transformers in the module's
eval closure. We catch the primitive-macros, compiling them to ghil,
and expand the rest.
(lookup-transformer): Fold in trans-pair here. Add a hacky case for the
unspecified value; the problem shows up when compiling e.g.
(define-macro (plus! x) `(set! ,x (1+ x))), as a fallout from
eval-case.
(make-pmatch-transformers, primitive-syntax-table): Define the
primitive syntax transformers as a data-driven table instead of a
function. There's a bit of syntax, too. Eval-case was rewritten to use
pmatch.
* module/system/base/compile.scm (scheme): Define as a thunk instead
of a value, so as to allow (language scheme translate) to be imported
in the repl. Still, a hack.
* module/language/scheme/translate.scm (expand-macro, trans-pair): Remove
support for the scheme form, '(void). Replace it by (begin). What was
Keisuke thinking? :)
* Makefile.am:
* module/Makefile.am:
* module/language/scheme/Makefile.am:
* module/system/Makefile.am:
* module/system/base/Makefile.am:
* module/system/il/Makefile.am:
* module/system/repl/Makefile.am:
* module/system/vm/Makefile.am: Cleaned up to be more complete, if not
completely working.
* module/guile/slib.scm:
* module/slib/: Removed the slib import; it's a bit out of place here,
and bitrotten at that.
* module/system/repl/repl.scm (default-pre-unwind-handler)
(default-catch-handler): New procedures, to do some error handling in
the repl.
(start-repl): Catch errors in the repl loop.
* module/system/base/compile.scm (<cenv>): No more cenv, it was a useless
data structure.
* module/system/repl/command.scm (*command-table*): Remove `use', it's
the same as `import'. Otherwise in this file, adapt to the repl having
direct pointers to the vm and the language, and to the module being in
the current-module fluid.
* module/system/repl/repl.scm (prompting-meta-read):
* module/system/repl/common.scm (<repl>): The repl now has a direct
pointer to the vm and language. Adapt accordingly.
Before:
> ,c (set! x 3)
0 (make-int8 3) ;; 3
2 (link "x")
5 (variable-set)
> ,c (define x 3)
0 (make-int8 3) ;; 3
2 (link "x")
5 (variable-set)
After:
> ,c (define x 3)
0 (make-int8 3) ;; 3
2 (define "x")
5 (variable-set)
* src/vm_loader.c (link): `link' now errors if the variable is undefined.
This corresponds with desired behavior, for both `ref' and `set'
operations, for scheme. It's not what elisp wants, though. Perhaps
elisp linking needs another instruction.
(define): New instruction, the same as calling scm_define(), basically.
* module/language/scheme/translate.scm (trans-pair): Don't try to look up
an existing variable definition when translating `define'; instead use
the special-purpose lookup from ghil.scm's `ghil-define'.
* module/system/il/compile.scm (codegen): Compile to a different kind of
variable access from `set!', specifically via passing 'define as the op
to `make-glil-var'.
* module/system/il/ghil.scm (ghil-lookup): Don't add to the module table
when compiling variable sets via `set!'.
(ghil-define): New procedure, for looking up variables for `define'.
* module/system/vm/assemble.scm (<vdefine>): New record: a new
instruction type.
(codegen): Compile `define' module vars into <vdefine>.
(dump-object!): <vdefine> == `define'.
* module/language/scheme/translate.scm (trans-pair): Add a guard to only
allow `define' at the top level; other defines are already filtered out
via trans-body.
* module/system/il/ghil.scm (ghil-env-toplevel?): Export, and fix.
* module/system/base/compile.scm:
* module/system/il/ghil.scm:
* module/system/repl/describe.scm:
* module/system/vm/core.scm:
* module/system/vm/frame.scm:
* module/system/vm/trace.scm: Explicitly list exports in the module
declaration instead of using define-public.
* module/system/base/compile.scm: Export cenv? also.
* module/system/base/syntax.scm: Clean up vestiges of the old structure
code. Make accessors defined as foo? instead of <foo>?.
* module/system/il/glil.scm:
* module/system/il/ghil.scm: Remove <foo>-1 accessors, since we have
named accessors.
* module/system/repl/common.scm (repl-prompt): Return a string instead of
outputting to the port, for better readline integration.
* module/system/repl/repl.scm (meta-reader, prompting-meta-read)
(start-repl): Integrate with (ice-9 readline) via the current-reader
fluid and the repl-reader function, both from boot-9.scm.
* module/system/repl/command.scm (system): Declare exports in the module
declaration.
* module/system/repl/repl.scm (start-repl): If the evaluation returns
multiple values, print them separately.
* module/system/base/syntax.scm (define-record): Rebase to implement on
top of Guile's records, which are the substrate of srfi-9's records.
(%compute-initargs): Rename from %make-struct, just return the list of
values.
(get-slot, set-slot!, slot): Removed, no longer used.
(record-case): Allow slots of the form (MYNAME SLOTNAME), which binds
SLOTNAME to MYNAME (instead of SLOTNAME to SLOTNAME).
(record-case, record?): No more ice-9 match!
* module/system/il/compile.scm (codegen): Tweaks so that the new record
code works.
* module/system/il/ghil.scm: Fix some slot references.
* module/system/vm/assemble.scm (preprocess, codegen): Remove calls to
`slot'.
(codegen): Fix some slot references.