diff options
Diffstat (limited to 'src/tools/wasm-split/instrumenter.h')
-rw-r--r-- | src/tools/wasm-split/instrumenter.h | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/tools/wasm-split/instrumenter.h b/src/tools/wasm-split/instrumenter.h index 7de5a9135..f4f2f2119 100644 --- a/src/tools/wasm-split/instrumenter.h +++ b/src/tools/wasm-split/instrumenter.h @@ -23,6 +23,20 @@ namespace wasm { +struct InstrumenterConfig { + // The namespace from which to import the secondary memory + Name importNamespace = "env"; + // The name of the secondary memory created to store profile data during + // instrumentation + Name secondaryMemoryName = "profile-data"; + // Where to store the profile data + WasmSplitOptions::StorageKind storageKind = + WasmSplitOptions::StorageKind::InGlobals; + // The export name of the function the embedder calls to write the profile + // into memory + std::string profileExport = DEFAULT_PROFILE_EXPORT; +}; + // Add a global monotonic counter and a timestamp global for each function, code // at the beginning of each function to set its timestamp, and a new exported // function for dumping the profile data. @@ -30,20 +44,23 @@ struct Instrumenter : public Pass { PassRunner* runner = nullptr; Module* wasm = nullptr; - const WasmSplitOptions& options; + const InstrumenterConfig& config; uint64_t moduleHash; Name counterGlobal; std::vector<Name> functionGlobals; - Instrumenter(const WasmSplitOptions& options, uint64_t moduleHash); + Name secondaryMemory; + + Instrumenter(const InstrumenterConfig& config, uint64_t moduleHash); void run(PassRunner* runner, Module* wasm) override; private: - void addGlobals(); + void addGlobals(size_t numFuncs); + void addSecondaryMemory(size_t numFuncs); void instrumentFuncs(); - void addProfileExport(); + void addProfileExport(size_t numFuncs); }; } // namespace wasm |