1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00
Commit graph

10809 commits

Author SHA1 Message Date
Andy Wingo
89bbf35596 no disasm in measure.scm
* benchmark/measure.scm: Don't use (system vm disasm).
2009-02-01 11:29:43 +01:00
Andy Wingo
5338b62b86 don't make intermediate garbage when making vectors in the vm
* 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!
2009-02-01 11:25:51 +01:00
Andy Wingo
ac47d5f639 avoid 8 words of allocation per lambda, whoooo
* 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.
2009-02-01 10:50:45 +01:00
Andy Wingo
1f1ec13b5c add code for writing out metadata to the end of a program
* 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.
2009-02-01 10:15:00 +01:00
Andy Wingo
9aeaabdc45 add metalen field to bytecode serialization
* libguile/objcodes.h (struct scm_objcode): Add a new field, metalen, in
  preparation for embedding metadata within a program.
  (SCM_OBJCODE_META_LEN, SCM_OBJCODE_TOTAL_LEN): New defines.

* libguile/vm.c (really_make_boot_program):
* module/language/assembly.scm (*program-header-len*, 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"): Update for metalen
  addition.
2009-02-01 09:19:24 +01:00
Andy Wingo
d2d7acd5c1 cache 8 boot programs
* libguile/vm.c (vm_make_boot_program): Cache boot programs for nargs <
  8.
2009-01-31 21:54:59 +01:00
Andy Wingo
9bb8012dd6 remove conv.scm, disasm.scm; objcode->bytecode rename
* 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.
2009-01-30 14:36:49 +01:00
Andy Wingo
d7236899f5 add disassembler that fits in with old compiler tower
* 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.
2009-01-30 14:12:57 +01:00
Andy Wingo
7b107cceb9 add decompilers that can take us back to assembly
* 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.
2009-01-30 12:59:29 +01:00
Andy Wingo
5d6fb8bbeb allow specification of languages by name; add decompilers to languages
* 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.
2009-01-30 11:41:02 +01:00
Andy Wingo
4b31848284 remove glil->objcode path in favor of passing through assembly; refactorings.
* 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/.
2009-01-30 11:02:01 +01:00
Andy Wingo
6f78702819 add new language between assembly and objcode: bytecode
* 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.
2009-01-30 10:20:08 +01:00
Andy Wingo
bd02af8acf remove GPKG.def files
* module/language/ghil/GPKG.def:
* module/language/r5rs/GPKG.def: Reove these, they aren't used any more.
2009-01-29 21:12:00 +01:00
Andy Wingo
53e28ed9b2 static opcodes; refactor program/objcode division; use new assembly pipeline
* 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.
2009-01-29 21:12:00 +01:00
Andy Wingo
f1d7723bb3 add assembly intermediate language
* 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.
2009-01-19 00:06:49 +01:00
Andy Wingo
2fda024221 move module and meta inside programs' object tables
* 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.
2009-01-17 16:42:53 +01:00
Andy Wingo
a72317988f placeholder for meta and module in a program's object table
* 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.
2009-01-17 15:08:05 +01:00
Andy Wingo
86872cc392 fold in ludovic's suggestions for new manual sections
* INSTALL: Update from newest merge

* doc/ref/compiler.texi:
* doc/ref/vm.texi: Fold in Ludovic's suggestions
2009-01-15 23:04:06 +01:00
Andy Wingo
0c91a9105d Merge commit 'origin/master' into vm
Conflicts:

	INSTALL
2009-01-15 22:13:03 +01:00
Neil Jerram
9ffef3c6f6 Invoke gnulib-tool with --no-vc-files option, and
remove files that should not have been committed to the repository.
2009-01-15 01:07:15 +00:00
Neil Jerram
97027e4125 Revert lib/.gitignore and m4/.gitignore to how they should be
(before my confused Gnulib commits...)
2009-01-15 00:56:53 +00:00
Neil Jerram
e335ff3df0 Revert unintended change to INSTALL made by commit 4a462e3544 2009-01-15 00:09:21 +00:00
Neil Jerram
7f8e40b778 Add more missing Gnulib files 2009-01-15 00:04:02 +00:00
Neil Jerram
bfb18ff05a Add more missing Gnulib files 2009-01-14 21:05:15 +00:00
Neil Jerram
0a34f3954e Add missing Gnulib file (m4/localcharset.m4) 2009-01-14 20:51:47 +00:00
Andy Wingo
7aa6f86b77 fix marking empty VM continuations
* 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.
2009-01-13 22:33:21 +01:00
Andy Wingo
d5968e7f4e Merge branch 'master' into vm 2009-01-12 23:34:42 +01:00
Ludovic Courtès
bf4200ca9f Fixlet for `run-benchmark.scm'.
* gc-benchmarks/run-benchmark.scm (%default-options): Default to the
  empty list for `input'.
2009-01-12 23:31:51 +01:00
Ludovic Courtès
1c14d7671d gc-benchmarks: Adapt `gcold.scm' so that if conforms to the framework.
* gc-benchmarks/larceny/gcold.scm (main): Rename to `gcold-benchmark'.
  (GCOld): Fix the order of the predicate and run-maker.
2009-01-12 23:31:50 +01:00
Ludovic Courtès
83e3ac9475 gc-benchmarks: Add `gcold.scm', by Clinger, Hansen et al.
See http://www.ccs.neu.edu/home/will/Twobit/benchmarksAbout.html for
details.
2009-01-12 23:31:50 +01:00
Ludovic Courtès
69ecc0baa3 gc-benchmarks: Add `run-benchmark.scm'. 2009-01-12 23:31:50 +01:00
Ludovic Courtès
b9ecffc508 gc-profile: Show the result of `(version)'.
* gc-benchmarks/gc-profile.scm (main): Show `(version)'.
2009-01-12 23:31:50 +01:00
Ludovic Courtès
1b04c499c4 gc-benchmarks: Allow the iteration count to be passed to `gc-profile.scm'.
* 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*'.
2009-01-12 23:31:50 +01:00
Ludovic Courtès
1b706edff6 Import GC benchmarks from Larceny, by Hansen, Clinger, et al.
These GPLv2+-licensed GC benchmarks are available from
http://www.ccs.neu.edu/home/will/GC/sourcecode.html .
2009-01-12 23:31:50 +01:00
Ludovic Courtès
a13dc0b473 gc-benchmarks: Add a Larceny/Twobit benchmark compatibility layer.
* 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'.
2009-01-12 23:31:50 +01:00
Ludovic Courtès
8da56ffc0b Add GC benchmarks. 2009-01-12 23:31:50 +01:00
Neil Jerram
4a462e3544 Make sure that we have a real on-the-stack alloca()
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.
2009-01-12 22:08:56 +00:00
Andy Wingo
616167fc12 remove a paranoid define; fix bitrot in measure.scm.
* 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.
2009-01-12 22:37:29 +01:00
Andy Wingo
78bae3d6fa fix mismerge on srfi-19.scm
* module/srfi/srfi-19.scm (priv:locale-abbr-weekday->index): Whoops, fix
  broken manual merge on srfi-19.scm.
2009-01-12 21:45:37 +01:00
Andy Wingo
7bd5f2913d fix typo when compiling receive forms
* module/language/glil/compile-objcode.scm (codegen): Fix an embarassing
  typo, introduced in c2c82b62f4
2009-01-12 21:37:44 +01:00
Andy Wingo
c32929d14d Merge commit 'origin/master' into vm
Conflicts:

	.gitignore
	guile-tools.in
	srfi/srfi-19.scm
2009-01-12 21:36:39 +01:00
Andy Wingo
c41350777d fold in neil's feedback to history.texi
* doc/ref/history.texi: Fold in Neil's feedback
2009-01-11 18:30:11 +01:00
Andy Wingo
0b8f3ac521 word tweaks
* doc/ref/guile.texi: Finish some wording.

* doc/ref/compiler.texi: Fix some goofiness.
2009-01-11 18:21:27 +01:00
Andy Wingo
e33e3aeefd tweaks to compiler.texi
* doc/ref/compiler.texi: Minor tweaks.
2009-01-11 18:00:21 +01:00
Andy Wingo
ff73ae34c3 finish compiler.texi, woo
* libguile/objcodes.c (do-pair): Removed unused debuging hack.

* module/language/glil/spec.scm (glil): Simplify a bit.

* module/system/repl/repl.scm (default-catch-handler): Don't catch
  vm-error, as vm-backtrace doesn't exist any more.

* doc/ref/compiler.texi: Finish documenting GLIL and object code.
2009-01-11 14:23:48 +01:00
Andy Wingo
c850030fdd rename <glil-asm> to <glil-program>
* module/language/glil.scm (<glil-program>): Rename from <glil-asm>.

* module/language/ghil/compile-glil.scm (codegen):
* module/language/glil.scm (parse-glil, unparse-glil):
* module/language/glil/compile-objcode.scm (preprocess, codegen): Adapt
  to naming change.
2009-01-11 12:14:07 +01:00
Andy Wingo
c2c82b62f4 remove useless <glil-vars> helper type, serialize GHIL more strictly
* 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>.
2009-01-11 12:09:19 +01:00
Andy Wingo
ca445ba5ec rename translate.scm to compile-ghil.scm, and more work on compiler.texi
* 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.
2009-01-09 17:49:09 +01:00
Andy Wingo
e3ba263de4 fix some xrefs, flesh out compiler.texi a bit more
* 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.
2009-01-09 15:52:55 +01:00
Andy Wingo
46d666d4aa finish api-procedures.texi
* doc/ref/api-procedures.texi: Finish documenting bits on compiled
  procedures.
2009-01-09 13:28:43 +01:00