guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.1-115-ge4a28


From: Andy Wingo
Subject: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.1-115-ge4a2807
Date: Thu, 16 Jun 2011 12:07:45 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=e4a2807eee1d40f9ed226c7c39c9e78180c27b7d

The branch, stable-2.0 has been updated
       via  e4a2807eee1d40f9ed226c7c39c9e78180c27b7d (commit)
       via  7b0a2576c1687f9b39f409d9df4117549bdc1943 (commit)
       via  636c99d42ddfc44056622253eb66a356a91a3371 (commit)
      from  589bc528bd63291d2faa4bbcef9e402e62e1f72d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e4a2807eee1d40f9ed226c7c39c9e78180c27b7d
Author: Andy Wingo <address@hidden>
Date:   Thu Jun 16 13:29:17 2011 +0200

    update NEWS
    
    * NEWS: Update for 2.0.2.

commit 7b0a2576c1687f9b39f409d9df4117549bdc1943
Author: Andy Wingo <address@hidden>
Date:   Thu Jun 16 13:01:43 2011 +0200

    add docs for shift and reset
    
    * doc/ref/api-control.texi (Prompt Primitives): Break call-with-prompt
      and abort-to-prompt out into a subsubsection.
      (Shift and Reset): New subsubsection.

commit 636c99d42ddfc44056622253eb66a356a91a3371
Author: Andy Wingo <address@hidden>
Date:   Thu Jun 16 12:06:43 2011 +0200

    fix hash-set! on weak tables
    
    * test-suite/tests/weaks.test: Add tests.
    * libguile/hashtab.c (scm_hash_fn_set_x): Fix updates to weak-value hash
      tables to not deadlock inside the alloc lock.

-----------------------------------------------------------------------

Summary of changes:
 NEWS                        |  156 +++++++++++++++++++++++++++++++++++++++++++
 doc/ref/api-control.texi    |  108 +++++++++++++++++++++++++++++
 libguile/hashtab.c          |   53 ++++++++------
 test-suite/tests/weaks.test |   26 +++++++-
 4 files changed, 319 insertions(+), 24 deletions(-)

diff --git a/NEWS b/NEWS
index df6de65..b5715d6 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,162 @@ See the end for copying conditions.
 Please send Guile bug reports to address@hidden
 
 
