Skip to content

Commit d0b4394

Browse files
committed
Move WasmEdge initialization from the constructor into initStore() so it is more in line with other runtimes.
Signed-off-by: Rachel Green <[email protected]>
1 parent 0dfaedf commit d0b4394

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/wasmedge/wasmedge.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,6 @@ using HostModuleDataPtr = std::unique_ptr<HostModuleData>;
225225
class WasmEdge : public WasmVm {
226226
public:
227227
WasmEdge() {
228-
loader_ = WasmEdge_LoaderCreate(nullptr);
229-
validator_ = WasmEdge_ValidatorCreate(nullptr);
230-
executor_ = WasmEdge_ExecutorCreate(nullptr, nullptr);
231228
store_ = nullptr;
232229
ast_module_ = nullptr;
233230
module_ = nullptr;
@@ -324,6 +321,9 @@ void WasmEdge::initStore() {
324321
if (store_ != nullptr) {
325322
return;
326323
}
324+
loader_ = WasmEdge_LoaderCreate(nullptr);
325+
validator_ = WasmEdge_ValidatorCreate(nullptr);
326+
executor_ = WasmEdge_ExecutorCreate(nullptr, nullptr);
327327
store_ = WasmEdge_StoreCreate();
328328
}
329329

test/wasm_vm_test.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,9 @@ TEST_P(TestVm, Init) {
5555
EXPECT_LE(warm, warm_time_ns_limit);
5656

5757
// Verify that getting a "warm" engine takes at least 50x less time than getting a "cold" one.
58-
// We skip NullVM because warm() is a noop, and we skip wasmedge because its engine is initialized
59-
// in the constructor vs. on cold start.
60-
if (engine_ == "null" || engine_ == "wasmedge") {
61-
std::cout << "Skipping warm() performance assertions for " << engine_ << "." << std::endl;
58+
// We skip NullVM because warm() is a noop.
59+
if (engine_ == "null") {
60+
std::cout << "Skipping warm() performance assertions for NullVM." << std::endl;
6261
return;
6362
}
6463
EXPECT_LE(warm * 50, cold);

0 commit comments

Comments
 (0)