bpt/guile.git
15 years agoadd compile-toplevel and evaluate conditions to eval-case
Andy Wingo [Mon, 19 May 2008 10:26:20 +0000 (12:26 +0200)]
add compile-toplevel and evaluate conditions to eval-case

* ice-9/boot-9.scm (eval-case): Define two more conditions:
  compile-toplevel and evaluate, as common lisp and chez scheme do.
  (defmacro, define-option-interface, define-macro, define-syntax-macro)
  (define-module, use-modules, use-syntax, define-public)
  (defmacro-public, export, re-export): Add `compile-toplevel' to all
  uses of eval-case.

15 years agomake has-suffix? use string-suffix?
Andy Wingo [Mon, 19 May 2008 10:23:46 +0000 (12:23 +0200)]
make has-suffix? use string-suffix?

* ice-9/boot-9.scm (has-suffix?): Use the core / srfi-13's
  string-suffix?.

15 years agoSupport loading of compiled syncase macros
Andy Wingo [Mon, 19 May 2008 10:19:28 +0000 (12:19 +0200)]
Support loading of compiled syncase macros

* ice-9/syncase.scm (current-eval-closure): New procedure.
  (env->eval-closure): Don't default to the root module: if we have no
  environment, we default to the current module via the logic in
  current-eval-closure. This is because psyntax's compilation mode
  doesn't know about guile modules, and thus won't dump the code to
  twiddle the current eval closure.
  (putprop, getprop, guile-macro): Use `current-eval-closure'.
  At the end, leave the expansion-eval-closure set to #f.

15 years agosupport thunks as prompts, as readline does.
Andy Wingo [Fri, 9 May 2008 14:42:44 +0000 (16:42 +0200)]
support thunks as prompts, as readline does.

* ice-9/boot-9.scm (repl-reader): Support thunks as prompts.

15 years agomake readline's `repl-reader' impl check the current-reader fluid
Andy Wingo [Sat, 2 Aug 2008 10:29:07 +0000 (12:29 +0200)]
make readline's `repl-reader' impl check the current-reader fluid

* guile-readline/ice-9/readline.scm (activate-readline): Use the current
  binding of the current-reader fluid, if it is available.

15 years agoFixes to make guile-vm compile in guile source tree
Andy Wingo [Sat, 2 Aug 2008 10:17:27 +0000 (12:17 +0200)]
Fixes to make guile-vm compile in guile source tree

* INSTALL: Updated.
* m4/gnulib-cache.m4: Regenerated.

* Makefile.am: Spelling fix.

* guilec.mk:
* src/Makefile.am:
* src/vm.c: Update to actually work inside a guile source tree.

* libguile/Makefile.am: Don't error on warnings in the flex-generated
  c-tokenize function.

15 years agomerge guile-vm to guile
Andy Wingo [Sat, 2 Aug 2008 09:40:32 +0000 (11:40 +0200)]
merge guile-vm to guile

An attempt to pull in the original history from guile-vm into guile itself.

16 years agoUpdated loop disassembly
Andy Wingo [Sun, 25 May 2008 11:43:26 +0000 (13:43 +0200)]
Updated loop disassembly

* benchmark/lib.scm: Update loop disassembly, with inlining. Neat!

16 years agoadd inline macros for zero? and 1-
Andy Wingo [Sun, 25 May 2008 11:38:17 +0000 (13:38 +0200)]
add inline macros for zero? and 1-

* module/system/il/inline.scm (zero?, 1-): New inlines. Neat :) The loop
  benchmark speedup is now up to 5x.

16 years agoSpeed up the self-tail-recursive case (1x->2x)
Andy Wingo [Sun, 25 May 2008 11:34:50 +0000 (13:34 +0200)]
Speed up the self-tail-recursive case (1x->2x)

* 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.

16 years agoenable inlining; speed!
Andy Wingo [Sun, 25 May 2008 11:13:15 +0000 (13:13 +0200)]
enable inlining; speed!

* 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.

16 years agoupdate news
Andy Wingo [Tue, 20 May 2008 11:30:21 +0000 (13:30 +0200)]
update news

* NEWS: Update news for 0.7 release

16 years agodistcheck works now
Andy Wingo [Tue, 20 May 2008 10:54:14 +0000 (12:54 +0200)]
distcheck works now

* 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.

16 years agoinclude local copy of guile.m4
Andy Wingo [Tue, 20 May 2008 10:21:40 +0000 (12:21 +0200)]
include local copy of guile.m4

* acinclude.m4: Add guile.m4 to this, because I really can't be arsed
  with aclocal.

* autogen.sh: More better vanilla.

16 years agoautotooling, version bump to 0.7
Andy Wingo [Tue, 20 May 2008 10:10:18 +0000 (12:10 +0200)]
autotooling, version bump to 0.7

* 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?)

16 years agofix distcheck
Andy Wingo [Tue, 20 May 2008 09:54:05 +0000 (11:54 +0200)]
fix distcheck

* src/Makefile.am (AM_CFLAGS, libguile_vm_la_LDFLAGS): Don't build with
  -pg. (There are better profilers out there.)
  (CLEANFILES): Add guilev and guile-disasm.

* testsuite/Makefile.am (GUILE_VM): s/srcdir/builddir/.

