Skip to content

Commit

Permalink
Update WasmExecutor for WABT API changes (#6612)
Browse files Browse the repository at this point in the history
* Update WasmExecutor for WABT API changes

The API for WABT has changed in top-of-tree. This fixes the incompatibilities. It also (temporarily) changes to pulling WABT from top-of-tree (rather than a known release) as the most recent labeled release doesn't have these changes. (We'll change back to a fixed WABT release when the next one is released.)

* Update CMakeLists.txt
  • Loading branch information
steven-johnson authored Feb 11, 2022
1 parent dd32beb commit 832efeb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 3 additions & 1 deletion dependencies/wasm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
endif ()

if (WITH_WABT)
set(WABT_VER 1.0.25)
# TODO: this commit hash is temporary until WABT produces
# a new release tag with revised API
set(WABT_VER 09c40635207d42dd30ffaca22477fd3491dd9e7d)

message(STATUS "Fetching WABT ${WABT_VER}...")
FetchContent_Declare(wabt
Expand Down
11 changes: 6 additions & 5 deletions src/WasmExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ struct WabtContext {
};

WabtContext &get_wabt_context(wabt::interp::Thread &thread) {
void *host_info = thread.host_info();
void *host_info = thread.GetCallerInstance()->host_info();
wassert(host_info);
return *(WabtContext *)host_info;
}
Expand Down Expand Up @@ -2542,6 +2542,8 @@ int WasmModuleContents::run(const void **args) {
}

WabtContext wabt_context(jit_user_context, *memory, bdmalloc);
internal_assert(instance->host_info() == nullptr);
instance->set_host_info(&wabt_context);

wabt::interp::Values wabt_args;
wabt::interp::Values wabt_results;
Expand All @@ -2567,11 +2569,9 @@ int WasmModuleContents::run(const void **args) {
}
}

wabt::interp::Thread::Options options;
wabt::interp::Thread::Ptr thread = wabt::interp::Thread::New(store, options);
thread->set_host_info(&wabt_context);
wabt::interp::Thread thread(store);

auto r = func->Call(*thread, wabt_args, wabt_results, &trap);
auto r = func->Call(thread, wabt_args, wabt_results, &trap);
if (WASM_DEBUG_LEVEL >= 2) {
wabt::MemoryStream call_stream;
WriteCall(&call_stream, func_name, *func_type, wabt_args, wabt_results, trap);
Expand Down Expand Up @@ -2603,6 +2603,7 @@ int WasmModuleContents::run(const void **args) {
// between multiple invocations of the same function.
// bdmalloc.reset();

instance->set_host_info(nullptr);
return result;

#endif
Expand Down

0 comments on commit 832efeb

Please sign in to comment.