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

Side by Side Diff: src/hydrogen.cc

Issue 7857033: Refactored HInferRepresenation::TryChange a bit, making the heuristics a bit clearer. (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 | 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 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 if (rep.IsNone()) continue; 1642 if (rep.IsNone()) continue;
1643 if (use->IsPhi()) HPhi::cast(use)->AddIndirectUsesTo(&use_count[0]); 1643 if (use->IsPhi()) HPhi::cast(use)->AddIndirectUsesTo(&use_count[0]);
1644 ++use_count[rep.kind()]; 1644 ++use_count[rep.kind()];
1645 } 1645 }
1646 int tagged_count = use_count[Representation::kTagged]; 1646 int tagged_count = use_count[Representation::kTagged];
1647 int double_count = use_count[Representation::kDouble]; 1647 int double_count = use_count[Representation::kDouble];
1648 int int32_count = use_count[Representation::kInteger32]; 1648 int int32_count = use_count[Representation::kInteger32];
1649 int non_tagged_count = double_count + int32_count; 1649 int non_tagged_count = double_count + int32_count;
1650 1650
1651 // If a non-loop phi has tagged uses, don't convert it to untagged. 1651 // If a non-loop phi has tagged uses, don't convert it to untagged.
1652 if (value->IsPhi() && !value->block()->IsLoopHeader()) { 1652 if (value->IsPhi() && !value->block()->IsLoopHeader() && tagged_count > 0) {
1653 if (tagged_count > 0) return Representation::None(); 1653 return Representation::None();
1654 } 1654 }
1655 1655
1656 if (non_tagged_count >= tagged_count) { 1656 // Prefer unboxing over boxing, the latter is more expensive.
1657 if (int32_count > 0) { 1657 if (tagged_count > non_tagged_count) Representation::None();
1658 if (!value->IsPhi() || value->IsConvertibleToInteger()) { 1658
1659 return Representation::Integer32(); 1659 // Prefer Integer32 over Double, if possible.
1660 } 1660 if (int32_count > 0 && value->IsConvertibleToInteger()) {
1661 } 1661 return Representation::Integer32();
1662 if (double_count > 0) return Representation::Double();
1663 } 1662 }
1663
1664 if (double_count > 0) return Representation::Double();
1665
1664 return Representation::None(); 1666 return Representation::None();
1665 } 1667 }
1666 1668
1667 1669
1668 void HInferRepresentation::Analyze() { 1670 void HInferRepresentation::Analyze() {
1669 HPhase phase("Infer representations", graph_); 1671 HPhase phase("Infer representations", graph_);
1670 1672
1671 // (1) Initialize bit vectors and count real uses. Each phi gets a 1673 // (1) Initialize bit vectors and count real uses. Each phi gets a
1672 // bit-vector of length <number of phis>. 1674 // bit-vector of length <number of phis>.
1673 const ZoneList<HPhi*>* phi_list = graph_->phi_list(); 1675 const ZoneList<HPhi*>* phi_list = graph_->phi_list();
(...skipping 5149 matching lines...) Expand 10 before | Expand all | Expand 10 after
6823 } 6825 }
6824 } 6826 }
6825 6827
6826 #ifdef DEBUG 6828 #ifdef DEBUG
6827 if (graph_ != NULL) graph_->Verify(); 6829 if (graph_ != NULL) graph_->Verify();
6828 if (allocator_ != NULL) allocator_->Verify(); 6830 if (allocator_ != NULL) allocator_->Verify();
6829 #endif 6831 #endif
6830 } 6832 }
6831 6833
6832 } } // namespace v8::internal 6834 } } // 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