Commit 762d6ea8 authored by Leszek Swirski's avatar Leszek Swirski Committed by V8 LUCI CQ

[maglev] Allow waiting for compile jobs to finish

Add a mechanism similar to the optimizing compile dispatcher, for tests
to be able to wait for Maglev compilation to finish, and to force
finalization.

Bug: v8:7700
Change-Id: I0ef542001fe9f6622b1231eb9406130ad81c8f6e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3865551
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarJakob Linke <jgruber@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82899}
parent 29cf4178
...@@ -192,6 +192,15 @@ void MaglevConcurrentDispatcher::FinalizeFinishedJobs() { ...@@ -192,6 +192,15 @@ void MaglevConcurrentDispatcher::FinalizeFinishedJobs() {
} }
} }
void MaglevConcurrentDispatcher::AwaitCompileJobs() {
// Use Join to wait until there are no more queued or running jobs.
job_handle_->Join();
// Join kills the job handle, so drop it and post a new one.
job_handle_ = V8::GetCurrentPlatform()->PostJob(
TaskPriority::kUserVisible, std::make_unique<JobTask>(this));
DCHECK(incoming_queue_.IsEmpty());
}
} // namespace maglev } // namespace maglev
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -87,6 +87,8 @@ class MaglevConcurrentDispatcher final { ...@@ -87,6 +87,8 @@ class MaglevConcurrentDispatcher final {
// Called from the main thread. // Called from the main thread.
void FinalizeFinishedJobs(); void FinalizeFinishedJobs();
void AwaitCompileJobs();
bool is_enabled() const { return static_cast<bool>(job_handle_); } bool is_enabled() const { return static_cast<bool>(job_handle_); }
private: private:
......
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. #include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop.
#include "src/heap/heap-write-barrier-inl.h" #include "src/heap/heap-write-barrier-inl.h"
#include "src/ic/stub-cache.h" #include "src/ic/stub-cache.h"
#ifdef V8_ENABLE_MAGLEV
#include "src/maglev/maglev-concurrent-dispatcher.h"
#endif // V8_ENABLE_MAGLEV
#include "src/objects/js-atomics-synchronization-inl.h" #include "src/objects/js-atomics-synchronization-inl.h"
#include "src/objects/js-function-inl.h" #include "src/objects/js-function-inl.h"
#include "src/objects/js-regexp-inl.h" #include "src/objects/js-regexp-inl.h"
...@@ -594,6 +597,13 @@ void FinalizeOptimization(Isolate* isolate) { ...@@ -594,6 +597,13 @@ void FinalizeOptimization(Isolate* isolate) {
isolate->optimizing_compile_dispatcher()->AwaitCompileTasks(); isolate->optimizing_compile_dispatcher()->AwaitCompileTasks();
isolate->optimizing_compile_dispatcher()->InstallOptimizedFunctions(); isolate->optimizing_compile_dispatcher()->InstallOptimizedFunctions();
isolate->optimizing_compile_dispatcher()->set_finalize(true); isolate->optimizing_compile_dispatcher()->set_finalize(true);
#if V8_ENABLE_MAGLEV
if (isolate->maglev_concurrent_dispatcher()->is_enabled()) {
isolate->maglev_concurrent_dispatcher()->AwaitCompileJobs();
isolate->maglev_concurrent_dispatcher()->FinalizeFinishedJobs();
}
#endif // V8_ENABLE_MAGLEV
} }
BytecodeOffset OffsetOfNextJumpLoop(Isolate* isolate, UnoptimizedFrame* frame) { BytecodeOffset OffsetOfNextJumpLoop(Isolate* isolate, UnoptimizedFrame* frame) {
...@@ -879,6 +889,11 @@ RUNTIME_FUNCTION(Runtime_WaitForBackgroundOptimization) { ...@@ -879,6 +889,11 @@ RUNTIME_FUNCTION(Runtime_WaitForBackgroundOptimization) {
DCHECK_EQ(0, args.length()); DCHECK_EQ(0, args.length());
if (isolate->concurrent_recompilation_enabled()) { if (isolate->concurrent_recompilation_enabled()) {
isolate->optimizing_compile_dispatcher()->AwaitCompileTasks(); isolate->optimizing_compile_dispatcher()->AwaitCompileTasks();
#if V8_ENABLE_MAGLEV
if (isolate->maglev_concurrent_dispatcher()->is_enabled()) {
isolate->maglev_concurrent_dispatcher()->AwaitCompileJobs();
}
#endif // V8_ENABLE_MAGLEV
} }
return ReadOnlyRoots(isolate).undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment