Skip to content

Commit 9b3e34e

Browse files
authored
Merge branch 'master' into test-refactor
2 parents ba48a18 + 41cb336 commit 9b3e34e

File tree

4 files changed

+47
-28
lines changed

4 files changed

+47
-28
lines changed

.github/workflows/format.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
- uses: actions/checkout@v2
103103

104104
- name: Install dependencies (Linux)
105-
run: sudo apt-get install -y clang-format-12
105+
run: sudo apt update -y && sudo apt install -y clang-format-12
106106

107107
- name: Format (clang-format)
108108
run: |
@@ -118,7 +118,7 @@ jobs:
118118
- uses: actions/checkout@v2
119119

120120
- name: Install dependencies (Linux)
121-
run: sudo apt-get install -y clang-tidy-12
121+
run: sudo apt update -y && sudo apt install -y clang-tidy-12
122122

123123
- name: Bazel cache
124124
uses: PiotrSikora/[email protected]

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ jobs:
172172
os: ubuntu-20.04
173173
arch: x86_64
174174
action: test
175-
flags: --config=clang
175+
flags: --config=clang -c opt
176176
- name: 'Wasmtime on Linux/x86_64 with ASan'
177177
engine: 'wasmtime'
178178
repo: 'com_github_bytecodealliance_wasmtime'
@@ -223,7 +223,7 @@ jobs:
223223

224224
- name: Install dependencies (Linux)
225225
if: ${{ matrix.deps != '' && startsWith(matrix.os, 'ubuntu') }}
226-
run: sudo apt-get install -y ${{ matrix.deps }}
226+
run: sudo apt update -y && sudo apt install -y ${{ matrix.deps }}
227227

228228
- name: Activate Docker/QEMU
229229
if: startsWith(matrix.run_under, 'docker')

