[plt-scheme] Native code generation and immutable pairs

From: Jim Blandy (jimb at red-bean.com)
Date: Fri Feb 10 03:07:55 EST 2006

If MzScheme is heading down the native code generation route, have you
thought much about making pairs immutable?  Here's why I think the
topics are related:

If you're going for performance, I assume you're going to find a way
to inline operations like 'car' and 'cdr'.  If you're inlining those,
then you're going to be spending a lot of code space and processor
time on the type checks.  It'd be worthwhile (an assertion I have no
data for) to do analyses that can prove that values appearing at
certain points in the program always have certain types, so that type
checks can be omitted.  (Some of the PLT folks have written papers on
such analyses.)

However, if your system has threads that preempt each other at the
instruction level, then you must assume that any location reachable
via any value that has ever escaped might be modified at any point by
another thread.  So those analyses won't be able to prove much, and
you won't be able to eliminate many checks.

In this context, making pairs immutable, and telling people to use
boxes when they need mutation, would get you back a lot of

(It's not clear to me whether MzScheme actually supports threads that
preempt each other at the instruction level.)

Posted on the users mailing list.