16 years agoproperly include config.h in source files, not headers
Andy Wingo [Tue, 20 May 2008 09:46:52 +0000 (11:46 +0200)]
properly include config.h in source files, not headers

* 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.

16 years agoguile-vm is completely self-compiling now!
Andy Wingo [Tue, 20 May 2008 09:33:28 +0000 (11:33 +0200)]
guile-vm is completely self-compiling now!

* 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!

16 years agofix syntax error in describe.scm
Andy Wingo [Mon, 19 May 2008 19:38:09 +0000 (21:38 +0200)]
fix syntax error in describe.scm

* 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.

16 years agofix immediate linkage, some other fixes to allow vm/ to compile
Andy Wingo [Mon, 19 May 2008 19:29:18 +0000 (21:29 +0200)]
fix immediate linkage, some other fixes to allow vm/ to compile

* 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.

16 years agobind all module-level variables lazily
Andy Wingo [Mon, 19 May 2008 17:37:39 +0000 (19:37 +0200)]
bind all module-level variables lazily

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.

16 years agoAdd instructions for doing very late binding
Andy Wingo [Mon, 19 May 2008 15:46:05 +0000 (17:46 +0200)]
Add instructions for doing very late binding

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.

16 years agocompile all of base/; some arbitrary changes; more "fixes" to `link'
Andy Wingo [Mon, 19 May 2008 10:57:48 +0000 (12:57 +0200)]
compile all of base/; some arbitrary changes; more "fixes" to `link'

* 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.

16 years agosyncase macros compiling!
Andy Wingo [Mon, 19 May 2008 08:38:18 +0000 (10:38 +0200)]
syncase macros compiling!

* 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!

16 years agorudimentary syncase support; some dash symbol syncase removal
Andy Wingo [Thu, 15 May 2008 21:38:52 +0000 (23:38 +0200)]
rudimentary syncase support; some dash symbol syncase removal

* 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.

16 years agoavoid zealous unquotation
Andy Wingo [Thu, 15 May 2008 16:57:33 +0000 (18:57 +0200)]
avoid zealous unquotation

* 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.

16 years agofix else in cond, letrec env corruption, syntax.scm compile, define-module side effects
Andy Wingo [Thu, 15 May 2008 16:48:22 +0000 (18:48 +0200)]
fix else in cond, letrec env corruption, syntax.scm compile, define-module side effects

* 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'.

16 years ago`link' instruction links to symbols by module
Andy Wingo [Thu, 15 May 2008 11:55:33 +0000 (13:55 +0200)]
`link' instruction links to symbols by 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.

16 years agoremove some debugging info
Andy Wingo [Thu, 15 May 2008 11:03:47 +0000 (13:03 +0200)]
remove some debugging info

* module/system/vm/assemble.scm: remove a pk

16 years agopush the module resolution info for variables down into glil
Andy Wingo [Thu, 15 May 2008 11:03:10 +0000 (13:03 +0200)]
push the module resolution info for variables down into glil

* 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.

16 years agofix dumping of #:keywords
Andy Wingo [Thu, 15 May 2008 10:20:18 +0000 (12:20 +0200)]
fix dumping of #:keywords

* 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.

16 years agoallow interpretation of load-toplevel as compile-toplevel
Andy Wingo [Thu, 15 May 2008 09:17:00 +0000 (11:17 +0200)]
allow interpretation of load-toplevel as compile-toplevel

* 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'.

16 years agorework eval-case handling to be like cl's eval-when
Andy Wingo [Wed, 14 May 2008 22:38:31 +0000 (00:38 +0200)]
rework eval-case handling to be like cl's eval-when

* 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.

16 years agofix use-syntax / use-modules confusion -- fixes testsuites
Andy Wingo [Wed, 14 May 2008 12:54:52 +0000 (14:54 +0200)]
fix use-syntax / use-modules confusion -- fixes testsuites

* 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.

16 years agofix macro compilation via hooking into eval-case
Andy Wingo [Wed, 14 May 2008 12:47:29 +0000 (14:47 +0200)]
fix macro compilation via hooking into eval-case

* 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.

16 years ago(void) -> (begin)
Andy Wingo [Wed, 14 May 2008 09:19:06 +0000 (11:19 +0200)]
(void) -> (begin)

* module/language/scheme/translate.scm (expand-macro, trans-pair): Remove
  support for the scheme form, '(void). Replace it by (begin). What was
  Keisuke thinking? :)

16 years agoremove x.foo.bar -> (slot x 'foo 'bar) compile-time translation
Andy Wingo [Wed, 14 May 2008 09:13:00 +0000 (11:13 +0200)]
remove x.foo.bar -> (slot x 'foo 'bar) compile-time translation

* module/language/scheme/translate.scm (trans): Remove compile-time dot
  expansion.

16 years agofix env script
Andy Wingo [Mon, 12 May 2008 22:13:56 +0000 (00:13 +0200)]
fix env script

* env: Fix env script to find $top_srcdir correctly

16 years agoUpdate Makefile.am's; remove slib import
Andy Wingo [Mon, 12 May 2008 22:07:40 +0000 (00:07 +0200)]
Update Makefile.am's; remove slib import

* 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.

