diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2021-09-03 08:24:08 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-03 08:24:08 -0700 |
commit | 548d1971c3c844e8dab8c0da4e97aa5c339937df (patch) | |
tree | 188cec7d93b7743f987c101e6a8d8999d3c1d62d /src/tools/wasm-split/instrumenter.h | |
parent | e84980dffb62d672c991960a701a3c7de8f8aa74 (diff) | |
download | binaryen-548d1971c3c844e8dab8c0da4e97aa5c339937df.tar.gz binaryen-548d1971c3c844e8dab8c0da4e97aa5c339937df.tar.bz2 binaryen-548d1971c3c844e8dab8c0da4e97aa5c339937df.zip |
[NFC] Split wasm-split into multiple files (#4119)
As wasm-split has gained new functionality, its implementation file has become
large. In preparation for adding even more functionality, split the existing
implementation across multiple files in a new tools/wasm-split subdirectory.
Diffstat (limited to 'src/tools/wasm-split/instrumenter.h')
-rw-r--r-- | src/tools/wasm-split/instrumenter.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/tools/wasm-split/instrumenter.h b/src/tools/wasm-split/instrumenter.h new file mode 100644 index 000000000..4f714fde9 --- /dev/null +++ b/src/tools/wasm-split/instrumenter.h @@ -0,0 +1,47 @@ +/* + * Copyright 2021 WebAssembly Community Group participants + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef wasm_tools_wasm_split_instrumenter_h +#define wasm_tools_wasm_split_instrumenter_h + +#include "pass.h" + +namespace wasm { + +// 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. +struct Instrumenter : public Pass { + PassRunner* runner = nullptr; + Module* wasm = nullptr; + + const std::string& profileExport; + uint64_t moduleHash; + + Name counterGlobal; + std::vector<Name> functionGlobals; + + Instrumenter(const std::string& profileExport, uint64_t moduleHash); + + void run(PassRunner* runner, Module* wasm) override; + void addGlobals(); + void instrumentFuncs(); + void addProfileExport(); +}; + +} // namespace wasm + +#endif // wasm_tools_wasm_split_instrumenter_h |