guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What happened to the ex-Guile VM?


From: Marius Vollmer
Subject: Re: What happened to the ex-Guile VM?
Date: 25 Mar 2001 06:26:00 +0200
User-agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.7

Marius Vollmer <address@hidden> writes:

> Keisuke Nishida <address@hidden> writes:
> 
> > > Nice!  With Lightning and hand coding the assembler (probably
> > > pessimizing it on the way), I get a speedup of 28 compared to the
> > > debugging evaluator and 11 compared to the normal evaluator.
> >
> > I realized that I had compiled the VM with no optimization (-O0).
> > With -O2 and the fast engine, I get a speedup of about 13.7:
> 
> Woa!  This makes machine code look quite bad.  Why isn't it faster?  I
> think a native machine code compiler will only win big when it can
> generate inline code for common operations like car and fixnum
> arithmetic and can do type analysis like Stalin (supported by
> declarations).

As evidence in this direction, I get a speedup of 156 (62 compared to
the non-debugging evaluator) when I inline comparison and addition for
fixnums (with proper fallback in case of overflow, etc).  Lightning
has direct support for this kind of things by providing a
add-and-branch-on-overflow instruction.

I think the code could be interesting, so I post it here:

    (define-asm-macro (arg-prolog . args)
      (let ((n (length args)))
        (cons `(prolog ,n)
              (map (lambda (name) `(arg ,name))
                   args))))

    (define-asm-macro (scm-blt-constfix label a fix tmp1)
      (let ((l0 (gensym "ll"))
            (l1 (gensym "ll")))
        `(  (bmc ,l0 ,a (scm 0))
            (blt ,label ,a ,fix)
            (b ,l1)
          ,l0
            (prepare 2)
            (mov ,tmp1 ,fix)
            (pusharg ,tmp1)
            (pusharg ,a)
            (finish (subr "scm_less_p"))
            (retval ,tmp1)
            (bne ,label ,tmp1 (scm #f))
          ,l1)))

    (define-asm-macro (scm-add-constfix res a fix)
      (let ((l0 (gensym "ll"))
            (l1 (gensym "ll"))
            (fix-sans-tag (logand #xffffffff (* 4 (cadr fix))))) ;; XXX
      `(  (bmc ,l0 ,a (scm 0))
          (mov ,res ,a)
          (boadd ,l0 ,res ,fix-sans-tag)
          (b ,l1)
        ,l0
          (prepare 2)
          (mov ,res ,fix)
          (pusharg ,res)
          (pusharg ,a)
          (finish (subr "scm_sum"))
          (retval ,res)
        ,l1)))

    (define-asm-macro (scm-add res a b)
      (let ((l0 (gensym "ll"))
            (l1 (gensym "ll")))
        `(  (bmc ,l0 ,a (scm 0))
            (bmc ,l0 ,b (scm 0))
            (sub ,res ,a (scm 0))
            (boadd ,l0 ,res ,b)
            (b ,l1)
          ,l0
            (prepare 2)
            (pusharg ,b)
            (pusharg ,a)
            (finish (subr "scm_sum"))
            (retval ,res)
          ,l1)))

    (define asm-fib (assemble `(fib
                                  (arg-prolog n)
                                  (getarg v0 n)
                                  (scm-blt-constfix l0 v0 (scm 2) r0)
                                  (scm-add-constfix r0 v0 (scm -2))
                                  (prepare 1)
                                  (pusharg r0)
                                  (finish (label fib))
                                  (retval v2)
                                  (scm-add-constfix r0 v0 (scm -1))
                                  (prepare 1)
                                  (pusharg r0)
                                  (finish (label fib))
                                  (retval v1)
                                  (scm-add ret v1 v2)
                                  (b l1)
                                l0
                                  (mov ret (scm 1))
                                l1
                                  (ret))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]