23.03.2013 Views

Performance and Evaluation of Lisp Systems - Dreamsongs

Performance and Evaluation of Lisp Systems - Dreamsongs

Performance and Evaluation of Lisp Systems - Dreamsongs

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3.3 Ctak<br />

CTAK is a variant <strong>of</strong> TAK that uses CATCH <strong>and</strong> THROW to return values<br />

rather than the function-return mechanism. Not all <strong>Lisp</strong>s have CATCH/THROW<br />

functionality; INTERLISP can mimic the behavior <strong>of</strong> CATCH/THROW with its<br />

much more powerful spaghetti stack. The times for INTERLISP on this benchmark<br />

are quite slow, but the implementation doubles the number <strong>of</strong> function calls, as<br />

we shall see.<br />

3.3.1 The Program<br />

(defun ctak (x y z)<br />

(catch ’ctak (ctak-aux x y z)))<br />

(defun ctak-aux (x y z)<br />

(cond ((not (< y x))<br />

(throw ’ctak z))<br />

(t (ctak-aux<br />

(catch ’ctak<br />

(ctak-aux (1- x)<br />

y<br />

z))<br />

(catch ’ctak<br />

(ctak-aux (1- y)<br />

z<br />

x))<br />

(catch ’ctak<br />

(ctak-aux (1- z)<br />

x<br />

y))))))<br />

3.3.2 Analysis<br />

This benchmark is similar to TAK, but has both CATCH <strong>and</strong> THROW. The<br />

use <strong>of</strong> CATCH <strong>and</strong> THROW here is somewhat trivial because the THROW always<br />

throws to the nearest enclosing CATCH frame. Typically, CATCH <strong>and</strong> THROW<br />

are implemented in the following manner: whenever a CATCH is evaluated, a<br />

catch frame is placed on the stack. In the catch frame is a pointer to the next<br />

enclosing catch frame, so that we end up with a linked list <strong>of</strong> catch frames. When<br />

a THROW is evaluated, it determines which tag it will search for, <strong>and</strong> it will<br />

search up this threaded list <strong>of</strong> catch frames, checking whether the tags are EQ. In<br />

CTAK, this search only goes as far as the first catch frame. The length <strong>of</strong> time<br />

99

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!