| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 | 393 |
| 394 int LCodeGen::ToInteger32(LConstantOperand* op) const { | 394 int LCodeGen::ToInteger32(LConstantOperand* op) const { |
| 395 Handle<Object> value = chunk_->LookupLiteral(op); | 395 Handle<Object> value = chunk_->LookupLiteral(op); |
| 396 ASSERT(chunk_->LookupLiteralRepresentation(op).IsInteger32()); | 396 ASSERT(chunk_->LookupLiteralRepresentation(op).IsInteger32()); |
| 397 ASSERT(static_cast<double>(static_cast<int32_t>(value->Number())) == | 397 ASSERT(static_cast<double>(static_cast<int32_t>(value->Number())) == |
| 398 value->Number()); | 398 value->Number()); |
| 399 return static_cast<int32_t>(value->Number()); | 399 return static_cast<int32_t>(value->Number()); |
| 400 } | 400 } |
| 401 | 401 |
| 402 | 402 |
| 403 double LCodeGen::ToDouble(LConstantOperand* op) const { |
| 404 Handle<Object> value = chunk_->LookupLiteral(op); |
| 405 return value->Number(); |
| 406 } |
| 407 |
| 408 |
| 403 Operand LCodeGen::ToOperand(LOperand* op) { | 409 Operand LCodeGen::ToOperand(LOperand* op) { |
| 404 if (op->IsConstantOperand()) { | 410 if (op->IsConstantOperand()) { |
| 405 LConstantOperand* const_op = LConstantOperand::cast(op); | 411 LConstantOperand* const_op = LConstantOperand::cast(op); |
| 406 Handle<Object> literal = chunk_->LookupLiteral(const_op); | 412 Handle<Object> literal = chunk_->LookupLiteral(const_op); |
| 407 Representation r = chunk_->LookupLiteralRepresentation(const_op); | 413 Representation r = chunk_->LookupLiteralRepresentation(const_op); |
| 408 if (r.IsInteger32()) { | 414 if (r.IsInteger32()) { |
| 409 ASSERT(literal->IsNumber()); | 415 ASSERT(literal->IsNumber()); |
| 410 return Operand(static_cast<int32_t>(literal->Number())); | 416 return Operand(static_cast<int32_t>(literal->Number())); |
| 411 } else if (r.IsDouble()) { | 417 } else if (r.IsDouble()) { |
| 412 Abort("ToOperand Unsupported double immediate."); | 418 Abort("ToOperand Unsupported double immediate."); |
| (...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 break; | 1693 break; |
| 1688 case Token::IN: | 1694 case Token::IN: |
| 1689 case Token::INSTANCEOF: | 1695 case Token::INSTANCEOF: |
| 1690 default: | 1696 default: |
| 1691 UNREACHABLE(); | 1697 UNREACHABLE(); |
| 1692 } | 1698 } |
| 1693 return cond; | 1699 return cond; |
| 1694 } | 1700 } |
| 1695 | 1701 |
| 1696 | 1702 |
| 1697 void LCodeGen::EmitCmpI(LOperand* left, LOperand* right) { | |
| 1698 __ cmp(ToRegister(left), ToRegister(right)); | |
| 1699 } | |
| 1700 | |
| 1701 | |
| 1702 void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) { | 1703 void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) { |
| 1703 LOperand* left = instr->InputAt(0); | 1704 LOperand* left = instr->InputAt(0); |
| 1704 LOperand* right = instr->InputAt(1); | 1705 LOperand* right = instr->InputAt(1); |
| 1705 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1706 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1706 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1707 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1708 Condition cond = TokenToCondition(instr->op(), false); |
| 1707 | 1709 |
| 1708 if (instr->is_double()) { | 1710 if (left->IsConstantOperand() && right->IsConstantOperand()) { |
| 1709 // Compare left and right as doubles and load the | 1711 // We can statically evaluate the comparison. |
| 1710 // resulting flags into the normal status register. | 1712 double left_val = ToDouble(LConstantOperand::cast(left)); |
| 1711 __ VFPCompareAndSetFlags(ToDoubleRegister(left), ToDoubleRegister(right)); | 1713 double right_val = ToDouble(LConstantOperand::cast(right)); |
| 1712 // If a NaN is involved, i.e. the result is unordered (V set), | 1714 int next_block = |
| 1713 // jump to false block label. | 1715 EvalComparison(instr->op(), left_val, right_val) ? true_block |
| 1714 __ b(vs, chunk_->GetAssemblyLabel(false_block)); | 1716 : false_block; |
| 1717 EmitGoto(next_block); |
| 1715 } else { | 1718 } else { |
| 1716 EmitCmpI(left, right); | 1719 if (instr->is_double()) { |
| 1720 // Compare left and right operands as doubles and load the |
| 1721 // resulting flags into the normal status register. |
| 1722 __ VFPCompareAndSetFlags(ToDoubleRegister(left), ToDoubleRegister(right)); |
| 1723 // If a NaN is involved, i.e. the result is unordered (V set), |
| 1724 // jump to false block label. |
| 1725 __ b(vs, chunk_->GetAssemblyLabel(false_block)); |
| 1726 } else { |
| 1727 if (right->IsConstantOperand()) { |
| 1728 __ cmp(ToRegister(left), |
| 1729 Operand(ToInteger32(LConstantOperand::cast(right)))); |
| 1730 } else if (left->IsConstantOperand()) { |
| 1731 __ cmp(ToRegister(right), |
| 1732 Operand(ToInteger32(LConstantOperand::cast(left)))); |
| 1733 // We transposed the operands. Reverse the condition. |
| 1734 cond = ReverseCondition(cond); |
| 1735 } else { |
| 1736 __ cmp(ToRegister(left), ToRegister(right)); |
| 1737 } |
| 1738 } |
| 1739 EmitBranch(true_block, false_block, cond); |
| 1717 } | 1740 } |
| 1718 | |
| 1719 Condition cc = TokenToCondition(instr->op(), instr->is_double()); | |
| 1720 EmitBranch(true_block, false_block, cc); | |
| 1721 } | 1741 } |
| 1722 | 1742 |
| 1723 | 1743 |
| 1724 void LCodeGen::DoCmpObjectEqAndBranch(LCmpObjectEqAndBranch* instr) { | 1744 void LCodeGen::DoCmpObjectEqAndBranch(LCmpObjectEqAndBranch* instr) { |
| 1725 Register left = ToRegister(instr->InputAt(0)); | 1745 Register left = ToRegister(instr->InputAt(0)); |
| 1726 Register right = ToRegister(instr->InputAt(1)); | 1746 Register right = ToRegister(instr->InputAt(1)); |
| 1727 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1747 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1728 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1748 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1729 | 1749 |
| 1730 __ cmp(left, Operand(right)); | 1750 __ cmp(left, Operand(right)); |
| (...skipping 2796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4527 ASSERT(osr_pc_offset_ == -1); | 4547 ASSERT(osr_pc_offset_ == -1); |
| 4528 osr_pc_offset_ = masm()->pc_offset(); | 4548 osr_pc_offset_ = masm()->pc_offset(); |
| 4529 } | 4549 } |
| 4530 | 4550 |
| 4531 | 4551 |
| 4532 | 4552 |
| 4533 | 4553 |
| 4534 #undef __ | 4554 #undef __ |
| 4535 | 4555 |
| 4536 } } // namespace v8::internal | 4556 } } // namespace v8::internal |
| OLD | NEW |