bpt/guile.git
14 years agotype limits error in string-tabulate
Michael Gran [Thu, 20 Aug 2009 14:23:22 +0000 (07:23 -0700)]
type limits error in string-tabulate

* libguile/srfi-13.c (scm_string_tabulate): test range of signed integer
  before casting it to unsigned size_t

14 years agoUpdate srfi-13 functions for Unicode
Michael Gran [Wed, 19 Aug 2009 12:25:47 +0000 (05:25 -0700)]
Update srfi-13 functions for Unicode

* libguile/srfi-13.c (MY_SUBF_VALIDATE_SUBSTRING_SPEC): new macro
  (MY_VALIDATE_SUBSTRING_SPEC_COPY): now unused, removed
  (MY_VALIDATE_SUBSTRING_SPEC_UCOPY): now unused, removed
  (REF_IN_CHARSET): new macro
  (race_error)[0]: unused, removed
  (scm_string_any, scm_string_every, scm_string_tabulate)
  (scm_substring_to_list, scm_reverse_string_to_list)
  (scm_reverse_list_to_string, scm_string_join)
  (s_scm_srfi13_substring_copy, scm_string_copy, scm_string_copy_x)
  (scm_string_pad, scm_string_pad_right, scm_string_trim)
  (scm_string_trim_right, scm_string_trim_both, scm_substring_fill_x):
  (scm_string_compare, scm_string_compare_ci): modified for
  both wide and narrow strings
  (compare_string): new function
  (scm_string_eq, scm_string_neq, scm_string_lt, scm_string_gt)
  (scm_string_le, scm_string_ge, scm_string_ci_eq, scm_string_ci_neq)
  (scm_string_ci_lt, scm-string_ci_gt, scm_string_ci_le, scm_string_ci_gt)
  (scm_substring_hash, scm_string_prefix_length, scm_string_suffix_length)
  (scm_string_prefix_length_ci, scm_string_suffix_length_ci)
  (scm_string_prefix_p, scm_string_prefix_ci_p, scm_string_suffix_p)
  (scm_string_suffix_ci_p, scm_string_index, scm_string_index_right)
  (scm_string_skip, scm_string_skip_right, scm_string_count)
  (scm_string_contains, scm_string_contains_ci, string_upcase_x)
  (scm_substring_upcase_x, scm_substring_upcase, string_downcase_x)
  (scm_string_downcase_x, scm_string_downcase, scm_string_titlecase_x)
  (scm_string_titlecase, scm_string_capitalize, scm_string_reverse)
  (scm_string_reverse_x, scm_string_map, scm_string_map_x)
  (scm_string_fold, scm_string_fold_right, scm_string_unfold)
  (scm_string_unfold_right, scm_xsubstring, scm_string_xcopy_x)
  (scm_string_replace, scm_string_tokenize, scm_string_split)
  (scm_string_filter, scm_string_delete): modified for both wide and
  narrow strings

14 years agoSome srfi-13 test with wide strings
Michael Gran [Thu, 20 Aug 2009 06:21:18 +0000 (23:21 -0700)]
Some srfi-13 test with wide strings

* test-suite/tests/srfi-13.test: more tests

14 years agoUpdates to benchmarks for srfi-13
Michael Gran [Thu, 20 Aug 2009 04:21:29 +0000 (21:21 -0700)]
Updates to benchmarks for srfi-13

Test more of the positive paths.  Add test for string-prefix-ci?
string-suffix-ci? and string-hash-ci.  Update the counts per test
to give approximately the same bench/interp time for each test for
1.8.7.

* benchmark-suite/benchmarks/srfi-13.bm: update benchmarks

14 years agoAvoid possible mutex hang on error message output
Michael Gran [Thu, 20 Aug 2009 04:47:19 +0000 (21:47 -0700)]
Avoid possible mutex hang on error message output

Avoid possible mutex hang when scm_lfwrite_substr is used in error
message output and when an error has caused the stringbuf write
mutex to not be unlocked.  scm_lfwrite_substr makes a substring:
making a substring requires that mutex.

Hopefully, all cases of non-local jumps when the stringbuf write
lock is held have been eliminated anyway, making this O.B.E.

