bpt/guile.git
14 years agoUse Gnulib's `lib-symbol-versions' module.
Ludovic Courtès [Sun, 9 Aug 2009 21:05:37 +0000 (23:05 +0200)]
Use Gnulib's `lib-symbol-versions' module.

* m4/gnulib-cache.m4: Add `lib-symbol-versions'.

14 years agoRemove bogus `configure' test for GNU libunistring.
Ludovic Courtès [Sun, 9 Aug 2009 18:21:41 +0000 (20:21 +0200)]
Remove bogus `configure' test for GNU libunistring.

* configure.ac: Remove explicit test for libunistring, which conflicted
  with Gnulib's own test.  This fixes commit
  f4863880f5ef539cb545999c19b6b5c0eec9382d.

14 years agoMerge commit 'origin/master'
Michael Gran [Sat, 8 Aug 2009 09:35:08 +0000 (02:35 -0700)]
Merge commit 'origin/master'

14 years agoAdd Unicode strings and symbols
Michael Gran [Sat, 8 Aug 2009 09:35:00 +0000 (02:35 -0700)]
Add Unicode strings and symbols

This adds full Unicode strings as a datatype, and it adds some
minimal functionality.  The terminal and port encoding is assumed
to be ISO-8859-1.  Non-ISO-8859-1 characters are written or
input as string character escapes.

The string character escapes now have 3 forms: \xXX \uXXXX and
\UXXXXXX, for unprintable characters that have 2, 4 or 6 hex digits.

The process for writing to strings has been modified.  There is now a
function scm_i_string_start_writing that does the copy-on-write
conversion if necessary.

To compile strings that may be wide, the VM storage of strings and
string-likes has changed.

Most string-using functions have not yet been updated and may break
when used with wide strings.

        * module/language/assembly/compile-bytecode.scm (write-bytecode):
        use variable width string bytecode format

        * module/language/assembly.scm (byte-length): use variable width
        bytecode format

        * libguile/vm-i-loader.c (load-string, load-symbol):
        (load-keyword, define): use variable-width bytecode format

        * libguile/vm-engine.h (FETCH_WIDTH): new macro

        * libguile/strings.h: new declarations

        * libguile/strings.c (make_wide_stringbuf): new function
        (widen_stringbuf): new function
        (scm_i_make_wide_string): new function
        (scm_i_is_narrow_string): new function
        (scm_i_string_wide_chars): new function
        (scm_i_string_start_writing): new function
        (scm_i_string_ref): new function
        (scm_i_string_set_x): new function
        (scm_i_is_narrow_symbol): new function
        (scm_i_symbol_wide_chars, scm_i_symbol_ref): new function
        (scm_string_width): new function
        (unistring_escapes_to_guile_escapes): new function
        (scm_to_stringn): new function
        (scm_i_stringbuf_free): modify for wide strings
        (scm_i_substring_copy): modify for wide strings
        (scm_i_string_chars, scm_string_append): modify for wide strings
        (scm_i_make_symbol, scm_to_locale_stringn): modify for wide strings
        (scm_string_dump, scm_symbol_dump, scm_to_locale_stringbuf):
        (scm_string, scm_i_deprecated_string_chars): modify for wide strings
        (scm_from_locale_string, scm_from_locale_stringn): add null test

        * libguile/srfi-13.c: add calls for scm_i_string_start_writing for
        each call of scm_i_string_stop_writing
        (scm_string_for_each): modify for wide strings

        * libguile/socket.c: add calls for scm_i_string_start_writing for each
        call of scm_i_string_stop_writing

        * libguile/rw.c: add calls for scm_i_string_start_writing for each
        call of scm_i_string_stop_writing

        * libguile/read.c (scm_read_string): allow reading of wide strings

        * libguile/print.h: add declaration for scm_charprint

        * libguile/print.c (iprin1): print wide strings and add new string
        escapes
        (scm_charprint): new function

        * libguile/ports.h: new declarations for scm_lfwrite_substr and
        scm_lfwrite_str

        * libguile/ports.c (update_port_lf): new function
        (scm_lfwrite): use update_port_lf
        (scm_lfwrite_substr): new function
        (scm_lfwrite_str): new function

        * test-suite/tests/asm-to-bytecode.test ("compiler"): add string
        width byte to sting-like asm tests

14 years agolambda, the ultimate goto
Andy Wingo [Fri, 7 Aug 2009 17:06:15 +0000 (19:06 +0200)]
lambda, the ultimate goto

* module/language/tree-il/analyze.scm (analyze-lexicals): Rework to
  actually determine when a fixed-point procedure may be allocated as a
  label.
* module/language/tree-il/compile-glil.scm (emit-bindings): Always emit
  a <glil-bind>. Otherwise it's too hard to pair with unbindings.
  (flatten-lambda): Consequently, here we only `bind' if there are any
  vars to bind. This doesn't make any difference, given that lambdas
  don't have trailing unbind instructions, but it does keep the GLIL
  output the same for thunks -- no extraneous (bind) instructions. Keeps
  tree-il.test happy.
  (flatten): Some bugfixes. Yaaay, it works!!!

14 years agoimplement compilation of label-allocated lambda expressions
Andy Wingo [Fri, 7 Aug 2009 15:44:02 +0000 (17:44 +0200)]
implement compilation of label-allocated lambda expressions

* module/language/tree-il/compile-glil.scm (flatten-lambda, flatten):
  Implement compilation of label-allocated lambda expressions. Quite
  tricky, we'll see if this works when the new analyzer lands.

14 years agoadd label alist to lambda allocations in tree-il->glil compiler
Andy Wingo [Fri, 7 Aug 2009 13:35:53 +0000 (15:35 +0200)]
add label alist to lambda allocations in tree-il->glil compiler

* module/language/tree-il/analyze.scm: Add some more comments about
  something that will land in a future commit: compiling fixpoint
  lambdas as labels.
  (analyze-lexicals): Reorder a bit, and add a label alist to procedure
  allocations. Empty for now.

* module/language/tree-il/compile-glil.scm (flatten): Adapt to the free
  variables being in the cddr of the allocation, not the cdr.

14 years agoloop detection in the house
Andy Wingo [Thu, 6 Aug 2009 15:46:38 +0000 (17:46 +0200)]
loop detection in the house

* libguile/vm-i-scheme.c (vector-ref, vector-set): Sync registers if we
  call out to C.

* module/language/tree-il/compile-glil.scm (flatten-lambda): Add an
  extra argument, the self-label, which should be the gensym under which
  the procedure is bound in a <fix> expression.
  (flatten): If we see a call to a lexical ref to the self-label in a
  tail position, rename and goto instead of goto/args, which will tear
  down the frame -- or will, in the future. It's a primitive form of
  loop detection.

* module/language/tree-il/primitives.scm (zero?): Expand to (= x 0).

14 years agoactually implement "fixing letrec"
Andy Wingo [Thu, 6 Aug 2009 14:01:24 +0000 (16:01 +0200)]
actually implement "fixing letrec"

* module/Makefile.am (SOURCES): Reorganize so GHIL is compiled last,
  along with ecmascript.

* module/language/scheme/spec.scm: Remove references to GHIL, as it's
  bitrotten and obsolete..

* module/language/tree-il.scm (make-tree-il-folder): Rework so that we
  only have down and up procs, and call down and up on each element.
* module/language/tree-il/analyze.scm (analyze-lexicals): Fix a thinko
  handling let-values.

* module/language/tree-il/fix-letrec.scm: Actually implement fixing
  letrec. The resulting code will perform better, but violations of the
  letrec restriction are not detected. This behavior is allowed by the
  spec, but it is undesirable. Perhaps that will be fixed later.

* module/language/tree-il/inline.scm (inline!): Fix a case in which
  ((lambda args foo)) would be erroneously inlined to foo. Remove empty
  let, letrec, and fix statements.

* module/language/tree-il/primitives.scm (effect-free-primitive?): New
  public predicate.

14 years agoactually inline call-with-values to tree-il's <let-values>
Andy Wingo [Thu, 6 Aug 2009 09:48:16 +0000 (11:48 +0200)]
actually inline call-with-values to tree-il's <let-values>

