Commit d87296eb authored by titzer@chromium.org's avatar titzer@chromium.org

Eagerly set the types of many kinds of hydrogen instructions.

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