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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 // For main entry point. | 78 // For main entry point. |
79 PipelineData(ZonePool* zone_pool, CompilationInfo* info, | 79 PipelineData(ZonePool* zone_pool, CompilationInfo* info, |
80 PipelineStatistics* pipeline_statistics) | 80 PipelineStatistics* pipeline_statistics) |
81 : isolate_(info->isolate()), | 81 : isolate_(info->isolate()), |
82 info_(info), | 82 info_(info), |
83 outer_zone_(info_->zone()), | 83 outer_zone_(info_->zone()), |
84 zone_pool_(zone_pool), | 84 zone_pool_(zone_pool), |
85 pipeline_statistics_(pipeline_statistics), | 85 pipeline_statistics_(pipeline_statistics), |
86 compilation_failed_(false), | 86 compilation_failed_(false), |
87 code_(Handle<Code>::null()), | 87 code_(Handle<Code>::null()), |
88 profiler_data_(nullptr), | |
88 graph_zone_scope_(zone_pool_), | 89 graph_zone_scope_(zone_pool_), |
89 graph_zone_(graph_zone_scope_.zone()), | 90 graph_zone_(graph_zone_scope_.zone()), |
90 graph_(nullptr), | 91 graph_(nullptr), |
91 loop_assignment_(nullptr), | 92 loop_assignment_(nullptr), |
92 simplified_(nullptr), | 93 simplified_(nullptr), |
93 machine_(nullptr), | 94 machine_(nullptr), |
94 common_(nullptr), | 95 common_(nullptr), |
95 javascript_(nullptr), | 96 javascript_(nullptr), |
96 jsgraph_(nullptr), | 97 jsgraph_(nullptr), |
97 schedule_(nullptr), | 98 schedule_(nullptr), |
(...skipping 20 matching lines...) Expand all Loading... | |
118 // For machine graph testing entry point. | 119 // For machine graph testing entry point. |
119 PipelineData(ZonePool* zone_pool, CompilationInfo* info, Graph* graph, | 120 PipelineData(ZonePool* zone_pool, CompilationInfo* info, Graph* graph, |
120 Schedule* schedule) | 121 Schedule* schedule) |
121 : isolate_(info->isolate()), | 122 : isolate_(info->isolate()), |
122 info_(info), | 123 info_(info), |
123 outer_zone_(nullptr), | 124 outer_zone_(nullptr), |
124 zone_pool_(zone_pool), | 125 zone_pool_(zone_pool), |
125 pipeline_statistics_(nullptr), | 126 pipeline_statistics_(nullptr), |
126 compilation_failed_(false), | 127 compilation_failed_(false), |
127 code_(Handle<Code>::null()), | 128 code_(Handle<Code>::null()), |
129 profiler_data_(nullptr), | |
128 graph_zone_scope_(zone_pool_), | 130 graph_zone_scope_(zone_pool_), |
129 graph_zone_(nullptr), | 131 graph_zone_(nullptr), |
130 graph_(graph), | 132 graph_(graph), |
131 source_positions_(new SourcePositionTable(graph_)), | 133 source_positions_(new SourcePositionTable(graph_)), |
132 loop_assignment_(nullptr), | 134 loop_assignment_(nullptr), |
133 simplified_(nullptr), | 135 simplified_(nullptr), |
134 machine_(nullptr), | 136 machine_(nullptr), |
135 common_(nullptr), | 137 common_(nullptr), |
136 javascript_(nullptr), | 138 javascript_(nullptr), |
137 jsgraph_(nullptr), | 139 jsgraph_(nullptr), |
138 schedule_(schedule), | 140 schedule_(schedule), |
139 instruction_zone_scope_(zone_pool_), | 141 instruction_zone_scope_(zone_pool_), |
140 instruction_zone_(instruction_zone_scope_.zone()), | 142 instruction_zone_(instruction_zone_scope_.zone()), |
141 sequence_(nullptr), | 143 sequence_(nullptr), |
142 frame_(nullptr), | 144 frame_(nullptr), |
143 register_allocation_zone_scope_(zone_pool_), | 145 register_allocation_zone_scope_(zone_pool_), |
144 register_allocation_zone_(register_allocation_zone_scope_.zone()), | 146 register_allocation_zone_(register_allocation_zone_scope_.zone()), |
145 register_allocation_data_(nullptr) {} | 147 register_allocation_data_(nullptr) {} |
146 | 148 |
147 // For register allocation testing entry point. | 149 // For register allocation testing entry point. |
148 PipelineData(ZonePool* zone_pool, CompilationInfo* info, | 150 PipelineData(ZonePool* zone_pool, CompilationInfo* info, |
149 InstructionSequence* sequence) | 151 InstructionSequence* sequence) |
150 : isolate_(info->isolate()), | 152 : isolate_(info->isolate()), |
151 info_(info), | 153 info_(info), |
152 outer_zone_(nullptr), | 154 outer_zone_(nullptr), |
153 zone_pool_(zone_pool), | 155 zone_pool_(zone_pool), |
154 pipeline_statistics_(nullptr), | 156 pipeline_statistics_(nullptr), |
155 compilation_failed_(false), | 157 compilation_failed_(false), |
156 code_(Handle<Code>::null()), | 158 code_(Handle<Code>::null()), |
159 profiler_data_(nullptr), | |
157 graph_zone_scope_(zone_pool_), | 160 graph_zone_scope_(zone_pool_), |
158 graph_zone_(nullptr), | 161 graph_zone_(nullptr), |
159 graph_(nullptr), | 162 graph_(nullptr), |
160 loop_assignment_(nullptr), | 163 loop_assignment_(nullptr), |
161 simplified_(nullptr), | 164 simplified_(nullptr), |
162 machine_(nullptr), | 165 machine_(nullptr), |
163 common_(nullptr), | 166 common_(nullptr), |
164 javascript_(nullptr), | 167 javascript_(nullptr), |
165 jsgraph_(nullptr), | 168 jsgraph_(nullptr), |
166 schedule_(nullptr), | 169 schedule_(nullptr), |
(...skipping 17 matching lines...) Expand all Loading... | |
184 CompilationInfo* info() const { return info_; } | 187 CompilationInfo* info() const { return info_; } |
185 ZonePool* zone_pool() const { return zone_pool_; } | 188 ZonePool* zone_pool() const { return zone_pool_; } |
186 PipelineStatistics* pipeline_statistics() { return pipeline_statistics_; } | 189 PipelineStatistics* pipeline_statistics() { return pipeline_statistics_; } |
187 bool compilation_failed() const { return compilation_failed_; } | 190 bool compilation_failed() const { return compilation_failed_; } |
188 void set_compilation_failed() { compilation_failed_ = true; } | 191 void set_compilation_failed() { compilation_failed_ = true; } |
189 Handle<Code> code() { return code_; } | 192 Handle<Code> code() { return code_; } |
190 void set_code(Handle<Code> code) { | 193 void set_code(Handle<Code> code) { |
191 DCHECK(code_.is_null()); | 194 DCHECK(code_.is_null()); |
192 code_ = code; | 195 code_ = code; |
193 } | 196 } |
194 | 197 BasicBlockProfiler::Data* profiler_data() { return profiler_data_; } |
198 void set_profiler_data(BasicBlockProfiler::Data* data) { | |
199 profiler_data_ = data; | |
200 } | |
201 std::ostringstream* source_position_output() { | |
202 return &source_position_output_; | |
203 } | |
195 // RawMachineAssembler generally produces graphs which cannot be verified. | 204 // RawMachineAssembler generally produces graphs which cannot be verified. |
196 bool MayHaveUnverifiableGraph() const { return outer_zone_ == nullptr; } | 205 bool MayHaveUnverifiableGraph() const { return outer_zone_ == nullptr; } |
197 | 206 |
198 Zone* graph_zone() const { return graph_zone_; } | 207 Zone* graph_zone() const { return graph_zone_; } |
199 Graph* graph() const { return graph_; } | 208 Graph* graph() const { return graph_; } |
200 SourcePositionTable* source_positions() const { | 209 SourcePositionTable* source_positions() const { |
201 return source_positions_.get(); | 210 return source_positions_.get(); |
202 } | 211 } |
203 MachineOperatorBuilder* machine() const { return machine_; } | 212 MachineOperatorBuilder* machine() const { return machine_; } |
204 CommonOperatorBuilder* common() const { return common_; } | 213 CommonOperatorBuilder* common() const { return common_; } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
306 } | 315 } |
307 | 316 |
308 private: | 317 private: |
309 Isolate* isolate_; | 318 Isolate* isolate_; |
310 CompilationInfo* info_; | 319 CompilationInfo* info_; |
311 Zone* outer_zone_; | 320 Zone* outer_zone_; |
312 ZonePool* const zone_pool_; | 321 ZonePool* const zone_pool_; |
313 PipelineStatistics* pipeline_statistics_; | 322 PipelineStatistics* pipeline_statistics_; |
314 bool compilation_failed_; | 323 bool compilation_failed_; |
315 Handle<Code> code_; | 324 Handle<Code> code_; |
325 BasicBlockProfiler::Data* profiler_data_; | |
326 std::ostringstream source_position_output_; | |
316 | 327 |
317 // All objects in the following group of fields are allocated in graph_zone_. | 328 // All objects in the following group of fields are allocated in graph_zone_. |
318 // They are all set to nullptr when the graph_zone_ is destroyed. | 329 // They are all set to nullptr when the graph_zone_ is destroyed. |
319 ZonePool::Scope graph_zone_scope_; | 330 ZonePool::Scope graph_zone_scope_; |
320 Zone* graph_zone_; | 331 Zone* graph_zone_; |
321 Graph* graph_; | 332 Graph* graph_; |
322 // TODO(dcarney): make this into a ZoneObject. | 333 // TODO(dcarney): make this into a ZoneObject. |
323 base::SmartPointer<SourcePositionTable> source_positions_; | 334 base::SmartPointer<SourcePositionTable> source_positions_; |
324 LoopAssignmentAnalysis* loop_assignment_; | 335 LoopAssignmentAnalysis* loop_assignment_; |
325 TypeHintAnalysis* type_hint_analysis_ = nullptr; | 336 TypeHintAnalysis* type_hint_analysis_ = nullptr; |
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1397 | 1408 |
1398 return pipeline.ScheduleAndGenerateCode(call_descriptor); | 1409 return pipeline.ScheduleAndGenerateCode(call_descriptor); |
1399 } | 1410 } |
1400 | 1411 |
1401 void Pipeline::InitializeWasmCompilation(Zone* pipeline_zone, | 1412 void Pipeline::InitializeWasmCompilation(Zone* pipeline_zone, |
1402 ZonePool* zone_pool, Graph* graph) { | 1413 ZonePool* zone_pool, Graph* graph) { |
1403 data_ = new (pipeline_zone) PipelineData(zone_pool, info(), graph, nullptr); | 1414 data_ = new (pipeline_zone) PipelineData(zone_pool, info(), graph, nullptr); |
1404 RunPrintAndVerify("Machine", true); | 1415 RunPrintAndVerify("Machine", true); |
1405 } | 1416 } |
1406 | 1417 |
1407 void Pipeline::FinalizeWasmCompilation() { data_->Destroy(); } | 1418 bool Pipeline::ExecuteWasmCompilation(CallDescriptor* descriptor) { |
Michael Starzinger
2016/04/20 16:59:08
This duplicates quite a lot of complex logic. We c
ahaas
2016/04/21 07:59:43
I use the same code for the new functions and Sche
| |
1419 PipelineData* data = this->data_; | |
1420 DCHECK_NOT_NULL(data); | |
1421 DCHECK_NOT_NULL(data->graph()); | |
1422 | |
1423 if (data->schedule() == nullptr) Run<ComputeSchedulePhase>(); | |
1424 TraceSchedule(data->info(), data->schedule()); | |
1425 | |
1426 if (FLAG_turbo_profiling) { | |
1427 data->set_profiler_data(BasicBlockInstrumentor::Instrument( | |
1428 info(), data->graph(), data->schedule())); | |
1429 } | |
1430 | |
1431 data->InitializeInstructionSequence(descriptor); | |
1432 | |
1433 data->InitializeFrameData(descriptor); | |
1434 // Select and schedule instructions covering the scheduled graph. | |
1435 Linkage linkage(descriptor); | |
1436 Run<InstructionSelectionPhase>(&linkage); | |
1437 | |
1438 if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) { | |
1439 TurboCfgFile tcf(isolate()); | |
1440 tcf << AsC1V("CodeGen", data->schedule(), data->source_positions(), | |
1441 data->sequence()); | |
1442 } | |
1443 | |
1444 if (FLAG_trace_turbo) { | |
1445 // Output source position information before the graph is deleted. | |
1446 data_->source_positions()->Print(*(data->source_position_output())); | |
1447 } | |
1448 | |
1449 data->DeleteGraphZone(); | |
1450 | |
1451 BeginPhaseKind("register allocation"); | |
1452 | |
1453 bool run_verifier = FLAG_turbo_verify_allocation; | |
1454 | |
1455 // Allocate registers. | |
1456 AllocateRegisters( | |
1457 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN), | |
1458 descriptor, run_verifier); | |
1459 Run<FrameElisionPhase>(); | |
1460 if (data->compilation_failed()) { | |
1461 info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); | |
1462 return false; | |
1463 } | |
1464 | |
1465 BeginPhaseKind("code generation"); | |
1466 // TODO(mtrofin): move this off to the register allocator. | |
1467 bool generate_frame_at_start = | |
1468 data_->sequence()->instruction_blocks().front()->must_construct_frame(); | |
1469 // Optimimize jumps. | |
1470 if (FLAG_turbo_jt) { | |
1471 Run<JumpThreadingPhase>(generate_frame_at_start); | |
1472 } | |
1473 return true; | |
1474 } | |
1475 | |
1476 Handle<Code> Pipeline::FinalizeWasmCompilation(CallDescriptor* descriptor) { | |
1477 PipelineData* data = this->data_; | |
1478 Linkage linkage(descriptor); | |
1479 // Generate final machine code. | |
1480 Run<GenerateCodePhase>(&linkage); | |
1481 | |
1482 Handle<Code> code = data->code(); | |
1483 if (data->profiler_data() != nullptr) { | |
1484 #if ENABLE_DISASSEMBLER | |
1485 std::ostringstream os; | |
1486 code->Disassemble(nullptr, os); | |
1487 data->profiler_data()->SetCode(&os); | |
1488 #endif | |
1489 } | |
1490 | |
1491 info()->SetCode(code); | |
1492 v8::internal::CodeGenerator::PrintCode(code, info()); | |
1493 | |
1494 if (FLAG_trace_turbo) { | |
1495 FILE* json_file = OpenVisualizerLogFile(info(), nullptr, "json", "a+"); | |
1496 if (json_file != nullptr) { | |
1497 OFStream json_of(json_file); | |
1498 json_of | |
1499 << "{\"name\":\"disassembly\",\"type\":\"disassembly\",\"data\":\""; | |
1500 #if ENABLE_DISASSEMBLER | |
1501 std::stringstream disassembly_stream; | |
1502 code->Disassemble(nullptr, disassembly_stream); | |
1503 std::string disassembly_string(disassembly_stream.str()); | |
1504 for (const auto& c : disassembly_string) { | |
1505 json_of << AsEscapedUC16ForJSON(c); | |
1506 } | |
1507 #endif // ENABLE_DISASSEMBLER | |
1508 json_of << "\"}\n],\n"; | |
1509 json_of << "\"nodePositions\":"; | |
1510 json_of << data->source_position_output()->str(); | |
1511 json_of << "}"; | |
1512 fclose(json_file); | |
1513 } | |
1514 OFStream os(stdout); | |
1515 os << "---------------------------------------------------\n" | |
1516 << "Finished compiling method " << info()->GetDebugName().get() | |
1517 << " using Turbofan" << std::endl; | |
1518 } | |
1519 data->Destroy(); | |
1520 return code; | |
1521 } | |
1408 | 1522 |
1409 OptimizedCompileJob* Pipeline::NewCompilationJob(CompilationInfo* info) { | 1523 OptimizedCompileJob* Pipeline::NewCompilationJob(CompilationInfo* info) { |
1410 return new (info->zone()) PipelineCompilationJob(info); | 1524 return new (info->zone()) PipelineCompilationJob(info); |
1411 } | 1525 } |
1412 | 1526 |
1413 bool Pipeline::AllocateRegistersForTesting(const RegisterConfiguration* config, | 1527 bool Pipeline::AllocateRegistersForTesting(const RegisterConfiguration* config, |
1414 InstructionSequence* sequence, | 1528 InstructionSequence* sequence, |
1415 bool run_verifier) { | 1529 bool run_verifier) { |
1416 CompilationInfo info("testing", sequence->isolate(), sequence->zone()); | 1530 CompilationInfo info("testing", sequence->isolate(), sequence->zone()); |
1417 ZonePool zone_pool(sequence->isolate()->allocator()); | 1531 ZonePool zone_pool(sequence->isolate()->allocator()); |
1418 PipelineData data(&zone_pool, &info, sequence); | 1532 PipelineData data(&zone_pool, &info, sequence); |
1419 Pipeline pipeline(&info); | 1533 Pipeline pipeline(&info); |
1420 pipeline.data_ = &data; | 1534 pipeline.data_ = &data; |
1421 pipeline.data_->InitializeFrameData(nullptr); | 1535 pipeline.data_->InitializeFrameData(nullptr); |
1422 pipeline.AllocateRegisters(config, nullptr, run_verifier); | 1536 pipeline.AllocateRegisters(config, nullptr, run_verifier); |
1423 return !data.compilation_failed(); | 1537 return !data.compilation_failed(); |
1424 } | 1538 } |
1425 | 1539 |
1426 | |
1427 Handle<Code> Pipeline::ScheduleAndGenerateCode( | 1540 Handle<Code> Pipeline::ScheduleAndGenerateCode( |
1428 CallDescriptor* call_descriptor) { | 1541 CallDescriptor* call_descriptor) { |
1429 PipelineData* data = this->data_; | 1542 PipelineData* data = this->data_; |
1430 | |
1431 DCHECK_NOT_NULL(data); | 1543 DCHECK_NOT_NULL(data); |
1432 DCHECK_NOT_NULL(data->graph()); | 1544 DCHECK_NOT_NULL(data->graph()); |
1433 | 1545 |
1434 if (data->schedule() == nullptr) Run<ComputeSchedulePhase>(); | 1546 if (data->schedule() == nullptr) Run<ComputeSchedulePhase>(); |
1435 TraceSchedule(data->info(), data->schedule()); | 1547 TraceSchedule(data->info(), data->schedule()); |
1436 | 1548 |
1437 BasicBlockProfiler::Data* profiler_data = nullptr; | |
1438 if (FLAG_turbo_profiling) { | 1549 if (FLAG_turbo_profiling) { |
1439 profiler_data = BasicBlockInstrumentor::Instrument(info(), data->graph(), | 1550 data->set_profiler_data(BasicBlockInstrumentor::Instrument( |
1440 data->schedule()); | 1551 info(), data->graph(), data->schedule())); |
1441 } | 1552 } |
1442 | 1553 |
1443 data->InitializeInstructionSequence(call_descriptor); | 1554 data->InitializeInstructionSequence(call_descriptor); |
1444 | 1555 |
1445 data->InitializeFrameData(call_descriptor); | 1556 data->InitializeFrameData(call_descriptor); |
1446 // Select and schedule instructions covering the scheduled graph. | 1557 // Select and schedule instructions covering the scheduled graph. |
1447 Linkage linkage(call_descriptor); | 1558 Linkage linkage(call_descriptor); |
1448 Run<InstructionSelectionPhase>(&linkage); | 1559 Run<InstructionSelectionPhase>(&linkage); |
1449 | 1560 |
1450 if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) { | 1561 if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) { |
1451 TurboCfgFile tcf(isolate()); | 1562 TurboCfgFile tcf(isolate()); |
1452 tcf << AsC1V("CodeGen", data->schedule(), data->source_positions(), | 1563 tcf << AsC1V("CodeGen", data->schedule(), data->source_positions(), |
1453 data->sequence()); | 1564 data->sequence()); |
1454 } | 1565 } |
1455 | 1566 |
1456 std::ostringstream source_position_output; | |
1457 if (FLAG_trace_turbo) { | 1567 if (FLAG_trace_turbo) { |
1458 // Output source position information before the graph is deleted. | 1568 // Output source position information before the graph is deleted. |
1459 data_->source_positions()->Print(source_position_output); | 1569 data_->source_positions()->Print(*(data->source_position_output())); |
1460 } | 1570 } |
1461 | 1571 |
1462 data->DeleteGraphZone(); | 1572 data->DeleteGraphZone(); |
1463 | 1573 |
1464 BeginPhaseKind("register allocation"); | 1574 BeginPhaseKind("register allocation"); |
1465 | 1575 |
1466 bool run_verifier = FLAG_turbo_verify_allocation; | 1576 bool run_verifier = FLAG_turbo_verify_allocation; |
1467 | 1577 |
1468 // Allocate registers. | 1578 // Allocate registers. |
1469 AllocateRegisters( | 1579 AllocateRegisters( |
1470 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN), | 1580 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN), |
1471 call_descriptor, run_verifier); | 1581 call_descriptor, run_verifier); |
1472 Run<FrameElisionPhase>(); | 1582 Run<FrameElisionPhase>(); |
1473 if (data->compilation_failed()) { | 1583 if (data->compilation_failed()) { |
1474 info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); | 1584 info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); |
1475 return Handle<Code>(); | 1585 return Handle<Code>(); |
1476 } | 1586 } |
1477 | 1587 |
1478 BeginPhaseKind("code generation"); | 1588 BeginPhaseKind("code generation"); |
1479 // TODO(mtrofin): move this off to the register allocator. | 1589 // TODO(mtrofin): move this off to the register allocator. |
1480 bool generate_frame_at_start = | 1590 bool generate_frame_at_start = |
1481 data_->sequence()->instruction_blocks().front()->must_construct_frame(); | 1591 data_->sequence()->instruction_blocks().front()->must_construct_frame(); |
1482 // Optimimize jumps. | 1592 // Optimimize jumps. |
1483 if (FLAG_turbo_jt) { | 1593 if (FLAG_turbo_jt) { |
1484 Run<JumpThreadingPhase>(generate_frame_at_start); | 1594 Run<JumpThreadingPhase>(generate_frame_at_start); |
1485 } | 1595 } |
1486 | |
1487 // Generate final machine code. | 1596 // Generate final machine code. |
1488 Run<GenerateCodePhase>(&linkage); | 1597 Run<GenerateCodePhase>(&linkage); |
1489 | 1598 |
1490 Handle<Code> code = data->code(); | 1599 Handle<Code> code = data->code(); |
1491 if (profiler_data != nullptr) { | 1600 if (data->profiler_data() != nullptr) { |
1492 #if ENABLE_DISASSEMBLER | 1601 #if ENABLE_DISASSEMBLER |
1493 std::ostringstream os; | 1602 std::ostringstream os; |
1494 code->Disassemble(nullptr, os); | 1603 code->Disassemble(nullptr, os); |
1495 profiler_data->SetCode(&os); | 1604 data->profiler_data()->SetCode(&os); |
1496 #endif | 1605 #endif |
1497 } | 1606 } |
1498 | 1607 |
1499 info()->SetCode(code); | 1608 info()->SetCode(code); |
1500 v8::internal::CodeGenerator::PrintCode(code, info()); | 1609 v8::internal::CodeGenerator::PrintCode(code, info()); |
1501 | 1610 |
1502 if (FLAG_trace_turbo) { | 1611 if (FLAG_trace_turbo) { |
1503 FILE* json_file = OpenVisualizerLogFile(info(), nullptr, "json", "a+"); | 1612 FILE* json_file = OpenVisualizerLogFile(info(), nullptr, "json", "a+"); |
1504 if (json_file != nullptr) { | 1613 if (json_file != nullptr) { |
1505 OFStream json_of(json_file); | 1614 OFStream json_of(json_file); |
1506 json_of | 1615 json_of |
1507 << "{\"name\":\"disassembly\",\"type\":\"disassembly\",\"data\":\""; | 1616 << "{\"name\":\"disassembly\",\"type\":\"disassembly\",\"data\":\""; |
1508 #if ENABLE_DISASSEMBLER | 1617 #if ENABLE_DISASSEMBLER |
1509 std::stringstream disassembly_stream; | 1618 std::stringstream disassembly_stream; |
1510 code->Disassemble(nullptr, disassembly_stream); | 1619 code->Disassemble(nullptr, disassembly_stream); |
1511 std::string disassembly_string(disassembly_stream.str()); | 1620 std::string disassembly_string(disassembly_stream.str()); |
1512 for (const auto& c : disassembly_string) { | 1621 for (const auto& c : disassembly_string) { |
1513 json_of << AsEscapedUC16ForJSON(c); | 1622 json_of << AsEscapedUC16ForJSON(c); |
1514 } | 1623 } |
1515 #endif // ENABLE_DISASSEMBLER | 1624 #endif // ENABLE_DISASSEMBLER |
1516 json_of << "\"}\n],\n"; | 1625 json_of << "\"}\n],\n"; |
1517 json_of << "\"nodePositions\":"; | 1626 json_of << "\"nodePositions\":"; |
1518 json_of << source_position_output.str(); | 1627 json_of << data->source_position_output()->str(); |
1519 json_of << "}"; | 1628 json_of << "}"; |
1520 fclose(json_file); | 1629 fclose(json_file); |
1521 } | 1630 } |
1522 OFStream os(stdout); | 1631 OFStream os(stdout); |
1523 os << "---------------------------------------------------\n" | 1632 os << "---------------------------------------------------\n" |
1524 << "Finished compiling method " << info()->GetDebugName().get() | 1633 << "Finished compiling method " << info()->GetDebugName().get() |
1525 << " using Turbofan" << std::endl; | 1634 << " using Turbofan" << std::endl; |
1526 } | 1635 } |
1527 | |
1528 return code; | 1636 return code; |
1529 } | 1637 } |
1530 | 1638 |
1531 | |
1532 void Pipeline::AllocateRegisters(const RegisterConfiguration* config, | 1639 void Pipeline::AllocateRegisters(const RegisterConfiguration* config, |
1533 CallDescriptor* descriptor, | 1640 CallDescriptor* descriptor, |
1534 bool run_verifier) { | 1641 bool run_verifier) { |
1535 PipelineData* data = this->data_; | 1642 PipelineData* data = this->data_; |
1536 | 1643 |
1537 // Don't track usage for this zone in compiler stats. | 1644 // Don't track usage for this zone in compiler stats. |
1538 base::SmartPointer<Zone> verifier_zone; | 1645 base::SmartPointer<Zone> verifier_zone; |
1539 RegisterAllocatorVerifier* verifier = nullptr; | 1646 RegisterAllocatorVerifier* verifier = nullptr; |
1540 if (run_verifier) { | 1647 if (run_verifier) { |
1541 verifier_zone.Reset(new Zone(isolate()->allocator())); | 1648 verifier_zone.Reset(new Zone(isolate()->allocator())); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1618 } | 1725 } |
1619 | 1726 |
1620 data->DeleteRegisterAllocationZone(); | 1727 data->DeleteRegisterAllocationZone(); |
1621 } | 1728 } |
1622 | 1729 |
1623 Isolate* Pipeline::isolate() const { return info()->isolate(); } | 1730 Isolate* Pipeline::isolate() const { return info()->isolate(); } |
1624 | 1731 |
1625 } // namespace compiler | 1732 } // namespace compiler |
1626 } // namespace internal | 1733 } // namespace internal |
1627 } // namespace v8 | 1734 } // namespace v8 |
OLD | NEW |