JITs cannot afford graph coloring's compile time, so V8, HotSpot's C1, and LuaJIT use linear-scan allocation — the algorithm you are implementing — trading a little code quality for orders-of-magnitude faster compilation. This compile-speed/code-speed tradeoff defines the entire JIT design space.