16 years agoadd env script
Andy Wingo [Mon, 12 May 2008 21:39:25 +0000 (23:39 +0200)]
add env script

* env: New file, run as ./env guile

16 years agocatch errors in the repl, with poor backtraces
Andy Wingo [Mon, 12 May 2008 21:27:14 +0000 (23:27 +0200)]
catch errors in the repl, with poor backtraces

* 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.

16 years agoreplace cenv with things in <repl> and fluids; remove the `use' meta-command
Andy Wingo [Mon, 12 May 2008 20:26:31 +0000 (22:26 +0200)]
replace cenv with things in <repl> and fluids; remove the `use' meta-command

* 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.

16 years agofixes so that typing asdfadfasff in the repl doesn't error
Andy Wingo [Sun, 11 May 2008 22:22:36 +0000 (00:22 +0200)]
fixes so that typing asdfadfasff in the repl doesn't error

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'.

16 years agoonly allow `define' at toplevel
Andy Wingo [Sun, 11 May 2008 20:37:35 +0000 (22:37 +0200)]
only allow `define' at toplevel

* 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.

16 years agoremove define-private
Andy Wingo [Sun, 11 May 2008 20:03:50 +0000 (22:03 +0200)]
remove define-private

* module/language/scheme/translate.scm: Remove define-private.

16 years agoexplicitly list exports instead of using define-public
Andy Wingo [Sun, 11 May 2008 20:00:34 +0000 (22:00 +0200)]
explicitly list exports instead of using define-public

* 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.

16 years ago<foo>? -> foo?; some exports cleanups
Andy Wingo [Sun, 11 May 2008 19:48:10 +0000 (21:48 +0200)]
<foo>? -> foo?; some exports cleanups

* 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.

16 years agopmatchify a cond for prettiness
Andy Wingo [Sun, 11 May 2008 19:30:02 +0000 (21:30 +0200)]
pmatchify a cond for prettiness

* module/language/scheme/translate.scm: pmatchify, it's prettier.

16 years agofix to meta-reader's optional port argument
Andy Wingo [Sun, 11 May 2008 18:53:47 +0000 (20:53 +0200)]
fix to meta-reader's optional port argument

* module/system/repl/repl.scm (meta-reader): Make the generated read
  procedure accept a port argument.

16 years agoice-9 history integration
Andy Wingo [Fri, 9 May 2008 11:21:23 +0000 (13:21 +0200)]
ice-9 history integration

* module/system/repl/repl.scm (start-repl): (ice-9 history) integration
  via the before-eval-hook and the before-print-hook.

16 years agoreadline integration for guile-vm
Andy Wingo [Fri, 9 May 2008 11:15:15 +0000 (13:15 +0200)]
readline integration for guile-vm

* 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.

16 years agomore exports cleanups
Andy Wingo [Fri, 9 May 2008 10:14:15 +0000 (12:14 +0200)]
more exports cleanups

* module/system/repl/common.scm: Declare exports in the module
  declaration.

16 years agomultiple-values help for the repl; exports cleanups
Andy Wingo [Fri, 9 May 2008 10:08:06 +0000 (12:08 +0200)]
multiple-values help for the repl; exports cleanups

* 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.

16 years agoReplace ice-9 match's structures with guile's records
Andy Wingo [Sun, 4 May 2008 15:25:13 +0000 (17:25 +0200)]
Replace ice-9 match's structures with guile's records

* 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.

16 years agoRemoved dot-expander syntax foo
Andy Wingo [Sun, 4 May 2008 14:26:56 +0000 (16:26 +0200)]
Removed dot-expander syntax foo

* module/system/base/syntax.scm (expand-dot!, expand-symbol, syntax):
  Removed, we don't use this syntax any more.

16 years agofinish dedottifying
Andy Wingo [Sun, 4 May 2008 14:25:36 +0000 (16:25 +0200)]
finish dedottifying

* module/system/base/compile.scm: Dedottify.

* module/system/base/language.scm: Export language accessors.

* module/system/repl/common.scm: Dedottify. It's ugly, I know.

16 years agomore dedottification, almost done
Andy Wingo [Sun, 4 May 2008 14:12:36 +0000 (16:12 +0200)]
more dedottification, almost done

* module/system/repl/common.scm:
* module/system/base/compile.scm: Export some more things.

* module/system/repl/command.scm: Dedottify.

16 years agoDedottify some more
Andy Wingo [Sun, 4 May 2008 13:59:40 +0000 (15:59 +0200)]
Dedottify some more

* module/system/il/compile.scm: Dedottify.

* module/system/il/ghil.scm: Export some more thingies.

16 years agoprocedures-with-setters, debitrot `optimize', dedottification
Andy Wingo [Sun, 4 May 2008 13:37:54 +0000 (15:37 +0200)]
procedures-with-setters, debitrot `optimize', dedottification

* module/system/base/syntax.scm (define-record): Define the accessors as
  procedures-with-setters, not just as getters.

* module/system/il/compile.scm (optimize): This function was bitrotten
  since the addition of source locations in
  cb4cca12e719edfef1740f238d9187c21c8e1e35. Untested attempts to
  de-bitrot it. Dedottify as well.

