| Index: src/hydrogen-instructions.cc
|
| diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
|
| index 11cc901b38ccfccf7a3607f99e1088b47b7f4ac9..6b7a08f8e87de43440b64ea830072964af42f37d 100644
|
| --- a/src/hydrogen-instructions.cc
|
| +++ b/src/hydrogen-instructions.cc
|
| @@ -524,6 +524,17 @@ const char* HValue::Mnemonic() const {
|
| }
|
|
|
|
|
| +bool HValue::IsInteger32Constant() {
|
| + return IsConstant() && HConstant::cast(this)->HasInteger32Value();
|
| +}
|
| +
|
| +
|
| +int32_t HValue::GetInteger32Constant() {
|
| + ASSERT(IsInteger32Constant());
|
| + return HConstant::cast(this)->Integer32Value();
|
| +}
|
| +
|
| +
|
| void HValue::SetOperandAt(int index, HValue* value) {
|
| RegisterUse(index, value);
|
| InternalSetOperandAt(index, value);
|
| @@ -690,6 +701,14 @@ void HInstruction::PrintMnemonicTo(StringStream* stream) {
|
| }
|
|
|
|
|
| +HValue* HValue::AddNumericConstraint(HInstruction* insertion_point,
|
| + HValue* related_value,
|
| + NumericRelation relation) {
|
| + return HNumericConstraint::New(
|
| + insertion_point, this, related_value, relation);
|
| +}
|
| +
|
| +
|
| void HInstruction::Unlink() {
|
| ASSERT(IsLinked());
|
| ASSERT(!IsControlInstruction()); // Must never move control instructions.
|
| @@ -794,6 +813,27 @@ void HInstruction::Verify() {
|
| #endif
|
|
|
|
|
| +HNumericConstraint* HNumericConstraint::New(HInstruction* insertion_point,
|
| + HValue* constrained_value,
|
| + HValue* related_value,
|
| + NumericRelation relation) {
|
| + HNumericConstraint* result =
|
| + new(insertion_point->block()->zone()) HNumericConstraint(
|
| + constrained_value, related_value, relation);
|
| + result->InsertAfter(insertion_point);
|
| + return result;
|
| +}
|
| +
|
| +
|
| +void HNumericConstraint::PrintDataTo(StringStream* stream) {
|
| + stream->Add("(");
|
| + constrained_value()->PrintNameTo(stream);
|
| + stream->Add(" %s ", relation().Mnemonic());
|
| + related_value()->PrintNameTo(stream);
|
| + stream->Add(")");
|
| +}
|
| +
|
| +
|
| void HDummyUse::PrintDataTo(StringStream* stream) {
|
| value()->PrintNameTo(stream);
|
| }
|
| @@ -815,6 +855,18 @@ void HBinaryCall::PrintDataTo(StringStream* stream) {
|
| }
|
|
|
|
|
| +bool HBoundsCheck::CheckRelation(NumericRelation relation,
|
| + HValue* related_value) {
|
| + if (related_value == length()) {
|
| + return NumericRelation::Lt().Implies(relation);
|
| + } else if (related_value == block()->graph()->GetConstant0()) {
|
| + return NumericRelation::Ge().Implies(relation);
|
| + } else {
|
| + return false;
|
| + }
|
| +}
|
| +
|
| +
|
| void HBoundsCheck::PrintDataTo(StringStream* stream) {
|
| index()->PrintNameTo(stream);
|
| stream->Add(" ");
|
| @@ -1476,6 +1528,31 @@ Range* HMod::InferRange(Zone* zone) {
|
| }
|
|
|
|
|
| +void HPhi::AddInformativeDefinitions() {
|
| + HValue* induction_base = NULL;
|
| + NumericRelation relation = NumericRelation::None();
|
| + if (OperandCount() == 2) {
|
| + if (OperandAt(0)->IsRelationTrue(NumericRelation::Ge(), this)) {
|
| + induction_base = OperandAt(1);
|
| + relation = NumericRelation::Ge();
|
| + } else if (OperandAt(0)->IsRelationTrue(NumericRelation::Le(), this)) {
|
| + induction_base = OperandAt(1);
|
| + relation = NumericRelation::Ge();
|
| + } else if (OperandAt(1)->IsRelationTrue(NumericRelation::Ge(), this)) {
|
| + induction_base = OperandAt(0);
|
| + relation = NumericRelation::Ge();
|
| + } else if (OperandAt(1)->IsRelationTrue(NumericRelation::Le(), this)) {
|
| + induction_base = OperandAt(0);
|
| + relation = NumericRelation::Ge();
|
| + }
|
| + }
|
| +
|
| + if (induction_base == NULL) return;
|
| +
|
| + AddNumericConstraint(block()->first(), induction_base, relation);
|
| +}
|
| +
|
| +
|
| Range* HMathMinMax::InferRange(Zone* zone) {
|
| if (representation().IsInteger32()) {
|
| Range* a = left()->range();
|
| @@ -1937,6 +2014,15 @@ void HStringCompareAndBranch::PrintDataTo(StringStream* stream) {
|
| }
|
|
|
|
|
| +void HCompareIDAndBranch::AddInformativeDefinitions() {
|
| + NumericRelation r = NumericRelation::FromToken(token());
|
| + if (r == NumericRelation::None()) return;
|
| +
|
| + left()->AddNumericConstraint(SuccessorAt(0)->first(), right(), r);
|
| + left()->AddNumericConstraint(SuccessorAt(1)->first(), right(), r.Reversed());
|
| +}
|
| +
|
| +
|
| void HCompareIDAndBranch::PrintDataTo(StringStream* stream) {
|
| stream->Add(Token::Name(token()));
|
| stream->Add(" ");
|
|
|