Keisuke Nishida
2001-04-01 06:16:46 UTC
I have checked in the current snapshot of my Guile VM to the CVS.
If anyone is interested, please check it out and try it.
Install
-------
% cd guile/guile-vm
% ./autogen.sh; configure && make install
% ln -s module/{language,system} /usr/local/share/guile/site/
Setup
-----
Add the following lines to your ~/.guile:
(if (string=? (car (command-line)) "guile-vm")
(begin
(use-modules (system repl repl))
(start-repl 'ghil)
(quit)))
Example
-------
% gulie-vm
Guile High Intermediate Language (GHIL) interpreter 0.3 on Guile 1.4.1
Copyright (C) 2001 Free Software Foundation, Inc.
Enter `,help' for help.
***@user> (@+ 1 2)
$1 = 3
***@user> ,c -c (@+ 1 2) ;; Compile into GLIL
(@asm (0 0 0 0)
(const 1)
(const 2)
(add)
(return))
***@user> ,c -l (@+ 1 2) ;; Compile into loadable code
0 make-int8:0 ;; 0
1 load-program #0
8 return
Bytecode #0:
0 make-int8:1 ;; 1
1 make-int8 2 ;; 2
3 add
4 return
***@user> ,c (@+ 1 2) ;; Compile and disassemble
Disassembly of #<program 0x80ff863>:
args = 0 rest = 0 locals = 0
Bytecode:
0 make-int8:1 ;; 1
1 make-int8 2 ;; 2
3 add
4 return
***@user> (@define fib
(@lambda (n)
(@if (@< n 2) 1 (@+ (fib (@- n 1)) (fib (@- n 2))))))
***@user> ,trace (fib 3)
(#<program 0x80f607c> 3)
| (#<program 0x80f607c> 2)
| | (#<program 0x80f607c> 1)
| | 1
| | (#<program 0x80f607c> 0)
| | 1
| 2
| (#<program 0x80f607c> 1)
| 1
3
***@user> ,trace -a (fib 1)
0xbfffef68 (call 0) #() (#<program 0x80f6813>)
0x80f6813 (make-int8:1) #() ()
0x80f6814 (load-module) #() (1)
0x80f681a (load-symbol) #() (#<env 40345e00> 1)
0x80f681f (link) #() (fib #<env 40345e00> 1)
0x80f6820 (variable-ref) #() ((fib . #<program 0x80f607c>) 1)
0x80f6821 (tail-call 1) #() (#<program 0x80f607c> 1)
(#<program 0x80f607c> 1)
0x80f607c (local-ref:0) #(1) ()
0x80f607d (make-int8 2) #(1) (1)
0x80f607f (lt?) #(1) (2 1)
0x80f6080 (br-if-not 2) #(1) (#t)
0x80f6082 (make-int8:1) #(1) ()
0x80f6083 (return) #(1) (1)
1
0xbfffef6a (halt) #() (1)
***@user> ,time (fib 30)
$2 = 1346269
clock utime stime cutime cstime gctime
3.42 3.40 0.00 0.00 0.00 0.00
***@user>
Status
------
Currently, the Scheme interpreter (r5rs) is not working.
I have tested the VM only by the fib function above.
Please don't expect too much for now.
I'll hopefully get the VM usable during this summer.
Kei
If anyone is interested, please check it out and try it.
Install
-------
% cd guile/guile-vm
% ./autogen.sh; configure && make install
% ln -s module/{language,system} /usr/local/share/guile/site/
Setup
-----
Add the following lines to your ~/.guile:
(if (string=? (car (command-line)) "guile-vm")
(begin
(use-modules (system repl repl))
(start-repl 'ghil)
(quit)))
Example
-------
% gulie-vm
Guile High Intermediate Language (GHIL) interpreter 0.3 on Guile 1.4.1
Copyright (C) 2001 Free Software Foundation, Inc.
Enter `,help' for help.
***@user> (@+ 1 2)
$1 = 3
***@user> ,c -c (@+ 1 2) ;; Compile into GLIL
(@asm (0 0 0 0)
(const 1)
(const 2)
(add)
(return))
***@user> ,c -l (@+ 1 2) ;; Compile into loadable code
0 make-int8:0 ;; 0
1 load-program #0
8 return
Bytecode #0:
0 make-int8:1 ;; 1
1 make-int8 2 ;; 2
3 add
4 return
***@user> ,c (@+ 1 2) ;; Compile and disassemble
Disassembly of #<program 0x80ff863>:
args = 0 rest = 0 locals = 0
Bytecode:
0 make-int8:1 ;; 1
1 make-int8 2 ;; 2
3 add
4 return
***@user> (@define fib
(@lambda (n)
(@if (@< n 2) 1 (@+ (fib (@- n 1)) (fib (@- n 2))))))
***@user> ,trace (fib 3)
(#<program 0x80f607c> 3)
| (#<program 0x80f607c> 2)
| | (#<program 0x80f607c> 1)
| | 1
| | (#<program 0x80f607c> 0)
| | 1
| 2
| (#<program 0x80f607c> 1)
| 1
3
***@user> ,trace -a (fib 1)
0xbfffef68 (call 0) #() (#<program 0x80f6813>)
0x80f6813 (make-int8:1) #() ()
0x80f6814 (load-module) #() (1)
0x80f681a (load-symbol) #() (#<env 40345e00> 1)
0x80f681f (link) #() (fib #<env 40345e00> 1)
0x80f6820 (variable-ref) #() ((fib . #<program 0x80f607c>) 1)
0x80f6821 (tail-call 1) #() (#<program 0x80f607c> 1)
(#<program 0x80f607c> 1)
0x80f607c (local-ref:0) #(1) ()
0x80f607d (make-int8 2) #(1) (1)
0x80f607f (lt?) #(1) (2 1)
0x80f6080 (br-if-not 2) #(1) (#t)
0x80f6082 (make-int8:1) #(1) ()
0x80f6083 (return) #(1) (1)
1
0xbfffef6a (halt) #() (1)
***@user> ,time (fib 30)
$2 = 1346269
clock utime stime cutime cstime gctime
3.42 3.40 0.00 0.00 0.00 0.00
***@user>
Status
------
Currently, the Scheme interpreter (r5rs) is not working.
I have tested the VM only by the fib function above.
Please don't expect too much for now.
I'll hopefully get the VM usable during this summer.
Kei