* module/system/il/ghil.scm:
* module/system/il/glil.scm (unparse):
* module/system/vm/debug.scm (debugger-repl): Ongoing dedottification.

16 years agofix errors in (language scheme translate) introduced in pmatchification
Andy Wingo [Sun, 4 May 2008 12:28:16 +0000 (14:28 +0200)]
fix errors in (language scheme translate) introduced in pmatchification

* module/language/scheme/translate.scm (trans-pair): Fix some errors
  introduced in pmatchification.

16 years agoStart the process of de-dottification.
Andy Wingo [Sun, 4 May 2008 12:03:53 +0000 (14:03 +0200)]
Start the process of de-dottification.

* module/system/vm/assemble.scm: De-dottify.

16 years agoDefine named accessors for legacy record types
Andy Wingo [Sun, 4 May 2008 11:54:41 +0000 (13:54 +0200)]
Define named accessors for legacy record types

* module/system/base/syntax.scm (define-record): Define named accessors,
  to prepare the code for srfi-9 records switchover.

* module/system/il/ghil.scm:
* module/system/il/glil.scm: Export a bunch of named accessors.

16 years agoRefactor (language scheme translate) to use pmatch
Andy Wingo [Sun, 4 May 2008 11:26:00 +0000 (13:26 +0200)]
Refactor (language scheme translate) to use pmatch

* module/language/scheme/translate.scm: Refactor use of `match' to use
  `pmatch'. Relatively straightforward.

* module/system/base/pmatch.scm (ppat): Fix some copy-n-paste bugs: the _
  rule, the quote rule.

16 years agomore pmatchification
Andy Wingo [Sat, 3 May 2008 17:39:41 +0000 (19:39 +0200)]
more pmatchification

* module/system/il/ghil.scm: No need for a match

* module/system/repl/command.scm: Pmatchify

* module/system/vm/disasm.scm: Pmatchify.

16 years agobugfix to make-cenv
Andy Wingo [Sat, 3 May 2008 17:38:10 +0000 (19:38 +0200)]
bugfix to make-cenv

* module/system/base/compile.scm (make-cenv): Fix make-cenv.

16 years agostart using pmatch instead of match
Andy Wingo [Sat, 3 May 2008 17:23:45 +0000 (19:23 +0200)]
start using pmatch instead of match

* module/system/base/Makefile.am: Add pmatch.scm.

* module/system/base/pmatch.scm: New file, taken from Dan Friedman's
  alpha-kanren paper. Implements a less magical match syntax, pmatch.

* module/system/vm/assemble.scm: No more need for (ice-9 match).

* module/system/vm/conv.scm (code-pack, code->object): Change to use
  pmatch.

16 years agos/match-lambda\*/case-lambda/g
Andy Wingo [Sat, 3 May 2008 17:13:51 +0000 (19:13 +0200)]
s/match-lambda\*/case-lambda/g

* module/system/il/macros.scm: Use case-lambda from srfi-16 rather than
  match-lambda*.

16 years agoconvert a couple more modules to record-case
Andy Wingo [Sat, 3 May 2008 16:47:05 +0000 (18:47 +0200)]
convert a couple more modules to record-case

* module/system/base/syntax.scm (record-case): Capture the match macro.

* module/system/il/glil.scm:
* module/system/il/compile.scm: Convert to record-case.

16 years agounify variant types and records; also make-foo instead of <foo>
Andy Wingo [Sat, 3 May 2008 16:32:46 +0000 (18:32 +0200)]
unify variant types and records; also make-foo instead of <foo>

* module/system/base/syntax.scm (define-record): Rework to separate the
  type and its constructor. Now (define-record (<foo> bar)) will create
  `make-foo' as the constructor, not `<foo>'. Also the constructor now
  takes either keyword or positional arguments, so that it can be used as
  the implementation of variant types as well.
  (|): Map directly to define-record instead of rolling our own thing.

* module/language/scheme/translate.scm:
* module/system/base/language.scm:
* module/system/il/compile.scm:
* module/system/il/ghil.scm:
* module/system/il/glil.scm:
* module/system/repl/common.scm:
* module/system/vm/assemble.scm:
* module/system/vm/debug.scm: Change instances of record creation to use
  the make-foo procedures instead of <foo>. Adjust module exports as
  necessary.

16 years agoConvert assemble.scm to use record-case.
Andy Wingo [Sat, 3 May 2008 12:52:36 +0000 (14:52 +0200)]
Convert assemble.scm to use record-case.

* module/system/base/syntax.scm (record?): Temporarily export this thing,
  so that code will remain correct when I change to srfi-9 records.

* module/system/vm/assemble.scm: Convert to use record-case.

16 years agofix to (system base syntax)'s syntax
Andy Wingo [Sat, 3 May 2008 12:00:45 +0000 (14:00 +0200)]
fix to (system base syntax)'s syntax

* module/system/base/syntax.scm: Fix define-module

16 years agorebase record-case on `match'
Andy Wingo [Sat, 3 May 2008 11:55:33 +0000 (13:55 +0200)]
rebase record-case on `match'

