Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ jobs:
os: ubuntu-20.04
arch: x86_64
action: test
flags: --config=clang
flags: --config=clang -c opt
- name: 'Wasmtime on Linux/x86_64 with ASan'
engine: 'wasmtime'
repo: 'com_github_bytecodealliance_wasmtime'
Expand Down
6 changes: 6 additions & 0 deletions src/v8/v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,8 @@ void V8::getModuleFunctionImpl(std::string_view function_name,
const bool log = cmpLogLevel(LogLevel::trace);
SaveRestoreContext saved_context(context);
wasm::own<wasm::Trap> trap = nullptr;

// Workaround for MSVC++ not supporting zero-sized arrays.
if constexpr (sizeof...(args) > 0) {
wasm::Val params[] = {makeVal(args)...};
if (log) {
Expand All @@ -599,6 +601,7 @@ void V8::getModuleFunctionImpl(std::string_view function_name,
}
trap = func->call(nullptr, nullptr);
}

if (trap) {
fail(FailState::RuntimeError, getFailMessage(std::string(function_name), std::move(trap)));
return;
Expand Down Expand Up @@ -635,6 +638,8 @@ void V8::getModuleFunctionImpl(std::string_view function_name,
SaveRestoreContext saved_context(context);
wasm::Val results[1];
wasm::own<wasm::Trap> trap = nullptr;

// Workaround for MSVC++ not supporting zero-sized arrays.
if constexpr (sizeof...(args) > 0) {
wasm::Val params[] = {makeVal(args)...};
if (log) {
Expand All @@ -648,6 +653,7 @@ void V8::getModuleFunctionImpl(std::string_view function_name,
}
trap = func->call(nullptr, results);
}

if (trap) {
fail(FailState::RuntimeError, getFailMessage(std::string(function_name), std::move(trap)));
return R{};
Expand Down
60 changes: 37 additions & 23 deletions src/wasmtime/wasmtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -591,21 +591,28 @@ void Wasmtime::getModuleFunctionImpl(std::string_view function_name,
}

*function = [func, function_name, this](ContextBase *context, Args... args) -> void {
wasm_val_vec_t params;
const bool log = cmpLogLevel(LogLevel::trace);
SaveRestoreContext saved_context(context);
wasm_val_vec_t results = WASM_EMPTY_VEC;
WasmTrapPtr trap;

// Workaround for MSVC++ not supporting zero-sized arrays.
if constexpr (sizeof...(args) > 0) {
wasm_val_t params_arr[] = {makeVal(args)...};
params = WASM_ARRAY_VEC(params_arr);
wasm_val_vec_t params = WASM_ARRAY_VEC(params_arr);
if (log) {
integration()->trace("[host->vm] " + std::string(function_name) + "(" +
printValues(&params) + ")");
}
trap.reset(wasm_func_call(func, &params, &results));
} else {
params = WASM_EMPTY_VEC;
}
wasm_val_vec_t results = WASM_EMPTY_VEC;
const bool log = cmpLogLevel(LogLevel::trace);
if (log) {
integration()->trace("[host->vm] " + std::string(function_name) + "(" + printValues(&params) +
")");
wasm_val_vec_t params = WASM_EMPTY_VEC;
if (log) {
integration()->trace("[host->vm] " + std::string(function_name) + "()");
}
trap.reset(wasm_func_call(func, &params, &results));
}
SaveRestoreContext saved_context(context);
WasmTrapPtr trap{wasm_func_call(func, &params, &results)};

if (trap) {
WasmByteVec error_message;
wasm_trap_message(trap.get(), error_message.get());
Expand Down Expand Up @@ -645,22 +652,29 @@ void Wasmtime::getModuleFunctionImpl(std::string_view function_name,
}

*function = [func, function_name, this](ContextBase *context, Args... args) -> R {
wasm_val_vec_t params;
const bool log = cmpLogLevel(LogLevel::trace);
SaveRestoreContext saved_context(context);
wasm_val_t results_arr[1];
wasm_val_vec_t results = WASM_ARRAY_VEC(results_arr);
WasmTrapPtr trap;

// Workaround for MSVC++ not supporting zero-sized arrays.
if constexpr (sizeof...(args) > 0) {
wasm_val_t params_arr[] = {makeVal(args)...};
params = WASM_ARRAY_VEC(params_arr);
wasm_val_vec_t params = WASM_ARRAY_VEC(params_arr);
if (log) {
integration()->trace("[host->vm] " + std::string(function_name) + "(" +
printValues(&params) + ")");
}
trap.reset(wasm_func_call(func, &params, &results));
} else {
params = WASM_EMPTY_VEC;
}
wasm_val_t results_arr[1];
wasm_val_vec_t results = WASM_ARRAY_VEC(results_arr);
const bool log = cmpLogLevel(LogLevel::trace);
if (log) {
integration()->trace("[host->vm] " + std::string(function_name) + "(" + printValues(&params) +
")");
wasm_val_vec_t params = WASM_EMPTY_VEC;
if (log) {
integration()->trace("[host->vm] " + std::string(function_name) + "()");
}
trap.reset(wasm_func_call(func, &params, &results));
}
SaveRestoreContext saved_context(context);
WasmTrapPtr trap{wasm_func_call(func, &params, &results)};

if (trap) {
WasmByteVec error_message;
wasm_trap_message(trap.get(), error_message.get());
Expand Down