Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Unified Diff: src/compiler/instruction-scheduler.cc

Issue 2281523002: [turbofan] Instruction scheduler: keep ready nodes list sorted by latency. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/instruction-scheduler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/instruction-scheduler.cc
diff --git a/src/compiler/instruction-scheduler.cc b/src/compiler/instruction-scheduler.cc
index 6a1d8497411d6b3dcecc649732f58afcb9c495f4..d5bd1255767ff9351924e08ccf1c4566a172284a 100644
--- a/src/compiler/instruction-scheduler.cc
+++ b/src/compiler/instruction-scheduler.cc
@@ -11,11 +11,16 @@ namespace v8 {
namespace internal {
namespace compiler {
-// Compare the two nodes and return true if node1 is a better candidate than
-// node2 (i.e. node1 should be scheduled before node2).
-bool InstructionScheduler::CriticalPathFirstQueue::CompareNodes(
- ScheduleGraphNode *node1, ScheduleGraphNode *node2) const {
- return node1->total_latency() > node2->total_latency();
+void InstructionScheduler::SchedulingQueueBase::AddNode(
+ ScheduleGraphNode* node) {
+ // We keep the ready list sorted by total latency so that we can quickly find
+ // the next best candidate to schedule.
+ auto it = nodes_.begin();
+ while ((it != nodes_.end()) &&
+ ((*it)->total_latency() > node->total_latency())) {
+ ++it;
+ }
+ nodes_.insert(it, node);
}
@@ -24,12 +29,10 @@ InstructionScheduler::CriticalPathFirstQueue::PopBestCandidate(int cycle) {
DCHECK(!IsEmpty());
auto candidate = nodes_.end();
for (auto iterator = nodes_.begin(); iterator != nodes_.end(); ++iterator) {
- // We only consider instructions that have all their operands ready and
- // we try to schedule the critical path first.
+ // We only consider instructions that have all their operands ready.
if (cycle >= (*iterator)->start_cycle()) {
- if ((candidate == nodes_.end()) || CompareNodes(*iterator, *candidate)) {
- candidate = iterator;
- }
+ candidate = iterator;
+ break;
}
}
« no previous file with comments | « src/compiler/instruction-scheduler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698