diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc index 72bff7850e..861ea38104 100644 --- a/src/arm/lithium-arm.cc +++ b/src/arm/lithium-arm.cc @@ -1667,7 +1667,7 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) { LInstruction* LChunkBuilder::DoCheckNonSmi(HCheckNonSmi* instr) { LOperand* value = UseRegisterAtStart(instr->value()); - return AssignEnvironment(new LCheckSmi(value, eq)); + return AssignEnvironment(new LCheckNonSmi(value)); } @@ -1688,7 +1688,7 @@ LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) { LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) { LOperand* value = UseRegisterAtStart(instr->value()); - return AssignEnvironment(new LCheckSmi(value, ne)); + return AssignEnvironment(new LCheckSmi(value)); } diff --git a/src/arm/lithium-arm.h b/src/arm/lithium-arm.h index cb811ccd6e..a148fdbea4 100644 --- a/src/arm/lithium-arm.h +++ b/src/arm/lithium-arm.h @@ -69,6 +69,7 @@ class LCodeGen; V(CallStub) \ V(CheckFunction) \ V(CheckInstanceType) \ + V(CheckNonSmi) \ V(CheckMap) \ V(CheckPrototypeMaps) \ V(CheckSmi) \ @@ -1718,20 +1719,21 @@ class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 2> { class LCheckSmi: public LTemplateInstruction<0, 1, 0> { public: - LCheckSmi(LOperand* value, Condition condition) - : condition_(condition) { + explicit LCheckSmi(LOperand* value) { inputs_[0] = value; } - Condition condition() const { return condition_; } + DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi") +}; - virtual void CompileToNative(LCodeGen* generator); - virtual const char* Mnemonic() const { - return (condition_ == eq) ? "check-non-smi" : "check-smi"; + +class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> { + public: + explicit LCheckNonSmi(LOperand* value) { + inputs_[0] = value; } - private: - Condition condition_; + DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi") }; diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index aa252f1fcf..a2d1df04ae 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -3525,9 +3525,15 @@ void LCodeGen::DoDoubleToI(LDoubleToI* instr) { void LCodeGen::DoCheckSmi(LCheckSmi* instr) { LOperand* input = instr->InputAt(0); - ASSERT(input->IsRegister()); __ tst(ToRegister(input), Operand(kSmiTagMask)); - DeoptimizeIf(instr->condition(), instr->environment()); + DeoptimizeIf(ne, instr->environment()); +} + + +void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) { + LOperand* input = instr->InputAt(0); + __ tst(ToRegister(input), Operand(kSmiTagMask)); + DeoptimizeIf(eq, instr->environment()); } diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index 2446c576ce..95383b301f 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -3497,9 +3497,15 @@ void LCodeGen::DoDoubleToI(LDoubleToI* instr) { void LCodeGen::DoCheckSmi(LCheckSmi* instr) { LOperand* input = instr->InputAt(0); - ASSERT(input->IsRegister()); __ test(ToRegister(input), Immediate(kSmiTagMask)); - DeoptimizeIf(instr->condition(), instr->environment()); + DeoptimizeIf(not_zero, instr->environment()); +} + + +void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) { + LOperand* input = instr->InputAt(0); + __ test(ToRegister(input), Immediate(kSmiTagMask)); + DeoptimizeIf(zero, instr->environment()); } diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc index 3148ae2b24..3408451c0a 100644 --- a/src/ia32/lithium-ia32.cc +++ b/src/ia32/lithium-ia32.cc @@ -1683,7 +1683,7 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) { LInstruction* LChunkBuilder::DoCheckNonSmi(HCheckNonSmi* instr) { LOperand* value = UseRegisterAtStart(instr->value()); - return AssignEnvironment(new LCheckSmi(value, zero)); + return AssignEnvironment(new LCheckNonSmi(value)); } @@ -1704,7 +1704,7 @@ LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) { LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) { LOperand* value = UseRegisterAtStart(instr->value()); - return AssignEnvironment(new LCheckSmi(value, not_zero)); + return AssignEnvironment(new LCheckSmi(value)); } diff --git a/src/ia32/lithium-ia32.h b/src/ia32/lithium-ia32.h index 9a07c6f2a1..3d09267499 100644 --- a/src/ia32/lithium-ia32.h +++ b/src/ia32/lithium-ia32.h @@ -70,6 +70,7 @@ class LCodeGen; V(CheckFunction) \ V(CheckInstanceType) \ V(CheckMap) \ + V(CheckNonSmi) \ V(CheckPrototypeMaps) \ V(CheckSmi) \ V(ClassOfTest) \ @@ -1792,20 +1793,21 @@ class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 1> { class LCheckSmi: public LTemplateInstruction<0, 1, 0> { public: - LCheckSmi(LOperand* value, Condition condition) - : condition_(condition) { + explicit LCheckSmi(LOperand* value) { inputs_[0] = value; } - Condition condition() const { return condition_; } + DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi") +}; - virtual void CompileToNative(LCodeGen* generator); - virtual const char* Mnemonic() const { - return (condition_ == zero) ? "check-non-smi" : "check-smi"; + +class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> { + public: + explicit LCheckNonSmi(LOperand* value) { + inputs_[0] = value; } - private: - Condition condition_; + DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi") }; diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index d48b871769..8809f8877c 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -3297,11 +3297,14 @@ void LCodeGen::DoDoubleToI(LDoubleToI* instr) { void LCodeGen::DoCheckSmi(LCheckSmi* instr) { LOperand* input = instr->InputAt(0); - ASSERT(input->IsRegister()); Condition cc = masm()->CheckSmi(ToRegister(input)); - if (instr->condition() != equal) { - cc = NegateCondition(cc); - } + DeoptimizeIf(NegateCondition(cc), instr->environment()); +} + + +void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) { + LOperand* input = instr->InputAt(0); + Condition cc = masm()->CheckSmi(ToRegister(input)); DeoptimizeIf(cc, instr->environment()); } diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc index 99a7ace3d1..4882d79a16 100644 --- a/src/x64/lithium-x64.cc +++ b/src/x64/lithium-x64.cc @@ -1658,7 +1658,7 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) { LInstruction* LChunkBuilder::DoCheckNonSmi(HCheckNonSmi* instr) { LOperand* value = UseRegisterAtStart(instr->value()); - return AssignEnvironment(new LCheckSmi(value, zero)); + return AssignEnvironment(new LCheckNonSmi(value)); } @@ -1678,7 +1678,7 @@ LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) { LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) { LOperand* value = UseRegisterAtStart(instr->value()); - return AssignEnvironment(new LCheckSmi(value, not_zero)); + return AssignEnvironment(new LCheckSmi(value)); } diff --git a/src/x64/lithium-x64.h b/src/x64/lithium-x64.h index 926924b5d4..b43b9aea7b 100644 --- a/src/x64/lithium-x64.h +++ b/src/x64/lithium-x64.h @@ -70,6 +70,7 @@ class LCodeGen; V(CheckFunction) \ V(CheckInstanceType) \ V(CheckMap) \ + V(CheckNonSmi) \ V(CheckPrototypeMaps) \ V(CheckSmi) \ V(ClassOfTest) \ @@ -1707,20 +1708,21 @@ class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 1> { class LCheckSmi: public LTemplateInstruction<0, 1, 0> { public: - LCheckSmi(LOperand* value, Condition condition) - : condition_(condition) { + explicit LCheckSmi(LOperand* value) { inputs_[0] = value; } - Condition condition() const { return condition_; } + DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi") +}; - virtual void CompileToNative(LCodeGen* generator); - virtual const char* Mnemonic() const { - return (condition_ == zero) ? "check-non-smi" : "check-smi"; + +class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> { + public: + explicit LCheckNonSmi(LOperand* value) { + inputs_[0] = value; } - private: - Condition condition_; + DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi") };