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

17263 commits

Author SHA1 Message Date
Andy Wingo
3a0d141233 Rewrite %method-more-specific? to be in Scheme
* libguile/goops.h:
* libguile/goops.c (more_specificp, scm_sys_method_more_specific_p):
* module/oop/goops.scm (%method-more-specific?): Rewrite in Scheme.  We
  remove the scm_sys_method_more_specific_p interface as it is a private
  interface and it's not extensible.
2015-01-23 16:15:59 +01:00
Andy Wingo
e4aa440a2f Deprecate C interfaces scm_compute_applicable_methods, scm_find_method
* libguile/deprecated.h:
* libguile/deprecated.c (scm_compute_applicable_methods): Deprecate.
  This was the boot version of compute-applicable-methods, not the full
  version; the right thing to do is to call scheme.
  (scm_find_method): Deprecate.  Again, the right thing is to do this on
  the Scheme level.

* libguile/goops.c:
* libguile/goops.h: Deprecated code moved to deprecated.[ch].
2015-01-23 16:15:59 +01:00
Andy Wingo
c0a56ec78d %compute-applicable-methods in Scheme
* libguile/goops.c: Move %compute-applicable-methods to Scheme.
  (scm_sys_goops_loaded): No need to initialize
  var_compute_applicable_methods.
* libguile/goops.h (scm_sys_compute_applicable_methods): Remove.  This
  was internal so it shouldn't cause a problem.

* module/oop/goops.scm (%sort-applicable-methods):
  (%compute-applicable-methods): New definitions.
