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

Side by Side Diff: src/hydrogen.cc

Issue 7754010: Re-use phi reachability information to avoid a fixed-point computation. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/hydrogen-instructions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 HValue* use = it.value(); 1683 HValue* use = it.value();
1684 if (use->IsPhi()) { 1684 if (use->IsPhi()) {
1685 int id = HPhi::cast(use)->phi_id(); 1685 int id = HPhi::cast(use)->phi_id();
1686 if (connected_phis[i]->UnionIsChanged(*connected_phis[id])) 1686 if (connected_phis[i]->UnionIsChanged(*connected_phis[id]))
1687 change = true; 1687 change = true;
1688 } 1688 }
1689 } 1689 }
1690 } 1690 }
1691 } 1691 }
1692 1692
1693 // (3) Sum up the non-phi use counts of all connected phis. Don't include 1693 // (3) Use the phi reachability information from step 2 to
1694 // the non-phi uses of the phi itself. 1694 // (a) sum up the non-phi use counts of all connected phis.
1695 // (b) push information about values which can't be converted to integer
1696 // without deoptimization through the phi use-def chains, avoiding
1697 // unnecessary deoptimizations later.
1695 for (int i = 0; i < phi_count; ++i) { 1698 for (int i = 0; i < phi_count; ++i) {
1696 HPhi* phi = phi_list->at(i); 1699 HPhi* phi = phi_list->at(i);
1700 bool cti = phi->AllOperandsConvertibleToInteger();
1697 for (BitVector::Iterator it(connected_phis.at(i)); 1701 for (BitVector::Iterator it(connected_phis.at(i));
1698 !it.Done(); 1702 !it.Done();
1699 it.Advance()) { 1703 it.Advance()) {
1700 int index = it.Current(); 1704 int index = it.Current();
1701 if (index != i) { 1705 HPhi* it_use = phi_list->at(it.Current());
1702 HPhi* it_use = phi_list->at(it.Current()); 1706 if (index != i) phi->AddNonPhiUsesFrom(it_use); // Don't count twice!
1703 phi->AddNonPhiUsesFrom(it_use); 1707 if (!cti) it_use->set_is_convertible_to_integer(false);
1704 }
1705 } 1708 }
1706 } 1709 }
1707 1710
1708 // (4) Compute phis that definitely can't be converted to integer 1711 // Initialize work list
1709 // without deoptimization and mark them to avoid unnecessary deoptimization.
1710 change = true;
1711 while (change) {
1712 change = false;
1713 for (int i = 0; i < phi_count; ++i) {
1714 HPhi* phi = phi_list->at(i);
1715 for (int j = 0; j < phi->OperandCount(); ++j) {
1716 if (phi->IsConvertibleToInteger() &&
1717 !phi->OperandAt(j)->IsConvertibleToInteger()) {
1718 phi->set_is_convertible_to_integer(false);
1719 change = true;
1720 break;
1721 }
1722 }
1723 }
1724 }
1725
1726
1727 for (int i = 0; i < graph_->blocks()->length(); ++i) { 1712 for (int i = 0; i < graph_->blocks()->length(); ++i) {
1728 HBasicBlock* block = graph_->blocks()->at(i); 1713 HBasicBlock* block = graph_->blocks()->at(i);
1729 const ZoneList<HPhi*>* phis = block->phis(); 1714 const ZoneList<HPhi*>* phis = block->phis();
1730 for (int j = 0; j < phis->length(); ++j) { 1715 for (int j = 0; j < phis->length(); ++j) {
1731 AddToWorklist(phis->at(j)); 1716 AddToWorklist(phis->at(j));
1732 } 1717 }
1733 1718
1734 HInstruction* current = block->first(); 1719 HInstruction* current = block->first();
1735 while (current != NULL) { 1720 while (current != NULL) {
1736 AddToWorklist(current); 1721 AddToWorklist(current);
1737 current = current->next(); 1722 current = current->next();
1738 } 1723 }
1739 } 1724 }
1740 1725
1726 // Do a fixed point iteration, trying to improve representations
1741 while (!worklist_.is_empty()) { 1727 while (!worklist_.is_empty()) {
1742 HValue* current = worklist_.RemoveLast(); 1728 HValue* current = worklist_.RemoveLast();
1743 in_worklist_.Remove(current->id()); 1729 in_worklist_.Remove(current->id());
1744 InferBasedOnInputs(current); 1730 InferBasedOnInputs(current);
1745 InferBasedOnUses(current); 1731 InferBasedOnUses(current);
1746 } 1732 }
1747 } 1733 }
1748 1734
1749 1735
1750 void HGraph::InitializeInferredTypes() { 1736 void HGraph::InitializeInferredTypes() {
(...skipping 5059 matching lines...) Expand 10 before | Expand all | Expand 10 after
6810 } 6796 }
6811 } 6797 }
6812 6798
6813 #ifdef DEBUG 6799 #ifdef DEBUG
6814 if (graph_ != NULL) graph_->Verify(); 6800 if (graph_ != NULL) graph_->Verify();
6815 if (allocator_ != NULL) allocator_->Verify(); 6801 if (allocator_ != NULL) allocator_->Verify();
6816 #endif 6802 #endif
6817 } 6803 }
6818 6804
6819 } } // namespace v8::internal 6805 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698