* module/system/base/syntax.scm (record-case): Rebase on `match', for
  transition purposes.

16 years agopull in srfi-9, implement record-case
Andy Wingo [Sat, 3 May 2008 11:46:56 +0000 (13:46 +0200)]
pull in srfi-9, implement record-case

* module/system/base/syntax.scm: Pull in srfi-9. Define a record-case
  macro that will replace (match foo (($ <type> slot ...) body...)).

16 years agoclean up some syntax imports and exports
Andy Wingo [Fri, 2 May 2008 16:59:04 +0000 (18:59 +0200)]
clean up some syntax imports and exports

* module/system/base/syntax.scm (system): Don't re-export receive or
  and-let*; modules should explicitly import these if they want to. Don't
  export an empty stack-catch definition!

* module/system/repl/command.scm (system): Pull in and-let*.

* module/system/vm/disasm.scm (system): Don't import and-let*.

16 years agoremove module.scm
Andy Wingo [Fri, 2 May 2008 15:51:34 +0000 (17:51 +0200)]
remove module.scm

* module/system/base/module.scm: Removed module.scm, as it was unused
  (see 9419ff9ae91c93983972797e607e135ecd1233bb).

16 years agocleanups in syntax.scm
Andy Wingo [Fri, 2 May 2008 15:35:25 +0000 (17:35 +0200)]
cleanups in syntax.scm

* benchmark/lib.scm (fibo): Make fibo actually a fibonacci sequence.

* module/system/base/syntax.scm (system): Forward-declare all exports.
  (expand-symbol, slot): Rewrite expand-symbol to expand to a
  non-recursive invocation of `slot', so that in the future when we get
  rid of this syntax, the replacement will be more palatable to the eyes.

16 years agoSlowly improving support for macro compilation.
Ludovic Courtes [Sun, 30 Jul 2006 21:01:40 +0000 (21:01 +0000)]
Slowly improving support for macro compilation.

* module/language/scheme/translate.scm (&current-macros): Removed.
  (&current-macro-module): Removed.
  (&compile-time-module): New.
  (eval-at-compile-time): New.
  (translate): Initialize `&compile-time-module'.
  (expand-macro)[use-syntax]: New case.
  [begin let...]: Don't expand these built-in macros.
  [else]: Rewrote the macro detection and invocation logic.  Invoke macro
  transformers in the current compile-time module.
  (trans): Let `expand-macro' raise an exception if needed.
  (trans-pair)[defmacro define-macro]: Evaluate the macro definition in
  the compile-time module.

* testsuite/t-match.scm: Use `use-syntax' instead of `use-modules' for
  `(ice-9 match)' and `(srfi srfi-9)'.

* testsuite/t-records.scm: Likewise.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-15

16 years agoFixed `autogen.sh' and removed `module' from the list of dirs to build.
Ludovic Court`es [Tue, 10 Jan 2006 08:36:43 +0000 (08:36 +0000)]
Fixed `autogen.sh' and removed `module' from the list of dirs to build.

