OLD | NEW |
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/pipeline.h" | 5 #include "src/compiler/pipeline.h" |
6 | 6 |
7 #include <fstream> // NOLINT(readability/streams) | 7 #include <fstream> // NOLINT(readability/streams) |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "src/base/adapters.h" | 10 #include "src/base/adapters.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 void InitializeInstructionSequence() { | 252 void InitializeInstructionSequence() { |
253 DCHECK(sequence_ == nullptr); | 253 DCHECK(sequence_ == nullptr); |
254 InstructionBlocks* instruction_blocks = | 254 InstructionBlocks* instruction_blocks = |
255 InstructionSequence::InstructionBlocksFor(instruction_zone(), | 255 InstructionSequence::InstructionBlocksFor(instruction_zone(), |
256 schedule()); | 256 schedule()); |
257 sequence_ = new (instruction_zone()) InstructionSequence( | 257 sequence_ = new (instruction_zone()) InstructionSequence( |
258 info()->isolate(), instruction_zone(), instruction_blocks); | 258 info()->isolate(), instruction_zone(), instruction_blocks); |
259 } | 259 } |
260 | 260 |
261 void InitializeRegisterAllocationData(const RegisterConfiguration* config, | 261 void InitializeRegisterAllocationData(const RegisterConfiguration* config, |
| 262 CallDescriptor* descriptor, |
262 const char* debug_name) { | 263 const char* debug_name) { |
263 DCHECK(frame_ == nullptr); | 264 DCHECK(frame_ == nullptr); |
264 DCHECK(register_allocation_data_ == nullptr); | 265 DCHECK(register_allocation_data_ == nullptr); |
265 frame_ = new (instruction_zone()) Frame(); | 266 int fixed_frame_size = 0; |
| 267 if (descriptor != nullptr) { |
| 268 fixed_frame_size = (descriptor->kind() == CallDescriptor::kCallAddress) |
| 269 ? StandardFrameConstants::kFixedSlotCountAboveFp |
| 270 : StandardFrameConstants::kFixedSlotCount; |
| 271 } |
| 272 frame_ = new (instruction_zone()) Frame(fixed_frame_size); |
266 register_allocation_data_ = new (register_allocation_zone()) | 273 register_allocation_data_ = new (register_allocation_zone()) |
267 RegisterAllocationData(config, register_allocation_zone(), frame(), | 274 RegisterAllocationData(config, register_allocation_zone(), frame(), |
268 sequence(), debug_name); | 275 sequence(), debug_name); |
269 } | 276 } |
270 | 277 |
271 private: | 278 private: |
272 Isolate* isolate_; | 279 Isolate* isolate_; |
273 CompilationInfo* info_; | 280 CompilationInfo* info_; |
274 Zone* outer_zone_; | 281 Zone* outer_zone_; |
275 ZonePool* const zone_pool_; | 282 ZonePool* const zone_pool_; |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 | 1190 |
1184 bool Pipeline::AllocateRegistersForTesting(const RegisterConfiguration* config, | 1191 bool Pipeline::AllocateRegistersForTesting(const RegisterConfiguration* config, |
1185 InstructionSequence* sequence, | 1192 InstructionSequence* sequence, |
1186 bool run_verifier) { | 1193 bool run_verifier) { |
1187 FakeStubForTesting stub(sequence->isolate()); | 1194 FakeStubForTesting stub(sequence->isolate()); |
1188 CompilationInfo info(&stub, sequence->isolate(), sequence->zone()); | 1195 CompilationInfo info(&stub, sequence->isolate(), sequence->zone()); |
1189 ZonePool zone_pool; | 1196 ZonePool zone_pool; |
1190 PipelineData data(&zone_pool, &info, sequence); | 1197 PipelineData data(&zone_pool, &info, sequence); |
1191 Pipeline pipeline(&info); | 1198 Pipeline pipeline(&info); |
1192 pipeline.data_ = &data; | 1199 pipeline.data_ = &data; |
1193 pipeline.AllocateRegisters(config, run_verifier); | 1200 pipeline.AllocateRegisters(config, nullptr, run_verifier); |
1194 return !data.compilation_failed(); | 1201 return !data.compilation_failed(); |
1195 } | 1202 } |
1196 | 1203 |
1197 | 1204 |
1198 Handle<Code> Pipeline::ScheduleAndGenerateCode( | 1205 Handle<Code> Pipeline::ScheduleAndGenerateCode( |
1199 CallDescriptor* call_descriptor) { | 1206 CallDescriptor* call_descriptor) { |
1200 PipelineData* data = this->data_; | 1207 PipelineData* data = this->data_; |
1201 | 1208 |
1202 DCHECK_NOT_NULL(data->graph()); | 1209 DCHECK_NOT_NULL(data->graph()); |
1203 | 1210 |
(...skipping 23 matching lines...) Expand all Loading... |
1227 // Output source position information before the graph is deleted. | 1234 // Output source position information before the graph is deleted. |
1228 data_->source_positions()->Print(source_position_output); | 1235 data_->source_positions()->Print(source_position_output); |
1229 } | 1236 } |
1230 | 1237 |
1231 data->DeleteGraphZone(); | 1238 data->DeleteGraphZone(); |
1232 | 1239 |
1233 BeginPhaseKind("register allocation"); | 1240 BeginPhaseKind("register allocation"); |
1234 | 1241 |
1235 bool run_verifier = FLAG_turbo_verify_allocation; | 1242 bool run_verifier = FLAG_turbo_verify_allocation; |
1236 // Allocate registers. | 1243 // Allocate registers. |
1237 AllocateRegisters(RegisterConfiguration::ArchDefault(), run_verifier); | 1244 AllocateRegisters(RegisterConfiguration::ArchDefault(), call_descriptor, |
| 1245 run_verifier); |
1238 if (data->compilation_failed()) { | 1246 if (data->compilation_failed()) { |
1239 info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); | 1247 info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); |
1240 return Handle<Code>(); | 1248 return Handle<Code>(); |
1241 } | 1249 } |
1242 | 1250 |
1243 BeginPhaseKind("code generation"); | 1251 BeginPhaseKind("code generation"); |
1244 | 1252 |
1245 // Optimimize jumps. | 1253 // Optimimize jumps. |
1246 if (FLAG_turbo_jt) { | 1254 if (FLAG_turbo_jt) { |
1247 Run<JumpThreadingPhase>(); | 1255 Run<JumpThreadingPhase>(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 os << "---------------------------------------------------\n" | 1294 os << "---------------------------------------------------\n" |
1287 << "Finished compiling method " << GetDebugName(info()).get() | 1295 << "Finished compiling method " << GetDebugName(info()).get() |
1288 << " using Turbofan" << std::endl; | 1296 << " using Turbofan" << std::endl; |
1289 } | 1297 } |
1290 | 1298 |
1291 return code; | 1299 return code; |
1292 } | 1300 } |
1293 | 1301 |
1294 | 1302 |
1295 void Pipeline::AllocateRegisters(const RegisterConfiguration* config, | 1303 void Pipeline::AllocateRegisters(const RegisterConfiguration* config, |
| 1304 CallDescriptor* descriptor, |
1296 bool run_verifier) { | 1305 bool run_verifier) { |
1297 PipelineData* data = this->data_; | 1306 PipelineData* data = this->data_; |
1298 | 1307 |
1299 // Don't track usage for this zone in compiler stats. | 1308 // Don't track usage for this zone in compiler stats. |
1300 base::SmartPointer<Zone> verifier_zone; | 1309 base::SmartPointer<Zone> verifier_zone; |
1301 RegisterAllocatorVerifier* verifier = nullptr; | 1310 RegisterAllocatorVerifier* verifier = nullptr; |
1302 if (run_verifier) { | 1311 if (run_verifier) { |
1303 verifier_zone.Reset(new Zone()); | 1312 verifier_zone.Reset(new Zone()); |
1304 verifier = new (verifier_zone.get()) RegisterAllocatorVerifier( | 1313 verifier = new (verifier_zone.get()) RegisterAllocatorVerifier( |
1305 verifier_zone.get(), config, data->sequence()); | 1314 verifier_zone.get(), config, data->sequence()); |
1306 } | 1315 } |
1307 | 1316 |
1308 base::SmartArrayPointer<char> debug_name; | 1317 base::SmartArrayPointer<char> debug_name; |
1309 #ifdef DEBUG | 1318 #ifdef DEBUG |
1310 debug_name = GetDebugName(data->info()); | 1319 debug_name = GetDebugName(data->info()); |
1311 #endif | 1320 #endif |
1312 | 1321 |
1313 data->InitializeRegisterAllocationData(config, debug_name.get()); | 1322 data->InitializeRegisterAllocationData(config, descriptor, debug_name.get()); |
1314 if (info()->is_osr()) { | 1323 if (info()->is_osr()) { |
1315 OsrHelper osr_helper(info()); | 1324 OsrHelper osr_helper(info()); |
1316 osr_helper.SetupFrame(data->frame()); | 1325 osr_helper.SetupFrame(data->frame()); |
1317 } | 1326 } |
1318 | 1327 |
1319 Run<MeetRegisterConstraintsPhase>(); | 1328 Run<MeetRegisterConstraintsPhase>(); |
1320 Run<ResolvePhisPhase>(); | 1329 Run<ResolvePhisPhase>(); |
1321 Run<BuildLiveRangesPhase>(); | 1330 Run<BuildLiveRangesPhase>(); |
1322 if (FLAG_trace_turbo_graph) { | 1331 if (FLAG_trace_turbo_graph) { |
1323 OFStream os(stdout); | 1332 OFStream os(stdout); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1369 tcf << AsC1VRegisterAllocationData("CodeGen", | 1378 tcf << AsC1VRegisterAllocationData("CodeGen", |
1370 data->register_allocation_data()); | 1379 data->register_allocation_data()); |
1371 } | 1380 } |
1372 | 1381 |
1373 data->DeleteRegisterAllocationZone(); | 1382 data->DeleteRegisterAllocationZone(); |
1374 } | 1383 } |
1375 | 1384 |
1376 } // namespace compiler | 1385 } // namespace compiler |
1377 } // namespace internal | 1386 } // namespace internal |
1378 } // namespace v8 | 1387 } // namespace v8 |
OLD | NEW |