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.
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.
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.
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'.
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!
Andy Wingo [Tue, 9 Sep 2008 06:33:53 +0000 (08:33 +0200)]
really newline on eof
* module/system/repl/repl.scm (next-char): Another newline-on-eof case.
Andy Wingo [Tue, 9 Sep 2008 06:27:49 +0000 (08:27 +0200)]
fix program disassembly for meta-in-a-thunk
* module/system/vm/disasm.scm (disassemble-program): Fix for recent
meta-in-a-thunk change.
Andy Wingo [Tue, 9 Sep 2008 06:23:10 +0000 (08:23 +0200)]
run the vm repl instead of the scm-style-repl
* ice-9/boot-9.scm (@, @@): Note that these don't work with the compiler.
Damn.
(top-repl): Run the VM repl. Whooo!
* module/system/repl/repl.scm (start-repl): Catch 'quit, as the
scm-style-repl does. Newline after input EOF's, so that we don't leave
the user's shell messed up.
Andy Wingo [Tue, 9 Sep 2008 05:54:23 +0000 (07:54 +0200)]
add repl option to interpret rather than compile
* module/language/scheme/spec.scm (scheme): Specify an evaluator, `eval'.
* module/system/repl/common.scm (repl-default-options): Add option,
`interp', specifying that, if possible, the repl should interpret its
expressions rather than compile them. Defaults to #f.
Andy Wingo [Tue, 9 Sep 2008 05:15:01 +0000 (07:15 +0200)]
rework late binding resolution to be simpler and more efficient
* libguile/programs.h (struct scm_program):
* libguile/programs.c (scm_c_make_program): Record the current module
when making a program. This replaces the per-late binding recorded
module in the generated code, which should be more efficient, both in
terms of garbage, and in not calling resolve-module.
(program-module): New accessor.
* module/system/vm/program.scm: Add program-module to exports.
* libguile/vm-i-loader.c (link-later): Remove this instruction, since now
the entry in the object table is just a symbol, and can be loaded with
load-symbol.
* libguile/vm-i-system.c (late-variable-ref, late-variable-set): Rework
so as to look up in the module of the current program. The logic could
be condensed quite a bit if scm_module_lookup () knew what to do with
mod==#f.
* module/system/vm/assemble.scm (dump-object!): Dump <vlink-later> just
as load-symbol, as mentioned in the note on link-later.
* module/system/il/ghil.scm: Update comment to reflect the new reality.
Andy Wingo [Tue, 9 Sep 2008 05:13:14 +0000 (07:13 +0200)]
final de-:prefixification
* scripts/compile: Don't (read-set! keywords 'prefix) here either.
Andy Wingo [Tue, 9 Sep 2008 04:56:06 +0000 (06:56 +0200)]
use #:keywords in module/*.scm, not :keywords
* module/system/base/syntax.scm (keywords): Don't enable :keywords, it
breaks code that may assume that ':foo is a symbol, like boot-9.
* module/*.scm: Don't use :keywords, use #:keywords. The user can decide
if she wants #:keywords in their .guile, and :keywords might make us
compile modules differently.
Andy Wingo [Sun, 7 Sep 2008 23:03:34 +0000 (01:03 +0200)]
lazily load meta info, for less consage
* module/system/vm/assemble.scm (make-meta, codegen): Hide the "meta"
information -- the names of the bindings, source info, procedure
properties, etc -- behind a lambda. This way, loading up a program
conses less, because the metadata stays as mmap'd code until it is
needed.
* libguile/vm-i-loader.c (load-program): Adjust load-program to expect
the metadata to be a program.
* module/system/vm/program.scm (program-bindings, program-sources)
(program-properties): Adjust to new meta format.
Andy Wingo [Sun, 7 Sep 2008 21:17:58 +0000 (23:17 +0200)]
compile boot-9. woop!
* ice-9/Makefile.am (SOURCES, NOCOMP_SOURCES): Compile boot-9.scm.
Wooooo! This makes some things harder to debug, and program loading
needs to cons much less, but I think it makes sense to compile boot-9
by default if for no other reason than to catch bugs earlier.
Andy Wingo [Sun, 7 Sep 2008 21:13:52 +0000 (23:13 +0200)]
macro-transformer recognizes compiled macros
* libguile/macros.c (macro-transformer): Recognize compiled as well as
interpreted transformer procedures.
Andy Wingo [Wed, 3 Sep 2008 05:24:11 +0000 (22:24 -0700)]
print compiled macros correctly
* libguile/macros.c (macro_print): Print macros whose code is a program
as non-primitive. (Already, primitive-macro? would return #f.)
Andy Wingo [Tue, 2 Sep 2008 16:33:25 +0000 (09:33 -0700)]
allow boot-9.go load if available
* libguile/init.c (scm_load_startup_files): Don't specify the .scm
suffix, so as to allow loading a boot-9.go if appropriate.
Andy Wingo [Tue, 2 Sep 2008 16:32:31 +0000 (09:32 -0700)]
remove define-syntax-macro from boot-9.scm
* ice-9/boot-9.scm (defmacro:syntax-transformer, define-syntax-macro):
Removed these, as I could not see anywhere they were being used, and
they use the unnecessary procedure->syntax procedure.
Andy Wingo [Tue, 2 Sep 2008 07:51:54 +0000 (00:51 -0700)]
take procedure->memoizing-macro off of probation
* module/language/scheme/translate.scm (%forbidden-primitives): Take
procedure->memoizing-macro off probation; although it's not a good
idea, there is a fair amount of existing code that uses it that can be
compiled fine. So allow it in that case.
Andy Wingo [Tue, 2 Sep 2008 07:49:50 +0000 (00:49 -0700)]
make thunk? understand programs
* libguile/procs.c (thunk?): Return #t for thunk programs.
Andy Wingo [Tue, 2 Sep 2008 07:42:39 +0000 (00:42 -0700)]
reorder module system boot time
* ice-9/boot-9.scm: Postpone module system boot until (%app modules) is
defined, so that resolve-module will work. This might not actually be
necessary given the previous tomfoolery in resolve-module, but it
doesn't seem like a bad change.
Andy Wingo [Tue, 2 Sep 2008 07:49:17 +0000 (00:49 -0700)]
module-variable accesses pre-module-obarray if module is #f
* libguile/modules.c (module-variable): If module is #f, access the
pre-modules-array. This is so that nested-ref can work before the
module system is booted, I think.
Of course all of these dependency lines during bootstrap are just to
make sure the system can be booted properly, either interpreted or
compiled, so there's no one right way: there are many ways that could
work.
Andy Wingo [Tue, 2 Sep 2008 07:40:57 +0000 (00:40 -0700)]
prevent (resolve-module '(guile)) recursion
* ice-9/boot-9.scm (resolve-module): Change so that resolving '(guile)
does not require any module lookups. This is so that while within a
call to (resolve-module '(guile)), we don't recurse when looking up the
location for e.g. `append'. I can imagine other ways to get around
this, but this one seems OK.
Andy Wingo [Tue, 2 Sep 2008 07:33:31 +0000 (00:33 -0700)]
make late-variable-{ref,set} work before module system boot
* libguile/vm-i-system.c (late-variable-ref, late-variable-set): If the
module system isn't booted, do a simple scm_lookup. In the -ref case,
actually cache the variable location (doh!).
Andy Wingo [Tue, 2 Sep 2008 07:21:10 +0000 (00:21 -0700)]
better diagnostics on quasiquote errors
* module/system/il/compile.scm (constant?, codegen): Add some diagnostics
so that we can get decent error reporting if we accidentally unquote an
unreadable value into the compiled output.
Andy Wingo [Sun, 7 Sep 2008 20:27:08 +0000 (22:27 +0200)]
allow multiple modules in one compilation unit
* module/system/il/ghil.scm (<ghil-env>, <ghil-toplevel-env>): Refactor
so that all environments point (eventually) at one toplevel
environment. Instead of having potentially multiple toplevel
environments, each noting the module against which its bindings are
resolved, have each binding in the toplevel record what module it
should be resolved in. Should fix compilation units that define
multiple modules.
(ghil-lookup, ghil-define): Reworked to not be destructive. Module
variables now have the module name as their "env", and are keyed as
`(MODNAME . SYM)' in the var table.
(call-with-ghil-environment): Reindented.
* module/system/il/inline.scm (try-inline-with-env): Adapt to
env/toplevel changes.
* module/system/vm/assemble.scm (dump-object!): A vlink-later now holds
the module name, not the module itself.
* module/system/il/compile.scm (make-glil-var): The "env" of a "module"
var is now the module name, not the module.
* module/language/scheme/translate.scm (primitive-syntax-table): Update
the way we test for toplevel environments. Reindent the lambda
translator.
(lookup-transformer, trans): lookup-transformer now has 2 args, not 3.
(translate): Update the way we make toplevel environments.
Andy Wingo [Sun, 7 Sep 2008 20:15:25 +0000 (22:15 +0200)]
improve backtraces
* module/system/vm/frame.scm (frame-call-representation): Show more of
lists.
(program-name): Avoid a traceback if (frame-address link) is #f. Not
sure when this can happen, but it does, and since this is already in
the backtrace function, there be badness there.
Andy Wingo [Sun, 7 Sep 2008 20:14:18 +0000 (22:14 +0200)]
update .gitignore files
* .gitignore:
* libguile/.gitignore: Update
Andy Wingo [Tue, 2 Sep 2008 07:15:26 +0000 (00:15 -0700)]
superstition with no important effect
* module/system/vm/assemble.scm (dump-object!): Some superstition, use
bit arithmetic instead of int arithmetic. Makes me happier.
Andy Wingo [Tue, 2 Sep 2008 07:08:26 +0000 (00:08 -0700)]
make primitive-load-path load compiled files if available
* libguile/load.h: Update scm_search_path prototype.
* libguile/load.c: Include vm.h for load-compiled/vm. Not sure if this is
bad wrt modularity.
(scm_c_string_has_an_ext): New private helper.
(scm_search_path): Add an extra optional arg, `require_exts'; if true,
require that the returned file name have one of the given extensions.
Changes the C API, but not the scheme API.
(scm_sys_search_load_path): Adapt to scm_search_path API change.
(primitive-load-path): Here is the craziness: load a compiled file if
found and newer than the corresponding (or not) source file.
(scm_init_load): Define %load-compiled-extensions as the list of
extensions denoting compiled files; defaults to '(".go").
Andy Wingo [Tue, 2 Sep 2008 07:27:59 +0000 (00:27 -0700)]
move up some initializations in the vm
* libguile/vm.c: Move 'vm-run, 'vm-error, 'debug sym initialization up to
the bootstrap phase, so they are ready if load-compiled/vm is called
before (system vm vm) is loaded.
Andy Wingo [Tue, 2 Sep 2008 06:51:30 +0000 (23:51 -0700)]
turn define-option-interface into a defmacro
* ice-9/boot-9.scm (define-option-interface): Turn into a defmacro
instead of an mmacro.
Andy Wingo [Tue, 2 Sep 2008 06:48:10 +0000 (23:48 -0700)]
disable start-stack in compiled code
* module/language/scheme/translate.scm (primitive-syntax-table): Disable
semantics of start-stack in compiled code. I think start-stack
semantics aren't bad, but they don't have vm-based implementations at
this point.
Andy Wingo [Tue, 2 Sep 2008 06:45:20 +0000 (23:45 -0700)]
remove the-environment, the-root-environment, environment-module
* ice-9/boot-9.scm (the-environment, the-root-environment)
(environment-module): Remove these representation of the interpreter's
idea of the environment, because they are not valid in the compiled
case, and are not part of the scheme spec anyway.
Andy Wingo [Tue, 2 Sep 2008 06:43:38 +0000 (23:43 -0700)]
avoid local-eval in record constructors and accessors
* ice-9/boot-9.scm (record-constructor, record-accessor)
(record-modifier): Avoid local-eval when possible, because it uses the
interpreter's representation of environments; and when we need to eval,
use primitive-eval instead. Slight semantic change in that this
evaluates relative to the current module rather than the root module,
but not really a biggie. Should make this compilable in the future,
somehow.
Andy Wingo [Tue, 2 Sep 2008 06:40:10 +0000 (23:40 -0700)]
nits picked on boot-9.scm
* ice-9/boot-9.scm (defmacro): Indentation fix.
(begin-deprecated): Don't cons in the `begin' macro itself, only the
symbol `begin'.
Andy Wingo [Tue, 2 Sep 2008 06:37:15 +0000 (23:37 -0700)]
enter into the (guile) module when compiling boot-9.scm
* ice-9/boot-9.scm: Before doing very much, put us into the (guile)
module when compiling. This avoids some circularity in the module boot
process, whereby symbols are seen to resolve to the (guile-user)
module, whereas in fact they originally pertain to the (guile) module.
Andy Wingo [Tue, 2 Sep 2008 06:54:15 +0000 (23:54 -0700)]
Fix compilation #ifndef STACK_CHECKING.
* libguile/debug.c (scm_debug_options): Fix compilation #ifndef
STACK_CHECKING.
Andy Wingo [Tue, 2 Sep 2008 07:36:21 +0000 (00:36 -0700)]
fix Makefile.am in module/language
* module/language/Makefile.am: Actually recurse into scheme/.
Andy Wingo [Tue, 2 Sep 2008 17:23:05 +0000 (10:23 -0700)]
ditch the 8-bit compiled form of program parameters
* libguile/vm-i-loader.c (load-program):
* module/system/vm/assemble.scm (dump-object!): There are cases in which
we use the 16-bit representation for program params (nargs, nexts,
etc), but the actual 16-bit number actually fits into 8 bits -- which
is then misinterpreted by the loader as the 8-bit form. So ditch the
8-bit form entirely (it was never much of an optimization), and just
use the 16-bit form. Make sure to clear out all your .go files before
recompiling this one!
Andy Wingo [Tue, 2 Sep 2008 07:13:08 +0000 (00:13 -0700)]
fix a bug loading functions with 8 or more arguments
* libguile/vm-i-loader.c: A combination of superstition and a bugfix:
make sure that we treat bits as being of a type as wide as we think it
is, and, more importantly, allow for programs with 8 <= nargs < 16.
Andy Wingo [Tue, 2 Sep 2008 07:23:10 +0000 (00:23 -0700)]
fix nested quasiquotes (yeepers)
* module/language/scheme/translate.scm (primitive-syntax-table)
(trans-quasiquote): Fix handling of nested quasiquotes.
* testsuite/Makefile.am (vm_test_files):
* testsuite/t-quasiquote.scm: Add a quasiquote test case.
Andy Wingo [Thu, 28 Aug 2008 00:19:41 +0000 (17:19 -0700)]
shamefully disable some more gc asserts
* libguile/gc-freelist.c: Disable some more asserts. I have no idea why
they're hitting, however.
Andy Wingo [Thu, 28 Aug 2008 00:17:30 +0000 (17:17 -0700)]
move guilec and guile-disasm to be guile-tools scripts
* .gitignore: Some touchups.
* configure.in:
* src/.cvsignore:
* src/Makefile.am:
* Makefile.am: No more src/.
* scripts/compile:
* scripts/disassemble: Moved here from src/ and changed into guile-tools
scripts.
* scripts/Makefile.am: Add the new scriptes.
* guilec.mk: Adapt to new way of invoking the compiler.
Andy Wingo [Tue, 26 Aug 2008 20:55:05 +0000 (13:55 -0700)]
fix guile-disasm
* src/guile-disasm.in: Adapt to the split-up of (system vm core).
Detabify.
Patch by C. K. Jester-Young <cky944 <at> gmail.com>.
Andy Wingo [Tue, 26 Aug 2008 20:52:20 +0000 (13:52 -0700)]
m4 quoting foo in labels-as-values.m4.
* m4/labels-as-values.m4: More m4 quoting love.
Patch from C. K. Jester-Young <cky944 <at> gmail.com>.
Andy Wingo [Tue, 26 Aug 2008 20:43:17 +0000 (13:43 -0700)]
fix casting-pointers-to-ints bug
* libguile/vm.c: Cast pointers to intptr_t, not int.
Patch from C. K. Jester-Young <cky944 <at> gmail.com>.
Andy Wingo [Tue, 26 Aug 2008 20:40:07 +0000 (13:40 -0700)]
fetch an inum's bits into a scm_bits_t, not an int
* libguile/vm-i-scheme.c (FUNC1): Remove, cause it's not used.
(FUNC2): Don't assume an inum can fit into an int, use scm_bits_t
instead. In reality though we should probably do use different checks,
i.e. for multiplication probably we overflow. (That would be a bug.)
Based on a patch by C. K. Jester-Young <cky944 <at> gmail.com>.
Andy Wingo [Tue, 26 Aug 2008 20:33:55 +0000 (13:33 -0700)]
suppress autoconf warning
* guile-tools.in: Suppress ``WARNING: $ac_file_inputs seems to ignore the
--datarootdir setting'' message.
Patch from C. K. Jester-Young <cky944 <at> gmail.com>
Andy Wingo [Tue, 26 Aug 2008 20:29:55 +0000 (13:29 -0700)]
disable gc statistics asserts
* libguile/gc.c: Disable the statistics asserts; see
http://thread.gmane.org/gmane.lisp.guile.devel/7505
Andy Wingo [Tue, 26 Aug 2008 19:51:19 +0000 (12:51 -0700)]
merge from guile master
Had to fix up .gitignore for some conflicts.
Andy Wingo [Tue, 26 Aug 2008 19:40:25 +0000 (12:40 -0700)]
start compiling ice-9
* ice-9/Makefile.am: Integrate with guilec.mk, and start compiling
sources. Have to figure out what to do with procedure->memoized-macro
though, to get boot-9.scm compiling.
Ludovic Courtès [Mon, 25 Aug 2008 09:20:02 +0000 (11:20 +0200)]
Use $(GCC_CFLAGS) for `-Werror' et al. so that it's not used to compile
Gnulib code.
Andy Wingo [Mon, 25 Aug 2008 20:05:16 +0000 (13:05 -0700)]
module compilation fixen, post-integration
Thanks to Dale Smith.
* guilec.mk: Rework to expect the includer to define $(modpath), then
make $(moddir) from that.
* module/language/Makefile.am:
* 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: Define modpath instead.
* src/guilec.in: Don't import (system vm bootstrap), it is no more.
Han-Wen Nienhuys [Fri, 22 Aug 2008 02:21:57 +0000 (23:21 -0300)]
Fix 2 indentation nitpicks.
Han-Wen Nienhuys [Fri, 22 Aug 2008 02:16:20 +0000 (23:16 -0300)]
Style nitpicks: space before () in function call.
Andy Wingo [Fri, 22 Aug 2008 01:39:30 +0000 (18:39 -0700)]
merge guile-vm into libguile itself
* ice-9/boot-9.scm: Only define load-compiled as #f if it's not already
defined, which won't normally be the case.
* libguile/guile-vm.c: Removed, there's no more guile-vm binary.
* libguile/frames.c: (with change frame? -> heap-frame?)
* libguile/frames.h:
* libguile/instructions.c:
* libguile/instructions.h:
* libguile/objcodes.c:
* libguile/objcodes.h:
* libguile/programs.c:
* libguile/programs.h:
* libguile/vm-bootstrap.h: (was bootstrap.h)
* libguile/vm-engine.c: (was vm_engine.c)
* libguile/vm-engine.h: (was vm_engine.h)
* libguile/vm-expand.h: (was vm_expand.h)
* libguile/vm-i-loader.c: (was vm_loader.c)
* libguile/vm-i-scheme.c: (was vm_scheme.c)
* libguile/vm-i-system.c: (was vm_system.c)
* libguile/vm.c:
* libguile/vm.h: These files moved here from src/, as guile-vm is now a
part of libguile.
* libguile/init.c: Bootstrap the VM. Yay!
* libguile/Makefile.am: The necessary chicanery here.
* module/system/vm/Makefile.am:
* module/system/vm/bootstrap.scm:
* module/system/vm/frame.scm:
* module/system/vm/instruction.scm:
* module/system/vm/objcode.scm:
* module/system/vm/program.scm:
* module/system/vm/vm.scm:
* pre-inst-guile-env.in: Add builddirs to the load path; add module/ to
the path in the empty-$GUILE_LOAD_PATH case as well.
* src/Makefile.am: Moved out everything except guilec and guile-disasm,
which probably should be moved to the scripts directory?
* testsuite/Makefile.am: Update to find guile-vm in the right place.
* module/system/vm/Makefile.am:
* module/system/vm/bootstrap.scm: Removed bootstrap.scm, scm_init_guile
handles the bootstrapping for us.
* module/system/vm/frame.scm:
* module/system/vm/instruction.scm:
* module/system/vm/objcode.scm:
* module/system/vm/program.scm:
* module/system/vm/vm.scm: Call the init functions in libguile; should
fix at some point to avoid the dlopen?
Andy Wingo [Thu, 21 Aug 2008 22:11:27 +0000 (15:11 -0700)]
make pre-inst-guile use pre-inst-guile-env
* pre-inst-guile-env.in:
* pre-inst-guile.in: Change so that pre-inst-guile uses
pre-inst-guile-env. Fixed inconsistency regarding $subdirs_with_ltlibs.
Andy Wingo [Thu, 21 Aug 2008 21:49:12 +0000 (14:49 -0700)]
chmod -x guilec.in.
* src/guilec.in: Chmod -x.
Ludovic Courtès [Thu, 21 Aug 2008 20:23:59 +0000 (22:23 +0200)]
Add Gnulib-provided files for convenience.
These come from Gnulib's Git commit
ae3a0d62f26d8156b403e40d6007475006f3136f, dated 2008-08-19.
Andy Wingo [Wed, 20 Aug 2008 21:32:36 +0000 (14:32 -0700)]
fix some compilation warnings, in anticipation of moving to libguile/
* src/Makefile.am: Use standard guile CFLAGS, which has -Werror and
-Wmissing-prototypes.
* src/frames.h:
* src/instructions.h:
* src/objcodes.h:
* src/programs.h:
* src/vm.h:
* src/vm.c: Fix warnings, mostly about prototypes.
* src/vm_system.c: Fix a tricky x-is-not-initialized error. Thanks, GCC!
Andy Wingo [Wed, 20 Aug 2008 21:11:35 +0000 (14:11 -0700)]
remove unused "envs" code from guile-vm
* src/Makefile.am:
* src/envs.c:
* src/envs.h: Remove the envs code, which was historically used to
implement modules. But since we use Guile's modules, these aren't
necessary.
* src/vm.c:
* src/vm_loader.c:
* module/system/vm/assemble.scm: Remove code bits that trafficked in yon
deprecation.
Ludovic Courtès [Wed, 20 Aug 2008 17:31:46 +0000 (19:31 +0200)]
Never define `_GNU_SOURCE' explicitly since `AC_USE_SYSTEM_EXTENSIONS'
takes care of it.
Conflicts:
ChangeLog
configure.in
libguile/eval.c
libguile/srfi-14.c
libguile/threads.c
Ludovic Courtès [Tue, 19 Aug 2008 22:44:20 +0000 (00:44 +0200)]
Add test case for the GOOPS `class-redefinition' memory corruption.
Ludovic Courtès [Tue, 19 Aug 2008 17:13:39 +0000 (19:13 +0200)]
Add ChangeLog and NEWS entry for the GOOPS `class-redefinition' memory
corruption fix.
Ludovic Courtès [Tue, 19 Aug 2008 17:08:29 +0000 (19:08 +0200)]
Complete fix of `hell' allocation in GOOPS.
Han-Wen Nienhuys [Mon, 18 Aug 2008 14:02:43 +0000 (11:02 -0300)]
Fix sizeof() nitpick for goops corruption.
Han-Wen Nienhuys [Sat, 16 Aug 2008 18:34:04 +0000 (15:34 -0300)]
Make marked conservatively statistic accumulative.
Han-Wen Nienhuys [Sat, 16 Aug 2008 18:20:55 +0000 (15:20 -0300)]
If realloc() fails in scm_realloc, then do a complete GC with complete
sweep directly.
Han-Wen Nienhuys [Sat, 16 Aug 2008 18:03:48 +0000 (15:03 -0300)]
Add a statistic for tracking how many cells are marked conservatively.
This allows an informed choice for deciding how many segments to
create. After startup, ~2% of the cells are scanned conservatively.
Han-Wen Nienhuys [Sat, 16 Aug 2008 16:57:23 +0000 (13:57 -0300)]
Garbage collection cleanup.
* New file gc-segment-table.c: hold code for the segment table.
* Remove data that might be out of date; remove
scm_i_adjust_min_yield(). We don't store min_yields, since they
are only accurate at one point in time (when the sweep finishes).
We decide the min yield at that point from min_yield_fraction and
freelist->collected / freelist->swept
* Introduce scm_i_gc_heap_size_delta() replacing
scm_i_gc_grow_heap_p().
* Remove foo_1 fields containing penultimate results.
* After GC, count mark bit vector to discover number of live
objects. This simplifies hairy updates.
* Many formatting and layout cleanups.
* Fix in scm_i_sweep_card(): return the length of free_list returned,
rather than number of deleted objects.
* For mtrigger GCs: do not also run a full sweep after the gc() call, as
this is inconsistent with lazy sweeping.
* Remove scm_i_make_initial_segment().
* Use calloc in scm_i_make_empty_heap_segment() to save on
initialization code.
* New function scm_i_sweep_for_freelist() which sweeps, with proper
statistic variable updates.
* New segments are conceptually blocks with 100% reclaimable cells.
* Remove some useless constants/comments: SCM_HEAP_SIZE,
SCM_INIT_HEAP_SIZE, SCM_EXPHEAP, SCM_HEAP_SEG_SIZE
* Do not increment scm_cells_allocated() from the
scm_[double]cell(). This would be a race condition.
* Move some deprecation checks in separate functions to not distract
from main code flow.
Han-Wen Nienhuys [Sat, 16 Aug 2008 16:27:17 +0000 (13:27 -0300)]
Remove comments about removed variables.
Han-Wen Nienhuys [Sat, 16 Aug 2008 14:57:27 +0000 (11:57 -0300)]
Introduce scm_i_marking to detect when GC mark bits are touched
outside of marking stage.
Han-Wen Nienhuys [Sat, 16 Aug 2008 05:58:36 +0000 (02:58 -0300)]
Remove unused macro UNMARKED_CELL_P()
Han-Wen Nienhuys [Sat, 16 Aug 2008 05:58:17 +0000 (02:58 -0300)]
Use word_2 to store mark bits for freeing structs and vtables in the
correct order.
This ensures that we only use GC Marks during the actual GC Mark.
Han-Wen Nienhuys [Sat, 16 Aug 2008 15:28:19 +0000 (12:28 -0300)]
Do not include private-gc.h in srfi-60.
Han-Wen Nienhuys [Sat, 16 Aug 2008 05:18:51 +0000 (02:18 -0300)]
Fix memory corruption issue with hell[] array: realloc/calloc need to
factor in sizeof(scm_t_bits)
Han-Wen Nienhuys [Thu, 14 Aug 2008 05:16:41 +0000 (02:16 -0300)]
Include min-yields in gc-stats output.
Han-Wen Nienhuys [Thu, 14 Aug 2008 04:51:24 +0000 (01:51 -0300)]
Whitespace and formatting fixes.
Conflicts:
libguile/gc-freelist.c
libguile/gc-segment.c
libguile/gc.h
Ludovic Courtès [Wed, 13 Aug 2008 22:15:03 +0000 (00:15 +0200)]
Remove the now useless `qthreads.m4'.
Andy Wingo [Mon, 11 Aug 2008 17:51:33 +0000 (19:51 +0200)]
make ,stats work
* module/system/repl/command.scm (display-time-stat, display-mips-stat):
Always convert to float.
* module/system/vm/frame.scm (print-frame): Write the args, don't display them.
* module/system/repl/command.scm (statistics): gc-sweep-time is no more.
Andy Wingo [Mon, 11 Aug 2008 17:27:23 +0000 (19:27 +0200)]
ease-of-use improvement to ,m; catch read errors at the repl
* module/system/repl/command.scm (module): Accept e.g. `,m ice-9 popen'
in addition to `,m (ice-9 popen)'.
* module/system/repl/repl.scm (start-repl): Call read with a backtrace
handler too.
Andy Wingo [Mon, 11 Aug 2008 16:35:58 +0000 (18:35 +0200)]
fix bug in compilation of `and' and `or'; more robust underflow detection.
* module/system/il/compile.scm (codegen): Rewrite handling of `and' and
`or' ghil compilation, because it was broken if drop was #t. Tricky
bug, this one! Took me days to track down!
* module/system/repl/repl.scm: Export call-with-backtrace, which probably
should go in some other file.
* src/vm.c (scm_vm_save_stack): Handle the fp==0 case for errors before
we have a frame.
* src/vm_engine.h (NEW_FRAME, FREE_FRAME): Stricter underflow checking,
raising the stack base to the return address, in an attempt to prevent
inadvertant stack smashing (the symptom of the and/or miscompilation
bug).
(CHECK_IP): A check that the current IP is within the bounds of the
current program. Not normally compiled in. Perhaps it should be?
* src/vm_system.c (halt): Set vp->ip to NULL. Paranoia, I know.
(return): Call CHECK_IP(), if such a thing is compiled in.
* testsuite/Makefile.am (vm_test_files):
* testsuite/t-catch.scm:
* testsuite/t-map.scm:
* testsuite/t-or.scm: New tests.
Andy Wingo [Sat, 9 Aug 2008 12:30:52 +0000 (14:30 +0200)]
backtraces on meta-commands too
* module/system/repl/repl.scm (call-with-backtrace): New helper.
(start-repl): Use the helper, for normal expressions *and* for
meta-commands.
Andy Wingo [Sat, 9 Aug 2008 12:23:20 +0000 (14:23 +0200)]
warn and load source file if newer than compile file
* ice-9/boot-9.scm (try-module-autoload): Warn if the compiled file is
older than the source file, and in that case load the source file.