Commit 38262dde authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

Revert "[Compiler] Use IdentityMap to store jobs in CompilerDispatcher."

This reverts commit 087e95ba.

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/446357Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43372}
parent 4a655cbe
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "src/base/platform/mutex.h" #include "src/base/platform/mutex.h"
#include "src/base/platform/semaphore.h" #include "src/base/platform/semaphore.h"
#include "src/globals.h" #include "src/globals.h"
#include "src/identity-map.h"
#include "testing/gtest/include/gtest/gtest_prod.h" #include "testing/gtest/include/gtest/gtest_prod.h"
namespace v8 { namespace v8 {
...@@ -129,6 +128,9 @@ class V8_EXPORT_PRIVATE CompilerDispatcher { ...@@ -129,6 +128,9 @@ class V8_EXPORT_PRIVATE CompilerDispatcher {
FRIEND_TEST(CompilerDispatcherTest, AsyncAbortAllRunningBackgroundTask); FRIEND_TEST(CompilerDispatcherTest, AsyncAbortAllRunningBackgroundTask);
FRIEND_TEST(CompilerDispatcherTest, FinishNowDuringAbortAll); FRIEND_TEST(CompilerDispatcherTest, FinishNowDuringAbortAll);
typedef std::multimap<std::pair<int, int>,
std::unique_ptr<CompilerDispatcherJob>>
JobMap;
class AbortTask; class AbortTask;
class BackgroundTask; class BackgroundTask;
class IdleTask; class IdleTask;
...@@ -136,10 +138,11 @@ class V8_EXPORT_PRIVATE CompilerDispatcher { ...@@ -136,10 +138,11 @@ class V8_EXPORT_PRIVATE CompilerDispatcher {
void WaitForJobIfRunningOnBackground(CompilerDispatcherJob* job); void WaitForJobIfRunningOnBackground(CompilerDispatcherJob* job);
void AbortInactiveJobs(); void AbortInactiveJobs();
bool CanEnqueue(Handle<SharedFunctionInfo> function); bool CanEnqueue(Handle<SharedFunctionInfo> function);
JobMap::const_iterator GetJobFor(Handle<SharedFunctionInfo> shared) const;
void ConsiderJobForBackgroundProcessing(CompilerDispatcherJob* job); void ConsiderJobForBackgroundProcessing(CompilerDispatcherJob* job);
void ScheduleMoreBackgroundTasksIfNeeded(); void ScheduleMoreBackgroundTasksIfNeeded();
void ScheduleIdleTaskIfNeeded();
void ScheduleIdleTaskFromAnyThread(); void ScheduleIdleTaskFromAnyThread();
void ScheduleIdleTaskIfNeeded();
void ScheduleAbortTask(); void ScheduleAbortTask();
void DoBackgroundWork(); void DoBackgroundWork();
void DoIdleWork(double deadline_in_seconds); void DoIdleWork(double deadline_in_seconds);
...@@ -155,10 +158,9 @@ class V8_EXPORT_PRIVATE CompilerDispatcher { ...@@ -155,10 +158,9 @@ class V8_EXPORT_PRIVATE CompilerDispatcher {
std::unique_ptr<CancelableTaskManager> task_manager_; std::unique_ptr<CancelableTaskManager> task_manager_;
// Mapping from SharedFunctionInfo to job. // Mapping from (script id, function literal id) to job. We use a multimap,
typedef IdentityMap<CompilerDispatcherJob*, FreeStoreAllocationPolicy> // as script id is not necessarily unique.
JobsMap; JobMap jobs_;
JobsMap jobs_;
base::AtomicValue<v8::MemoryPressureLevel> memory_pressure_level_; base::AtomicValue<v8::MemoryPressureLevel> memory_pressure_level_;
......
...@@ -16,7 +16,7 @@ class Heap; ...@@ -16,7 +16,7 @@ class Heap;
// Base class of identity maps contains shared code for all template // Base class of identity maps contains shared code for all template
// instantions. // instantions.
class V8_EXPORT_PRIVATE IdentityMapBase { class IdentityMapBase {
public: public:
bool empty() const { return size_ == 0; } bool empty() const { return size_ == 0; }
int size() const { return size_; } int size() const { return size_; }
...@@ -47,8 +47,8 @@ class V8_EXPORT_PRIVATE IdentityMapBase { ...@@ -47,8 +47,8 @@ class V8_EXPORT_PRIVATE IdentityMapBase {
void* DeleteIndex(int index); void* DeleteIndex(int index);
void Clear(); void Clear();
RawEntry EntryAtIndex(int index) const; V8_EXPORT_PRIVATE RawEntry EntryAtIndex(int index) const;
int NextIndex(int index) const; V8_EXPORT_PRIVATE int NextIndex(int index) const;
void EnableIteration(); void EnableIteration();
void DisableIteration(); void DisableIteration();
......
...@@ -341,8 +341,8 @@ TEST_F(CompilerDispatcherTest, IdleTaskSmallIdleTime) { ...@@ -341,8 +341,8 @@ TEST_F(CompilerDispatcherTest, IdleTaskSmallIdleTime) {
ASSERT_TRUE(platform.IdleTaskPending()); ASSERT_TRUE(platform.IdleTaskPending());
// The job should be scheduled for the main thread. // The job should be scheduled for the main thread.
ASSERT_EQ(dispatcher.jobs_.size(), 1); ASSERT_EQ(dispatcher.jobs_.size(), 1u);
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() == ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
CompileJobStatus::kInitial); CompileJobStatus::kInitial);
// Only grant a little idle time and have time advance beyond it in one step. // Only grant a little idle time and have time advance beyond it in one step.
...@@ -354,8 +354,8 @@ TEST_F(CompilerDispatcherTest, IdleTaskSmallIdleTime) { ...@@ -354,8 +354,8 @@ TEST_F(CompilerDispatcherTest, IdleTaskSmallIdleTime) {
// The job should be still scheduled for the main thread, but ready for // The job should be still scheduled for the main thread, but ready for
// parsing. // parsing.
ASSERT_EQ(dispatcher.jobs_.size(), 1); ASSERT_EQ(dispatcher.jobs_.size(), 1u);
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() == ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
CompileJobStatus::kReadyToParse); CompileJobStatus::kReadyToParse);
// Now grant a lot of idle time and freeze time. // Now grant a lot of idle time and freeze time.
...@@ -406,15 +406,15 @@ TEST_F(CompilerDispatcherTest, CompileOnBackgroundThread) { ...@@ -406,15 +406,15 @@ TEST_F(CompilerDispatcherTest, CompileOnBackgroundThread) {
ASSERT_TRUE(dispatcher.Enqueue(shared)); ASSERT_TRUE(dispatcher.Enqueue(shared));
ASSERT_TRUE(platform.IdleTaskPending()); ASSERT_TRUE(platform.IdleTaskPending());
ASSERT_EQ(dispatcher.jobs_.size(), 1); ASSERT_EQ(dispatcher.jobs_.size(), 1u);
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() == ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
CompileJobStatus::kInitial); CompileJobStatus::kInitial);
// Make compiling super expensive, and advance job as much as possible on the // Make compiling super expensive, and advance job as much as possible on the
// foreground thread. // foreground thread.
dispatcher.tracer_->RecordCompile(50000.0, 1); dispatcher.tracer_->RecordCompile(50000.0, 1);
platform.RunIdleTask(10.0, 0.0); platform.RunIdleTask(10.0, 0.0);
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() == ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
CompileJobStatus::kReadyToCompile); CompileJobStatus::kReadyToCompile);
ASSERT_TRUE(dispatcher.IsEnqueued(shared)); ASSERT_TRUE(dispatcher.IsEnqueued(shared));
...@@ -426,7 +426,7 @@ TEST_F(CompilerDispatcherTest, CompileOnBackgroundThread) { ...@@ -426,7 +426,7 @@ TEST_F(CompilerDispatcherTest, CompileOnBackgroundThread) {
ASSERT_TRUE(platform.IdleTaskPending()); ASSERT_TRUE(platform.IdleTaskPending());
ASSERT_FALSE(platform.BackgroundTasksPending()); ASSERT_FALSE(platform.BackgroundTasksPending());
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() == ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
CompileJobStatus::kCompiled); CompileJobStatus::kCompiled);
// Now grant a lot of idle time and freeze time. // Now grant a lot of idle time and freeze time.
...@@ -451,15 +451,15 @@ TEST_F(CompilerDispatcherTest, FinishNowWithBackgroundTask) { ...@@ -451,15 +451,15 @@ TEST_F(CompilerDispatcherTest, FinishNowWithBackgroundTask) {
ASSERT_TRUE(dispatcher.Enqueue(shared)); ASSERT_TRUE(dispatcher.Enqueue(shared));
ASSERT_TRUE(platform.IdleTaskPending()); ASSERT_TRUE(platform.IdleTaskPending());
ASSERT_EQ(dispatcher.jobs_.size(), 1); ASSERT_EQ(dispatcher.jobs_.size(), 1u);
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() == ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
CompileJobStatus::kInitial); CompileJobStatus::kInitial);
// Make compiling super expensive, and advance job as much as possible on the // Make compiling super expensive, and advance job as much as possible on the
// foreground thread. // foreground thread.
dispatcher.tracer_->RecordCompile(50000.0, 1); dispatcher.tracer_->RecordCompile(50000.0, 1);
platform.RunIdleTask(10.0, 0.0); platform.RunIdleTask(10.0, 0.0);
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() == ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
CompileJobStatus::kReadyToCompile); CompileJobStatus::kReadyToCompile);
ASSERT_TRUE(dispatcher.IsEnqueued(shared)); ASSERT_TRUE(dispatcher.IsEnqueued(shared));
...@@ -550,15 +550,15 @@ TEST_F(CompilerDispatcherTest, AsyncAbortAllPendingBackgroundTask) { ...@@ -550,15 +550,15 @@ TEST_F(CompilerDispatcherTest, AsyncAbortAllPendingBackgroundTask) {
ASSERT_TRUE(dispatcher.Enqueue(shared)); ASSERT_TRUE(dispatcher.Enqueue(shared));
ASSERT_TRUE(platform.IdleTaskPending()); ASSERT_TRUE(platform.IdleTaskPending());
ASSERT_EQ(dispatcher.jobs_.size(), 1); ASSERT_EQ(dispatcher.jobs_.size(), 1u);
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() == ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
CompileJobStatus::kInitial); CompileJobStatus::kInitial);
// Make compiling super expensive, and advance job as much as possible on the // Make compiling super expensive, and advance job as much as possible on the
// foreground thread. // foreground thread.
dispatcher.tracer_->RecordCompile(50000.0, 1); dispatcher.tracer_->RecordCompile(50000.0, 1);
platform.RunIdleTask(10.0, 0.0); platform.RunIdleTask(10.0, 0.0);
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() == ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
CompileJobStatus::kReadyToCompile); CompileJobStatus::kReadyToCompile);
ASSERT_TRUE(dispatcher.IsEnqueued(shared)); ASSERT_TRUE(dispatcher.IsEnqueued(shared));
...@@ -600,15 +600,15 @@ TEST_F(CompilerDispatcherTest, AsyncAbortAllRunningBackgroundTask) { ...@@ -600,15 +600,15 @@ TEST_F(CompilerDispatcherTest, AsyncAbortAllRunningBackgroundTask) {
ASSERT_TRUE(dispatcher.Enqueue(shared1)); ASSERT_TRUE(dispatcher.Enqueue(shared1));
ASSERT_TRUE(platform.IdleTaskPending()); ASSERT_TRUE(platform.IdleTaskPending());
ASSERT_EQ(dispatcher.jobs_.size(), 1); ASSERT_EQ(dispatcher.jobs_.size(), 1u);
ASSERT_TRUE((*dispatcher.jobs_.Find(shared1))->status() == ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
CompileJobStatus::kInitial); CompileJobStatus::kInitial);
// Make compiling super expensive, and advance job as much as possible on the // Make compiling super expensive, and advance job as much as possible on the
// foreground thread. // foreground thread.
dispatcher.tracer_->RecordCompile(50000.0, 1); dispatcher.tracer_->RecordCompile(50000.0, 1);
platform.RunIdleTask(10.0, 0.0); platform.RunIdleTask(10.0, 0.0);
ASSERT_TRUE((*dispatcher.jobs_.Find(shared1))->status() == ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
CompileJobStatus::kReadyToCompile); CompileJobStatus::kReadyToCompile);
ASSERT_TRUE(dispatcher.IsEnqueued(shared1)); ASSERT_TRUE(dispatcher.IsEnqueued(shared1));
...@@ -678,15 +678,15 @@ TEST_F(CompilerDispatcherTest, FinishNowDuringAbortAll) { ...@@ -678,15 +678,15 @@ TEST_F(CompilerDispatcherTest, FinishNowDuringAbortAll) {
ASSERT_TRUE(dispatcher.Enqueue(shared)); ASSERT_TRUE(dispatcher.Enqueue(shared));
ASSERT_TRUE(platform.IdleTaskPending()); ASSERT_TRUE(platform.IdleTaskPending());
ASSERT_EQ(dispatcher.jobs_.size(), 1); ASSERT_EQ(dispatcher.jobs_.size(), 1u);
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() == ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
CompileJobStatus::kInitial); CompileJobStatus::kInitial);
// Make compiling super expensive, and advance job as much as possible on the // Make compiling super expensive, and advance job as much as possible on the
// foreground thread. // foreground thread.
dispatcher.tracer_->RecordCompile(50000.0, 1); dispatcher.tracer_->RecordCompile(50000.0, 1);
platform.RunIdleTask(10.0, 0.0); platform.RunIdleTask(10.0, 0.0);
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() == ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
CompileJobStatus::kReadyToCompile); CompileJobStatus::kReadyToCompile);
ASSERT_TRUE(dispatcher.IsEnqueued(shared)); ASSERT_TRUE(dispatcher.IsEnqueued(shared));
...@@ -830,7 +830,7 @@ TEST_F(CompilerDispatcherTest, EnqueueAndStep) { ...@@ -830,7 +830,7 @@ TEST_F(CompilerDispatcherTest, EnqueueAndStep) {
ASSERT_TRUE(dispatcher.EnqueueAndStep(shared)); ASSERT_TRUE(dispatcher.EnqueueAndStep(shared));
ASSERT_TRUE(dispatcher.IsEnqueued(shared)); ASSERT_TRUE(dispatcher.IsEnqueued(shared));
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() == ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
CompileJobStatus::kReadyToParse); CompileJobStatus::kReadyToParse);
ASSERT_TRUE(platform.IdleTaskPending()); ASSERT_TRUE(platform.IdleTaskPending());
...@@ -859,7 +859,7 @@ TEST_F(CompilerDispatcherTest, EnqueueParsed) { ...@@ -859,7 +859,7 @@ TEST_F(CompilerDispatcherTest, EnqueueParsed) {
parse_info.zone_shared(), handles, handles)); parse_info.zone_shared(), handles, handles));
ASSERT_TRUE(dispatcher.IsEnqueued(shared)); ASSERT_TRUE(dispatcher.IsEnqueued(shared));
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() == ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
CompileJobStatus::kAnalyzed); CompileJobStatus::kAnalyzed);
ASSERT_TRUE(platform.IdleTaskPending()); ASSERT_TRUE(platform.IdleTaskPending());
...@@ -888,7 +888,7 @@ TEST_F(CompilerDispatcherTest, EnqueueAndStepParsed) { ...@@ -888,7 +888,7 @@ TEST_F(CompilerDispatcherTest, EnqueueAndStepParsed) {
handles)); handles));
ASSERT_TRUE(dispatcher.IsEnqueued(shared)); ASSERT_TRUE(dispatcher.IsEnqueued(shared));
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() == ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
CompileJobStatus::kReadyToCompile); CompileJobStatus::kReadyToCompile);
ASSERT_TRUE(platform.IdleTaskPending()); ASSERT_TRUE(platform.IdleTaskPending());
...@@ -1081,7 +1081,7 @@ TEST_F(CompilerDispatcherTest, EnqueueAndStepTwice) { ...@@ -1081,7 +1081,7 @@ TEST_F(CompilerDispatcherTest, EnqueueAndStepTwice) {
handles)); handles));
ASSERT_TRUE(dispatcher.IsEnqueued(shared)); ASSERT_TRUE(dispatcher.IsEnqueued(shared));
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() == ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
CompileJobStatus::kReadyToCompile); CompileJobStatus::kReadyToCompile);
// EnqueueAndStep of the same function again (either already parsed or for // EnqueueAndStep of the same function again (either already parsed or for
...@@ -1090,10 +1090,10 @@ TEST_F(CompilerDispatcherTest, EnqueueAndStepTwice) { ...@@ -1090,10 +1090,10 @@ TEST_F(CompilerDispatcherTest, EnqueueAndStepTwice) {
parse_info.zone_shared(), handles, parse_info.zone_shared(), handles,
handles)); handles));
ASSERT_TRUE(dispatcher.IsEnqueued(shared)); ASSERT_TRUE(dispatcher.IsEnqueued(shared));
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() == ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
CompileJobStatus::kReadyToCompile); CompileJobStatus::kReadyToCompile);
ASSERT_TRUE(dispatcher.EnqueueAndStep(shared)); ASSERT_TRUE(dispatcher.EnqueueAndStep(shared));
ASSERT_TRUE((*dispatcher.jobs_.Find(shared))->status() == ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
CompileJobStatus::kReadyToCompile); CompileJobStatus::kReadyToCompile);
ASSERT_TRUE(platform.IdleTaskPending()); ASSERT_TRUE(platform.IdleTaskPending());
......
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