* module/srfi/srfi-11.scm (let-values): In the one-clause case, avoid
  going through temporary variables.

* module/language/tree-il/inline.scm (inline!): Add another case:
  (call-with-values (lambda () ...) (lambda ... ...) -> let-values.

* module/language/tree-il/compile-glil.scm (flatten): Fix a bug
  compiling applications in "vals" context.

* module/language/tree-il/analyze.scm (analyze-lexicals): Fix a couple
  bugs with let-values and rest arguments.

14 years agolet-values in terms of syntax-case, add make-tree-il-folder
Andy Wingo [Wed, 5 Aug 2009 19:25:35 +0000 (21:25 +0200)]
let-values in terms of syntax-case, add make-tree-il-folder

* module/language/tree-il.scm (tree-il-fold): Fix for let-values case.
  (make-tree-il-folder): New public macro, makes a multi-valued folder
  specific to the number of seeds that the user wants.
* module/language/tree-il/optimize.scm (optimize!): Reverse the order of
  inline! and fix-letrec!, as the latter might expose opportunities for
  the former.
* module/srfi/srfi-11.scm (let-values): Reimplement in terms of
  syntax-case, so that its expressions may reference hygienically bound
  variables. See the NEWS for the rationale.
  (let*-values): An empty let*-values still introduces a local `let'
  binding contour.
* module/system/base/syntax.scm (record-case): Yukkkk. Reimplement in
  terms of syntax-case. Ug-ly, but see the NEWS again: "Lexical bindings
  introduced by hygienic macros may not be referenced by nonhygienic
  macros."

14 years agoadd <fix> tree-il construct, and compile it
Andy Wingo [Wed, 5 Aug 2009 15:51:40 +0000 (17:51 +0200)]
add <fix> tree-il construct, and compile it

* libguile/vm-i-system.c (fix-closure): New instruction, for wiring
  together fixpoint procedures.

* module/Makefile.am (TREE_IL_LANG_SOURCES): Add fix-letrec.scm.

* module/language/glil/compile-assembly.scm (glil->assembly): Reindent
  the <glil-lexical> case, and handle 'fix for locally-bound vars.

* module/language/tree-il.scm (<fix>): Add the <fix> tree-il type and
  accessors, for fixed-point bindings. This IL construct is taken from
  the Waddell paper.
  (parse-tree-il, unparse-tree-il, tree-il->scheme, tree-il-fold)
  (pre-order!, post-order!): Update for <fix>.

* module/language/tree-il/analyze.scm (analyze-lexicals): Update for
  <fix>. The difference here is that the bindings may not be assigned,
  and are not marked as such. They are not boxed.
  (report-unused-variables): Update for <fix>.

* module/language/tree-il/compile-glil.scm (flatten): Compile <fix> to
  GLIL.

* module/language/tree-il/fix-letrec.scm: A stub implementation of
  fixing letrec -- will flesh out in a separate commit.

* module/language/tree-il/inline.scm: Fix license, it was mistakenly
  added with LGPL v2.1+.

* module/language/tree-il/optimize.scm (optimize!): Run the fix-letrec!
  pass.

14 years agoadd a brain-dead inliner
Andy Wingo [Wed, 5 Aug 2009 14:17:20 +0000 (16:17 +0200)]
add a brain-dead inliner

* module/Makefile.am (TREE_IL_LANG_SOURCES):
* module/language/tree-il/inline.scm: Add a brain-dead inliner, to
  inline ((lambda () x)) => x.

* module/language/tree-il/optimize.scm (optimize!): Invoke the inliner.

14 years agoadd1 and sub1 instructions
Andy Wingo [Wed, 5 Aug 2009 09:55:42 +0000 (11:55 +0200)]
add1 and sub1 instructions

* libguile/vm-i-scheme.c: Add add1 and sub1 instructions.
* module/language/tree-il/compile-glil.scm: Compile 1+ and 1- to add1
  and sub1.

* module/language/tree-il/primitives.scm (define-primitive-expander):
  Add support for `if' statements in the consequent.
  (+, -): Compile (- x 1), (+ x 1), and (+ 1 x) to 1- or 1+ as
  appropriate.
  (1-): Remove this one. Seems we forgot 1+ before, but we weren't
  compiling it nicely anyway.

* test-suite/tests/tree-il.test ("void"): Fix expected compilation of (+
  (void) 1) to allow for add1.

14 years agoperform gmp/unistring compile checks with AC_LIB_HAVE_LINKFLAGS
Andy Wingo [Tue, 4 Aug 2009 19:16:32 +0000 (21:16 +0200)]
perform gmp/unistring compile checks with AC_LIB_HAVE_LINKFLAGS

* configure.ac: Rework gmp and unistring checks to use
  AC_LIB_HAVE_LINKFLAGS, so that the compilation checks run with the
  right -L/-l flags.

* libguile/Makefile.am (libguile_la_LIBADD): Adapt to need to add
  $(LIBGMP) and $(LIBUNISTRING) here.

Hopefully this solves
http://article.gmane.org/gmane.lisp.guile.bugs/4288.

14 years agorename configure.in to configure.ac
Andy Wingo [Tue, 4 Aug 2009 18:46:20 +0000 (20:46 +0200)]
rename configure.in to configure.ac

* configure.ac:
* guile-readline/configure.ac: Rename from configure.in, as recommended
  by the autoconf manual.

14 years agofix buffer overrun reading partial numbers: 1.0f, 1.0/, and 1.0+
Andy Wingo [Tue, 4 Aug 2009 18:29:09 +0000 (20:29 +0200)]
fix buffer overrun reading partial numbers: 1.0f, 1.0/, and 1.0+

* libguile/numbers.c (mem2decimal_from_point, mem2ureal, mem2complex):
  Fix a number of cases where, for invalid numbers, we could read past
  the end of the buffer. This happened in e.g. "1.0+", "1/" and "1.0f".
  But I couldn't figure out how to test for these, given that the
  behavior depended on the contents of uninitialized memory in the
  reader buffer. We'll just have to be happy with this.

Thanks to Kjetil S. Matheussen for the report.

14 years agoDon't doubly define scm_t_wchar
Michael Gran [Sat, 1 Aug 2009 18:21:46 +0000 (11:21 -0700)]
Don't doubly define scm_t_wchar

        * libguile/chars.h: don't define scm_t_wchar
        * libguile/numbers.h: define scm_t_wchar here

14 years agoFix coding style compliance for recent 32-bit char changes
Michael Gran [Sat, 1 Aug 2009 18:04:43 +0000 (11:04 -0700)]
Fix coding style compliance for recent 32-bit char changes

        * libguile/print.c (iprin1): extra braces

        * libguile/chars.h (SCM_IS_UNICODE_CHAR): coding style

14 years agoDon't use GNU extensions for SCM_MAKE_CHAR macro
Michael Gran [Sat, 1 Aug 2009 17:15:20 +0000 (10:15 -0700)]
Don't use GNU extensions for SCM_MAKE_CHAR macro

Since the contents of SCM_MAKE_CHAR are evaluated more than once,
don't use it in situations where this could cause side-effects.

        * libguile/vm-i-system.c (make-char8): avoid side-effects with
        SCM_MAKE_CHAR call

        * libguile/chars.h (SCM_MAKE_CHAR): modified

14 years agoMake charname declarations module-level and GCS
Michael Gran [Sat, 1 Aug 2009 15:12:15 +0000 (08:12 -0700)]
Make charname declarations module-level and GCS

Charname array declarations are corrected for style and
are made module-level.  Array list length variables are
replaced with macros.

        * libguile/chars.c: variable declaration fixes

14 years agoUpdate NEWS for charname changes
Michael Gran [Sat, 1 Aug 2009 15:05:55 +0000 (08:05 -0700)]
Update NEWS for charname changes

        * NEWS: updated

14 years agoAdd unused variable analysis in the tree-il->glil compiler.
Ludovic Courtès [Thu, 30 Jul 2009 22:42:58 +0000 (00:42 +0200)]
Add unused variable analysis in the tree-il->glil compiler.

* module/language/tree-il/analyze.scm (<binding-info>): New record type.
  (report-unused-variables): New procedure.

* module/language/tree-il/compile-glil.scm (%warning-passes): New
  variable.
  (compile-glil): Honor `#:warnings' from OPTS.

* test-suite/tests/tree-il.test (call-with-warnings): New procedure.
  (%opts-w-unused): New variable.
  ("warnings"): New test prefix.

14 years agoAdd `(system base message)', a simple warning framework.
Ludovic Courtès [Thu, 30 Jul 2009 22:06:59 +0000 (00:06 +0200)]
Add `(system base message)', a simple warning framework.

* module/Makefile.am (SOURCES): Add `system/base/message.scm'.

* module/scripts/compile.scm (%options): Add `--warn'.
  (parse-args): Update default value for `warnings'.
  (show-warning-help): New procedure.
  (compile)[compile-opts]: Add `#:warnings'.
  Update help message.

* module/system/base/compile.scm (compile): Sanity-check the requested
  warnings.

* module/system/base/message.scm: New file.

14 years agoAdd `tree-il-fold', a purely functional iterator on `tree-il'.
Ludovic Courtès [Wed, 29 Jul 2009 22:48:04 +0000 (00:48 +0200)]
Add `tree-il-fold', a purely functional iterator on `tree-il'.

* module/language/tree-il.scm (tree-il-fold): New procedure.

* test-suite/tests/tree-il.test ("tree-il-fold"): New test prefix.

14 years agoAdd 32-bit characters
Michael Gran [Wed, 29 Jul 2009 13:38:32 +0000 (06:38 -0700)]
Add 32-bit characters

This adds the 32-bit standalone characters.  Strings are still
8-bit.  Characters larger than 8-bit can only be entered or
displayed in octal format at this point.  At this point, the
terminal's display encoding is expected to be Latin-1.

        * module/language/assembly/compile-bytecode.scm (write-bytecode):
        add 32-bit char

        * module/language/assembly.scm (object->assembly): add 32-bit char
        (assembly->object): add 32-bit char

        * libguile/vm-i-system.c (make-char32): new op

        * libguile/print.c (iprin1): print 32-bit char

        * libguile/numbers.h: add type scm_t_wchar

        * libguile/numbers.c: add type scm_t_wchar

        * libguile/chars.h: new type scm_t_wchar
        (SCM_CODEPOINT_MAX): new
        (SCM_IS_UNICODE_CHAR): new
        (SCM_MAKE_CHAR): operate on 32-bit char

        * libguile/chars.c: comparison operators now use Unicode
        codepoints
        (scm_c_upcase): now receives and returns scm_t_wchar
        (scm_c_downcase): now receives and returns scm_t_wchar

14 years agoReplace global charnames variables with accessors
Michael Gran [Tue, 28 Jul 2009 04:02:23 +0000 (21:02 -0700)]
Replace global charnames variables with accessors

The global variables scm_charnames and scm_charnums are replaced with
the accessor functions scm_i_charname and scm_i_charname_to_num.
Also, the incomplete and broken EBCDIC support is removed.

       * libguile/print.c (iprin1): use new func scm_i_charname

        * libguile/read.c (scm_read_character): use new func
        scm_i_charname_to_num

        * libguile/chars.c (scm_i_charname): new function
        (scm_i_charname_to_char): new function
        (scm_charnames, scm_charnums): removed

        * libguile/chars.h: new declarations

14 years agoincrease range of relative jumps by aligning blocks to 8-byte boundaries
Andy Wingo [Sun, 26 Jul 2009 12:01:56 +0000 (14:01 +0200)]
increase range of relative jumps by aligning blocks to 8-byte boundaries

* libguile/objcodes.c (OBJCODE_COOKIE): Bump again, as our jump offsets
  are now multiplied by 8.

* libguile/vm-i-system.c (BR): Interpret the 16-bit offset as a relative
  jump to the nearest 8-byte-aligned block -- increasing relative jump
  range from +/-32K to +/-240K.
  (mvra): Do the same for the mvra jump.

* libguile/vm.c (really_make_boot_program): Align the mvra.

* module/language/assembly.scm (align-block): New export, for aligning
  blocks.

* module/language/assembly/compile-bytecode.scm (write-bytecode): Emit
  jumps to the nearest 8-byte-aligned block. Effectively our range is 18
  bits in either direction. I would like to do this differently -- have
  long-br and long-br-if, and all the other br instructions go to 8 bits
  only. But the assembler doesn't have an appropriate representation to
  allow me to do this yet, so for now this is what we have.

* module/language/assembly/decompile-bytecode.scm (decode-load-program):
  Decode the 19-bit jumps.

14 years agomake sure all programs are 8-byte aligned
Andy Wingo [Sun, 26 Jul 2009 10:56:11 +0000 (12:56 +0200)]
make sure all programs are 8-byte aligned

* libguile/objcodes.c (OBJCODE_COOKIE): Bump objcode cookie, as we added
  to struct scm_objcode.
* libguile/objcodes.h (struct scm_objcode): Add a uint32 after metalen
  and before base, so that if the structure has 8-byte alignment, base
  will have 8-byte alignment too. (Before, base was 12 bytes from the
  start of the structure, now it's 16 bytes.)

* libguile/vm-engine.h (ASSERT_ALIGNED_PROCEDURE): Add a check that can
  be turned on with VM_ENABLE_PARANOID_ASSERTIONS.
  (CACHE_PROGRAM): Call ASSERT_ALIGNED_PROCEDURE.

* libguile/vm-i-system.c (long-local-ref): Add a missing semicolon.

* libguile/vm.c (really_make_boot_program): Rework to operate directly
  on a malloc'd buffer, so that the program will be 8-byte aligned.

* module/language/assembly.scm (*program-header-len*): Add another 4 for
  the padding.
  (object->assembly): Fix case in which we would return (make-int8 0)
  instead of (make-int8:0). This would throw off compile-assembly.scm's
  use of addr+.

* module/language/assembly/compile-bytecode.scm (write-bytecode): Write
  out the padding int.

* module/language/assembly/decompile-bytecode.scm (decode-load-program):
  And pop off the padding int too.

* module/language/glil/compile-assembly.scm (glil->assembly): Don't pack
  the assembly, assume that assembly.scm has done it for us. If a
  program has a meta, pad out the program so that meta will be aligned.

* test-suite/tests/asm-to-bytecode.test: Adapt to expect programs to
  have the extra 4-byte padding int.

14 years agofix alignment of subprograms of subprograms
Andy Wingo [Sun, 26 Jul 2009 09:54:05 +0000 (11:54 +0200)]
fix alignment of subprograms of subprograms

* module/language/glil/compile-assembly.scm (glil->assembly)
  (dump-object): Fix an exciting bug! Subprograms of subprograms were
  not being aligned correctly, because the code was generated too early.
  So instead delay dumping the object table until the proper time.

14 years agofix unused SCM_FRAME_SET_DYNAMIC_LINK macro
Andy Wingo [Sun, 26 Jul 2009 09:21:18 +0000 (11:21 +0200)]
fix unused SCM_FRAME_SET_DYNAMIC_LINK macro

* libguile/frames.h (SCM_FRAME_SET_DYNAMIC_LINK): Fix for new stack
  layout, though this macro is not used.

14 years agofix vmstack gdb macro for new stack frame layout
Andy Wingo [Sun, 26 Jul 2009 09:20:39 +0000 (11:20 +0200)]
fix vmstack gdb macro for new stack frame layout

* gdbinit (vmstack): No more external link.

14 years agocheck that jumps are within the range of a signed 16-bit int
Andy Wingo [Fri, 24 Jul 2009 10:06:40 +0000 (12:06 +0200)]
check that jumps are within the range of a signed 16-bit int

* module/language/assembly/compile-bytecode.scm (write-bytecode): Check
  that the offset is within the range of a signed int16 value.

14 years agofix gensym creation in psyntax
Andy Wingo [Fri, 24 Jul 2009 10:06:19 +0000 (12:06 +0200)]
fix gensym creation in psyntax

* module/ice-9/psyntax.scm (build-lexical-var): Make our gensyms really
  unique. Before, there was a chance that different lexicals could
  result in the same gensym.
* module/ice-9/psyntax-pp.scm: Regenerate.

14 years agoincrease default stack size to 64 kilowords
Andy Wingo [Fri, 24 Jul 2009 10:05:54 +0000 (12:05 +0200)]
increase default stack size to 64 kilowords

* libguile/vm.c (VM_DEFAULT_STACK_SIZE): Increase to 64 kilowords.
  Really, we should simply add overflow handlers, but in the meantime,
  this will do.

14 years agocompiler support for nlocs >= 256
Andy Wingo [Fri, 24 Jul 2009 09:00:32 +0000 (11:00 +0200)]
compiler support for nlocs >= 256

* libguile/vm-i-system.c (long-local-ref, long-local-set)
  (make-variable): New intructions, for handling nlocs >= 256.
* module/language/glil/compile-assembly.scm (glil->assembly): Compile
  <glil-lexical> with support for nlocs >= 256.

14 years agonlocs is now 16 bits wide
Andy Wingo [Fri, 24 Jul 2009 08:12:01 +0000 (10:12 +0200)]
nlocs is now 16 bits wide

* libguile/objcodes.h (struct scm_objcode): Remove the "unused" field --
  the old "nexts" -- and expand nlocs to 16 bits.

* module/language/assembly/compile-bytecode.scm (write-bytecode): Write
  the nlocs as a uint16.

* module/language/assembly/decompile-bytecode.scm (decode-load-program):
  Decompile 16-bit nlocs. It seems this decompilation is little-endian
  :-/

* test-suite/tests/asm-to-bytecode.test: Fix up to understand nlocs as a
  little-endian value. The test does the right thing regarding
  endianness.

14 years agoremove all mentions of "external" from the compiler and related code
Andy Wingo [Thu, 23 Jul 2009 14:50:47 +0000 (16:50 +0200)]
remove all mentions of "external" from the compiler and related code

With this, GHIL is effectively bitrotten. I need to port the ECMAScript
compiler to tree-il, then I'll remove it.

* 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):
  (disassemble-free-vars, code-annotation):
* module/language/glil.scm (<glil-program>, <glil-local>)
  (<glil-exteral>, parse-glil, unparse-glil):
* module/language/glil/compile-assembly.scm (make-meta):
  (compile-assembly, glil->assembly):
* module/language/glil/decompile-assembly.scm (decompile-toplevel):
  (decompile-load-program):
* module/language/objcode/spec.scm (decompile-value):
* module/language/tree-il/compile-glil.scm (flatten-lambda):
* module/system/vm/frame.scm (frame-binding-ref):
  (frame-binding-set!):
* module/system/vm/program.scm (binding:boxed?):
* module/system/vm/trace.scm (trace-next):
* test-suite/tests/asm-to-bytecode.test ("compiler"):
* test-suite/tests/tree-il.test: Remove all mentions of "external", and
  of <glil-local>. Docs updates will come soon.

14 years agorename "closure-ref" to "free-ref"; s/vars/variables/ in some names
Andy Wingo [Thu, 23 Jul 2009 12:36:22 +0000 (14:36 +0200)]
rename "closure-ref" to "free-ref"; s/vars/variables/ in some names

* libguile/programs.h:
* libguile/programs.c: (SCM_PROGRAM_FREE_VARIABLES): Rename from
  SCM_PROGRAM_FREE_VARS. Callers changed.
* libguile/programs.c (scm_make_program): Rename arg to
  "free_variables".
  (scm_program_free_variables): Rename from program-free-vars.

* libguile/vm-engine.h:
* libguile/vm-engine.c (VM_CHECK_FREE_VARIABLES): Rename from
  VM_CHECK_CLOSURE.
  (vm_engine, CACHE_PROGRAM): Rename closure and closure_count to free_vars and
  free_vars_vount.

* libguile/vm-i-system.c (FREE_VARIABLE_REF): Rename from CLOSURE_REF.
  (free-ref, free-boxed-ref, free-boxed-set): Rename from closure-ref,
  closure-boxed-ref, closure-boxed-set.
  (make-closure): Renamed from make-closure2.

* module/language/glil/compile-assembly.scm (glil->assembly): Hack to
  never write out the the old "make-closure" instruction. Will fix
  better later. Change to emit free-ref etc instead of closure-ref.

* module/language/tree-il/compile-glil.scm (flatten): Emit make-closure
  instead of make-closure2, now that the old make-closure is gone.

* module/system/vm/program.scm (system): Rename program-free-vars to
  program-free-variables.

* test-suite/tests/tree-il.test ("lambda"): Update for make-closure.

14 years agoremove "externals" from the vm
Andy Wingo [Thu, 23 Jul 2009 15:12:10 +0000 (17:12 +0200)]
remove "externals" from the vm

* libguile/frames.c (scm_frame_external_link): Removed.
* libguile/frames.h: No need to have the "external link" in the stack
  frame -- update macros to take the new situation into account.

* libguile/objcodes.h (struct scm_objcode): Rename the nexts field to
  "unused". In the future we can use it for nlocs, I think.
  (SCM_OBJCODE_NEXTS): removed.

* libguile/programs.h:
* libguile/programs.c (scm_make_program): Expect the third argument to
  be a vector of free variables, not a list of free variables.
  SCM_BOOL_F indicates no free variables, not SCM_EOL.
  (program_mark): Adapt.
  (scm_program_arity): No more nexts.
  (scm_program_free_vars): Replaces scm_program_externals.

* libguile/vm-engine.c (VM_CHECK_EXTERNAL)
  (vm_engine): No need for the "external" var.
* libguile/vm-engine.h (CACHE_PROGRAM): Update for SCM_PROGRAM_FREE_VARS
  instead of SCM_PROGRAM_EXTERNALS.
  (NEW_FRAME): Update for new frame size, and no need to cons up
  externals. Yay :)

