[Openmcl-devel] tagbody and go

Taoufik Dachraoui dachraoui.taoufik at gmail.com
Wed Dec 8 22:02:58 UTC 2010


I think that I will use a vector with body of code, and a macro, as my tests
show it is 3 times faster
than having a compiled lambdas that I funcall.

It is something like the following:
(defvar *opcode* 0)
(defvar *codes* (make-array 100 :element-type 'cons))
(defmacro run-inst ()  `,(svref *codes* *opcode*))
(setf (svref *codes* 10) '(setf r3 (+ r1 r2))) ; add
(setf (svref *codes* 20) '(setf r3 (* r1 r2))) ; mul
(setf *opcode* 10) ; addition
(run-inst)
(setf *opcode* 20) ; multiplication
(run-inst)
....

The tests in my previous posting show that using a vector and a macro
is 3 times faster than using compiled lambdas

Kind regards
Taoufik


On Wed, Dec 8, 2010 at 10:33 PM, Robert Goldman <rpgoldman at sift.info> wrote:

> On 12/8/10 Dec 8 -3:20 PM, Taoufik Dachraoui wrote:
> > I am writing a compiler for a pure functional language with completely
> > lazy evaluation (sharing).
> >
> > The compiler generates binary code for a virtual machine. I am trying to
> > implement a simulator for it.
> >
> > It is easy to implement the simulator using cond (or ecase), but I
> > thought if it does not cost me
> > time why not implement it more efficiently. So, for performance issues I
> > would like the simulator,
> > for each encountered instruction (the opcode is represented by 1 byte),
> > to directly jump to the
> > corresponding code.
>
> Apologies if I'm being foolish, but why can't you just make a vector
> that's full of thunks (compiled lambdas of no arguments)?
>
> Best,
> r
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.clozure.com/pipermail/openmcl-devel/attachments/20101208/8ee059dc/attachment.html>


More information about the Openmcl-devel mailing list