Commit ac0605a1 authored by Georg Neis's avatar Georg Neis Committed by V8 LUCI CQ

Disable left-trimming when optimizing compile jobs exist

... as these jobs may have references to the array backing store and
expect them to stay valid.


Bug: chromium:1211215
Change-Id: Ia48519e993306223afab8d11a94d6d8fc150a11d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2928502Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74901}
parent 2806aa41
...@@ -46,7 +46,6 @@ class OptimizingCompileDispatcher::CompileTask : public CancelableTask { ...@@ -46,7 +46,6 @@ class OptimizingCompileDispatcher::CompileTask : public CancelableTask {
worker_thread_runtime_call_stats_( worker_thread_runtime_call_stats_(
isolate->counters()->worker_thread_runtime_call_stats()), isolate->counters()->worker_thread_runtime_call_stats()),
dispatcher_(dispatcher) { dispatcher_(dispatcher) {
base::MutexGuard lock_guard(&dispatcher_->ref_count_mutex_);
++dispatcher_->ref_count_; ++dispatcher_->ref_count_;
} }
...@@ -98,12 +97,7 @@ class OptimizingCompileDispatcher::CompileTask : public CancelableTask { ...@@ -98,12 +97,7 @@ class OptimizingCompileDispatcher::CompileTask : public CancelableTask {
}; };
OptimizingCompileDispatcher::~OptimizingCompileDispatcher() { OptimizingCompileDispatcher::~OptimizingCompileDispatcher() {
#ifdef DEBUG DCHECK_EQ(0, ref_count_);
{
base::MutexGuard lock_guard(&ref_count_mutex_);
DCHECK_EQ(0, ref_count_);
}
#endif
DCHECK_EQ(0, input_queue_length_); DCHECK_EQ(0, input_queue_length_);
DeleteArray(input_queue_); DeleteArray(input_queue_);
} }
...@@ -219,6 +213,14 @@ void OptimizingCompileDispatcher::InstallOptimizedFunctions() { ...@@ -219,6 +213,14 @@ void OptimizingCompileDispatcher::InstallOptimizedFunctions() {
} }
} }
bool OptimizingCompileDispatcher::HasJobs() {
DCHECK_EQ(ThreadId::Current(), isolate_->thread_id());
// Note: This relies on {output_queue_} being mutated by a background thread
// only when {ref_count_} is not zero. Also, {ref_count_} is never incremented
// by a background thread.
return !(ref_count_ == 0 && output_queue_.empty());
}
void OptimizingCompileDispatcher::QueueForOptimization( void OptimizingCompileDispatcher::QueueForOptimization(
OptimizedCompilationJob* job) { OptimizedCompilationJob* job) {
DCHECK(IsQueueAvailable()); DCHECK(IsQueueAvailable());
......
...@@ -52,6 +52,9 @@ class V8_EXPORT_PRIVATE OptimizingCompileDispatcher { ...@@ -52,6 +52,9 @@ class V8_EXPORT_PRIVATE OptimizingCompileDispatcher {
static bool Enabled() { return FLAG_concurrent_recompilation; } static bool Enabled() { return FLAG_concurrent_recompilation; }
// This method must be called on the main thread.
bool HasJobs();
private: private:
class CompileTask; class CompileTask;
...@@ -88,7 +91,7 @@ class V8_EXPORT_PRIVATE OptimizingCompileDispatcher { ...@@ -88,7 +91,7 @@ class V8_EXPORT_PRIVATE OptimizingCompileDispatcher {
int blocked_jobs_; int blocked_jobs_;
int ref_count_; std::atomic<int> ref_count_;
base::Mutex ref_count_mutex_; base::Mutex ref_count_mutex_;
base::ConditionVariable ref_count_zero_; base::ConditionVariable ref_count_zero_;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "src/codegen/compilation-cache.h" #include "src/codegen/compilation-cache.h"
#include "src/common/assert-scope.h" #include "src/common/assert-scope.h"
#include "src/common/globals.h" #include "src/common/globals.h"
#include "src/compiler-dispatcher/optimizing-compile-dispatcher.h"
#include "src/debug/debug.h" #include "src/debug/debug.h"
#include "src/deoptimizer/deoptimizer.h" #include "src/deoptimizer/deoptimizer.h"
#include "src/execution/isolate-utils-inl.h" #include "src/execution/isolate-utils-inl.h"
...@@ -3163,6 +3164,9 @@ bool Heap::CanMoveObjectStart(HeapObject object) { ...@@ -3163,6 +3164,9 @@ bool Heap::CanMoveObjectStart(HeapObject object) {
if (IsLargeObject(object)) return false; if (IsLargeObject(object)) return false;
// Compilation jobs may have references to the object.
if (isolate()->optimizing_compile_dispatcher()->HasJobs()) return false;
// We can move the object start if the page was already swept. // We can move the object start if the page was already swept.
return Page::FromHeapObject(object)->SweepingDone(); return Page::FromHeapObject(object)->SweepingDone();
} }
......
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