diff options
Diffstat (limited to 'deps/v8/test/unittests')
37 files changed, 777 insertions, 461 deletions
diff --git a/deps/v8/test/unittests/BUILD.gn b/deps/v8/test/unittests/BUILD.gn index 4b1447d34b..08669793c2 100644 --- a/deps/v8/test/unittests/BUILD.gn +++ b/deps/v8/test/unittests/BUILD.gn @@ -23,11 +23,21 @@ v8_executable("unittests") { "//testing/gtest", ] + data_deps = [ + "../../tools:v8_testrunner", + ] + + data = [ + "testcfg.py", + "unittests.status", + ] + configs = [ "../..:external_config", "../..:internal_config_base", ] } + v8_source_set("unittests_sources") { testonly = true diff --git a/deps/v8/test/unittests/api/isolate-unittest.cc b/deps/v8/test/unittests/api/isolate-unittest.cc index 5a7c8e0cef..377ad83187 100644 --- a/deps/v8/test/unittests/api/isolate-unittest.cc +++ b/deps/v8/test/unittests/api/isolate-unittest.cc @@ -9,6 +9,7 @@ #include "include/v8.h" #include "src/base/macros.h" #include "src/base/platform/semaphore.h" +#include "src/base/template-utils.h" #include "src/execution.h" #include "src/isolate.h" #include "src/v8.h" @@ -60,9 +61,8 @@ TEST_F(IsolateTest, MemoryPressureNotificationBackground) { base::Semaphore semaphore(0); - internal::V8::GetCurrentPlatform()->CallOnBackgroundThread( - new MemoryPressureTask(isolate(), &semaphore), - v8::Platform::kShortRunningTask); + internal::V8::GetCurrentPlatform()->CallOnWorkerThread( + base::make_unique<MemoryPressureTask>(isolate(), &semaphore)); semaphore.Wait(); diff --git a/deps/v8/test/unittests/base/logging-unittest.cc b/deps/v8/test/unittests/base/logging-unittest.cc index a0686a2f64..d73845c373 100644 --- a/deps/v8/test/unittests/base/logging-unittest.cc +++ b/deps/v8/test/unittests/base/logging-unittest.cc @@ -248,6 +248,42 @@ TEST(LoggingDeathTest, V8_DcheckCanBeOverridden) { "Dread pirate"); } +#if defined(DEBUG) +namespace { +int g_log_sink_call_count = 0; +void DcheckCountFunction(const char* file, int line, const char* message) { + ++g_log_sink_call_count; +} + +void DcheckEmptyFunction1() { + // Provide a body so that Release builds do not cause the compiler to + // optimize DcheckEmptyFunction1 and DcheckEmptyFunction2 as a single + // function, which breaks the Dcheck tests below. + // Note that this function is never actually called. + g_log_sink_call_count += 42; +} +void DcheckEmptyFunction2() {} + +} // namespace + +TEST(LoggingTest, LogFunctionPointers) { + v8::base::SetDcheckFunction(&DcheckCountFunction); + g_log_sink_call_count = 0; + void (*fp1)() = DcheckEmptyFunction1; + void (*fp2)() = DcheckEmptyFunction2; + void (*fp3)() = DcheckEmptyFunction1; + DCHECK_EQ(fp1, DcheckEmptyFunction1); + DCHECK_EQ(fp1, fp3); + EXPECT_EQ(0, g_log_sink_call_count); + DCHECK_EQ(fp1, fp2); + EXPECT_EQ(1, g_log_sink_call_count); + std::string* error_message = + CheckEQImpl<decltype(fp1), decltype(fp2)>(fp1, fp2, ""); + EXPECT_NE(*error_message, "(1 vs 1)"); + delete error_message; +} +#endif // defined(DEBUG) + } // namespace logging_unittest } // namespace base } // namespace v8 diff --git a/deps/v8/test/unittests/base/macros-unittest.cc b/deps/v8/test/unittests/base/macros-unittest.cc index 593319d1f8..a7bd876979 100644 --- a/deps/v8/test/unittests/base/macros-unittest.cc +++ b/deps/v8/test/unittests/base/macros-unittest.cc @@ -21,5 +21,41 @@ TEST(AlignedAddressTest, AlignedAddress) { AlignedAddress(reinterpret_cast<void*>(0xFFFFF), 0x100000)); } +struct TriviallyCopyable { + const int i; +}; +ASSERT_TRIVIALLY_COPYABLE(TriviallyCopyable); + +struct StillTriviallyCopyable { + const int i; + StillTriviallyCopyable(const StillTriviallyCopyable&) = delete; +}; +ASSERT_TRIVIALLY_COPYABLE(StillTriviallyCopyable); + +struct NonTrivialDestructor { + ~NonTrivialDestructor() {} +}; +ASSERT_NOT_TRIVIALLY_COPYABLE(NonTrivialDestructor); + +struct NonTrivialCopyConstructor { + NonTrivialCopyConstructor(const NonTrivialCopyConstructor&) {} +}; +ASSERT_NOT_TRIVIALLY_COPYABLE(NonTrivialCopyConstructor); + +struct NonTrivialMoveConstructor { + NonTrivialMoveConstructor(const NonTrivialMoveConstructor&) {} +}; +ASSERT_NOT_TRIVIALLY_COPYABLE(NonTrivialMoveConstructor); + +struct NonTrivialCopyAssignment { + NonTrivialCopyAssignment(const NonTrivialCopyAssignment&) {} +}; +ASSERT_NOT_TRIVIALLY_COPYABLE(NonTrivialCopyAssignment); + +struct NonTrivialMoveAssignment { + NonTrivialMoveAssignment(const NonTrivialMoveAssignment&) {} +}; +ASSERT_NOT_TRIVIALLY_COPYABLE(NonTrivialMoveAssignment); + } // namespace base } // namespace v8 diff --git a/deps/v8/test/unittests/base/platform/time-unittest.cc b/deps/v8/test/unittests/base/platform/time-unittest.cc index cbd5d9e81b..19420d5dc6 100644 --- a/deps/v8/test/unittests/base/platform/time-unittest.cc +++ b/deps/v8/test/unittests/base/platform/time-unittest.cc @@ -386,15 +386,21 @@ TEST(TimeTicks, IsMonotonic) { TEST(ThreadTicks, MAYBE_ThreadNow) { if (ThreadTicks::IsSupported()) { ThreadTicks::WaitUntilInitialized(); - TimeTicks begin = TimeTicks::Now(); - ThreadTicks begin_thread = ThreadTicks::Now(); + TimeTicks end, begin = TimeTicks::Now(); + ThreadTicks end_thread, begin_thread = ThreadTicks::Now(); + TimeDelta delta; // Make sure that ThreadNow value is non-zero. EXPECT_GT(begin_thread, ThreadTicks()); - // Sleep for 10 milliseconds to get the thread de-scheduled. - OS::Sleep(base::TimeDelta::FromMilliseconds(10)); - ThreadTicks end_thread = ThreadTicks::Now(); - TimeTicks end = TimeTicks::Now(); - TimeDelta delta = end - begin; + int iterations_count = 0; + do { + // Sleep for 10 milliseconds to get the thread de-scheduled. + OS::Sleep(base::TimeDelta::FromMilliseconds(10)); + end_thread = ThreadTicks::Now(); + end = TimeTicks::Now(); + delta = end - begin; + EXPECT_LE(++iterations_count, 2); // fail after 2 attempts. + } while (delta.InMicroseconds() < + 10000); // Make sure that the OS did sleep for at least 10 ms. TimeDelta delta_thread = end_thread - begin_thread; // Make sure that some thread time have elapsed. EXPECT_GT(delta_thread.InMicroseconds(), 0); diff --git a/deps/v8/test/unittests/base/template-utils-unittest.cc b/deps/v8/test/unittests/base/template-utils-unittest.cc index 2c1da8ec86..42917e0ffc 100644 --- a/deps/v8/test/unittests/base/template-utils-unittest.cc +++ b/deps/v8/test/unittests/base/template-utils-unittest.cc @@ -93,13 +93,19 @@ static_assert(has_output_operator<uint64_t>::value, "int can be output"); // Classes: class TestClass1 {}; class TestClass2 {}; -extern std::ostream& operator<<(std::ostream& str, TestClass2&); +extern std::ostream& operator<<(std::ostream& str, const TestClass2&); +class TestClass3 {}; +extern std::ostream& operator<<(std::ostream& str, TestClass3); static_assert(!has_output_operator<TestClass1>::value, "TestClass1 can not be output"); static_assert(has_output_operator<TestClass2>::value, "non-const TestClass2 can be output"); -static_assert(!has_output_operator<const TestClass2>::value, - "const TestClass2 can not be output"); +static_assert(has_output_operator<const TestClass2>::value, + "const TestClass2 can be output"); +static_assert(has_output_operator<TestClass3>::value, + "non-const TestClass3 can be output"); +static_assert(has_output_operator<const TestClass3>::value, + "const TestClass3 can be output"); ////////////////////////////// // Test fold. diff --git a/deps/v8/test/unittests/bigint-unittest.cc b/deps/v8/test/unittests/bigint-unittest.cc index 6e1018c581..d69c512162 100644 --- a/deps/v8/test/unittests/bigint-unittest.cc +++ b/deps/v8/test/unittests/bigint-unittest.cc @@ -5,7 +5,7 @@ #include <cmath> #include "src/conversions.h" -#include "src/factory.h" +#include "src/heap/factory.h" #include "src/isolate.h" #include "src/objects-inl.h" #include "src/objects/bigint.h" diff --git a/deps/v8/test/unittests/code-stub-assembler-unittest.cc b/deps/v8/test/unittests/code-stub-assembler-unittest.cc index 0ef06c71ff..d39649a355 100644 --- a/deps/v8/test/unittests/code-stub-assembler-unittest.cc +++ b/deps/v8/test/unittests/code-stub-assembler-unittest.cc @@ -32,7 +32,7 @@ CodeStubAssemblerTestState::CodeStubAssemblerTestState( CodeStubAssemblerTest* test) : compiler::CodeAssemblerState(test->isolate(), test->zone(), VoidDescriptor(test->isolate()), Code::STUB, - "test") {} + "test", PoisoningMitigationLevel::kOn) {} TARGET_TEST_F(CodeStubAssemblerTest, SmiTag) { CodeStubAssemblerTestState state(this); diff --git a/deps/v8/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc b/deps/v8/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc index fe97cb30d8..31a5044e14 100644 --- a/deps/v8/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc +++ b/deps/v8/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc @@ -10,6 +10,7 @@ #include "src/api.h" #include "src/ast/ast-value-factory.h" #include "src/base/platform/semaphore.h" +#include "src/base/template-utils.h" #include "src/compiler-dispatcher/compiler-dispatcher-job.h" #include "src/compiler-dispatcher/compiler-dispatcher-tracer.h" #include "src/compiler-dispatcher/unoptimized-compile-job.h" @@ -93,11 +94,11 @@ class MockPlatform : public v8::Platform { ~MockPlatform() override { base::LockGuard<base::Mutex> lock(&mutex_); EXPECT_TRUE(foreground_tasks_.empty()); - EXPECT_TRUE(background_tasks_.empty()); + EXPECT_TRUE(worker_tasks_.empty()); EXPECT_TRUE(idle_task_ == nullptr); } - size_t NumberOfAvailableBackgroundThreads() override { return 1; } + int NumberOfWorkerThreads() override { return 1; } std::shared_ptr<TaskRunner> GetForegroundTaskRunner( v8::Isolate* isolate) override { @@ -105,21 +106,20 @@ class MockPlatform : public v8::Platform { return std::make_shared<MockTaskRunner>(this, is_foreground_task_runner); } - std::shared_ptr<TaskRunner> GetBackgroundTaskRunner( + std::shared_ptr<TaskRunner> GetWorkerThreadsTaskRunner( v8::Isolate* isolate) override { constexpr bool is_foreground_task_runner = false; return std::make_shared<MockTaskRunner>(this, is_foreground_task_runner); } - void CallOnBackgroundThread(Task* task, - ExpectedRuntime expected_runtime) override { + void CallOnWorkerThread(std::unique_ptr<Task> task) override { base::LockGuard<base::Mutex> lock(&mutex_); - background_tasks_.push_back(task); + worker_tasks_.push_back(std::move(task)); } void CallOnForegroundThread(v8::Isolate* isolate, Task* task) override { base::LockGuard<base::Mutex> lock(&mutex_); - foreground_tasks_.push_back(task); + foreground_tasks_.push_back(std::unique_ptr<Task>(task)); } void CallDelayedOnForegroundThread(v8::Isolate* isolate, Task* task, @@ -167,9 +167,9 @@ class MockPlatform : public v8::Platform { return idle_task_; } - bool BackgroundTasksPending() { + bool WorkerTasksPending() { base::LockGuard<base::Mutex> lock(&mutex_); - return !background_tasks_.empty(); + return !worker_tasks_.empty(); } bool ForegroundTasksPending() { @@ -177,59 +177,54 @@ class MockPlatform : public v8::Platform { return !foreground_tasks_.empty(); } - void RunBackgroundTasksAndBlock(Platform* platform) { - std::vector<Task*> tasks; + void RunWorkerTasksAndBlock(Platform* platform) { + std::vector<std::unique_ptr<Task>> tasks; { base::LockGuard<base::Mutex> lock(&mutex_); - tasks.swap(background_tasks_); + tasks.swap(worker_tasks_); } - platform->CallOnBackgroundThread(new TaskWrapper(this, tasks, true), - kShortRunningTask); + platform->CallOnWorkerThread( + base::make_unique<TaskWrapper>(this, std::move(tasks), true)); sem_.Wait(); } - void RunBackgroundTasks(Platform* platform) { - std::vector<Task*> tasks; + void RunWorkerTasks(Platform* platform) { + std::vector<std::unique_ptr<Task>> tasks; { base::LockGuard<base::Mutex> lock(&mutex_); - tasks.swap(background_tasks_); + tasks.swap(worker_tasks_); } - platform->CallOnBackgroundThread(new TaskWrapper(this, tasks, false), - kShortRunningTask); + platform->CallOnWorkerThread( + base::make_unique<TaskWrapper>(this, std::move(tasks), false)); } void RunForegroundTasks() { - std::vector<Task*> tasks; + std::vector<std::unique_ptr<Task>> tasks; { base::LockGuard<base::Mutex> lock(&mutex_); tasks.swap(foreground_tasks_); } for (auto& task : tasks) { task->Run(); - delete task; + // Reset |task| before running the next one. + task.reset(); } } - void ClearBackgroundTasks() { - std::vector<Task*> tasks; + void ClearWorkerTasks() { + std::vector<std::unique_ptr<Task>> tasks; { base::LockGuard<base::Mutex> lock(&mutex_); - tasks.swap(background_tasks_); - } - for (auto& task : tasks) { - delete task; + tasks.swap(worker_tasks_); } } void ClearForegroundTasks() { - std::vector<Task*> tasks; + std::vector<std::unique_ptr<Task>> tasks; { base::LockGuard<base::Mutex> lock(&mutex_); tasks.swap(foreground_tasks_); } - for (auto& task : tasks) { - delete task; - } } void ClearIdleTask() { @@ -242,22 +237,23 @@ class MockPlatform : public v8::Platform { private: class TaskWrapper : public Task { public: - TaskWrapper(MockPlatform* platform, const std::vector<Task*>& tasks, - bool signal) - : platform_(platform), tasks_(tasks), signal_(signal) {} + TaskWrapper(MockPlatform* platform, + std::vector<std::unique_ptr<Task>> tasks, bool signal) + : platform_(platform), tasks_(std::move(tasks)), signal_(signal) {} ~TaskWrapper() = default; void Run() override { for (auto& task : tasks_) { task->Run(); - delete task; + // Reset |task| before running the next one. + task.reset(); } if (signal_) platform_->sem_.Signal(); } private: MockPlatform* platform_; - std::vector<Task*> tasks_; + std::vector<std::unique_ptr<Task>> tasks_; bool signal_; DISALLOW_COPY_AND_ASSIGN(TaskWrapper); @@ -272,9 +268,9 @@ class MockPlatform : public v8::Platform { void PostTask(std::unique_ptr<v8::Task> task) override { base::LockGuard<base::Mutex> lock(&platform_->mutex_); if (is_foreground_task_runner_) { - platform_->foreground_tasks_.push_back(task.release()); + platform_->foreground_tasks_.push_back(std::move(task)); } else { - platform_->background_tasks_.push_back(task.release()); + platform_->worker_tasks_.push_back(std::move(task)); } } @@ -307,8 +303,8 @@ class MockPlatform : public v8::Platform { base::Mutex mutex_; IdleTask* idle_task_; - std::vector<Task*> background_tasks_; - std::vector<Task*> foreground_tasks_; + std::vector<std::unique_ptr<Task>> worker_tasks_; + std::vector<std::unique_ptr<Task>> foreground_tasks_; base::Semaphore sem_; @@ -386,7 +382,7 @@ TEST_F(CompilerDispatcherTest, FinishAllNow) { ASSERT_TRUE(shared[i]->is_compiled()); } platform.ClearIdleTask(); - platform.ClearBackgroundTasks(); + platform.ClearWorkerTasks(); } TEST_F(CompilerDispatcherTest, IdleTask) { @@ -500,12 +496,12 @@ TEST_F(CompilerDispatcherTest, CompileOnBackgroundThread) { ASSERT_TRUE(dispatcher.IsEnqueued(shared)); ASSERT_FALSE(shared->is_compiled()); ASSERT_FALSE(platform.IdleTaskPending()); - ASSERT_TRUE(platform.BackgroundTasksPending()); + ASSERT_TRUE(platform.WorkerTasksPending()); - platform.RunBackgroundTasksAndBlock(V8::GetCurrentPlatform()); + platform.RunWorkerTasksAndBlock(V8::GetCurrentPlatform()); ASSERT_TRUE(platform.IdleTaskPending()); - ASSERT_FALSE(platform.BackgroundTasksPending()); + ASSERT_FALSE(platform.WorkerTasksPending()); ASSERT_EQ(UnoptimizedCompileJob::Status::kCompiled, dispatcher.jobs_.begin()->second->status()); @@ -517,7 +513,7 @@ TEST_F(CompilerDispatcherTest, CompileOnBackgroundThread) { ASSERT_FALSE(platform.IdleTaskPending()); } -TEST_F(CompilerDispatcherTest, FinishNowWithBackgroundTask) { +TEST_F(CompilerDispatcherTest, FinishNowWithWorkerTask) { MockPlatform platform; CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size); @@ -543,17 +539,17 @@ TEST_F(CompilerDispatcherTest, FinishNowWithBackgroundTask) { ASSERT_TRUE(dispatcher.IsEnqueued(shared)); ASSERT_FALSE(shared->is_compiled()); ASSERT_FALSE(platform.IdleTaskPending()); - ASSERT_TRUE(platform.BackgroundTasksPending()); + ASSERT_TRUE(platform.WorkerTasksPending()); // This does not block, but races with the FinishNow() call below. - platform.RunBackgroundTasks(V8::GetCurrentPlatform()); + platform.RunWorkerTasks(V8::GetCurrentPlatform()); ASSERT_TRUE(dispatcher.FinishNow(shared)); // Finishing removes the SFI from the queue. ASSERT_FALSE(dispatcher.IsEnqueued(shared)); ASSERT_TRUE(shared->is_compiled()); if (platform.IdleTaskPending()) platform.ClearIdleTask(); - ASSERT_FALSE(platform.BackgroundTasksPending()); + ASSERT_FALSE(platform.WorkerTasksPending()); } TEST_F(CompilerDispatcherTest, IdleTaskMultipleJobs) { @@ -611,7 +607,7 @@ TEST_F(CompilerDispatcherTest, FinishNowException) { platform.ClearIdleTask(); } -TEST_F(CompilerDispatcherTest, AsyncAbortAllPendingBackgroundTask) { +TEST_F(CompilerDispatcherTest, AsyncAbortAllPendingWorkerTask) { MockPlatform platform; CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size); @@ -637,7 +633,7 @@ TEST_F(CompilerDispatcherTest, AsyncAbortAllPendingBackgroundTask) { ASSERT_TRUE(dispatcher.IsEnqueued(shared)); ASSERT_FALSE(shared->is_compiled()); ASSERT_FALSE(platform.IdleTaskPending()); - ASSERT_TRUE(platform.BackgroundTasksPending()); + ASSERT_TRUE(platform.WorkerTasksPending()); // The background task hasn't yet started, so we can just cancel it. dispatcher.AbortAll(BlockingBehavior::kDontBlock); @@ -646,14 +642,14 @@ TEST_F(CompilerDispatcherTest, AsyncAbortAllPendingBackgroundTask) { ASSERT_FALSE(dispatcher.IsEnqueued(shared)); ASSERT_FALSE(shared->is_compiled()); - platform.RunBackgroundTasksAndBlock(V8::GetCurrentPlatform()); + platform.RunWorkerTasksAndBlock(V8::GetCurrentPlatform()); if (platform.IdleTaskPending()) platform.ClearIdleTask(); - ASSERT_FALSE(platform.BackgroundTasksPending()); + ASSERT_FALSE(platform.WorkerTasksPending()); ASSERT_FALSE(platform.ForegroundTasksPending()); } -TEST_F(CompilerDispatcherTest, AsyncAbortAllRunningBackgroundTask) { +TEST_F(CompilerDispatcherTest, AsyncAbortAllRunningWorkerTask) { MockPlatform platform; CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size); @@ -683,11 +679,11 @@ TEST_F(CompilerDispatcherTest, AsyncAbortAllRunningBackgroundTask) { ASSERT_TRUE(dispatcher.IsEnqueued(shared1)); ASSERT_FALSE(shared1->is_compiled()); ASSERT_FALSE(platform.IdleTaskPending()); - ASSERT_TRUE(platform.BackgroundTasksPending()); + ASSERT_TRUE(platform.WorkerTasksPending()); // Kick off background tasks and freeze them. dispatcher.block_for_testing_.SetValue(true); - platform.RunBackgroundTasks(V8::GetCurrentPlatform()); + platform.RunWorkerTasks(V8::GetCurrentPlatform()); // Busy loop until the background task started running. while (dispatcher.block_for_testing_.Value()) { @@ -722,13 +718,13 @@ TEST_F(CompilerDispatcherTest, AsyncAbortAllRunningBackgroundTask) { ASSERT_TRUE(platform.IdleTaskPending()); platform.RunIdleTask(5.0, 1.0); - ASSERT_FALSE(platform.BackgroundTasksPending()); + ASSERT_FALSE(platform.WorkerTasksPending()); ASSERT_FALSE(platform.ForegroundTasksPending()); // Now it's possible to enqueue new functions again. ASSERT_TRUE(dispatcher.Enqueue(shared2)); ASSERT_TRUE(platform.IdleTaskPending()); - ASSERT_FALSE(platform.BackgroundTasksPending()); + ASSERT_FALSE(platform.WorkerTasksPending()); ASSERT_FALSE(platform.ForegroundTasksPending()); platform.ClearIdleTask(); } @@ -759,11 +755,11 @@ TEST_F(CompilerDispatcherTest, FinishNowDuringAbortAll) { ASSERT_TRUE(dispatcher.IsEnqueued(shared)); ASSERT_FALSE(shared->is_compiled()); ASSERT_FALSE(platform.IdleTaskPending()); - ASSERT_TRUE(platform.BackgroundTasksPending()); + ASSERT_TRUE(platform.WorkerTasksPending()); // Kick off background tasks and freeze them. dispatcher.block_for_testing_.SetValue(true); - platform.RunBackgroundTasks(V8::GetCurrentPlatform()); + platform.RunWorkerTasks(V8::GetCurrentPlatform()); // Busy loop until the background task started running. while (dispatcher.block_for_testing_.Value()) { @@ -792,14 +788,14 @@ TEST_F(CompilerDispatcherTest, FinishNowDuringAbortAll) { // Busy wait for the background task to finish. for (;;) { base::LockGuard<base::Mutex> lock(&dispatcher.mutex_); - if (dispatcher.num_background_tasks_ == 0) { + if (dispatcher.num_worker_tasks_ == 0) { break; } } ASSERT_TRUE(platform.ForegroundTasksPending()); ASSERT_TRUE(platform.IdleTaskPending()); - ASSERT_FALSE(platform.BackgroundTasksPending()); + ASSERT_FALSE(platform.WorkerTasksPending()); platform.RunForegroundTasks(); { @@ -868,9 +864,9 @@ TEST_F(CompilerDispatcherTest, MemoryPressureFromBackground) { ASSERT_TRUE(dispatcher.Enqueue(shared)); base::Semaphore sem(0); - V8::GetCurrentPlatform()->CallOnBackgroundThread( - new PressureNotificationTask(i_isolate(), &dispatcher, &sem), - v8::Platform::kShortRunningTask); + V8::GetCurrentPlatform()->CallOnWorkerThread( + base::make_unique<PressureNotificationTask>(i_isolate(), &dispatcher, + &sem)); sem.Wait(); @@ -905,7 +901,7 @@ TEST_F(CompilerDispatcherTest, EnqueueJob) { ASSERT_TRUE(platform.IdleTaskPending()); platform.ClearIdleTask(); - ASSERT_FALSE(platform.BackgroundTasksPending()); + ASSERT_FALSE(platform.WorkerTasksPending()); } TEST_F(CompilerDispatcherTest, EnqueueAndStep) { @@ -925,8 +921,8 @@ TEST_F(CompilerDispatcherTest, EnqueueAndStep) { ASSERT_TRUE(platform.IdleTaskPending()); platform.ClearIdleTask(); - ASSERT_TRUE(platform.BackgroundTasksPending()); - platform.ClearBackgroundTasks(); + ASSERT_TRUE(platform.WorkerTasksPending()); + platform.ClearWorkerTasks(); } TEST_F(CompilerDispatcherTest, CompileLazyFinishesDispatcherJob) { @@ -995,9 +991,9 @@ TEST_F(CompilerDispatcherTest, EnqueueAndStepTwice) { dispatcher.jobs_.begin()->second->status()); ASSERT_TRUE(platform.IdleTaskPending()); - ASSERT_TRUE(platform.BackgroundTasksPending()); + ASSERT_TRUE(platform.WorkerTasksPending()); platform.ClearIdleTask(); - platform.ClearBackgroundTasks(); + platform.ClearWorkerTasks(); } TEST_F(CompilerDispatcherTest, CompileMultipleOnBackgroundThread) { @@ -1037,12 +1033,12 @@ TEST_F(CompilerDispatcherTest, CompileMultipleOnBackgroundThread) { ASSERT_FALSE(shared1->is_compiled()); ASSERT_FALSE(shared2->is_compiled()); ASSERT_FALSE(platform.IdleTaskPending()); - ASSERT_TRUE(platform.BackgroundTasksPending()); + ASSERT_TRUE(platform.WorkerTasksPending()); - platform.RunBackgroundTasksAndBlock(V8::GetCurrentPlatform()); + platform.RunWorkerTasksAndBlock(V8::GetCurrentPlatform()); ASSERT_TRUE(platform.IdleTaskPending()); - ASSERT_FALSE(platform.BackgroundTasksPending()); + ASSERT_FALSE(platform.WorkerTasksPending()); ASSERT_EQ(dispatcher.jobs_.size(), 2u); ASSERT_EQ(UnoptimizedCompileJob::Status::kCompiled, dispatcher.jobs_.begin()->second->status()); diff --git a/deps/v8/test/unittests/compiler-dispatcher/optimizing-compile-dispatcher-unittest.cc b/deps/v8/test/unittests/compiler-dispatcher/optimizing-compile-dispatcher-unittest.cc index 529b518070..145bf78fb6 100644 --- a/deps/v8/test/unittests/compiler-dispatcher/optimizing-compile-dispatcher-unittest.cc +++ b/deps/v8/test/unittests/compiler-dispatcher/optimizing-compile-dispatcher-unittest.cc @@ -6,11 +6,11 @@ #include "src/base/atomic-utils.h" #include "src/base/platform/semaphore.h" -#include "src/compilation-info.h" #include "src/compiler.h" #include "src/handles.h" #include "src/isolate.h" #include "src/objects-inl.h" +#include "src/optimized-compilation-info.h" #include "src/parsing/parse-info.h" #include "test/unittests/test-helpers.h" #include "test/unittests/test-utils.h" @@ -23,15 +23,15 @@ typedef TestWithNativeContext OptimizingCompileDispatcherTest; namespace { -class BlockingCompilationJob : public CompilationJob { +class BlockingCompilationJob : public OptimizedCompilationJob { public: BlockingCompilationJob(Isolate* isolate, Handle<JSFunction> function) - : CompilationJob(isolate->stack_guard()->real_climit(), &parse_info_, - &info_, "BlockingCompilationJob", - State::kReadyToExecute), + : OptimizedCompilationJob(isolate->stack_guard()->real_climit(), &info_, + "BlockingCompilationJob", + State::kReadyToExecute), shared_(function->shared()), - parse_info_(shared_), - info_(parse_info_.zone(), function->GetIsolate(), shared_, function), + zone_(isolate->allocator(), ZONE_NAME), + info_(&zone_, function->GetIsolate(), shared_, function), blocking_(false), semaphore_(0) {} ~BlockingCompilationJob() override = default; @@ -39,7 +39,7 @@ class BlockingCompilationJob : public CompilationJob { bool IsBlocking() const { return blocking_.Value(); } void Signal() { semaphore_.Signal(); } - // CompilationJob implementation. + // OptimiziedCompilationJob implementation. Status PrepareJobImpl(Isolate* isolate) override { UNREACHABLE(); } Status ExecuteJobImpl() override { @@ -53,8 +53,8 @@ class BlockingCompilationJob : public CompilationJob { private: Handle<SharedFunctionInfo> shared_; - ParseInfo parse_info_; - CompilationInfo info_; + Zone zone_; + OptimizedCompilationInfo info_; base::AtomicValue<bool> blocking_; base::Semaphore semaphore_; diff --git a/deps/v8/test/unittests/compiler-dispatcher/unoptimized-compile-job-unittest.cc b/deps/v8/test/unittests/compiler-dispatcher/unoptimized-compile-job-unittest.cc index d6816279ed..6344d3806e 100644 --- a/deps/v8/test/unittests/compiler-dispatcher/unoptimized-compile-job-unittest.cc +++ b/deps/v8/test/unittests/compiler-dispatcher/unoptimized-compile-job-unittest.cc @@ -9,6 +9,7 @@ #include "src/ast/ast.h" #include "src/ast/scopes.h" #include "src/base/platform/semaphore.h" +#include "src/base/template-utils.h" #include "src/compiler-dispatcher/compiler-dispatcher-job.h" #include "src/compiler-dispatcher/compiler-dispatcher-tracer.h" #include "src/compiler-dispatcher/unoptimized-compile-job.h" @@ -226,10 +227,9 @@ TEST_F(UnoptimizedCompileJobTest, CompileOnBackgroundThread) { ASSERT_FALSE(job->IsFailed()); base::Semaphore semaphore(0); - CompileTask* background_task = new CompileTask(job.get(), &semaphore); + auto background_task = base::make_unique<CompileTask>(job.get(), &semaphore); ASSERT_JOB_STATUS(CompilerDispatcherJob::Status::kPrepared, job); - V8::GetCurrentPlatform()->CallOnBackgroundThread(background_task, - Platform::kShortRunningTask); + V8::GetCurrentPlatform()->CallOnWorkerThread(std::move(background_task)); semaphore.Wait(); job->FinalizeOnMainThread(isolate()); ASSERT_FALSE(job->IsFailed()); diff --git a/deps/v8/test/unittests/compiler/code-assembler-unittest.cc b/deps/v8/test/unittests/compiler/code-assembler-unittest.cc index 1716c8d535..9cf955e86e 100644 --- a/deps/v8/test/unittests/compiler/code-assembler-unittest.cc +++ b/deps/v8/test/unittests/compiler/code-assembler-unittest.cc @@ -20,7 +20,8 @@ namespace compiler { CodeAssemblerTestState::CodeAssemblerTestState(CodeAssemblerTest* test) : CodeAssemblerState(test->isolate(), test->zone(), - VoidDescriptor(test->isolate()), Code::STUB, "test") {} + VoidDescriptor(test->isolate()), Code::STUB, "test", + PoisoningMitigationLevel::kOn) {} TARGET_TEST_F(CodeAssemblerTest, IntPtrAdd) { CodeAssemblerTestState state(this); diff --git a/deps/v8/test/unittests/compiler/common-operator-unittest.cc b/deps/v8/test/unittests/compiler/common-operator-unittest.cc index b51d5f3cf6..2ee0dbb382 100644 --- a/deps/v8/test/unittests/compiler/common-operator-unittest.cc +++ b/deps/v8/test/unittests/compiler/common-operator-unittest.cc @@ -238,17 +238,19 @@ TEST_F(CommonOperatorTest, Switch) { TEST_F(CommonOperatorTest, IfValue) { TRACED_FOREACH(int32_t, value, kInt32Values) { - const Operator* const op = common()->IfValue(value); - EXPECT_EQ(IrOpcode::kIfValue, op->opcode()); - EXPECT_EQ(Operator::kKontrol, op->properties()); - EXPECT_EQ(value, OpParameter<int32_t>(op)); - EXPECT_EQ(0, op->ValueInputCount()); - EXPECT_EQ(0, op->EffectInputCount()); - EXPECT_EQ(1, op->ControlInputCount()); - EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op)); - EXPECT_EQ(0, op->ValueOutputCount()); - EXPECT_EQ(0, op->EffectOutputCount()); - EXPECT_EQ(1, op->ControlOutputCount()); + TRACED_FOREACH(int32_t, order, kInt32Values) { + const Operator* const op = common()->IfValue(value, order); + EXPECT_EQ(IrOpcode::kIfValue, op->opcode()); + EXPECT_EQ(Operator::kKontrol, op->properties()); + EXPECT_EQ(IfValueParameters(value, order), IfValueParametersOf(op)); + EXPECT_EQ(0, op->ValueInputCount()); + EXPECT_EQ(0, op->EffectInputCount()); + EXPECT_EQ(1, op->ControlInputCount()); + EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op)); + EXPECT_EQ(0, op->ValueOutputCount()); + EXPECT_EQ(0, op->EffectOutputCount()); + EXPECT_EQ(1, op->ControlOutputCount()); + } } } diff --git a/deps/v8/test/unittests/compiler/control-flow-optimizer-unittest.cc b/deps/v8/test/unittests/compiler/control-flow-optimizer-unittest.cc index a0c483344e..607df1fafb 100644 --- a/deps/v8/test/unittests/compiler/control-flow-optimizer-unittest.cc +++ b/deps/v8/test/unittests/compiler/control-flow-optimizer-unittest.cc @@ -57,11 +57,12 @@ TEST_F(ControlFlowOptimizerTest, BuildSwitch1) { graph()->SetEnd(graph()->NewNode(common()->End(1), merge)); Optimize(); Capture<Node*> switch_capture; - EXPECT_THAT(end(), - IsEnd(IsMerge(IsIfValue(0, CaptureEq(&switch_capture)), - IsIfValue(1, CaptureEq(&switch_capture)), - IsIfDefault(AllOf(CaptureEq(&switch_capture), - IsSwitch(index, start())))))); + EXPECT_THAT( + end(), IsEnd(IsMerge( + IsIfValue(IfValueParameters(0, 1), CaptureEq(&switch_capture)), + IsIfValue(IfValueParameters(1, 2), CaptureEq(&switch_capture)), + IsIfDefault(AllOf(CaptureEq(&switch_capture), + IsSwitch(index, start())))))); } @@ -89,11 +90,11 @@ TEST_F(ControlFlowOptimizerTest, BuildSwitch2) { Optimize(); Capture<Node*> switch_capture; EXPECT_THAT( - end(), - IsEnd(IsMerge(IsIfValue(0, CaptureEq(&switch_capture)), - IsIfValue(1, CaptureEq(&switch_capture)), - IsIfDefault(AllOf(CaptureEq(&switch_capture), - IsSwitch(index, IsIfSuccess(index))))))); + end(), IsEnd(IsMerge( + IsIfValue(IfValueParameters(0, 1), CaptureEq(&switch_capture)), + IsIfValue(IfValueParameters(1, 2), CaptureEq(&switch_capture)), + IsIfDefault(AllOf(CaptureEq(&switch_capture), + IsSwitch(index, IsIfSuccess(index))))))); } } // namespace compiler diff --git a/deps/v8/test/unittests/compiler/graph-unittest.cc b/deps/v8/test/unittests/compiler/graph-unittest.cc index a39f56e6bb..0bdd223d1b 100644 --- a/deps/v8/test/unittests/compiler/graph-unittest.cc +++ b/deps/v8/test/unittests/compiler/graph-unittest.cc @@ -5,7 +5,7 @@ #include "test/unittests/compiler/graph-unittest.h" #include "src/compiler/node-properties.h" -#include "src/factory.h" +#include "src/heap/factory.h" #include "src/objects-inl.h" // TODO(everyone): Make typer.h IWYU compliant. #include "test/unittests/compiler/node-test-utils.h" diff --git a/deps/v8/test/unittests/compiler/instruction-selector-unittest.cc b/deps/v8/test/unittests/compiler/instruction-selector-unittest.cc index 1c2213d138..947bcdf4e4 100644 --- a/deps/v8/test/unittests/compiler/instruction-selector-unittest.cc +++ b/deps/v8/test/unittests/compiler/instruction-selector-unittest.cc @@ -44,9 +44,10 @@ InstructionSelectorTest::Stream InstructionSelectorTest::StreamBuilder::Build( InstructionSelector selector(test_->zone(), node_count, &linkage, &sequence, schedule, &source_position_table, nullptr, InstructionSelector::kEnableSwitchJumpTable, - InstructionSelector::kEnableSpeculationPoison, source_position_mode, features, - InstructionSelector::kDisableScheduling); + InstructionSelector::kDisableScheduling, + InstructionSelector::kDisableSerialization, + PoisoningMitigationLevel::kOn); selector.SelectInstructions(); if (FLAG_trace_turbo) { OFStream out(stdout); @@ -463,8 +464,8 @@ TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeopt) { EXPECT_EQ(kArchCallCodeObject, call_instr->arch_opcode()); size_t num_operands = 1 + // Code object. - 1 + - 5 + // Frame state deopt id + one input for each value in frame state. + 1 + // Poison index + 6 + // Frame state deopt id + one input for each value in frame state. 1 + // Function. 1; // Context. ASSERT_EQ(num_operands, call_instr->InputCount()); @@ -473,23 +474,23 @@ TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeopt) { EXPECT_TRUE(call_instr->InputAt(0)->IsImmediate()); // Deoptimization id. - int32_t deopt_id_before = s.ToInt32(call_instr->InputAt(1)); + int32_t deopt_id_before = s.ToInt32(call_instr->InputAt(2)); FrameStateDescriptor* desc_before = s.GetFrameStateDescriptor(deopt_id_before); EXPECT_EQ(bailout_id_before, desc_before->bailout_id()); EXPECT_EQ(1u, desc_before->parameters_count()); EXPECT_EQ(1u, desc_before->locals_count()); EXPECT_EQ(1u, desc_before->stack_count()); - EXPECT_EQ(43, s.ToInt32(call_instr->InputAt(3))); - EXPECT_EQ(0, s.ToInt32(call_instr->InputAt(4))); // This should be a context. + EXPECT_EQ(43, s.ToInt32(call_instr->InputAt(4))); + EXPECT_EQ(0, s.ToInt32(call_instr->InputAt(5))); // This should be a context. // We inserted 0 here. - EXPECT_EQ(0.5, s.ToFloat64(call_instr->InputAt(5))); - EXPECT_TRUE(s.ToHeapObject(call_instr->InputAt(6))->IsUndefined(isolate())); + EXPECT_EQ(0.5, s.ToFloat64(call_instr->InputAt(6))); + EXPECT_TRUE(s.ToHeapObject(call_instr->InputAt(7))->IsUndefined(isolate())); // Function. - EXPECT_EQ(s.ToVreg(function_node), s.ToVreg(call_instr->InputAt(7))); + EXPECT_EQ(s.ToVreg(function_node), s.ToVreg(call_instr->InputAt(8))); // Context. - EXPECT_EQ(s.ToVreg(context), s.ToVreg(call_instr->InputAt(8))); + EXPECT_EQ(s.ToVreg(context), s.ToVreg(call_instr->InputAt(9))); EXPECT_EQ(kArchRet, s[index++]->arch_opcode()); @@ -572,6 +573,7 @@ TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeoptRecursiveFrameState) { EXPECT_EQ(kArchCallCodeObject, call_instr->arch_opcode()); size_t num_operands = 1 + // Code object. + 1 + // Poison index. 1 + // Frame state deopt id 6 + // One input for each value in frame state + context. 5 + // One input for each value in the parent frame state + context. @@ -582,7 +584,7 @@ TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeoptRecursiveFrameState) { EXPECT_TRUE(call_instr->InputAt(0)->IsImmediate()); // Deoptimization id. - int32_t deopt_id_before = s.ToInt32(call_instr->InputAt(1)); + int32_t deopt_id_before = s.ToInt32(call_instr->InputAt(2)); FrameStateDescriptor* desc_before = s.GetFrameStateDescriptor(deopt_id_before); FrameStateDescriptor* desc_before_outer = desc_before->outer_state(); @@ -591,25 +593,25 @@ TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeoptRecursiveFrameState) { EXPECT_EQ(1u, desc_before_outer->locals_count()); EXPECT_EQ(1u, desc_before_outer->stack_count()); // Values from parent environment. - EXPECT_EQ(63, s.ToInt32(call_instr->InputAt(3))); + EXPECT_EQ(63, s.ToInt32(call_instr->InputAt(4))); // Context: - EXPECT_EQ(66, s.ToInt32(call_instr->InputAt(4))); - EXPECT_EQ(64, s.ToInt32(call_instr->InputAt(5))); - EXPECT_EQ(65, s.ToInt32(call_instr->InputAt(6))); + EXPECT_EQ(66, s.ToInt32(call_instr->InputAt(5))); + EXPECT_EQ(64, s.ToInt32(call_instr->InputAt(6))); + EXPECT_EQ(65, s.ToInt32(call_instr->InputAt(7))); // Values from the nested frame. EXPECT_EQ(1u, desc_before->parameters_count()); EXPECT_EQ(1u, desc_before->locals_count()); EXPECT_EQ(2u, desc_before->stack_count()); - EXPECT_EQ(43, s.ToInt32(call_instr->InputAt(8))); - EXPECT_EQ(46, s.ToInt32(call_instr->InputAt(9))); - EXPECT_EQ(0.25, s.ToFloat64(call_instr->InputAt(10))); - EXPECT_EQ(44, s.ToInt32(call_instr->InputAt(11))); - EXPECT_EQ(45, s.ToInt32(call_instr->InputAt(12))); + EXPECT_EQ(43, s.ToInt32(call_instr->InputAt(9))); + EXPECT_EQ(46, s.ToInt32(call_instr->InputAt(10))); + EXPECT_EQ(0.25, s.ToFloat64(call_instr->InputAt(11))); + EXPECT_EQ(44, s.ToInt32(call_instr->InputAt(12))); + EXPECT_EQ(45, s.ToInt32(call_instr->InputAt(13))); // Function. - EXPECT_EQ(s.ToVreg(function_node), s.ToVreg(call_instr->InputAt(13))); + EXPECT_EQ(s.ToVreg(function_node), s.ToVreg(call_instr->InputAt(14))); // Context. - EXPECT_EQ(s.ToVreg(context2), s.ToVreg(call_instr->InputAt(14))); + EXPECT_EQ(s.ToVreg(context2), s.ToVreg(call_instr->InputAt(15))); // Continuation. EXPECT_EQ(kArchRet, s[index++]->arch_opcode()); diff --git a/deps/v8/test/unittests/compiler/int64-lowering-unittest.cc b/deps/v8/test/unittests/compiler/int64-lowering-unittest.cc index 2098249bd6..0d949f7c0d 100644 --- a/deps/v8/test/unittests/compiler/int64-lowering-unittest.cc +++ b/deps/v8/test/unittests/compiler/int64-lowering-unittest.cc @@ -355,8 +355,8 @@ TEST_F(Int64LoweringTest, CallI64Return) { start(), start())); CompareCallDescriptors( - OpParameter<const CallDescriptor*>( - graph()->end()->InputAt(1)->InputAt(1)->InputAt(0)), + CallDescriptorOf( + graph()->end()->InputAt(1)->InputAt(1)->InputAt(0)->op()), compiler::GetI32WasmCallDescriptor(zone(), call_descriptor)); } @@ -391,8 +391,7 @@ TEST_F(Int64LoweringTest, CallI64Parameter) { start(), start())); CompareCallDescriptors( - OpParameter<const CallDescriptor*>( - graph()->end()->InputAt(1)->InputAt(1)), + CallDescriptorOf(graph()->end()->InputAt(1)->InputAt(1)->op()), compiler::GetI32WasmCallDescriptor(zone(), call_descriptor)); } diff --git a/deps/v8/test/unittests/compiler/js-builtin-reducer-unittest.cc b/deps/v8/test/unittests/compiler/js-builtin-reducer-unittest.cc index 4ded3fd667..a110b87a33 100644 --- a/deps/v8/test/unittests/compiler/js-builtin-reducer-unittest.cc +++ b/deps/v8/test/unittests/compiler/js-builtin-reducer-unittest.cc @@ -196,97 +196,6 @@ TEST_F(JSBuiltinReducerTest, GlobalIsNaNWithPlainPrimitive) { } // ----------------------------------------------------------------------------- -// Number.isFinite - -TEST_F(JSBuiltinReducerTest, NumberIsFiniteWithNumber) { - Node* function = NumberFunction("isFinite"); - - Node* effect = graph()->start(); - Node* control = graph()->start(); - Node* context = UndefinedConstant(); - Node* frame_state = graph()->start(); - TRACED_FOREACH(Type*, t0, kNumberTypes) { - Node* p0 = Parameter(t0, 0); - Node* call = - graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), - p0, context, frame_state, effect, control); - Reduction r = Reduce(call); - - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), IsNumberEqual(IsNumberSubtract(p0, p0), - IsNumberSubtract(p0, p0))); - } -} - -// ----------------------------------------------------------------------------- -// Number.isInteger - -TEST_F(JSBuiltinReducerTest, NumberIsIntegerWithNumber) { - Node* function = NumberFunction("isInteger"); - - Node* effect = graph()->start(); - Node* control = graph()->start(); - Node* context = UndefinedConstant(); - Node* frame_state = graph()->start(); - TRACED_FOREACH(Type*, t0, kNumberTypes) { - Node* p0 = Parameter(t0, 0); - Node* call = - graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), - p0, context, frame_state, effect, control); - Reduction r = Reduce(call); - - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), - IsNumberEqual(IsNumberSubtract(p0, IsNumberTrunc(p0)), - IsNumberConstant(0.0))); - } -} - -// ----------------------------------------------------------------------------- -// Number.isNaN - -TEST_F(JSBuiltinReducerTest, NumberIsNaNWithNumber) { - Node* function = NumberFunction("isNaN"); - - Node* effect = graph()->start(); - Node* control = graph()->start(); - Node* context = UndefinedConstant(); - Node* frame_state = graph()->start(); - TRACED_FOREACH(Type*, t0, kNumberTypes) { - Node* p0 = Parameter(t0, 0); - Node* call = - graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), - p0, context, frame_state, effect, control); - Reduction r = Reduce(call); - - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), IsObjectIsNaN(p0)); - } -} - -// ----------------------------------------------------------------------------- -// Number.isSafeInteger - -TEST_F(JSBuiltinReducerTest, NumberIsSafeIntegerWithIntegral32) { - Node* function = NumberFunction("isSafeInteger"); - - Node* effect = graph()->start(); - Node* control = graph()->start(); - Node* context = UndefinedConstant(); - Node* frame_state = graph()->start(); - TRACED_FOREACH(Type*, t0, kIntegral32Types) { - Node* p0 = Parameter(t0, 0); - Node* call = - graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), - p0, context, frame_state, effect, control); - Reduction r = Reduce(call); - - ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), IsTrueConstant()); - } -} - -// ----------------------------------------------------------------------------- // Number.parseInt TEST_F(JSBuiltinReducerTest, NumberParseIntWithIntegral32) { diff --git a/deps/v8/test/unittests/compiler/js-call-reducer-unittest.cc b/deps/v8/test/unittests/compiler/js-call-reducer-unittest.cc index 2a917d3c36..9b0010796d 100644 --- a/deps/v8/test/unittests/compiler/js-call-reducer-unittest.cc +++ b/deps/v8/test/unittests/compiler/js-call-reducer-unittest.cc @@ -8,8 +8,8 @@ #include "src/compiler/js-call-reducer.h" #include "src/compiler/js-graph.h" #include "src/compiler/simplified-operator.h" -#include "src/factory.h" #include "src/feedback-vector.h" +#include "src/heap/factory.h" #include "src/isolate.h" #include "test/unittests/compiler/graph-unittest.h" #include "test/unittests/compiler/node-test-utils.h" @@ -80,6 +80,19 @@ class JSCallReducerTest : public TypedGraphTest { return HeapConstant(f); } + Node* NumberFunction(const char* name) { + Handle<Object> m = + JSObject::GetProperty( + isolate()->global_object(), + isolate()->factory()->NewStringFromAsciiChecked("Number")) + .ToHandleChecked(); + Handle<JSFunction> f = Handle<JSFunction>::cast( + Object::GetProperty( + m, isolate()->factory()->NewStringFromAsciiChecked(name)) + .ToHandleChecked()); + return HeapConstant(f); + } + std::string op_name_for(const char* fnc) { std::string string_fnc(fnc); char initial = std::toupper(fnc[0]); @@ -92,9 +105,11 @@ class JSCallReducerTest : public TypedGraphTest { spec.AddCallICSlot(); Handle<FeedbackMetadata> metadata = FeedbackMetadata::New(isolate(), &spec); Handle<SharedFunctionInfo> shared = - isolate()->factory()->NewSharedFunctionInfo( - isolate()->factory()->empty_string(), MaybeHandle<Code>(), false); - shared->set_feedback_metadata(*metadata); + isolate()->factory()->NewSharedFunctionInfoForBuiltin( + isolate()->factory()->empty_string(), Builtins::kIllegal); + // Set the raw feedback metadata to circumvent checks that we are not + // overwriting existing metadata. + shared->set_raw_outer_scope_info_or_feedback_metadata(*metadata); Handle<FeedbackVector> vector = FeedbackVector::New(isolate(), shared); VectorSlotPair feedback(vector, FeedbackSlot(0)); return javascript()->Call(arity, CallFrequency(), feedback, @@ -407,7 +422,7 @@ TEST_F(JSCallReducerTest, MathMaxWithTwoArguments) { // ----------------------------------------------------------------------------- // String.fromCharCode -TEST_F(JSCallReducerTest, StringFromCharCodeWithNumber) { +TEST_F(JSCallReducerTest, StringFromSingleCharCodeWithNumber) { Node* function = StringFunction("fromCharCode"); Node* effect = graph()->start(); @@ -420,10 +435,11 @@ TEST_F(JSCallReducerTest, StringFromCharCodeWithNumber) { Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), IsStringFromCharCode(IsSpeculativeToNumber(p0))); + EXPECT_THAT(r.replacement(), + IsStringFromSingleCharCode(IsSpeculativeToNumber(p0))); } -TEST_F(JSCallReducerTest, StringFromCharCodeWithPlainPrimitive) { +TEST_F(JSCallReducerTest, StringFromSingleCharCodeWithPlainPrimitive) { Node* function = StringFunction("fromCharCode"); Node* effect = graph()->start(); @@ -436,7 +452,87 @@ TEST_F(JSCallReducerTest, StringFromCharCodeWithPlainPrimitive) { Reduction r = Reduce(call); ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), IsStringFromCharCode(IsSpeculativeToNumber(p0))); + EXPECT_THAT(r.replacement(), + IsStringFromSingleCharCode(IsSpeculativeToNumber(p0))); +} + +// ----------------------------------------------------------------------------- +// Number.isFinite + +TEST_F(JSCallReducerTest, NumberIsFinite) { + Node* function = NumberFunction("isFinite"); + + Node* effect = graph()->start(); + Node* control = graph()->start(); + Node* context = UndefinedConstant(); + Node* frame_state = graph()->start(); + Node* p0 = Parameter(Type::Any(), 0); + Node* call = graph()->NewNode(Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); + Reduction r = Reduce(call); + + ASSERT_TRUE(r.Changed()); + EXPECT_THAT(r.replacement(), IsObjectIsFiniteNumber(p0)); +} + +// ----------------------------------------------------------------------------- +// Number.isInteger + +TEST_F(JSCallReducerTest, NumberIsIntegerWithNumber) { + Node* function = NumberFunction("isInteger"); + + Node* effect = graph()->start(); + Node* control = graph()->start(); + Node* context = UndefinedConstant(); + Node* frame_state = graph()->start(); + Node* p0 = Parameter(Type::Any(), 0); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); + Reduction r = Reduce(call); + + ASSERT_TRUE(r.Changed()); + EXPECT_THAT(r.replacement(), IsObjectIsInteger(p0)); +} + +// ----------------------------------------------------------------------------- +// Number.isNaN + +TEST_F(JSCallReducerTest, NumberIsNaNWithNumber) { + Node* function = NumberFunction("isNaN"); + + Node* effect = graph()->start(); + Node* control = graph()->start(); + Node* context = UndefinedConstant(); + Node* frame_state = graph()->start(); + Node* p0 = Parameter(Type::Any(), 0); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); + Reduction r = Reduce(call); + + ASSERT_TRUE(r.Changed()); + EXPECT_THAT(r.replacement(), IsObjectIsNaN(p0)); +} + +// ----------------------------------------------------------------------------- +// Number.isSafeInteger + +TEST_F(JSCallReducerTest, NumberIsSafeIntegerWithIntegral32) { + Node* function = NumberFunction("isSafeInteger"); + + Node* effect = graph()->start(); + Node* control = graph()->start(); + Node* context = UndefinedConstant(); + Node* frame_state = graph()->start(); + Node* p0 = Parameter(Type::Any(), 0); + Node* call = + graph()->NewNode(javascript()->Call(3), function, UndefinedConstant(), p0, + context, frame_state, effect, control); + Reduction r = Reduce(call); + + ASSERT_TRUE(r.Changed()); + EXPECT_THAT(r.replacement(), IsObjectIsSafeInteger(p0)); } } // namespace compiler diff --git a/deps/v8/test/unittests/compiler/machine-operator-unittest.cc b/deps/v8/test/unittests/compiler/machine-operator-unittest.cc index 75e8468244..eea7276f6f 100644 --- a/deps/v8/test/unittests/compiler/machine-operator-unittest.cc +++ b/deps/v8/test/unittests/compiler/machine-operator-unittest.cc @@ -88,8 +88,7 @@ TEST_P(MachineLoadOperatorTest, OpcodeIsCorrect) { TEST_P(MachineLoadOperatorTest, ParameterIsCorrect) { MachineOperatorBuilder machine(zone(), representation()); - EXPECT_EQ(GetParam(), - OpParameter<LoadRepresentation>(machine.Load(GetParam()))); + EXPECT_EQ(GetParam(), LoadRepresentationOf(machine.Load(GetParam()))); } @@ -149,8 +148,7 @@ TEST_P(MachineStoreOperatorTest, OpcodeIsCorrect) { TEST_P(MachineStoreOperatorTest, ParameterIsCorrect) { MachineOperatorBuilder machine(zone(), representation()); - EXPECT_EQ(GetParam(), - OpParameter<StoreRepresentation>(machine.Store(GetParam()))); + EXPECT_EQ(GetParam(), StoreRepresentationOf(machine.Store(GetParam()))); } diff --git a/deps/v8/test/unittests/compiler/node-test-utils.cc b/deps/v8/test/unittests/compiler/node-test-utils.cc index 68bf36c6e2..1695902639 100644 --- a/deps/v8/test/unittests/compiler/node-test-utils.cc +++ b/deps/v8/test/unittests/compiler/node-test-utils.cc @@ -135,7 +135,7 @@ class IsSwitchMatcher final : public TestNodeMatcher { class IsIfValueMatcher final : public TestNodeMatcher { public: - IsIfValueMatcher(const Matcher<int32_t>& value_matcher, + IsIfValueMatcher(const Matcher<IfValueParameters>& value_matcher, const Matcher<Node*>& control_matcher) : TestNodeMatcher(IrOpcode::kIfValue), value_matcher_(value_matcher), @@ -152,14 +152,14 @@ class IsIfValueMatcher final : public TestNodeMatcher { bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { return (TestNodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(OpParameter<int32_t>(node->op()), "value", + PrintMatchAndExplain(IfValueParametersOf(node->op()), "value", value_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node), "control", control_matcher_, listener)); } private: - const Matcher<int32_t> value_matcher_; + const Matcher<IfValueParameters> value_matcher_; const Matcher<Node*> control_matcher_; }; @@ -442,8 +442,8 @@ class IsConstantMatcher final : public TestNodeMatcher { bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { return (TestNodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(OpParameter<T>(node), "value", value_matcher_, - listener)); + PrintMatchAndExplain(OpParameter<T>(node->op()), "value", + value_matcher_, listener)); } private: @@ -646,7 +646,7 @@ class IsProjectionMatcher final : public TestNodeMatcher { bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { return (TestNodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(OpParameter<size_t>(node), "index", + PrintMatchAndExplain(OpParameter<size_t>(node->op()), "index", index_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", base_matcher_, listener)); @@ -688,8 +688,8 @@ class IsCallMatcher final : public TestNodeMatcher { bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { if (!TestNodeMatcher::MatchAndExplain(node, listener) || - !PrintMatchAndExplain(OpParameter<const CallDescriptor*>(node), - "descriptor", descriptor_matcher_, listener)) { + !PrintMatchAndExplain(CallDescriptorOf(node->op()), "descriptor", + descriptor_matcher_, listener)) { return false; } for (size_t i = 0; i < value_matchers_.size(); ++i) { @@ -753,8 +753,8 @@ class IsTailCallMatcher final : public TestNodeMatcher { bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { if (!TestNodeMatcher::MatchAndExplain(node, listener) || - !PrintMatchAndExplain(OpParameter<CallDescriptor const*>(node), - "descriptor", descriptor_matcher_, listener)) { + !PrintMatchAndExplain(CallDescriptorOf(node->op()), "descriptor", + descriptor_matcher_, listener)) { return false; } for (size_t i = 0; i < value_matchers_.size(); ++i) { @@ -805,8 +805,8 @@ class IsSpeculativeBinopMatcher final : public TestNodeMatcher { bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { return (TestNodeMatcher::MatchAndExplain(node, listener) && // TODO(bmeurer): The type parameter is currently ignored. - PrintMatchAndExplain(OpParameter<NumberOperationHint>(node->op()), - "hints", hint_matcher_, listener) && + PrintMatchAndExplain(NumberOperationHintOf(node->op()), "hints", + hint_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs", lhs_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "rhs", @@ -879,7 +879,7 @@ class IsLoadFieldMatcher final : public TestNodeMatcher { bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { return (TestNodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(OpParameter<FieldAccess>(node), "access", + PrintMatchAndExplain(FieldAccessOf(node->op()), "access", access_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", base_matcher_, listener) && @@ -927,7 +927,7 @@ class IsStoreFieldMatcher final : public TestNodeMatcher { bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { return (TestNodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(OpParameter<FieldAccess>(node), "access", + PrintMatchAndExplain(FieldAccessOf(node->op()), "access", access_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", base_matcher_, listener) && @@ -978,7 +978,7 @@ class IsLoadElementMatcher final : public TestNodeMatcher { bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { return (TestNodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access", + PrintMatchAndExplain(ElementAccessOf(node->op()), "access", access_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", base_matcher_, listener) && @@ -1033,7 +1033,7 @@ class IsStoreElementMatcher final : public TestNodeMatcher { bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { return (TestNodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access", + PrintMatchAndExplain(ElementAccessOf(node->op()), "access", access_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", base_matcher_, listener) && @@ -1059,7 +1059,7 @@ class IsStoreElementMatcher final : public TestNodeMatcher { #define LOAD_MATCHER(kLoad) \ class Is##kLoad##Matcher final : public TestNodeMatcher { \ public: \ - Is##kLoad##Matcher(const Matcher<kLoad##Representation>& rep_matcher, \ + Is##kLoad##Matcher(const Matcher<LoadRepresentation>& rep_matcher, \ const Matcher<Node*>& base_matcher, \ const Matcher<Node*>& index_matcher, \ const Matcher<Node*>& effect_matcher, \ @@ -1097,8 +1097,8 @@ class IsStoreElementMatcher final : public TestNodeMatcher { control_node = NodeProperties::GetControlInput(node); \ } \ return (TestNodeMatcher::MatchAndExplain(node, listener) && \ - PrintMatchAndExplain(OpParameter<kLoad##Representation>(node), \ - "rep", rep_matcher_, listener) && \ + PrintMatchAndExplain(LoadRepresentationOf(node->op()), "rep", \ + rep_matcher_, listener) && \ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), \ "base", base_matcher_, listener) && \ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), \ @@ -1110,7 +1110,7 @@ class IsStoreElementMatcher final : public TestNodeMatcher { } \ \ private: \ - const Matcher<kLoad##Representation> rep_matcher_; \ + const Matcher<LoadRepresentation> rep_matcher_; \ const Matcher<Node*> base_matcher_; \ const Matcher<Node*> index_matcher_; \ const Matcher<Node*> effect_matcher_; \ @@ -1119,6 +1119,7 @@ class IsStoreElementMatcher final : public TestNodeMatcher { LOAD_MATCHER(Load) LOAD_MATCHER(UnalignedLoad) +LOAD_MATCHER(PoisonedLoad) #define STORE_MATCHER(kStore) \ class Is##kStore##Matcher final : public TestNodeMatcher { \ @@ -1165,8 +1166,9 @@ LOAD_MATCHER(UnalignedLoad) control_node = NodeProperties::GetControlInput(node); \ } \ return (TestNodeMatcher::MatchAndExplain(node, listener) && \ - PrintMatchAndExplain(OpParameter<kStore##Representation>(node), \ - "rep", rep_matcher_, listener) && \ + PrintMatchAndExplain( \ + OpParameter<kStore##Representation>(node->op()), "rep", \ + rep_matcher_, listener) && \ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), \ "base", base_matcher_, listener) && \ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), \ @@ -1206,8 +1208,8 @@ class IsStackSlotMatcher final : public TestNodeMatcher { bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { return (TestNodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(OpParameter<StackSlotRepresentation>(node), - "rep", rep_matcher_, listener)); + PrintMatchAndExplain(StackSlotRepresentationOf(node->op()), "rep", + rep_matcher_, listener)); } private: @@ -1277,7 +1279,7 @@ class IsLoadContextMatcher final : public TestNodeMatcher { bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { return (TestNodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(OpParameter<ContextAccess>(node), "access", + PrintMatchAndExplain(ContextAccessOf(node->op()), "access", access_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetContextInput(node), "context", context_matcher_, listener)); @@ -1526,8 +1528,7 @@ Matcher<Node*> IsSwitch(const Matcher<Node*>& value_matcher, return MakeMatcher(new IsSwitchMatcher(value_matcher, control_matcher)); } - -Matcher<Node*> IsIfValue(const Matcher<int32_t>& value_matcher, +Matcher<Node*> IsIfValue(const Matcher<IfValueParameters>& value_matcher, const Matcher<Node*>& control_matcher) { return MakeMatcher(new IsIfValueMatcher(value_matcher, control_matcher)); } @@ -1970,11 +1971,21 @@ Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher, effect_matcher, control_matcher)); } -Matcher<Node*> IsUnalignedLoad( - const Matcher<UnalignedLoadRepresentation>& rep_matcher, - const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher, - const Matcher<Node*>& effect_matcher, - const Matcher<Node*>& control_matcher) { +Matcher<Node*> IsPoisonedLoad(const Matcher<LoadRepresentation>& rep_matcher, + const Matcher<Node*>& base_matcher, + const Matcher<Node*>& index_matcher, + const Matcher<Node*>& effect_matcher, + const Matcher<Node*>& control_matcher) { + return MakeMatcher(new IsPoisonedLoadMatcher(rep_matcher, base_matcher, + index_matcher, effect_matcher, + control_matcher)); +} + +Matcher<Node*> IsUnalignedLoad(const Matcher<LoadRepresentation>& rep_matcher, + const Matcher<Node*>& base_matcher, + const Matcher<Node*>& index_matcher, + const Matcher<Node*>& effect_matcher, + const Matcher<Node*>& control_matcher) { return MakeMatcher(new IsUnalignedLoadMatcher(rep_matcher, base_matcher, index_matcher, effect_matcher, control_matcher)); @@ -2025,10 +2036,6 @@ Matcher<Node*> IsParameter(const Matcher<int> index_matcher) { return MakeMatcher(new IsParameterMatcher(index_matcher)); } -Matcher<Node*> IsSpeculationPoison() { - return MakeMatcher(new TestNodeMatcher(IrOpcode::kSpeculationPoison)); -} - Matcher<Node*> IsLoadFramePointer() { return MakeMatcher(new TestNodeMatcher(IrOpcode::kLoadFramePointer)); } @@ -2178,17 +2185,21 @@ IS_UNOP_MATCHER(NumberToBoolean) IS_UNOP_MATCHER(NumberToInt32) IS_UNOP_MATCHER(NumberToUint32) IS_UNOP_MATCHER(PlainPrimitiveToNumber) +IS_UNOP_MATCHER(ObjectIsFiniteNumber) +IS_UNOP_MATCHER(ObjectIsInteger) +IS_UNOP_MATCHER(ObjectIsSafeInteger) IS_UNOP_MATCHER(ObjectIsNaN) IS_UNOP_MATCHER(ObjectIsReceiver) IS_UNOP_MATCHER(ObjectIsSmi) IS_UNOP_MATCHER(ObjectIsUndetectable) -IS_UNOP_MATCHER(StringFromCharCode) +IS_UNOP_MATCHER(StringFromSingleCharCode) IS_UNOP_MATCHER(StringLength) IS_UNOP_MATCHER(Word32Clz) IS_UNOP_MATCHER(Word32Ctz) IS_UNOP_MATCHER(Word32Popcnt) IS_UNOP_MATCHER(Word32ReverseBytes) IS_UNOP_MATCHER(SpeculativeToNumber) +IS_UNOP_MATCHER(PoisonOnSpeculationTagged) #undef IS_UNOP_MATCHER // Special-case Bitcast operators which are disabled when ENABLE_VERIFY_CSA is @@ -2212,6 +2223,11 @@ Matcher<Node*> IsBitcastWordToTaggedSigned( #endif } +#undef LOAD_MATCHER +#undef STORE_MATCHER +#undef IS_QUADOP_MATCHER +#undef IS_TERNOP_MATCHER + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/unittests/compiler/node-test-utils.h b/deps/v8/test/unittests/compiler/node-test-utils.h index e3de90eb1f..baec34cd33 100644 --- a/deps/v8/test/unittests/compiler/node-test-utils.h +++ b/deps/v8/test/unittests/compiler/node-test-utils.h @@ -5,6 +5,7 @@ #ifndef V8_UNITTESTS_COMPILER_NODE_TEST_UTILS_H_ #define V8_UNITTESTS_COMPILER_NODE_TEST_UTILS_H_ +#include "src/compiler/common-operator.h" #include "src/compiler/machine-operator.h" #include "src/compiler/simplified-operator.h" #include "src/machine-type.h" @@ -68,7 +69,7 @@ Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher); Matcher<Node*> IsIfSuccess(const Matcher<Node*>& control_matcher); Matcher<Node*> IsSwitch(const Matcher<Node*>& value_matcher, const Matcher<Node*>& control_matcher); -Matcher<Node*> IsIfValue(const Matcher<int32_t>& value_matcher, +Matcher<Node*> IsIfValue(const Matcher<IfValueParameters>& value_matcher, const Matcher<Node*>& control_matcher); Matcher<Node*> IsIfDefault(const Matcher<Node*>& control_matcher); Matcher<Node*> IsBeginRegion(const Matcher<Node*>& effect_matcher); @@ -271,7 +272,7 @@ Matcher<Node*> IsNumberSqrt(const Matcher<Node*>& value_matcher); Matcher<Node*> IsNumberTan(const Matcher<Node*>& value_matcher); Matcher<Node*> IsNumberTanh(const Matcher<Node*>& value_matcher); Matcher<Node*> IsNumberTrunc(const Matcher<Node*>& value_matcher); -Matcher<Node*> IsStringFromCharCode(const Matcher<Node*>& value_matcher); +Matcher<Node*> IsStringFromSingleCharCode(const Matcher<Node*>& value_matcher); Matcher<Node*> IsStringLength(const Matcher<Node*>& value_matcher); Matcher<Node*> IsAllocate(const Matcher<Node*>& size_matcher, const Matcher<Node*>& effect_matcher, @@ -309,6 +310,10 @@ Matcher<Node*> IsStoreElement(const Matcher<ElementAccess>& access_matcher, const Matcher<Node*>& value_matcher, const Matcher<Node*>& effect_matcher, const Matcher<Node*>& control_matcher); + +Matcher<Node*> IsObjectIsFiniteNumber(const Matcher<Node*>& value_matcher); +Matcher<Node*> IsObjectIsInteger(const Matcher<Node*>& value_matcher); +Matcher<Node*> IsObjectIsSafeInteger(const Matcher<Node*>& value_matcher); Matcher<Node*> IsObjectIsNaN(const Matcher<Node*>& value_matcher); Matcher<Node*> IsObjectIsReceiver(const Matcher<Node*>& value_matcher); Matcher<Node*> IsObjectIsSmi(const Matcher<Node*>& value_matcher); @@ -319,11 +324,16 @@ Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher, const Matcher<Node*>& index_matcher, const Matcher<Node*>& effect_matcher, const Matcher<Node*>& control_matcher); -Matcher<Node*> IsUnalignedLoad( - const Matcher<UnalignedLoadRepresentation>& rep_matcher, - const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher, - const Matcher<Node*>& effect_matcher, - const Matcher<Node*>& control_matcher); +Matcher<Node*> IsPoisonedLoad(const Matcher<LoadRepresentation>& rep_matcher, + const Matcher<Node*>& base_matcher, + const Matcher<Node*>& index_matcher, + const Matcher<Node*>& effect_matcher, + const Matcher<Node*>& control_matcher); +Matcher<Node*> IsUnalignedLoad(const Matcher<LoadRepresentation>& rep_matcher, + const Matcher<Node*>& base_matcher, + const Matcher<Node*>& index_matcher, + const Matcher<Node*>& effect_matcher, + const Matcher<Node*>& control_matcher); Matcher<Node*> IsStore(const Matcher<StoreRepresentation>& rep_matcher, const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher, diff --git a/deps/v8/test/unittests/heap/gc-tracer-unittest.cc b/deps/v8/test/unittests/heap/gc-tracer-unittest.cc index e4e9260881..0f1a841e2d 100644 --- a/deps/v8/test/unittests/heap/gc-tracer-unittest.cc +++ b/deps/v8/test/unittests/heap/gc-tracer-unittest.cc @@ -295,6 +295,42 @@ TEST_F(GCTracerTest, IncrementalMarkingSpeed) { tracer->IncrementalMarkingSpeedInBytesPerMillisecond())); } +TEST_F(GCTracerTest, MutatorUtilization) { + GCTracer* tracer = i_isolate()->heap()->tracer(); + tracer->ResetForTesting(); + + // Mark-compact #1 ended at 200ms and took 100ms. + tracer->RecordMutatorUtilization(200, 100); + // Avarage mark-compact time = 0ms. + // Avarage mutator time = 0ms. + EXPECT_DOUBLE_EQ(1.0, tracer->CurrentMarkCompactMutatorUtilization()); + EXPECT_DOUBLE_EQ(1.0, tracer->AverageMarkCompactMutatorUtilization()); + + // Mark-compact #2 ended at 400ms and took 100ms. + tracer->RecordMutatorUtilization(400, 100); + // The first mark-compactor is ignored. + // Avarage mark-compact time = 100ms. + // Avarage mutator time = 100ms. + EXPECT_DOUBLE_EQ(0.5, tracer->CurrentMarkCompactMutatorUtilization()); + EXPECT_DOUBLE_EQ(0.5, tracer->AverageMarkCompactMutatorUtilization()); + + // Mark-compact #3 ended at 600ms and took 200ms. + tracer->RecordMutatorUtilization(600, 200); + // Avarage mark-compact time = 100ms * 0.5 + 200ms * 0.5. + // Avarage mutator time = 100ms * 0.5 + 0ms * 0.5. + EXPECT_DOUBLE_EQ(0.0, tracer->CurrentMarkCompactMutatorUtilization()); + EXPECT_DOUBLE_EQ(50.0 / 200.0, + tracer->AverageMarkCompactMutatorUtilization()); + + // Mark-compact #4 ended at 800ms and took 0ms. + tracer->RecordMutatorUtilization(800, 0); + // Avarage mark-compact time = 150ms * 0.5 + 0ms * 0.5. + // Avarage mutator time = 50ms * 0.5 + 200ms * 0.5. + EXPECT_DOUBLE_EQ(1.0, tracer->CurrentMarkCompactMutatorUtilization()); + EXPECT_DOUBLE_EQ(125.0 / 200.0, + tracer->AverageMarkCompactMutatorUtilization()); +} + TEST_F(GCTracerTest, BackgroundScavengerScope) { GCTracer* tracer = i_isolate()->heap()->tracer(); tracer->ResetForTesting(); diff --git a/deps/v8/test/unittests/interpreter/bytecode-array-builder-unittest.cc b/deps/v8/test/unittests/interpreter/bytecode-array-builder-unittest.cc index 8591e55628..e6348f4785 100644 --- a/deps/v8/test/unittests/interpreter/bytecode-array-builder-unittest.cc +++ b/deps/v8/test/unittests/interpreter/bytecode-array-builder-unittest.cc @@ -104,6 +104,8 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { FeedbackSlot strict_keyed_store_slot = feedback_spec.AddKeyedStoreICSlot(LanguageMode::kStrict); FeedbackSlot store_own_slot = feedback_spec.AddStoreOwnICSlot(); + FeedbackSlot store_array_element_slot = + feedback_spec.AddStoreInArrayLiteralICSlot(); // Emit global load / store operations. const AstRawString* name = ast_factory.GetOneByteString("var_name"); @@ -141,7 +143,8 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { LanguageMode::kStrict) .StoreKeyedProperty(reg, reg, strict_keyed_store_slot.ToInt(), LanguageMode::kStrict) - .StoreNamedOwnProperty(reg, name, store_own_slot.ToInt()); + .StoreNamedOwnProperty(reg, name, store_own_slot.ToInt()) + .StoreInArrayLiteral(reg, reg, store_array_element_slot.ToInt()); // Emit load / store lookup slots. builder.LoadLookupSlot(name, TypeofMode::NOT_INSIDE_TYPEOF) @@ -190,7 +193,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { .CallUndefinedReceiver(reg, pair, 1) .CallRuntime(Runtime::kIsArray, reg) .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, reg_list, pair) - .CallJSRuntime(Context::SPREAD_ITERABLE_INDEX, reg_list) + .CallJSRuntime(Context::OBJECT_IS_FROZEN, reg_list) .CallWithSpread(reg, reg_list, 1); // Emit binary operator invocations. @@ -259,7 +262,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { .CompareNull(); // Emit conversion operator invocations. - builder.ToNumber(1).ToNumeric(1).ToObject(reg).ToName(reg); + builder.ToNumber(1).ToNumeric(1).ToObject(reg).ToName(reg).ToString(); // Emit GetSuperConstructor. builder.GetSuperConstructor(reg); diff --git a/deps/v8/test/unittests/interpreter/bytecode-array-writer-unittest.cc b/deps/v8/test/unittests/interpreter/bytecode-array-writer-unittest.cc index 9f8f2db953..5eb4d3be9a 100644 --- a/deps/v8/test/unittests/interpreter/bytecode-array-writer-unittest.cc +++ b/deps/v8/test/unittests/interpreter/bytecode-array-writer-unittest.cc @@ -5,7 +5,7 @@ #include "src/v8.h" #include "src/api.h" -#include "src/factory.h" +#include "src/heap/factory.h" #include "src/interpreter/bytecode-array-writer.h" #include "src/interpreter/bytecode-label.h" #include "src/interpreter/bytecode-node.h" diff --git a/deps/v8/test/unittests/interpreter/constant-array-builder-unittest.cc b/deps/v8/test/unittests/interpreter/constant-array-builder-unittest.cc index 5c1bfe127c..59e228a29c 100644 --- a/deps/v8/test/unittests/interpreter/constant-array-builder-unittest.cc +++ b/deps/v8/test/unittests/interpreter/constant-array-builder-unittest.cc @@ -5,8 +5,8 @@ #include "src/v8.h" #include "src/ast/ast-value-factory.h" -#include "src/factory.h" #include "src/handles-inl.h" +#include "src/heap/factory.h" #include "src/interpreter/constant-array-builder.h" #include "src/isolate.h" #include "src/objects-inl.h" diff --git a/deps/v8/test/unittests/interpreter/interpreter-assembler-unittest.cc b/deps/v8/test/unittests/interpreter/interpreter-assembler-unittest.cc index 1d48b65d25..cb4875063c 100644 --- a/deps/v8/test/unittests/interpreter/interpreter-assembler-unittest.cc +++ b/deps/v8/test/unittests/interpreter/interpreter-assembler-unittest.cc @@ -28,7 +28,7 @@ InterpreterAssemblerTestState::InterpreterAssemblerTestState( test->isolate(), test->zone(), InterpreterDispatchDescriptor(test->isolate()), Code::BYTECODE_HANDLER, Bytecodes::ToString(bytecode), - Bytecodes::ReturnCount(bytecode)) {} + PoisoningMitigationLevel::kOn, Bytecodes::ReturnCount(bytecode)) {} const interpreter::Bytecode kBytecodes[] = { #define DEFINE_BYTECODE(Name, ...) interpreter::Bytecode::k##Name, @@ -51,7 +51,13 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest:: Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsLoad( const Matcher<c::LoadRepresentation>& rep_matcher, - const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher) { + const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher, + LoadSensitivity needs_poisoning) { + if (poisoning_enabled() == PoisoningMitigationLevel::kOn && + needs_poisoning == LoadSensitivity::kNeedsPoisoning) { + return ::i::compiler::IsPoisonedLoad(rep_matcher, base_matcher, + index_matcher, _, _); + } return ::i::compiler::IsLoad(rep_matcher, base_matcher, index_matcher, _, _); } @@ -71,36 +77,39 @@ Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsWordNot( Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedByteOperand( - int offset) { + int offset, LoadSensitivity needs_poisoning) { return IsLoad( MachineType::Uint8(), c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), c::IsIntPtrAdd( c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - c::IsIntPtrConstant(offset))); + c::IsIntPtrConstant(offset)), + needs_poisoning); } Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedByteOperand( - int offset) { + int offset, LoadSensitivity needs_poisoning) { return IsLoad( MachineType::Int8(), c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), c::IsIntPtrAdd( c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - c::IsIntPtrConstant(offset))); + c::IsIntPtrConstant(offset)), + needs_poisoning); } Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedShortOperand( - int offset) { + int offset, LoadSensitivity needs_poisoning) { if (TargetSupportsUnalignedAccess()) { return IsLoad( MachineType::Uint16(), c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), c::IsIntPtrAdd( c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - c::IsIntPtrConstant(offset))); + c::IsIntPtrConstant(offset)), + needs_poisoning); } else { #if V8_TARGET_LITTLE_ENDIAN const int kStep = -1; @@ -118,7 +127,8 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedShortOperand( c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), c::IsIntPtrAdd( c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - c::IsIntPtrConstant(offset + kMsbOffset + kStep * i))); + c::IsIntPtrConstant(offset + kMsbOffset + kStep * i)), + needs_poisoning); } return c::IsWord32Or( c::IsWord32Shl(bytes[0], c::IsInt32Constant(kBitsPerByte)), bytes[1]); @@ -127,14 +137,15 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedShortOperand( Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedShortOperand( - int offset) { + int offset, LoadSensitivity needs_poisoning) { if (TargetSupportsUnalignedAccess()) { return IsLoad( MachineType::Int16(), c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), c::IsIntPtrAdd( c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - c::IsIntPtrConstant(offset))); + c::IsIntPtrConstant(offset)), + needs_poisoning); } else { #if V8_TARGET_LITTLE_ENDIAN const int kStep = -1; @@ -152,7 +163,8 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedShortOperand( c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), c::IsIntPtrAdd( c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - c::IsIntPtrConstant(offset + kMsbOffset + kStep * i))); + c::IsIntPtrConstant(offset + kMsbOffset + kStep * i)), + needs_poisoning); } return c::IsWord32Or( c::IsWord32Shl(bytes[0], c::IsInt32Constant(kBitsPerByte)), bytes[1]); @@ -161,14 +173,15 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedShortOperand( Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedQuadOperand( - int offset) { + int offset, LoadSensitivity needs_poisoning) { if (TargetSupportsUnalignedAccess()) { return IsLoad( MachineType::Uint32(), c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), c::IsIntPtrAdd( c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - c::IsIntPtrConstant(offset))); + c::IsIntPtrConstant(offset)), + needs_poisoning); } else { #if V8_TARGET_LITTLE_ENDIAN const int kStep = -1; @@ -186,7 +199,8 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedQuadOperand( c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), c::IsIntPtrAdd( c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - c::IsIntPtrConstant(offset + kMsbOffset + kStep * i))); + c::IsIntPtrConstant(offset + kMsbOffset + kStep * i)), + needs_poisoning); } return c::IsWord32Or( c::IsWord32Shl(bytes[0], c::IsInt32Constant(3 * kBitsPerByte)), @@ -200,14 +214,15 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedQuadOperand( Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedQuadOperand( - int offset) { + int offset, LoadSensitivity needs_poisoning) { if (TargetSupportsUnalignedAccess()) { return IsLoad( MachineType::Int32(), c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), c::IsIntPtrAdd( c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - c::IsIntPtrConstant(offset))); + c::IsIntPtrConstant(offset)), + needs_poisoning); } else { #if V8_TARGET_LITTLE_ENDIAN const int kStep = -1; @@ -225,7 +240,8 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedQuadOperand( c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), c::IsIntPtrAdd( c::IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), - c::IsIntPtrConstant(offset + kMsbOffset + kStep * i))); + c::IsIntPtrConstant(offset + kMsbOffset + kStep * i)), + needs_poisoning); } return c::IsWord32Or( c::IsWord32Shl(bytes[0], c::IsInt32Constant(3 * kBitsPerByte)), @@ -237,30 +253,32 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedQuadOperand( } } -Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest:: - IsUnpoisonedSignedOperand(int offset, OperandSize operand_size) { +Matcher<Node*> +InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedOperand( + int offset, OperandSize operand_size, LoadSensitivity needs_poisoning) { switch (operand_size) { case OperandSize::kByte: - return IsSignedByteOperand(offset); + return IsSignedByteOperand(offset, needs_poisoning); case OperandSize::kShort: - return IsSignedShortOperand(offset); + return IsSignedShortOperand(offset, needs_poisoning); case OperandSize::kQuad: - return IsSignedQuadOperand(offset); + return IsSignedQuadOperand(offset, needs_poisoning); case OperandSize::kNone: UNREACHABLE(); } return nullptr; } -Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest:: - IsUnpoisonedUnsignedOperand(int offset, OperandSize operand_size) { +Matcher<Node*> +InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedOperand( + int offset, OperandSize operand_size, LoadSensitivity needs_poisoning) { switch (operand_size) { case OperandSize::kByte: - return IsUnsignedByteOperand(offset); + return IsUnsignedByteOperand(offset, needs_poisoning); case OperandSize::kShort: - return IsUnsignedShortOperand(offset); + return IsUnsignedShortOperand(offset, needs_poisoning); case OperandSize::kQuad: - return IsUnsignedQuadOperand(offset); + return IsUnsignedQuadOperand(offset, needs_poisoning); case OperandSize::kNone: UNREACHABLE(); } @@ -268,47 +286,14 @@ Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest:: } Matcher<compiler::Node*> -InterpreterAssemblerTest::InterpreterAssemblerForTest::IsPoisonTagged( - const Matcher<compiler::Node*> value_matcher) { - return IsBitcastWordToTagged(IsWordAnd(c::IsSpeculationPoison(), - IsBitcastTaggedToWord(value_matcher))); -} - -Matcher<compiler::Node*> -InterpreterAssemblerTest::InterpreterAssemblerForTest::IsPoisonWord( - const Matcher<compiler::Node*> value_matcher) { - return IsWordAnd(c::IsSpeculationPoison(), value_matcher); -} - -Matcher<compiler::Node*> -InterpreterAssemblerTest::InterpreterAssemblerForTest::IsPoisonInt32( - const Matcher<compiler::Node*> value_matcher) { - Matcher<compiler::Node*> truncated_speculation_poison = - Is64() ? c::IsTruncateInt64ToInt32(c::IsSpeculationPoison()) - : c::IsSpeculationPoison(); - return IsWord32And(truncated_speculation_poison, value_matcher); -} - -Matcher<Node*> -InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedOperand( - int offset, OperandSize operand_size) { - return IsPoisonInt32(IsUnpoisonedSignedOperand(offset, operand_size)); -} - -Matcher<Node*> -InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedOperand( - int offset, OperandSize operand_size) { - return IsPoisonInt32(IsUnpoisonedUnsignedOperand(offset, operand_size)); -} - -Matcher<compiler::Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsLoadRegisterOperand( int offset, OperandSize operand_size) { - Matcher<compiler::Node*> reg_operand = - IsChangeInt32ToIntPtr(IsUnpoisonedSignedOperand(offset, operand_size)); - return IsPoisonTagged( - IsLoad(MachineType::AnyTagged(), c::IsLoadParentFramePointer(), - c::IsWordShl(reg_operand, c::IsIntPtrConstant(kPointerSizeLog2)))); + Matcher<compiler::Node*> reg_operand = IsChangeInt32ToIntPtr( + IsSignedOperand(offset, operand_size, LoadSensitivity::kSafe)); + return IsLoad( + MachineType::AnyTagged(), c::IsLoadParentFramePointer(), + c::IsWordShl(reg_operand, c::IsIntPtrConstant(kPointerSizeLog2)), + LoadSensitivity::kNeedsPoisoning); } TARGET_TEST_F(InterpreterAssemblerTest, Jump) { @@ -368,38 +353,46 @@ TARGET_TEST_F(InterpreterAssemblerTest, BytecodeOperand) { switch (interpreter::Bytecodes::GetOperandType(bytecode, i)) { case interpreter::OperandType::kRegCount: EXPECT_THAT(m.BytecodeOperandCount(i), - m.IsUnsignedOperand(offset, operand_size)); + m.IsUnsignedOperand(offset, operand_size, + LoadSensitivity::kNeedsPoisoning)); break; case interpreter::OperandType::kFlag8: EXPECT_THAT(m.BytecodeOperandFlag(i), - m.IsUnsignedOperand(offset, operand_size)); + m.IsUnsignedOperand(offset, operand_size, + LoadSensitivity::kNeedsPoisoning)); break; case interpreter::OperandType::kIdx: - EXPECT_THAT(m.BytecodeOperandIdx(i), - c::IsChangeUint32ToWord( - m.IsUnsignedOperand(offset, operand_size))); + EXPECT_THAT( + m.BytecodeOperandIdx(i), + c::IsChangeUint32ToWord(m.IsUnsignedOperand( + offset, operand_size, LoadSensitivity::kNeedsPoisoning))); break; case interpreter::OperandType::kNativeContextIndex: - EXPECT_THAT(m.BytecodeOperandNativeContextIndex(i), - c::IsChangeUint32ToWord( - m.IsUnsignedOperand(offset, operand_size))); + EXPECT_THAT( + m.BytecodeOperandNativeContextIndex(i), + c::IsChangeUint32ToWord(m.IsUnsignedOperand( + offset, operand_size, LoadSensitivity::kNeedsPoisoning))); break; case interpreter::OperandType::kUImm: EXPECT_THAT(m.BytecodeOperandUImm(i), - m.IsUnsignedOperand(offset, operand_size)); + m.IsUnsignedOperand(offset, operand_size, + LoadSensitivity::kNeedsPoisoning)); break; case interpreter::OperandType::kImm: { EXPECT_THAT(m.BytecodeOperandImm(i), - m.IsSignedOperand(offset, operand_size)); + m.IsSignedOperand(offset, operand_size, + LoadSensitivity::kNeedsPoisoning)); break; } case interpreter::OperandType::kRuntimeId: EXPECT_THAT(m.BytecodeOperandRuntimeId(i), - m.IsUnsignedOperand(offset, operand_size)); + m.IsUnsignedOperand(offset, operand_size, + LoadSensitivity::kNeedsPoisoning)); break; case interpreter::OperandType::kIntrinsicId: EXPECT_THAT(m.BytecodeOperandIntrinsicId(i), - m.IsUnsignedOperand(offset, operand_size)); + m.IsUnsignedOperand(offset, operand_size, + LoadSensitivity::kNeedsPoisoning)); break; case interpreter::OperandType::kRegList: case interpreter::OperandType::kReg: @@ -444,11 +437,12 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) { c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), c::IsIntPtrConstant(BytecodeArray::kConstantPoolOffset - kHeapObjectTag)); - EXPECT_THAT(load_constant, - m.IsPoisonTagged(m.IsLoad( - MachineType::AnyTagged(), constant_pool_matcher, - c::IsIntPtrConstant(FixedArray::OffsetOfElementAt(2) - - kHeapObjectTag)))); + EXPECT_THAT( + load_constant, + m.IsLoad(MachineType::AnyTagged(), constant_pool_matcher, + c::IsIntPtrConstant(FixedArray::OffsetOfElementAt(2) - + kHeapObjectTag), + LoadSensitivity::kNeedsPoisoning)); } { Node* index = m.Parameter(2); @@ -460,12 +454,12 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) { kHeapObjectTag)); EXPECT_THAT( load_constant, - m.IsPoisonTagged(m.IsLoad( + m.IsLoad( MachineType::AnyTagged(), constant_pool_matcher, c::IsIntPtrAdd( c::IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), - c::IsWordShl(index, - c::IsIntPtrConstant(kPointerSizeLog2)))))); + c::IsWordShl(index, c::IsIntPtrConstant(kPointerSizeLog2))), + LoadSensitivity::kNeedsPoisoning)); } } } @@ -512,7 +506,8 @@ TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime) { Node* context = m.IntPtrConstant(4); Matcher<Node*> function_table = c::IsExternalConstant( - ExternalReference::runtime_function_table_address(isolate())); + ExternalReference::runtime_function_table_address_for_unittests( + isolate())); Matcher<Node*> function = c::IsIntPtrAdd( function_table, c::IsChangeUint32ToWord(c::IsInt32Mul( diff --git a/deps/v8/test/unittests/interpreter/interpreter-assembler-unittest.h b/deps/v8/test/unittests/interpreter/interpreter-assembler-unittest.h index 2e768be5c4..669db93040 100644 --- a/deps/v8/test/unittests/interpreter/interpreter-assembler-unittest.h +++ b/deps/v8/test/unittests/interpreter/interpreter-assembler-unittest.h @@ -42,7 +42,8 @@ class InterpreterAssemblerTest : public TestWithIsolateAndZone { Matcher<compiler::Node*> IsLoad( const Matcher<compiler::LoadRepresentation>& rep_matcher, const Matcher<compiler::Node*>& base_matcher, - const Matcher<compiler::Node*>& index_matcher); + const Matcher<compiler::Node*>& index_matcher, + LoadSensitivity needs_poisoning = LoadSensitivity::kSafe); Matcher<compiler::Node*> IsStore( const Matcher<compiler::StoreRepresentation>& rep_matcher, const Matcher<compiler::Node*>& base_matcher, @@ -51,29 +52,30 @@ class InterpreterAssemblerTest : public TestWithIsolateAndZone { Matcher<Node*> IsWordNot(const Matcher<Node*>& value_matcher); - Matcher<compiler::Node*> IsPoisonTagged( - const Matcher<compiler::Node*> value_matcher); - Matcher<compiler::Node*> IsPoisonInt32( - const Matcher<compiler::Node*> value_matcher); - Matcher<compiler::Node*> IsPoisonWord( - const Matcher<compiler::Node*> value_matcher); - - Matcher<compiler::Node*> IsUnsignedByteOperand(int offset); - Matcher<compiler::Node*> IsSignedByteOperand(int offset); - Matcher<compiler::Node*> IsUnsignedShortOperand(int offset); - Matcher<compiler::Node*> IsSignedShortOperand(int offset); - Matcher<compiler::Node*> IsUnsignedQuadOperand(int offset); - Matcher<compiler::Node*> IsSignedQuadOperand(int offset); + Matcher<compiler::Node*> IsUnsignedByteOperand( + int offset, LoadSensitivity needs_poisoning); + Matcher<compiler::Node*> IsSignedByteOperand( + int offset, LoadSensitivity needs_poisoning); + Matcher<compiler::Node*> IsUnsignedShortOperand( + int offset, LoadSensitivity needs_poisoning); + Matcher<compiler::Node*> IsSignedShortOperand( + int offset, LoadSensitivity needs_poisoning); + Matcher<compiler::Node*> IsUnsignedQuadOperand( + int offset, LoadSensitivity needs_poisoning); + Matcher<compiler::Node*> IsSignedQuadOperand( + int offset, LoadSensitivity needs_poisoning); Matcher<compiler::Node*> IsUnpoisonedSignedOperand( - int offset, OperandSize operand_size); + int offset, OperandSize operand_size, LoadSensitivity needs_poisoning); Matcher<compiler::Node*> IsUnpoisonedUnsignedOperand( - int offset, OperandSize operand_size); + int offset, OperandSize operand_size, LoadSensitivity needs_poisoning); Matcher<compiler::Node*> IsSignedOperand(int offset, - OperandSize operand_size); + OperandSize operand_size, + LoadSensitivity needs_poisoning); Matcher<compiler::Node*> IsUnsignedOperand(int offset, - OperandSize operand_size); + OperandSize operand_size, + LoadSensitivity needs_poisoning); Matcher<compiler::Node*> IsLoadRegisterOperand(int offset, OperandSize operand_size); diff --git a/deps/v8/test/unittests/libplatform/default-platform-unittest.cc b/deps/v8/test/unittests/libplatform/default-platform-unittest.cc index 17f1a34ba4..6417e56482 100644 --- a/deps/v8/test/unittests/libplatform/default-platform-unittest.cc +++ b/deps/v8/test/unittests/libplatform/default-platform-unittest.cc @@ -264,7 +264,7 @@ TEST(DefaultPlatformTest, RunBackgroundTask) { DefaultPlatform platform; platform.SetThreadPoolSize(1); std::shared_ptr<TaskRunner> taskrunner = - platform.GetBackgroundTaskRunner(isolate); + platform.GetWorkerThreadsTaskRunner(isolate); base::Semaphore sem(0); bool task_executed = false; @@ -282,7 +282,7 @@ TEST(DefaultPlatformTest, NoIdleTasksInBackground) { DefaultPlatform platform; platform.SetThreadPoolSize(1); std::shared_ptr<TaskRunner> taskrunner = - platform.GetBackgroundTaskRunner(isolate); + platform.GetWorkerThreadsTaskRunner(isolate); EXPECT_FALSE(taskrunner->IdleTasksEnabled()); } @@ -296,7 +296,7 @@ TEST(DefaultPlatformTest, PostTaskAfterPlatformTermination) { DefaultPlatformWithMockTime platform; platform.SetThreadPoolSize(1); foreground_taskrunner = platform.GetForegroundTaskRunner(isolate); - background_taskrunner = platform.GetBackgroundTaskRunner(isolate); + background_taskrunner = platform.GetWorkerThreadsTaskRunner(isolate); } // It should still be possible to post tasks, even when the platform does not // exist anymore. diff --git a/deps/v8/test/unittests/test-helpers.cc b/deps/v8/test/unittests/test-helpers.cc index 46600c662d..a40b0359ef 100644 --- a/deps/v8/test/unittests/test-helpers.cc +++ b/deps/v8/test/unittests/test-helpers.cc @@ -32,13 +32,16 @@ Handle<SharedFunctionInfo> CreateSharedFunctionInfo( HandleScope scope(isolate); Handle<String> source = CreateSource(isolate, maybe_resource); Handle<Script> script = isolate->factory()->NewScript(source); - Handle<FixedArray> infos = isolate->factory()->NewFixedArray(3); + Handle<WeakFixedArray> infos = isolate->factory()->NewWeakFixedArray(3); script->set_shared_function_infos(*infos); - Handle<SharedFunctionInfo> shared = isolate->factory()->NewSharedFunctionInfo( - isolate->factory()->NewStringFromAsciiChecked("f"), - BUILTIN_CODE(isolate, CompileLazy), false); - shared->set_end_position(source->length()); - shared->set_outer_scope_info(ScopeInfo::Empty(isolate)); + Handle<SharedFunctionInfo> shared = + isolate->factory()->NewSharedFunctionInfoForBuiltin( + isolate->factory()->NewStringFromAsciiChecked("f"), + Builtins::kCompileLazy); + shared->set_raw_end_position(source->length()); + // Make sure we have an outer scope info, even though it's empty + shared->set_raw_outer_scope_info_or_feedback_metadata( + ScopeInfo::Empty(isolate)); shared->set_function_literal_id(1); SharedFunctionInfo::SetScript(shared, script); return scope.CloseAndEscape(shared); diff --git a/deps/v8/test/unittests/unittests.isolate b/deps/v8/test/unittests/unittests.isolate deleted file mode 100644 index ec3bae42d3..0000000000 --- a/deps/v8/test/unittests/unittests.isolate +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 2015 the V8 project authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -{ - 'variables': { - 'files': [ - '<(PRODUCT_DIR)/unittests<(EXECUTABLE_SUFFIX)', - './testcfg.py', - './unittests.status', - ], - }, - 'includes': [ - '../../src/base.isolate', - '../../tools/testrunner/testrunner.isolate', - ], -} diff --git a/deps/v8/test/unittests/unittests.status b/deps/v8/test/unittests/unittests.status index 972d7e11f1..51f3462fe9 100644 --- a/deps/v8/test/unittests/unittests.status +++ b/deps/v8/test/unittests/unittests.status @@ -3,8 +3,14 @@ # found in the LICENSE file. [ -['system == windows', { - # BUG(7492). - 'ThreadTicks.ThreadNow': [SKIP], -}], # 'system == windows' +['system == macos and asan', { + # BUG(820416). + 'BitsDeathTest*': [SKIP], + 'LiveRangeUnitTest*': [SKIP], + 'LoggingDeathTest*': [SKIP], + 'LoggingTest.CompareClassTypes': [SKIP], + 'RandomNumberGenerator.NextSampleInvalidParam': [SKIP], + 'RandomNumberGenerator.NextSampleSlowInvalidParam1': [SKIP], + 'RandomNumberGenerator.NextSampleSlowInvalidParam2': [SKIP], +}], # 'system == macos and asan' ] diff --git a/deps/v8/test/unittests/value-serializer-unittest.cc b/deps/v8/test/unittests/value-serializer-unittest.cc index 3a997b62ec..92603b588a 100644 --- a/deps/v8/test/unittests/value-serializer-unittest.cc +++ b/deps/v8/test/unittests/value-serializer-unittest.cc @@ -81,7 +81,6 @@ class ValueSerializerTest : public TestWithIsolate { // Overridden in more specific fixtures. virtual ValueSerializer::Delegate* GetSerializerDelegate() { return nullptr; } virtual void BeforeEncode(ValueSerializer*) {} - virtual void AfterEncode() {} virtual ValueDeserializer::Delegate* GetDeserializerDelegate() { return nullptr; } @@ -118,7 +117,6 @@ class ValueSerializerTest : public TestWithIsolate { if (!serializer.WriteValue(context, value).FromMaybe(false)) { return Nothing<std::vector<uint8_t>>(); } - AfterEncode(); std::pair<uint8_t*, size_t> buffer = serializer.Release(); std::vector<uint8_t> result(buffer.first, buffer.first + buffer.second); free(buffer.first); @@ -387,6 +385,72 @@ TEST_F(ValueSerializerTest, DecodeNumber) { // TODO(jbroman): Equivalent test for big-endian machines. } +TEST_F(ValueSerializerTest, RoundTripBigInt) { + Local<Value> value = RoundTripTest(BigInt::New(isolate(), -42)); + ASSERT_TRUE(value->IsBigInt()); + ExpectScriptTrue("result === -42n"); + + value = RoundTripTest(BigInt::New(isolate(), 42)); + ExpectScriptTrue("result === 42n"); + + value = RoundTripTest(BigInt::New(isolate(), 0)); + ExpectScriptTrue("result === 0n"); + + value = RoundTripTest("0x1234567890abcdef777888999n"); + ExpectScriptTrue("result === 0x1234567890abcdef777888999n"); + + value = RoundTripTest("-0x1234567890abcdef777888999123n"); + ExpectScriptTrue("result === -0x1234567890abcdef777888999123n"); + + Context::Scope scope(serialization_context()); + value = RoundTripTest(BigIntObject::New(isolate(), 23)); + ASSERT_TRUE(value->IsBigIntObject()); + ExpectScriptTrue("result == 23n"); +} + +TEST_F(ValueSerializerTest, DecodeBigInt) { + Local<Value> value = DecodeTest({ + 0xFF, 0x0D, // Version 13 + 0x5A, // BigInt + 0x08, // Bitfield: sign = false, bytelength = 4 + 0x2A, 0x00, 0x00, 0x00, // Digit: 42 + }); + ASSERT_TRUE(value->IsBigInt()); + ExpectScriptTrue("result === 42n"); + + value = DecodeTest({ + 0xFF, 0x0D, // Version 13 + 0x7A, // BigIntObject + 0x11, // Bitfield: sign = true, bytelength = 8 + 0x2A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Digit: 42 + }); + ASSERT_TRUE(value->IsBigIntObject()); + ExpectScriptTrue("result == -42n"); + + value = DecodeTest({ + 0xFF, 0x0D, // Version 13 + 0x5A, // BigInt + 0x10, // Bitfield: sign = false, bytelength = 8 + 0xEF, 0xCD, 0xAB, 0x90, 0x78, 0x56, 0x34, 0x12 // Digit(s). + }); + ExpectScriptTrue("result === 0x1234567890abcdefn"); + + value = DecodeTest({0xFF, 0x0D, // Version 13 + 0x5A, // BigInt + 0x17, // Bitfield: sign = true, bytelength = 11 + 0xEF, 0xCD, 0xAB, 0x90, // Digits. + 0x78, 0x56, 0x34, 0x12, 0x33, 0x44, 0x55}); + ExpectScriptTrue("result === -0x5544331234567890abcdefn"); + + value = DecodeTest({ + 0xFF, 0x0D, // Version 13 + 0x5A, // BigInt + 0x02, // Bitfield: sign = false, bytelength = 1 + 0x2A, // Digit: 42 + }); + ExpectScriptTrue("result === 42n"); +} + // String constants (in UTF-8) used for string encoding tests. static const char kHelloString[] = "Hello"; static const char kQuebecString[] = "\x51\x75\xC3\xA9\x62\x65\x63"; @@ -1586,8 +1650,6 @@ class ValueSerializerTestWithArrayBufferTransfer : public ValueSerializerTest { serializer->TransferArrayBuffer(0, input_buffer_); } - void AfterEncode() override { input_buffer_->Neuter(); } - void BeforeDecode(ValueDeserializer* deserializer) override { deserializer->TransferArrayBuffer(0, output_buffer_); } diff --git a/deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc b/deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc index 3048ae51a3..147c42caac 100644 --- a/deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc +++ b/deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc @@ -36,7 +36,8 @@ static const byte kCodeGetLocal1[] = {kExprGetLocal, 1}; static const byte kCodeSetLocal0[] = {WASM_SET_LOCAL(0, WASM_ZERO)}; static const byte kCodeTeeLocal0[] = {WASM_TEE_LOCAL(0, WASM_ZERO)}; -static const ValueType kValueTypes[] = {kWasmI32, kWasmI64, kWasmF32, kWasmF64}; +static const ValueType kValueTypes[] = {kWasmI32, kWasmI64, kWasmF32, kWasmF64, + kWasmAnyRef}; static const MachineType machineTypes[] = { MachineType::Int8(), MachineType::Uint8(), MachineType::Int16(), MachineType::Uint16(), MachineType::Int32(), MachineType::Uint32(), @@ -220,7 +221,6 @@ class TestModuleBuilder { mod.functions.push_back({sig, // sig 0, // func_index 0, // sig_index - {0, 0}, // name {0, 0}, // code false, // import false}); // export @@ -261,6 +261,12 @@ TEST_F(FunctionBodyDecoderTest, Int32Const1) { } } +TEST_F(FunctionBodyDecoderTest, RefNull) { + FlagScope<bool> flag_scope(&FLAG_experimental_wasm_anyref, true); + byte code[] = {kExprRefNull}; + EXPECT_VERIFIES_C(r_v, code); +} + TEST_F(FunctionBodyDecoderTest, EmptyFunction) { byte code[] = {0}; Verify(true, sigs.v_v(), code, code, kAppendEnd); @@ -929,6 +935,7 @@ TEST_F(FunctionBodyDecoderTest, ReturnVoid3) { EXPECT_FAILURE(v_v, kExprI64Const, 0); EXPECT_FAILURE(v_v, kExprF32Const, 0, 0, 0, 0); EXPECT_FAILURE(v_v, kExprF64Const, 0, 0, 0, 0, 0, 0, 0, 0); + EXPECT_FAILURE(v_v, kExprRefNull); EXPECT_FAILURE(v_i, kExprGetLocal, 0); } @@ -1229,6 +1236,7 @@ TEST_F(FunctionBodyDecoderTest, MacrosInt64) { TEST_F(FunctionBodyDecoderTest, AllSimpleExpressions) { EXPERIMENTAL_FLAG_SCOPE(se); + EXPERIMENTAL_FLAG_SCOPE(anyref); // Test all simple expressions which are described by a signature. #define DECODE_TEST(name, opcode, sig) \ { \ @@ -2778,6 +2786,7 @@ TEST_F(WasmOpcodeLengthTest, Statements) { TEST_F(WasmOpcodeLengthTest, MiscExpressions) { EXPECT_LENGTH(5, kExprF32Const); EXPECT_LENGTH(9, kExprF64Const); + EXPECT_LENGTH(1, kExprRefNull); EXPECT_LENGTH(2, kExprGetLocal); EXPECT_LENGTH(2, kExprSetLocal); EXPECT_LENGTH(2, kExprGetGlobal); @@ -2965,6 +2974,7 @@ TEST_F(WasmOpcodeLengthTest, SimpleExpressions) { EXPECT_LENGTH(1, kExprF64ReinterpretI64); EXPECT_LENGTH(1, kExprI32ReinterpretF32); EXPECT_LENGTH(1, kExprI64ReinterpretF64); + EXPECT_LENGTH(1, kExprRefEq); } TEST_F(WasmOpcodeLengthTest, SimdExpressions) { @@ -3014,6 +3024,7 @@ TEST_F(LocalDeclDecoderTest, NoLocals) { } TEST_F(LocalDeclDecoderTest, OneLocal) { + EXPERIMENTAL_FLAG_SCOPE(anyref); for (size_t i = 0; i < arraysize(kValueTypes); i++) { ValueType type = kValueTypes[i]; const byte data[] = { @@ -3029,6 +3040,7 @@ TEST_F(LocalDeclDecoderTest, OneLocal) { } TEST_F(LocalDeclDecoderTest, FiveLocals) { + EXPERIMENTAL_FLAG_SCOPE(anyref); for (size_t i = 0; i < arraysize(kValueTypes); i++) { ValueType type = kValueTypes[i]; const byte data[] = { diff --git a/deps/v8/test/unittests/wasm/module-decoder-unittest.cc b/deps/v8/test/unittests/wasm/module-decoder-unittest.cc index a472623096..79ae8e578b 100644 --- a/deps/v8/test/unittests/wasm/module-decoder-unittest.cc +++ b/deps/v8/test/unittests/wasm/module-decoder-unittest.cc @@ -25,6 +25,7 @@ namespace module_decoder_unittest { #define WASM_INIT_EXPR_F32(val) WASM_F32(val), kExprEnd #define WASM_INIT_EXPR_I64(val) WASM_I64(val), kExprEnd #define WASM_INIT_EXPR_F64(val) WASM_F64(val), kExprEnd +#define WASM_INIT_EXPR_ANYREF WASM_REF_NULL, kExprEnd #define WASM_INIT_EXPR_GLOBAL(index) WASM_GET_GLOBAL(index), kExprEnd #define SIZEOF_EMPTY_FUNCTION ((size_t)5) @@ -137,7 +138,8 @@ struct ValueTypePair { } kValueTypes[] = {{kLocalI32, kWasmI32}, {kLocalI64, kWasmI64}, {kLocalF32, kWasmF32}, - {kLocalF64, kWasmF64}}; + {kLocalF64, kWasmF64}, + {kLocalAnyRef, kWasmAnyRef}}; class WasmModuleVerifyTest : public TestWithIsolateAndZone { public: @@ -211,6 +213,67 @@ TEST_F(WasmModuleVerifyTest, OneGlobal) { EXPECT_OFF_END_FAILURE(data, 1, sizeof(data)); } +TEST_F(WasmModuleVerifyTest, AnyRefGlobal) { + EXPERIMENTAL_FLAG_SCOPE(anyref); + static const byte data[] = { + SECTION(Global, 5), // -- + 1, + kLocalAnyRef, // local type + 0, // immutable + WASM_INIT_EXPR_ANYREF // init + }; + + { + // Should decode to exactly one global. + ModuleResult result = DecodeModule(data, data + sizeof(data)); + EXPECT_OK(result); + EXPECT_EQ(1u, result.val->globals.size()); + EXPECT_EQ(0u, result.val->functions.size()); + EXPECT_EQ(0u, result.val->data_segments.size()); + + const WasmGlobal* global = &result.val->globals.back(); + + EXPECT_EQ(kWasmAnyRef, global->type); + EXPECT_FALSE(global->mutability); + EXPECT_EQ(WasmInitExpr::kAnyRefConst, global->init.kind); + } +} + +TEST_F(WasmModuleVerifyTest, AnyRefGlobalWithGlobalInit) { + EXPERIMENTAL_FLAG_SCOPE(anyref); + static const byte data[] = { + SECTION(Import, 8), // section header + 1, // number of imports + NAME_LENGTH(1), // -- + 'm', // module name + NAME_LENGTH(1), // -- + 'f', // global name + kExternalGlobal, // import kind + kLocalAnyRef, // type + 0, // mutability + SECTION(Global, 6), // -- + 1, + kLocalAnyRef, // local type + 0, // immutable + WASM_INIT_EXPR_GLOBAL(0), + }; + + { + // Should decode to exactly one global. + ModuleResult result = DecodeModule(data, data + sizeof(data)); + EXPECT_OK(result); + EXPECT_EQ(2u, result.val->globals.size()); + EXPECT_EQ(0u, result.val->functions.size()); + EXPECT_EQ(0u, result.val->data_segments.size()); + + const WasmGlobal* global = &result.val->globals.back(); + + EXPECT_EQ(kWasmAnyRef, global->type); + EXPECT_FALSE(global->mutability); + EXPECT_EQ(WasmInitExpr::kGlobalIndex, global->init.kind); + } +} + TEST_F(WasmModuleVerifyTest, Global_invalid_type) { static const byte data[] = { SECTION(Global, 6), // -- @@ -894,7 +957,17 @@ TEST_F(WasmModuleVerifyTest, IndirectFunctionInvalidIndex) { EXPECT_FAILURE(data); } -class WasmSignatureDecodeTest : public TestWithZone {}; +class WasmSignatureDecodeTest : public TestWithZone { + public: + WasmSignatureDecodeTest() + // In the following tests we turn on support for AnyRef by default. There + // is a test (Fail_anyref_without_flag) which explicitly turns off support + // for AnyRef. + : flag_scope(&FLAG_experimental_wasm_anyref, true) {} + + private: + FlagScope<bool> flag_scope; +}; TEST_F(WasmSignatureDecodeTest, Ok_v_v) { static const byte data[] = {SIG_ENTRY_v_v}; @@ -1010,6 +1083,19 @@ TEST_F(WasmSignatureDecodeTest, Fail_off_end) { } } +TEST_F(WasmSignatureDecodeTest, Fail_anyref_without_flag) { + // Disable AnyRef support and check that decoding fails. + FlagScope<bool> flag_scope(&FLAG_experimental_wasm_anyref, false); + byte kInvalidType = kLocalAnyRef; + for (size_t i = 0; i < SIZEOF_SIG_ENTRY_x_xx; i++) { + byte data[] = {SIG_ENTRY_x_xx(kLocalI32, kLocalI32, kLocalI32)}; + data[i] = kInvalidType; + FunctionSig* sig = + DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data)); + EXPECT_EQ(nullptr, sig); + } +} + TEST_F(WasmSignatureDecodeTest, Fail_invalid_type) { byte kInvalidType = 76; for (size_t i = 0; i < SIZEOF_SIG_ENTRY_x_xx; i++) { @@ -1075,7 +1161,6 @@ TEST_F(WasmFunctionVerifyTest, Ok_v_v_empty) { WasmFunction* function = result.val.get(); EXPECT_EQ(0u, function->sig->parameter_count()); EXPECT_EQ(0u, function->sig->return_count()); - EXPECT_EQ(0u, function->name.offset()); EXPECT_EQ(static_cast<uint32_t>(SIZEOF_SIG_ENTRY_v_v), function->code.offset()); EXPECT_EQ(sizeof(data), function->code.end_offset()); @@ -1673,6 +1758,13 @@ TEST_F(WasmModuleVerifyTest, InitExpr_f64) { EXPECT_INIT_EXPR(F64, f64, 77999.1, WASM_F64(77999.1)); } +TEST_F(WasmModuleVerifyTest, InitExpr_AnyRef) { + EXPERIMENTAL_FLAG_SCOPE(anyref); + static const byte data[] = {kExprRefNull, kExprEnd}; + WasmInitExpr expr = DecodeWasmInitExprForTesting(data, data + sizeof(data)); + EXPECT_EQ(WasmInitExpr::kAnyRefConst, expr.kind); +} + #undef EXPECT_INIT_EXPR #define EXPECT_INIT_EXPR_FAIL(...) \ @@ -1711,13 +1803,6 @@ class WasmModuleCustomSectionTest : public TestWithIsolateAndZone { public: void CheckSections(const byte* module_start, const byte* module_end, const CustomSectionOffset* expected, size_t num_expected) { - // Add the WASM magic and version number automatically. - size_t size = static_cast<size_t>(module_end - module_start); - byte header[] = {WASM_MODULE_HEADER}; - size_t total = sizeof(header) + size; - auto temp = new byte[total]; - memcpy(temp, header, sizeof(header)); - memcpy(temp + sizeof(header), module_start, size); std::vector<CustomSectionOffset> custom_sections = DecodeCustomSections(module_start, module_end); @@ -1796,6 +1881,7 @@ TEST_F(WasmModuleCustomSectionTest, TwoKnownTwoUnknownSections) { #undef WASM_INIT_EXPR_F32 #undef WASM_INIT_EXPR_I64 #undef WASM_INIT_EXPR_F64 +#undef WASM_INIT_EXPR_ANYREF #undef WASM_INIT_EXPR_GLOBAL #undef SIZEOF_EMPTY_FUNCTION #undef EMPTY_BODY diff --git a/deps/v8/test/unittests/wasm/trap-handler-unittest.cc b/deps/v8/test/unittests/wasm/trap-handler-unittest.cc index eb578647ad..1b4ddf5bb0 100644 --- a/deps/v8/test/unittests/wasm/trap-handler-unittest.cc +++ b/deps/v8/test/unittests/wasm/trap-handler-unittest.cc @@ -13,7 +13,7 @@ namespace { -#if V8_OS_POSIX +#if V8_TRAP_HANDLER_SUPPORTED void CrashOnPurpose() { *reinterpret_cast<volatile int*>(42); } @@ -52,7 +52,8 @@ sigjmp_buf SignalHandlerFallbackTest::continuation_; TEST_F(SignalHandlerFallbackTest, DoTest) { const int save_sigs = 1; if (!sigsetjmp(continuation_, save_sigs)) { - v8::V8::RegisterDefaultSignalHandler(); + constexpr bool use_default_signal_handler = true; + CHECK(v8::V8::EnableWebAssemblyTrapHandler(use_default_signal_handler)); CrashOnPurpose(); FAIL(); } else { diff --git a/deps/v8/test/unittests/wasm/wasm-code-manager-unittest.cc b/deps/v8/test/unittests/wasm/wasm-code-manager-unittest.cc index 75eeea013f..6292d32947 100644 --- a/deps/v8/test/unittests/wasm/wasm-code-manager-unittest.cc +++ b/deps/v8/test/unittests/wasm/wasm-code-manager-unittest.cc @@ -153,7 +153,7 @@ TEST_F(DisjointAllocationPoolTest, MergingSkipLargerSrcWithGap) { enum ModuleStyle : int { Fixed = 0, Growable = 1 }; -class WasmCodeManagerTest : public TestWithIsolate, +class WasmCodeManagerTest : public TestWithContext, public ::testing::WithParamInterface<ModuleStyle> { public: using NativeModulePtr = std::unique_ptr<NativeModule>; @@ -186,7 +186,9 @@ class WasmCodeManagerTest : public TestWithIsolate, std::unique_ptr<byte[]> exec_buff(new byte[size]); desc.buffer = exec_buff.get(); desc.instr_size = static_cast<int>(size); - return native_module->AddCode(desc, 0, index, 0, 0, {}, false); + Handle<ByteArray> source_pos = i_isolate()->factory()->empty_byte_array(); + return native_module->AddCode(desc, 0, index, 0, 0, {}, source_pos, + WasmCode::kOther); } size_t page() const { return AllocatePageSize(); } @@ -290,11 +292,11 @@ TEST_P(WasmCodeManagerTest, Lookup) { NativeModulePtr nm1 = AllocModule(&manager, 1 * page(), GetParam()); NativeModulePtr nm2 = AllocModule(&manager, 1 * page(), GetParam()); WasmCode* code1_0 = AddCode(nm1.get(), 0, kCodeAlignment); - CHECK_EQ(nm1.get(), code1_0->owner()); + CHECK_EQ(nm1.get(), code1_0->native_module()); WasmCode* code1_1 = AddCode(nm1.get(), 1, kCodeAlignment); WasmCode* code2_0 = AddCode(nm2.get(), 0, kCodeAlignment); WasmCode* code2_1 = AddCode(nm2.get(), 1, kCodeAlignment); - CHECK_EQ(nm2.get(), code2_1->owner()); + CHECK_EQ(nm2.get(), code2_1->native_module()); CHECK_EQ(0, code1_0->index()); CHECK_EQ(1, code1_1->index()); @@ -331,11 +333,11 @@ TEST_P(WasmCodeManagerTest, MultiManagerLookup) { NativeModulePtr nm2 = AllocModule(&manager2, 1 * page(), GetParam()); WasmCode* code1_0 = AddCode(nm1.get(), 0, kCodeAlignment); - CHECK_EQ(nm1.get(), code1_0->owner()); + CHECK_EQ(nm1.get(), code1_0->native_module()); WasmCode* code1_1 = AddCode(nm1.get(), 1, kCodeAlignment); WasmCode* code2_0 = AddCode(nm2.get(), 0, kCodeAlignment); WasmCode* code2_1 = AddCode(nm2.get(), 1, kCodeAlignment); - CHECK_EQ(nm2.get(), code2_1->owner()); + CHECK_EQ(nm2.get(), code2_1->native_module()); CHECK_EQ(0, code1_0->index()); CHECK_EQ(1, code1_1->index()); |