* autogen.sh: Fixed (call `libtoolize').

* Makefile.am (SUBDIRS): Removed `module' which doesn't build right now.

git-archimport-id: lcourtes@laas.fr--2004-libre/guile-vm--revival--0.6--patch-16

16 years agoImproved macro handling; started documenting the issue.
Ludovic Courtes [Tue, 3 Jan 2006 23:13:30 +0000 (23:13 +0000)]
Improved macro handling; started documenting the issue.

* doc/guile-vm.texi (Compiling Scheme Code): New node.

* module/language/scheme/translate.scm (&current-macro-module): New.
  (translate): Evaluate macros in `&current-macro-module'.
  (trans-pair): Likewise.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-13

16 years agoFixed the exception handler of `guilec'.
Ludovic Courtes [Mon, 2 Jan 2006 18:05:23 +0000 (18:05 +0000)]
Fixed the exception handler of `guilec'.

* src/guilec.in: Fixed the exception handler.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-12

16 years agoEncode the length of constant lists/vectors on 2 octets instead of 1.
Ludovic Courtes [Mon, 2 Jan 2006 18:04:04 +0000 (18:04 +0000)]
Encode the length of constant lists/vectors on 2 octets instead of 1.

* module/system/vm/assemble.scm (dump-object!): New sub-procedure
  `too-long'.  For `list' and `vector', encode the length on 2 octets
  instead of 1 and report an error if a list/vector is longer than 65535.

* module/system/vm/disasm.scm (original-value): New sub-procedure
  `list-or-vector?'; when true, return the number of elements for that
  list/vector.

* src/vm_system.c (list): Fetch the length as a two-octet integer.
  (vector): Likewise.

* testsuite/t-basic-contructs.scm: New.

* testsuite/Makefile.am (vm_test_files): Added the above file.

* module/system/vm/core.scm (load-compiled): Added a bit of
  documentation.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-11

16 years agoRenamed the library from `libguilevm' to `libguile-vm'.
Ludovic Courtes [Mon, 2 Jan 2006 15:20:33 +0000 (15:20 +0000)]
Renamed the library from `libguilevm' to `libguile-vm'.

* src/Makefile.am (lib_LTLIBRARIES): Renamed to `libguilevm.la' to
  `libguile-vm.la'.

* module/system/vm/core.scm: Dynamic-link "libguile-vm" instead of
  "libguilevm.so".

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-10

16 years agoAdded support for `defmacro' and `define-macro' in the compiler.
Ludovic Courtes [Tue, 20 Dec 2005 23:22:11 +0000 (23:22 +0000)]
Added support for `defmacro' and `define-macro' in the compiler.

* module/language/scheme/translate.scm: Use `(srfi srfi-39)'.
  (&current-macros): New top-level.
  (expand-macro): New.
  (scheme-primitives): Renamed `%scheme-primitives'.
  (%forbidden-primitives): New.
  (trans): Use `expand-macro' instead of `macroexpand'.
  (trans-pair): Handle `define-macro' and `defmacro'.

* module/system/base/compile.scm (call-with-compile-error-catch): Handle
  non-pair LOC.

* testsuite/t-macros2.scm: New test case.

* testsuite/Makefile.am (vm_test_files): Updated.

* testsuite/t-macros.scm: Test `read-options'.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-9

16 years agoFixed an "unbound variable" in `(system vm conv)'.
Ludovic Courtes [Tue, 20 Dec 2005 23:12:10 +0000 (23:12 +0000)]
Fixed an "unbound variable" in `(system vm conv)'.

* module/system/vm/conv.scm: Autoload `(system vm core)' also when
  `opcode->instruction' is hit.  This fixes an "unbound variable" problem.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-8

16 years agoFixed error handling; detect and report macro expansion errors.
Ludovic Courtes [Tue, 13 Dec 2005 21:33:50 +0000 (21:33 +0000)]
Fixed error handling; detect and report macro expansion errors.

* module/language/scheme/translate.scm (trans): Catch exceptions thrown
  by `macroexpand' and throw a syntax error.
  (trans-pair): Catch calls to `procedure->memoizing-macro' and raise a
  syntax error.

* module/system/base/compile.scm (call-with-compile-error-catch): Made a
  macro (a procedure doesn't do the job).
  (compile-file): Uncommented call to `call-with-compile-error-catch'.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-7

16 years agoTried compiling more code; augmented the doc.
Ludovic Courtes [Tue, 1 Nov 2005 23:24:15 +0000 (23:24 +0000)]
Tried compiling more code; augmented the doc.

* module/language/Makefile.am: New.

* module/language/scheme/Makefile.am: New.

* configure.in: Produce these two new Makefiles.

* doc/guile-vm.texi: Documented `compile-file', `compiled-file-name', and
  `compile-in'.

* module/system/base/compile.scm: Cosmetic changes.

* module/system/base/language.scm: Likewise.

* module/system/il/Makefile.am: Tried (and failed) to compile more
  things.

* module/system/vm/Makefile.am: All source files in here can now be
  compiled without harming further compilation.

* module/system/vm/assemble.scm: Select only specific bindings from
  `(system vm core)'.
  (dump-object!): Show a more meaningful error message.

* module/system/vm/conv.scm: Select only specific bindings from `(system
  vm core)'.

* module/system/vm/debug.scm: Likewise.

* module/system/vm/frame.scm: Changed the header.  Use a renamer for
  `(system vm core)'.

* src/guilec.in: Added options, via `getopt-long'.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-6

16 years agoFixed a Scheme translation bug; cleaned compilation with GCC 4.
Ludovic Courtes [Tue, 1 Nov 2005 21:29:04 +0000 (21:29 +0000)]
Fixed a Scheme translation bug; cleaned compilation with GCC 4.

* module/language/scheme/translate.scm (trans-pair): In the `set!' case,
  when a procedure-with-setter is passed, call `trans:pair' with an
  actual pair.  This fixes a long-lasting bug which prevented compilation
  of `set!' statements with procedures-with-setter (this showed up when
  compiling `(system vm assemble)').

* module/system/base/compile.scm: Added `objcode->u8vector' to the
  `#:select' clause.

* module/system/base/syntax.scm: Cosmetic changes.

* module/system/vm/assemble.scm (preprocess): Removed debugging
  statements.

* src/frames.c: Cosmetic changes.

* src/frames.h (SCM_FRAME_SET_DYNAMIC_LINK): New.

* src/objcodes.c: Use `scm_t_uint8' instead of `char' when relevant.

* src/vm.c (vm_heapify_frames_1): Use `SCM_FRAME_SET_DYNAMIC_LINK ()'.

* src/vm_loader.c: Added casts to mute GCC 4 warnings.

* testsuite/run-vm-tests.scm (*scheme*): Renamed to `%scheme'.
  (run-test-from-file): Renamed to `compile/run-test-from-file'.
  (run-vm-tests): Run each test using both the VM and the interpreter;
  compare the results.

* testsuite/t-proc-with-setter.scm: Try out `get/set'.

* doc/Makefile.am (info_TEXINFOS): New.

* doc/guile-vm.texi: Added index entries and indices.

* doc/texinfo.tex: New file.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-5

16 years agoMinor binding name clash tweak.
Ludovic Court`es [Fri, 28 Oct 2005 14:49:25 +0000 (14:49 +0000)]
Minor binding name clash tweak.

* module/system/base/compile.scm: Only import `the-vm' and `vm-load' from
  `(system vm core)'.

git-archimport-id: lcourtes@laas.fr--2004-libre/guile-vm--revival--0.6--patch-10

16 years agoStarted documenting the compiler.
Ludovic Courtes [Sat, 25 Jun 2005 06:57:20 +0000 (06:57 +0000)]
Started documenting the compiler.

* doc/guile-vm.texi:  Documented the compiler (node `The Compiler').
  Removed a number of things that might have been relevant to Guile-VM 0.0.

* module/system/il/compile.scm (optimize):  Commented out the case
  using `<ghil-inst?>'.

* src/vm_engine.c (vm_run)[objects_handle]:  New variable.
  Before leaving the function, release OBJECTS_HANDLE.

* src/vm_engine.h (CACHE_PROGRAM):  Use `scm_vector_writable_elements'
  instead of `scm_vector_elements';  don't release the handle right away.

* src/vm_loader.c (load-program):  New commented out piece of code
  dealing with simple vectors.

* src/vm_system.c (object-ref):  Added the type of OBJNUM.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-3

16 years ago* src/objcodes.c (make_objcode_by_mmap): Fixed the error type when the
Ludovic Courtes [Sat, 25 Jun 2005 03:13:56 +0000 (03:13 +0000)]
* src/objcodes.c (make_objcode_by_mmap):  Fixed the error type when the
  object file is too small.

* doc/guile-vm.texi:  Documented `make-closure'.  Improved the documentation
  of `load-program'.

* testsuite:  New directory.

* configure.in:  Added `testsuite/Makefile' to `AC_OUTPUT'.

* Makefile.am (SUBDIRS):  Added `testsuite'.

* src/vm_engine.h (VM_CHECK_OBJECT):  New option.
  (CHECK_OBJECT):  New macro.

* src/vm_system.c (object-ref):  Use VM_CHECK_OBJECT.

* module/system/vm/assemble.scm (preprocess):  Commented out the debugging
  code.

* benchmark/lib.scm (do-loop):  New procedure.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-2

16 years agoRemoved a few more deprecated function calls; documented closures.
Ludovic Courtes [Fri, 24 Jun 2005 17:25:36 +0000 (17:25 +0000)]
Removed a few more deprecated function calls;  documented closures.

* src/Makefile.am (.c.x):  Fixed the rule.

* src/envs.c:  Use `scm_hash_get_handle ()' instead of
  `scm_sym2ovcell_soft ()' and `scm_hash_create_handle_x ()' instead of
  `scm_intern_symbol ()'.

* src/objcodes.c (bytecode->objcode):  Don't use `SCM_VALIDATE_INUM', use
  `SCM_VALIDATE_NUMBER' instead.
  (make_objcode_by_mmap):  Check whether the file is smaller than the
  magic cookies; check whether the magic cookies are there.

* src/frames.c (frame-local-ref):  Likewise, but use `SCM_MAKE_VALIDATE'.
  (frame-local-set!):  Likewise.

* src/instructions.c (opcode->instruction):  Likewise.

* src/programs.c (program-external-set!):  New function.

* src/guile-disasm.in:  New file.

* src/Makefile.am:  Produce `guile-disasm'.

* doc/guile-vm.texi:  Documented `external-ref', `external-set', `local-ref'
  and `local-set'.

* module/system/vm/disasm.scm (disassemble-bytecode):  Fixed the way
  `load-program' is represented.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-1

16 years agoPlaying with the procedure call mechanism.
Ludovic Court`es [Tue, 3 May 2005 15:13:42 +0000 (15:13 +0000)]
Playing with the procedure call mechanism.

* src/objcodes.c (do-pair):  New experiment.
* src/vm_engine.h (ALIGN_AS_NON_IMMEDIATE):  New macro.
  (POP_LIST_ON_STACK):  New experimental macro.
* src/vm_engine.c (call):  In the procedure call case, I tried using the above
  macro.

git-archimport-id: lcourtes@laas.fr--2004-libre/guile-vm--revival--0.6--patch-8

16 years agoFixed a stack leak. Now observing actual performance.
Ludovic Court`es [Mon, 2 May 2005 16:32:32 +0000 (16:32 +0000)]
Fixed a stack leak.  Now observing actual performance.

* src/*.[ch]:  Replaced `scm_mem2symbol' by `scm_from_locale_symboln' and
  `scm_ulong2num' by `scm_from_ulong'.
* src/vm_system.c (tail-call):  Fixed stack leak (SP lacked decrement by
  one more Scheme object in the tail-recursive case).
* benchmark/measure.scm (measure):  Make sure we are using the compiled
  procedure (i.e. a program object) when measuring.  This yields better
  results than before.  :-)
