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

252 commits

Author SHA1 Message Date
Andy Wingo
22bcbe8cc9 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.
2008-05-25 13:13:15 +02:00
Andy Wingo
51f6b8f377 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.
2008-05-20 12:54:14 +02:00
Andy Wingo
d79d908ef0 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!
2008-05-20 11:33:28 +02:00
Andy Wingo
1b8abe5514 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.
2008-05-19 12:57:48 +02:00
Andy Wingo
8f43eb2b42 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!
2008-05-19 10:38:18 +02:00
Andy Wingo
7f52f9e3b4 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.
2008-05-15 18:57:33 +02:00
Andy Wingo
cd702346f2 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'.
2008-05-15 18:48:22 +02:00
Andy Wingo
10be70254b 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.
2008-05-15 12:20:18 +02:00
Andy Wingo
7d1c45d38e 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.
2008-05-14 14:47:29 +02:00
Andy Wingo
83dff6e55f 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.
2008-05-13 00:07:40 +02:00
Andy Wingo
db917b4152 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.
2008-05-12 22:26:31 +02:00
Andy Wingo
77046be3d3 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.
2008-05-11 22:00:34 +02:00
Andy Wingo
01967b694c <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.
2008-05-11 21:48:10 +02:00
Andy Wingo
f540e3271b 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.
2008-05-04 17:25:13 +02:00
Andy Wingo
a27bf0b7f6 Removed dot-expander syntax foo
* module/system/base/syntax.scm (expand-dot!, expand-symbol, syntax):
  Removed, we don't use this syntax any more.
2008-05-04 16:26:56 +02:00
Andy Wingo
44f38a1f36 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.
2008-05-04 16:25:36 +02:00
Andy Wingo
ce0925e14e more dedottification, almost done
* module/system/repl/common.scm:
* module/system/base/compile.scm: Export some more things.

* module/system/repl/command.scm: Dedottify.
2008-05-04 16:12:36 +02:00
Andy Wingo
61dc81d993 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
  cb4cca12e7. 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.
2008-05-04 15:37:54 +02:00
Andy Wingo
bdaffda2c4 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.
2008-05-04 13:54:41 +02:00
Andy Wingo
f245e62cf8 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.
2008-05-04 13:26:00 +02:00
Andy Wingo
23d43503d1 bugfix to make-cenv
* module/system/base/compile.scm (make-cenv): Fix make-cenv.
2008-05-03 19:38:10 +02:00
Andy Wingo
e9b8c501d6 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.
2008-05-03 19:23:45 +02:00
Andy Wingo
67169b2960 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.
2008-05-03 18:47:05 +02:00
Andy Wingo
849cefacf1 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.
2008-05-03 18:32:46 +02:00
Andy Wingo
1aa0dd2b45 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.
2008-05-03 14:52:36 +02:00
Andy Wingo
7ef8d0a008 fix to (system base syntax)'s syntax
* module/system/base/syntax.scm: Fix define-module
2008-05-03 14:00:45 +02:00
Andy Wingo
b816304293 rebase record-case on `match'
* module/system/base/syntax.scm (record-case): Rebase on `match', for
  transition purposes.
2008-05-03 13:55:33 +02:00
Andy Wingo
be4efc52d2 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...)).
2008-05-03 13:46:56 +02:00
Andy Wingo
063fd30bbe 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*.
2008-05-02 18:59:04 +02:00
Andy Wingo
0a8a9780b8 remove module.scm
* module/system/base/module.scm: Removed module.scm, as it was unused
  (see 9419ff9ae9).
2008-05-02 17:51:34 +02:00
Andy Wingo
6649bc0436 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.
2008-05-02 17:35:25 +02:00
Ludovic Courtes
2335fb97dc 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
2008-04-25 19:09:30 +02:00
Ludovic Courtes
48302624d9 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
2008-04-25 19:09:30 +02:00
Ludovic Courtes
884d46de23 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
2008-04-25 19:09:30 +02:00
Ludovic Courtes
b6368dbbb9 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
2008-04-25 19:09:30 +02:00
Ludovic Court`es
49edef60dc 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
2008-04-25 19:09:30 +02:00
Ludovic Court`es
054599f117 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
2008-04-25 19:09:29 +02:00
Ludovic Court`es
d8eeb67c89 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
2008-04-25 19:09:29 +02:00
Keisuke Nishida
7a0d0cee1f *** empty log message *** 2001-05-02 15:05:05 +00:00
Keisuke Nishida
abaca96059 *** empty log message *** 2001-04-25 07:42:32 +00:00
Keisuke Nishida
ac99cb0cb1 *** empty log message *** 2001-04-22 02:13:48 +00:00
Keisuke Nishida
f21dfea659 *** empty log message *** 2001-04-19 03:09:27 +00:00
Keisuke Nishida
8f5cfc810f *** empty log message *** 2001-04-16 03:43:48 +00:00
Keisuke Nishida
cb4cca12e7 *** empty log message *** 2001-04-15 15:02:41 +00:00
Keisuke Nishida
58995613d9 *** empty log message *** 2001-04-09 01:50:48 +00:00
Keisuke Nishida
3616e9e963 *** empty log message *** 2001-04-07 09:39:38 +00:00
Keisuke Nishida
46cd9a346f *** empty log message *** 2001-04-05 05:48:59 +00:00
Keisuke Nishida
9419ff9ae9 Don't use module.scm. 2001-04-04 20:23:13 +00:00
Keisuke Nishida
9d3903dbed *** empty log message *** 2001-04-04 20:14:34 +00:00
Keisuke Nishida
d4ae3ae6fa Better current module system support. 2001-04-04 19:58:40 +00:00