Removed a "feature envy" bad smell: Moved AssumeRepresentation method to where
authorsvenpanne@chromium.org <svenpanne@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 13 May 2011 13:29:02 +0000 (13:29 +0000)
committersvenpanne@chromium.org <svenpanne@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 13 May 2011 13:29:02 +0000 (13:29 +0000)
it belongs.
Review URL: http://codereview.chromium.org/7015039

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7890 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/hydrogen-instructions.cc
src/hydrogen-instructions.h
src/hydrogen.cc

index 5aa5dd0bf8abab51504486883f019531a4288bec..ccc3c182eadf51d008f5b5abec5a9b4cb22d0616 100644 (file)
@@ -67,6 +67,16 @@ const char* Representation::Mnemonic() const {
 }
 
 
+void HValue::AssumeRepresentation(Representation r) {
+  if (CheckFlag(kFlexibleRepresentation)) {
+    ChangeRepresentation(r);
+    // The representation of the value is dictated by type feedback and
+    // will not be changed later.
+    ClearFlag(kFlexibleRepresentation);
+  }
+}
+
+
 static int32_t ConvertAndSetOverflow(int64_t result, bool* overflow) {
   if (result > kMaxInt) {
     *overflow = true;
index 03ff00751eb37929637ed757c18c10dae3fd136c..88ce87dbc264b2411a9d3711d7d95fd0db9759a3 100644 (file)
@@ -557,6 +557,7 @@ class HValue: public ZoneObject {
     RepresentationChanged(r);
     representation_ = r;
   }
+  void AssumeRepresentation(Representation r);
 
   virtual bool IsConvertibleToInteger() const { return true; }
 
index eb6cbe0c9fded1e381f10aeb0238bf9c53b873a8..18d77f3390acd9a457c77bd8249fe76223df4173 100644 (file)
@@ -4636,7 +4636,7 @@ void HGraphBuilder::VisitSub(UnaryOperation* expr) {
   TypeInfo info = oracle()->UnaryType(expr);
   Representation rep = ToRepresentation(info);
   TraceRepresentation(expr->op(), info, instr, rep);
-  AssumeRepresentation(instr, rep);
+  instr->AssumeRepresentation(rep);
   ast_context()->ReturnInstruction(instr, expr->id());
 }
 
@@ -4707,7 +4707,7 @@ HInstruction* HGraphBuilder::BuildIncrement(HValue* value,
     rep = Representation::Integer32();
   }
   TraceRepresentation(expr->op(), info, instr, rep);
-  AssumeRepresentation(instr, rep);
+  instr->AssumeRepresentation(rep);
   return instr;
 }
 
@@ -4885,7 +4885,7 @@ HInstruction* HGraphBuilder::BuildBinaryOperation(BinaryOperation* expr,
     rep = Representation::Integer32();
   }
   TraceRepresentation(expr->op(), info, instr, rep);
-  AssumeRepresentation(instr, rep);
+  instr->AssumeRepresentation(rep);
   return instr;
 }
 
@@ -5073,16 +5073,6 @@ void HGraphBuilder::TraceRepresentation(Token::Value op,
 }
 
 
-void HGraphBuilder::AssumeRepresentation(HValue* value, Representation rep) {
-  if (value->CheckFlag(HValue::kFlexibleRepresentation)) {
-    value->ChangeRepresentation(rep);
-    // The representation of the value is dictated by type feedback and
-    // will not be changed later.
-    value->ClearFlag(HValue::kFlexibleRepresentation);
-  }
-}
-
-
 Representation HGraphBuilder::ToRepresentation(TypeInfo info) {
   if (info.IsSmi()) return Representation::Integer32();
   if (info.IsInteger32()) return Representation::Integer32();