Chromium Code Reviews| Index: src/hydrogen-instructions.cc |
| =================================================================== |
| --- src/hydrogen-instructions.cc (revision 9619) |
| +++ src/hydrogen-instructions.cc (working copy) |
| @@ -67,6 +67,19 @@ |
| } |
| +template<class T> inline const T& min(const T& a, const T& b) { |
| + return (a < b) ? a : b; |
| +} |
| + |
| + |
| +int HValue::LoopWeight() const { |
| + const int w = FLAG_loop_weight; |
| + 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
|
| + return weights[min(block()->LoopNestingDepth(), |
| + static_cast<int>(ARRAY_SIZE(weights)-1))]; |
| +} |
| + |
| + |
| void HValue::AssumeRepresentation(Representation r) { |
| if (CheckFlag(kFlexibleRepresentation)) { |
| ChangeRepresentation(r); |
| @@ -1117,7 +1130,7 @@ |
| HValue* value = it.value(); |
| if (!value->IsPhi()) { |
| Representation rep = value->RequiredInputRepresentation(it.index()); |
| - ++non_phi_uses_[rep.kind()]; |
| + non_phi_uses_[rep.kind()] += value->LoopWeight(); |
| } |
| } |
| } |