Commit 4922e3d2 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Flexible representation for BuildIncrement, but CannotBeTagged.

R=jkummerow@chromium.org

Review URL: https://chromiumcodereview.appspot.com/17028017

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15244 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b17e759d
......@@ -128,6 +128,7 @@ void HValue::UpdateRepresentation(Representation new_rep,
const char* reason) {
Representation r = representation();
if (new_rep.is_more_general_than(r)) {
if (CheckFlag(kCannotBeTagged) && r.IsTagged()) return;
if (FLAG_trace_representation) {
PrintF("Changing #%d %s representation %s -> %s based on %s\n",
id(), Mnemonic(), r.Mnemonic(), new_rep.Mnemonic(), reason);
......
......@@ -784,6 +784,7 @@ class HValue: public ZoneObject {
enum Flag {
kFlexibleRepresentation,
kCannotBeTagged,
// Participate in Global Value Numbering, i.e. elimination of
// unnecessary recomputations. If an instruction sets this flag, it must
// implement DataEquals(), which will be used to determine if other
......@@ -891,7 +892,8 @@ class HValue: public ZoneObject {
ASSERT(CheckFlag(kFlexibleRepresentation));
RepresentationChanged(r);
representation_ = r;
if (r.IsTagged()) {
if (r.IsTagged() ||
(r.IsDouble() && CheckFlag(kCannotBeTagged))) {
// Tagged is the bottom of the lattice, don't go any further.
ClearFlag(kFlexibleRepresentation);
}
......
......@@ -2953,7 +2953,11 @@ void HInferRepresentation::Analyze() {
current != NULL; current = current->next()) {
if (current->representation().IsNone() &&
current->CheckFlag(HInstruction::kFlexibleRepresentation)) {
current->ChangeRepresentation(Representation::Tagged());
if (current->CheckFlag(HInstruction::kCannotBeTagged)) {
current->ChangeRepresentation(Representation::Double());
} else {
current->ChangeRepresentation(Representation::Tagged());
}
}
}
}
......@@ -9106,8 +9110,8 @@ HInstruction* HOptimizedGraphBuilder::BuildIncrement(
// The input to the count operation is on top of the expression stack.
TypeInfo info = expr->type();
Representation rep = ToRepresentation(info);
if (rep.IsTagged()) {
rep = Representation::Integer32();
if (rep.IsNone() || rep.IsTagged()) {
rep = Representation::Smi();
}
if (returns_original_input) {
......@@ -9116,6 +9120,10 @@ HInstruction* HOptimizedGraphBuilder::BuildIncrement(
// phase, so it is not available now to be used as an input to HAdd and
// as the return value.
HInstruction* number_input = new(zone()) HForceRepresentation(Pop(), rep);
if (!rep.IsDouble()) {
number_input->SetFlag(HInstruction::kFlexibleRepresentation);
number_input->SetFlag(HInstruction::kCannotBeTagged);
}
AddInstruction(number_input);
Push(number_input);
}
......@@ -9128,10 +9136,7 @@ HInstruction* HOptimizedGraphBuilder::BuildIncrement(
: graph()->GetConstantMinus1();
HValue* context = environment()->LookupContext();
HInstruction* instr = HAdd::New(zone(), context, Top(), delta);
// We can't insert a simulate here, because it would break deoptimization,
// so the HAdd must not have side effects, so we must freeze its
// representation.
instr->AssumeRepresentation(rep);
instr->SetFlag(HInstruction::kCannotBeTagged);
instr->ClearAllSideEffects();
AddInstruction(instr);
return instr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment