[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: Jakob Linke <jgruber@chromium.org> Auto-Submit: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/main@{#82899}
This commit is contained in:
parent
29cf41780a
commit
762d6ea802
@ -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 internal
|
||||
} // namespace v8
|
||||
|
@ -87,6 +87,8 @@ class MaglevConcurrentDispatcher final {
|
||||
// Called from the main thread.
|
||||
void FinalizeFinishedJobs();
|
||||
|
||||
void AwaitCompileJobs();
|
||||
|
||||
bool is_enabled() const { return static_cast<bool>(job_handle_); }
|
||||
|
||||
private:
|
||||
|
@ -23,6 +23,9 @@
|
||||
#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop.
|
||||
#include "src/heap/heap-write-barrier-inl.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-function-inl.h"
|
||||
#include "src/objects/js-regexp-inl.h"
|
||||
@ -594,6 +597,13 @@ void FinalizeOptimization(Isolate* isolate) {
|
||||
isolate->optimizing_compile_dispatcher()->AwaitCompileTasks();
|
||||
isolate->optimizing_compile_dispatcher()->InstallOptimizedFunctions();
|
||||
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) {
|
||||
@ -879,6 +889,11 @@ RUNTIME_FUNCTION(Runtime_WaitForBackgroundOptimization) {
|
||||
DCHECK_EQ(0, args.length());
|
||||
if (isolate->concurrent_recompilation_enabled()) {
|
||||
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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user