* libguile/vm-i-loader.c (load-program): Update for scm_make_program.

* libguile/vm-i-system.c (external-ref, external-set): No more.
  (make-closure): No more.
  (goto/args): No need to re-cons externals here. Update for new stack
  frame size.
  (mv-call, return, return/values): Update for new frame size. No need
  to reinstate externals on return.

* libguile/vm.c (really_make_boot_program, scm_load_compiled_with_vm):
  Update for scm_make_program.
* module/language/objcode/spec.scm (objcode-env-externals): Treat '() as
  #f, for the externals. Need to clean this up later...
* module/system/vm/program.scm (arity:nexts): Remove. Rename
  program-external to program-free-vars.

14 years agocompile lexical variable access and closure creation to the new ops
Andy Wingo [Thu, 23 Jul 2009 15:00:56 +0000 (17:00 +0200)]
compile lexical variable access and closure creation to the new ops

* module/language/glil.scm (<glil>): New GLIL type, <glil-lexical>,
  which will subsume other lexical types.
* module/language/glil/compile-assembly.scm: Compile <glil-lexical>.
  (make-open-binding): Change the interpretation of the second argument
  -- instead of indicating an "external" var, it now indicates a boxed
  var.
  (open-binding): Adapt to new glil-bind format.
* module/language/tree-il/analyze.scm: Add a lot more docs.
  (analyze-lexicals): Change the allocation algorithm and output format
  to allow the tree-il->glil compiler to capture free variables
  appropriately and to reference bound variables in boxes if necessary.
  Amply documented.

