From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.devel,gmane.lisp.guile.user Subject: Re: racing srfi-18 threads Date: Wed, 02 Dec 2009 21:46:51 +0000 Message-ID: <87ws1582wk.fsf@ossau.uklinux.net> References: <2e6d10880911060129s538fab2cv84805475450f33d0@mail.gmail.com> <2e6d10880911060652g56092de3g649c540e54102c05@mail.gmail.com> <87bpjcy4bc.fsf@ossau.uklinux.net> <87skceglog.fsf@ossau.uklinux.net> <87my2iuksq.fsf@ossau.uklinux.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1259796090 4268 80.91.229.12 (2 Dec 2009 23:21:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 2 Dec 2009 23:21:30 +0000 (UTC) Cc: guile-user@gnu.org, Guile Development To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Dec 03 00:21:23 2009 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NFyVb-0004Nm-H9 for guile-devel@m.gmane.org; Thu, 03 Dec 2009 00:21:20 +0100 Original-Received: from localhost ([127.0.0.1]:50889 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFyVb-0007kL-5P for guile-devel@m.gmane.org; Wed, 02 Dec 2009 18:21:19 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NFx2P-0006FC-TC for guile-devel@gnu.org; Wed, 02 Dec 2009 16:47:06 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NFx2J-00068D-Ev for guile-devel@gnu.org; Wed, 02 Dec 2009 16:47:04 -0500 Original-Received: from [199.232.76.173] (port=47226 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFx2J-00067i-8o; Wed, 02 Dec 2009 16:46:59 -0500 Original-Received: from mail3.uklinux.net ([80.84.72.33]:54846) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NFx2H-00088H-72; Wed, 02 Dec 2009 16:46:57 -0500 Original-Received: from arudy (host86-145-153-90.range86-145.btcentralplus.com [86.145.153.90]) by mail3.uklinux.net (Postfix) with ESMTP id F18C51F67A9; Wed, 2 Dec 2009 21:46:54 +0000 (GMT) Original-Received: from arudy (arudy [127.0.0.1]) by arudy (Postfix) with ESMTP id 4A7F038023; Wed, 2 Dec 2009 21:46:51 +0000 (GMT) In-Reply-To: <87my2iuksq.fsf@ossau.uklinux.net> (Neil Jerram's message of "Fri, 20 Nov 2009 00:00:53 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:9732 gmane.lisp.guile.user:7512 Archived-At: Neil Jerram writes: > I now have it down to this: a program compiled inside the RHS of a > define-syntax form apparently has no meta; whereas the same program > compiled outside a define-syntax form does have meta: Apologies for taking so long to follow up on this! I've been trying to remedy my lack of detailed understanding about how compilation works, and that has led me to wondering whether and how we will provide similar debugging facilities for compiled code as we have in 1.8.x for interpreted code. One option would be not to take the 1.8.x approach at all (i.e. using special hooks from the core of the evaluator/VM) but instead rely on instrumenting code at runtime. I had a quick play with this and it seems quite simple and promising. For example, here's a way of tracing when a procedure is called, and its return values: (define-macro (trace proc) `(let ((proc ,proc)) (set! ,proc (lambda args (display ";TRACE: ") (display ',proc) (display " ") (write args) (newline) (call-with-values (lambda () (apply proc args)) (lambda results (for-each (lambda (result) (display ";TRACE: ") (display ',proc) (display " => ") (write result) (newline)) results) (apply values results))))))) Yes, I know I should write that with define-syntax instead. :-) Then, with that in my .guile: neil@arudy:~/SW/Guile/git$ meta/uninstalled-env guile Guile Scheme interpreter 0.5 on Guile 1.9.5 Copyright (C) 2001-2008 Free Software Foundation, Inc. Enter `,help' for help. scheme@(guile-user)> (trace (@@ (system base compile) compile-fold)) ;;; note: source file /home/neil/SW/Guile/git/module/language/glil/compile-assembly.scm ;;; newer than compiled /home/neil/SW/Guile/git/module/language/glil/compile-assembly.go ;;; found fresh local cache at /home/neil/SW/Guile/git/cache/guile/ccache/1.9-0.L-LE-4/home/neil/SW/Guile/git/module/language/glil/compile-assembly.scm.go scheme@(guile-user)> (trace (@@ (language glil compile-assembly) compile-assembly)) ;TRACE: (@@ (system base compile) compile-fold) ((# # # # #) (trace (@@ (language glil compile-assembly) compile-assembly)) # (())) ;TRACE: (@@ (system base compile) compile-fold) => # ;TRACE: (@@ (system base compile) compile-fold) => # ;TRACE: (@@ (system base compile) compile-fold) => # scheme@(guile-user)> (+ 3 4 5) ;TRACE: (@@ (system base compile) compile-fold) ((# # # # #) (+ 3 4 5) # (())) ;TRACE: (@@ (language glil compile-assembly) compile-assembly) (#) ;TRACE: (@@ (language glil compile-assembly) compile-assembly) (#) ;TRACE: (@@ (language glil compile-assembly) compile-assembly) => (load-program () 25 #f (make-eol) (make-int8:0) (make-int8 2) (make-int8:0) (cons) (cons) (list 0 1) (make-int8 6) (make-int8 15) (make-int8:0) (list 0 3) (list 0 1) (list 0 3) (return)) ;TRACE: (@@ (language glil compile-assembly) compile-assembly) => (load-program ((:LCASE113 . 6)) 16 (load-program () 25 #f (make-eol) (make-int8:0) (make-int8 2) (make-int8:0) (cons) (cons) (list 0 1) (make-int8 6) (make-int8 15) (make-int8:0) (list 0 3) (list 0 1) (list 0 3) (return)) (assert-nargs-ee 0 0) (reserve-locals 0 0) (make-int8 3) (make-int8 4) (make-int8 5) (add) (add) (return) (nop)) ;TRACE: (@@ (system base compile) compile-fold) => # ;TRACE: (@@ (system base compile) compile-fold) => # ;TRACE: (@@ (system base compile) compile-fold) => # 12 scheme@(guile-user)> That seems quite nice and useful. (SLIB has stuff like this too. I wonder if it would just work.) We should be able to do breakpoints like this too, using either the command line or the GDS debugger - although I'm not sure how much of the stack inspection facilities will immediately work. I'll try that next. I don't see how single-stepping could easily be implemented this way, though. I think that may require hooks in the VM. But then again, would single stepping through VM operations be useful and comprehensible anyway? All thoughts welcome, as ever... Neil