* libguile/ports.c (scm_lfwrite_str): include functionality in this
  function instead of making this a special case of scm_lfwrite_substr

14 years agoAdd VM exception in strings.test
Michael Gran [Thu, 20 Aug 2009 05:12:33 +0000 (22:12 -0700)]
Add VM exception in strings.test

* test-suite/tests/strings.test (exception:wrong-type-arg): change regex

14 years agoTry to optimize scm_string for speed
Michael Gran [Thu, 20 Aug 2009 04:26:11 +0000 (21:26 -0700)]
Try to optimize scm_string for speed

* libguile/strings.c (scm_string): optimize for speed

14 years agoRename string-width to string-bytes-per-char
Michael Gran [Thu, 20 Aug 2009 04:24:23 +0000 (21:24 -0700)]
Rename string-width to string-bytes-per-char

* libguile/strings.h: rename scm_string_width to scm_string_bytes_per_char

* libguile/strings.c (scm_string_width): renamed to scm_string_bytes_per_char
  (scm_string_bytes_per_char): renamed from scm_string_width

* module/language/assembly/compile-bytecode.scm (write-bytecode): string-width
  -> string-bytes-per-char

* module/language/glil/compile-assembly.scm (dump-object): string-width
  -> string-bytes-per-char

14 years agoMisleading error message text in scm_i_string_writable_wide_chars
Michael Gran [Thu, 20 Aug 2009 04:25:23 +0000 (21:25 -0700)]
Misleading error message text in scm_i_string_writable_wide_chars

* libguile/strings.c (scm_i_string_writable_wide_chars): change error text

14 years agoprocedure-documentation works on vm procedures
Andy Wingo [Wed, 19 Aug 2009 10:20:58 +0000 (12:20 +0200)]
procedure-documentation works on vm procedures

* libguile/procs.c (scm_procedure_documentation): Add a hack so that
  this function works for compiled procedures too.

14 years agoDisplay wide strings using escapes
Michael Gran [Wed, 19 Aug 2009 05:32:08 +0000 (22:32 -0700)]
Display wide strings using escapes

* libguile/print.c (iprin1): for now, display wide strings
  as escaped strings

14 years agoAvoid double-casts of stringbuf
Michael Gran [Wed, 19 Aug 2009 04:14:56 +0000 (21:14 -0700)]
Avoid double-casts of stringbuf

Conversion from char to scm_t_wchar require an intermediate cast to
unsigned char.  By changing the return type of SCM_STRINGBUF_INLINE_CHARS
to unsigned char *, doublecasts in the code can be avoided.  Also,
some clarification of return types.

* libguile/strings.c (STRINGBUF_OUTLINE_CHARS)
(STRINGBUF_INLINE_CHARS): now returns unsigned char *; all callers changed.

14 years agoAvoid compilation warnings in SCM_MAKE_CHAR
Michael Gran [Wed, 19 Aug 2009 04:13:38 +0000 (21:13 -0700)]
Avoid compilation warnings in SCM_MAKE_CHAR

* libguile/chars.h (SCM_MAKE_CHAR): change inequality

14 years agoBenchmarks for common character and string procedures
Michael Gran [Wed, 19 Aug 2009 02:42:38 +0000 (19:42 -0700)]
Benchmarks for common character and string procedures

* benchmark-suite/benchmarks/chars.bm: new benchmarks

* benchmark-suite/benchmarks/srfi-13.bm: new benchmarks

14 years agoremove (ice-9 lineio)'s dependency on (ice-9 readline)
Andy Wingo [Tue, 18 Aug 2009 15:52:46 +0000 (17:52 +0200)]
remove (ice-9 lineio)'s dependency on (ice-9 readline)

* module/ice-9/lineio.scm: Use (ice-9 rdelim) instead of (ice-9
  readline) to remove readline dependency.

14 years ago`load' autocompiles
Andy Wingo [Tue, 18 Aug 2009 09:05:17 +0000 (11:05 +0200)]
`load' autocompiles

