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

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

Issue 1872483002: [compiler] Make OptimizedCompileJob agnostic from backend. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Prevent endless recompile. Created 4 years, 8 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/pipeline.h ('k') | src/crankshaft/hydrogen.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/adapters.h" 10 #include "src/base/adapters.h"
11 #include "src/base/platform/elapsed-timer.h" 11 #include "src/base/platform/elapsed-timer.h"
12 #include "src/compiler/ast-graph-builder.h" 12 #include "src/compiler/ast-graph-builder.h"
13 #include "src/compiler/ast-loop-assignment-analyzer.h" 13 #include "src/compiler/ast-loop-assignment-analyzer.h"
14 #include "src/compiler/basic-block-instrumentor.h" 14 #include "src/compiler/basic-block-instrumentor.h"
15 #include "src/compiler/branch-elimination.h" 15 #include "src/compiler/branch-elimination.h"
16 #include "src/compiler/bytecode-graph-builder.h" 16 #include "src/compiler/bytecode-graph-builder.h"
17 #include "src/compiler/change-lowering.h" 17 #include "src/compiler/change-lowering.h"
18 #include "src/compiler/code-generator.h" 18 #include "src/compiler/code-generator.h"
19 #include "src/compiler/common-operator-reducer.h" 19 #include "src/compiler/common-operator-reducer.h"
20 #include "src/compiler/control-flow-optimizer.h" 20 #include "src/compiler/control-flow-optimizer.h"
21 #include "src/compiler/dead-code-elimination.h" 21 #include "src/compiler/dead-code-elimination.h"
22 #include "src/compiler/escape-analysis-reducer.h"
22 #include "src/compiler/escape-analysis.h" 23 #include "src/compiler/escape-analysis.h"
23 #include "src/compiler/escape-analysis-reducer.h"
24 #include "src/compiler/frame-elider.h" 24 #include "src/compiler/frame-elider.h"
25 #include "src/compiler/graph-replay.h" 25 #include "src/compiler/graph-replay.h"
26 #include "src/compiler/graph-trimmer.h" 26 #include "src/compiler/graph-trimmer.h"
27 #include "src/compiler/graph-visualizer.h" 27 #include "src/compiler/graph-visualizer.h"
28 #include "src/compiler/greedy-allocator.h" 28 #include "src/compiler/greedy-allocator.h"
29 #include "src/compiler/instruction-selector.h"
29 #include "src/compiler/instruction.h" 30 #include "src/compiler/instruction.h"
30 #include "src/compiler/instruction-selector.h"
31 #include "src/compiler/js-builtin-reducer.h" 31 #include "src/compiler/js-builtin-reducer.h"
32 #include "src/compiler/js-call-reducer.h" 32 #include "src/compiler/js-call-reducer.h"
33 #include "src/compiler/js-context-specialization.h" 33 #include "src/compiler/js-context-specialization.h"
34 #include "src/compiler/js-create-lowering.h" 34 #include "src/compiler/js-create-lowering.h"
35 #include "src/compiler/js-frame-specialization.h" 35 #include "src/compiler/js-frame-specialization.h"
36 #include "src/compiler/js-generic-lowering.h" 36 #include "src/compiler/js-generic-lowering.h"
37 #include "src/compiler/js-global-object-specialization.h" 37 #include "src/compiler/js-global-object-specialization.h"
38 #include "src/compiler/js-inlining-heuristic.h" 38 #include "src/compiler/js-inlining-heuristic.h"
39 #include "src/compiler/js-intrinsic-lowering.h" 39 #include "src/compiler/js-intrinsic-lowering.h"
40 #include "src/compiler/js-native-context-specialization.h" 40 #include "src/compiler/js-native-context-specialization.h"
41 #include "src/compiler/js-typed-lowering.h" 41 #include "src/compiler/js-typed-lowering.h"
42 #include "src/compiler/jump-threading.h" 42 #include "src/compiler/jump-threading.h"
43 #include "src/compiler/live-range-separator.h" 43 #include "src/compiler/live-range-separator.h"
44 #include "src/compiler/load-elimination.h" 44 #include "src/compiler/load-elimination.h"
45 #include "src/compiler/loop-analysis.h" 45 #include "src/compiler/loop-analysis.h"
46 #include "src/compiler/loop-peeling.h" 46 #include "src/compiler/loop-peeling.h"
47 #include "src/compiler/machine-operator-reducer.h" 47 #include "src/compiler/machine-operator-reducer.h"
48 #include "src/compiler/move-optimizer.h" 48 #include "src/compiler/move-optimizer.h"
49 #include "src/compiler/osr.h" 49 #include "src/compiler/osr.h"
50 #include "src/compiler/pipeline-statistics.h" 50 #include "src/compiler/pipeline-statistics.h"
51 #include "src/compiler/register-allocator-verifier.h"
51 #include "src/compiler/register-allocator.h" 52 #include "src/compiler/register-allocator.h"
52 #include "src/compiler/register-allocator-verifier.h"
53 #include "src/compiler/schedule.h" 53 #include "src/compiler/schedule.h"
54 #include "src/compiler/scheduler.h" 54 #include "src/compiler/scheduler.h"
55 #include "src/compiler/select-lowering.h" 55 #include "src/compiler/select-lowering.h"
56 #include "src/compiler/simplified-lowering.h" 56 #include "src/compiler/simplified-lowering.h"
57 #include "src/compiler/simplified-operator-reducer.h"
57 #include "src/compiler/simplified-operator.h" 58 #include "src/compiler/simplified-operator.h"
58 #include "src/compiler/simplified-operator-reducer.h"
59 #include "src/compiler/tail-call-optimization.h" 59 #include "src/compiler/tail-call-optimization.h"
60 #include "src/compiler/type-hint-analyzer.h" 60 #include "src/compiler/type-hint-analyzer.h"
61 #include "src/compiler/typer.h" 61 #include "src/compiler/typer.h"
62 #include "src/compiler/value-numbering-reducer.h" 62 #include "src/compiler/value-numbering-reducer.h"
63 #include "src/compiler/verifier.h" 63 #include "src/compiler/verifier.h"
64 #include "src/compiler/zone-pool.h" 64 #include "src/compiler/zone-pool.h"
65 #include "src/isolate-inl.h"
65 #include "src/ostreams.h" 66 #include "src/ostreams.h"
66 #include "src/register-configuration.h" 67 #include "src/register-configuration.h"
67 #include "src/type-info.h" 68 #include "src/type-info.h"
68 #include "src/utils.h" 69 #include "src/utils.h"
69 70
70 namespace v8 { 71 namespace v8 {
71 namespace internal { 72 namespace internal {
72 namespace compiler { 73 namespace compiler {
73 74
74 class PipelineData { 75 class PipelineData {
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 phase_name), 470 phase_name),
470 zone_scope_(data->zone_pool()) {} 471 zone_scope_(data->zone_pool()) {}
471 472
472 Zone* zone() { return zone_scope_.zone(); } 473 Zone* zone() { return zone_scope_.zone(); }
473 474
474 private: 475 private:
475 PhaseScope phase_scope_; 476 PhaseScope phase_scope_;
476 ZonePool::Scope zone_scope_; 477 ZonePool::Scope zone_scope_;
477 }; 478 };
478 479
480 class PipelineCompilationJob : public OptimizedCompileJob {
481 public:
482 explicit PipelineCompilationJob(CompilationInfo* info)
483 : OptimizedCompileJob(info) {}
484
485 protected:
486 virtual Status CreateGraphImpl();
487 virtual Status OptimizeGraphImpl();
488 virtual Status GenerateCodeImpl();
489 };
490
491 PipelineCompilationJob::Status PipelineCompilationJob::CreateGraphImpl() {
492 if (FLAG_trace_opt) {
493 OFStream os(stdout);
494 os << "[compiling method " << Brief(*info()->closure())
495 << " using TurboFan";
496 if (info()->is_osr()) os << " OSR";
497 os << "]" << std::endl;
498 }
499
500 if (info()->shared_info()->asm_function()) {
501 if (info()->osr_frame()) info()->MarkAsFrameSpecializing();
502 info()->MarkAsFunctionContextSpecializing();
503 } else {
504 if (!FLAG_always_opt) {
505 info()->MarkAsBailoutOnUninitialized();
506 }
507 if (FLAG_native_context_specialization) {
508 info()->MarkAsNativeContextSpecializing();
509 info()->MarkAsTypingEnabled();
510 }
511 }
512 if (!info()->shared_info()->asm_function() || FLAG_turbo_asm_deoptimization) {
513 info()->MarkAsDeoptimizationEnabled();
514 }
515
516 Pipeline pipeline(info());
517 pipeline.GenerateCode();
518 if (isolate()->has_pending_exception()) return FAILED; // Stack overflowed.
519 if (info()->code().is_null()) return AbortOptimization(kGraphBuildingFailed);
520
521 return SUCCEEDED;
522 }
523
524 PipelineCompilationJob::Status PipelineCompilationJob::OptimizeGraphImpl() {
525 // TODO(turbofan): Currently everything is done in the first phase.
526 DCHECK(!info()->code().is_null());
527 return SUCCEEDED;
528 }
529
530 PipelineCompilationJob::Status PipelineCompilationJob::GenerateCodeImpl() {
531 // TODO(turbofan): Currently everything is done in the first phase.
532 DCHECK(!info()->code().is_null());
533 info()->dependencies()->Commit(info()->code());
534 if (info()->is_deoptimization_enabled()) {
535 info()->context()->native_context()->AddOptimizedCode(*info()->code());
536 RegisterWeakObjectsInOptimizedCode(info()->code());
537 }
538 return SUCCEEDED;
539 }
540
479 } // namespace 541 } // namespace
480 542
481 543
482 template <typename Phase> 544 template <typename Phase>
483 void Pipeline::Run() { 545 void Pipeline::Run() {
484 PipelineRunScope scope(this->data_, Phase::phase_name()); 546 PipelineRunScope scope(this->data_, Phase::phase_name());
485 Phase phase; 547 Phase phase;
486 phase.Run(this->data_, scope.zone()); 548 phase.Run(this->data_, scope.zone());
487 } 549 }
488 550
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 Pipeline pipeline(info); 1368 Pipeline pipeline(info);
1307 pipeline.data_ = &data; 1369 pipeline.data_ = &data;
1308 if (data.schedule() == nullptr) { 1370 if (data.schedule() == nullptr) {
1309 // TODO(rossberg): Should this really be untyped? 1371 // TODO(rossberg): Should this really be untyped?
1310 pipeline.RunPrintAndVerify("Machine", true); 1372 pipeline.RunPrintAndVerify("Machine", true);
1311 } 1373 }
1312 1374
1313 return pipeline.ScheduleAndGenerateCode(call_descriptor); 1375 return pipeline.ScheduleAndGenerateCode(call_descriptor);
1314 } 1376 }
1315 1377
1378 OptimizedCompileJob* Pipeline::NewCompilationJob(CompilationInfo* info) {
1379 return new (info->zone()) PipelineCompilationJob(info);
1380 }
1316 1381
1317 bool Pipeline::AllocateRegistersForTesting(const RegisterConfiguration* config, 1382 bool Pipeline::AllocateRegistersForTesting(const RegisterConfiguration* config,
1318 InstructionSequence* sequence, 1383 InstructionSequence* sequence,
1319 bool run_verifier) { 1384 bool run_verifier) {
1320 CompilationInfo info("testing", sequence->isolate(), sequence->zone()); 1385 CompilationInfo info("testing", sequence->isolate(), sequence->zone());
1321 ZonePool zone_pool(sequence->isolate()->allocator()); 1386 ZonePool zone_pool(sequence->isolate()->allocator());
1322 PipelineData data(&zone_pool, &info, sequence); 1387 PipelineData data(&zone_pool, &info, sequence);
1323 Pipeline pipeline(&info); 1388 Pipeline pipeline(&info);
1324 pipeline.data_ = &data; 1389 pipeline.data_ = &data;
1325 pipeline.data_->InitializeFrameData(nullptr); 1390 pipeline.data_->InitializeFrameData(nullptr);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 } 1586 }
1522 1587
1523 data->DeleteRegisterAllocationZone(); 1588 data->DeleteRegisterAllocationZone();
1524 } 1589 }
1525 1590
1526 Isolate* Pipeline::isolate() const { return info()->isolate(); } 1591 Isolate* Pipeline::isolate() const { return info()->isolate(); }
1527 1592
1528 } // namespace compiler 1593 } // namespace compiler
1529 } // namespace internal 1594 } // namespace internal
1530 } // namespace v8 1595 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/pipeline.h ('k') | src/crankshaft/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698