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

Side by Side Diff: src/compiler/pipeline.cc

Issue 671043004: [turbofan] cleanup register allocator interface a little (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
« no previous file with comments | « no previous file | src/compiler/register-allocator.h » ('j') | 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/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/platform/elapsed-timer.h" 10 #include "src/base/platform/elapsed-timer.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 }; 252 };
253 253
254 254
255 static void TraceSchedule(Schedule* schedule) { 255 static void TraceSchedule(Schedule* schedule) {
256 if (!FLAG_trace_turbo) return; 256 if (!FLAG_trace_turbo) return;
257 OFStream os(stdout); 257 OFStream os(stdout);
258 os << "-- Schedule --------------------------------------\n" << *schedule; 258 os << "-- Schedule --------------------------------------\n" << *schedule;
259 } 259 }
260 260
261 261
262 static SmartArrayPointer<char> GetDebugName(CompilationInfo* info) {
263 SmartArrayPointer<char> name;
264 if (info->IsStub()) {
265 if (info->code_stub() != NULL) {
266 CodeStub::Major major_key = info->code_stub()->MajorKey();
267 const char* major_name = CodeStub::MajorName(major_key, false);
268 size_t len = strlen(major_name);
269 name.Reset(new char[len]);
270 memcpy(name.get(), major_name, len);
271 }
272 } else {
273 AllowHandleDereference allow_deref;
274 name = info->function()->debug_name()->ToCString();
275 }
276 return name;
277 }
278
279
262 Handle<Code> Pipeline::GenerateCode() { 280 Handle<Code> Pipeline::GenerateCode() {
263 // This list must be kept in sync with DONT_TURBOFAN_NODE in ast.cc. 281 // This list must be kept in sync with DONT_TURBOFAN_NODE in ast.cc.
264 if (info()->function()->dont_optimize_reason() == kTryCatchStatement || 282 if (info()->function()->dont_optimize_reason() == kTryCatchStatement ||
265 info()->function()->dont_optimize_reason() == kTryFinallyStatement || 283 info()->function()->dont_optimize_reason() == kTryFinallyStatement ||
266 // TODO(turbofan): Make ES6 for-of work and remove this bailout. 284 // TODO(turbofan): Make ES6 for-of work and remove this bailout.
267 info()->function()->dont_optimize_reason() == kForOfStatement || 285 info()->function()->dont_optimize_reason() == kForOfStatement ||
268 // TODO(turbofan): Make super work and remove this bailout. 286 // TODO(turbofan): Make super work and remove this bailout.
269 info()->function()->dont_optimize_reason() == kSuperReference || 287 info()->function()->dont_optimize_reason() == kSuperReference ||
270 // TODO(turbofan): Make class literals work and remove this bailout. 288 // TODO(turbofan): Make class literals work and remove this bailout.
271 info()->function()->dont_optimize_reason() == kClassLiteral || 289 info()->function()->dont_optimize_reason() == kClassLiteral ||
272 // TODO(turbofan): Make OSR work and remove this bailout. 290 // TODO(turbofan): Make OSR work and remove this bailout.
273 info()->is_osr()) { 291 info()->is_osr()) {
274 return Handle<Code>::null(); 292 return Handle<Code>::null();
275 } 293 }
276 294
277 ZonePool zone_pool(isolate()); 295 ZonePool zone_pool(isolate());
278 296
279 SmartPointer<PipelineStatistics> pipeline_statistics; 297 SmartPointer<PipelineStatistics> pipeline_statistics;
280 if (FLAG_turbo_stats) { 298 if (FLAG_turbo_stats) {
281 pipeline_statistics.Reset(new PipelineStatistics(info(), &zone_pool)); 299 pipeline_statistics.Reset(new PipelineStatistics(info(), &zone_pool));
282 pipeline_statistics->BeginPhaseKind("graph creation"); 300 pipeline_statistics->BeginPhaseKind("graph creation");
283 } 301 }
284 302
285 if (FLAG_trace_turbo) { 303 if (FLAG_trace_turbo) {
286 OFStream os(stdout); 304 OFStream os(stdout);
287 os << "---------------------------------------------------\n" 305 os << "---------------------------------------------------\n"
288 << "Begin compiling method " 306 << "Begin compiling method " << GetDebugName(info()).get()
289 << info()->function()->debug_name()->ToCString().get()
290 << " using Turbofan" << std::endl; 307 << " using Turbofan" << std::endl;
291 TurboCfgFile tcf(isolate()); 308 TurboCfgFile tcf(isolate());
292 tcf << AsC1VCompilation(info()); 309 tcf << AsC1VCompilation(info());
293 } 310 }
294 311
295 // Initialize the graph and builders. 312 // Initialize the graph and builders.
296 PipelineData data(info(), &zone_pool, pipeline_statistics.get()); 313 PipelineData data(info(), &zone_pool, pipeline_statistics.get());
297 314
298 data.source_positions()->AddDecorator(); 315 data.source_positions()->AddDecorator();
299 316
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 code = GenerateCode(&linkage, &data); 473 code = GenerateCode(&linkage, &data);
457 info()->SetCode(code); 474 info()->SetCode(code);
458 } 475 }
459 476
460 // Print optimized code. 477 // Print optimized code.
461 v8::internal::CodeGenerator::PrintCode(code, info()); 478 v8::internal::CodeGenerator::PrintCode(code, info());
462 479
463 if (FLAG_trace_turbo) { 480 if (FLAG_trace_turbo) {
464 OFStream os(stdout); 481 OFStream os(stdout);
465 os << "--------------------------------------------------\n" 482 os << "--------------------------------------------------\n"
466 << "Finished compiling method " 483 << "Finished compiling method " << GetDebugName(info()).get()
467 << info()->function()->debug_name()->ToCString().get()
468 << " using Turbofan" << std::endl; 484 << " using Turbofan" << std::endl;
469 } 485 }
470 486
471 return code; 487 return code;
472 } 488 }
473 489
474 490
475 void Pipeline::ComputeSchedule(PipelineData* data) { 491 void Pipeline::ComputeSchedule(PipelineData* data) {
476 PhaseScope phase_scope(data->pipeline_statistics(), "scheduling"); 492 PhaseScope phase_scope(data->pipeline_statistics(), "scheduling");
477 Schedule* schedule = 493 Schedule* schedule =
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 565
550 // Allocate registers. 566 // Allocate registers.
551 Frame frame; 567 Frame frame;
552 { 568 {
553 int node_count = sequence.VirtualRegisterCount(); 569 int node_count = sequence.VirtualRegisterCount();
554 if (node_count > UnallocatedOperand::kMaxVirtualRegisters) { 570 if (node_count > UnallocatedOperand::kMaxVirtualRegisters) {
555 info()->AbortOptimization(kNotEnoughVirtualRegistersForValues); 571 info()->AbortOptimization(kNotEnoughVirtualRegistersForValues);
556 return Handle<Code>::null(); 572 return Handle<Code>::null();
557 } 573 }
558 ZonePool::Scope zone_scope(data->zone_pool()); 574 ZonePool::Scope zone_scope(data->zone_pool());
559 RegisterAllocator allocator(zone_scope.zone(), &frame, info(), &sequence); 575
576 SmartArrayPointer<char> debug_name;
577 #ifdef DEBUG
578 debug_name = GetDebugName(info());
579 #endif
580
581 RegisterAllocator allocator(zone_scope.zone(), &frame, &sequence,
582 debug_name.get());
560 if (!allocator.Allocate(data->pipeline_statistics())) { 583 if (!allocator.Allocate(data->pipeline_statistics())) {
561 info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); 584 info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc);
562 return Handle<Code>::null(); 585 return Handle<Code>::null();
563 } 586 }
564 if (FLAG_trace_turbo) { 587 if (FLAG_trace_turbo) {
565 TurboCfgFile tcf(isolate()); 588 TurboCfgFile tcf(isolate());
566 tcf << AsC1VAllocator("CodeGen", &allocator); 589 tcf << AsC1VAllocator("CodeGen", &allocator);
567 } 590 }
568 } 591 }
569 592
(...skipping 30 matching lines...) Expand all
600 } 623 }
601 624
602 625
603 void Pipeline::TearDown() { 626 void Pipeline::TearDown() {
604 InstructionOperand::TearDownCaches(); 627 InstructionOperand::TearDownCaches();
605 } 628 }
606 629
607 } // namespace compiler 630 } // namespace compiler
608 } // namespace internal 631 } // namespace internal
609 } // namespace v8 632 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/register-allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698