* module/language/tree-il/compile-glil.scm (compile-glil): Compile
  lexical variable access to <glil-lexical>. Emit variable capture and
  closure creation code here, instead of leaving that task to the
  GLIL->assembly compiler.

* test-suite/tests/tree-il.test: Update expected code emission.

14 years agovm support for display closures
Andy Wingo [Sun, 19 Jul 2009 17:48:26 +0000 (19:48 +0200)]
vm support for display closures

* libguile/vm-i-system.c (box, empty-box): Boxing values and storing
  them in local variables.
  (local-boxed-ref, local-boxed-set): A combination of local-ref then
  variable-ref/set.
  (make-closure2, closure-ref, closure-boxed-ref, closure-boxed-set):
  New ops. The idea is to migrate Guile over to using flat dispay
  closures. See the paper "Three Implementation Models for Scheme" by
  Kent Dybvig for more details; this is the "stack-based" model.

* libguile/vm-engine.c:
* libguile/vm-engine.h: Add the necessary infrastructure to keep track
  of a "closure" variable, like our "externals" in semantics, but
  minimal, flat, and O(1) in implementation.

14 years agorenumber vm ops (objcode cookie bumped)
Andy Wingo [Sun, 19 Jul 2009 17:02:30 +0000 (19:02 +0200)]
renumber vm ops (objcode cookie bumped)

