Revision: 7874
Author:   [email protected]
Date:     Thu May 12 06:36:49 2011
Log: Made the output of the --trace-representation flag a bit more informative and
centralized its handling.
Review URL: http://codereview.chromium.org/6969034
http://code.google.com/p/v8/source/detail?r=7874

Modified:
 /branches/bleeding_edge/src/hydrogen.cc
 /branches/bleeding_edge/src/hydrogen.h

=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Wed May 11 05:50:04 2011
+++ /branches/bleeding_edge/src/hydrogen.cc     Thu May 12 06:36:49 2011
@@ -4694,10 +4694,12 @@
       ? graph_->GetConstant1()
       : graph_->GetConstantMinus1();
   HInstruction* instr = new(zone()) HAdd(value, delta);
-  Representation rep = ToRepresentation(oracle()->IncrementType(expr));
+  TypeInfo info = oracle()->IncrementType(expr);
+  Representation rep = ToRepresentation(info);
   if (rep.IsTagged()) {
     rep = Representation::Integer32();
   }
+  TraceRepresentation(expr->op(), info, instr, rep);
   AssumeRepresentation(instr, rep);
   return instr;
 }
@@ -4870,14 +4872,12 @@
(right->IsConstant() && HConstant::cast(right)->HasStringValue()))) {
     return instr;
   }
-  if (FLAG_trace_representation) {
- PrintF("Info: %s/%s\n", info.ToString(), ToRepresentation(info).Mnemonic());
-  }
   Representation rep = ToRepresentation(info);
   // We only generate either int32 or generic tagged bitwise operations.
   if (instr->IsBitwiseBinaryOperation() && rep.IsDouble()) {
     rep = Representation::Integer32();
   }
+  TraceRepresentation(expr->op(), info, instr, rep);
   AssumeRepresentation(instr, rep);
   return instr;
 }
@@ -5046,20 +5046,32 @@
 }


-void HGraphBuilder::AssumeRepresentation(HValue* value, Representation r) {
+void HGraphBuilder::TraceRepresentation(Token::Value op,
+                                        TypeInfo info,
+                                        HValue* value,
+                                        Representation rep) {
+  if (!FLAG_trace_representation) return;
+ // TODO(svenpanne) Under which circumstances are we actually not flexible?
+  // At first glance, this looks a bit weird...
+  bool flexible = value->CheckFlag(HValue::kFlexibleRepresentation);
+ PrintF("Operation %s has type info %s, %schange representation assumption "
+         "for %s (ID %d) from %s to %s\n",
+         Token::Name(op),
+         info.ToString(),
+         flexible ? "" : " DO NOT ",
+         value->Mnemonic(),
+         graph_->GetMaximumValueID(),
+         value->representation().Mnemonic(),
+         rep.Mnemonic());
+}
+
+
+void HGraphBuilder::AssumeRepresentation(HValue* value, Representation rep) {
   if (value->CheckFlag(HValue::kFlexibleRepresentation)) {
-    if (FLAG_trace_representation) {
-      PrintF("Assume representation for %s to be %s (%d)\n",
-             value->Mnemonic(),
-             r.Mnemonic(),
-             graph_->GetMaximumValueID());
-    }
-    value->ChangeRepresentation(r);
+    value->ChangeRepresentation(rep);
     // The representation of the value is dictated by type feedback and
     // will not be changed later.
     value->ClearFlag(HValue::kFlexibleRepresentation);
-  } else if (FLAG_trace_representation) {
-    PrintF("No representation assumed\n");
   }
 }

=======================================
--- /branches/bleeding_edge/src/hydrogen.h      Wed May 11 05:50:04 2011
+++ /branches/bleeding_edge/src/hydrogen.h      Thu May 12 06:36:49 2011
@@ -819,7 +819,11 @@
   // to push them as outgoing parameters.
   template <int V> HInstruction* PreProcessCall(HCall<V>* call);

-  void AssumeRepresentation(HValue* value, Representation r);
+  void TraceRepresentation(Token::Value op,
+                           TypeInfo info,
+                           HValue* value,
+                           Representation rep);
+  void AssumeRepresentation(HValue* value, Representation rep);
   static Representation ToRepresentation(TypeInfo info);

   void SetupScope(Scope* scope);

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to