diff --git a/lib/rtrace/index.d.ts b/lib/rtrace/index.d.ts index d59da1fb6c..cc0983dc2b 100644 --- a/lib/rtrace/index.d.ts +++ b/lib/rtrace/index.d.ts @@ -27,6 +27,13 @@ export declare interface RtraceOptions { getMemory(): WebAssembly.Memory; } +/** Overhead between a pointer to a block and its unmanaged data. */ +export declare const BLOCK_OVERHEAD; +/** Overhead between a pointer to a block's unmanaged data to its managed data. */ +export declare const OBJECT_OVERHEAD; +/** Overhead between a pointer to a block and its managed data. */ +export declare const TOTAL_OVERHEAD; + export declare class Rtrace { [key: string]: unknown; // can be used as a Wasm import diff --git a/lib/rtrace/index.js b/lib/rtrace/index.js index 7f1a17111b..3b6d910b1c 100644 --- a/lib/rtrace/index.js +++ b/lib/rtrace/index.js @@ -9,7 +9,9 @@ const PTR_SIZE = 1 << PTR_SIZE_BITS; const PTR_MASK = PTR_SIZE - 1; const PTR_VIEW = Uint32Array; -const BLOCK_OVERHEAD = PTR_SIZE; +export const BLOCK_OVERHEAD = PTR_SIZE; +export const OBJECT_OVERHEAD = 16; +export const TOTAL_OVERHEAD = BLOCK_OVERHEAD + OBJECT_OVERHEAD; const RT_TLSF = "~lib/rt/tlsf/"; diff --git a/lib/rtrace/umd/index.js b/lib/rtrace/umd/index.js index 7c05e4bd9e..9f4c38395f 100644 --- a/lib/rtrace/umd/index.js +++ b/lib/rtrace/umd/index.js @@ -5,7 +5,7 @@ var rtrace = (function(exports) { Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = exports.Rtrace = void 0; + exports.default = exports.Rtrace = exports.TOTAL_OVERHEAD = exports.OBJECT_OVERHEAD = exports.BLOCK_OVERHEAD = void 0; // WebAssembly pages are 65536 kb const PAGE_SIZE_BITS = 16; const PAGE_SIZE = 1 << PAGE_SIZE_BITS; @@ -16,6 +16,11 @@ var rtrace = (function(exports) { const PTR_MASK = PTR_SIZE - 1; const PTR_VIEW = Uint32Array; const BLOCK_OVERHEAD = PTR_SIZE; + exports.BLOCK_OVERHEAD = BLOCK_OVERHEAD; + const OBJECT_OVERHEAD = 16; + exports.OBJECT_OVERHEAD = OBJECT_OVERHEAD; + const TOTAL_OVERHEAD = BLOCK_OVERHEAD + OBJECT_OVERHEAD; + exports.TOTAL_OVERHEAD = TOTAL_OVERHEAD; const RT_TLSF = "~lib/rt/tlsf/"; function assert(x) {