* libguile/objcodes.c (OBJCODE_COOKIE): Bump.

* libguile/vm-i-loader.c:
* libguile/vm-i-scheme.c:
* libguile/vm-i-system.c: Renumber instructions, so I can have a bit
  more space to work.

14 years agoBump version number for 1.9.1.
Ludovic Courtès [Wed, 15 Jul 2009 21:57:18 +0000 (23:57 +0200)]
Bump version number for 1.9.1.

* GUILE-VERSION (GUILE_MICRO_VERSION): Increment.

14 years agoMake the non-integrated VM test-suite less verbose.
Ludovic Courtès [Wed, 15 Jul 2009 21:56:27 +0000 (23:56 +0200)]
Make the non-integrated VM test-suite less verbose.

* testsuite/run-vm-tests.scm (run-vm-tests): Don't display the number of
  tests passed since it's always 1 or 0.

14 years agoAdd FIXMEs about misaligned objcode-metas.
Ludovic Courtès [Wed, 15 Jul 2009 21:53:22 +0000 (23:53 +0200)]
Add FIXMEs about misaligned objcode-metas.

* libguile/objcodes.c (scm_c_make_objcode_slice): Add comment about
  misaligned `objcode-meta'.

* module/language/assembly/compile-bytecode.scm (write-bytecode):
  Likewise.

14 years agoFix unaligned access in the VM code.
Ludovic Courtès [Wed, 15 Jul 2009 21:51:42 +0000 (23:51 +0200)]
Fix unaligned access in the VM code.

* libguile/vm.c (struct t_32bit_aligned): New.
  (really_make_boot_program)[bytes]: Use it.  This fixes possibly
  unaligned accesses, which cause a "bus error" on some platforms (e.g.,
  sparc-*).

14 years agoConst-qualify buffers passed to `scm_c_make_objcode_slice ()'.
Ludovic Courtès [Wed, 15 Jul 2009 21:12:43 +0000 (23:12 +0200)]
Const-qualify buffers passed to `scm_c_make_objcode_slice ()'.

* libguile/objcodes.c (scm_c_make_objcode_slice): Add `const' qualifier
  for PTR and DATA.

* libguile/objcodes.h: Update accordingly.

14 years agoSwitch remaining GPLv2+ Guile-VM headers to LGPLv3+.
Ludovic Courtès [Wed, 15 Jul 2009 20:46:54 +0000 (22:46 +0200)]
Switch remaining GPLv2+ Guile-VM headers to LGPLv3+.

* module/system/base/compile.scm, module/system/base/syntax.scm,
  module/system/repl/common.scm, module/system/repl/describe.scm,
  module/system/vm/instruction.scm, module/system/vm/objcode.scm,
  module/system/vm/profile.scm, module/system/vm/program.scm,
  module/system/vm/trace.scm: Switch header from GPLv2+ to LGPLv3+.

14 years agoFix typo in the compile-type verification of `OBJCODE_COOKIE'.
Ludovic Courtès [Tue, 14 Jul 2009 23:17:32 +0000 (01:17 +0200)]
Fix typo in the compile-type verification of `OBJCODE_COOKIE'.

* libguile/objcodes.c: Fix `sizeof (OBJCODE_COOKIE)' assertion: the
  trailing 0 must not be taken into account, and multiple of 8 means the
  3 LSBs are clear.

14 years agoMake sure at compile-time that `OBJCODE_COOKIE' has the right size.
Ludovic Courtès [Tue, 14 Jul 2009 23:03:35 +0000 (01:03 +0200)]
Make sure at compile-time that `OBJCODE_COOKIE' has the right size.

* libguile/objcodes.c: Use `verify' to assert that the size of
  `OBJCODE_COOKIE' is a multiple of 8.

14 years agoExplicitly use Gnulib's `verify' module.
Ludovic Courtès [Tue, 14 Jul 2009 22:58:01 +0000 (00:58 +0200)]
Explicitly use Gnulib's `verify' module.

* m4/gnulib-cache.m4: Add `verify'.

14 years agoAugment `OBJCODE_COOKIE' to detect wrong endianness or word size.
Ludovic Courtès [Tue, 14 Jul 2009 22:55:33 +0000 (00:55 +0200)]
Augment `OBJCODE_COOKIE' to detect wrong endianness or word size.

* libguile/objcodes.c (OBJCODE_ENDIANNESS, _OBJCODE_STRINGIFY,
  OBJCODE_STRINGIFY, OBJCODE_WORD_SIZE): New macros.
  (OBJCODE_COOKIE): Use them.  The intent is that `.go' files compiled
  for a different endianness or word size are detected.

14 years agoRemove the `long_long' and `ulong_long' types.
Ludovic Courtès [Tue, 14 Jul 2009 22:32:05 +0000 (00:32 +0200)]
Remove the `long_long' and `ulong_long' types.

* libguile/gen-scmconfig.c (main): Don't emit typedefs for `long_long'
  and `ulong_long'.  This was already deprecated in 1.8 and known to
  cause conflicts with other libraries such as HDF5, as reported by Mark
  Patterson <mpatterson@physics.queensu.ca>
  (http://lists.gnu.org/archive/html/bug-guile/2009-02/msg00003.html).

14 years agoupdate NEWS
Andy Wingo [Tue, 14 Jul 2009 20:55:35 +0000 (22:55 +0200)]
update NEWS

* NEWS: Update.

14 years agoNEWS has info on 1.9.N to 1.9.N+1 in addition to 1.8 to 2.0
Andy Wingo [Thu, 2 Jul 2009 15:46:23 +0000 (17:46 +0200)]
NEWS has info on 1.9.N to 1.9.N+1 in addition to 1.8 to 2.0

* NEWS: Update to have an incremental section in addition to a
  comprehensive 1.8->2.0 section.

14 years agofix race in which some instruction name symbols could go unmarked
Andy Wingo [Thu, 2 Jul 2009 15:46:23 +0000 (17:46 +0200)]
fix race in which some instruction name symbols could go unmarked

* libguile/instructions.c: In loops, replace scm_op_last with
  SCM_VM_NUM_INSTRUCTIONS.
  (fetch_instruction_table): Protect the instruction symbols from
  collection. Before they were only marked by the name->opcode hash
  table, leading to races in which they could be collected.
  (scm_lookup_instruction_by_name): Protect the hash table earlier, as
  it's not actually a stack variable, since it's static.

14 years agofix bounds checks for the last element of bv-*-{ref,set}
Andy Wingo [Thu, 2 Jul 2009 15:43:07 +0000 (17:43 +0200)]
fix bounds checks for the last element of bv-*-{ref,set}

* libguile/vm-i-scheme.c (BV_FIXABLE_INT_REF, BV_INT_REF):
  (BV_FLOAT_REF, BV_FIXABLE_INT_SET, BV_INT_SET, BV_FLOAT_SET): Fix the
  bounds check for the last element.

14 years agoRemove potential "uninitialized variable" GCC warnings.
Ludovic Courtès [Tue, 14 Jul 2009 15:12:04 +0000 (17:12 +0200)]
Remove potential "uninitialized variable" GCC warnings.

* libguile/vm-i-scheme.c (vector_ref, vector_set, BV_FIXABLE_INT_REF,
  BV_INT_REF, BV_FLOAT_REF, BV_FIXABLE_INT_SET, BV_INT_SET,
  BV_FLOAT_SET): Explicitly initialize all locals, to make some versions
  of GCC happier.  Patch by Dale P. Smith <dsmich@roadrunner.com>.

14 years agoFix tests that assumed little endian.
Ludovic Courtès [Tue, 14 Jul 2009 14:07:13 +0000 (16:07 +0200)]
Fix tests that assumed little endian.

* test-suite/tests/asm-to-bytecode.test (u32->u8-list): New procedure.
  ("compiler")[(load-program 3 2 1 0 () 3 #f (make-int8 3) (return)),
  (load-program 3 2 1 0 () 3 (load-program 3 2 1 0 ...))]: Make these
  tests work on hosts whose endianness is not little endian.

14 years agoUse Gnulib's `vsnprintf' module.
Ludovic Courtès [Sun, 5 Jul 2009 21:57:37 +0000 (23:57 +0200)]
Use Gnulib's `vsnprintf' module.

