News for hackers. Stuff that matters.
Re:Faster than C? Parsing binary data in JavaScript. by marshray on Monday October 08, 2012 @05:41PM (#4628861)
> > There are tricks that let them do this 8 bytes at a time (on AMD64, 4 bytes on x86)

> It's actually 16 bytes at a time on any machine that supports SSE (maybe 32 bytes soon with AVX).

Is there a sequence of fewer than 16 instructions to spot a NUL byte inside the 16 byte block?

Re:Faster than C? Parsing binary data in JavaScript. by haberman on Monday October 08, 2012 @07:01PM (#4629104)
> Is there a sequence of fewer than 16 instructions to spot a NUL byte inside the 16 byte block?

Yes:

    pxor  %xmm1, %xmm1
    pcmpeqb (mem), %xmm1  // Do 16 byte-wise compares
    pmovmskb %xmm1, %eax  // Move results into the low 16 bits
    test %eax, %eax
    jnz saw_null
Re:Faster than C? Parsing binary data in JavaScript. by marshray on Tuesday October 09, 2012 @05:15PM (#4633990)
Very cool.