Re: [Chicken-hackers] will we have a release this year?

2012-09-23 Thread Andy Bennett
Hi,

  I have been testing 4.8.0rc4 quite a bit this week, and everything
 seems to work fine, so if there are no objections, I will make the
 release next Monday.

Did people see my bug report on chicken-users regarding the environments
egg and eval? I posted in the Re: [Chicken-users] Chicken 4.8.0 release
candidate 4 now available thread on 2012/09/18.

--
Another was segfaulting and continued to segfault on 'load'. I narrowed
it down to this repro case in the interpreter:

-
#;1 (use environments)
#;2 (define widget-eval-env (make-parameter (environment-copy
(scheme-report-environment 5) #t)))
-

Using Mortiz's rewrite branch of the environments egg:
https://anonymous:@code.call-cc.org/svn/chicken-eggs/release/4/environments/branches/rewrite/
... stops the segfault.

I can get a binary out but it throws an exception somewhere it didn't
used to:

-
unbound variable
##sys#list
-

...and my debugging efforts so far point to a problem with eval and an
environment from the environments egg.
--




Regards,
@ndy

-- 
andy...@ashurst.eu.org
http://www.ashurst.eu.org/
0x7EBA75FF


___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


[Chicken-hackers] [PATCH] Re: [PATCH] Update irregex to 0.9.0

2012-09-23 Thread Peter Bex
On Thu, Sep 20, 2012 at 02:32:47PM +0200, Sven Hartrumpf wrote:
 Hi.
 
 Peter wrote:
  I decided to go ahead
  and update our core irregex to the latest version.  The attached patches
  (all 4 of them) synchronizes us with upstream 0.9.0 irregex.  This gives
  some performance improvements for submatches.
 
 And some severe bugs?

While I did expect bugs to crop up when running regexes in the wild, I
didn't expect any bugs in this part of the code.  The surprising thing
is that our test suite has zero tests for searching when there is
trailing data with submatches.

The reason this failed is because, when searching, irregex runs the DFA
over a string and records the positions of matching substrings.
This means that the memory slots which get manipulated during operation
keep getting manipulated while processing the trailing data.  Then, when
it's finished, it jumps back and reads out the old indices and applies
the old finalizers, but does so using the current values of the memory
slots.  This is obviously wrong.

I've added a simplified test case and fixed the code by making it run
the finalizer whenever transitioning from an accepting state to a
nonaccepting state, thereby preserving the state of the memory slots
at the time the match is found.  I've also cleaned up my code a little
because returning to it after a few months, it was a little hard to
understand.  See the attached two patches.

Thanks for reporting this bug!

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music.
-- Donald Knuth
From 0f48b3ad0d09bcaf0648aca6f12e1458ccadfd48 Mon Sep 17 00:00:00 2001
From: Peter Bex peter@xs4all.nl
Date: Sun, 23 Sep 2012 15:35:51 +0200
Subject: [PATCH 1/2] Irregex: Use proper abstractions for manipulating the
 nfa-multi-state representation, to make the code more
 readable and maintainable. (upstream changeset
 65b8e4a1529c)

---
 irregex-core.scm |  158 +-
 1 files changed, 85 insertions(+), 73 deletions(-)