src/v8/v8.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,8 @@ void V8::getModuleFunctionImpl(std::string_view function_name,
586586
const bool log = cmpLogLevel(LogLevel::trace);
587587
SaveRestoreContext saved_context(context);
588588
wasm::own<wasm::Trap> trap = nullptr;
589+
590+
// Workaround for MSVC++ not supporting zero-sized arrays.
589591
if constexpr (sizeof...(args) > 0) {
590592
wasm::Val params[] = {makeVal(args)...};
591593
if (log) {
@@ -599,6 +601,7 @@ void V8::getModuleFunctionImpl(std::string_view function_name,
599601
}
600602
trap = func->call(nullptr, nullptr);
601603
}
604+
602605
if (trap) {
603606
fail(FailState::RuntimeError, getFailMessage(std::string(function_name), std::move(trap)));
604607
return;
@@ -635,6 +638,8 @@ void V8::getModuleFunctionImpl(std::string_view function_name,
635638
SaveRestoreContext saved_context(context);
636639
wasm::Val results[1];
637640
wasm::own<wasm::Trap> trap = nullptr;
641+
642+
// Workaround for MSVC++ not supporting zero-sized arrays.
638643
if constexpr (sizeof...(args) > 0) {
639644
wasm::Val params[] = {makeVal(args)...};
640645
if (log) {
@@ -648,6 +653,7 @@ void V8::getModuleFunctionImpl(std::string_view function_name,
648653
}
649654
trap = func->call(nullptr, results);
650655
}
656+
651657
if (trap) {
652658
fail(FailState::RuntimeError, getFailMessage(std::string(function_name), std::move(trap)));
653659
return R{};
@@ -668,7 +674,6 @@ void V8::terminate() {
668674
while (isolate->IsExecutionTerminating()) {
669675
std::this_thread::yield();
670676
}
671-
integration()->trace("[host->vm] Terminated");
672677
}
673678

674679
std::string V8::getFailMessage(std::string_view function_name, wasm::own<wasm::Trap> trap) {

src/wasmtime/wasmtime.cc

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -591,21 +591,28 @@ void Wasmtime::getModuleFunctionImpl(std::string_view function_name,
591591
}
592592

593593
*function = [func, function_name, this](ContextBase *context, Args... args) -> void {
594-
wasm_val_vec_t params;
594+
const bool log = cmpLogLevel(LogLevel::trace);
595+
SaveRestoreContext saved_context(context);
596+
wasm_val_vec_t results = WASM_EMPTY_VEC;
597+
WasmTrapPtr trap;
598+
599+
// Workaround for MSVC++ not supporting zero-sized arrays.
595600
if constexpr (sizeof...(args) > 0) {
596601
wasm_val_t params_arr[] = {makeVal(args)...};
597-
params = WASM_ARRAY_VEC(params_arr);
602+
wasm_val_vec_t params = WASM_ARRAY_VEC(params_arr);
603+
if (log) {
604+
integration()->trace("[host->vm] " + std::string(function_name) + "(" +
605+
printValues(&params) + ")");
606+
}
607+
trap.reset(wasm_func_call(func, &params, &results));
598608
} else {
599-
params = WASM_EMPTY_VEC;
600-
}
601-
wasm_val_vec_t results = WASM_EMPTY_VEC;
602-
const bool log = cmpLogLevel(LogLevel::trace);
603-
if (log) {
604-
integration()->trace("[host->vm] " + std::string(function_name) + "(" + printValues(&params) +
605-
")");
609+
wasm_val_vec_t params = WASM_EMPTY_VEC;
610+
if (log) {
611+
integration()->trace("[host->vm] " + std::string(function_name) + "()");
612+
}
613+
trap.reset(wasm_func_call(func, &params, &results));
606614
}
607-
SaveRestoreContext saved_context(context);
608-
WasmTrapPtr trap{wasm_func_call(func, &params, &results)};
615+
609616
if (trap) {
610617
WasmByteVec error_message;
611618
wasm_trap_message(trap.get(), error_message.get());
@@ -645,22 +652,29 @@ void Wasmtime::getModuleFunctionImpl(std::string_view function_name,
645652
}
646653

647654
*function = [func, function_name, this](ContextBase *context, Args... args) -> R {
648-
wasm_val_vec_t params;
655+
const bool log = cmpLogLevel(LogLevel::trace);
656+
SaveRestoreContext saved_context(context);
657+
wasm_val_t results_arr[1];
658+
wasm_val_vec_t results = WASM_ARRAY_VEC(results_arr);
659+
WasmTrapPtr trap;
660+
661+
// Workaround for MSVC++ not supporting zero-sized arrays.
649662
if constexpr (sizeof...(args) > 0) {
650663
wasm_val_t params_arr[] = {makeVal(args)...};
651-
params = WASM_ARRAY_VEC(params_arr);
664+
wasm_val_vec_t params = WASM_ARRAY_VEC(params_arr);
665+
if (log) {
666+
integration()->trace("[host->vm] " + std::string(function_name) + "(" +
667+
printValues(&params) + ")");
668+
}
669+
trap.reset(wasm_func_call(func, &params, &results));
652670
} else {
653-
params = WASM_EMPTY_VEC;
654-
}
655-
wasm_val_t results_arr[1];
656-
wasm_val_vec_t results = WASM_ARRAY_VEC(results_arr);
657-
const bool log = cmpLogLevel(LogLevel::trace);
658-
if (log) {
659-
integration()->trace("[host->vm] " + std::string(function_name) + "(" + printValues(&params) +
660-
")");
671+
wasm_val_vec_t params = WASM_EMPTY_VEC;
672+
if (log) {
673+
integration()->trace("[host->vm] " + std::string(function_name) + "()");
674+
}
675+
trap.reset(wasm_func_call(func, &params, &results));
661676
}
662-
SaveRestoreContext saved_context(context);
663-
WasmTrapPtr trap{wasm_func_call(func, &params, &results)};
677+
664678
if (trap) {
665679
WasmByteVec error_message;
666680
wasm_trap_message(trap.get(), error_message.get());

0 commit comments

Comments
 (0)