* m4/gnulib-cache.m4: Use `vsnprintf', needed by `deprecation.c'.

14 years agoUpdate `NEWS'.
Ludovic Courtès [Sun, 5 Jul 2009 20:19:30 +0000 (22:19 +0200)]
Update `NEWS'.

* NEWS: Update.

14 years agoEnclose `bit-operations.test' in its own module.
Ludovic Courtès [Sun, 5 Jul 2009 19:13:51 +0000 (21:13 +0200)]
Enclose `bit-operations.test' in its own module.

* test-suite/tests/bit-operations.test: Use the `define-module' clause.

14 years agoFix the `BUILD_PTHREAD_SUPPORT' Automake conditional when not using pthread.
Ludovic Courtès [Sun, 5 Jul 2009 19:10:35 +0000 (21:10 +0200)]
Fix the `BUILD_PTHREAD_SUPPORT' Automake conditional when not using pthread.

* configure.in: Set $build_pthread_support to "no" when thread support
  isn't built.  This fixes the `BUILD_PTHREAD_SUPPORT' Automake
  conditional.

14 years agofix error message for bad objcode cookie
Andy Wingo [Thu, 2 Jul 2009 19:55:28 +0000 (21:55 +0200)]
fix error message for bad objcode cookie

* libguile/objcodes.c: Whoop-dee :)

14 years agoRead complex numbers where both parts are inexact decimals
Neil Jerram [Wed, 1 Jul 2009 00:39:24 +0000 (01:39 +0100)]
Read complex numbers where both parts are inexact decimals

Thanks to Bill Schottstaedt for reporting this problem!

* libguile/numbers.c (mem2ureal): Don't be misled by *p_exactness
  being INEXACT on entry (as is possible when reading a complex
  number): use local exactness variable x which starts as EXACT.
  Call mem2decimal_from_point () with &x instead of p_exactness.

* test-suite/tests/numbers.test ("string->number"): Add complex number
  tests suggested by Bill.

14 years agoCorrection to doc on Accessing Arrays from C
Neil Jerram [Tue, 30 Jun 2009 22:56:40 +0000 (23:56 +0100)]
Correction to doc on Accessing Arrays from C

Thanks to Ludovic for the new wording!

* doc/ref/api-compound.texi (Accessing Arrays from C): Correct text to
  reflect the current implementation of scm_array_get_handle and
  scm_array_handle_release - which don't actuall do any dynwind stuff.

14 years agoRemove seek/truncate shortcuts to file ports.
Ludovic Courtès [Sun, 28 Jun 2009 21:33:17 +0000 (23:33 +0200)]
Remove seek/truncate shortcuts to file ports.

Suggested by Neil.

* libguile/fports.c (fport_seek_or_seek64): Rename to `fport_seek ()'.
  (fport_seek, scm_i_fport_seek, scm_i_fport_truncate): Remove.

* libguile/fports.h (scm_i_fport_seek, scm_i_fport_truncate): Remove
  declarations.

* libguile/ports.c (scm_seek): Remove shortcut that would call out to
  `scm_i_fport_seek ()'.
  (scm_truncate_file): Likewise.

14 years agobytevector ops now compile down to low-level VM ops
Andy Wingo [Fri, 26 Jun 2009 10:41:34 +0000 (12:41 +0200)]
bytevector ops now compile down to low-level VM ops

* libguile/instructions.c (scm_instruction_list): Fix a longstanding bug
  in this humble function.

* libguile/vm-i-scheme.c (BV_FIXABLE_INT_SET, BV_INT_SET, BV_FLOAT_SET):
  Fix some bugs in these macros -- now the bytevector ops work.

* module/language/tree-il/compile-glil.scm (*primcall-ops*): Compile
  bytevector calls to VM ops.

* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*): Resolve bytevector calls to primitive
  calls.

14 years agorun bytevectors tests under the compiler and evaluator
Andy Wingo [Fri, 26 Jun 2009 09:12:37 +0000 (11:12 +0200)]
run bytevectors tests under the compiler and evaluator

* test-suite/tests/bytevectors.test: Run a number of tests under the
  compiler/vm and the evaluator.

14 years agovector-ref and vector-set! now have opcodes
Andy Wingo [Thu, 25 Jun 2009 22:15:37 +0000 (00:15 +0200)]
vector-ref and vector-set! now have opcodes

* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*): Resolve vector-ref and vector-set!.

* module/language/tree-il/compile-glil.scm (*primcall-ops*): And compile
  vector-ref and vector-set! to their opcodes.

* libguile/vm-i-scheme.c (vector-ref, vector-set): New opcodes, placed
  before the bytevector ops. The renumbering shouldn't affect anyone,
  given that the bytevector ops were not yet used. Fix a few bugs in the
  bytevector ops.

14 years agoadd bytevector ops to the vm
Andy Wingo [Wed, 24 Jun 2009 21:49:11 +0000 (23:49 +0200)]
add bytevector ops to the vm

* libguile/instructions.h (SCM_VM_NUM_INSTRUCTIONS): Enlarge to 255. Not
  sure what performance effects this will have.

* libguile/vm-engine.c: Add new error case, vm_error_not_a_bytevector.

* libguile/vm-engine.h: Don't assign specific registers for i386. Having
  added the new VM vector ops, GCC 4.4 is erroring for me now.

* libguile/vm-i-scheme.c: Add bytevector-specific ops to the VM.
  We don't actually use them yet, though.

14 years agobytevectors provide scm_i_native_endianness to the vm
Andy Wingo [Wed, 24 Jun 2009 21:46:42 +0000 (23:46 +0200)]
bytevectors provide scm_i_native_endianness to the vm

* libguile/bytevectors.h (scm_i_native_endianness): Allow the VM to use
  scm_i_native_endianness, but still keep it marked as internal.

* libguile/bytevectors.c: Adjust to use scm_i_native_endianness instead
  of native_endianness. Define it at bootstrap time.

14 years agominor doc tweaks
Andy Wingo [Wed, 24 Jun 2009 21:44:03 +0000 (23:44 +0200)]
minor doc tweaks

* doc/ref/api-compound.texi: Generalized vector doc fixups.

* doc/ref/api-data.texi: Minor fixes to bytevector docs.

14 years agoRevert "* FAQ: New file."
Neil Jerram [Thu, 25 Jun 2009 22:24:57 +0000 (23:24 +0100)]
Revert "* FAQ: New file."

This reverts commit d53f85dd859fa69af8a0b67482774d2a88aaf407.

It was a confusing mistake to create an FAQ file in the Guile
repository/distribution, because there was already an FAQ page on the
Guile web site.  The information that was in the FAQ file is now in
the FAQ web page.

14 years agoAdd `scm_t_off' type so that `scm_t_port' has a fixed layout.
Ludovic Courtès [Thu, 25 Jun 2009 21:32:44 +0000 (23:32 +0200)]
Add `scm_t_off' type so that `scm_t_port' has a fixed layout.

* libguile/gen-scmconfig.c (main): Produce a definition for
  `scm_t_off'.

* libguile/ports.h (scm_t_port)[read_buf_size, saved_read_buf_size,
  write_buf_size, seek, truncate]: Use `scm_t_off' instead of `off_t' so
  that the layout and size of the structure does not depend on the
  application's `_FILE_OFFSET_BITS' value.  Reported by Bill
  Schottstaedt, see
  http://lists.gnu.org/archive/html/bug-guile/2009-06/msg00018.html.
  (scm_set_port_seek, scm_set_port_truncate): Update.

