asm-js / validator

A reference validator for asm.js.
Apache License 2.0
1.78k stars 148 forks source link

`p >> 2` "converts the byte offset to a 32-bit word offset"? #39

Closed SimonSapin closed 11 years ago

SimonSapin commented 11 years ago

Hi,

In http://asmjs.org/spec/latest/#programming-model one can read:

HEAP32[p >> 2]|0

The shift converts the byte offset to a 32-bit word offset, […]

Shouldn’t that be p >> 4? 4 being the byte size of a 32-bit word.

vvuk commented 11 years ago

>> is a bitwise shift operator; so this is correctly shifting 2 bits, which is the same as dividing by 2**2, or 4 bytes.

SimonSapin commented 11 years ago

Oh, right. I somehow got confused with division.