mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-23 06:10:02 +08:00
- Emit JavaScript bitwise operators with native i32 instructions. - Cover native emission and hot-loop coercion semantics. Fixes #357 Co-authored-by: Fábio Pereira <300015+redvulps@users.noreply.github.com>
10 lines
358 B
TypeScript
10 lines
358 B
TypeScript
// Dependent bitwise chains keep JavaScript's 32-bit coercion and unsigned
|
|
// result semantics when every intermediate value feeds the next operation.
|
|
let value = 0x12345678;
|
|
for (let i = 0; i < 1_000_000; i++) {
|
|
value = (value ^ (value << 13)) >>> 0;
|
|
value = (value ^ (value >>> 17)) >>> 0;
|
|
value = (value ^ (value << 5)) >>> 0;
|
|
}
|
|
console.log(value);
|