From 4922e3d206a266f0b31c56ff9a043a914eb19da2 Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Thu, 20 Jun 2013 13:22:46 +0000 Subject: [PATCH] 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 --- src/hydrogen-instructions.cc | 1 + src/hydrogen-instructions.h | 4 +++- src/hydrogen.cc | 19 ++++++++++++------- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc index f4a92a5..3765a98 100644 --- a/src/hydrogen-instructions.cc +++ b/src/hydrogen-instructions.cc @@ -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); diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index fe725ee..2b36775 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -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); } diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 1a1292b..21de99d 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -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; -- 2.7.4