2015-01-23 16:15:59 +01:00
Andy Wingo
6679375332 Mark two coverage tests as XFAIL
* test-suite/tests/coverage.test ("several times", "one proc hit, one
  proc unused"): Mark as XFAIL until we can fix either the expander or
  the compiler to have proper source info.
2015-01-23 16:15:59 +01:00
Andy Wingo
e00c0a4824 Fix the assembler for unexpected source properties
* module/system/vm/assembler.scm (link-debug): Fix for source properties
  that don't have line and column, as are currently being produced by
  the new lalr.
2015-01-23 16:11:10 +01:00
Andy Wingo
4247d8e34e Merge commit '5b7632331e'
Conflicts:
	module/oop/goops.scm
2015-01-22 14:54:17 +01:00
Andy Wingo
0a5b437ef9 Merge commit 'ed72201a79'
Conflicts:
	test-suite/tests/r6rs-ports.test
2015-01-22 14:53:06 +01:00
Andy Wingo
e19235e21b Merge commit '01a301d1b6'
Conflicts:
	libguile/hash.c
2015-01-22 14:49:36 +01:00
Andy Wingo
baf90102cf Merge commit '894d0b894d'
Conflicts:
	libguile/hash.c
2015-01-22 14:48:40 +01:00
Andy Wingo
1cd779140d Merge commit '5943a62042' 2015-01-22 14:38:00 +01:00
Andy Wingo
baa74d3695 Merge commit '37b1453032' 2015-01-22 14:37:52 +01:00
Andy Wingo
6f248df1f6 Merge commit 'cdcba5b2f6'
Conflicts:
	module/statprof.scm
2015-01-22 14:37:18 +01:00
Ludovic Courtès
1abe6ba5d8 Really disable stack underflow checks when VM_CHECK_UNDERFLOW == 0.
* libguile/vm-engine.h: Use '#if VM_CHECK_UNDERFLOW' instead of
  '#ifdef'.
2015-01-22 14:01:16 +01:00
Andy Wingo
2f5c5d09a0 Merge commit '5d971db802'
Conflicts:
	libguile/ports.c
2015-01-22 13:34:48 +01:00
Andy Wingo
1fc3fc11ff Merge commit '47ca15c7df' 2015-01-22 13:33:07 +01:00
Andy Wingo
7c6ce75e2c Merge commit '7c433cbbce'
Conflicts:
	meta/Makefile.am
2015-01-22 13:32:59 +01:00
Andy Wingo
12dfe6568c Merge commit '5fac1a7ada'
Conflicts:
	configure.ac
	doc/ref/libguile-parallel.texi
2015-01-22 13:30:25 +01:00
Andy Wingo
a5b5cb422e Merge commit '8cf2a7ba74' 2015-01-22 13:24:30 +01:00
Andy Wingo
a51111dd25 Merge commit '81d2c84674'
Some fixups in bytevectors.c.
2015-01-22 13:23:51 +01:00
Andy Wingo
086bbcc874 Merge commit 'fdd319e9bd' 2015-01-22 13:04:34 +01:00
Andy Wingo
d5dffec4ff Merge commit 'a7bbba0583' 2015-01-22 13:04:11 +01:00
Andy Wingo
e2fafeb901 Keywords have a tc7
* libguile/tags.h (scm_tc7_keyword): Allocate a tc7, so that the VM can
  have cheap keyword? tests.

* libguile/keywords.c:
* libguile/keywords.h: Adapt.

* libguile/goops.c (scm_class_of, scm_sys_goops_early_init): Capture
  <keyword>.

* libguile/print.c (iprin1): Inline keyword printer.

* libguile/evalext.c (scm_self_evaluating_p): Add keywords here.

* libguile/deprecated.h:
* libguile/deprecated.c (scm_tc16_keyword): Deprecate.

* module/language/cps/compile-bytecode.scm (compile-fun): Add keyword?
  case, and bitvector? case while we're at it.
* module/language/cps/effects-analysis.scm (define-primitive-effects):
  Add bytevector?, keyword?, and bitvector? cases.

* module/language/cps/primitives.scm (*branching-primcall-arities*): Add
  keyword?.

* module/language/cps/types.scm (bitvector?, keyword?, bytevector?): Add
  branch inferrers.

* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  (*effect-free-primitives*):
  (*effect+exception-free-primitives*): Add bytevector?, keyword?, and
  bitvector?.

* module/oop/goops.scm (<keyword>): New class.

* module/system/base/types.scm (%tc7-keyword, cell->object): Add cases.

* module/system/vm/assembler.scm (br-if-keyword): New definition.
* module/system/vm/disassembler.scm (code-annotation): Add br-if-tc7
  case for keywords.

* test-suite/tests/types.test ("clonable objects"): Update now that
  keywords are cloneable.
2015-01-22 13:03:11 +01:00
Andy Wingo
27b3b5b92d Add allocate-struct, struct-ref, struct-set! instructions
* libguile/vm-engine.c (allocate-struct, struct-ref, struct-set!): New
  instructions, to complement their "immediate" variants.

* module/language/cps/compile-bytecode.scm (compile-fun):
* module/system/vm/assembler.scm (system): Wire up the new instructions.
2015-01-22 12:53:33 +01:00
Andy Wingo
678995ff79 Merge commit '5af307de43'
Conflicts:
	test-suite/tests/reader.test
2015-01-22 12:50:18 +01:00
Andy Wingo
24d4f029bf Merge commit 'b1451ad859' 2015-01-22 12:46:11 +01:00
Andy Wingo
5b7632331e Fix #:init-value on class-allocated slots
Allocating an instance of a class with a #:class or #:each-subclass slot
allocation should not re-initialize the class-allocated slot.  In Guile
1.8, this worked by effectively doing a slot-bound? within
%initialize-object.  In Guile 2.0 we instead initialize the slot when it
is allocated -- in compute-get-n-set.

* module/oop/goops.scm (compute-getters-n-setters): Don't set an
  init-thunk for class-allocated slots.
  (compute-get-n-set): Initialize class-allocated slots here, if an
  init-thunk or init-value are present.

* test-suite/tests/goops.test ("#:each-subclass"): Add test.
2015-01-22 12:40:43 +01:00
Ludovic Courtès
ed72201a79 Fix buffer overrun with unbuffered custom binary input ports.
Fixes <http://bugs.gnu.org/19621>.

Before that, in 'cbip_fill_input', BUFFERED would be set to 0 when
reading from 'scm_getc' et al, because 'shortbuf' was being used.  Thus,
we could eventually execute this line:

      /* Copy the data back to the internal buffer.  */
      memcpy ((char *) c_port->read_pos, SCM_BYTEVECTOR_CONTENTS (bv),
	      c_octets);

But 'read_pos' would quickly point to the fields beyond 'shortbuf',
thereby leading to a corruption of the 'scm_t_port' itself.

* libguile/r6rs-ports.c (cbip_setvbuf): When READ_SIZE is 0, keep using
  BV as the 'read_buf'.
  (cbip_fill_input): Adjust assertion to accept 'read_buf_size = 1'.
* test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports")["custom binary
  input port unbuffered & 'get-string-all'", "custom binary input port
  unbuffered UTF-8 & 'get-string-all'"]: New tests.
2015-01-18 22:05:44 +01:00
Ludovic Courtès
e1d29ee4f7 Improve output of command-line errors.
* module/ice-9/command-line.scm (shell-usage): Add 'newline' call when
  FMT is true.
  (compile-shell-switches)[error]: Prepend "error: " and append "~%" to
  FMT.
  Use a lower-case message.
2015-01-13 09:30:08 +01:00
Ludovic Courtès
01a301d1b6 Optimize 'string-hash'.
This yields a 50% improvement on the "narrow string" benchmark of
'hash.bm', 41% on "wide string", and 76% on "long string".

* libguile/hash.c (scm_i_string_hash): Rewrite to avoid
  'scm_i_string_ref' calls.
2015-01-11 22:40:07 +01:00
Ludovic Courtès
87a8b56f8c Add 'string-hash' benchmarks.
* benchmark-suite/benchmarks/hash.bm: New file.
* benchmark-suite/Makefile.am (SCM_BENCHMARKS): Add it.
2015-01-11 22:37:00 +01:00
Ludovic Courtès
894d0b894d Deprecate 'scm_string_hash'.
This function has been unused internally for some time and is undocumented.

* libguile/hash.c (scm_string_hash): Wrap if #if SCM_ENABLE_DEPRECATED
  == 1.
* libguile/hash.h (scm_string_hash): Likewise, and replace SCM_API with
  SCM_DEPRECATED.
2015-01-11 22:11:17 +01:00
Ludovic Courtès
5943a62042 Optimize 'write' for strings.
This shows a 19% improvement on the "string without escapes"
micro-benchmark of 'write.bm', and 12% on "string with escapes".

* libguile/print.c (iprin1) <scm_tc7_string>: Replace 'scm_i_string_ref'
  loop with a call to 'write_string'.
  (display_character): Adjust description of return value in comment.
  (write_string): New function.
2015-01-11 21:57:54 +01:00
Ludovic Courtès
37b1453032 Avoid converting the 'mode' argument of 'open-file'.
* libguile/fports.c (scm_open_file_with_encoding): const-qualify 'md'
  and 'ptr'.  Add call to 'scm_i_try_narrow_string'.  Use
  'scm_i_string_chars' instead of 'scm_to_locale_string' plus '
  scm_dynwind_free'.
* test-suite/tests/ports.test ("invalid wide mode string",
  "valid wide mode string"): New tests.
2015-01-11 20:59:03 +01:00
Ludovic Courtès
cdcba5b2f6 statprof: 'statprof' and 'with-statprof' return the code's return values.
* module/statprof.scm (statprof): Return the return values of THUNK.
  (with-statprof): Adjust docstring accordingly.
* test-suite/tests/statprof.test ("return values"): New test.
* doc/ref/statprof.texi (Statprof): Adjust accordingly.
2015-01-11 20:44:44 +01:00
Ludovic Courtès
5d971db802 Improve deprecation message of 'scm_add_to_port_table'.
Reported by Thien-Thi Nguyen <ttn@gnu.org>.

* libguile/ports.c (scm_add_to_port_table): Mention
  'scm_new_port_table_entry'.
2015-01-09 15:47:15 +01:00
Mark H Weaver
015c3c08af Assembler: Cope with non-string port filenames.
Fixes <http://bugs.gnu.org/19354>.
Reported by Linas Vepstas <linasvepstas@gmail.com>.

* module/system/vm/assembler.scm (write-sources): Intern the filename
  only if it's a string.  (For sockets, the filename is a symbol).
2014-12-14 10:24:00 -05:00
Andy Wingo
95de4f52a8 Convert primitive-eval to "compile" its expressions to linked closures
* libguile/memoize.c (memoize): Fix meta on subsequent case-lambda
  clauses.

* module/ice-9/eval.scm (primitive-eval): Rewrite to compile expressions
  to thunks, to avoid runtime dispatch cost.
2014-12-10 17:32:16 +01:00
Andy Wingo
dc33a94502 Fix syntax.test
* test-suite/tests/syntax.test (exception:variable-ref): Change expected
  error.
2014-12-10 16:25:50 +01:00
Andy Wingo
5bfc0653d6 Minor evaluator tweaks
* libguile/eval.c (eval): Remove unused variable.
* libguile/memoize.c (unmemoize): Fix unmemoization.
* module/ice-9/eval.scm: Attempt to speed up common box-ref cases.
2014-12-07 19:03:19 +01:00
Andy Wingo
e6a42e6765 Simplify variable resolution in the evaluator
* libguile/expand.c (convert_assignment): Handle creation of the default
  lambda-case body here.

* libguile/eval.c (eval):
* module/ice-9/eval.scm (primitive-eval):

* libguile/memoize.h:
* libguile/memoize.c (MAKMEMO_BOX_REF, MAKMEMO_BOX_SET):
  (MAKMEMO_TOP_BOX, MAKMEMO_MOD_BOX): Refactor all global var resolution
  to go through "resolve".  Add "box-ref" and "box-set!".  Rename
  memoize-variable-access! to %resolve-variable, and don't be
  destructive.
2014-12-07 15:52:34 +01:00
Andy Wingo
a3cae847d0 Closure conversion in evaluator
* libguile/memoize.c (MAKMEMO_CAPTURE_ENV, push_nested_link)
  (push_flat_link, env_link_is_flat, env_link_vars)
  (env_link_add_flat_var, lookup, capture_flat_env, memoize): Capture
  flat environments around closures.
2014-12-07 09:34:22 +01:00
Andy Wingo
99fb07e19b Add capture-env to evaluator
* libguile/eval.c (eval):
* libguile/memoize.c (memoized_tags, unmemoize):
* libguile/memoize.h (SCM_M_CAPTURE_ENV):
* module/ice-9/eval.scm (primitive-eval): Add capture-env memoized
  expression type.
2014-12-06 19:43:24 +01:00
Ludovic Courtès
47ca15c7df build: Better handle substitutions in 'guile-2.0.pc' & co.
* meta/Makefile.am (dependency_substitutions): Use '|' as the separate
  instead of ','.  See <http://hydra.nixos.org/build/17684751>.
2014-12-06 15:57:23 +01:00
Andy Wingo
cfdc8416a2 Simplify the interpreter for trivial inits and no letrec
* libguile/memoize.c (FULL_ARITY): Serialize "ninits" and the unbound
  value instead of the init list.
  (memoize): Adapt to FULL_ARITY changes.  Remove LETREC case.
  (unmemoize): Adapt to memoized code change.

* libguile/eval.c (BOOT_CLOSURE_PARSE_FULL): Adapt to parse ninits and
  unbound instead of inits.
  (eval): Lexical-ref can no longer raise an error.
  (prepare_boot_closure_env_for_apply): Adapt to inits change.

* module/ice-9/eval.scm (primitive-eval): Adapt to ninits/unbound
  change.

* libguile/expand.c (expand_named_let): Fix lambda-case creation to make
  lists for opt and inits.
2014-12-05 16:54:35 +01:00
Andy Wingo
7974c57937 Assignment conversion in the interpreter
* libguile/expand.c (compute_assigned, convert_assignment)
  (scm_convert_assignment): New functions.

* libguile/expand.h: Declare scm_convert_assignment.

* libguile/memoize.c (scm_memoize_expression): Do assignment conversion
  before memoization.

* test-suite/tests/syntax.test ("letrec"): Detection of unbound letrec
  variables now works.
2014-12-05 11:45:36 +01:00
Ludovic Courtès
7c433cbbce build: Add missing substitutions for 'guile-2.0.pc'.
This is a followup to 5fac1a7.

* meta/Makefile.am (substitute): Add GUILE_* and LIBGUILE_* substitutions,
  and $(dependency_substitutions).
  (dependency_substitutions): New variable.
2014-12-03 23:09:12 +01:00
Ludovic Courtès
680135b6a3 doc: Clarify the unit of the 'offset' argument of 'seek'.
Reported in <http://bugs.gnu.org/18520>
by David Kastrup <dak@gnu.org>.

* doc/ref/api-io.texi (Random Access): Clarify the unit of the 'offset'
  argument to 'seek'.
2014-12-03 19:07:28 +01:00
Ludovic Courtès
5fac1a7ada Add the 'guild' and 'guile' variables to 'guile-2.0.pc'.
* configure.ac: Remove meta/guile-2.0.pc and
  meta/guile-2.0-uninstalled.pc from 'AC_CONFIG_FILES'.
* meta/Makefile.am (substitute): New variable.
  (guile-2.0.pc, guile-2.0-uninstalled.pc): New targets.
  (guile-config, guild): Use $(substitute) instead of duplicated sed
  script.
  (CLEANFILES): Add the .pc files.
* meta/guile-2.0.pc.in (bindir, guild, guile): New variables.
* doc/ref/libguile-parallel.texi (Parallel Installations): Document the
  'guild' and 'guile' pkg-config variables.
2014-12-03 18:59:36 +01:00
Ludovic Courtès
8cf2a7ba74 Update (system base lalr) from upstream.
Suggested by Jan Nieuwenhuizen <janneke@gnu.org>.

* module/system/base/lalr.upstream.scm: Update from
  <https://github.com/schemeway/lalr-scm.git>, commit 4c4f149.
2014-12-02 21:25:56 +01:00
Ludovic Courtès
7e466e0265 doc: Tell when 'GUILE_INSTALL_LOCALE' first appeared.
* doc/ref/guile-invoke.texi (Environment Variables): Add footnote about
  the Guile version where 'GUILE_INSTALL_LOCALE' appeared.
2014-12-02 21:25:56 +01:00