[gs-devel] Re: Another good excercise, ,

lazer1 lazer1 at blueyonder.co.uk
Fri Jan 12 06:35:51 PST 2007


On 11-Jan-07, Leonardo wrote:
>Thanks for suggestion.
>A disadvantage of this code is the necessity of a dynamic check
>whether the index is within the signed_eo array.

the dynamic check can be done transparently via an mmu 
but that would be too unfeasible for portable code and 
wouldnt port to cpus without mmus,

I think the max index so far can only increase by +1, so mmu protection of 
the first byte beyond (and before) the array would check the index in
hardware,

its just the hassle of having to write a page-fault handler

for actual documents say downloaded from the internet I'm sure winding 
numbers will be tiny, but theoretically they could be huge,

so on most actual documents the page-fault handler wouldnt be invoked,

>In the worst case the array size is twice the number of turns
>of a contour around any point. Unfortunately
>I can't know it in advance.

the problem is interesting as various ideas are almost possible,

if there is an asm instruction for sign you can do it in 3
asm instructions via:

#define signed_eo( a )  (sign(a) * ( (a) & 1 ))

in fact this could be as fast as 2 asm instructions because of 
speculative execution: sign(a) and ((a) & 1) will be done
simultaneously,






More information about the gs-devel mailing list