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

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

Issue 713803002: [turbofan] add register assignment verifier (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
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/compiler/linkage.h" 5 #include "src/compiler/linkage.h"
6 #include "src/compiler/pipeline-statistics.h" 6 #include "src/compiler/pipeline-statistics.h"
7 #include "src/compiler/register-allocator.h" 7 #include "src/compiler/register-allocator.h"
8 #include "src/compiler/register-allocator-verifier.h"
8 #include "src/string-stream.h" 9 #include "src/string-stream.h"
9 10
10 namespace v8 { 11 namespace v8 {
11 namespace internal { 12 namespace internal {
12 namespace compiler { 13 namespace compiler {
13 14
14 static inline LifetimePosition Min(LifetimePosition a, LifetimePosition b) { 15 static inline LifetimePosition Min(LifetimePosition a, LifetimePosition b) {
15 return a.Value() < b.Value() ? a : b; 16 return a.Value() < b.Value() ? a : b;
16 } 17 }
17 18
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 1110
1110 // We use the phi-ness of some nodes in some later heuristics. 1111 // We use the phi-ness of some nodes in some later heuristics.
1111 live_range->set_is_phi(true); 1112 live_range->set_is_phi(true);
1112 if (!block->IsLoopHeader()) { 1113 if (!block->IsLoopHeader()) {
1113 live_range->set_is_non_loop_phi(true); 1114 live_range->set_is_non_loop_phi(true);
1114 } 1115 }
1115 } 1116 }
1116 } 1117 }
1117 1118
1118 1119
1119 bool RegisterAllocator::Allocate(PipelineStatistics* stats) { 1120 bool RegisterAllocator::Allocate(PipelineStatistics* stats,
1121 VerificationType verification_type) {
1122 SmartPointer<Zone> verifier_zone;
1123 RegisterAllocatorVerifier* verifier = NULL;
1124 if (verification_type == kVerifyAssignment) {
1125 // Don't track usage for this zone in compiler stats.
1126 verifier_zone.Reset(new Zone(local_zone()->isolate()));
1127 verifier = new (verifier_zone.get())
1128 RegisterAllocatorVerifier(verifier_zone.get(), code());
1129 }
1120 assigned_registers_ = new (code_zone()) 1130 assigned_registers_ = new (code_zone())
1121 BitVector(config()->num_general_registers(), code_zone()); 1131 BitVector(config()->num_general_registers(), code_zone());
1122 assigned_double_registers_ = new (code_zone()) 1132 assigned_double_registers_ = new (code_zone())
1123 BitVector(config()->num_aliased_double_registers(), code_zone()); 1133 BitVector(config()->num_aliased_double_registers(), code_zone());
1124 { 1134 {
1125 PhaseScope phase_scope(stats, "meet register constraints"); 1135 PhaseScope phase_scope(stats, "meet register constraints");
1126 MeetRegisterConstraints(); 1136 MeetRegisterConstraints();
1127 } 1137 }
1128 if (!AllocationOk()) return false; 1138 if (!AllocationOk()) return false;
1129 { 1139 {
(...skipping 21 matching lines...) Expand all
1151 { 1161 {
1152 PhaseScope phase_scope(stats, "connect ranges"); 1162 PhaseScope phase_scope(stats, "connect ranges");
1153 ConnectRanges(); 1163 ConnectRanges();
1154 } 1164 }
1155 { 1165 {
1156 PhaseScope phase_scope(stats, "resolve control flow"); 1166 PhaseScope phase_scope(stats, "resolve control flow");
1157 ResolveControlFlow(); 1167 ResolveControlFlow();
1158 } 1168 }
1159 frame()->SetAllocatedRegisters(assigned_registers_); 1169 frame()->SetAllocatedRegisters(assigned_registers_);
1160 frame()->SetAllocatedDoubleRegisters(assigned_double_registers_); 1170 frame()->SetAllocatedDoubleRegisters(assigned_double_registers_);
1171 if (verifier != NULL) {
1172 verifier->VerifyAssignment();
1173 }
1161 return true; 1174 return true;
1162 } 1175 }
1163 1176
1164 1177
1165 void RegisterAllocator::MeetRegisterConstraints() { 1178 void RegisterAllocator::MeetRegisterConstraints() {
1166 for (auto block : code()->instruction_blocks()) { 1179 for (auto block : code()->instruction_blocks()) {
1167 MeetRegisterConstraints(block); 1180 MeetRegisterConstraints(block);
1168 if (!AllocationOk()) return; 1181 if (!AllocationOk()) return;
1169 } 1182 }
1170 } 1183 }
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after
2318 } else { 2331 } else {
2319 DCHECK(range->Kind() == GENERAL_REGISTERS); 2332 DCHECK(range->Kind() == GENERAL_REGISTERS);
2320 assigned_registers_->Add(reg); 2333 assigned_registers_->Add(reg);
2321 } 2334 }
2322 range->set_assigned_register(reg, code_zone()); 2335 range->set_assigned_register(reg, code_zone());
2323 } 2336 }
2324 2337
2325 } 2338 }
2326 } 2339 }
2327 } // namespace v8::internal::compiler 2340 } // namespace v8::internal::compiler
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698