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

Side by Side Diff: src/hydrogen-instructions.cc

Issue 8277031: Give uses within a loop a greater weight when doing representation inference. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 2 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 | « src/hydrogen-instructions.h ('k') | 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 case kDouble: return "d"; 60 case kDouble: return "d";
61 case kInteger32: return "i"; 61 case kInteger32: return "i";
62 case kExternal: return "x"; 62 case kExternal: return "x";
63 default: 63 default:
64 UNREACHABLE(); 64 UNREACHABLE();
65 return NULL; 65 return NULL;
66 } 66 }
67 } 67 }
68 68
69 69
70 template<class T> inline const T& min(const T& a, const T& b) {
71 return (a < b) ? a : b;
72 }
73
74
75 int HValue::LoopWeight() const {
76 const int w = FLAG_loop_weight;
77 static const int weights[] = { 1, w, w*w, w*w*w, w*w*w*w };
fschneider 2012/01/27 22:33:24 I think no need for static here. Actually, I'd als
Sven Panne 2012/01/30 07:51:04 Well, initializing the array every time wouldn't b
78 return weights[min(block()->LoopNestingDepth(),
79 static_cast<int>(ARRAY_SIZE(weights)-1))];
80 }
81
82
70 void HValue::AssumeRepresentation(Representation r) { 83 void HValue::AssumeRepresentation(Representation r) {
71 if (CheckFlag(kFlexibleRepresentation)) { 84 if (CheckFlag(kFlexibleRepresentation)) {
72 ChangeRepresentation(r); 85 ChangeRepresentation(r);
73 // The representation of the value is dictated by type feedback and 86 // The representation of the value is dictated by type feedback and
74 // will not be changed later. 87 // will not be changed later.
75 ClearFlag(kFlexibleRepresentation); 88 ClearFlag(kFlexibleRepresentation);
76 } 89 }
77 } 90 }
78 91
79 92
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 } 1123 }
1111 1124
1112 1125
1113 void HPhi::InitRealUses(int phi_id) { 1126 void HPhi::InitRealUses(int phi_id) {
1114 // Initialize real uses. 1127 // Initialize real uses.
1115 phi_id_ = phi_id; 1128 phi_id_ = phi_id;
1116 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { 1129 for (HUseIterator it(uses()); !it.Done(); it.Advance()) {
1117 HValue* value = it.value(); 1130 HValue* value = it.value();
1118 if (!value->IsPhi()) { 1131 if (!value->IsPhi()) {
1119 Representation rep = value->RequiredInputRepresentation(it.index()); 1132 Representation rep = value->RequiredInputRepresentation(it.index());
1120 ++non_phi_uses_[rep.kind()]; 1133 non_phi_uses_[rep.kind()] += value->LoopWeight();
1121 } 1134 }
1122 } 1135 }
1123 } 1136 }
1124 1137
1125 1138
1126 void HPhi::AddNonPhiUsesFrom(HPhi* other) { 1139 void HPhi::AddNonPhiUsesFrom(HPhi* other) {
1127 for (int i = 0; i < Representation::kNumRepresentations; i++) { 1140 for (int i = 0; i < Representation::kNumRepresentations; i++) {
1128 indirect_uses_[i] += other->non_phi_uses_[i]; 1141 indirect_uses_[i] += other->non_phi_uses_[i];
1129 } 1142 }
1130 } 1143 }
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 1979
1967 1980
1968 void HCheckPrototypeMaps::Verify() { 1981 void HCheckPrototypeMaps::Verify() {
1969 HInstruction::Verify(); 1982 HInstruction::Verify();
1970 ASSERT(HasNoUses()); 1983 ASSERT(HasNoUses());
1971 } 1984 }
1972 1985
1973 #endif 1986 #endif
1974 1987
1975 } } // namespace v8::internal 1988 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698