* libguile/ports.c (scm_set_port_seek, scm_set_port_truncate): Use
  `scm_t_off' and `off_t_or_off64_t'.

* libguile/fports.c (fport_seek, fport_truncate): Use `scm_t_off'
  instead of `off_t'.

* libguile/r6rs-ports.c (bip_seek, cbp_seek, bop_seek): Use `scm_t_off'
  instead of `off_t'.

* libguile/rw.c (scm_write_string_partial): Likewise.

* libguile/strports.c (st_resize_port, st_seek, st_truncate): Likewise.

* doc/ref/api-io.texi (Port Implementation): Update prototype of
  `scm_set_port_seek ()' and `scm_set_port_truncate ()'.

* NEWS: Update.

14 years agoFix `load-objcode' FD/mapping leak occurring upon failure.
Ludovic Courtès [Thu, 25 Jun 2009 20:45:12 +0000 (22:45 +0200)]
Fix `load-objcode' FD/mapping leak occurring upon failure.

* libguile/objcodes.c (make_objcode_by_mmap): Close FD and unmap ADDR
  upon failure.

14 years agoallow primcall ops to push 0 values
Andy Wingo [Wed, 24 Jun 2009 13:14:00 +0000 (15:14 +0200)]
allow primcall ops to push 0 values

* libguile/objcodes.c (OBJCODE_COOKIE): Bump the objcode cookie. We'll
  be doing this on incompatible changes until 2.0.

* libguile/vm-i-scheme.c (set_car, set_cdr, slot_set): These
  instructions don't have natural return values -- so declare them that
  way, that they push 0 values.

* module/language/tree-il/compile-glil.scm (flatten): When compiling
  primitive calls, check `(instruction-pushes op)' to see how many
  values that instruction will push, and do something appropriate,
  instead of just assuming that all primcall ops push 1 value.

14 years agoremove lambda wrap hack of brainfuck tree-il compiler
Andy Wingo [Wed, 24 Jun 2009 11:42:59 +0000 (13:42 +0200)]
remove lambda wrap hack of brainfuck tree-il compiler

* module/language/brainfuck/compile-tree-il.scm (compile-tree-il):
  Remove the hack where we wrapped the compiled code in a `lambda',
  because not only should the tree-il compiler optimize that away, it
  was really papering around other inefficiencies, and obtuse to boot.

14 years agoRemove AC_SYS_RESTARTABLE_SYSCALLS and related code
Neil Jerram [Thu, 18 Jun 2009 19:35:45 +0000 (20:35 +0100)]
Remove AC_SYS_RESTARTABLE_SYSCALLS and related code

As the Autoconf documentation says, "These days portable programs
[...] should not rely on `HAVE_RESTARTABLE_SYSCALLS', since nowadays
whether a system call is restartable is a dynamic issue, not a
configuration-time issue."

In other words, if we ever rely on HAVE_RESTARTABLE_SYSCALLS, we are
at the mercy of any code that Guile happens to be linked with, because
that code could install a signal handler without the SA_RESTART flag,
and then a Guile system call could unexpectedly return EINTR.

The readline part of this goes back to this problem report:
http://sources.redhat.com/ml/guile/2000-05/msg00177.html; and is an
excellent example of the above paragraph.  It was noted during the
discussion that undefining HAVE_RESTARTABLE_SYSCALLS would fix the
problem, but that solution wasn't adopted - I guess because Guile was
still using cooperative threads then (not pthreads) and so there was a
significant concern (whether founded or not) that not using
restartable syscalls (where available) could lead to a loss of
performance.

Now Guile's default mode of operation is with pthreads, where we
already don't assume that HAVE_RESTARTABLE_SYSCALLS is reliable, so
there is no possible further performance loss.  And in any case we
really have no choice, if we want correct operation.

Thanks to Sylvain Beucler for reporting this and suggesting the fix.

* configure.in (AC_SYS_RESTARTABLE_SYSCALLS): Removed.

* doc/ref/posix.texi (Signals): Remove statement that Guile always
  sets SA_RESTART flag.

* guile-readline/configure.in (GUILE_SIGWINCH_SA_RESTART_CLEARED):
  Remove this setting, together with its test code.
  (HAVE_RL_PRE_INPUT_HOOK): Remove this setting and its code, as no
  longer needed.

* guile-readline/readline.c (sigwinch_enable_restart): Removed.
  (scm_init_readline): Remove setting of rl_pre_input_hook.

* libguile/_scm.h (SCM_SYSCALL): Remove the definition that relies on
  HAVE_RESTARTABLE_SYSCALLS.

* libguile/scmsigs.c (scm_sigaction_for_thread): Don't always set the
  SA_RESTART flag if available.  Update docstring accordingly.
  (scm_init_scmsigs): Remove code that sets SA_RESTART flag for all
  signals.

* THANKS: Add Sylvain.

14 years agoflush whitespace from the repl input buffer *before* evaluation
Andy Wingo [Mon, 22 Jun 2009 20:57:48 +0000 (22:57 +0200)]
flush whitespace from the repl input buffer *before* evaluation

* module/system/repl/repl.scm (start-repl): Given that the input port of
  the repl is line-buffered, it's likely we have #\newline in the input
  that is strictly extraneous, an in-band indicator to the repl that it
  should begin reading now. So flush out that newline, so that you can
  (read-char) at the repl, and it actually does wait for you to type in
  a char instead of just returning #\newline.

  While it's not an overriding concern, this does fix some brainfuck
  programs that want to input from the user.

14 years agomore docs to brainfuck->tree-il compiler
Andy Wingo [Mon, 22 Jun 2009 20:44:34 +0000 (22:44 +0200)]
more docs to brainfuck->tree-il compiler

* module/language/brainfuck/compile-tree-il.scm (compile-tree-il): Wrap
  the result in a ((lambda () ...)), so we can use toplevel-ref. Add
  lots more comments.

14 years agometa-commands read off their own arguments
Andy Wingo [Mon, 22 Jun 2009 18:45:01 +0000 (20:45 +0200)]
meta-commands read off their own arguments

* module/system/repl/command.scm: Update copyright.
  (meta-command): Rework so that it's the various meta-commands that do
  the reading for their arguments. This way you can compile forms that
  span more than one line, and forms that need to be read with another
  language's reader.
  (define-meta-command): New helper macro. Update commands to use it.
  (help): Allow ,help on commands too.

* module/system/repl/repl.scm: Update copyright.
  (start-repl): Adjust to give meta-command what it wants.

14 years agoAlways create the bytevector SMOB type.
Ludovic Courtès [Sun, 21 Jun 2009 22:56:00 +0000 (00:56 +0200)]
Always create the bytevector SMOB type.

* libguile/bytevectors.c (scm_tc16_bytevector, print_bytevector,
  bytevector_equal_p, free_bytevector): Don't use the snarfing macros.
  (scm_bootstrap_bytevectors): New.
  (scm_init_bytevectors): No longer initialize SCM_NULL_BYTEVECTOR,
  which is done by `scm_bootstrap_bytevectors ()'.

* libguile/bytevectors.h (scm_bootstrap_bytevectors): New declaration.
  (scm_init_bytevectors): Made internal.  This can be done because we
  explicitly register it with `scm_c_register_extension ()' in
  `scm_bootstrap_bytevectors ()'.

* libguile/init.c (scm_i_init_guile): Call `scm_bootstrap_bytevectors ()'.
  This is so that expressions like "(generalized-vector-length #vu8())"
  work even when `(rnrs bytevector)' hasn't been loaded.

14 years agoMake bytevectors accessible using the generalized-vector API.
Ludovic Courtès [Sun, 21 Jun 2009 22:51:08 +0000 (00:51 +0200)]
Make bytevectors accessible using the generalized-vector API.

As a side effect, this allows compilation of literal bytevectors
("#vu8(...)"), which gets done by the generic array handling
of the GLIL->assembly compiler.

