-
-
Notifications
You must be signed in to change notification settings - Fork 666
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RTrace shadow memory and instrumentation (#1476)
BREAKING CHANGE: RTrace is now a class and the onrealloc callback has been split into onresize and onmove.
- Loading branch information
Showing
103 changed files
with
1,114 additions
and
1,664 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,41 @@ | ||
/** Creates a new `RTrace` instance, tracking allocations, frees and reference counts. */ | ||
declare function rtrace( | ||
/** Block information. */ | ||
export declare interface BlockInfo { | ||
/** Pointer to the block. */ | ||
ptr: number, | ||
/** Block size. */ | ||
size: number, | ||
/** Runtime header. */ | ||
header: { | ||
/** Memory manager info bits. */ | ||
mmInfo: number, | ||
/** Garbage collector info bits. */ | ||
gcInfo: number, | ||
/** Runtime id. */ | ||
rtId: number, | ||
/** Runtime size. */ | ||
rtSize: number | ||
}, | ||
toString(): string | ||
} | ||
|
||
export declare interface RtraceOptions { | ||
/** Function being called when a problem is detected. */ | ||
onerror?: (error: Error) => void, | ||
onerror?: (error: Error, info: BlockInfo) => void, | ||
/** Function being called with information messages. */ | ||
oninfo?: (info: string) => void | ||
): rtrace.RTrace; | ||
|
||
declare namespace rtrace { | ||
/** The rtrace instance used as the `rtrace` import to the Wasm module. */ | ||
export interface RTrace { | ||
/** Number of allocations so far. */ | ||
allocCount: number; | ||
/** Number of reallocations so far. */ | ||
reallocCount: number; | ||
/** Number of frees so far. */ | ||
freeCount: number; | ||
/** Number of RC increments (retains) so far. */ | ||
incrementCount: number; | ||
/** Number of RC decrements (releases) so far. */ | ||
decrementCount: number; | ||
|
||
/** Called when a new block is allocated. */ | ||
onalloc( | ||
/** New block being allocated. */ | ||
block: number | ||
): void; | ||
|
||
/** Called when a block is reallocated and must be moved. */ | ||
onrealloc( | ||
/** Block being moved. */ | ||
oldBlock: number, | ||
/** New block used from now on. */ | ||
newBlock: number | ||
): void; | ||
|
||
/** Called when a block is freed, implicitly or explicitly. */ | ||
onfree( | ||
/** Block being freed. */ | ||
block: number | ||
): void; | ||
oninfo?: (msg: string) => void, | ||
/** Obtains the module's memory instance. */ | ||
getMemory() | ||
} | ||
|
||
/** Called when a reference to a block is retained (RC incremented by one). */ | ||
onincrement( | ||
/** Block a reference to is being retained. */ | ||
block: number | ||
): void; | ||
export declare class Rtrace { | ||
[key: string]: unknown; // can be used as a Wasm import | ||
|
||
/** Called when a reference to a block is released (RC decremented by one). */ | ||
ondecrement( | ||
/** Block a reference to is being released. */ | ||
block: number | ||
): void; | ||
/** Creates a new `RTrace` instance. */ | ||
constructor(options: RtraceOptions); | ||
|
||
/** Checks if rtrace is active, i.e. at least one event has occurred. */ | ||
readonly active: boolean; | ||
/** Checks if rtrace is active, i.e. at least one event has occurred. */ | ||
readonly active: boolean; | ||
|
||
/** Checks if there are any leaks and emits them via `oninfo`. Returns the number of live blocks. */ | ||
check(): number; | ||
} | ||
/** Checks if there are any leaks and emits them via `oninfo`. Returns the number of live blocks. */ | ||
check(): number; | ||
} | ||
|
||
export = rtrace; |
Oops, something went wrong.