Reviewers: Jakob,

Message:
PTAL

Description:
Improve smi support in crankshaft
- Recover smi in phis if inputs are smi-typed
- Don't record smi-typed values as pointers

BUG=

Please review this at https://chromiumcodereview.appspot.com/16240003/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/hydrogen-instructions.h
  M src/hydrogen-instructions.cc
  M src/lithium-allocator.cc


Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index d4938e5c3848d9509b7d0603ae19c2cf253a4373..b276cb20c77ba9e8595ebdd5c85fad7eb28ac9c7 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -3565,6 +3565,7 @@ void HPhi::InferRepresentation(HInferRepresentation* h_infer) {


 Representation HPhi::RepresentationFromInputs() {
+  bool tagged_smi_occurred = false;
   bool double_occurred = false;
   bool int32_occurred = false;
   bool smi_occurred = false;
@@ -3574,10 +3575,18 @@ Representation HPhi::RepresentationFromInputs() {
       HPhi* hint_value = HUnknownOSRValue::cast(value)->incoming_value();
       if (hint_value != NULL) {
         Representation hint = hint_value->representation();
-        if (hint.IsTagged()) return hint;
-        if (hint.IsDouble()) double_occurred = true;
-        if (hint.IsInteger32()) int32_occurred = true;
-        if (hint.IsSmi()) smi_occurred = true;
+        if (hint.IsTagged()) {
+          if (!hint_value->type().IsSmi()) return hint;
+          if (double_occurred) return hint;
+          if (int32_occurred) return hint;
+          tagged_smi_occurred = true;
+        } else if (tagged_smi_occurred) {
+          if (!hint.IsSmi()) return Representation::Tagged();
+        } else {
+          if (hint.IsDouble()) double_occurred = true;
+          if (hint.IsInteger32()) int32_occurred = true;
+          if (hint.IsSmi()) smi_occurred = true;
+        }
       }
       continue;
     }
@@ -3587,7 +3596,9 @@ Representation HPhi::RepresentationFromInputs() {
     if (value->representation().IsTagged()) {
       if (value->IsConstant()) {
         HConstant* constant = HConstant::cast(value);
-        if (constant->IsConvertibleToInteger()) {
+        if (constant->HasSmiValue()) {
+          smi_occurred = true;
+        } else if (constant->IsConvertibleToInteger()) {
           int32_occurred = true;
         } else if (constant->HasNumberValue()) {
           double_occurred = true;
@@ -3596,12 +3607,16 @@ Representation HPhi::RepresentationFromInputs() {
         }
       } else {
         if (value->IsPhi() && !IsConvertibleToInteger()) {
-          return Representation::Tagged();
+          if (!value->type().IsSmi()) return Representation::Tagged();
+          if (double_occurred) return Representation::Tagged();
+          if (int32_occurred) return Representation::Tagged();
+          tagged_smi_occurred = true;
         }
       }
     }
   }

+  if (tagged_smi_occurred) return Representation::Smi();
   if (double_occurred) return Representation::Double();
   if (int32_occurred) return Representation::Integer32();
   if (smi_occurred) return Representation::Smi();
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index 9f52569ccf60fa1a03a7a6aafc178f991a22b6d6..1e3f1c1213a1434724cfe134519b9f3fb3a41a0a 100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -2449,7 +2449,7 @@ class HMapEnumLength: public HUnaryOperation {
  public:
   explicit HMapEnumLength(HValue* value) : HUnaryOperation(value) {
     set_type(HType::Smi());
-    set_representation(Representation::Tagged());
+    set_representation(Representation::Smi());
     SetFlag(kUseGVN);
     SetGVNFlag(kDependsOnMaps);
   }
Index: src/lithium-allocator.cc
diff --git a/src/lithium-allocator.cc b/src/lithium-allocator.cc
index 04113e170d50a16270ea2aa64e7e9a262da7caaa..9defc5e29cefc955a35b2df6dfbc82dcb5ba36a7 100644
--- a/src/lithium-allocator.cc
+++ b/src/lithium-allocator.cc
@@ -1057,7 +1057,7 @@ void LAllocator::ResolvePhis(HBasicBlock* block) {
       LInstruction* branch =
           InstructionAt(cur_block->last_instruction_index());
       if (branch->HasPointerMap()) {
-        if (phi->representation().IsSmiOrTagged()) {
+        if (phi->representation().IsTagged() && !phi->type().IsSmi()) {
           branch->pointer_map()->RecordPointer(phi_operand, zone());
         } else if (!phi->representation().IsDouble()) {
           branch->pointer_map()->RecordUntagged(phi_operand, zone());
@@ -1640,7 +1640,7 @@ void LAllocator::TraceAlloc(const char* msg, ...) {
 bool LAllocator::HasTaggedValue(int virtual_register) const {
   HValue* value = graph_->LookupValue(virtual_register);
   if (value == NULL) return false;
-  return value->representation().IsSmiOrTagged();
+  return value->representation().IsTagged() && !value->type().IsSmi();
 }




--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to