From 34dd7a0d94dfd3d0c28fe355f6071c61775bd66c Mon Sep 17 00:00:00 2001 From: jtenner Date: Mon, 23 Nov 2020 14:30:44 -0500 Subject: [PATCH] Add definitions for RTrace hooks (#1558) --- lib/rtrace/index.d.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/rtrace/index.d.ts b/lib/rtrace/index.d.ts index a5703cb4f9..d59da1fb6c 100644 --- a/lib/rtrace/index.d.ts +++ b/lib/rtrace/index.d.ts @@ -24,7 +24,7 @@ export declare interface RtraceOptions { /** Function being called with information messages. */ oninfo?: (msg: string) => void, /** Obtains the module's memory instance. */ - getMemory() + getMemory(): WebAssembly.Memory; } export declare class Rtrace { @@ -38,4 +38,25 @@ export declare class Rtrace { /** Checks if there are any leaks and emits them via `oninfo`. Returns the number of live blocks. */ check(): number; + + /** A function that is called when an allocation occurs. */ + onalloc(ptr: number): void; + + /** A function that is called when a heap allocation resize occurs. */ + onresize(ptr: number, oldSize: number): void; + + /** A function that is called when an object is moved on the heap. */ + onmove(oldPtr: number, newPtr: number): void; + + /** A function that is called when a heap allocation is freed. */ + onfree(ptr: number): void; + + /** A function that is called when a reference counting increment occurs. */ + onincrement(ptr: number): void; + + /** A function that is called when a reference counting decrement occurs. */ + ondecrement(ptr: number): void; + + /** Obtains information about a block. */ + getBlockInfo(ptr: number): BlockInfo; }