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

[Scheme-reports] Unsafe optimizations



alexshinn@x (Alex Shinn) writes:

> On Wed, Jun 13, 2012 at 12:10 AM, Mark H Weaver <mhw at netris.org> wrote:
>> Alex Shinn <alexshinn at gmail.com> writes:
>>> Implicit forcing can be done without any overhead except
>>> when actually making use of it.
>>
>> This is not necessarily true for monomorphic procedures that are
>> open-coded in a natively compiled implementation with error checks
>> disabled. ?For example, 'car' can be compiled to code that simply
>> extracts the field from the pair, without any conditional branches.
>>
>> Implicit forcing makes monomorphic primitives into polymorphic ones.
>
> This is called an unsafe optimization - it assumes the program
> is correct, and breaks/segfaults when not passed the valid types.

With some assistance from the hardware it is possible to do this
optimization without assuming that the program is correct. This is even
possible on an x86. It's a fun micro-optimization that I'm using in my
own compiler, but for various reasons it might not be widely useful:

http://weinholt.se/scheme/alignment-check.pdf

Regards,

-- 
Göran Weinholt <goran@x>
"Always listen to the experts. They'll tell you
what can't be done and why. Then do it."
 -- Robert Heinlein

_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports