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

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

Issue 1487973002: [turbofan] Add binary operation hints for javascript operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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
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"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "src/compiler/pipeline-statistics.h" 48 #include "src/compiler/pipeline-statistics.h"
49 #include "src/compiler/register-allocator.h" 49 #include "src/compiler/register-allocator.h"
50 #include "src/compiler/register-allocator-verifier.h" 50 #include "src/compiler/register-allocator-verifier.h"
51 #include "src/compiler/schedule.h" 51 #include "src/compiler/schedule.h"
52 #include "src/compiler/scheduler.h" 52 #include "src/compiler/scheduler.h"
53 #include "src/compiler/select-lowering.h" 53 #include "src/compiler/select-lowering.h"
54 #include "src/compiler/simplified-lowering.h" 54 #include "src/compiler/simplified-lowering.h"
55 #include "src/compiler/simplified-operator.h" 55 #include "src/compiler/simplified-operator.h"
56 #include "src/compiler/simplified-operator-reducer.h" 56 #include "src/compiler/simplified-operator-reducer.h"
57 #include "src/compiler/tail-call-optimization.h" 57 #include "src/compiler/tail-call-optimization.h"
58 #include "src/compiler/type-hint-analyzer.h"
58 #include "src/compiler/typer.h" 59 #include "src/compiler/typer.h"
59 #include "src/compiler/value-numbering-reducer.h" 60 #include "src/compiler/value-numbering-reducer.h"
60 #include "src/compiler/verifier.h" 61 #include "src/compiler/verifier.h"
61 #include "src/compiler/zone-pool.h" 62 #include "src/compiler/zone-pool.h"
62 #include "src/ostreams.h" 63 #include "src/ostreams.h"
63 #include "src/register-configuration.h" 64 #include "src/register-configuration.h"
64 #include "src/type-info.h" 65 #include "src/type-info.h"
65 #include "src/utils.h" 66 #include "src/utils.h"
66 67
67 namespace v8 { 68 namespace v8 {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 204 }
204 return MaybeHandle<Context>(); 205 return MaybeHandle<Context>();
205 } 206 }
206 207
207 LoopAssignmentAnalysis* loop_assignment() const { return loop_assignment_; } 208 LoopAssignmentAnalysis* loop_assignment() const { return loop_assignment_; }
208 void set_loop_assignment(LoopAssignmentAnalysis* loop_assignment) { 209 void set_loop_assignment(LoopAssignmentAnalysis* loop_assignment) {
209 DCHECK(!loop_assignment_); 210 DCHECK(!loop_assignment_);
210 loop_assignment_ = loop_assignment; 211 loop_assignment_ = loop_assignment;
211 } 212 }
212 213
214 TypeHintAnalysis* type_hint_analysis() const { return type_hint_analysis_; }
215 void set_type_hint_analysis(TypeHintAnalysis* type_hint_analysis) {
216 DCHECK_NULL(type_hint_analysis_);
217 type_hint_analysis_ = type_hint_analysis;
218 }
219
213 Schedule* schedule() const { return schedule_; } 220 Schedule* schedule() const { return schedule_; }
214 void set_schedule(Schedule* schedule) { 221 void set_schedule(Schedule* schedule) {
215 DCHECK(!schedule_); 222 DCHECK(!schedule_);
216 schedule_ = schedule; 223 schedule_ = schedule;
217 } 224 }
218 225
219 Zone* instruction_zone() const { return instruction_zone_; } 226 Zone* instruction_zone() const { return instruction_zone_; }
220 InstructionSequence* sequence() const { return sequence_; } 227 InstructionSequence* sequence() const { return sequence_; }
221 Frame* frame() const { return frame_; } 228 Frame* frame() const { return frame_; }
222 229
223 Zone* register_allocation_zone() const { return register_allocation_zone_; } 230 Zone* register_allocation_zone() const { return register_allocation_zone_; }
224 RegisterAllocationData* register_allocation_data() const { 231 RegisterAllocationData* register_allocation_data() const {
225 return register_allocation_data_; 232 return register_allocation_data_;
226 } 233 }
227 234
228 void DeleteGraphZone() { 235 void DeleteGraphZone() {
229 // Destroy objects with destructors first. 236 // Destroy objects with destructors first.
230 source_positions_.Reset(nullptr); 237 source_positions_.Reset(nullptr);
231 if (graph_zone_ == nullptr) return; 238 if (graph_zone_ == nullptr) return;
232 // Destroy zone and clear pointers. 239 // Destroy zone and clear pointers.
233 graph_zone_scope_.Destroy(); 240 graph_zone_scope_.Destroy();
234 graph_zone_ = nullptr; 241 graph_zone_ = nullptr;
235 graph_ = nullptr; 242 graph_ = nullptr;
236 loop_assignment_ = nullptr; 243 loop_assignment_ = nullptr;
244 type_hint_analysis_ = nullptr;
237 simplified_ = nullptr; 245 simplified_ = nullptr;
238 machine_ = nullptr; 246 machine_ = nullptr;
239 common_ = nullptr; 247 common_ = nullptr;
240 javascript_ = nullptr; 248 javascript_ = nullptr;
241 jsgraph_ = nullptr; 249 jsgraph_ = nullptr;
242 schedule_ = nullptr; 250 schedule_ = nullptr;
243 } 251 }
244 252
245 void DeleteInstructionZone() { 253 void DeleteInstructionZone() {
246 if (instruction_zone_ == nullptr) return; 254 if (instruction_zone_ == nullptr) return;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 Handle<Code> code_; 302 Handle<Code> code_;
295 303
296 // All objects in the following group of fields are allocated in graph_zone_. 304 // All objects in the following group of fields are allocated in graph_zone_.
297 // They are all set to NULL when the graph_zone_ is destroyed. 305 // They are all set to NULL when the graph_zone_ is destroyed.
298 ZonePool::Scope graph_zone_scope_; 306 ZonePool::Scope graph_zone_scope_;
299 Zone* graph_zone_; 307 Zone* graph_zone_;
300 Graph* graph_; 308 Graph* graph_;
301 // TODO(dcarney): make this into a ZoneObject. 309 // TODO(dcarney): make this into a ZoneObject.
302 base::SmartPointer<SourcePositionTable> source_positions_; 310 base::SmartPointer<SourcePositionTable> source_positions_;
303 LoopAssignmentAnalysis* loop_assignment_; 311 LoopAssignmentAnalysis* loop_assignment_;
312 TypeHintAnalysis* type_hint_analysis_ = nullptr;
304 SimplifiedOperatorBuilder* simplified_; 313 SimplifiedOperatorBuilder* simplified_;
305 MachineOperatorBuilder* machine_; 314 MachineOperatorBuilder* machine_;
306 CommonOperatorBuilder* common_; 315 CommonOperatorBuilder* common_;
307 JSOperatorBuilder* javascript_; 316 JSOperatorBuilder* javascript_;
308 JSGraph* jsgraph_; 317 JSGraph* jsgraph_;
309 Schedule* schedule_; 318 Schedule* schedule_;
310 319
311 // All objects in the following group of fields are allocated in 320 // All objects in the following group of fields are allocated in
312 // instruction_zone_. They are all set to NULL when the instruction_zone_ is 321 // instruction_zone_. They are all set to NULL when the instruction_zone_ is
313 // destroyed. 322 // destroyed.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 OFStream os(stdout); 365 OFStream os(stdout);
357 os << "-- Schedule --------------------------------------\n" << *schedule; 366 os << "-- Schedule --------------------------------------\n" << *schedule;
358 } 367 }
359 368
360 369
361 class AstGraphBuilderWithPositions final : public AstGraphBuilder { 370 class AstGraphBuilderWithPositions final : public AstGraphBuilder {
362 public: 371 public:
363 AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info, 372 AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info,
364 JSGraph* jsgraph, 373 JSGraph* jsgraph,
365 LoopAssignmentAnalysis* loop_assignment, 374 LoopAssignmentAnalysis* loop_assignment,
375 TypeHintAnalysis* type_hint_analysis,
366 SourcePositionTable* source_positions) 376 SourcePositionTable* source_positions)
367 : AstGraphBuilder(local_zone, info, jsgraph, loop_assignment), 377 : AstGraphBuilder(local_zone, info, jsgraph, loop_assignment,
378 type_hint_analysis),
368 source_positions_(source_positions), 379 source_positions_(source_positions),
369 start_position_(info->shared_info()->start_position()) {} 380 start_position_(info->shared_info()->start_position()) {}
370 381
371 bool CreateGraph(bool stack_check) { 382 bool CreateGraph(bool stack_check) {
372 SourcePositionTable::Scope pos_scope(source_positions_, start_position_); 383 SourcePositionTable::Scope pos_scope(source_positions_, start_position_);
373 return AstGraphBuilder::CreateGraph(stack_check); 384 return AstGraphBuilder::CreateGraph(stack_check);
374 } 385 }
375 386
376 #define DEF_VISIT(type) \ 387 #define DEF_VISIT(type) \
377 void Visit##type(type* node) override { \ 388 void Visit##type(type* node) override { \
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 static const char* phase_name() { return "loop assignment analysis"; } 480 static const char* phase_name() { return "loop assignment analysis"; }
470 481
471 void Run(PipelineData* data, Zone* temp_zone) { 482 void Run(PipelineData* data, Zone* temp_zone) {
472 AstLoopAssignmentAnalyzer analyzer(data->graph_zone(), data->info()); 483 AstLoopAssignmentAnalyzer analyzer(data->graph_zone(), data->info());
473 LoopAssignmentAnalysis* loop_assignment = analyzer.Analyze(); 484 LoopAssignmentAnalysis* loop_assignment = analyzer.Analyze();
474 data->set_loop_assignment(loop_assignment); 485 data->set_loop_assignment(loop_assignment);
475 } 486 }
476 }; 487 };
477 488
478 489
490 struct TypeHintAnalysisPhase {
491 static const char* phase_name() { return "type hint analysis"; }
492
493 void Run(PipelineData* data, Zone* temp_zone) {
494 TypeHintAnalyzer analyzer(data->graph_zone());
495 Handle<Code> code(data->info()->shared_info()->code(), data->isolate());
496 TypeHintAnalysis* type_hint_analysis = analyzer.Analyze(code);
497 data->set_type_hint_analysis(type_hint_analysis);
498 }
499 };
500
501
479 struct GraphBuilderPhase { 502 struct GraphBuilderPhase {
480 static const char* phase_name() { return "graph builder"; } 503 static const char* phase_name() { return "graph builder"; }
481 504
482 void Run(PipelineData* data, Zone* temp_zone) { 505 void Run(PipelineData* data, Zone* temp_zone) {
483 bool stack_check = !data->info()->IsStub(); 506 bool stack_check = !data->info()->IsStub();
484 bool succeeded = false; 507 bool succeeded = false;
485 508
486 if (data->info()->shared_info()->HasBytecodeArray()) { 509 if (data->info()->shared_info()->HasBytecodeArray()) {
487 BytecodeGraphBuilder graph_builder(temp_zone, data->info(), 510 BytecodeGraphBuilder graph_builder(temp_zone, data->info(),
488 data->jsgraph()); 511 data->jsgraph());
489 succeeded = graph_builder.CreateGraph(stack_check); 512 succeeded = graph_builder.CreateGraph(stack_check);
490 } else { 513 } else {
491 AstGraphBuilderWithPositions graph_builder( 514 AstGraphBuilderWithPositions graph_builder(
492 temp_zone, data->info(), data->jsgraph(), data->loop_assignment(), 515 temp_zone, data->info(), data->jsgraph(), data->loop_assignment(),
493 data->source_positions()); 516 data->type_hint_analysis(), data->source_positions());
494 succeeded = graph_builder.CreateGraph(stack_check); 517 succeeded = graph_builder.CreateGraph(stack_check);
495 } 518 }
496 519
497 if (!succeeded) { 520 if (!succeeded) {
498 data->set_compilation_failed(); 521 data->set_compilation_failed();
499 } 522 }
500 } 523 }
501 }; 524 };
502 525
503 526
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 TurboCfgFile tcf(isolate()); 1090 TurboCfgFile tcf(isolate());
1068 tcf << AsC1VCompilation(info()); 1091 tcf << AsC1VCompilation(info());
1069 } 1092 }
1070 1093
1071 data.source_positions()->AddDecorator(); 1094 data.source_positions()->AddDecorator();
1072 1095
1073 if (FLAG_loop_assignment_analysis) { 1096 if (FLAG_loop_assignment_analysis) {
1074 Run<LoopAssignmentAnalysisPhase>(); 1097 Run<LoopAssignmentAnalysisPhase>();
1075 } 1098 }
1076 1099
1100 if (info()->is_typing_enabled()) {
1101 Run<TypeHintAnalysisPhase>();
1102 }
1103
1077 Run<GraphBuilderPhase>(); 1104 Run<GraphBuilderPhase>();
1078 if (data.compilation_failed()) return Handle<Code>::null(); 1105 if (data.compilation_failed()) return Handle<Code>::null();
1079 RunPrintAndVerify("Initial untyped", true); 1106 RunPrintAndVerify("Initial untyped", true);
1080 1107
1081 // Perform OSR deconstruction. 1108 // Perform OSR deconstruction.
1082 if (info()->is_osr()) { 1109 if (info()->is_osr()) {
1083 Run<OsrDeconstructionPhase>(); 1110 Run<OsrDeconstructionPhase>();
1084 RunPrintAndVerify("OSR deconstruction", true); 1111 RunPrintAndVerify("OSR deconstruction", true);
1085 } 1112 }
1086 1113
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 tcf << AsC1VRegisterAllocationData("CodeGen", 1451 tcf << AsC1VRegisterAllocationData("CodeGen",
1425 data->register_allocation_data()); 1452 data->register_allocation_data());
1426 } 1453 }
1427 1454
1428 data->DeleteRegisterAllocationZone(); 1455 data->DeleteRegisterAllocationZone();
1429 } 1456 }
1430 1457
1431 } // namespace compiler 1458 } // namespace compiler
1432 } // namespace internal 1459 } // namespace internal
1433 } // namespace v8 1460 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698