Index: src/hydrogen-instructions.h |
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h |
index 64910c8d55ff8a70b27b6b97b49e0fc5038917db..fc414059d5efd1695e4cf13636076e0148f178f4 100644 |
--- a/src/hydrogen-instructions.h |
+++ b/src/hydrogen-instructions.h |
@@ -2369,38 +2369,10 @@ class HBitNot: public HUnaryOperation { |
class HUnaryMathOperation: public HTemplateInstruction<2> { |
public: |
- HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op) |
- : op_(op) { |
- SetOperandAt(0, context); |
- SetOperandAt(1, value); |
- switch (op) { |
- case kMathFloor: |
- case kMathRound: |
- case kMathCeil: |
- set_representation(Representation::Integer32()); |
- break; |
- case kMathAbs: |
- // Not setting representation here: it is None intentionally. |
- SetFlag(kFlexibleRepresentation); |
- SetGVNFlag(kChangesNewSpacePromotion); |
- break; |
- case kMathSqrt: |
- case kMathPowHalf: |
- case kMathLog: |
- case kMathSin: |
- case kMathCos: |
- case kMathTan: |
- set_representation(Representation::Double()); |
- SetGVNFlag(kChangesNewSpacePromotion); |
- break; |
- case kMathExp: |
- set_representation(Representation::Double()); |
- break; |
- default: |
- UNREACHABLE(); |
- } |
- SetFlag(kUseGVN); |
- } |
+ static HInstruction* New(Zone* zone, |
+ HValue* context, |
+ HValue* value, |
+ BuiltinFunctionId op); |
HValue* context() { return OperandAt(0); } |
HValue* value() { return OperandAt(1); } |
@@ -2418,7 +2390,6 @@ class HUnaryMathOperation: public HTemplateInstruction<2> { |
switch (op_) { |
case kMathFloor: |
case kMathRound: |
- case kMathCeil: |
case kMathSqrt: |
case kMathPowHalf: |
case kMathLog: |
@@ -2450,6 +2421,39 @@ class HUnaryMathOperation: public HTemplateInstruction<2> { |
} |
private: |
+ HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op) |
+ : op_(op) { |
+ SetOperandAt(0, context); |
+ SetOperandAt(1, value); |
+ switch (op) { |
+ case kMathFloor: |
+ case kMathRound: |
+ case kMathCeil: |
+ set_representation(Representation::Integer32()); |
+ break; |
+ case kMathAbs: |
+ // Not setting representation here: it is None intentionally. |
+ SetFlag(kFlexibleRepresentation); |
+ SetGVNFlag(kChangesNewSpacePromotion); |
+ break; |
+ case kMathSqrt: |
+ case kMathPowHalf: |
+ case kMathLog: |
+ case kMathSin: |
+ case kMathCos: |
+ case kMathTan: |
+ set_representation(Representation::Double()); |
+ SetGVNFlag(kChangesNewSpacePromotion); |
+ break; |
+ case kMathExp: |
+ set_representation(Representation::Double()); |
+ break; |
+ default: |
+ UNREACHABLE(); |
+ } |
+ SetFlag(kUseGVN); |
+ } |
+ |
virtual bool IsDeletable() const { return true; } |
BuiltinFunctionId op_; |
@@ -3064,6 +3068,15 @@ class HConstant: public HTemplateInstruction<0> { |
// representation of the number in int32_value_. |
return int32_value_; |
} |
+ bool HasStringValue() const { |
+ if (has_double_value_ || has_int32_value_) return false; |
+ ASSERT(!handle_.is_null()); |
+ return handle_->IsString(); |
+ } |
+ Handle<String> StringValue() const { |
+ ASSERT(HasStringValue()); |
+ return Handle<String>::cast(handle_); |
+ } |
bool ToBoolean(); |
@@ -3884,13 +3897,7 @@ class HInstanceOfKnownGlobal: public HTemplateInstruction<2> { |
class HPower: public HTemplateInstruction<2> { |
public: |
- HPower(HValue* left, HValue* right) { |
- SetOperandAt(0, left); |
- SetOperandAt(1, right); |
- set_representation(Representation::Double()); |
- SetFlag(kUseGVN); |
- SetGVNFlag(kChangesNewSpacePromotion); |
- } |
+ static HInstruction* New(Zone* zone, HValue* left, HValue* right); |
HValue* left() { return OperandAt(0); } |
HValue* right() const { return OperandAt(1); } |
@@ -3910,6 +3917,14 @@ class HPower: public HTemplateInstruction<2> { |
virtual bool DataEquals(HValue* other) { return true; } |
private: |
+ HPower(HValue* left, HValue* right) { |
+ SetOperandAt(0, left); |
+ SetOperandAt(1, right); |
+ set_representation(Representation::Double()); |
+ SetFlag(kUseGVN); |
+ SetGVNFlag(kChangesNewSpacePromotion); |
+ } |
+ |
virtual bool IsDeletable() const { |
return !right()->representation().IsTagged(); |
} |
@@ -3938,10 +3953,10 @@ class HRandom: public HTemplateInstruction<1> { |
class HAdd: public HArithmeticBinaryOperation { |
public: |
- HAdd(HValue* context, HValue* left, HValue* right) |
- : HArithmeticBinaryOperation(context, left, right) { |
- SetFlag(kCanOverflow); |
- } |
+ static HInstruction* New(Zone* zone, |
+ HValue* context, |
+ HValue* left, |
+ HValue* right); |
// Add is only commutative if two integer values are added and not if two |
// tagged values are added (because it might be a String concatenation). |
@@ -3951,11 +3966,6 @@ class HAdd: public HArithmeticBinaryOperation { |
virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
- static HInstruction* NewHAdd(Zone* zone, |
- HValue* context, |
- HValue* left, |
- HValue* right); |
- |
virtual HType CalculateInferredType(); |
virtual HValue* Canonicalize(); |
@@ -3983,25 +3993,26 @@ class HAdd: public HArithmeticBinaryOperation { |
virtual bool DataEquals(HValue* other) { return true; } |
virtual Range* InferRange(Zone* zone); |
+ |
+ private: |
+ HAdd(HValue* context, HValue* left, HValue* right) |
+ : HArithmeticBinaryOperation(context, left, right) { |
+ SetFlag(kCanOverflow); |
+ } |
}; |
class HSub: public HArithmeticBinaryOperation { |
public: |
- HSub(HValue* context, HValue* left, HValue* right) |
- : HArithmeticBinaryOperation(context, left, right) { |
- SetFlag(kCanOverflow); |
- } |
+ static HInstruction* New(Zone* zone, |
+ HValue* context, |
+ HValue* left, |
+ HValue* right); |
virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
virtual HValue* Canonicalize(); |
- static HInstruction* NewHSub(Zone* zone, |
- HValue* context, |
- HValue* left, |
- HValue* right); |
- |
virtual bool IsRelationTrueInternal(NumericRelation relation, HValue* other) { |
if (right()->IsInteger32Constant()) { |
HValue* base = left(); |
@@ -4019,15 +4030,21 @@ class HSub: public HArithmeticBinaryOperation { |
virtual bool DataEquals(HValue* other) { return true; } |
virtual Range* InferRange(Zone* zone); |
+ |
+ private: |
+ HSub(HValue* context, HValue* left, HValue* right) |
+ : HArithmeticBinaryOperation(context, left, right) { |
+ SetFlag(kCanOverflow); |
+ } |
}; |
class HMul: public HArithmeticBinaryOperation { |
public: |
- HMul(HValue* context, HValue* left, HValue* right) |
- : HArithmeticBinaryOperation(context, left, right) { |
- SetFlag(kCanOverflow); |
- } |
+ static HInstruction* New(Zone* zone, |
+ HValue* context, |
+ HValue* left, |
+ HValue* right); |
virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
@@ -4036,26 +4053,27 @@ class HMul: public HArithmeticBinaryOperation { |
return !representation().IsTagged(); |
} |
- static HInstruction* NewHMul(Zone* zone, |
- HValue* context, |
- HValue* left, |
- HValue* right); |
- |
DECLARE_CONCRETE_INSTRUCTION(Mul) |
protected: |
virtual bool DataEquals(HValue* other) { return true; } |
virtual Range* InferRange(Zone* zone); |
+ |
+ private: |
+ HMul(HValue* context, HValue* left, HValue* right) |
+ : HArithmeticBinaryOperation(context, left, right) { |
+ SetFlag(kCanOverflow); |
+ } |
}; |
class HMod: public HArithmeticBinaryOperation { |
public: |
- HMod(HValue* context, HValue* left, HValue* right) |
- : HArithmeticBinaryOperation(context, left, right) { |
- SetFlag(kCanBeDivByZero); |
- } |
+ static HInstruction* New(Zone* zone, |
+ HValue* context, |
+ HValue* left, |
+ HValue* right); |
bool HasPowerOf2Divisor() { |
if (right()->IsConstant() && |
@@ -4069,27 +4087,27 @@ class HMod: public HArithmeticBinaryOperation { |
virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
- static HInstruction* NewHMod(Zone* zone, |
- HValue* context, |
- HValue* left, |
- HValue* right); |
- |
DECLARE_CONCRETE_INSTRUCTION(Mod) |
protected: |
virtual bool DataEquals(HValue* other) { return true; } |
virtual Range* InferRange(Zone* zone); |
+ |
+ private: |
+ HMod(HValue* context, HValue* left, HValue* right) |
+ : HArithmeticBinaryOperation(context, left, right) { |
+ SetFlag(kCanBeDivByZero); |
+ } |
}; |
class HDiv: public HArithmeticBinaryOperation { |
public: |
- HDiv(HValue* context, HValue* left, HValue* right) |
- : HArithmeticBinaryOperation(context, left, right) { |
- SetFlag(kCanBeDivByZero); |
- SetFlag(kCanOverflow); |
- } |
+ static HInstruction* New(Zone* zone, |
+ HValue* context, |
+ HValue* left, |
+ HValue* right); |
bool HasPowerOf2Divisor() { |
if (right()->IsConstant() && |
@@ -4103,17 +4121,19 @@ class HDiv: public HArithmeticBinaryOperation { |
virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
- static HInstruction* NewHDiv(Zone* zone, |
- HValue* context, |
- HValue* left, |
- HValue* right); |
- |
DECLARE_CONCRETE_INSTRUCTION(Div) |
protected: |
virtual bool DataEquals(HValue* other) { return true; } |
virtual Range* InferRange(Zone* zone); |
+ |
+ private: |
+ HDiv(HValue* context, HValue* left, HValue* right) |
+ : HArithmeticBinaryOperation(context, left, right) { |
+ SetFlag(kCanBeDivByZero); |
+ SetFlag(kCanOverflow); |
+ } |
}; |
@@ -4121,9 +4141,11 @@ class HMathMinMax: public HArithmeticBinaryOperation { |
public: |
enum Operation { kMathMin, kMathMax }; |
- HMathMinMax(HValue* context, HValue* left, HValue* right, Operation op) |
- : HArithmeticBinaryOperation(context, left, right), |
- operation_(op) { } |
+ static HInstruction* New(Zone* zone, |
+ HValue* context, |
+ HValue* left, |
+ HValue* right, |
+ Operation op); |
virtual Representation RequiredInputRepresentation(int index) { |
return index == 0 ? Representation::Tagged() |
@@ -4161,18 +4183,21 @@ class HMathMinMax: public HArithmeticBinaryOperation { |
virtual Range* InferRange(Zone* zone); |
private: |
+ HMathMinMax(HValue* context, HValue* left, HValue* right, Operation op) |
+ : HArithmeticBinaryOperation(context, left, right), |
+ operation_(op) { } |
+ |
Operation operation_; |
}; |
class HBitwise: public HBitwiseBinaryOperation { |
public: |
- HBitwise(Token::Value op, HValue* context, HValue* left, HValue* right) |
- : HBitwiseBinaryOperation(context, left, right), op_(op) { |
- ASSERT(op == Token::BIT_AND || |
- op == Token::BIT_OR || |
- op == Token::BIT_XOR); |
- } |
+ static HInstruction* New(Zone* zone, |
+ Token::Value op, |
+ HValue* context, |
+ HValue* left, |
+ HValue* right); |
Token::Value op() const { return op_; } |
@@ -4180,12 +4205,6 @@ class HBitwise: public HBitwiseBinaryOperation { |
virtual HValue* Canonicalize(); |
- static HInstruction* NewHBitwise(Zone* zone, |
- Token::Value op, |
- HValue* context, |
- HValue* left, |
- HValue* right); |
- |
virtual void PrintDataTo(StringStream* stream); |
DECLARE_CONCRETE_INSTRUCTION(Bitwise) |
@@ -4198,79 +4217,82 @@ class HBitwise: public HBitwiseBinaryOperation { |
virtual Range* InferRange(Zone* zone); |
private: |
+ HBitwise(Token::Value op, HValue* context, HValue* left, HValue* right) |
+ : HBitwiseBinaryOperation(context, left, right), op_(op) { |
+ ASSERT(op == Token::BIT_AND || op == Token::BIT_OR || op == Token::BIT_XOR); |
+ } |
+ |
Token::Value op_; |
}; |
class HShl: public HBitwiseBinaryOperation { |
public: |
- HShl(HValue* context, HValue* left, HValue* right) |
- : HBitwiseBinaryOperation(context, left, right) { } |
+ static HInstruction* New(Zone* zone, |
+ HValue* context, |
+ HValue* left, |
+ HValue* right); |
virtual Range* InferRange(Zone* zone); |
- static HInstruction* NewHShl(Zone* zone, |
- HValue* context, |
- HValue* left, |
- HValue* right); |
- |
DECLARE_CONCRETE_INSTRUCTION(Shl) |
protected: |
virtual bool DataEquals(HValue* other) { return true; } |
+ |
+ private: |
+ HShl(HValue* context, HValue* left, HValue* right) |
+ : HBitwiseBinaryOperation(context, left, right) { } |
}; |
class HShr: public HBitwiseBinaryOperation { |
public: |
- HShr(HValue* context, HValue* left, HValue* right) |
- : HBitwiseBinaryOperation(context, left, right) { } |
+ static HInstruction* New(Zone* zone, |
+ HValue* context, |
+ HValue* left, |
+ HValue* right); |
virtual Range* InferRange(Zone* zone); |
- static HInstruction* NewHShr(Zone* zone, |
- HValue* context, |
- HValue* left, |
- HValue* right); |
- |
DECLARE_CONCRETE_INSTRUCTION(Shr) |
protected: |
virtual bool DataEquals(HValue* other) { return true; } |
+ |
+ private: |
+ HShr(HValue* context, HValue* left, HValue* right) |
+ : HBitwiseBinaryOperation(context, left, right) { } |
}; |
class HSar: public HBitwiseBinaryOperation { |
public: |
- HSar(HValue* context, HValue* left, HValue* right) |
- : HBitwiseBinaryOperation(context, left, right) { } |
+ static HInstruction* New(Zone* zone, |
+ HValue* context, |
+ HValue* left, |
+ HValue* right); |
virtual Range* InferRange(Zone* zone); |
- static HInstruction* NewHSar(Zone* zone, |
- HValue* context, |
- HValue* left, |
- HValue* right); |
- |
DECLARE_CONCRETE_INSTRUCTION(Sar) |
protected: |
virtual bool DataEquals(HValue* other) { return true; } |
+ |
+ private: |
+ HSar(HValue* context, HValue* left, HValue* right) |
+ : HBitwiseBinaryOperation(context, left, right) { } |
}; |
class HRor: public HBitwiseBinaryOperation { |
public: |
HRor(HValue* context, HValue* left, HValue* right) |
- : HBitwiseBinaryOperation(context, left, right) { |
+ : HBitwiseBinaryOperation(context, left, right) { |
ChangeRepresentation(Representation::Integer32()); |
} |
- static HInstruction* NewHRor(Zone* zone, |
- HValue* context, |
- HValue* left, |
- HValue* right); |
- |
DECLARE_CONCRETE_INSTRUCTION(Ror) |
protected: |
@@ -5394,13 +5416,10 @@ class HTransitionElementsKind: public HTemplateInstruction<2> { |
class HStringAdd: public HBinaryOperation { |
public: |
- HStringAdd(HValue* context, HValue* left, HValue* right) |
- : HBinaryOperation(context, left, right) { |
- set_representation(Representation::Tagged()); |
- SetFlag(kUseGVN); |
- SetGVNFlag(kDependsOnMaps); |
- SetGVNFlag(kChangesNewSpacePromotion); |
- } |
+ static HInstruction* New(Zone* zone, |
+ HValue* context, |
+ HValue* left, |
+ HValue* right); |
virtual Representation RequiredInputRepresentation(int index) { |
return Representation::Tagged(); |
@@ -5415,8 +5434,17 @@ class HStringAdd: public HBinaryOperation { |
protected: |
virtual bool DataEquals(HValue* other) { return true; } |
+ |
+ private: |
+ HStringAdd(HValue* context, HValue* left, HValue* right) |
+ : HBinaryOperation(context, left, right) { |
+ set_representation(Representation::Tagged()); |
+ SetFlag(kUseGVN); |
+ SetGVNFlag(kDependsOnMaps); |
+ SetGVNFlag(kChangesNewSpacePromotion); |
+ } |
+ |
// TODO(svenpanne) Might be safe, but leave it out until we know for sure. |
- // private: |
// virtual bool IsDeletable() const { return true; } |
}; |
@@ -5461,13 +5489,9 @@ class HStringCharCodeAt: public HTemplateInstruction<3> { |
class HStringCharFromCode: public HTemplateInstruction<2> { |
public: |
- HStringCharFromCode(HValue* context, HValue* char_code) { |
- SetOperandAt(0, context); |
- SetOperandAt(1, char_code); |
- set_representation(Representation::Tagged()); |
- SetFlag(kUseGVN); |
- SetGVNFlag(kChangesNewSpacePromotion); |
- } |
+ static HInstruction* New(Zone* zone, |
+ HValue* context, |
+ HValue* char_code); |
virtual Representation RequiredInputRepresentation(int index) { |
return index == 0 |
@@ -5483,19 +5507,23 @@ class HStringCharFromCode: public HTemplateInstruction<2> { |
DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode) |
+ private: |
+ HStringCharFromCode(HValue* context, HValue* char_code) { |
+ SetOperandAt(0, context); |
+ SetOperandAt(1, char_code); |
+ set_representation(Representation::Tagged()); |
+ SetFlag(kUseGVN); |
+ SetGVNFlag(kChangesNewSpacePromotion); |
+ } |
+ |
// TODO(svenpanne) Might be safe, but leave it out until we know for sure. |
- // private: |
- // virtual bool IsDeletable() const { return true; } |
+ // virtual bool IsDeletable() const { return true; } |
}; |
class HStringLength: public HUnaryOperation { |
public: |
- explicit HStringLength(HValue* string) : HUnaryOperation(string) { |
- set_representation(Representation::Tagged()); |
- SetFlag(kUseGVN); |
- SetGVNFlag(kDependsOnMaps); |
- } |
+ static HInstruction* New(Zone* zone, HValue* string); |
virtual Representation RequiredInputRepresentation(int index) { |
return Representation::Tagged(); |
@@ -5516,6 +5544,12 @@ class HStringLength: public HUnaryOperation { |
} |
private: |
+ explicit HStringLength(HValue* string) : HUnaryOperation(string) { |
+ set_representation(Representation::Tagged()); |
+ SetFlag(kUseGVN); |
+ SetGVNFlag(kDependsOnMaps); |
+ } |
+ |
virtual bool IsDeletable() const { return true; } |
}; |