Re: Guile 2.2 TODO

2013-10-03 Thread Andy Wingo
Hi,

On Sun 01 Sep 2013 13:03, Andy Wingo  writes:

> * Source information.
>
> The plan here would be to use DWARF.  We don't use DWARF yet, so there
> are a few parts of this.
>
>   - Add a DWARF parser; see the wip-dwarf branch for that.  
>
>   - Emit debugging info entries (DIEs) for each function in a
> compilation unit, into the .debug_info section.  Initially they
> would be minimal, just having the function's address and maybe its
> name.
>
>   - Add machinery to (system vm debug) to get a DIE for a procedure, if
> it is present.
>
>   - Add a macro-instruction to the assembler that records source
> location info.  Have the assembler collect this info.
>
>   - Have the assembler write out source location info into a .debug_line
> section, and link the DIE to that info.
>
>   - Add an appropriate interface to (system vm debug) to parse out line
> number information.  Perhaps model this interface on what is already
> in (system vm program).
>
>   - Shim the existing (system vm program) interfaces to call the new
> (system vm debug) interfaces for RTL programs.

Done!  Woo hoo :)

> * Local variable information.

Still to do, will put off until later.

> * Replace bytecode trampolines with RTL trampolines.
> * Prompt, abort, and call/cc.
> * Compiling all of Guile to RTL.

These are next.

Andy
-- 
http://wingolog.org/



[PATCH] allow specifying a required version in GUILE_PROGS

2013-10-03 Thread Aleix Conchillo FlaquƩ
The following patch allows to specify a required Guile version in
GUILE_PROGS. By default, it requires >= 2.0. The following works:

GUILE_PROGS([2.0])
GUILE_PROGS([2.0.9])

It also works with 1.8.

I am not an expert on m4 macros. I've used "cut" instead of
m4_bregexp. I tried it but couldn't get it right.

In some packages I have implemented procedures which will be available
in the next release of Guile. My plan is to remove these procedures
and add a requirement on a Guile version.

Let me know what you think.

Aleix


guile-progs.patch
Description: Binary data


Re: [PATCH] Add read-wrapper REPL option

2013-10-03 Thread David Thompson
On 09/29/2013 06:10 PM, David Thompson wrote:
> Guile-2D needs a REPL that runs within its event loop without blocking
> when reading user input. Mark Weaver has helped me add a new REPL
> option, read-wrapper, that can be used by Guile-2D to push the read
> operation into another thread while the main thread's event loop
> continues to run as normal. This avoids the problem of thread safety
> with the normal REPL server.
> 
> I think that this could be useful for other programs that run in an
> event loop. Perhaps Emacsy?
> 
> - Dave Thompson

Here is an updated patch. I've updated prompting-meta-read to preserve
the REPL stack when the reader thunk is called, in the case of the thunk
being called outside of the current thread.
>From b7cae3fb33d2cc059c4016709e4d0630eee1610d Mon Sep 17 00:00:00 2001
From: David Thompson 
Date: Sun, 29 Sep 2013 18:01:31 -0400
Subject: [PATCH] Add read-wrapper REPL option.

* module/system/repl/common.scm (repl-default-options): Add read-wrapper
  REPL option.

* module/system/repl/repl.scm (prompting-meta-read): Use read-wrapper
  REPL option.
---
 module/system/repl/common.scm |  4 
 module/system/repl/repl.scm   | 35 ++-
 2 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/module/system/repl/common.scm b/module/system/repl/common.scm
