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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 | 510 |
511 int visited_count_; | 511 int visited_count_; |
512 ZoneList<HBasicBlock*> stack_; | 512 ZoneList<HBasicBlock*> stack_; |
513 BitVector reachable_; | 513 BitVector reachable_; |
514 HBasicBlock* dont_visit_; | 514 HBasicBlock* dont_visit_; |
515 }; | 515 }; |
516 | 516 |
517 | 517 |
518 void HGraph::Verify(bool do_full_verify) const { | 518 void HGraph::Verify(bool do_full_verify) const { |
519 // Allow dereferencing for debug mode verification. | 519 // Allow dereferencing for debug mode verification. |
520 Heap::RelocationLock(isolate()->heap()); | |
521 HandleDereferenceGuard allow_handle_deref(isolate(), | 520 HandleDereferenceGuard allow_handle_deref(isolate(), |
522 HandleDereferenceGuard::ALLOW); | 521 HandleDereferenceGuard::ALLOW); |
523 for (int i = 0; i < blocks_.length(); i++) { | 522 for (int i = 0; i < blocks_.length(); i++) { |
524 HBasicBlock* block = blocks_.at(i); | 523 HBasicBlock* block = blocks_.at(i); |
525 | 524 |
526 block->Verify(); | 525 block->Verify(); |
527 | 526 |
528 // Check that every block contains at least one node and that only the last | 527 // Check that every block contains at least one node and that only the last |
529 // node is a control instruction. | 528 // node is a control instruction. |
530 HInstruction* current = block->first(); | 529 HInstruction* current = block->first(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 HConstant* HGraph::GetConstantMinus1() { | 611 HConstant* HGraph::GetConstantMinus1() { |
613 return GetConstantInt32(&constant_minus1_, -1); | 612 return GetConstantInt32(&constant_minus1_, -1); |
614 } | 613 } |
615 | 614 |
616 | 615 |
617 #define DEFINE_GET_CONSTANT(Name, name, htype, boolean_value) \ | 616 #define DEFINE_GET_CONSTANT(Name, name, htype, boolean_value) \ |
618 HConstant* HGraph::GetConstant##Name() { \ | 617 HConstant* HGraph::GetConstant##Name() { \ |
619 if (!constant_##name##_.is_set()) { \ | 618 if (!constant_##name##_.is_set()) { \ |
620 HConstant* constant = new(zone()) HConstant( \ | 619 HConstant* constant = new(zone()) HConstant( \ |
621 isolate()->factory()->name##_value(), \ | 620 isolate()->factory()->name##_value(), \ |
| 621 UniqueValueId(isolate()->heap()->name##_value()), \ |
622 Representation::Tagged(), \ | 622 Representation::Tagged(), \ |
623 htype, \ | 623 htype, \ |
624 false, \ | 624 false, \ |
625 boolean_value); \ | 625 boolean_value); \ |
626 constant->InsertAfter(GetConstantUndefined()); \ | 626 constant->InsertAfter(GetConstantUndefined()); \ |
627 constant_##name##_.set(constant); \ | 627 constant_##name##_.set(constant); \ |
628 } \ | 628 } \ |
629 return constant_##name##_.get(); \ | 629 return constant_##name##_.get(); \ |
630 } | 630 } |
631 | 631 |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 finished_ = true; | 873 finished_ = true; |
874 } | 874 } |
875 | 875 |
876 | 876 |
877 HGraph* HGraphBuilder::CreateGraph() { | 877 HGraph* HGraphBuilder::CreateGraph() { |
878 graph_ = new(zone()) HGraph(info_); | 878 graph_ = new(zone()) HGraph(info_); |
879 if (FLAG_hydrogen_stats) isolate()->GetHStatistics()->Initialize(info_); | 879 if (FLAG_hydrogen_stats) isolate()->GetHStatistics()->Initialize(info_); |
880 HPhase phase("H_Block building", isolate()); | 880 HPhase phase("H_Block building", isolate()); |
881 set_current_block(graph()->entry_block()); | 881 set_current_block(graph()->entry_block()); |
882 if (!BuildGraph()) return NULL; | 882 if (!BuildGraph()) return NULL; |
| 883 graph()->FinalizeUniqueValueIds(); |
883 return graph_; | 884 return graph_; |
884 } | 885 } |
885 | 886 |
886 | 887 |
887 HInstruction* HGraphBuilder::AddInstruction(HInstruction* instr) { | 888 HInstruction* HGraphBuilder::AddInstruction(HInstruction* instr) { |
888 ASSERT(current_block() != NULL); | 889 ASSERT(current_block() != NULL); |
889 current_block()->AddInstruction(instr); | 890 current_block()->AddInstruction(instr); |
890 if (no_side_effects_scope_count_ > 0) { | 891 if (no_side_effects_scope_count_ > 0) { |
891 instr->SetFlag(HValue::kHasNoObservableSideEffects); | 892 instr->SetFlag(HValue::kHasNoObservableSideEffects); |
892 } | 893 } |
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1689 } | 1690 } |
1690 | 1691 |
1691 | 1692 |
1692 HBasicBlock* HGraph::CreateBasicBlock() { | 1693 HBasicBlock* HGraph::CreateBasicBlock() { |
1693 HBasicBlock* result = new(zone()) HBasicBlock(this); | 1694 HBasicBlock* result = new(zone()) HBasicBlock(this); |
1694 blocks_.Add(result, zone()); | 1695 blocks_.Add(result, zone()); |
1695 return result; | 1696 return result; |
1696 } | 1697 } |
1697 | 1698 |
1698 | 1699 |
| 1700 void HGraph::FinalizeUniqueValueIds() { |
| 1701 AssertNoAllocation no_gc; |
| 1702 ASSERT(!isolate()->optimizing_compiler_thread()->IsOptimizerThread()); |
| 1703 for (int i = 0; i < blocks()->length(); ++i) { |
| 1704 for (HInstruction* instr = blocks()->at(i)->first(); |
| 1705 instr != NULL; |
| 1706 instr = instr->next()) { |
| 1707 instr->FinalizeUniqueValueId(); |
| 1708 } |
| 1709 } |
| 1710 } |
| 1711 |
| 1712 |
1699 void HGraph::Canonicalize() { | 1713 void HGraph::Canonicalize() { |
1700 if (!FLAG_use_canonicalizing) return; | 1714 if (!FLAG_use_canonicalizing) return; |
1701 HPhase phase("H_Canonicalize", this); | 1715 HPhase phase("H_Canonicalize", this); |
1702 for (int i = 0; i < blocks()->length(); ++i) { | 1716 for (int i = 0; i < blocks()->length(); ++i) { |
1703 HInstruction* instr = blocks()->at(i)->first(); | 1717 HInstruction* instr = blocks()->at(i)->first(); |
1704 while (instr != NULL) { | 1718 while (instr != NULL) { |
1705 HValue* value = instr->Canonicalize(); | 1719 HValue* value = instr->Canonicalize(); |
1706 if (value != instr) instr->DeleteAndReplaceWith(value); | 1720 if (value != instr) instr->DeleteAndReplaceWith(value); |
1707 instr = instr->next(); | 1721 instr = instr->next(); |
1708 } | 1722 } |
(...skipping 2611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4320 !type_info->matches_inlined_type_change_checksum(composite_checksum)); | 4334 !type_info->matches_inlined_type_change_checksum(composite_checksum)); |
4321 type_info->set_inlined_type_change_checksum(composite_checksum); | 4335 type_info->set_inlined_type_change_checksum(composite_checksum); |
4322 | 4336 |
4323 return true; | 4337 return true; |
4324 } | 4338 } |
4325 | 4339 |
4326 | 4340 |
4327 void HGraph::GlobalValueNumbering() { | 4341 void HGraph::GlobalValueNumbering() { |
4328 // Perform common subexpression elimination and loop-invariant code motion. | 4342 // Perform common subexpression elimination and loop-invariant code motion. |
4329 if (FLAG_use_gvn) { | 4343 if (FLAG_use_gvn) { |
4330 // We use objects' raw addresses for identification, so they must not move. | |
4331 Heap::RelocationLock relocation_lock(isolate()->heap()); | |
4332 HPhase phase("H_Global value numbering", this); | 4344 HPhase phase("H_Global value numbering", this); |
4333 HGlobalValueNumberer gvn(this, info()); | 4345 HGlobalValueNumberer gvn(this, info()); |
4334 bool removed_side_effects = gvn.Analyze(); | 4346 bool removed_side_effects = gvn.Analyze(); |
4335 // Trigger a second analysis pass to further eliminate duplicate values that | 4347 // Trigger a second analysis pass to further eliminate duplicate values that |
4336 // could only be discovered by removing side-effect-generating instructions | 4348 // could only be discovered by removing side-effect-generating instructions |
4337 // during the first pass. | 4349 // during the first pass. |
4338 if (FLAG_smi_only_arrays && removed_side_effects) { | 4350 if (FLAG_smi_only_arrays && removed_side_effects) { |
4339 removed_side_effects = gvn.Analyze(); | 4351 removed_side_effects = gvn.Analyze(); |
4340 ASSERT(!removed_side_effects); | 4352 ASSERT(!removed_side_effects); |
4341 } | 4353 } |
(...skipping 7325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11667 } | 11679 } |
11668 } | 11680 } |
11669 | 11681 |
11670 #ifdef DEBUG | 11682 #ifdef DEBUG |
11671 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 11683 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
11672 if (allocator_ != NULL) allocator_->Verify(); | 11684 if (allocator_ != NULL) allocator_->Verify(); |
11673 #endif | 11685 #endif |
11674 } | 11686 } |
11675 | 11687 |
11676 } } // namespace v8::internal | 11688 } } // namespace v8::internal |
OLD | NEW |