+Changes in 2.0.2 (since 2.0.1):
+
+* Notable changes
+
+** New control operators: `shift' and `reset'
+    
+See "Shift and Reset" in the manual, for more information.
+
+** `while' as an expression
+    
+Previously the return value of `while' was unspecified.  Now its
+values are specified both in the case of normal termination, and via
+termination by invoking `break', possibly with arguments.  See "while
+do" in the manual for more.
+
+** Disallow access to handles of weak hash tables
+    
+`hash-get-handle' and `hash-create-handle!' are no longer permitted to
+be called on weak hash tables, because the fields in a weak handle could
+be nulled out by the garbage collector at any time, but yet they are
+otherwise indistinguishable from pairs.  Use `hash-ref' and `hash-set!'
+instead.
+
+** More precision for `get-internal-run-time', `get-internal-real-time'
+    
+On 64-bit systems which support POSIX clocks, Guile's internal timing
+procedures offer nanosecond resolution instead of the 10-millisecond
+resolution previously available.  32-bit systems now use 1-millisecond
+timers.
+
+** Guile now measures time spent in GC
+    
+`gc-stats' now returns a meaningful value for `gc-time-taken'.
+
+** Add `gcprof'
+    
+The statprof profiler now exports a `gcprof' procedure, driven by the
+`after-gc-hook', to see which parts of your program are causing GC.  Let
+us know if you find it useful.
+
+** `map', `for-each' and some others now implemented in Scheme
+
+We would not mention this in NEWS, as it is not a user-visible change,
+if it were not for one thing: `map' and `for-each' are no longer
+primitive generics.  Instead they are normal bindings, which can be
+wrapped by normal generics.  This fixes some modularity issues between
+core `map', SRFI-1 `map', and GOOPS.
+
+Also it's pretty cool that we can do this without a performance impact.
+
+** Add `scm_peek_byte_or_eof'.
+    
+This helper is like `scm_peek_char_or_eof', but for bytes instead of
+full characters.
+
+** Implement #:stop-at-first-non-option option for getopt-long
+    
+See "getopt-long Reference" in the manual, for more information.
+
+** Improve R6RS conformance for conditions in the I/O libraries
+    
+The `(rnrs io simple)' module now raises the correct R6RS conditions in
+error cases.  `(rnrs io ports)' is also more correct now, though it is
+still a work in progress.
+
+** All deprecated routines emit warnings
+    
+A few deprecated routines were lacking deprecation warnings.  This has
+been fixed now.
+
+* Speed improvements
+
+** Constants in compiled code now share state better
+
+Constants with shared state, like `("foo")' and `"foo"', now share state
+as much as possible, in the entire compilation unit.  This cuts compiled
+`.go' file sizes in half, generally, and speeds startup.
+
+** VLists: optimize `vlist-fold-right', and add `vhash-fold-right'
+
+These procedures are now twice as fast as they were.
+
+** UTF-8 ports to bypass `iconv' entirely
+    
+This reduces memory usage in a very common case.
+
+** Compiler speedups
+
+The compiler is now about 40% faster.  (Note that this is only the case
+once the compiler is itself compiled, so the build still takes as long
+as it did before.)
+
+** VM speed tuning
+    
+Some assertions that were mostly useful for sanity-checks on the
+bytecode compiler are now off for both "regular" and "debug" engines.
+This together with a fix to cache a TLS access and some other tweaks
+improve the VM's performance by about 20%.
+
+** SRFI-1 list-set optimizations
+
+lset-adjoin and lset-union now have fast paths for eq? sets.
+
+** `memq', `memv' optimizations
+
+These procedures are now at least twice as fast than in 2.0.1.
+
+* Deprecations
+
+** Deprecate scm_whash API
+    
+`scm_whash_get_handle', `SCM_WHASHFOUNDP', `SCM_WHASHREF',
+`SCM_WHASHSET', `scm_whash_create_handle', `scm_whash_lookup', and
+`scm_whash_insert' are now deprecated.  Use the normal hash table API
+instead.
+
+** Deprecate scm_struct_table
+    
+`SCM_STRUCT_TABLE_NAME', `SCM_SET_STRUCT_TABLE_NAME',
+`SCM_STRUCT_TABLE_CLASS', `SCM_SET_STRUCT_TABLE_CLASS',
+`scm_struct_table', and `scm_struct_create_handle' are now deprecated.
+These routines formed part of the internals of the map between structs
+and classes.
+
+** Deprecate scm_internal_dynamic_wind
+    
+The `scm_t_inner' type and `scm_internal_dynamic_wind' are deprecated,
+as the `scm_dynwind' API is better, and this API encourages users to
+stuff SCM values into pointers.
+
+** Deprecate scm_immutable_cell, scm_immutable_double_cell
+    
+These routines are deprecated, as the GC_STUBBORN API doesn't do
+anything any more.
+
+* Manual updates
+
+Andreas Rottman kindly transcribed the missing parts of the `(rnrs io
+ports)' documentation from the R6RS documentation.  Thanks Andreas!
+
+* Bugs fixed
+
+** Fix double-loading of script in -ds case
+** -x error message fix
+** iconveh-related cross-compilation fixes
+** Fix small integer return value packing on big endian machines.
+** Fix hash-set! in weak-value table from non-immediate to immediate
+** Fix call-with-input-file & relatives for multiple values
+** Fix `hash' for inf and nan
+** Fix libguile internal type errors caught by typing-strictness==2
+** Fix compile error in mingw fstat socket detection
+** Fix multithreaded access to internal hash tables
+** Emit a 1-based line number in error messages
+** Fix define-module ordering
+    
+
 Changes in 2.0.1 (since 2.0.0):
 
 * Notable changes
diff --git a/doc/ref/api-control.texi b/doc/ref/api-control.texi
index 4e13527..9f741fd 100644
--- a/doc/ref/api-control.texi
+++ b/doc/ref/api-control.texi
@@ -374,6 +374,17 @@ programming junkie, you probably haven't heard the term, 
``delimited, composable
 continuation''. That's OK; it's a relatively recent topic, but a very useful
 one to know about.
 
address@hidden
+* Prompt Primitives::           Call-with-prompt and abort-to-prompt.
+* Shift and Reset::             The zoo of delimited control operators.
address@hidden menu
+
address@hidden Prompt Primitives
address@hidden Prompt Primitives
+
+Guile's primitive delimited control operators are
address@hidden and @code{abort-to-prompt}.
+
 @deffn {Scheme Procedure} call-with-prompt tag thunk handler
 Set up a prompt, and call @var{thunk} within that prompt.
 
@@ -388,6 +399,17 @@ the call to @code{abort-to-prompt}. The remaining 
arguments to @var{handler} are
 those passed to @code{abort-to-prompt}.
 @end deffn
 
address@hidden {Scheme Procedure} make-prompt-tag [stem]
+Make a new prompt tag.  Currently prompt tags are generated symbols.
+This may change in some future Guile version.
address@hidden deffn
+
address@hidden {Scheme Procedure} default-prompt-tag
+Return the default prompt tag.  Having a distinguished default prompt
+tag allows some useful prompt and abort idioms, discussed in the next
+section.
address@hidden deffn
+
 @deffn {Scheme Procedure} abort-to-prompt tag val ...
 Unwind the dynamic and control context to the nearest prompt named @var{tag},
 also passing the given values.
@@ -461,6 +483,92 @@ Before moving on, we should mention that if the handler of 
a prompt is a
 that prompt will not cause a continuation to be reified. This can be an
 important efficiency consideration to keep in mind.
 
address@hidden Shift and Reset
address@hidden Shift, Reset, and All That
+
+There is a whole zoo of delimited control operators, and as it does not
+seem to be a bounded set, Guile implements support for them in a
+separate module:
+
address@hidden
+(use-modules (ice-9 control))
address@hidden example
+
+Firstly, we have a helpful abbreviation for the @code{call-with-prompt}
+operator.
+
address@hidden {Scheme Syntax} % expr
address@hidden {Scheme Syntax} % expr handler
address@hidden {Scheme Syntax} % tag expr handler
+Evaluate @var{expr} in a prompt, optionally specifying a tag and a
+handler.  If no tag is given, the default prompt tag is used.
+
+If no handler is given, a default handler is installed.  The default
+handler accepts a procedure of one argument, which will called on the
+captured continuation, within a prompt.
+
+Sometimes it's easier just to show code, as in this case:
+
address@hidden
+(define (default-prompt-handler k proc)
+  (% (default-prompt-tag)
+     (proc k)
+     default-prompt-handler))
address@hidden example
+
+The @code{%} symbol is chosen because it looks like a prompt.
address@hidden deffn
+
+Likewise there is an abbreviation for @code{abort-to-prompt}, which
+assumes the default prompt tag:
+
address@hidden {Scheme Procedure} abort val...
+Abort to the default prompt tag, passing @var{val...} to the handler.
address@hidden deffn
+
+As mentioned before, @code{(ice-9 control)} also provides other
+delimited control operators.  This section is a bit technical, and
+first-time users of delimited continuations should probably come back to
+it after some practice with @code{%}.
+
+Still here?  So, when one implements a delimited control operator like
address@hidden, one needs to make two decisions.  Firstly, does
+the handler run within or outside the prompt?  Having the handler run
+within the prompt allows an abort inside the handler to return to the
+same prompt handler, which is often useful.  However it prevents tail
+calls from the handler, so it is less general.
+
+Similarly, does invoking a captured continuation reinstate a prompt?
+Again we have the tradeoff of convenience versus proper tail calls.
+
+These decisions are captured in the Felleisen @dfn{F} operator.  If
+neither the continuations nor the handlers implicitly add a prompt, the
+operator is known as @dfn{--F--}.  This is the case for Guile's
address@hidden and @code{abort-to-prompt}.
+
+If both continuation and handler implicitly add prompts, then the
+operator is @dfn{+F+}.  @code{shift} and @code{reset} are such
+operators.
+
address@hidden {Scheme Syntax} reset body...
+Establish a prompt, and evaluate @var{body...} within that prompt.
+
+The prompt handler is designed to work with @code{shift}, described
+below.
address@hidden deffn
+
address@hidden {Scheme Syntax} shift cont body...
+Abort to the nearest @code{reset}, and evaluate @var{body...} in a
+context in which the captured continuation is bound to @var{cont}.
+
+As mentioned above, both the @var{body...} expression and invocations of
address@hidden implicitly establish a prompt.
address@hidden deffn
+
+Interested readers are invited to explore Oleg Kiselyov's wonderful web
+site at @uref{http://okmij.org/ftp/}, for more information on these
+operators.
+
 
 @node Continuations
 @subsection Continuations
diff --git a/libguile/hashtab.c b/libguile/hashtab.c
index 440738c..6141e4f 100644
--- a/libguile/hashtab.c
+++ b/libguile/hashtab.c
@@ -760,34 +760,36 @@ scm_hash_fn_ref (SCM table, SCM obj, SCM dflt,
     return dflt;
 }
 
-
-
-
-struct set_weak_cdr_data
+struct weak_cdr_data
 {
   SCM pair;
-  SCM new_val;
+  SCM cdr;
 };
 
 static void*
-set_weak_cdr (void *data)
+get_weak_cdr (void *data)
 {
-  struct set_weak_cdr_data *d = data;
+  struct weak_cdr_data *d = data;
 
-  if (SCM_NIMP (SCM_WEAK_PAIR_CDR (d->pair)) && !SCM_NIMP (d->new_val))
-    {
-      GC_unregister_disappearing_link ((GC_PTR) SCM_CDRLOC (d->pair));
-      SCM_SETCDR (d->pair, d->new_val);
-    }
+  if (SCM_WEAK_PAIR_CDR_DELETED_P (d->pair))
+    d->cdr = SCM_BOOL_F;
   else
-    {
-      SCM_SETCDR (d->pair, d->new_val);
-      SCM_I_REGISTER_DISAPPEARING_LINK ((GC_PTR) SCM_CDRLOC (d->pair),
-                                        (GC_PTR) SCM2PTR (d->new_val));
-    }
+    d->cdr = SCM_CDR (d->pair);
+
   return NULL;
 }
 
+static SCM
+weak_pair_cdr (SCM x)
+{
+  struct weak_cdr_data data;
+
+  data.pair = x;
+  GC_call_with_alloc_lock (get_weak_cdr, &data);
+
+  return data.cdr;
+}
+
 SCM
 scm_hash_fn_set_x (SCM table, SCM obj, SCM val,
                   scm_t_hash_fn hash_fn, scm_t_assoc_fn assoc_fn,
@@ -798,16 +800,21 @@ scm_hash_fn_set_x (SCM table, SCM obj, SCM val,
   pair = scm_hash_fn_create_handle_x (table, obj, val,
                                       hash_fn, assoc_fn, closure);
 
-  if (SCM_UNLIKELY (!scm_is_eq (SCM_CDR (pair), val)))
+  if (!scm_is_eq (SCM_CDR (pair), val))
     {
       if (SCM_UNLIKELY (SCM_HASHTABLE_WEAK_VALUE_P (table)))
         {
-          struct set_weak_cdr_data data;
-
-          data.pair = pair;
-          data.new_val = val;
+          /* If the former value was on the heap, we need to unregister
+             the weak link.  */
+          SCM prev = weak_pair_cdr (pair);
           
-          GC_call_with_alloc_lock (set_weak_cdr, &data);
+          SCM_SETCDR (pair, val);
+
+          if (SCM_NIMP (prev) && !SCM_NIMP (val))
+            GC_unregister_disappearing_link ((GC_PTR) SCM_CDRLOC (pair));
+          else
+            SCM_I_REGISTER_DISAPPEARING_LINK ((GC_PTR) SCM_CDRLOC (pair),
+                                              (GC_PTR) SCM2PTR (val));
         }
       else
         SCM_SETCDR (pair, val);
diff --git a/test-suite/tests/weaks.test b/test-suite/tests/weaks.test
index 3c9a290..d0f6c5e 100644
--- a/test-suite/tests/weaks.test
+++ b/test-suite/tests/weaks.test
@@ -1,5 +1,5 @@
 ;;;; weaks.test --- tests guile's weaks     -*- scheme -*-
-;;;; Copyright (C) 1999, 2001, 2003, 2006, 2009, 2010 Free Software 
Foundation, Inc.
+;;;; Copyright (C) 1999, 2001, 2003, 2006, 2009, 2010, 2011 Free Software 
Foundation, Inc.
 ;;;; 
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
@@ -208,6 +208,30 @@
                      (hash-ref z test-key)
                      #t))))
 
+   (pass-if "hash-set!, weak val, im -> im"
+     (let ((t (make-weak-value-hash-table)))
+       (hash-set! t "foo" 1)
+       (hash-set! t "foo" 2)
+       (equal? (hash-ref t "foo") 2)))
+
+   (pass-if "hash-set!, weak val, im -> nim"
+     (let ((t (make-weak-value-hash-table)))
+       (hash-set! t "foo" 1)
+       (hash-set! t "foo" "baz")
+       (equal? (hash-ref t "foo") "baz")))
+
+   (pass-if "hash-set!, weak val, nim -> nim"
+     (let ((t (make-weak-value-hash-table)))
+       (hash-set! t "foo" "bar")
+       (hash-set! t "foo" "baz")
+       (equal? (hash-ref t "foo") "baz")))
+
+   (pass-if "hash-set!, weak val, nim -> im"
+     (let ((t (make-weak-value-hash-table)))
+       (hash-set! t "foo" "bar")
+       (hash-set! t "foo" 1)
+       (equal? (hash-ref t "foo") 1)))
+
    (pass-if "assoc can do anything"
             ;; Until 1.9.12, as hash table's custom ASSOC procedure was
             ;; called with the GC lock alloc held, which imposed severe


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]