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

Side by Side Diff: src/compiler/register-allocator.cc

Issue 1386253004: [turbofan] More efficient splintering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « src/compiler/register-allocator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/base/adapters.h" 5 #include "src/base/adapters.h"
6 #include "src/compiler/linkage.h" 6 #include "src/compiler/linkage.h"
7 #include "src/compiler/register-allocator.h" 7 #include "src/compiler/register-allocator.h"
8 #include "src/string-stream.h" 8 #include "src/string-stream.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 : relative_id_(relative_id), 259 : relative_id_(relative_id),
260 bits_(0), 260 bits_(0),
261 last_interval_(nullptr), 261 last_interval_(nullptr),
262 first_interval_(nullptr), 262 first_interval_(nullptr),
263 first_pos_(nullptr), 263 first_pos_(nullptr),
264 top_level_(top_level), 264 top_level_(top_level),
265 next_(nullptr), 265 next_(nullptr),
266 current_interval_(nullptr), 266 current_interval_(nullptr),
267 last_processed_use_(nullptr), 267 last_processed_use_(nullptr),
268 current_hint_position_(nullptr), 268 current_hint_position_(nullptr),
269 splitting_pointer_(nullptr),
269 size_(kInvalidSize), 270 size_(kInvalidSize),
270 weight_(kInvalidWeight), 271 weight_(kInvalidWeight),
271 group_(nullptr) { 272 group_(nullptr) {
272 DCHECK(AllocatedOperand::IsSupportedMachineType(machine_type)); 273 DCHECK(AllocatedOperand::IsSupportedMachineType(machine_type));
273 bits_ = AssignedRegisterField::encode(kUnassignedRegister) | 274 bits_ = AssignedRegisterField::encode(kUnassignedRegister) |
274 MachineTypeField::encode(machine_type); 275 MachineTypeField::encode(machine_type);
275 } 276 }
276 277
277 278
278 void LiveRange::Verify() const { 279 void LiveRange::Verify() const {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 child->top_level_ = TopLevel(); 449 child->top_level_ = TopLevel();
449 child->next_ = next_; 450 child->next_ = next_;
450 next_ = child; 451 next_ = child;
451 if (child->next() == nullptr) { 452 if (child->next() == nullptr) {
452 TopLevel()->set_last_child(child); 453 TopLevel()->set_last_child(child);
453 } 454 }
454 return child; 455 return child;
455 } 456 }
456 457
457 458
458 void LiveRange::DetachAt(LifetimePosition position, LiveRange* result, 459 UsePosition* LiveRange::DetachAt(LifetimePosition position, LiveRange* result,
459 Zone* zone) { 460 Zone* zone) {
460 DCHECK(Start() < position); 461 DCHECK(Start() < position);
461 DCHECK(End() > position); 462 DCHECK(End() > position);
462 DCHECK(result->IsEmpty()); 463 DCHECK(result->IsEmpty());
463 // Find the last interval that ends before the position. If the 464 // Find the last interval that ends before the position. If the
464 // position is contained in one of the intervals in the chain, we 465 // position is contained in one of the intervals in the chain, we
465 // split that interval and use the first part. 466 // split that interval and use the first part.
466 auto current = FirstSearchIntervalForPosition(position); 467 auto current = FirstSearchIntervalForPosition(position);
467 468
468 // If the split position coincides with the beginning of a use interval 469 // If the split position coincides with the beginning of a use interval
469 // we need to split use positons in a special way. 470 // we need to split use positons in a special way.
(...skipping 25 matching lines...) Expand all
495 auto before = current; 496 auto before = current;
496 result->last_interval_ = 497 result->last_interval_ =
497 (last_interval_ == before) 498 (last_interval_ == before)
498 ? after // Only interval in the range after split. 499 ? after // Only interval in the range after split.
499 : last_interval_; // Last interval of the original range. 500 : last_interval_; // Last interval of the original range.
500 result->first_interval_ = after; 501 result->first_interval_ = after;
501 last_interval_ = before; 502 last_interval_ = before;
502 503
503 // Find the last use position before the split and the first use 504 // Find the last use position before the split and the first use
504 // position after it. 505 // position after it.
505 auto use_after = first_pos_; 506 auto use_after =
507 splitting_pointer_ == nullptr || splitting_pointer_->pos() > position
508 ? first_pos()
509 : splitting_pointer_;
506 UsePosition* use_before = nullptr; 510 UsePosition* use_before = nullptr;
507 if (split_at_start) { 511 if (split_at_start) {
508 // The split position coincides with the beginning of a use interval (the 512 // The split position coincides with the beginning of a use interval (the
509 // end of a lifetime hole). Use at this position should be attributed to 513 // end of a lifetime hole). Use at this position should be attributed to
510 // the split child because split child owns use interval covering it. 514 // the split child because split child owns use interval covering it.
511 while (use_after != nullptr && use_after->pos() < position) { 515 while (use_after != nullptr && use_after->pos() < position) {
512 use_before = use_after; 516 use_before = use_after;
513 use_after = use_after->next(); 517 use_after = use_after->next();
514 } 518 }
515 } else { 519 } else {
(...skipping 17 matching lines...) Expand all
533 current_interval_ = nullptr; 537 current_interval_ = nullptr;
534 538
535 // Invalidate size and weight of this range. The child range has them 539 // Invalidate size and weight of this range. The child range has them
536 // invalid at construction. 540 // invalid at construction.
537 size_ = kInvalidSize; 541 size_ = kInvalidSize;
538 weight_ = kInvalidWeight; 542 weight_ = kInvalidWeight;
539 #ifdef DEBUG 543 #ifdef DEBUG
540 Verify(); 544 Verify();
541 result->Verify(); 545 result->Verify();
542 #endif 546 #endif
547 return use_before;
543 } 548 }
544 549
545 550
546 void LiveRange::AppendAsChild(TopLevelLiveRange* other) { 551 void LiveRange::AppendAsChild(TopLevelLiveRange* other) {
547 next_ = other; 552 next_ = other;
548 553
549 other->UpdateParentForAllChildren(TopLevel()); 554 other->UpdateParentForAllChildren(TopLevel());
550 TopLevel()->UpdateSpillRangePostMerge(other); 555 TopLevel()->UpdateSpillRangePostMerge(other);
551 TopLevel()->set_last_child(other->last_child()); 556 TopLevel()->set_last_child(other->last_child());
552 } 557 }
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 next_ = nullptr; 863 next_ = nullptr;
859 } else if (end >= End()) { 864 } else if (end >= End()) {
860 DCHECK(start > Start()); 865 DCHECK(start > Start());
861 DetachAt(start, result, zone); 866 DetachAt(start, result, zone);
862 next_ = nullptr; 867 next_ = nullptr;
863 } else { 868 } else {
864 DCHECK(start < End() && Start() < end); 869 DCHECK(start < End() && Start() < end);
865 870
866 const int kInvalidId = std::numeric_limits<int>::max(); 871 const int kInvalidId = std::numeric_limits<int>::max();
867 872
868 DetachAt(start, result, zone); 873 UsePosition* last = DetachAt(start, result, zone);
869 874
870 LiveRange end_part(kInvalidId, this->machine_type(), nullptr); 875 LiveRange end_part(kInvalidId, this->machine_type(), nullptr);
871 result->DetachAt(end, &end_part, zone); 876 result->DetachAt(end, &end_part, zone);
872 877
873 next_ = end_part.next_; 878 next_ = end_part.next_;
874 last_interval_->set_next(end_part.first_interval_); 879 last_interval_->set_next(end_part.first_interval_);
875 // The next splinter will happen either at or after the current interval. 880 // The next splinter will happen either at or after the current interval.
876 // We can optimize DetachAt by setting current_interval_ accordingly, 881 // We can optimize DetachAt by setting current_interval_ accordingly,
877 // which will then be picked up by FirstSearchIntervalForPosition. 882 // which will then be picked up by FirstSearchIntervalForPosition.
878 current_interval_ = last_interval_; 883 current_interval_ = last_interval_;
879 last_interval_ = end_part.last_interval_; 884 last_interval_ = end_part.last_interval_;
880 885
881
882 if (first_pos_ == nullptr) { 886 if (first_pos_ == nullptr) {
883 first_pos_ = end_part.first_pos_; 887 first_pos_ = end_part.first_pos_;
884 } else { 888 } else {
885 UsePosition* pos = first_pos_; 889 splitting_pointer_ = last;
886 for (; pos->next() != nullptr; pos = pos->next()) { 890 if (last != nullptr) last->set_next(end_part.first_pos_);
887 }
888 pos->set_next(end_part.first_pos_);
889 } 891 }
890 } 892 }
891 result->next_ = nullptr; 893 result->next_ = nullptr;
892 result->top_level_ = result; 894 result->top_level_ = result;
893 895
894 result->SetSplinteredFrom(this); 896 result->SetSplinteredFrom(this);
895 // Ensure the result's relative ID is unique within the IDs used for this 897 // Ensure the result's relative ID is unique within the IDs used for this
896 // virtual register's children and splinters. 898 // virtual register's children and splinters.
897 result->relative_id_ = GetNextChildId(); 899 result->relative_id_ = GetNextChildId();
898 } 900 }
(...skipping 2460 matching lines...) Expand 10 before | Expand all | Expand 10 after
3359 auto eliminate = moves->PrepareInsertAfter(move); 3361 auto eliminate = moves->PrepareInsertAfter(move);
3360 to_insert.push_back(move); 3362 to_insert.push_back(move);
3361 if (eliminate != nullptr) to_eliminate.push_back(eliminate); 3363 if (eliminate != nullptr) to_eliminate.push_back(eliminate);
3362 } 3364 }
3363 } 3365 }
3364 3366
3365 3367
3366 } // namespace compiler 3368 } // namespace compiler
3367 } // namespace internal 3369 } // namespace internal
3368 } // namespace v8 3370 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/register-allocator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698