Eagerly set the types of many kinds of hydrogen instructions.
authortitzer@chromium.org <titzer@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 31 Jul 2013 09:29:30 +0000 (09:29 +0000)
committertitzer@chromium.org <titzer@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 31 Jul 2013 09:29:30 +0000 (09:29 +0000)
BUG=
R=verwaest@chromium.org

Review URL: https://codereview.chromium.org/21072002

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

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

index 6b51847..ea3a3c3 100644 (file)
@@ -3660,26 +3660,6 @@ HType HValue::CalculateInferredType() {
 }
 
 
-HType HCheckMaps::CalculateInferredType() {
-  return value()->type();
-}
-
-
-HType HCheckFunction::CalculateInferredType() {
-  return value()->type();
-}
-
-
-HType HCheckHeapObject::CalculateInferredType() {
-  return HType::NonPrimitive();
-}
-
-
-HType HCheckSmi::CalculateInferredType() {
-  return HType::Smi();
-}
-
-
 HType HPhi::CalculateInferredType() {
   if (OperandCount() == 0) return HType::Tagged();
   HType result = OperandAt(0)->type();
@@ -3691,52 +3671,12 @@ HType HPhi::CalculateInferredType() {
 }
 
 
-HType HCompareGeneric::CalculateInferredType() {
-  return HType::Boolean();
-}
-
-
-HType HInstanceOf::CalculateInferredType() {
-  return HType::Boolean();
-}
-
-
-HType HInstanceOfKnownGlobal::CalculateInferredType() {
-  return HType::Boolean();
-}
-
-
 HType HChange::CalculateInferredType() {
   if (from().IsDouble() && to().IsTagged()) return HType::HeapNumber();
   return type();
 }
 
 
-HType HBitwiseBinaryOperation::CalculateInferredType() {
-  return HType::TaggedNumber();
-}
-
-
-HType HArithmeticBinaryOperation::CalculateInferredType() {
-  return HType::TaggedNumber();
-}
-
-
-HType HAdd::CalculateInferredType() {
-  return HType::Tagged();
-}
-
-
-HType HBitNot::CalculateInferredType() {
-  return HType::TaggedNumber();
-}
-
-
-HType HUnaryMathOperation::CalculateInferredType() {
-  return HType::TaggedNumber();
-}
-
-
 Representation HUnaryMathOperation::RepresentationFromInputs() {
   Representation rep = representation();
   // If any of the actual input representation is more general than what we
@@ -3834,16 +3774,6 @@ void HAllocate::PrintDataTo(StringStream* stream) {
 }
 
 
-HType HRegExpLiteral::CalculateInferredType() {
-  return HType::JSObject();
-}
-
-
-HType HFunctionLiteral::CalculateInferredType() {
-  return HType::JSObject();
-}
-
-
 HValue* HUnaryMathOperation::EnsureAndPropagateNotMinusZero(
     BitVector* visited) {
   visited->Add(id());
index 7f8806c..c16a007 100644 (file)
@@ -2557,6 +2557,7 @@ class HBitNot: public HUnaryOperation {
     SetFlag(kUseGVN);
     SetFlag(kTruncatingToInt32);
     SetFlag(kAllowUndefinedAsNaN);
+    set_type(HType::TaggedNumber());
   }
 
   virtual Representation RequiredInputRepresentation(int index) {
@@ -2565,7 +2566,6 @@ class HBitNot: public HUnaryOperation {
   virtual Representation observed_input_representation(int index) {
     return Representation::Integer32();
   }
-  virtual HType CalculateInferredType();
 
   virtual HValue* Canonicalize();
 
@@ -2591,8 +2591,6 @@ class HUnaryMathOperation: public HTemplateInstruction<2> {
 
   virtual void PrintDataTo(StringStream* stream);
 
-  virtual HType CalculateInferredType();
-
   virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
 
   virtual Representation RequiredInputRepresentation(int index) {
@@ -2671,6 +2669,7 @@ class HUnaryMathOperation: public HTemplateInstruction<2> {
     }
     SetFlag(kUseGVN);
     SetFlag(kAllowUndefinedAsNaN);
+    set_type(HType::TaggedNumber());
   }
 
   virtual bool IsDeletable() const { return true; }
@@ -2735,7 +2734,6 @@ class HCheckMaps: public HTemplateInstruction<2> {
   virtual void HandleSideEffectDominator(GVNFlag side_effect,
                                          HValue* dominator);
   virtual void PrintDataTo(StringStream* stream);
-  virtual HType CalculateInferredType();
 
   HValue* value() { return OperandAt(0); }
   SmallMapList* map_set() { return &map_set_; }
@@ -2773,6 +2771,7 @@ class HCheckMaps: public HTemplateInstruction<2> {
     SetFlag(kTrackSideEffectDominators);
     SetGVNFlag(kDependsOnMaps);
     SetGVNFlag(kDependsOnElementsKind);
+    set_type(value->type());
   }
 
   void omit(CompilationInfo* info) {
@@ -2797,13 +2796,13 @@ class HCheckFunction: public HUnaryOperation {
     set_representation(Representation::Tagged());
     SetFlag(kUseGVN);
     target_in_new_space_ = Isolate::Current()->heap()->InNewSpace(*function);
+    set_type(value->type());
   }
 
   virtual Representation RequiredInputRepresentation(int index) {
     return Representation::Tagged();
   }
   virtual void PrintDataTo(StringStream* stream);
-  virtual HType CalculateInferredType();
 
   virtual HValue* Canonicalize();
 
@@ -2898,14 +2897,13 @@ class HCheckSmi: public HUnaryOperation {
   explicit HCheckSmi(HValue* value) : HUnaryOperation(value) {
     set_representation(Representation::Smi());
     SetFlag(kUseGVN);
+    set_type(HType::Smi());
   }
 
   virtual Representation RequiredInputRepresentation(int index) {
     return Representation::Tagged();
   }
 
-  virtual HType CalculateInferredType();
-
   virtual HValue* Canonicalize() {
     HType value_type = value()->type();
     if (value_type.IsSmi()) {
@@ -2941,14 +2939,13 @@ class HCheckHeapObject: public HUnaryOperation {
   explicit HCheckHeapObject(HValue* value) : HUnaryOperation(value) {
     set_representation(Representation::Tagged());
     SetFlag(kUseGVN);
+    set_type(HType::NonPrimitive());
   }
 
   virtual Representation RequiredInputRepresentation(int index) {
     return Representation::Tagged();
   }
 
-  virtual HType CalculateInferredType();
-
 #ifdef DEBUG
   virtual void Verify();
 #endif
@@ -4087,8 +4084,6 @@ class HBitwiseBinaryOperation: public HBinaryOperation {
     HBinaryOperation::initialize_output_representation(observed);
   }
 
-  virtual HType CalculateInferredType();
-
   DECLARE_ABSTRACT_INSTRUCTION(BitwiseBinaryOperation)
 
  private:
@@ -4132,6 +4127,7 @@ class HArithmeticBinaryOperation: public HBinaryOperation {
     SetAllSideEffects();
     SetFlag(kFlexibleRepresentation);
     SetFlag(kAllowUndefinedAsNaN);
+    set_type(HType::TaggedNumber());
   }
 
   virtual void RepresentationChanged(Representation to) {
@@ -4144,8 +4140,6 @@ class HArithmeticBinaryOperation: public HBinaryOperation {
     }
   }
 
-  virtual HType CalculateInferredType();
-
   DECLARE_ABSTRACT_INSTRUCTION(ArithmeticBinaryOperation)
 
  private:
@@ -4162,6 +4156,7 @@ class HCompareGeneric: public HBinaryOperation {
       : HBinaryOperation(context, left, right), token_(token) {
     ASSERT(Token::IsCompareOp(token));
     set_representation(Representation::Tagged());
+    set_type(HType::Boolean());
     SetAllSideEffects();
   }
 
@@ -4174,8 +4169,6 @@ class HCompareGeneric: public HBinaryOperation {
   Token::Value token() const { return token_; }
   virtual void PrintDataTo(StringStream* stream);
 
-  virtual HType CalculateInferredType();
-
   DECLARE_CONCRETE_INSTRUCTION(CompareGeneric)
 
  private:
@@ -4453,6 +4446,7 @@ class HInstanceOf: public HBinaryOperation {
   HInstanceOf(HValue* context, HValue* left, HValue* right)
       : HBinaryOperation(context, left, right) {
     set_representation(Representation::Tagged());
+    set_type(HType::Boolean());
     SetAllSideEffects();
   }
 
@@ -4460,8 +4454,6 @@ class HInstanceOf: public HBinaryOperation {
     return Representation::Tagged();
   }
 
-  virtual HType CalculateInferredType();
-
   virtual void PrintDataTo(StringStream* stream);
 
   DECLARE_CONCRETE_INSTRUCTION(InstanceOf)
@@ -4476,6 +4468,7 @@ class HInstanceOfKnownGlobal: public HTemplateInstruction<2> {
       : function_(right) {
     SetOperandAt(0, context);
     SetOperandAt(1, left);
+    set_type(HType::Boolean());
     set_representation(Representation::Tagged());
     SetAllSideEffects();
   }
@@ -4488,8 +4481,6 @@ class HInstanceOfKnownGlobal: public HTemplateInstruction<2> {
     return Representation::Tagged();
   }
 
-  virtual HType CalculateInferredType();
-
   DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal)
 
  private:
@@ -4588,8 +4579,6 @@ class HAdd: public HArithmeticBinaryOperation {
 
   virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
 
-  virtual HType CalculateInferredType();
-
   virtual HValue* Canonicalize();
 
   virtual bool TryDecompose(DecompositionResult* decomposition) {
@@ -4903,6 +4892,7 @@ class HBitwise: public HBitwiseBinaryOperation {
           HConstant::cast(right)->Integer32Value() < 0))) {
       SetFlag(kTruncatingToSmi);
     }
+    set_type(HType::TaggedNumber());
   }
 
   Token::Value op_;
@@ -6508,10 +6498,6 @@ class HStringAdd: public HBinaryOperation {
     return Representation::Tagged();
   }
 
-  virtual HType CalculateInferredType() {
-    return HType::String();
-  }
-
   DECLARE_CONCRETE_INSTRUCTION(StringAdd)
 
  protected:
@@ -6524,6 +6510,7 @@ class HStringAdd: public HBinaryOperation {
     SetFlag(kUseGVN);
     SetGVNFlag(kDependsOnMaps);
     SetGVNFlag(kChangesNewSpacePromotion);
+    set_type(HType::String());
   }
 
   // No side-effects except possible allocation.
@@ -6583,7 +6570,6 @@ class HStringCharFromCode: public HTemplateInstruction<2> {
         ? Representation::Tagged()
         : Representation::Integer32();
   }
-  virtual HType CalculateInferredType() { return HType::String(); }
 
   HValue* context() const { return OperandAt(0); }
   HValue* value() const { return OperandAt(1); }
@@ -6599,6 +6585,7 @@ class HStringCharFromCode: public HTemplateInstruction<2> {
     set_representation(Representation::Tagged());
     SetFlag(kUseGVN);
     SetGVNFlag(kChangesNewSpacePromotion);
+    set_type(HType::String());
   }
 
   virtual bool IsDeletable() const {
@@ -6615,11 +6602,6 @@ class HStringLength: public HUnaryOperation {
     return Representation::Tagged();
   }
 
-  virtual HType CalculateInferredType() {
-    STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue);
-    return HType::Smi();
-  }
-
   DECLARE_CONCRETE_INSTRUCTION(StringLength)
 
  protected:
@@ -6631,9 +6613,11 @@ class HStringLength: public HUnaryOperation {
 
  private:
   explicit HStringLength(HValue* string) : HUnaryOperation(string) {
+    STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue);
     set_representation(Representation::Tagged());
     SetFlag(kUseGVN);
     SetGVNFlag(kDependsOnMaps);
+    set_type(HType::Smi());
   }
 
   virtual bool IsDeletable() const { return true; }
@@ -6682,6 +6666,7 @@ class HRegExpLiteral: public HMaterializedLiteral<1> {
         flags_(flags) {
     SetOperandAt(0, context);
     SetAllSideEffects();
+    set_type(HType::JSObject());
   }
 
   HValue* context() { return OperandAt(0); }
@@ -6692,7 +6677,6 @@ class HRegExpLiteral: public HMaterializedLiteral<1> {
   virtual Representation RequiredInputRepresentation(int index) {
     return Representation::Tagged();
   }
-  virtual HType CalculateInferredType();
 
   DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral)
 
@@ -6714,6 +6698,7 @@ class HFunctionLiteral: public HTemplateInstruction<1> {
         is_generator_(shared->is_generator()),
         language_mode_(shared->language_mode()) {
     SetOperandAt(0, context);
+    set_type(HType::JSObject());
     set_representation(Representation::Tagged());
     SetGVNFlag(kChangesNewSpacePromotion);
   }
@@ -6723,7 +6708,6 @@ class HFunctionLiteral: public HTemplateInstruction<1> {
   virtual Representation RequiredInputRepresentation(int index) {
     return Representation::Tagged();
   }
-  virtual HType CalculateInferredType();
 
   DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral)