We used to cringe a little about a "bit"

new topic     » topic index » view thread      » older message » newer message

I remember (vaguely) we used to cringe a little bit because we used bit 31 to flag a sequence, and we thought other languages would look askance at us for having done so.

Now it seems that V8 JavaScript itself does it. In the article How JavaScript works: inside the V8 engine + 5 tips on how to write optimized code, down the bottom in the "5 tips on how to write optimized code" section it says:

Alexander Zlatkov said...

Tagged values: V8 represents objects and numbers with 32 bits. It uses a bit to know if it is an object (flag = 1) or an integer (flag = 0) called SMI (SMall Integer) because of its 31 bits. Then, if a numeric value is bigger than 31 bits, V8 will box the number, turning it into a double and creating a new object to put the number inside. Try to use 31 bit signed numbers whenever possible to avoid the expensive boxing operation into a JS object.

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu