Skip to content

Export block and object layout constants from Rtrace #1572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/rtrace/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion lib/rtrace/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/";

Expand Down
7 changes: 6 additions & 1 deletion lib/rtrace/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down