Uses of a value are weighted by a factor of FLAG_loop_weight (default: 10) for
every loop they are in. This makes uses in inner loops "more important", which
should improve the result of the representation inference.
Review URL: https://chromiumcodereview.appspot.com/8277031
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10573
ce2b1a6d-e550-0410-aec6-
3dcde31c8c00
DEFINE_bool(trace_osr, false, "trace on-stack replacement")
DEFINE_int(stress_runs, 0, "number of stress runs")
DEFINE_bool(optimize_closures, true, "optimize closures")
+DEFINE_int(loop_weight, 1, "loop weight for representation inference")
// assembler-ia32.cc / assembler-arm.cc / assembler-x64.cc
DEFINE_bool(debug_code, false,
}
+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 };
+ return weights[Min(block()->LoopNestingDepth(),
+ static_cast<int>(ARRAY_SIZE(weights)-1))];
+}
+
+
void HValue::AssumeRepresentation(Representation r) {
if (CheckFlag(kFlexibleRepresentation)) {
ChangeRepresentation(r);
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();
}
}
}
HBasicBlock* block() const { return block_; }
void SetBlock(HBasicBlock* block);
+ int LoopWeight() const;
int id() const { return id_; }
void set_id(int id) { id_ = id; }
Representation rep = use->RequiredInputRepresentation(it.index());
if (rep.IsNone()) continue;
if (use->IsPhi()) HPhi::cast(use)->AddIndirectUsesTo(&use_count[0]);
- ++use_count[rep.kind()];
+ use_count[rep.kind()] += use->LoopWeight();
}
int tagged_count = use_count[Representation::kTagged];
int double_count = use_count[Representation::kDouble];