* libguile/vm-i-system.c (vector): Don't cons up a list just to make a
vector. Saves a couple percent in total cell allocation when loading
syncase. Probably not worth it, but foo!
* libguile/objcodes.c (scm_bytecode_to_objcode): Check that the length of
the vector matches the length embedded in the bytecode.
* libguile/programs.c (scm_program_meta): Call through to
scm_objcode_meta, instead of looking in the object table. Avoids
consing up a program+objcode slice for the meta until the meta is
actually called.
* libguile/vm-i-loader.c (load-program): Step past the metadata too.
* module/language/glil/compile-assembly.scm (make-meta): Just return the
load-program form, or #f.
(assoc-ref-or-acons, object-index-and-alist, make-object-table): Don't
write the meta into the object table.
(glil->assembly): Instead write the meta into the load-program form.
* libguile/objcodes.c (make_objcode_by_mmap, scm_c_make_objcode_slice):
Verify the lengths with the meta-length.
(scm_objcode_meta): New procedure, for getting at the meta-info of an
objcode.
(scm_objcode_to_bytecode):
(scm_write_objcode): Write bytecode with the metadata too.
* module/system/vm/objcode.scm: Export object-meta.
* module/language/assembly.scm (byte-length):
* module/language/assembly/compile-bytecode.scm (write-bytecode):
* module/language/assembly/decompile-bytecode.scm (decode-load-program):
* module/language/assembly/disassemble.scm (disassemble-load-program):
* module/language/glil/compile-assembly.scm (glil->assembly):
* test-suite/tests/asm-to-bytecode.test ("compiler"): Change to
load-program format to have meta-or-#f instead of meta-length, so that
we can serialize the meta as objcode without a load-program byte. Add a
test for writing out the meta.
* module/system/vm/Makefile.am:
* module/system/vm/conv.scm:
* module/system/vm/disasm.scm: Remove these modules, as their
functionality is now in (language ...).
* libguile/objcodes.h:
* libguile/objcodes.c:
* module/system/vm/objcode.scm: Rename objcode->u8vector to
objcode->bytecode.
* module/system/vm/frame.scm:
* module/language/bytecode/spec.scm: Fix for objcode->bytecode.
* scripts/disassemble:
* testsuite/run-vm-tests.scm: Fix for (system vm disasm) removal.
* module/system/repl/command.scm: Use the right disassembler.
* module/language/assembly/Makefile.am:
* module/language/assembly/disassemble.scm: Add a disassembler, based on
the old one but fitting in with the decompiler tower.
* module/language/objcode/spec.scm (decompile-value): When decompiling
programs, shove all the metadata that we know about into the "env".
* module/system/base/compile.scm (decompile-fold, decompile): Return the
env from `decompile' as a second value. Not sure if `compile' should do
this too.
* module/language/assembly/Makefile.am:
* module/language/assembly/spec.scm:
* module/language/assembly/decompile-bytecode.scm: Add a bytecode
decompiler. Neat!
* module/language/bytecode/spec.scm (decompile-objcode):
* module/language/objcode/spec.scm (decompile-value): Add some
"decompilers" here too.
* module/system/base/compile.scm (current-language): Since we can refer
to languages by name, do so here -- removes the previous
anti-circularity hack.
(compile-file, compile): Refer to target languages by name.
(decompile): New public function. Neat!
* module/system/base/language.scm (lookup-decompilation-order): Fix so we
look for decompilers with the high-level language definition.
* module/system/base/language.scm (lookup-decompilation-order): New
function, like its compiling cousin, but backwards.
(compute-translation-order): Rework so that languages can be specified
either by name or by identity. Return a list of language - procedure
pairs, without the "to" language in the list, instead of a list of
languages.
(invalidate-compilation-cache!): Invalidate the decompilation cache
too.
(<language>): Add a decompiler field.
* module/system/base/compile.scm (compile-passes): Much simpler now that
lookup-compilation-order gives us the procedures directly.
* module/language/*/spec.scm: Specify compilers by name, so that we can
avoid unnecessary module loads, and so that when we specify
decompilers, we can avoid cycles.
* module/language/assembly.scm: Refactor a bit; remove the name "code"
from the API, as it's too generic, and replace with "assembly".
* module/language/assembly/compile-bytecode.scm: Get byte lengths via,
well, byte-length.
* module/language/glil/Makefile.am:
* module/language/glil/spec.scm:
* module/language/glil/compile-objcode.scm: Remove compile-objcode, as we
just go through bytecode now.
* module/language/glil/compile-assembly.scm (glil->assembly)
(dump-object): s/object->code/object->assembly/.
* module/language/bytecode/Makefile.am:
* module/language/bytecode/spec.scm: Add another language to the stack,
bytecode. Bytecode is the u8vector form of object code..
* configure.in:
* module/language/Makefile.am:
* module/language/assembly/Makefile.am:
* test-suite/tests/asm-to-bytecode.test:
* module/language/assembly/spec.scm:
* module/language/assembly/compile-bytecode.scm: Update to include the
new pass.
* gdbinit: Untested attempts to get the stack fondling macros to deal
with the new program representation.
* libguile/frames.c (scm_vm_frame_arguments, scm_vm_frame_source)
(scm_vm_frame_local_ref, scm_vm_frame_local_set_x): SCM_PROGRAM_DATA is
a struct scm_objcode*.
* libguile/instructions.h:
* libguile/instructions.c: Hide the instruction table and the struct
scm_instruction structure; all access to instructions now goes through
procedures. This is because instructions are no longer in a packed
array indexed by opcode. Also, declare a mask that all instructions
should fit in.
* libguile/objcodes.h:
* libguile/objcodes.c: Rewrite so that object code directly maps its
arity and length from its bytecode. This makes it unnecessary to keep
this information in programs, allowing programs to be simple conses
between the code (objcodes) and data (the object table and the closure
variables).
* libguile/programs.c (scm_make_program): Rework so that make-program
takes objcode, an object table, and externals as arguments. It's much
clearer this way, and we avoid malloc().
* libguile/stacks.c (is_vm_bootstrap_frame): Update for program/objcode
changes.
* libguile/vm-engine.c (vm_run): Initialize the jump table on the first
run, with the opcodes declared in the instruction sources, and with bad
instructions raising an error instead of wandering off into the
Unknown.
* libguile/vm-engine.h (FETCH_LENGTH): Always represent lengths as 3
bytes. The old code was too error-prone.
(NEXT_JUMP): Mask the instruction with SCM_VM_INSTRUCTION_MASK.
(NEW_FRAME): Update for program/objcode changes.
* libguile/vm-expand.h (VM_DEFINE_FUNCTION, VM_DEFINE_INSTRUCTION)
(VM_DEFINE_LOADER): Update so that we explicitly specify opcodes, so
that we have a stable bytecode API.
* libguile/vm-i-loader.c: Update license to LGPLv2+. Explicitly declare
opcodes.
(load-integer): Use an int instead of a long as the accumulator; still
need to revisit this code at some point, I think.
(load-program): Simplify, thankfully!! Just creates the objcode slice
and rolls with it.
* libguile/vm-i-scheme.c: Number the opcodes explicitly.
* libguile/vm-i-system.c: Update license to LGPLv2+. Explicitly declare
opcodes.
(make-closure): Update for new program API.
* libguile/vm.c (vm_make_boot_program): Update for new program/objcode
API. Still a bit ugly.
(scm_load_compiled_with_vm): Update for new program/objcode API.
* module/language/assembly.scm (byte-length): Fix byte-length calculation
for loaders, and load-program.
(code-pack, code-unpack): Start to move things from (system vm conv)
here.
(object->code, code->object): More things from conv.scm.
* module/language/glil.scm (<glil-program>): Add a new field,
closure-level.
(make-glil-program, compute-closure-level): Calculate the "closure
level" when making a glil program. This is the maximum depth of
external binding refs in this closure.
(unparse-glil): Fix label serialization.
* module/language/glil/compile-assembly.scm (make-meta): Prepend #f for
the meta's object table, though maybe in the future we can avoid
creating assembly in the first place.
(assoc-ref-or-acons, object-index-and-alist): GRRR! Caught again by the
different sets of arguments to assoc and assoc-ref!
(glil->assembly): Attempt to make the <glil-program> case more
readable, and fix the bugs. Sorry I don't know how to comment this
change any more than this.
(glil->assembly): For <glil-module> serialize the whole key, not just
the name.
(dump-object): subprogram-code is already a list. Serialize integers as
strings, not u8vectors. Fix the order of lists and vectors.
* module/language/glil/spec.scm (glil): Switch orders, so we prefer glil
-> assembly -> objcode. Actually glil->objcode doesn't work any more,
needs to be removed I think.
* module/language/objcode/spec.scm (objcode->value):
s/objcode->program/make-program/.
* module/language/scheme/inline.scm: Add acons inline.
* module/system/vm/conv.scm (make-byte-decoder): Skip the first 8 bytes,
they are header. Handle subprograms properly. Still needs help though.
(decode-length): Lengths are always 3 bytes now.
* module/system/vm/disasm.scm: Superficial changes to keep things
working. I'd like to fix this better in the future.
* module/system/vm/frame.scm (bootstrap-frame?): Fixes for
program-bytecode.
* module/system/vm/program.scm: Export make-program. It's program-objcode
now, no more program-bytecode.
* module/system/vm/vm.scm (vm-load): Use make-program.
* test-suite/tests/asm-to-bytecode.test: New test, very minimal.
* module/system/vm/objcode.scm: Export word-size, byte-order, and
write-objcode.
* configure.in:
* module/language/Makefile.am:
* module/language/assembly/Makefile.am: Automakery.
* module/language/assembly.scm:
* module/language/assembly/spec.scm: Add a new language, which is oddly
even lower than GLIL. I got tired of GLIL's terrible
compile-objcode.scm, and wanted a cleaner intermediate format.
* module/language/glil/compile-assembly.scm: A purely-functional
assembler, that produces "assembly". Will document later.
* module/language/glil/spec.scm: Declare the compiler to assembly.
* libguile/programs.h (struct scm_program): Remove the module and meta
fields.
* libguile/programs.c (scm_c_make_program): Add a new argument, `objs'.
If it's a vector, we'll look for the module and the metadata in there,
instead of having them in the scm_program structure.
(scm_c_make_closure, program_mark, scm_program_meta)
(scm_c_program_source, scm_program_module): Adapt to the new program
representation.
* libguile/objcodes.c (scm_objcode_to_program): Pass #f as the object
table when making the program.
* libguile/vm-engine.h (CACHE_PROGRAM):
* libguile/vm-engine.c (vm_run): Rework to use the simple vector API for
getting the current object table. Call the helper,
vm_make_boot_program, to make the boot program.
* libguile/vm-i-loader.c (load-program): Set the current module and the
meta in the object vector, which we pass to scm_c_make_program.
* libguile/vm-i-system.c (toplevel-ref, toplevel-set): Adapt to the new
program representation.
* module/language/glil/compile-objcode.scm (codegen): Clarify.
* module/language/glil/compile-objcode.scm (codegen): If the generated
objcode will have a meta or it has objects, prepend two cells to the
object table: one for the meta, and one for the module. This is a
placeholder for future work.
* libguile/vm.h (struct scm_vm_cont):
* libguile/vm.c (capture_vm_cont, reinstate_vm_cont): Change so we just
store the registers as they are, with the reloc.
(vm_cont_mark): Only mark the stack if it has elements on it, otherwise
we get a bogus fp.
* libguile/stacks.c (scm_make_stack): Update for change to vm
continuations.
* gc-benchmarks/gc-profile.scm (*iteration-count*): New parameter.
(run-benchmark): Moved from `twobit-compat.scm'. Honor
`*iteration-count*'.
(%options): Add `--iterations'.
(show-help): Document it.
(main): Parameterize `*iteration-count*'.
* gc-benchmarks/gc-profile.scm: Load "twobit-compat.scm".
(save-directory-excursion, load-larceny-benchmark): New procedures.
(%options): New variable.
(show-help, parse-args): New procedures.
(main): Use `parse-args' and `load-larceny-benchmark'.
Because of how Guile saves and restores continuations (by copying the
stack), and how it uses alloca to create space for debug information
on the stack, we must have an alloca() that really does use the stack,
and not one that uses the heap.
To do this, we use the Gnulib "alloca-opt" module instead of "alloca".
This commit also updates the Gnulib sources from the current Gnulib
Git repository.
* benchmark/measure.scm (measure): Fix bitrot.
* libguile/vm.c (VM_ENABLE_STACK_NULLING): Undefine this, as it hasn't
caught any errors in quite a while.
* module/language/ghil.scm (parse-ghil, unparse-ghil): Rework to make the
parse format correspond more closely with the object representation, so
that I only have to document it once in the manual. The salient change
is that no expression is self-quoting, and that variable references
should go through `(ref FOO)'. Rename `set!' to `set'.
* module/language/ghil/compile-glil.scm: Add a couple of compilers for
unquote and unquote-splicing, that just raise an error. This way I can
document unquote and unquote-splicing as normal ghil expressions,
except that it's the compiler that catches them if they're outside a
quasiquote.
(codegen): Adapt to change in <glil-asm>.
* module/language/ghil/spec.scm (parse): Fix parser typo bug.
* module/language/glil.scm (<glil-asm>): Remove useless <glil-vars>
structure, which also had a confusing name. Just put the nargs, nrest,
nlocs, and nexts in the <glil-asm> directly.
(parse-glil, unparse-glil): Serialize `asm' more straightforwardly.
* module/language/glil/compile-objcode.scm (<bytespec>): Remove
<glil-vars>, as with <glil-asm>.
(preprocess, make-meta, codegen, dump-object!): Adapt to change in
<glil-asm>.
* doc/ref/api-evaluation.texi: Fix some typos and xrefs.
* doc/ref/compiler.texi (The Scheme Compiler): Document the scheme
compiler, and start documenting the GHIL language.
* doc/ref/guile.texi (Guile Implementation): Whoops, put autoconf after
the implementation foo. Unless we want it before?
* doc/ref/history.texi (The Emacs Thesis): Fix typo.
* doc/ref/vm.texi (Environment Control Instructions): Rename offset to
index.
* module/language/ghil.scm (parse-ghil): Fix what I think was a bug --
the consumer in a mv-call shouldn't be a rest arg.
* module/language/scheme/Makefile.am (SOURCES):
* module/language/scheme/compile-ghil.scm: Rename this file from
translate.scm.
* module/oop/goops.scm:
* module/language/scheme/spec.scm: Deal with renaming.
* doc/ref/api-debug.texi:
* doc/ref/vm.texi: Fix some cross-references.
* doc/ref/compiler.texi: Hack some more, finishing the section on the
compiler tower.