* libguile/load.h:
* libguile/load.c (scm_sys_warn_autocompilation_enabled): New primitive,
  not exported. Since `load' autocompiles now, it should warn in the
  same way that the bits hardcoded into C warn.
  (scm_try_autocompile): Use scm_sys_warn_autocompilation_enabled.

* module/ice-9/boot-9.scm (autocompiled-file-name): New helper.
  (load): Try autocompiling the argument, if appropriate. Will
  autocompile files passed on Guile's command line. `primitive-load' is
  unaffected.

14 years agoThanks, Mike.
Ludovic Courtès [Mon, 17 Aug 2009 21:06:49 +0000 (23:06 +0200)]
Thanks, Mike.

14 years agoUpdate `NEWS' for commit d8dd381fa781c236ae777ca1ac55b73d3ca91c2a.
Ludovic Courtès [Mon, 17 Aug 2009 21:05:50 +0000 (23:05 +0200)]
Update `NEWS' for commit d8dd381fa781c236ae777ca1ac55b73d3ca91c2a.

14 years agoBump version number for 1.9.2.
Ludovic Courtès [Sat, 15 Aug 2009 12:41:46 +0000 (14:41 +0200)]
Bump version number for 1.9.2.

* GUILE-VERSION (GUILE_MICRO_VERSION): Increment.

14 years agoTurn off auto-compilation to stand-alone tests.
Ludovic Courtès [Sat, 15 Aug 2009 12:35:29 +0000 (14:35 +0200)]
Turn off auto-compilation to stand-alone tests.

* test-suite/standalone/Makefile.am (TESTS_ENVIRONMENT): Add
  "GUILE_AUTO_COMPILE=0".

14 years agoUpdate the manual and `NEWS' regarding `guile-2.0.pc'.
Ludovic Courtès [Sat, 15 Aug 2009 12:26:17 +0000 (14:26 +0200)]
Update the manual and `NEWS' regarding `guile-2.0.pc'.

* NEWS: Mention `guile-2.0.pc'.

* doc/ref/autoconf.texi (Autoconf Macros): Update to `guile-2.0'.

14 years agoAdd proper `--help' and `--version' for `guile-tools compile'.
Ludovic Courtès [Sat, 15 Aug 2009 10:53:59 +0000 (12:53 +0200)]
Add proper `--help' and `--version' for `guile-tools compile'.

* configure.ac: Produce `meta/guile-tools'.

* meta/Makefile.am (EXTRA_DIST): Add `guile-tools.in'.
  (bin_SCRIPTS): Remove `guile-tools'.

* meta/uninstalled-env.in (PATH): Add "${top_builddir}/meta".

* module/scripts/compile.scm (%options): Add `--version'.
  (parse-args): Show the offending option name upon error.
  (show-version): New.
  (compile): Use `%guile-bug-report-address'.

14 years agoupdate NEWS for 1.9.2
Andy Wingo [Sat, 15 Aug 2009 10:49:44 +0000 (12:49 +0200)]
update NEWS for 1.9.2

* NEWS: Update.

14 years agoUpdate `.gitignore' for GNU Global.
Ludovic Courtès [Sat, 15 Aug 2009 10:06:28 +0000 (12:06 +0200)]
Update `.gitignore' for GNU Global.

14 years agoSwitch from `guile-1.8.pc' to `guile-2.0.pc'.
Ludovic Courtès [Sat, 15 Aug 2009 10:05:36 +0000 (12:05 +0200)]
Switch from `guile-1.8.pc' to `guile-2.0.pc'.

* configure.ac: Produce guile-2.0*.pc.

* meta/Makefile.am (EXTRA_DIST): Rename guile-1.8*.pc.in to
  guile-2.0*.pc.in.
  (pkgconfig_DATA): Update accordingly.

* meta/guile-config (guile-module): Likewise.

14 years agoUncomment run-time objcode alignment check.
Ludovic Courtès [Thu, 13 Aug 2009 21:59:51 +0000 (23:59 +0200)]
Uncomment run-time objcode alignment check.

