| 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 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 builder_->set_current_block(exit_block_); | 956 builder_->set_current_block(exit_block_); |
| 957 // Pop the phi from the expression stack | 957 // Pop the phi from the expression stack |
| 958 builder_->environment()->Pop(); | 958 builder_->environment()->Pop(); |
| 959 finished_ = true; | 959 finished_ = true; |
| 960 } | 960 } |
| 961 | 961 |
| 962 | 962 |
| 963 HGraph* HGraphBuilder::CreateGraph() { | 963 HGraph* HGraphBuilder::CreateGraph() { |
| 964 graph_ = new(zone()) HGraph(info_); | 964 graph_ = new(zone()) HGraph(info_); |
| 965 if (FLAG_hydrogen_stats) isolate()->GetHStatistics()->Initialize(info_); | 965 if (FLAG_hydrogen_stats) isolate()->GetHStatistics()->Initialize(info_); |
| 966 HPhase phase("H_Block building", isolate(), zone()); | 966 CompilationPhase phase("H_Block building", isolate(), zone()); |
| 967 set_current_block(graph()->entry_block()); | 967 set_current_block(graph()->entry_block()); |
| 968 if (!BuildGraph()) return NULL; | 968 if (!BuildGraph()) return NULL; |
| 969 graph()->FinalizeUniqueValueIds(); | 969 graph()->FinalizeUniqueValueIds(); |
| 970 return graph_; | 970 return graph_; |
| 971 } | 971 } |
| 972 | 972 |
| 973 | 973 |
| 974 HInstruction* HGraphBuilder::AddInstruction(HInstruction* instr) { | 974 HInstruction* HGraphBuilder::AddInstruction(HInstruction* instr) { |
| 975 ASSERT(current_block() != NULL); | 975 ASSERT(current_block() != NULL); |
| 976 current_block()->AddInstruction(instr); | 976 current_block()->AddInstruction(instr); |
| (...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2377 HLoopInformation* loop_; | 2377 HLoopInformation* loop_; |
| 2378 HBasicBlock* block_; | 2378 HBasicBlock* block_; |
| 2379 HBasicBlock* loop_header_; | 2379 HBasicBlock* loop_header_; |
| 2380 int loop_index; | 2380 int loop_index; |
| 2381 int loop_length; | 2381 int loop_length; |
| 2382 HSuccessorIterator successor_iterator; | 2382 HSuccessorIterator successor_iterator; |
| 2383 }; | 2383 }; |
| 2384 | 2384 |
| 2385 | 2385 |
| 2386 void HGraph::OrderBlocks() { | 2386 void HGraph::OrderBlocks() { |
| 2387 HPhase phase("H_Block ordering", isolate(), zone()); | 2387 CompilationPhase phase("H_Block ordering", isolate(), zone()); |
| 2388 BitVector visited(blocks_.length(), zone()); | 2388 BitVector visited(blocks_.length(), zone()); |
| 2389 | 2389 |
| 2390 ZoneList<HBasicBlock*> reverse_result(8, zone()); | 2390 ZoneList<HBasicBlock*> reverse_result(8, zone()); |
| 2391 HBasicBlock* start = blocks_[0]; | 2391 HBasicBlock* start = blocks_[0]; |
| 2392 PostorderProcessor* postorder = | 2392 PostorderProcessor* postorder = |
| 2393 PostorderProcessor::CreateEntryProcessor(zone(), start, &visited); | 2393 PostorderProcessor::CreateEntryProcessor(zone(), start, &visited); |
| 2394 while (postorder != NULL) { | 2394 while (postorder != NULL) { |
| 2395 postorder = postorder->PerformStep(zone(), &visited, &reverse_result); | 2395 postorder = postorder->PerformStep(zone(), &visited, &reverse_result); |
| 2396 } | 2396 } |
| 2397 blocks_.Rewind(0); | 2397 blocks_.Rewind(0); |
| (...skipping 9094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11492 double normalized_size_in_kb = source_size_in_kb > 0 | 11492 double normalized_size_in_kb = source_size_in_kb > 0 |
| 11493 ? total_size_ / 1024 / source_size_in_kb | 11493 ? total_size_ / 1024 / source_size_in_kb |
| 11494 : 0; | 11494 : 0; |
| 11495 PrintF("%30s - %8.3f ms %7.3f kB allocated\n", | 11495 PrintF("%30s - %8.3f ms %7.3f kB allocated\n", |
| 11496 "Average per kB source", | 11496 "Average per kB source", |
| 11497 normalized_time, normalized_size_in_kb); | 11497 normalized_time, normalized_size_in_kb); |
| 11498 } | 11498 } |
| 11499 | 11499 |
| 11500 | 11500 |
| 11501 void HStatistics::SaveTiming(const char* name, int64_t ticks, unsigned size) { | 11501 void HStatistics::SaveTiming(const char* name, int64_t ticks, unsigned size) { |
| 11502 if (name == HPhase::kFullCodeGen) { | 11502 total_size_ += size; |
| 11503 full_code_gen_ += ticks; | 11503 for (int i = 0; i < names_.length(); ++i) { |
| 11504 } else { | 11504 if (strcmp(names_[i], name) == 0) { |
| 11505 total_size_ += size; | 11505 timing_[i] += ticks; |
| 11506 for (int i = 0; i < names_.length(); ++i) { | 11506 sizes_[i] += size; |
| 11507 if (strcmp(names_[i], name) == 0) { | 11507 return; |
| 11508 timing_[i] += ticks; | |
| 11509 sizes_[i] += size; | |
| 11510 return; | |
| 11511 } | |
| 11512 } | 11508 } |
| 11513 names_.Add(name); | |
| 11514 timing_.Add(ticks); | |
| 11515 sizes_.Add(size); | |
| 11516 } | 11509 } |
| 11510 names_.Add(name); |
| 11511 timing_.Add(ticks); |
| 11512 sizes_.Add(size); |
| 11517 } | 11513 } |
| 11518 | 11514 |
| 11519 | 11515 |
| 11520 const char* const HPhase::kFullCodeGen = "Full code generator"; | 11516 HPhase::HPhase(const char* name, HGraph* graph) |
| 11521 | 11517 : CompilationPhase(name, graph->isolate(), graph->zone()), graph_(graph) { } |
| 11522 | |
| 11523 HPhase::HPhase(const char* name, Isolate* isolate, Zone* zone) { | |
| 11524 Init(isolate, name, zone, NULL, NULL, NULL); | |
| 11525 } | |
| 11526 | |
| 11527 | |
| 11528 HPhase::HPhase(const char* name, HGraph* graph) { | |
| 11529 Init(graph->isolate(), name, graph->zone(), graph, NULL, NULL); | |
| 11530 } | |
| 11531 | |
| 11532 | |
| 11533 HPhase::HPhase(const char* name, LChunk* chunk) { | |
| 11534 Init(chunk->isolate(), name, chunk->zone(), NULL, chunk, NULL); | |
| 11535 } | |
| 11536 | |
| 11537 | |
| 11538 HPhase::HPhase(const char* name, LAllocator* allocator) { | |
| 11539 Init(allocator->isolate(), name, allocator->zone(), NULL, NULL, allocator); | |
| 11540 } | |
| 11541 | |
| 11542 | |
| 11543 void HPhase::Init(Isolate* isolate, | |
| 11544 const char* name, | |
| 11545 Zone* zone, | |
| 11546 HGraph* graph, | |
| 11547 LChunk* chunk, | |
| 11548 LAllocator* allocator) { | |
| 11549 isolate_ = isolate; | |
| 11550 name_ = name; | |
| 11551 zone_ = zone; | |
| 11552 graph_ = graph; | |
| 11553 chunk_ = chunk; | |
| 11554 allocator_ = allocator; | |
| 11555 if (allocator != NULL && chunk_ == NULL) { | |
| 11556 chunk_ = allocator->chunk(); | |
| 11557 } | |
| 11558 if (FLAG_hydrogen_stats) { | |
| 11559 start_ticks_ = OS::Ticks(); | |
| 11560 start_allocation_size_ = zone_->allocation_size(); | |
| 11561 } | |
| 11562 } | |
| 11563 | 11518 |
| 11564 | 11519 |
| 11565 HPhase::~HPhase() { | 11520 HPhase::~HPhase() { |
| 11566 if (FLAG_hydrogen_stats) { | 11521 if (ShouldProduceTraceOutput()) { |
| 11567 int64_t ticks = OS::Ticks() - start_ticks_; | 11522 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 11568 unsigned size = zone_->allocation_size() - start_allocation_size_; | |
| 11569 isolate_->GetHStatistics()->SaveTiming(name_, ticks, size); | |
| 11570 } | |
| 11571 | |
| 11572 // Produce trace output if flag is set so that the first letter of the | |
| 11573 // phase name matches the command line parameter FLAG_trace_phase. | |
| 11574 if (FLAG_trace_hydrogen && | |
| 11575 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL) { | |
| 11576 if (graph_ != NULL) { | |
| 11577 isolate_->GetHTracer()->TraceHydrogen(name_, graph_); | |
| 11578 } | |
| 11579 if (chunk_ != NULL) { | |
| 11580 isolate_->GetHTracer()->TraceLithium(name_, chunk_); | |
| 11581 } | |
| 11582 if (allocator_ != NULL) { | |
| 11583 isolate_->GetHTracer()->TraceLiveRanges(name_, allocator_); | |
| 11584 } | |
| 11585 } | 11523 } |
| 11586 | 11524 |
| 11587 #ifdef DEBUG | 11525 #ifdef DEBUG |
| 11588 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 11526 graph_->Verify(false); // No full verify. |
| 11589 if (allocator_ != NULL) allocator_->Verify(); | |
| 11590 #endif | 11527 #endif |
| 11591 } | 11528 } |
| 11592 | 11529 |
| 11593 } } // namespace v8::internal | 11530 } } // namespace v8::internal |
| OLD | NEW |