diff --git a/irregex-core.scm b/irregex-core.scm
index 18bb50a..edfbf01 100644
--- a/irregex-core.scm
+++ b/irregex-core.scm
@@ -2392,23 +2392,19 @@
 (nfa-set-epsilons! nfa i (cons (cons x t) eps)
 
 (define (nfa-get-reorder-commands nfa mst)
-  (cond ((assoc mst
-(vector-ref nfa (+ (* (nfa-multi-state-hash nfa mst)
-  *nfa-num-fields*) 2)))
+  (cond ((assoc mst (vector-ref nfa (+ (* (mst-hash mst) *nfa-num-fields*) 2)))
  = cdr)
 (else #f)))
 (define (nfa-set-reorder-commands! nfa mst x)
-  (let ((i (+ (* (nfa-multi-state-hash nfa mst) *nfa-num-fields*) 2)))
+  (let ((i (+ (* (mst-hash mst) *nfa-num-fields*) 2)))
 (vector-set! nfa i (cons (cons mst x) (vector-ref nfa i)
 
 (define (nfa-get-closure nfa mst)
-  (cond ((assoc mst
-(vector-ref nfa (+ (* (nfa-multi-state-hash nfa mst)
-  *nfa-num-fields*) 3)))
+  (cond ((assoc mst (vector-ref nfa (+ (* (mst-hash mst) *nfa-num-fields*) 3)))
  = cdr)
 (else #f)))
 (define (nfa-add-closure! nfa mst x)
-  (let ((i (+ (* (nfa-multi-state-hash nfa mst) *nfa-num-fields*) 3)))
+  (let ((i (+ (* (mst-hash mst) *nfa-num-fields*) 3)))
 (vector-set! nfa i (cons (cons mst x) (vector-ref nfa i)
 
 ;; Compile and return the vector of NFA states (in groups of
@@ -2668,18 +2664,32 @@
 
  NFA multi-state representation
 
-(define (nfa-multi-state-hash nfa mst)
+(define *mst-first-state-index* 3)
+
+(define (mst-mappings-summary mst)
+  (vector-ref mst 0))
+
+(define (mst-num-states mst)
+  (vector-ref mst 1))
+
+(define (mst-num-states-set! mst num)
+  (vector-set! mst 1 num))
+
+(define (mst-hash mst)
   ;; We could do (modulo X (nfa-num-states nfa)) here which would be faster,
   ;; but we can't assume a full numerical tower (and updating *could*
   ;; produce a bignum), so we do it each time when updating the hash.
   (vector-ref mst 2))
 
+(define (mst-hash-set! mst hash)
+  (vector-set! mst 2 hash))
+
 ;; Returns #f if NFA state does not occur in multi-state
-(define (nfa-state-mappings mst state)
-  (vector-ref mst (+ state 3)))
+(define (mst-state-mappings mst state)
+  (vector-ref mst (+ state *mst-first-state-index*)))
 
-(define (nfa-multi-state-mappings-summary mst)
-  (vector-ref mst 0))
+(define (mst-state-mappings-set! mst state mappings)
+  (vector-set! mst (+ state *mst-first-state-index*) mappings))
 
 ;; A multi-state holds a set of states with their tag-to-slot mappings.
 ;; Slot 0 contains a summary of all mappings for all states in the multi-state.
@@ -2689,35 +2699,35 @@
 ;; 

[Chicken-hackers] [PATCH] Clean up some code

2012-09-23 Thread Peter Bex
Hi all,

Here are two cleanup patches which take care of things that were in my
notes.  The first is a couple of procedures which are simply unused.
Two of those are marked for binary compatibility, but have been marked
as such for a long time (since 2010).  I think we don't need to bump the
binary version since that has already happened a few times in between
and nothing in the new version generates code that uses these procedures.

The second patch removes the last remnants of the unboxing code.  The
compiler doesn't generate calls to them anymore, and they're all inlined
procedures or C macros, so I think they can be safely taken out.

There are still quite a few occurrances of the word box in the
compiler, though.  Can those all be removed?  It looks like some type
of boxing still exists, even if not the full boxing/unboxing that was
taken out.  Could someone explain the purpose of this?

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music.
-- Donald Knuth
From 46b50413de1221fbf542608f1b923d9b104783d8 Mon Sep 17 00:00:00 2001
From: Peter Bex peter@xs4all.nl
Date: Sun, 23 Sep 2012 20:38:34 +0200
Subject: [PATCH 1/2] Remove some unused procedures and old binary
 compatibility stuff:

- ##sys#double-number
- find-lambda-container
- explicitly-consed list
- contains?
- ##sys#call-with-cthulhu

- C_exact_to_inexact
- C_string_to_number
- C_call_with_cthulhu
---
 c-platform.scm |3 +-
 chicken.h  |3 --
 compiler-namespace.scm |1 -
 compiler.scm   |   11 +-
 library.scm|2 -
 runtime.c  |   52 +---
 support.scm|6 -
 7 files changed, 3 insertions(+), 75 deletions(-)

diff --git a/c-platform.scm b/c-platform.scm
index 32f9b88..4423cf6 100644
--- a/c-platform.scm
+++ b/c-platform.scm
@@ -184,7 +184,7 @@
 ##sys#foreign-char-argument ##sys#foreign-fixnum-argument 
##sys#foreign-flonum-argument
 ##sys#foreign-block-argument ##sys#foreign-struct-wrapper-argument
 ##sys#foreign-string-argument ##sys#foreign-pointer-argument ##sys#void
-##sys#foreign-integer-argument ##sys#foreign-unsigned-integer-argument 
##sys#double-number
+##sys#foreign-integer-argument ##sys#foreign-unsigned-integer-argument
 ##sys#peek-fixnum ##sys#setislot ##sys#poke-integer ##sys#permanent? 
##sys#values ##sys#poke-double
 ##sys#intern-symbol ##sys#make-symbol ##sys#null-pointer? ##sys#peek-byte
 ##sys#file-exists?) )
@@ -966,7 +966,6 @@
 (rewrite '##sys#setislot 17 3 C_i_set_i_slot)
 (rewrite '##sys#poke-integer 17 3 C_poke_integer)
 (rewrite '##sys#poke-double 17 3 C_poke_double)
-(rewrite '##sys#double-number 17 1 C_double_to_number)
 (rewrite 'string=? 17 2 C_i_string_equal_p C_u_i_string_equal_p)
 (rewrite 'string-ci=? 17 2 C_i_string_ci_equal_p)
 (rewrite '##sys#fudge 17 1 C_fudge)
diff --git a/chicken.h b/chicken.h
index 8293f07..90a1475 100644
--- a/chicken.h
+++ b/chicken.h
@@ -1716,9 +1716,7 @@ C_fctexport void C_ccall C_allocate_vector(C_word c, 
C_word closure, C_word k, C
 C_fctexport void C_ccall C_string_to_symbol(C_word c, C_word closure, C_word 
k, C_word string) C_noret;
 C_fctexport void C_ccall C_build_symbol(C_word c, C_word closure, C_word k, 
C_word string) C_noret;
 C_fctexport void C_ccall C_flonum_fraction(C_word c, C_word closure, C_word k, 
C_word n) C_noret;
-C_fctexport void C_ccall C_exact_to_inexact(C_word c, C_word closure, C_word 
k, C_word n) C_noret; /*XXX left for binary compatibility */
 C_fctexport void C_ccall C_quotient(C_word c, C_word closure, C_word k, C_word 
n1, C_word n2) C_noret;
-C_fctexport void C_ccall C_string_to_number(C_word c, C_word closure, C_word 
k, C_word str, ...) C_noret; /*XXX left for binary compatibility */
 C_fctexport void C_ccall C_number_to_string(C_word c, C_word closure, C_word 
k, C_word num, ...) C_noret;
 C_fctexport void C_ccall C_fixnum_to_string(C_word c, C_word closure, C_word 
k, C_word num) C_noret;
 C_fctexport void C_ccall C_get_argv(C_word c, C_word closure, C_word k) 
C_noret; /* OBSOLETE */
@@ -1746,7 +1744,6 @@ C_fctexport void C_ccall C_set_dlopen_flags(C_word c, 
C_word closure, C_word k,
 C_fctexport void C_ccall C_dload(C_word c, C_word closure, C_word k, C_word 
name, C_word entry) C_noret;
 C_fctexport void C_ccall C_become(C_word c, C_word closure, C_word k, C_word 
table) C_noret;
 C_fctexport void C_ccall C_locative_ref(C_word c, C_word closure, C_word k, 
C_word loc) C_noret;
-C_fctexport void C_ccall C_call_with_cthulhu(C_word c, C_word self, C_word k, 
C_word proc) C_noret;
 C_fctexport void C_ccall C_copy_closure(C_word c, C_word closure, C_word k, 
C_word proc) C_noret;
 C_fctexport void 

Re: [Chicken-hackers] [PATCH] Re: [PATCH] Update irregex to 0.9.0

2012-09-23 Thread Felix
 I've added a simplified test case and fixed the code by making it run
 the finalizer whenever transitioning from an accepting state to a
 nonaccepting state, thereby preserving the state of the memory slots
 at the time the match is found.  I've also cleaned up my code a little
 because returning to it after a few months, it was a little hard to
 understand.  See the attached two patches.

Pushed, thanks.


cheers,
felix

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


Re: [Chicken-hackers] [PATCH] Clean up some code

2012-09-23 Thread Felix
 Here are two cleanup patches which take care of things that were in my
 notes.  The first is a couple of procedures which are simply unused.
 Two of those are marked for binary compatibility, but have been marked
 as such for a long time (since 2010).  I think we don't need to bump the
 binary version since that has already happened a few times in between
 and nothing in the new version generates code that uses these procedures.

Note that some routines might be used by eggs. In particular
##sys#call-with-cthulhu, which is used in the suspensions
egg. Moreover, that procedure is quite useful, it serves a paticular
need. I can't go into details in public, because THEY mustn't know
about this - I'm sure you understand.

I have to go over the other removals and have to check whether they
are truly not needed anymore.

 
 The second patch removes the last remnants of the unboxing code.  The
 compiler doesn't generate calls to them anymore, and they're all inlined
 procedures or C macros, so I think they can be safely taken out.

Rather not, as unboxing will come back sooner or later.

 
 There are still quite a few occurrances of the word box in the
 compiler, though.  Can those all be removed?  It looks like some type
 of boxing still exists, even if not the full boxing/unboxing that was
 taken out.  Could someone explain the purpose of this?

Which occurrances do you mean exactly?


cheers,
felix

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


[Chicken-hackers] [PATCH] use more primitive operations in compiler-syntax for formatted output

2012-09-23 Thread Felix
The compiler-syntax for [sf]printf can be made slightly more efficient 
by adding a port-check at the beginning and use unsafe output-primitives
where possible.


cheers,
felix
From f875b7704106e0f07f7bfd13b4a9733b5f35acd2 Mon Sep 17 00:00:00 2001
From: felix fe...@call-with-current-continuation.org
Date: Sun, 23 Sep 2012 23:44:58 +0200
Subject: [PATCH] use lower-level runtime routines in compiler-syntax expansion of [sf]printf

---
 compiler-syntax.scm |   33 -
 1 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/compiler-syntax.scm b/compiler-syntax.scm
index 65a80db..418a0c9 100644
--- a/compiler-syntax.scm
+++ b/compiler-syntax.scm
@@ -197,9 +197,6 @@
 	(let ((code '())
 		  (index 0)
 		  (len (string-length fstr)) 
-		  (%display (r 'display))
-		  (%write (r 'write))
-		  (%write-char (r 'write-char))
 		  (%out (r 'out))
 		  (%fprintf (r 'fprintf))
 		  (%let (r 'let))
@@ -218,8 +215,8 @@
 		(when (pair? chunk)
 		  (push 
 		   (if (= 1 (length chunk))
-		   `(,%write-char ,(car chunk) ,%out)
-		   `(,%display ,(reverse-list-string chunk) ,%out)
+		   `(##sys#write-char-0 ,(car chunk) ,%out)
+		   `(##sys#print ,(reverse-list-string chunk) #f ,%out)
 	  (define (push exp)
 		(set! code (cons exp code)))
 	  (let loop ((chunk '()))
@@ -228,6 +225,7 @@
 			 (fail #f too many arguments to formatted output procedure))
 		   (endchunk chunk)
 		   `(,%let ((,%out ,out))
+			   (##sys#check-output-port ,%out #t ',func)
 			   ,@(reverse code)))
 		  (else
 		   (let ((c (fetch)))
@@ -235,19 +233,28 @@
 			 (let ((dchar (fetch)))
 			   (endchunk chunk)
 			   (case (char-upcase dchar)
- ((#\S) (push `(,%write ,(next) ,%out)))
- ((#\A) (push `(,%display ,(next) ,%out)))
- ((#\C) (push `(,%write-char ,(next) ,%out)))
- ((#\B) (push `(,%display (,%number-string ,(next) 2) ,%out)))
- ((#\O) (push `(,%display (,%number-string ,(next) 8) ,%out)))
- ((#\X) (push `(,%display (,%number-string ,(next) 16) ,%out)))
+ ((#\S) (push `(##sys#print ,(next) #t ,%out)))
+ ((#\A) (push `(##sys#print ,(next) #f ,%out)))
+ ((#\C) (push `(##sys#write-char-0 ,(next) ,%out)))
+ ((#\B)
+  (push
+   `(##sys#print (,%number-string ,(next) 2) 
+		  #f ,%out)))
+ ((#\O)
+  (push
+   `(##sys#print (,%number-string ,(next) 8) 
+		 #f ,%out)))
+ ((#\X)
+  (push
+   `(##sys#print (,%number-string ,(next) 16) 
+		 #f ,%out)))
  ((#\!) (push `(##sys#flush-output ,%out)))
  ((#\?)
   (let* ([fstr (next)]
 	 [lst (next)] )
 (push `(##sys#apply ,%fprintf ,%out ,fstr ,lst
- ((#\~) (push `(,write-char #\~ ,%out)))
- ((#\% #\N) (push `(,%write-char #\newline ,%out)))
+ ((#\~) (push `(##sys#write-char-0 #\~ ,%out)))
+ ((#\% #\N) (push `(##sys#write-char-0 #\newline ,%out)))
  (else
   (if (char-whitespace? dchar)
   (let skip ((c (fetch)))
-- 
1.7.0.4

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


Re: [Chicken-hackers] will we have a release this year?

2012-09-23 Thread Ivan Raikov
Hi Andy,

   The environments egg will not work under Chicken 4.7.4 and later, due to
changes in the internal representation (also noted in the documentation).
The rewrite branch is meant to fix this issue.

   Ivan
 On Sep 23, 2012 10:09 PM, Andy Bennett andy...@ashurst.eu.org wrote:

 Hi,

   I have been testing 4.8.0rc4 quite a bit this week, and everything
  seems to work fine, so if there are no objections, I will make the
  release next Monday.

 Did people see my bug report on chicken-users regarding the environments
 egg and eval? I posted in the Re: [Chicken-users] Chicken 4.8.0 release
 candidate 4 now available thread on 2012/09/18.

 --
 Another was segfaulting and continued to segfault on 'load'. I narrowed
 it down to this repro case in the interpreter:

 -
 #;1 (use environments)
 #;2 (define widget-eval-env (make-parameter (environment-copy
 (scheme-report-environment 5) #t)))
 -

 Using Mortiz's rewrite branch of the environments egg:

 https://anonymous:@code.call-cc.org/svn/chicken-eggs/release/4/environments/branches/rewrite/
 ... stops the segfault.

 I can get a binary out but it throws an exception somewhere it didn't
 used to:

 -
 unbound variable
 ##sys#list
 -

 ...and my debugging efforts so far point to a problem with eval and an
 environment from the environments egg.
 --




 Regards,
 @ndy

 --
 andy...@ashurst.eu.org
 http://www.ashurst.eu.org/
 0x7EBA75FF


___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers