OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 builder_->set_current_block(exit_block_); | 823 builder_->set_current_block(exit_block_); |
824 // Pop the phi from the expression stack | 824 // Pop the phi from the expression stack |
825 builder_->environment()->Pop(); | 825 builder_->environment()->Pop(); |
826 finished_ = true; | 826 finished_ = true; |
827 } | 827 } |
828 | 828 |
829 | 829 |
830 HGraph* HGraphBuilder::CreateGraph() { | 830 HGraph* HGraphBuilder::CreateGraph() { |
831 graph_ = new(zone()) HGraph(info_); | 831 graph_ = new(zone()) HGraph(info_); |
832 if (FLAG_hydrogen_stats) HStatistics::Instance()->Initialize(info_); | 832 if (FLAG_hydrogen_stats) HStatistics::Instance()->Initialize(info_); |
833 HPhase phase("H_Block building"); | 833 HPhase phase("H_Block building", graph()->isolate()); |
834 set_current_block(graph()->entry_block()); | 834 set_current_block(graph()->entry_block()); |
835 if (!BuildGraph()) return NULL; | 835 if (!BuildGraph()) return NULL; |
836 return graph_; | 836 return graph_; |
837 } | 837 } |
838 | 838 |
839 | 839 |
840 HInstruction* HGraphBuilder::AddInstruction(HInstruction* instr) { | 840 HInstruction* HGraphBuilder::AddInstruction(HInstruction* instr) { |
841 ASSERT(current_block() != NULL); | 841 ASSERT(current_block() != NULL); |
842 current_block()->AddInstruction(instr); | 842 current_block()->AddInstruction(instr); |
843 return instr; | 843 return instr; |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1546 HLoopInformation* loop_; | 1546 HLoopInformation* loop_; |
1547 HBasicBlock* block_; | 1547 HBasicBlock* block_; |
1548 HBasicBlock* loop_header_; | 1548 HBasicBlock* loop_header_; |
1549 int loop_index; | 1549 int loop_index; |
1550 int loop_length; | 1550 int loop_length; |
1551 HSuccessorIterator successor_iterator; | 1551 HSuccessorIterator successor_iterator; |
1552 }; | 1552 }; |
1553 | 1553 |
1554 | 1554 |
1555 void HGraph::OrderBlocks() { | 1555 void HGraph::OrderBlocks() { |
1556 HPhase phase("H_Block ordering"); | 1556 HPhase phase("H_Block ordering", isolate()); |
1557 BitVector visited(blocks_.length(), zone()); | 1557 BitVector visited(blocks_.length(), zone()); |
1558 | 1558 |
1559 ZoneList<HBasicBlock*> reverse_result(8, zone()); | 1559 ZoneList<HBasicBlock*> reverse_result(8, zone()); |
1560 HBasicBlock* start = blocks_[0]; | 1560 HBasicBlock* start = blocks_[0]; |
1561 PostorderProcessor* postorder = | 1561 PostorderProcessor* postorder = |
1562 PostorderProcessor::CreateEntryProcessor(zone(), start, &visited); | 1562 PostorderProcessor::CreateEntryProcessor(zone(), start, &visited); |
1563 while (postorder != NULL) { | 1563 while (postorder != NULL) { |
1564 postorder = postorder->PerformStep(zone(), &visited, &reverse_result); | 1564 postorder = postorder->PerformStep(zone(), &visited, &reverse_result); |
1565 } | 1565 } |
1566 blocks_.Rewind(0); | 1566 blocks_.Rewind(0); |
(...skipping 9139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10706 } | 10706 } |
10707 current_pos = current_pos->next(); | 10707 current_pos = current_pos->next(); |
10708 } | 10708 } |
10709 | 10709 |
10710 trace_.Add(" \"\"\n"); | 10710 trace_.Add(" \"\"\n"); |
10711 } | 10711 } |
10712 } | 10712 } |
10713 | 10713 |
10714 | 10714 |
10715 void HTracer::FlushToFile() { | 10715 void HTracer::FlushToFile() { |
10716 AppendChars(filename_, *trace_.ToCString(), trace_.length(), false); | 10716 AppendChars(filename_.start(), *trace_.ToCString(), trace_.length(), false); |
10717 trace_.Reset(); | 10717 trace_.Reset(); |
10718 } | 10718 } |
10719 | 10719 |
10720 | 10720 |
10721 void HStatistics::Initialize(CompilationInfo* info) { | 10721 void HStatistics::Initialize(CompilationInfo* info) { |
10722 if (info->shared_info().is_null()) return; | 10722 if (info->shared_info().is_null()) return; |
10723 source_size_ += info->shared_info()->SourceSize(); | 10723 source_size_ += info->shared_info()->SourceSize(); |
10724 } | 10724 } |
10725 | 10725 |
10726 | 10726 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10791 } | 10791 } |
10792 names_.Add(name); | 10792 names_.Add(name); |
10793 timing_.Add(ticks); | 10793 timing_.Add(ticks); |
10794 sizes_.Add(size); | 10794 sizes_.Add(size); |
10795 } | 10795 } |
10796 } | 10796 } |
10797 | 10797 |
10798 | 10798 |
10799 const char* const HPhase::kFullCodeGen = "Full code generator"; | 10799 const char* const HPhase::kFullCodeGen = "Full code generator"; |
10800 | 10800 |
10801 void HPhase::Begin(const char* name, | 10801 |
10802 HGraph* graph, | 10802 HPhase::HPhase(const char* name, Isolate* isolate) { |
10803 LChunk* chunk, | 10803 Init(isolate, name, NULL, NULL, NULL); |
10804 LAllocator* allocator) { | 10804 } |
| 10805 |
| 10806 |
| 10807 HPhase::HPhase(const char* name, HGraph* graph) { |
| 10808 Init(graph->isolate(), name, graph, NULL, NULL); |
| 10809 } |
| 10810 |
| 10811 |
| 10812 HPhase::HPhase(const char* name, LChunk* chunk) { |
| 10813 Init(chunk->graph()->isolate(), name, NULL, chunk, NULL); |
| 10814 } |
| 10815 |
| 10816 |
| 10817 HPhase::HPhase(const char* name, LAllocator* allocator) { |
| 10818 Init(allocator->graph()->isolate(), name, NULL, NULL, allocator); |
| 10819 } |
| 10820 |
| 10821 |
| 10822 void HPhase::Init(Isolate* isolate, |
| 10823 const char* name, |
| 10824 HGraph* graph, |
| 10825 LChunk* chunk, |
| 10826 LAllocator* allocator) { |
| 10827 isolate_ = isolate; |
10805 name_ = name; | 10828 name_ = name; |
10806 graph_ = graph; | 10829 graph_ = graph; |
10807 chunk_ = chunk; | 10830 chunk_ = chunk; |
10808 allocator_ = allocator; | 10831 allocator_ = allocator; |
10809 if (allocator != NULL && chunk_ == NULL) { | 10832 if (allocator != NULL && chunk_ == NULL) { |
10810 chunk_ = allocator->chunk(); | 10833 chunk_ = allocator->chunk(); |
10811 } | 10834 } |
10812 if (FLAG_hydrogen_stats) start_ = OS::Ticks(); | 10835 if (FLAG_hydrogen_stats) { |
10813 start_allocation_size_ = Zone::allocation_size_; | 10836 start_ticks_ = OS::Ticks(); |
| 10837 start_allocation_size_ = Zone::allocation_size_; |
| 10838 } |
10814 } | 10839 } |
10815 | 10840 |
10816 | 10841 |
10817 void HPhase::End() const { | 10842 HPhase::~HPhase() { |
10818 if (FLAG_hydrogen_stats) { | 10843 if (FLAG_hydrogen_stats) { |
10819 int64_t end = OS::Ticks(); | 10844 int64_t ticks = OS::Ticks() - start_ticks_; |
10820 unsigned size = Zone::allocation_size_ - start_allocation_size_; | 10845 unsigned size = Zone::allocation_size_ - start_allocation_size_; |
10821 HStatistics::Instance()->SaveTiming(name_, end - start_, size); | 10846 HStatistics::Instance()->SaveTiming(name_, ticks, size); |
10822 } | 10847 } |
10823 | 10848 |
10824 // Produce trace output if flag is set so that the first letter of the | 10849 // Produce trace output if flag is set so that the first letter of the |
10825 // phase name matches the command line parameter FLAG_trace_phase. | 10850 // phase name matches the command line parameter FLAG_trace_phase. |
10826 if (FLAG_trace_hydrogen && | 10851 if (FLAG_trace_hydrogen && |
10827 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL) { | 10852 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL) { |
10828 if (graph_ != NULL) HTracer::Instance()->TraceHydrogen(name_, graph_); | 10853 if (graph_ != NULL) { |
10829 if (chunk_ != NULL) HTracer::Instance()->TraceLithium(name_, chunk_); | 10854 isolate_->GetHTracer()->TraceHydrogen(name_, graph_); |
| 10855 } |
| 10856 if (chunk_ != NULL) { |
| 10857 isolate_->GetHTracer()->TraceLithium(name_, chunk_); |
| 10858 } |
10830 if (allocator_ != NULL) { | 10859 if (allocator_ != NULL) { |
10831 HTracer::Instance()->TraceLiveRanges(name_, allocator_); | 10860 isolate_->GetHTracer()->TraceLiveRanges(name_, allocator_); |
10832 } | 10861 } |
10833 } | 10862 } |
10834 | 10863 |
10835 #ifdef DEBUG | 10864 #ifdef DEBUG |
10836 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 10865 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
10837 if (allocator_ != NULL) allocator_->Verify(); | 10866 if (allocator_ != NULL) allocator_->Verify(); |
10838 #endif | 10867 #endif |
10839 } | 10868 } |
10840 | 10869 |
10841 } } // namespace v8::internal | 10870 } } // namespace v8::internal |
OLD | NEW |