* doc/ref/api-compound.texi (Generalized Vectors): Mention bytevectors.
  (Arrays, Array Syntax): Likewise.

* doc/ref/api-data.texi (Bytevectors as Generalized Vectors): New node.

* libguile/bytevectors.c (scm_i_bytevector_generalized_set_x): New.

* libguile/bytevectors.h (scm_i_bytevector_generalized_set_x): New
  declaration.

* libguile/srfi-4.c (scm_i_generalized_vector_type,
  scm_array_handle_uniform_element_size,
  scm_array_handle_uniform_writable_elements): Add support for
  bytevectors.

* libguile/unif.c (type_creator_table): Add `vu8'.
  (bytevector_ref, bytevector_set): New functions.
  (memoize_ref, memoize_set): Add support for bytevectors.

* libguile/vectors.c (scm_is_generalized_vector,
  scm_c_generalized_vector_length, scm_c_generalized_vector_ref,
  scm_c_generalized_vector_set_x): Add support for bytevectors.

* test-suite/tests/bytevectors.test ("Generalized Vectors"): New test
  set.

14 years agobytevectors: Add a C-friendly API.
Ludovic Courtès [Sun, 21 Jun 2009 21:16:57 +0000 (23:16 +0200)]
bytevectors: Add a C-friendly API.

* doc/ref/api-data.texi (Bytevector Manipulation): Add
  `scm_is_bytevector ()', `scm_c_bytevector_length ()',
  `scm_c_bytevector_length ()', and `scm_c_bytevector_set_x ()'.

* libguile/bytevectors.c (scm_is_bytevector, scm_c_bytevector_length,
  scm_c_bytevector_ref, scm_c_bytevector_set_x): New functions.
  (scm_bytevector_p): Use `scm_is_bytevector ()'.
  (scm_bytevector_length): Use `scm_c_bytevector_length ()'.

* libguile/bytevectors.h (scm_is_bytevector, scm_c_bytevector_length,
  scm_c_bytevector_ref, scm_c_bytevector_set_x): New declarations.

14 years agobytevectors: Use `size_t' rather than `unsigned' for sizes.
Ludovic Courtès [Sun, 21 Jun 2009 14:55:58 +0000 (16:55 +0200)]
bytevectors: Use `size_t' rather than `unsigned' for sizes.

* doc/ref/api-data.texi (Bytevector Manipulation): Update.

* libguile/bytevectors.c (INTEGER_ACCESSOR_PROLOGUE,
  make_bytevector_from_buffer, scm_c_make_bytevector,
  scm_c_take_bytevector, scm_i_shrink_bytevector): Use `size_t' for
  bytevector lengths.

14 years agoFix documentation of `make-bytevector'.
Ludovic Courtès [Sun, 21 Jun 2009 21:32:19 +0000 (23:32 +0200)]
Fix documentation of `make-bytevector'.

* doc/ref/api-data.texi (Bytevector Manipulation): Fix documentation of
  the FILL argument of `make-bytevector'.

14 years agoadd brainfuck->tree-il compiler
Andy Wingo [Sun, 21 Jun 2009 12:53:33 +0000 (14:53 +0200)]
add brainfuck->tree-il compiler

* module/Makefile.am (BRAINFUCK_LANG_SOURCES): Compile at the end. Add
  compile-tree-il.scm.

* module/language/brainfuck/compile-tree-il.scm: New compiler, compiles
  to tree-il instead of scheme. I thought it would be more illustrative,
  though there are some uncommented bits.

* module/language/brainfuck/parse.scm: Modify not to put a header on the
  scheme representation. After all, we don't put <scheme> before scheme
  code, do we? :)

* module/language/brainfuck/spec.scm: Add tree-il compiler.

* module/language/tree-il.scm: Understand (set! (lexical foo) ...).

* module/system/base/language.scm: Update license. Actually, updates
  licenses on all these.

14 years agoformatting changes to (language brainfuck compile-scheme)
Andy Wingo [Sun, 21 Jun 2009 11:36:39 +0000 (13:36 +0200)]
formatting changes to (language brainfuck compile-scheme)

* module/language/brainfuck/compile-scheme.scm: Standalone comments
  should have more than one semicolon, and update copyright to LGPLv3+.

14 years agolink to brainfuck wikipedia page
Andy Wingo [Sun, 21 Jun 2009 11:10:56 +0000 (13:10 +0200)]
link to brainfuck wikipedia page

* doc/ref/compiler.texi: Point to more info on Brainfuck. Patch by
  Daniel Kraft.

14 years agoadded documenting comments to the brainfuck compiler and mention it in the VM documen...
Daniel Kraft [Sat, 23 May 2009 07:58:54 +0000 (09:58 +0200)]
added documenting comments to the brainfuck compiler and mention it in the VM documentation.

* doc/ref/compiler.texi: Mention the new brainfuck compiler as an example.
* module/language/brainfuck/compile-scheme.scm: Add a lot of documentation comments.
* module/language/brainfuck/parse.scm: Ditto.
* module/language/brainfuck/spec.scm: Ditto.

14 years agobasic brainfuck -> scheme example compiler.
Daniel Kraft [Sat, 23 May 2009 07:58:54 +0000 (09:58 +0200)]
basic brainfuck -> scheme example compiler.

* module/Makefile.am: Install the brainfuck compiler modules.
* module/language/brainfuck/spec.scm: New file.
* module/language/brainfuck/parse.scm: New file.
* module/language/brainfuck/compile-scheme.scm: New file.

14 years agoremove obsolete guile-vm.texi
Andy Wingo [Sun, 21 Jun 2009 10:57:55 +0000 (12:57 +0200)]
remove obsolete guile-vm.texi

* doc/guile-vm.texi: Remove, has been folded into the Guile manual for a
  while now.

* doc/Makefile.am: Remove guile-vm.texi.

14 years agoupdate .gitignore
Andy Wingo [Sun, 21 Jun 2009 10:51:16 +0000 (12:51 +0200)]
update .gitignore

* .gitignore: Update.

14 years agoDeterministic test for the r6rs-ports.test segmentation fault
Neil Jerram [Sun, 21 Jun 2009 12:31:20 +0000 (13:31 +0100)]
Deterministic test for the r6rs-ports.test segmentation fault

* test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports"): Add (gc), to
  test the (ex-)bug in cbp_mark () when marking a closed port.

14 years agoFix crash when marking closed custom bytevector port
Andy Wingo [Sun, 21 Jun 2009 10:41:46 +0000 (12:41 +0200)]
Fix crash when marking closed custom bytevector port

* libguile/r6rs-ports.c (cbp_mark): A closed port will have had its
  stream destroyed, so don't dereference the stream in that case. Patch by
  Mike Gran.

14 years agoput autocompiled files into ~/.cache or $XDG_CACHE_HOME
Andy Wingo [Sat, 20 Jun 2009 12:26:54 +0000 (14:26 +0200)]
put autocompiled files into ~/.cache or $XDG_CACHE_HOME

* module/system/base/compile.scm (compiled-file-name): Remove unneeded
  path separator.

* libguile/load.c (scm_init_load_path): Change so the default cache path
  is ~/.cache/guile/ccache/1.9, and respect $XDG_CACHE_HOME.

14 years agofix source information lossage for (define (foo) ...) lambda sugar
Andy Wingo [Sat, 20 Jun 2009 10:41:11 +0000 (12:41 +0200)]
fix source information lossage for (define (foo) ...) lambda sugar

* module/ice-9/psyntax.scm (source-wrap): Use decorate-source, for
  clarity.
  (syntax-type): When turning the RHS of (define (foo) ...) into a
  lambda, decorate the resulting lambda expression with source
  information, as the RHS later goes to chi-expr, which receives no
  source information. Perhaps that is a bug. In any case, fixes some
  source location lossage, reported by Jao.

* module/ice-9/psyntax-pp.scm: Regenerated.

14 years agobetter error in make_objcode_by_mmap
Andy Wingo [Sat, 20 Jun 2009 09:41:50 +0000 (11:41 +0200)]
better error in make_objcode_by_mmap

* libguile/objcodes.c (make_objcode_by_mmap): Better error when the
  object header is incorrect.