We should assign type tags in a way, in which we can use a bitmask/and to reuse the same code for different stuff. For example, for ToInt32, it would be useful if we could detected int/boolean/undefined/null, which just require use to use the payload. I am sure there are some other cases, too. It would be good if we could find out these beforehand.
Originally type tags were just a bitmask. Punboxing forced a dense index since there were only 3 bits and I just made nunboxing do the same for simplicity in a few cases and to optimize a few conversions in the tracer (hah!). With nunbox64, the type bitmask could help both 32/64-bit, so I'm excited to see what speedups you find. One reason why there may not be a massive speedup awaiting is that js::Value usage in the VM is increasingly not hot and the hot paths often involve single-type queries, isObjectOrNull or isNumber and the latter two are, by design, already single operations.
I am not working on this.