* further hacking on guile-vm
@ 2008-05-12 21:49 Andy Wingo
2008-05-15 1:52 ` Ludovic Courtès
0 siblings, 1 reply; 2+ messages in thread
From: Andy Wingo @ 2008-05-12 21:49 UTC (permalink / raw)
To: guile-devel
Greetings!
So, I have been poking more at guile-vm. The focus of this patchset is
on repl usability. Download guile-vm, ./autogen.sh && ./configure &&
make, then run:
$ ./env guile
guile> (use-modules (system repl repl))
guile> (start-repl 'scheme)
Guile Scheme interpreter 0.5 on Guile 1.8.4
Copyright (C) 2001-2008 Free Software Foundation, Inc.
Enter `,help' for help.
scheme@(guile-user)> 3
$1 = 3
scheme@(guile-user)> ,compile (lambda (x) (* x x))
Disassembly of #<objcode b708d720>:
nlocs = 0 nexts = 0
0 (make-int8 64) ;; 64
2 (link "*")
5 (vector 0 1) ;; 1 element
8 (make-int8 0) ;; 0
10 (load-symbol "x") ;; x
13 (make-false) ;; #f
14 (make-int8 0) ;; 0
16 (list 0 3) ;; 3 elements
19 (list 0 2) ;; 2 elements
22 (list 0 1) ;; 1 element
25 (make-int8 9) ;; 9
27 (make-int8 0) ;; 0
29 (make-int8 21) ;; 21
31 (cons)
32 (cons)
33 (list 0 2) ;; 2 elements
36 (load-program ##{89}#)
47 (return)
Bytecode ##{89}#:
0 (object-ref 0)
2 (variable-ref)
3 (local-ref 0)
5 (local-ref 0)
7 (tail-call 2)
It's rather neat! There's a bit of preamble in the first bit, but
basically it compiles a "program" that has a prelude that loads up
constants and external linkages, and the actual lambda is in ##{89}##.
Of course, guile-vm can deal with much more complex code as well. It
can't deal with all guile code, but it's getting there.
Anyway, other than that, in this patchset there is something to make
`define' compile differently than `set'. I ended up making a new
instruction for `define', that's not `link'. Ludovic, or anyone else, if
you have any insights as to the wisdom or folly of this addition, they
are appreciated.
The following changes since commit f540e3271b55bd9e61165557c72d6ff8f9619e54:
Andy Wingo (1):
Replace ice-9 match's structures with guile's records
are available in the git repository at:
http://wingolog.org/git/guile-vm.git master
Andy Wingo (14):
multiple-values help for the repl; exports cleanups
more exports cleanups
readline integration for guile-vm
ice-9 history integration
fix to meta-reader's optional port argument
pmatchify a cond for prettiness
<foo>? -> foo?; some exports cleanups
explicitly list exports instead of using define-public
remove define-private
only allow `define' at toplevel
fixes so that typing asdfadfasff in the repl doesn't error
replace cenv with things in <repl> and fluids; remove the `use' meta-command
catch errors in the repl, with poor backtraces
add env script
env | 4 +
module/language/scheme/translate.scm | 25 ++++----
module/system/base/compile.scm | 22 ++++----
module/system/base/syntax.scm | 38 ++-----------
module/system/il/compile.scm | 2 +-
module/system/il/ghil.scm | 102 ++++++++++++++++++----------------
module/system/il/glil.scm | 42 ++++++++------
module/system/repl/command.scm | 69 +++++++----------------
module/system/repl/common.scm | 69 +++++++++++------------
module/system/repl/describe.scm | 8 +-
module/system/repl/repl.scm | 95 ++++++++++++++++++++++++++-----
module/system/vm/assemble.scm | 18 +++++-
module/system/vm/core.scm | 59 +++++++++++--------
module/system/vm/frame.scm | 17 +++--
module/system/vm/trace.scm | 9 ++-
src/vm_loader.c | 31 +++++-----
16 files changed, 331 insertions(+), 279 deletions(-)
create mode 100755 env
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: further hacking on guile-vm
2008-05-12 21:49 further hacking on guile-vm Andy Wingo
@ 2008-05-15 1:52 ` Ludovic Courtès
0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2008-05-15 1:52 UTC (permalink / raw)
To: guile-devel
Hello!
Andy Wingo <wingo@pobox.com> writes:
> So, I have been poking more at guile-vm. The focus of this patchset is
> on repl usability.
Looks cool!
I pulled from your branch and stumbled upon commit
7d1c45d38e34659c1ec3b76ba4c985901123bf61 entitled "fix macro compilation
via hooking into eval-case", which will probably lead to discussions.
;-)
I wanted to try a few things to refresh my memory on that topic, but it
appears that `pprint-glil' is currently broken:
guile> (use-modules (system il compile) (language scheme translate))
guile> (define hi (translate '(use-modules (srfi srfi-9)) (make-module)))
guile> (define lo (compile hi (make-module)))
guile> (use-modules (system il glil))
guile> (pprint-glil lo)
Backtrace:
In current input:
6: 0* [pprint-glil #<<glil-asm> vars: # body: #>]
In ../module/system/il/glil.scm:
195: 1 (let* ((port (if # # ...))) ((letrec (#) print) (unparse glil) 0) ...)
196: 2* [print ...
196: 3* [unparse #<<glil-asm> vars: # body: #>]
163: 4 (record-case glil ((<glil-asm> vars body) (quasiquote (@asm # #))) ...)
...
166: 5 (quasiquote (@asm (# # # #) (unquote-splicing #)))
168: 6* [map #<procedure unparse (glil)> (# # # # ...)]
In unknown file:
?: 7* [unparse #<<glil-source> loc: {#f}>]
In ../module/system/il/glil.scm:
163: 8* (let* ((#{\ g28}# glil)) (cond (# #) (# #) (# #) ...))
In unknown file:
?: 9 (cond ((# #{\ g28}#) (let # #)) ((# #{\ g28}#) (let # #)) ...)
In ../module/system/il/glil.scm:
...
171: 10 (quasiquote (@source (unquote (car loc)) (unquote (cdr loc))))
171: 11* [cdr {#f}]
../module/system/il/glil.scm:171:48: In procedure cdr in expression (cdr loc):
../module/system/il/glil.scm:171:48: Wrong type (expecting pair): #f
ABORT: (wrong-type-arg)
Any idea?
Surely you can achieve similar results more quickly using the REPL?
Thanks,
Ludovic.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-05-15 1:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-12 21:49 further hacking on guile-vm Andy Wingo
2008-05-15 1:52 ` Ludovic Courtès
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).