Comment Comment by dougall The tag bit can be inverted.V8 uses 1 for pointers, 0 for integers - you're usually loading from constant offsets from pointers anyway, so that mostly folds away nicely. Then:x + y is translated to CPU instructions x + yx * y is translated to CPU instructions (x >> 1) * yx / y is translated to CPU instructions (((x >> 1) / (y >> 1)) << 1)x lsl y is translated to CPU instructions (x << (y >> 1)) parent dougall 3 years ago
V8 uses 1 for pointers, 0 for integers - you're usually loading from constant offsets from pointers anyway, so that mostly folds away nicely. Then:
x + y is translated to CPU instructions x + y
x * y is translated to CPU instructions (x >> 1) * y
x / y is translated to CPU instructions (((x >> 1) / (y >> 1)) << 1)
x lsl y is translated to CPU instructions (x << (y >> 1))