MCPcopy Create free account
hub / github.com/nodejs/node / wasmSignedLeb64

Function wasmSignedLeb64

deps/v8/test/mjsunit/wasm/wasm-module-builder.js:2418–2439  ·  view source on GitHub ↗
(val, max_len = 10)

Source from the content-addressed store, hash-verified

2416}
2417
2418function wasmSignedLeb64(val, max_len = 10) {
2419 if (val == null) throw new Error("Leb value may not be null/undefined");
2420 if (typeof val != "bigint") {
2421 if (val < Math.pow(2, 31)) {
2422 return wasmSignedLeb(val, max_len);
2423 }
2424 val = BigInt(val);
2425 }
2426 let res = [];
2427 for (let i = 0; i < max_len; ++i) {
2428 let v = val & 0x7fn;
2429 // If {v} sign-extended from 7 to 32 bits is equal to val, we are done.
2430 if (BigInt.asIntN(7, v) == val) {
2431 res.push(Number(v));
2432 return res;
2433 }
2434 res.push(Number(v) | 0x80);
2435 val = val >> 7n;
2436 }
2437 throw new Error(
2438 'Leb value <' + val + '> exceeds maximum length of ' + max_len);
2439}
2440
2441function wasmUnsignedLeb(val, max_len = 5) {
2442 if (val == null) throw new Error("Leb value many not be null/undefined");

Callers 12

WasmAtomicNotifyFunction · 0.85
WasmI32AtomicWaitFunction · 0.85
WasmI64AtomicWaitFunction · 0.85
wasmI64ConstFunction · 0.85
memory64.jsFile · 0.85
WasmAtomicNotifyFunction · 0.85
WasmI32AtomicWaitFunction · 0.85
WasmI64AtomicWaitFunction · 0.85

Calls 2

wasmSignedLebFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected