diff options
Diffstat (limited to 'deps/v8/test/cctest/test-api-wasm.cc')
-rw-r--r-- | deps/v8/test/cctest/test-api-wasm.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/deps/v8/test/cctest/test-api-wasm.cc b/deps/v8/test/cctest/test-api-wasm.cc index 4dc84254bcf..eb49d5668ab 100644 --- a/deps/v8/test/cctest/test-api-wasm.cc +++ b/deps/v8/test/cctest/test-api-wasm.cc @@ -130,11 +130,16 @@ TEST(WasmStreamingAbortWithoutReject) { namespace { bool wasm_threads_enabled_value = false; +bool wasm_simd_enabled_value = false; bool MockWasmThreadsEnabledCallback(v8::Local<v8::Context>) { return wasm_threads_enabled_value; } +bool MockWasmSimdEnabledCallback(v8::Local<v8::Context>) { + return wasm_simd_enabled_value; +} + } // namespace TEST(TestSetWasmThreadsEnabledCallback) { @@ -165,3 +170,32 @@ TEST(TestSetWasmThreadsEnabledCallback) { i::FLAG_experimental_wasm_threads = false; CHECK(i_isolate->AreWasmThreadsEnabled(i_context)); } + +TEST(TestSetWasmSimdEnabledCallback) { + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); + v8::HandleScope scope(isolate); + v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); + i::Handle<i::Context> i_context = v8::Utils::OpenHandle(*context); + + // {Isolate::IsWasmSimdEnabled} calls the callback set by the embedder if + // such a callback exists. Otherwise it returns + // {FLAG_experimental_wasm_simd}. First we test that the flag is returned + // correctly if no callback is set. Then we test that the flag is ignored if + // the callback is set. + + i::FLAG_experimental_wasm_simd = false; + CHECK(!i_isolate->IsWasmSimdEnabled(i_context)); + + i::FLAG_experimental_wasm_simd = true; + CHECK(i_isolate->IsWasmSimdEnabled(i_context)); + + isolate->SetWasmSimdEnabledCallback(MockWasmSimdEnabledCallback); + wasm_simd_enabled_value = false; + CHECK(!i_isolate->IsWasmSimdEnabled(i_context)); + + wasm_simd_enabled_value = true; + i::FLAG_experimental_wasm_simd = false; + CHECK(i_isolate->IsWasmSimdEnabled(i_context)); +} |