* doc/guile-vm.texi:  Augmented the instruction set documentation with
  branch instructions, `call' and `tail-call'.

git-archimport-id: lcourtes@laas.fr--2004-libre/guile-vm--revival--0.6--patch-7

16 years agoImproved the VM's efficiency. The VM is as fast as the interpreter. :-(
Ludovic Court`es [Fri, 29 Apr 2005 14:12:12 +0000 (14:12 +0000)]
Improved the VM's efficiency.  The VM is as fast as the interpreter.  :-(

* benchmark/lib.scm:  New file.
* benchmark/measure.scm:  New file.
* README:  Added useful pointers to various threads.
* doc/guile-vm.texi:  Fixed the description of `load-program' (it now expects
  _immediate_ integers).
* src/*.[ch]:  Use immediate integers whereever possible, as in the original
  code.  For `CONS', use `scm_cell' rather than `scm_cons'.

git-archimport-id: lcourtes@laas.fr--2004-libre/guile-vm--revival--0.6--patch-6

16 years agoGot the VM up and running! Augmented the documentation.
Ludovic Court`es [Thu, 28 Apr 2005 15:45:59 +0000 (15:45 +0000)]
Got the VM up and running!  Augmented the documentation.

* src/*.[ch]:  Replaced the remaining `SCM_MAKINUM', and changed `SCM_VELTS'
  into `scm_vector_elements ()'.
* src/vm_loader.c (link):  Fixed so that it pushed a variable object on
  the stack.
* src/vm_system.c (variable-ref):  Fixed so that it uses `scm_variable_ref ()'
  and friends.
* module/system/vm/assemble.scm (dump-object!):  Fixed the string case.
* src/vm_engine.h (CONS):  Use `scm_cons' instead of `SCM_NEWCELL'.
* doc/guile-vm.texi:  Added actual instruction definitions, explanations of
  the program invocation mechanism, programs' object tables, etc., in the
  `Instruction Set' chapter.

git-archimport-id: lcourtes@laas.fr--2004-libre/guile-vm--revival--0.6--patch-5

16 years agoFixed the compiler, got the disassembler working.
Ludovic Court`es [Wed, 27 Apr 2005 09:36:52 +0000 (09:36 +0000)]
Fixed the compiler, got the disassembler working.

* doc/guile-vm.texi:  Texified and cleaned up.
* src/vm.c:  Use `scm_from_locale_string ()' instead of `scm_makfrom0str ()'.
* src/vm_engine.c:  Likewise.
* src/programs.c (scm_program_bytecode):  Return a u8vector instead of a string.
* module/system/vm/conv.scm (make-byte-decoder):  Fixed a few things wrt. to
  the string to u8vector transition.
* src/objcodes.c (bytecode->objcode):  Fixed a bug where the last 10 bytes of
  the bytecode where ignored.
* module/system/vm/assemble.scm (dump-object!):  Don't convert everything
  to a u8vector, keep strings where it makes sense.
* module/system/vm/conv.scm (code->bytes):  Accordingly, convert strings to
  u8vectors when needed.
  (make-byte-decoder):  Accordingly too, when decoding instructions, return
  variable-length instructions' argument as strings except for `load-program'.
* module/system/vm/disasm.scm:  Export `disassemble-bytecode'.

git-archimport-id: lcourtes@laas.fr--2004-libre/guile-vm--revival--0.6--patch-4

16 years agoUpdated the assembly process so that `u8vectors' are used. Compilation works.
Ludovic Court`es [Mon, 25 Apr 2005 16:56:18 +0000 (16:56 +0000)]
Updated the assembly process so that `u8vectors' are used.  Compilation works.

* module/system/vm/conv.scm (encode-length):  Use u8vectors.
  (code->bytes):  Likewise.
* module/system/vm/assemble.scm (codegen):  Use u8vectors instead
  of strings.
* src/objcodes.c (objcode->string):  Removed.
  (objcode->u8vector):  New function.
* module/system/base/compile.scm (compile-file):  Use `objcode->u8vector'
  and `uniform-vector-write'.

git-archimport-id: lcourtes@laas.fr--2004-libre/guile-vm--revival--0.6--patch-3

16 years agoTranslation from Scheme to GHIL, and compilation to GLIL work.
Ludovic Court`es [Fri, 22 Apr 2005 16:00:33 +0000 (16:00 +0000)]
Translation from Scheme to GHIL, and compilation to GLIL work.

* src/*.c:  Removed calls to `scm_must_malloc', `SCM_MUST_MALLOC' and
  `scm_must_free'.  Same for `SCM_INUMP', `SCM_INUM', `SCM_STRING_CHARS',
  and the likes.
* module/system/base/syntax.scm:  Do not import `(ice-9 match)' and do
  not re-export `match', do not export `syntax-error' which was not
  defined here.
* module/system/base/compile.scm (call-with-compile-error-catch):  Use
  the `catch' form instead of `try'.
* src/instructions.c:  Use `scm_from_char ()' instead of the deprecated
  macro `SCM_MAKINUM ()'.
* src/instructions.h (scm_instruction):  Made `npop' a signed char.

git-archimport-id: lcourtes@laas.fr--2004-libre/guile-vm--revival--0.6--patch-2

16 years agoUpdated the C code base so that it compiles with Guile 1.7.2.
Ludovic Court`es [Fri, 22 Apr 2005 11:07:06 +0000 (11:07 +0000)]
Updated the C code base so that it compiles with Guile 1.7.2.

* src/*.[ch]:  Introduced changes so that it compiles with Guile 1.7.2.

git-archimport-id: lcourtes@laas.fr--2004-libre/guile-vm--revival--0.6--patch-1

16 years agoFix inline machinery in C99 mode on MacOS X.
Ludovic Courtès [Thu, 10 Apr 2008 21:57:05 +0000 (23:57 +0200)]
Fix inline machinery in C99 mode on MacOS X.