Revert "[Compiler] Use IdentityMap to store jobs in CompilerDispatcher."
This reverts commit 087e95ba63
.
Reason for revert: <INSERT REASONING HERE>
Original change's description:
> [Compiler] Use IdentityMap to store jobs in CompilerDispatcher.
>
> Stores jobs in an IdentityMap keyed by their SharedFunctionInfo to enable
> fast checking of whether a job is enqueued.
>
> BUG=v8:5203
>
> Change-Id: I6c37972093515a27077f79594cad27e32e1a4e7c
> Reviewed-on: https://chromium-review.googlesource.com/444768
> Reviewed-by: Jochen Eisinger <jochen@chromium.org>
> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
> Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#43370}
TBR=rmcilroy@chromium.org,jochen@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=v8:5203
Change-Id: I5d1101bdae6939378dad595b26698fe2aaaad35e
Reviewed-on: https://chromium-review.googlesource.com/446357
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43372}
This commit is contained in:
parent
4a655cbe0c
commit
38262dde22
@ -221,7 +221,6 @@ CompilerDispatcher::CompilerDispatcher(Isolate* isolate, Platform* platform,
|
||||
trace_compiler_dispatcher_(FLAG_trace_compiler_dispatcher),
|
||||
tracer_(new CompilerDispatcherTracer(isolate_)),
|
||||
task_manager_(new CancelableTaskManager()),
|
||||
jobs_(isolate->heap()),
|
||||
memory_pressure_level_(MemoryPressureLevel::kNone),
|
||||
abort_(false),
|
||||
idle_task_scheduled_(false),
|
||||
@ -235,7 +234,7 @@ CompilerDispatcher::CompilerDispatcher(Isolate* isolate, Platform* platform,
|
||||
}
|
||||
|
||||
CompilerDispatcher::~CompilerDispatcher() {
|
||||
// To avoid crashing in unit tests due to unfinished jobs.
|
||||
// To avoid crashing in unit tests due to unfished jobs.
|
||||
AbortAll(BlockingBehavior::kBlock);
|
||||
task_manager_->CancelAndWait();
|
||||
}
|
||||
@ -278,7 +277,9 @@ bool CompilerDispatcher::Enqueue(Handle<SharedFunctionInfo> function) {
|
||||
|
||||
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob(
|
||||
isolate_, tracer_.get(), function, max_stack_size_));
|
||||
jobs_.Set(function, job.release());
|
||||
std::pair<int, int> key(Script::cast(function->script())->id(),
|
||||
function->function_literal_id());
|
||||
jobs_.insert(std::make_pair(key, std::move(job)));
|
||||
ScheduleIdleTaskIfNeeded();
|
||||
return true;
|
||||
}
|
||||
@ -294,9 +295,10 @@ bool CompilerDispatcher::EnqueueAndStep(Handle<SharedFunctionInfo> function) {
|
||||
function->ShortPrint();
|
||||
PrintF("\n");
|
||||
}
|
||||
CompilerDispatcherJob* job = *jobs_.Find(function);
|
||||
DoNextStepOnMainThread(isolate_, job, ExceptionHandling::kSwallow);
|
||||
ConsiderJobForBackgroundProcessing(job);
|
||||
JobMap::const_iterator job = GetJobFor(function);
|
||||
DoNextStepOnMainThread(isolate_, job->second.get(),
|
||||
ExceptionHandling::kSwallow);
|
||||
ConsiderJobForBackgroundProcessing(job->second.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -319,7 +321,9 @@ bool CompilerDispatcher::Enqueue(
|
||||
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob(
|
||||
isolate_, tracer_.get(), script, function, literal, parse_zone,
|
||||
parse_handles, compile_handles, max_stack_size_));
|
||||
jobs_.Set(function, job.release());
|
||||
std::pair<int, int> key(Script::cast(function->script())->id(),
|
||||
function->function_literal_id());
|
||||
jobs_.insert(std::make_pair(key, std::move(job)));
|
||||
ScheduleIdleTaskIfNeeded();
|
||||
return true;
|
||||
}
|
||||
@ -342,16 +346,18 @@ bool CompilerDispatcher::EnqueueAndStep(
|
||||
function->ShortPrint();
|
||||
PrintF("\n");
|
||||
}
|
||||
CompilerDispatcherJob* job = *jobs_.Find(function);
|
||||
DoNextStepOnMainThread(isolate_, job, ExceptionHandling::kSwallow);
|
||||
ConsiderJobForBackgroundProcessing(job);
|
||||
JobMap::const_iterator job = GetJobFor(function);
|
||||
DoNextStepOnMainThread(isolate_, job->second.get(),
|
||||
ExceptionHandling::kSwallow);
|
||||
ConsiderJobForBackgroundProcessing(job->second.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CompilerDispatcher::IsEnabled() const { return FLAG_compiler_dispatcher; }
|
||||
|
||||
bool CompilerDispatcher::IsEnqueued(Handle<SharedFunctionInfo> function) const {
|
||||
return jobs_.Find(function) != nullptr;
|
||||
if (jobs_.empty()) return false;
|
||||
return GetJobFor(function) != jobs_.end();
|
||||
}
|
||||
|
||||
void CompilerDispatcher::WaitForJobIfRunningOnBackground(
|
||||
@ -378,8 +384,8 @@ void CompilerDispatcher::WaitForJobIfRunningOnBackground(
|
||||
bool CompilerDispatcher::FinishNow(Handle<SharedFunctionInfo> function) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
|
||||
"V8.CompilerDispatcherFinishNow");
|
||||
CompilerDispatcherJob* job = jobs_.Delete(function);
|
||||
CHECK_NOT_NULL(job);
|
||||
JobMap::const_iterator job = GetJobFor(function);
|
||||
CHECK(job != jobs_.end());
|
||||
|
||||
if (trace_compiler_dispatcher_) {
|
||||
PrintF("CompilerDispatcher: finishing ");
|
||||
@ -387,11 +393,12 @@ bool CompilerDispatcher::FinishNow(Handle<SharedFunctionInfo> function) {
|
||||
PrintF(" now\n");
|
||||
}
|
||||
|
||||
WaitForJobIfRunningOnBackground(job);
|
||||
while (!IsFinished(job)) {
|
||||
DoNextStepOnMainThread(isolate_, job, ExceptionHandling::kThrow);
|
||||
WaitForJobIfRunningOnBackground(job->second.get());
|
||||
while (!IsFinished(job->second.get())) {
|
||||
DoNextStepOnMainThread(isolate_, job->second.get(),
|
||||
ExceptionHandling::kThrow);
|
||||
}
|
||||
bool result = job->status() != CompileJobStatus::kFailed;
|
||||
bool result = job->second->status() != CompileJobStatus::kFailed;
|
||||
|
||||
if (trace_compiler_dispatcher_) {
|
||||
PrintF("CompilerDispatcher: finished working on ");
|
||||
@ -400,8 +407,8 @@ bool CompilerDispatcher::FinishNow(Handle<SharedFunctionInfo> function) {
|
||||
tracer_->DumpStatistics();
|
||||
}
|
||||
|
||||
job->ResetOnMainThread();
|
||||
delete job;
|
||||
job->second->ResetOnMainThread();
|
||||
jobs_.erase(job);
|
||||
if (jobs_.empty()) {
|
||||
base::LockGuard<base::Mutex> lock(&mutex_);
|
||||
abort_ = false;
|
||||
@ -413,19 +420,16 @@ void CompilerDispatcher::AbortAll(BlockingBehavior blocking) {
|
||||
bool background_tasks_running =
|
||||
task_manager_->TryAbortAll() == CancelableTaskManager::kTaskRunning;
|
||||
if (!background_tasks_running || blocking == BlockingBehavior::kBlock) {
|
||||
JobsMap::IteratableScope job_iter_scope(&jobs_);
|
||||
for (auto it = job_iter_scope.begin(); it != job_iter_scope.end();) {
|
||||
CompilerDispatcherJob* job = **it;
|
||||
WaitForJobIfRunningOnBackground(job);
|
||||
for (auto& it : jobs_) {
|
||||
WaitForJobIfRunningOnBackground(it.second.get());
|
||||
if (trace_compiler_dispatcher_) {
|
||||
PrintF("CompilerDispatcher: aborted ");
|
||||
job->ShortPrint();
|
||||
it.second->ShortPrint();
|
||||
PrintF("\n");
|
||||
}
|
||||
job->ResetOnMainThread();
|
||||
delete job;
|
||||
it.DeleteAndIncrement();
|
||||
it.second->ResetOnMainThread();
|
||||
}
|
||||
jobs_.clear();
|
||||
{
|
||||
base::LockGuard<base::Mutex> lock(&mutex_);
|
||||
DCHECK(pending_background_jobs_.empty());
|
||||
@ -455,25 +459,23 @@ void CompilerDispatcher::AbortInactiveJobs() {
|
||||
// here with nothing left to do.
|
||||
if (!abort_) return;
|
||||
}
|
||||
JobsMap::IteratableScope job_iter_scope(&jobs_);
|
||||
for (auto it = job_iter_scope.begin(); it != job_iter_scope.end();) {
|
||||
CompilerDispatcherJob* job = **it;
|
||||
for (auto it = jobs_.begin(); it != jobs_.end();) {
|
||||
auto job = it;
|
||||
++it;
|
||||
{
|
||||
base::LockGuard<base::Mutex> lock(&mutex_);
|
||||
if (running_background_jobs_.find(job) !=
|
||||
if (running_background_jobs_.find(job->second.get()) !=
|
||||
running_background_jobs_.end()) {
|
||||
++it;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (trace_compiler_dispatcher_) {
|
||||
PrintF("CompilerDispatcher: aborted ");
|
||||
job->ShortPrint();
|
||||
job->second->ShortPrint();
|
||||
PrintF("\n");
|
||||
}
|
||||
job->ResetOnMainThread();
|
||||
delete job;
|
||||
it.DeleteAndIncrement();
|
||||
job->second->ResetOnMainThread();
|
||||
jobs_.erase(job);
|
||||
}
|
||||
if (jobs_.empty()) {
|
||||
base::LockGuard<base::Mutex> lock(&mutex_);
|
||||
@ -512,9 +514,16 @@ void CompilerDispatcher::MemoryPressureNotification(
|
||||
}
|
||||
}
|
||||
|
||||
void CompilerDispatcher::ScheduleIdleTaskIfNeeded() {
|
||||
if (jobs_.empty()) return;
|
||||
ScheduleIdleTaskFromAnyThread();
|
||||
CompilerDispatcher::JobMap::const_iterator CompilerDispatcher::GetJobFor(
|
||||
Handle<SharedFunctionInfo> shared) const {
|
||||
if (!shared->script()->IsScript()) return jobs_.end();
|
||||
std::pair<int, int> key(Script::cast(shared->script())->id(),
|
||||
shared->function_literal_id());
|
||||
auto range = jobs_.equal_range(key);
|
||||
for (auto job = range.first; job != range.second; ++job) {
|
||||
if (job->second->IsAssociatedWith(shared)) return job;
|
||||
}
|
||||
return jobs_.end();
|
||||
}
|
||||
|
||||
void CompilerDispatcher::ScheduleIdleTaskFromAnyThread() {
|
||||
@ -529,6 +538,11 @@ void CompilerDispatcher::ScheduleIdleTaskFromAnyThread() {
|
||||
v8_isolate, new IdleTask(isolate_, task_manager_.get(), this));
|
||||
}
|
||||
|
||||
void CompilerDispatcher::ScheduleIdleTaskIfNeeded() {
|
||||
if (jobs_.empty()) return;
|
||||
ScheduleIdleTaskFromAnyThread();
|
||||
}
|
||||
|
||||
void CompilerDispatcher::ScheduleAbortTask() {
|
||||
v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate_);
|
||||
platform_->CallOnForegroundThread(
|
||||
@ -628,7 +642,7 @@ void CompilerDispatcher::DoIdleWork(double deadline_in_seconds) {
|
||||
|
||||
// Number of jobs that are unlikely to make progress during any idle callback
|
||||
// due to their estimated duration.
|
||||
int too_long_jobs = 0;
|
||||
size_t too_long_jobs = 0;
|
||||
|
||||
// Iterate over all available jobs & remaining time. For each job, decide
|
||||
// whether to 1) skip it (if it would take too long), 2) erase it (if it's
|
||||
@ -641,57 +655,56 @@ void CompilerDispatcher::DoIdleWork(double deadline_in_seconds) {
|
||||
idle_time_in_seconds *
|
||||
static_cast<double>(base::Time::kMillisecondsPerSecond));
|
||||
}
|
||||
JobsMap::IteratableScope job_iter_scope(&jobs_);
|
||||
for (auto it = job_iter_scope.begin();
|
||||
it != job_iter_scope.end() && idle_time_in_seconds > 0.0;
|
||||
for (auto job = jobs_.begin();
|
||||
job != jobs_.end() && idle_time_in_seconds > 0.0;
|
||||
idle_time_in_seconds =
|
||||
deadline_in_seconds - platform_->MonotonicallyIncreasingTime()) {
|
||||
CompilerDispatcherJob* job = **it;
|
||||
// Don't work on jobs that are being worked on by background tasks.
|
||||
// Similarly, remove jobs we work on from the set of available background
|
||||
// jobs.
|
||||
std::unique_ptr<base::LockGuard<base::Mutex>> lock(
|
||||
new base::LockGuard<base::Mutex>(&mutex_));
|
||||
if (running_background_jobs_.find(job) != running_background_jobs_.end()) {
|
||||
++it;
|
||||
if (running_background_jobs_.find(job->second.get()) !=
|
||||
running_background_jobs_.end()) {
|
||||
++job;
|
||||
continue;
|
||||
}
|
||||
auto background_jobs_it = pending_background_jobs_.find(job);
|
||||
double estimate_in_ms = job->EstimateRuntimeOfNextStepInMs();
|
||||
auto it = pending_background_jobs_.find(job->second.get());
|
||||
double estimate_in_ms = job->second->EstimateRuntimeOfNextStepInMs();
|
||||
if (idle_time_in_seconds <
|
||||
(estimate_in_ms /
|
||||
static_cast<double>(base::Time::kMillisecondsPerSecond))) {
|
||||
// If there's not enough time left, try to estFdeimate whether we would
|
||||
// If there's not enough time left, try to estimate whether we would
|
||||
// have managed to finish the job in a large idle task to assess
|
||||
// whether we should ask for another idle callback.
|
||||
if (estimate_in_ms > kMaxIdleTimeToExpectInMs) ++too_long_jobs;
|
||||
if (background_jobs_it == pending_background_jobs_.end()) {
|
||||
if (it == pending_background_jobs_.end()) {
|
||||
lock.reset();
|
||||
ConsiderJobForBackgroundProcessing(job);
|
||||
ConsiderJobForBackgroundProcessing(job->second.get());
|
||||
}
|
||||
++it;
|
||||
continue;
|
||||
} else if (IsFinished(job)) {
|
||||
DCHECK(background_jobs_it == pending_background_jobs_.end());
|
||||
++job;
|
||||
} else if (IsFinished(job->second.get())) {
|
||||
DCHECK(it == pending_background_jobs_.end());
|
||||
if (trace_compiler_dispatcher_) {
|
||||
PrintF("CompilerDispatcher: finished working on ");
|
||||
job->ShortPrint();
|
||||
PrintF(": %s\n", job->status() == CompileJobStatus::kDone ? "success"
|
||||
: "failure");
|
||||
job->second->ShortPrint();
|
||||
PrintF(": %s\n", job->second->status() == CompileJobStatus::kDone
|
||||
? "success"
|
||||
: "failure");
|
||||
tracer_->DumpStatistics();
|
||||
}
|
||||
it.DeleteAndIncrement();
|
||||
job->ResetOnMainThread();
|
||||
delete job;
|
||||
job->second->ResetOnMainThread();
|
||||
job = jobs_.erase(job);
|
||||
continue;
|
||||
} else {
|
||||
// Do one step, and keep processing the job (as we don't advance the
|
||||
// iterator).
|
||||
if (background_jobs_it != pending_background_jobs_.end()) {
|
||||
pending_background_jobs_.erase(background_jobs_it);
|
||||
if (it != pending_background_jobs_.end()) {
|
||||
pending_background_jobs_.erase(it);
|
||||
}
|
||||
lock.reset();
|
||||
DoNextStepOnMainThread(isolate_, job, ExceptionHandling::kSwallow);
|
||||
DoNextStepOnMainThread(isolate_, job->second.get(),
|
||||
ExceptionHandling::kSwallow);
|
||||
}
|
||||
}
|
||||
if (jobs_.size() > too_long_jobs) ScheduleIdleTaskIfNeeded();
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "src/base/platform/mutex.h"
|
||||
#include "src/base/platform/semaphore.h"
|
||||
#include "src/globals.h"
|
||||
#include "src/identity-map.h"
|
||||
#include "testing/gtest/include/gtest/gtest_prod.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -129,6 +128,9 @@ class V8_EXPORT_PRIVATE CompilerDispatcher {
|
||||
FRIEND_TEST(CompilerDispatcherTest, AsyncAbortAllRunningBackgroundTask);
|
||||
FRIEND_TEST(CompilerDispatcherTest, FinishNowDuringAbortAll);
|
||||
|
||||
typedef std::multimap<std::pair<int, int>,
|
||||
std::unique_ptr<CompilerDispatcherJob>>
|
||||
JobMap;
|
||||
class AbortTask;
|
||||
class BackgroundTask;
|
||||
class IdleTask;
|
||||
@ -136,10 +138,11 @@ class V8_EXPORT_PRIVATE CompilerDispatcher {
|
||||
void WaitForJobIfRunningOnBackground(CompilerDispatcherJob* job);
|
||||
void AbortInactiveJobs();
|
||||
bool CanEnqueue(Handle<SharedFunctionInfo> function);
|
||||
JobMap::const_iterator GetJobFor(Handle<SharedFunctionInfo> shared) const;
|
||||
void ConsiderJobForBackgroundProcessing(CompilerDispatcherJob* job);
|
||||
void ScheduleMoreBackgroundTasksIfNeeded();
|
||||
void ScheduleIdleTaskIfNeeded();
|
||||
void ScheduleIdleTaskFromAnyThread();
|
||||
void ScheduleIdleTaskIfNeeded();
|
||||
void ScheduleAbortTask();
|
||||
void DoBackgroundWork();
|
||||
void DoIdleWork(double deadline_in_seconds);
|
||||
@ -155,10 +158,9 @@ class V8_EXPORT_PRIVATE CompilerDispatcher {
|
||||
|
||||
std::unique_ptr<CancelableTaskManager> task_manager_;
|
||||
|
||||
// Mapping from SharedFunctionInfo to job.
|
||||
typedef IdentityMap<CompilerDispatcherJob*, FreeStoreAllocationPolicy>
|
||||
JobsMap;
|
||||
JobsMap jobs_;
|
||||
// Mapping from (script id, function literal id) to job. We use a multimap,
|
||||
// as script id is not necessarily unique.
|
||||
JobMap jobs_;
|
||||
|
||||
base::AtomicValue<v8::MemoryPressureLevel> memory_pressure_level_;
|
||||
|
||||
|
@ -16,7 +16,7 @@ class Heap;
|
||||
|
||||
// Base class of identity maps contains shared code for all template
|
||||
// instantions.
|
||||
class V8_EXPORT_PRIVATE IdentityMapBase {
|
||||
class IdentityMapBase {
|
||||
public:
|
||||
bool empty() const { return size_ == 0; }
|
||||
int size() const { return size_; }
|
||||
@ -47,8 +47,8 @@ class V8_EXPORT_PRIVATE IdentityMapBase {
|
||||
void* DeleteIndex(int index);
|
||||
void Clear();
|
||||
|
||||
RawEntry EntryAtIndex(int index) const;
|
||||
int NextIndex(int index) const;
|
||||
V8_EXPORT_PRIVATE RawEntry EntryAtIndex(int index) const;
|
||||
V8_EXPORT_PRIVATE int NextIndex(int index) const;
|
||||
|
||||
void EnableIteration();
|
||||
void DisableIteration();
|
||||
|
@ -341,8 +341,8 @@ TEST_F(CompilerDispatcherTest, IdleTaskSmallIdleTime) {
|
||||
ASSERT_TRUE(platform.IdleTaskPending());
|
||||
|
||||
// The job should be scheduled for the main thread.
|
||||
ASSERT_EQ(dispatcher.jobs_.size(), 1);
|
||||
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() ==
|
||||
ASSERT_EQ(dispatcher.jobs_.size(), 1u);
|
||||
ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
|
||||
CompileJobStatus::kInitial);
|
||||
|
||||
// Only grant a little idle time and have time advance beyond it in one step.
|
||||
@ -354,8 +354,8 @@ TEST_F(CompilerDispatcherTest, IdleTaskSmallIdleTime) {
|
||||
|
||||
// The job should be still scheduled for the main thread, but ready for
|
||||
// parsing.
|
||||
ASSERT_EQ(dispatcher.jobs_.size(), 1);
|
||||
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() ==
|
||||
ASSERT_EQ(dispatcher.jobs_.size(), 1u);
|
||||
ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
|
||||
CompileJobStatus::kReadyToParse);
|
||||
|
||||
// Now grant a lot of idle time and freeze time.
|
||||
@ -406,15 +406,15 @@ TEST_F(CompilerDispatcherTest, CompileOnBackgroundThread) {
|
||||
ASSERT_TRUE(dispatcher.Enqueue(shared));
|
||||
ASSERT_TRUE(platform.IdleTaskPending());
|
||||
|
||||
ASSERT_EQ(dispatcher.jobs_.size(), 1);
|
||||
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() ==
|
||||
ASSERT_EQ(dispatcher.jobs_.size(), 1u);
|
||||
ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
|
||||
CompileJobStatus::kInitial);
|
||||
|
||||
// Make compiling super expensive, and advance job as much as possible on the
|
||||
// foreground thread.
|
||||
dispatcher.tracer_->RecordCompile(50000.0, 1);
|
||||
platform.RunIdleTask(10.0, 0.0);
|
||||
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() ==
|
||||
ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
|
||||
CompileJobStatus::kReadyToCompile);
|
||||
|
||||
ASSERT_TRUE(dispatcher.IsEnqueued(shared));
|
||||
@ -426,7 +426,7 @@ TEST_F(CompilerDispatcherTest, CompileOnBackgroundThread) {
|
||||
|
||||
ASSERT_TRUE(platform.IdleTaskPending());
|
||||
ASSERT_FALSE(platform.BackgroundTasksPending());
|
||||
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() ==
|
||||
ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
|
||||
CompileJobStatus::kCompiled);
|
||||
|
||||
// Now grant a lot of idle time and freeze time.
|
||||
@ -451,15 +451,15 @@ TEST_F(CompilerDispatcherTest, FinishNowWithBackgroundTask) {
|
||||
ASSERT_TRUE(dispatcher.Enqueue(shared));
|
||||
ASSERT_TRUE(platform.IdleTaskPending());
|
||||
|
||||
ASSERT_EQ(dispatcher.jobs_.size(), 1);
|
||||
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() ==
|
||||
ASSERT_EQ(dispatcher.jobs_.size(), 1u);
|
||||
ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
|
||||
CompileJobStatus::kInitial);
|
||||
|
||||
// Make compiling super expensive, and advance job as much as possible on the
|
||||
// foreground thread.
|
||||
dispatcher.tracer_->RecordCompile(50000.0, 1);
|
||||
platform.RunIdleTask(10.0, 0.0);
|
||||
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() ==
|
||||
ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
|
||||
CompileJobStatus::kReadyToCompile);
|
||||
|
||||
ASSERT_TRUE(dispatcher.IsEnqueued(shared));
|
||||
@ -550,15 +550,15 @@ TEST_F(CompilerDispatcherTest, AsyncAbortAllPendingBackgroundTask) {
|
||||
ASSERT_TRUE(dispatcher.Enqueue(shared));
|
||||
ASSERT_TRUE(platform.IdleTaskPending());
|
||||
|
||||
ASSERT_EQ(dispatcher.jobs_.size(), 1);
|
||||
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() ==
|
||||
ASSERT_EQ(dispatcher.jobs_.size(), 1u);
|
||||
ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
|
||||
CompileJobStatus::kInitial);
|
||||
|
||||
// Make compiling super expensive, and advance job as much as possible on the
|
||||
// foreground thread.
|
||||
dispatcher.tracer_->RecordCompile(50000.0, 1);
|
||||
platform.RunIdleTask(10.0, 0.0);
|
||||
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() ==
|
||||
ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
|
||||
CompileJobStatus::kReadyToCompile);
|
||||
|
||||
ASSERT_TRUE(dispatcher.IsEnqueued(shared));
|
||||
@ -600,15 +600,15 @@ TEST_F(CompilerDispatcherTest, AsyncAbortAllRunningBackgroundTask) {
|
||||
ASSERT_TRUE(dispatcher.Enqueue(shared1));
|
||||
ASSERT_TRUE(platform.IdleTaskPending());
|
||||
|
||||
ASSERT_EQ(dispatcher.jobs_.size(), 1);
|
||||
ASSERT_TRUE((*dispatcher.jobs_.Find(shared1))->status() ==
|
||||
ASSERT_EQ(dispatcher.jobs_.size(), 1u);
|
||||
ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
|
||||
CompileJobStatus::kInitial);
|
||||
|
||||
// Make compiling super expensive, and advance job as much as possible on the
|
||||
// foreground thread.
|
||||
dispatcher.tracer_->RecordCompile(50000.0, 1);
|
||||
platform.RunIdleTask(10.0, 0.0);
|
||||
ASSERT_TRUE((*dispatcher.jobs_.Find(shared1))->status() ==
|
||||
ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
|
||||
CompileJobStatus::kReadyToCompile);
|
||||
|
||||
ASSERT_TRUE(dispatcher.IsEnqueued(shared1));
|
||||
@ -678,15 +678,15 @@ TEST_F(CompilerDispatcherTest, FinishNowDuringAbortAll) {
|
||||
ASSERT_TRUE(dispatcher.Enqueue(shared));
|
||||
ASSERT_TRUE(platform.IdleTaskPending());
|
||||
|
||||
ASSERT_EQ(dispatcher.jobs_.size(), 1);
|
||||
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() ==
|
||||
ASSERT_EQ(dispatcher.jobs_.size(), 1u);
|
||||
ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
|
||||
CompileJobStatus::kInitial);
|
||||
|
||||
// Make compiling super expensive, and advance job as much as possible on the
|
||||
// foreground thread.
|
||||
dispatcher.tracer_->RecordCompile(50000.0, 1);
|
||||
platform.RunIdleTask(10.0, 0.0);
|
||||
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() ==
|
||||
ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
|
||||
CompileJobStatus::kReadyToCompile);
|
||||
|
||||
ASSERT_TRUE(dispatcher.IsEnqueued(shared));
|
||||
@ -830,7 +830,7 @@ TEST_F(CompilerDispatcherTest, EnqueueAndStep) {
|
||||
ASSERT_TRUE(dispatcher.EnqueueAndStep(shared));
|
||||
ASSERT_TRUE(dispatcher.IsEnqueued(shared));
|
||||
|
||||
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() ==
|
||||
ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
|
||||
CompileJobStatus::kReadyToParse);
|
||||
|
||||
ASSERT_TRUE(platform.IdleTaskPending());
|
||||
@ -859,7 +859,7 @@ TEST_F(CompilerDispatcherTest, EnqueueParsed) {
|
||||
parse_info.zone_shared(), handles, handles));
|
||||
ASSERT_TRUE(dispatcher.IsEnqueued(shared));
|
||||
|
||||
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() ==
|
||||
ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
|
||||
CompileJobStatus::kAnalyzed);
|
||||
|
||||
ASSERT_TRUE(platform.IdleTaskPending());
|
||||
@ -888,7 +888,7 @@ TEST_F(CompilerDispatcherTest, EnqueueAndStepParsed) {
|
||||
handles));
|
||||
ASSERT_TRUE(dispatcher.IsEnqueued(shared));
|
||||
|
||||
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() ==
|
||||
ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
|
||||
CompileJobStatus::kReadyToCompile);
|
||||
|
||||
ASSERT_TRUE(platform.IdleTaskPending());
|
||||
@ -1081,7 +1081,7 @@ TEST_F(CompilerDispatcherTest, EnqueueAndStepTwice) {
|
||||
handles));
|
||||
ASSERT_TRUE(dispatcher.IsEnqueued(shared));
|
||||
|
||||
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() ==
|
||||
ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
|
||||
CompileJobStatus::kReadyToCompile);
|
||||
|
||||
// EnqueueAndStep of the same function again (either already parsed or for
|
||||
@ -1090,10 +1090,10 @@ TEST_F(CompilerDispatcherTest, EnqueueAndStepTwice) {
|
||||
parse_info.zone_shared(), handles,
|
||||
handles));
|
||||
ASSERT_TRUE(dispatcher.IsEnqueued(shared));
|
||||
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() ==
|
||||
ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
|
||||
CompileJobStatus::kReadyToCompile);
|
||||
ASSERT_TRUE(dispatcher.EnqueueAndStep(shared));
|
||||
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() ==
|
||||
ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
|
||||
CompileJobStatus::kReadyToCompile);
|
||||
|
||||
ASSERT_TRUE(platform.IdleTaskPending());
|
||||
|
Loading…
Reference in New Issue
Block a user