[Pharo-project] Fastest utf-8 encoder contest

Igor Stasenko siguctua at gmail.com
Thu Jun 21 11:18:48 EDT 2012


On 21 June 2012 16:59, Henrik Sperre Johansen
<henrik.s.johansen at veloxit.no> wrote:
> Btw, if you want to optimize for shorter-encodings, couldn't you do
> asm
>    cmp: asm EAX with: 16r80;
>    jl: oneByte;
>    cmp: asm EAX with: 16r800;
>    jl: twoBytes;
>    cmp: asm EAX with:16r1000;
>    jl: threeBytes;
>    label: fourBytes;
>    ...
>    jmp end;
>    label: threeBytes;
>    ...
>    jmp end;
>    label: twoBytes;
>    ...
>    jmp: end;
>    label: oneByte;
>
>    label: end
>
> ie only one cmp/jmp for 1-byte chars (1 less jump than current),
> and n cmp/2 jmp's for n > 1.
>
Haha, nice trick.

> Or do the conditional jumps relying on last instruction stall enough that it
> doesn't really matter?
>

Can't say.. benchmarks should demonstrate that, but guess 1 less jump speedup
will be at the level of noise.

I'm not even sure that doing 4-byte aligned memory writes will get
over noise level :)

> Cheers,
> Henry
>


-- 
Best regards,
Igor Stasenko.




More information about the Pharo-dev mailing list