1. We used to cringe a little about a "bit"

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 message » categorize

2. Re: We used to cringe a little about a "bit"

Great find! That's exactly how Euphoria does it as well. I wonder if they took a page from Rob's book... getlost

-Greg

new topic     » goto parent     » topic index » view message » categorize

3. Re: We used to cringe a little about a "bit"

boost said...

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.

Excellent! Rob's paratroopers! T.S. smile


kinz

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu