3 ms·
Author here. I did work on Chromium but not on V8. There are definitely people here in this comments section who know a lot more than me about these topics! It
by modeless 4y ago
Author here. I did work on Chromium but not on V8. There are definitely people here in this comments section who know a lot more than me about these topics!
It's true that JS engines already optimize code to use integer math extensively, without |0 annotations. There are situations where this is made difficult or impossible due to requirements of the language, and |0 can help in these situations.
There's a whole lot more to know about this topic for sure. My article would be a lot better with some examples where |0 gives a benefit and the corresponding IR. This post already took a lot more time to put together than I expected, and I didn't know if that many people would read it. Now that it hit HN, maybe I can justify the extra work.