[wasm-api] Enable trap handler in c-api tests

Additionally a bug in the wasm-to-C wrapper got fixed, which caused
problems with the thread-in-wasm flag: An invalid effect-chain got
constructed. With the write of the thread-in-wasm flag not being
properly placed in the effect chain, the write got scheduled too late.

R=jkummerow@chromium.org

Bug: v8:11713
Change-Id: I351bf622081850b7b0c7aebfd798d1e73ae34a4a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2867468
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74340}
This commit is contained in:
Andreas Haas 2021-05-03 18:12:37 +02:00 committed by V8 LUCI CQ
parent f98f496f9e
commit dc35435802
2 changed files with 11 additions and 3 deletions

View File

@ -6958,6 +6958,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
BuildModifyThreadInWasmFlag(true);
Node* old_effect = effect();
Node* exception_branch = graph()->NewNode(
mcgraph()->common()->Branch(BranchHint::kTrue),
gasm_->WordEqual(return_value, mcgraph()->IntPtrConstant(0)),
@ -6974,9 +6975,8 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
gasm_->Call(call_descriptor, call_target, return_value);
TerminateThrow(effect(), control());
SetEffectControl(
return_value,
graph()->NewNode(mcgraph()->common()->IfTrue(), exception_branch));
SetEffectControl(old_effect, graph()->NewNode(mcgraph()->common()->IfTrue(),
exception_branch));
DCHECK_LT(sig_->return_count(), wasm::kV8MaxWasmFunctionReturns);
size_t return_count = sig_->return_count();
if (return_count == 0) {

View File

@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "include/v8.h"
#include "src/trap-handler/trap-handler.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@ -13,5 +14,12 @@ int main(int argc, char** argv) {
testing::InitGoogleMock(&argc, argv);
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
v8::V8::InitializeExternalStartupData(argv[0]);
if (V8_TRAP_HANDLER_SUPPORTED && i::FLAG_wasm_trap_handler) {
constexpr bool use_default_trap_handler = true;
if (!v8::V8::EnableWebAssemblyTrapHandler(use_default_trap_handler)) {
FATAL("Could not register trap handler");
}
}
return RUN_ALL_TESTS();
}