index 5da7c48..030d5de 100644
--- a/module/system/repl/common.scm
+++ b/module/system/repl/common.scm
@@ -125,6 +125,10 @@ See , for more details.")
((not print) #f)
((procedure? print) print)
(else (error "Invalid print procedure" print)
+ (read-wrapper
+  ,(lambda (thunk)
+ (thunk))
+  #f)
  (value-history
   ,(value-history-enabled?)
   ,(lambda (x)
diff --git a/module/system/repl/repl.scm b/module/system/repl/repl.scm
index 1649556..97adf72 100644
--- a/module/system/repl/repl.scm
+++ b/module/system/repl/repl.scm
@@ -107,20 +107,29 @@
 ;; to be able to re-use the existing readline machinery.
 ;;
 ;; Catches read errors, returning *unspecified* in that case.
+;;
+;; The reader thunk is passed into the read-wrapper procedure. The state
+;; of the stack is maintained, in case of the thunk being called outside
+;; of the current thread.
 (define (prompting-meta-read repl)
-  (catch #t
-(lambda ()
-  (repl-reader (lambda () (repl-prompt repl))
-   (meta-reader (repl-language repl) (current-module
-(lambda (key . args)
-  (case key
-((quit)
- (apply throw key args))
-(else
- (format (current-output-port) "While reading expression:\n")
- (print-exception (current-output-port) #f key args)
- (flush-all-input)
- *unspecified*)
+  (let ((read-wrapper (repl-option-ref repl 'read-wrapper))
+(stack (fluid-ref *repl-stack*)))
+(read-wrapper
+ (lambda ()
+   (with-fluids ((*repl-stack* stack))
+ (catch #t
+   (lambda ()
+ (repl-reader (lambda () (repl-prompt repl))
+  (meta-reader (repl-language repl) (current-module
+   (lambda (key . args)
+ (case key
+   ((quit)
+(apply throw key args))
+   (else
+(format (current-output-port) "While reading expression:\n")
+(print-exception (current-output-port) #f key args)
+(flush-all-input)
+*unspecified*)
 
 
 
-- 
1.8.4.rc3



Re: [Guile-commits] GNU Guile branch, master, updated. v2.1.0-213-gb43e81d

2013-10-03 Thread Mark H Weaver
Hi Andy,

"Andy Wingo"  writes:

> diff --git a/libguile/programs.c b/libguile/programs.c
> index 37130d0..5039d2a 100644
> --- a/libguile/programs.c
> +++ b/libguile/programs.c
> @@ -297,7 +297,7 @@ SCM_DEFINE (scm_program_bindings, "program-bindings", 1, 
> 0, 0,
>  }
>  #undef FUNC_NAME
>  
> -SCM_DEFINE (scm_program_sources, "program-sources", 1, 0, 0,
> +SCM_DEFINE (scm_program_sources, "%program-sources", 1, 0, 0,
>   (SCM program),
>   "")
>  #define FUNC_NAME s_scm_program_sources
> @@ -365,32 +365,24 @@ scm_i_program_properties (SCM program)
>  }
>  #undef FUNC_NAME
>  
> -static SCM
> -program_source (SCM program, size_t ip, SCM sources)
> +SCM
> +scm_program_source (SCM program, SCM ip, SCM sources)
>  {
> -  SCM source = SCM_BOOL_F;
> +  static SCM program_source = SCM_BOOL_F;
>  
> -  while (!scm_is_null (sources)
> - && scm_to_size_t (scm_caar (sources)) <= ip)
> -{
> -  source = scm_car (sources);
> -  sources = scm_cdr (sources);
> -}
> -  
> -  return source; /* (addr . (filename . (line . column))) */
> -}
> +  if (scm_is_false (program_source)) {
> +if (!scm_module_system_booted_p)
> +  return SCM_BOOL_F;
> +
> +program_source =
> +  scm_c_private_variable ("system vm program", "program-source");
> +  }

This lazy initialization pattern is not safe on modern weakly ordered
memory architectures.  I've already raised this issue on the mailing
list more than once, and I've been trying to fix these bugs wherever I
can find them, but they are non-trivial to search for.  Please do not
add more.

We need to either use a mutex to guard both reads and writes of
'program_source' (including the "scm_is_false (program_source)" check),
or we need to arrange for 'program_source' to be initialized during
guile's initialization before any other threads are created.

 Mark