Skip to content

Commit 4782292

Browse files
authored
Export block and object layout constants from Rtrace (#1572)
1 parent 879e10f commit 4782292

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

lib/rtrace/index.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ export declare interface RtraceOptions {
2727
getMemory(): WebAssembly.Memory;
2828
}
2929

30+
/** Overhead between a pointer to a block and its unmanaged data. */
31+
export declare const BLOCK_OVERHEAD;
32+
/** Overhead between a pointer to a block's unmanaged data to its managed data. */
33+
export declare const OBJECT_OVERHEAD;
34+
/** Overhead between a pointer to a block and its managed data. */
35+
export declare const TOTAL_OVERHEAD;
36+
3037
export declare class Rtrace {
3138
[key: string]: unknown; // can be used as a Wasm import
3239

lib/rtrace/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ const PTR_SIZE = 1 << PTR_SIZE_BITS;
99
const PTR_MASK = PTR_SIZE - 1;
1010
const PTR_VIEW = Uint32Array;
1111

12-
const BLOCK_OVERHEAD = PTR_SIZE;
12+
export const BLOCK_OVERHEAD = PTR_SIZE;
13+
export const OBJECT_OVERHEAD = 16;
14+
export const TOTAL_OVERHEAD = BLOCK_OVERHEAD + OBJECT_OVERHEAD;
1315

1416
const RT_TLSF = "~lib/rt/tlsf/";
1517

lib/rtrace/umd/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var rtrace = (function(exports) {
55
Object.defineProperty(exports, "__esModule", {
66
value: true
77
});
8-
exports.default = exports.Rtrace = void 0;
8+
exports.default = exports.Rtrace = exports.TOTAL_OVERHEAD = exports.OBJECT_OVERHEAD = exports.BLOCK_OVERHEAD = void 0;
99
// WebAssembly pages are 65536 kb
1010
const PAGE_SIZE_BITS = 16;
1111
const PAGE_SIZE = 1 << PAGE_SIZE_BITS;
@@ -16,6 +16,11 @@ var rtrace = (function(exports) {
1616
const PTR_MASK = PTR_SIZE - 1;
1717
const PTR_VIEW = Uint32Array;
1818
const BLOCK_OVERHEAD = PTR_SIZE;
19+
exports.BLOCK_OVERHEAD = BLOCK_OVERHEAD;
20+
const OBJECT_OVERHEAD = 16;
21+
exports.OBJECT_OVERHEAD = OBJECT_OVERHEAD;
22+
const TOTAL_OVERHEAD = BLOCK_OVERHEAD + OBJECT_OVERHEAD;
23+
exports.TOTAL_OVERHEAD = TOTAL_OVERHEAD;
1924
const RT_TLSF = "~lib/rt/tlsf/";
2025

2126
function assert(x) {

0 commit comments

Comments
 (0)