[cairo] fixed_from_double speedup masking pixman traps problem

Daniel Amelang daniel.amelang at gmail.com
Wed Nov 29 13:24:32 PST 2006


On 11/29/06, Bill Spitzak <spitzak at d2.com> wrote:
> In the fast fixed-from-double code, overflow can be detected because the
> "high word" of the resulting double after the math must be a constant.
> If it is not the expected value then overflow occurred and you can then
> use some slower code to do the conversion.

Slower code to do the conversion? If the number being converted is too
large to be represented in the target representation, how can you
avoid that with a slower conversion? Maybe if we shift the bits
reeaaaal carefully, they won't fall off the end :) Seriously though,
do you mean that you fall back onto a 64-bit wide data type or
something?

Regardless, this is at least a nice way of detecting overflow. I would
think that doing this wouldn't kill your speed:

*overflow_flag = (u.i[1] != EXPECTED_CONSTANT);

(an endian aware version would be used, obviously)

Even then, I don't think that this will help Vlad with the problem
that started this thread, will it Vlad? Aren't you looking for a way
to show off the existing problem of memory corruption when overflow
occurs? This method, if at all useful, would be so in helping the part
of code that scribbles on memory prevent itself from doing so,
assuming there isn't a better way, right?

Dan


More information about the cairo mailing list