Revision: 7717
Author:   [email protected]
Date:     Fri Apr 29 02:21:18 2011
Log:      Use type info for count operation in Crankshaft.

BUG=
TEST=

Review URL: http://codereview.chromium.org/6880276
http://code.google.com/p/v8/source/detail?r=7717

Modified:
 /branches/bleeding_edge/src/hydrogen.cc
 /branches/bleeding_edge/src/hydrogen.h
 /branches/bleeding_edge/src/type-info.cc
 /branches/bleeding_edge/src/type-info.h

=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Tue Apr 26 08:22:44 2011
+++ /branches/bleeding_edge/src/hydrogen.cc     Fri Apr 29 02:21:18 2011
@@ -4653,12 +4653,18 @@
 }


-HInstruction* HGraphBuilder::BuildIncrement(HValue* value, bool increment) {
+HInstruction* HGraphBuilder::BuildIncrement(HValue* value,
+                                            bool increment,
+                                            CountOperation* expr) {
   HConstant* delta = increment
       ? graph_->GetConstant1()
       : graph_->GetConstantMinus1();
   HInstruction* instr = new(zone()) HAdd(value, delta);
-  AssumeRepresentation(instr,  Representation::Integer32());
+  Representation rep = ToRepresentation(oracle()->IncrementType(expr));
+  if (rep.IsTagged()) {
+    rep = Representation::Integer32();
+  }
+  AssumeRepresentation(instr, rep);
   return instr;
 }

@@ -4681,7 +4687,7 @@
     // element for postfix operations in a non-effect context.
     bool has_extra = expr->is_postfix() && !ast_context()->IsEffect();
     HValue* before = has_extra ? Top() : Pop();
-    HInstruction* after = BuildIncrement(before, inc);
+    HInstruction* after = BuildIncrement(before, inc, expr);
     AddInstruction(after);
     Push(after);

@@ -4733,7 +4739,7 @@
       HValue* before = Pop();
// There is no deoptimization to after the increment, so we don't need
       // to simulate the expression stack after this instruction.
-      HInstruction* after = BuildIncrement(before, inc);
+      HInstruction* after = BuildIncrement(before, inc, expr);
       AddInstruction(after);

       HInstruction* store = BuildStoreNamed(obj, after, prop);
@@ -4769,7 +4775,7 @@
       HValue* before = Pop();
// There is no deoptimization to after the increment, so we don't need
       // to simulate the expression stack after this instruction.
-      HInstruction* after = BuildIncrement(before, inc);
+      HInstruction* after = BuildIncrement(before, inc, expr);
       AddInstruction(after);

       expr->RecordTypeFeedback(oracle());
=======================================
--- /branches/bleeding_edge/src/hydrogen.h      Wed Apr 20 03:38:08 2011
+++ /branches/bleeding_edge/src/hydrogen.h      Fri Apr 29 02:21:18 2011
@@ -831,7 +831,9 @@
   HInstruction* BuildBinaryOperation(BinaryOperation* expr,
                                      HValue* left,
                                      HValue* right);
-  HInstruction* BuildIncrement(HValue* value, bool increment);
+  HInstruction* BuildIncrement(HValue* value,
+                               bool increment,
+                               CountOperation* expr);
   HLoadNamedField* BuildLoadNamedField(HValue* object,
                                        Property* expr,
                                        Handle<Map> type,
=======================================
--- /branches/bleeding_edge/src/type-info.cc    Thu Apr 28 10:49:55 2011
+++ /branches/bleeding_edge/src/type-info.cc    Fri Apr 29 02:21:18 2011
@@ -332,6 +332,35 @@
       return unknown;
   }
 }
+
+
+TypeInfo TypeFeedbackOracle::IncrementType(CountOperation* expr) {
+  Handle<Object> object = GetInfo(expr->CountId());
+  TypeInfo unknown = TypeInfo::Unknown();
+  if (!object->IsCode()) return unknown;
+  Handle<Code> code = Handle<Code>::cast(object);
+  if (!code->is_type_recording_binary_op_stub()) return unknown;
+
+  TRBinaryOpIC::TypeInfo type = static_cast<TRBinaryOpIC::TypeInfo>(
+      code->type_recording_binary_op_type());
+  switch (type) {
+    case TRBinaryOpIC::UNINITIALIZED:
+    case TRBinaryOpIC::SMI:
+      return TypeInfo::Smi();
+    case TRBinaryOpIC::INT32:
+      return TypeInfo::Integer32();
+    case TRBinaryOpIC::HEAP_NUMBER:
+      return TypeInfo::Double();
+    case TRBinaryOpIC::BOTH_STRING:
+    case TRBinaryOpIC::STRING:
+    case TRBinaryOpIC::GENERIC:
+      return unknown;
+    default:
+      return unknown;
+  }
+  UNREACHABLE();
+  return unknown;
+}


 ZoneMapList* TypeFeedbackOracle::CollectReceiverTypes(unsigned ast_id,
=======================================
--- /branches/bleeding_edge/src/type-info.h     Thu Apr 28 10:49:55 2011
+++ /branches/bleeding_edge/src/type-info.h     Fri Apr 29 02:21:18 2011
@@ -231,6 +231,7 @@
 class BinaryOperation;
 class Call;
 class CompareOperation;
+class CountOperation;
 class CompilationInfo;
 class Property;
 class CaseClause;
@@ -263,6 +264,7 @@
   TypeInfo BinaryType(BinaryOperation* expr);
   TypeInfo CompareType(CompareOperation* expr);
   TypeInfo SwitchType(CaseClause* clause);
+  TypeInfo IncrementType(CountOperation* expr);

  private:
   ZoneMapList* CollectReceiverTypes(unsigned ast_id,

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

Reply via email to