Urgent.News

What's breaking now, across thousands of outlets.

Tech

We ported JSBI to C++ — and the benchmark taught us more than the port did

TL;DR: We ported GoogleChromeLabs/jsbi — a pure-JS arbitrary-precision integer library — to modern C++17, bridged back to Node via N-API, for Port Mortem 2026 (Track H). The port itself wasn't the hard part. Proving it behaved identically to the original — and being honest about the one place we couldn't prove that — was. This is the story of a compile error that was secretly a correctness bug, a…

We ported GoogleChromeLabs/jsbi, a pure-JS arbitrary-precision integer library, to modern C++17 and bridged it back to Node via N-API for Port Mortem 2026 (Track H). The porting process itself was not the difficult part; ensuring identical behavior to the original and acknowledging the one place where this could not be proven proved to be the challenge.

This story revolves around a compile error that turned out to be a correctness bug, a shared_ptr that claimed to own memory but didn't, and a benchmark that changed its results multiple times. JSBI is not a typical JavaScript library; it's V8's internal MutableBigInt, manually downgraded to 30-bit digits to accommodate JavaScript's 2^53 safe-integer ceiling without silently losing precision.

The porting process was more about undoing a constraint rather than swapping languages. The verification pipeline involved running the original test suite unmodified, which required using a pinned submodule and a three-way differential fuzzer comparing the ported code against native V8 BigInt and the actual upstream jsbi npm package.

Four bugs were identified during the process, ranging from a compile error hiding a correctness issue to a shared_ptr that falsely claimed ownership and a spec quirk that was not initially tested. These issues were discovered through careful debugging and a well-designed benchmark harness, ensuring that the ported library behaved identically to the original.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Through the Tunnel(Ep-5 of The $0 cloud)

After searching for a solution (I just GPT'd my way through it lol), I found that Cloudflare was the way to go. The thing about CGNAT (Carrier-Grade Network Address Translation) is that it allows…

More from Tuesday 11 August →