|
|
|
|
|
by rurban
3643 days ago
|
|
This overflow check is extremely cheap. Just check the overflow flag on the cpu. jo +4; jmp bignum; 6 byte.
C compilers didn't support it until last year, so everyone just used inline assembly. Now we have it in gcc 5 and clang 3.4 One good trick started by lua is to use double for everything and check the mantissa of the normalized result for overflows. A double can represent the whole int32 range. With double and nan-tagging you have a unique fast representation of all primitives and can use a double word stack. Which is the biggest win.
Look at how python, perl and ruby are doing this. Horrible. And then look how a fast dynamic language is doing it. |
|