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

Side by Side Diff: src/hydrogen.cc

Issue 7477052: use a worklist in HGraph::InsertRepresentationChanges (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 4 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 | no next file » | 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 1861 matching lines...) Expand 10 before | Expand all | Expand 10 after
1872 1872
1873 1873
1874 void HGraph::InsertRepresentationChanges() { 1874 void HGraph::InsertRepresentationChanges() {
1875 HPhase phase("Insert representation changes", this); 1875 HPhase phase("Insert representation changes", this);
1876 1876
1877 1877
1878 // Compute truncation flag for phis: Initially assume that all 1878 // Compute truncation flag for phis: Initially assume that all
1879 // int32-phis allow truncation and iteratively remove the ones that 1879 // int32-phis allow truncation and iteratively remove the ones that
1880 // are used in an operation that does not allow a truncating 1880 // are used in an operation that does not allow a truncating
1881 // conversion. 1881 // conversion.
1882 // TODO(fschneider): Replace this with a worklist-based iteration. 1882 int truncating_phis = 0;
1883 for (int i = 0; i < phi_list()->length(); i++) { 1883 for (int i = 0; i < phi_list()->length(); ++i) {
1884 HPhi* phi = phi_list()->at(i); 1884 HPhi* phi = phi_list()->at(i);
1885 if (phi->representation().IsInteger32()) { 1885 if (phi->representation().IsInteger32()) {
1886 ++truncating_phis;
1886 phi->SetFlag(HValue::kTruncatingToInt32); 1887 phi->SetFlag(HValue::kTruncatingToInt32);
1887 } 1888 }
1888 } 1889 }
1889 bool change = true; 1890
1890 while (change) { 1891 ZoneList<HPhi*> worklist(truncating_phis);
1891 change = false; 1892 for (int i = 0; i < phi_list()->length(); ++i) {
1892 for (int i = 0; i < phi_list()->length(); i++) { 1893 HPhi* phi = phi_list()->at(i);
1893 HPhi* phi = phi_list()->at(i); 1894 if (phi->CheckFlag (HValue::kTruncatingToInt32)) {
1894 if (!phi->CheckFlag(HValue::kTruncatingToInt32)) continue;
1895 for (HUseIterator it(phi->uses()); !it.Done(); it.Advance()) { 1895 for (HUseIterator it(phi->uses()); !it.Done(); it.Advance()) {
1896 HValue* use = it.value(); 1896 HValue* use = it.value();
1897 if (!use->CheckFlag(HValue::kTruncatingToInt32)) { 1897 if (!use->CheckFlag(HValue::kTruncatingToInt32)) {
1898 phi->ClearFlag(HValue::kTruncatingToInt32); 1898 phi->ClearFlag(HValue::kTruncatingToInt32);
1899 change = true; 1899 worklist.Add (phi);
1900 break; 1900 break;
1901 } 1901 }
1902 } 1902 }
1903 } 1903 }
1904 } 1904 }
1905
1906 while (!worklist.is_empty()) {
1907 HPhi* phi = worklist.RemoveLast();
1908 for (int i = 0; i < phi->OperandCount(); ++i) {
1909 HValue *v = phi->OperandAt(i);
1910 if (v->IsPhi() && v->CheckFlag(HValue::kTruncatingToInt32)) {
1911 v->ClearFlag(HValue::kTruncatingToInt32);
1912 worklist.Add(HPhi::cast(v));
1913 }
1914 }
1915 }
1905 1916
1906 for (int i = 0; i < blocks_.length(); ++i) { 1917 for (int i = 0; i < blocks_.length(); ++i) {
1907 // Process phi instructions first. 1918 // Process phi instructions first.
1908 const ZoneList<HPhi*>* phis = blocks_[i]->phis(); 1919 const ZoneList<HPhi*>* phis = blocks_[i]->phis();
1909 for (int j = 0; j < phis->length(); j++) { 1920 for (int j = 0; j < phis->length(); j++) {
1910 InsertRepresentationChangesForValue(phis->at(j)); 1921 InsertRepresentationChangesForValue(phis->at(j));
1911 } 1922 }
1912 1923
1913 // Process normal instructions. 1924 // Process normal instructions.
1914 HInstruction* current = blocks_[i]->first(); 1925 HInstruction* current = blocks_[i]->first();
(...skipping 4816 matching lines...) Expand 10 before | Expand all | Expand 10 after
6731 } 6742 }
6732 } 6743 }
6733 6744
6734 #ifdef DEBUG 6745 #ifdef DEBUG
6735 if (graph_ != NULL) graph_->Verify(); 6746 if (graph_ != NULL) graph_->Verify();
6736 if (allocator_ != NULL) allocator_->Verify(); 6747 if (allocator_ != NULL) allocator_->Verify();
6737 #endif 6748 #endif
6738 } 6749 }
6739 6750
6740 } } // namespace v8::internal 6751 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698