This should now work thanks to the changes in
28b119ee3da0f4b14cb87e638794d22843778cda ("make sure all programs are
8-byte aligned").  This commit is a follow-up to
ec99fe8ecb412e49e8e981246eb62ca46b32754b ("Add FIXMEs about misaligned
objcode-metas.").

* libguile/objcodes.c (scm_c_make_objcode_slice): Uncomment assertion
  that checks for proper alignment of PTR.

* module/language/assembly/compile-bytecode.scm (write-bytecode): Update
  comment about META's alignment.

14 years agoRemove deprecated semi-public memoizers.
Ludovic Courtès [Thu, 13 Aug 2009 21:36:46 +0000 (23:36 +0200)]
Remove deprecated semi-public memoizers.

* libguile/eval.c (scm_m_expand_body, scm_macroexp, scm_unmemocar):
  Remove.
  (scm_m_undefine): Make `static'.

* libguile/eval.h (scm_m_undefine, scm_m_expand_body, scm_unmemocar,
  scm_macroexp): Remove declarations.

14 years agoMake the evaluator's memoizers private.
Ludovic Courtès [Thu, 13 Aug 2009 21:08:35 +0000 (23:08 +0200)]
Make the evaluator's memoizers private.

* libguile/eval.c (macroexp): Move upwards.
  (scm_m_quote, scm_m_begin, scm_m_if, scm_m_set_x, scm_m_and, scm_m_or,
  scm_m_case, scm_m_cond, scm_m_lambda, scm_m_letstar, scm_m_do,
  scm_m_quasiquote, scm_m_delay, scm_m_generalized_set_x,
  scm_m_define, scm_m_letrec, scm_m_let, scm_m_at, scm_m_atat,
  scm_m_apply, scm_m_cont, scm_m_nil_cond, scm_m_atfop,
  scm_m_atbind, scm_m_atslot_ref, scm_m_atslot_set_x,
  scm_m_at_call_with_values, scm_m_eval_when): New static
  declarations; definitions made static.
  (s_atslot_ref, s_atslot_set_x): New, from `goops.c'.

* libguile/eval.h (scm_m_quote, scm_m_begin, scm_m_if, scm_m_set_x,
  scm_m_vref, scm_m_vset, scm_m_and, scm_m_or, scm_m_case, scm_m_cond,
  scm_m_lambda, scm_m_letstar, scm_m_do, scm_m_quasiquote, scm_m_delay,
  scm_m_generalized_set_x, scm_m_future, scm_m_define, scm_m_letrec,
  scm_m_let, scm_m_at, scm_m_atat, scm_m_apply, scm_m_cont,
  scm_m_nil_cond, scm_m_atfop, scm_m_atbind, scm_m_atslot_ref,
  scm_m_atslot_set_x, scm_m_atdispatch, scm_m_at_call_with_values,
  scm_m_eval_when): Remove public declarations.

* libguile/goops.c (s_atslot_ref, s_atslot_set_x): Remove.

14 years agocompiler.test: Enforce evaluation order.
Ludovic Courtès [Thu, 13 Aug 2009 14:16:08 +0000 (16:16 +0200)]
compiler.test: Enforce evaluation order.

* test-suite/tests/compiler.test ("psyntax")["redefinition", "compile in
  current module", "compile in fresh module"]: Use `begin' to enforce
  evaluation order.  Thanks Andy!

14 years agoAllow fresh modules to be passed to `compile'.
Ludovic Courtès [Wed, 12 Aug 2009 17:22:19 +0000 (19:22 +0200)]
Allow fresh modules to be passed to `compile'.

* module/ice-9/boot-9.scm (module-name): When making MOD non-anonymous,
  bind it in the `(%app modules)' name space.

* test-suite/tests/compiler.test ("psyntax")["compile in current
  module", "compile in fresh module"]: New tests.

* test-suite/tests/modules.test ("foundations")["modules don't remain
  anonymous"]: New test.

14 years agoAllow redefinitions in compiled code as in `(define round round)'.
Ludovic Courtès [Thu, 13 Aug 2009 13:39:12 +0000 (15:39 +0200)]
Allow redefinitions in compiled code as in `(define round round)'.

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

* module/ice-9/psyntax.scm (chi-top)[define-form]: If a same-named
  imported variable exists, take its value instead of `#f'.

* test-suite/tests/compiler.test ("psyntax")["redefinition"]: New tests.

14 years agoupdate docs for recent vm/compiler work
Andy Wingo [Wed, 12 Aug 2009 21:38:05 +0000 (23:38 +0200)]
update docs for recent vm/compiler work

* doc/ref/compiler.texi:
* doc/ref/vm.texi: Update for recent changes.
* module/language/assembly/disassemble.scm (disassemble-load-program):
  Don't print nops, they are distracting.

14 years ago"fix" <let>-bound lambda expressions too
Andy Wingo [Wed, 12 Aug 2009 18:44:30 +0000 (20:44 +0200)]
"fix" <let>-bound lambda expressions too

* module/language/tree-il/compile-glil.scm (compile-glil): Compute
  warnings before optimizing, as unreferenced variables will be
  optimized out.

* libguile/_scm.h: Fix C99 comment.

* module/language/tree-il/fix-letrec.scm (partition-vars): Also analyze
  let-bound vars.
  (fix-letrec!): Fix a bug whereby a set! to an unreffed var would be
  called for value, not effect. Also "fix" <let>-bound lambda
  expressions -- really speeds up pmatch.

* test-suite/tests/tree-il.test ("lexical sets", "the or hack"): Update
  to take into account the new optimizations.

14 years agoDon't include libunistring headers in Guile public headers
Michael Gran [Wed, 12 Aug 2009 15:30:59 +0000 (08:30 -0700)]
Don't include libunistring headers in Guile public headers

This requres the creation of a new type
scm_t_string_failed_conversion_handler to replace libunistring's
enum iconveh_ilseq_handler.

* libguile/strings.h: don't include <uniconv.h>
(scm_t_string_failed_conversion_handler): new enum type
(SCM_FAILED_CONVERSION_ERROR, SCM_FAILED_CONVERSION_QUESTION_MARK):
(SCM_FAILED_CONVERSION_ESCAPE_SEQUENCE): new enum type values

* libguile/strings.c (scm_to_stringn): now takes type
scm_t_string_failed_conversion_handler.  All callers changed.

* libguile/print.c: include <uniconv.h>

* libguile/ports.c (scm_lfwrite_substr): use
scm_t_string_conversion_handler's constants

* libguile/gen-scmconfig.c (SCM_ICONVEH_ERROR):
(SCM_ICONVEH_QUESTION_MARK, SCM_ICONVEH_ESCAPE_SEQUENCE): store
iconveh_ilseq_hander constants as #define's

14 years agoRegression, scm_string fails to test for circular lists
Michael Gran [Wed, 12 Aug 2009 16:21:37 +0000 (09:21 -0700)]
Regression, scm_string fails to test for circular lists

* libguile/string.c (scm_string): Restores the functionality
  where scm_string tests for circular lists

* test-suite/tests/strings.test: add test for circular lists

14 years agoSome signed/unsigned comparison and conversions
Michael Gran [Wed, 12 Aug 2009 15:50:12 +0000 (08:50 -0700)]
Some signed/unsigned comparison and conversions

* libguile/ports.c (scm_lfwrite_str, scm_lfwrite_substr): signed/unsigned
  conversion and comparison

* libguile/strings.c (scm_string_append): signed/unsigned comparison

14 years agorework the vm support for wide strings
Andy Wingo [Wed, 12 Aug 2009 14:33:49 +0000 (16:33 +0200)]
rework the vm support for wide strings

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.

* libguile/vm-engine.c (vm_error_bad_wide_string_length): New error
  case.

* libguile/vm-i-loader.c (load-unsigned-integer, load-integer)
  (load-keyword): Remove these instructions. The former two are
  obsoleted by make-int64/make-uint64, the latter via make-keyword.
  (load-string): Only handle narrow strings.
  (load-symbol): Only handle narrow symbols. The wide case is handled
  via make-symbol.
  (load-wide-string): New instruction, for wide strings.

* libguile/vm-i-system.c (define): Move here from loaders.c, as now it
  just takes a sym on the stack.
  (make-keyword, make-symbol): New instructions.

* module/language/assembly.scm: Remove removed instructions. No more
  width byte in load-string etc.

* module/language/assembly/compile-bytecode.scm (write-bytecode): Adapt
  to change in instruction set.

* module/language/glil/compile-assembly.scm (glil->assembly): Compile
  define by pushing the sym then emitting (define).
  (dump-object): Dump narrow and wide strings differently. Use
  make-keyword and make-symbol as appropriate.

* module/language/tree-il/compile-glil.scm (flatten): When compiling a
  ref to a primitive (not a call), first see if the primitive is
  actually bound in the root module. (That's not the case with e.g.
  bytevector-u8-ref).

* module/system/xref.scm (program-callee-rev-vars): Don't parse out
  "nexts".

* test-suite/tests/asm-to-bytecode.test ("compiler"): Adapt to bytecode
  format change.

14 years agoFix disassembly of strings and symbols
Michael Gran [Wed, 12 Aug 2009 07:26:12 +0000 (00:26 -0700)]
Fix disassembly of strings and symbols

* module/language/assembly/decompile-bytecode.scm (decode-bytecode):
  fix disassembly of strings, symbols, keywords, and defines

14 years agoQuiet signed/unsigned comparison warnings in chars.[ch]
Michael Gran [Wed, 12 Aug 2009 05:52:49 +0000 (22:52 -0700)]
Quiet signed/unsigned comparison warnings in chars.[ch]

* libguile/chars.h (SCM_MAKE_CHAR): quiet signed/unsigned
  comparison warnings

* libguile/chars.c (scm_i_charname):
  (scm_i_charname_to_char): quiet signed/unsigned comparison
  warnings

14 years agoAvoid unitialized and unused warnings in scm_string_append
Michael Gran [Wed, 12 Aug 2009 05:01:20 +0000 (22:01 -0700)]
Avoid unitialized and unused warnings in scm_string_append

* libguile/strings.c (scm_string_append): avoid warnings

14 years agoRevert to locale-dependent toupper and tolower
Michael Gran [Wed, 12 Aug 2009 04:27:20 +0000 (21:27 -0700)]
Revert to locale-dependent toupper and tolower

To avoid leaving Guile in a broken state, the conversion
from locale-dependent case modification to Unicode case modification
should be an atomic commit

* libguile/chars.c (scm_c_upcase): revert to locale-dependent
  toupper and tolower

14 years agoOnly pass ints to tolower and toupper
Michael Gran [Wed, 12 Aug 2009 04:12:52 +0000 (21:12 -0700)]
Only pass ints to tolower and toupper

* libguile/strings.c (unistring_escapes_to_guile_escapes): cast
  tolower's parameter to int

* libguile/read.c (CHAR_DOWNCASE): cast tolower's parameter to int

14 years agodebitrot the ecmascript compiler
Andy Wingo [Tue, 11 Aug 2009 22:14:44 +0000 (00:14 +0200)]
debitrot the ecmascript compiler

* module/Makefile.am (ECMASCRIPT_LANG_SOURCES):
* module/language/ecmascript/compile-ghil.scm:
* module/language/ecmascript/compile-tree-il.scm: SOURCES): Replace the
  GHIL compiler with a ->tree-il compiler. Not fully functional, but the
  basics work.

* module/language/ecmascript/spec.scm: Only include the tree-il compiler.

* module/language/ecmascript/tokenize.scm (read-punctuation): Avoid
  mutating a constant.

14 years agomake the fallback path look less like line noise
Andy Wingo [Tue, 11 Aug 2009 19:16:05 +0000 (21:16 +0200)]
make the fallback path look less like line noise

* libguile/_scm.h:
* libguile/load.c: Rework to only include the relevant pieces in the
  fallback path.

14 years agoinclude objcode cookie in the fallback path
Andy Wingo [Tue, 11 Aug 2009 18:25:19 +0000 (20:25 +0200)]
include objcode cookie in the fallback path

* libguile/_scm.h (SCM_OBJCODE_COOKIE): Move the objcode cookie define
  here, so that load.c can use it. This is a private header.

* libguile/load.c (FALLBACK_DIR): Include the objcode cookie in the
  fallback path. Should fix problems when objcode changes incompatibly
  during the 1.9 series.

* libguile/objcodes.c: Adapt to SCM_OBJCODE_COOKIE move.

This should fix http://article.gmane.org/gmane.lisp.guile.devel/9059.

14 years agoMore string and symbol tests
Michael Gran [Tue, 11 Aug 2009 05:55:29 +0000 (22:55 -0700)]
More string and symbol tests

        * test-suite/tests/strings.test: more tests

        * test-suite/tests/symbols.test: more tests

14 years agoFix %string-dump and %symbol-dump fields
Michael Gran [Tue, 11 Aug 2009 05:18:47 +0000 (22:18 -0700)]
Fix %string-dump and %symbol-dump fields

        * libguile/strings.c (scm_sys_string_dump): don't print
        stringbuf. Print read-only status.
        (scm_sys_symbol_dump): don't print stringbuf.  Print interned
        status.

14 years agoChange `defined?' to accept a module as its second argument.
Ludovic Courtès [Mon, 10 Aug 2009 17:24:34 +0000 (19:24 +0200)]
Change `defined?' to accept a module as its second argument.

Reported by Daniel Kraft <d@domob.eu>.

* doc/ref/api-binding.texi (Binding Reflection): Update documentation of
  `defined?'.

* libguile/evalext.c (scm_defined_p): Expect a module as the second
  argument, not a lexical environment.

14 years agoMake scm_charprint and scm_i_string_wide_chars SCM_INTERNAL.
Michael Gran [Mon, 10 Aug 2009 12:51:05 +0000 (05:51 -0700)]
Make scm_charprint and scm_i_string_wide_chars SCM_INTERNAL.

Also, scm_charprint is renamed to scm_i_charprint.

        * libguile/strings.h: make scm_i_string_wide_chars internal.

        * libguile/print.h: rename scm_charprint to scm_i_charprint.  Make
        internal.

        * libguile/print.c (scm_i_charprint): renamed from scm_charprint
        (scm_charprint): renamed to scm_i_charprint. All callers changed.

14 years agoImprove %string-dump and %symbol-dump
Michael Gran [Mon, 10 Aug 2009 07:09:33 +0000 (00:09 -0700)]
Improve %string-dump and %symbol-dump

%string-dump and %symbol-dump are modified to return assocation lists
of string and symbol attributes instead of printing to stderr.  They
are no longer conditional on SCM_DEBUG.

        * libguile/strings.c (scm_sys_string_dump)
        (scm_sys_symbol_dump): now returns alist of properties.  No longer
        require that SCM_DEBUG be defined.
        (scm_sys_stringbuf_hist): now conditional on
        SCM_STRING_LENGTH_HISTOGRAM

        * libguile/strings.h: scm_sys_string_dump and scm_sys_symbol dump
        are now declared as API

14 years agoMore comments for string functions
Michael Gran [Mon, 10 Aug 2009 01:06:59 +0000 (18:06 -0700)]
More comments for string functions

        * libguile/strings.c: comments

14 years agoMissing parentheses in SCM_MAKE_CHAR macro
Michael Gran [Sun, 9 Aug 2009 23:01:20 +0000 (16:01 -0700)]
Missing parentheses in SCM_MAKE_CHAR macro

* libguile/chars.h (SCM_MAKE_CHAR): missing parentheses

14 years agoPort position macros shouldn't require enclosing braces
Michael Gran [Sun, 9 Aug 2009 22:58:49 +0000 (15:58 -0700)]
Port position macros shouldn't require enclosing braces

The port position macros incorrectly required enclosing braces
when used within if statements.

        * libguile/ports.h (SCM_INCLINE, SCM_ZEROCOL, SCM_INCCOL)
        (SCM_DECCOL, SCM_TABCOL): enclose macro in do/while

        * libguile/ports.c (update_port_lf): remove extra braces

14 years agoUse a linker version script for libguile.
Ludovic Courtès [Sun, 9 Aug 2009 21:40:11 +0000 (23:40 +0200)]
Use a linker version script for libguile.

* libguile/Makefile.am (libguile_la_LDFLAGS)[HAVE_LD_VERSION_SCRIPT]:
  Use `libguile.map'.
  (EXTRA_DIST): Add `libguile.map'.

* libguile/libguile.map: New file.

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.