| 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 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1650 break; | 1656 break; |
| 1651 case Token::IN: | 1657 case Token::IN: |
| 1652 case Token::INSTANCEOF: | 1658 case Token::INSTANCEOF: |
| 1653 default: | 1659 default: |
| 1654 UNREACHABLE(); | 1660 UNREACHABLE(); |
| 1655 } | 1661 } |
| 1656 return cond; | 1662 return cond; |
| 1657 } | 1663 } |
| 1658 | 1664 |
| 1659 | 1665 |
| 1660 void LCodeGen::EmitCmpI(LOperand* left, LOperand* right) { | |
| 1661 __ cmp(ToRegister(left), ToRegister(right)); | |
| 1662 } | |
| 1663 | |
| 1664 | |
| 1665 void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) { | 1666 void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) { |
| 1666 LOperand* left = instr->InputAt(0); | 1667 LOperand* left = instr->InputAt(0); |
| 1667 LOperand* right = instr->InputAt(1); | 1668 LOperand* right = instr->InputAt(1); |
| 1668 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1669 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1669 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1670 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1671 Condition cond = TokenToCondition(instr->op(), instr->is_double()); |
| 1670 | 1672 |
| 1671 if (instr->is_double()) { | 1673 if (left->IsConstantOperand() && right->IsConstantOperand()) { |
| 1672 // Compare left and right as doubles and load the | 1674 // We can statically evaluate the comparison. |
| 1673 // resulting flags into the normal status register. | 1675 double left_val = ToDouble(LConstantOperand::cast(left)); |
| 1674 __ VFPCompareAndSetFlags(ToDoubleRegister(left), ToDoubleRegister(right)); | 1676 double right_val = ToDouble(LConstantOperand::cast(right)); |
| 1675 // If a NaN is involved, i.e. the result is unordered (V set), | 1677 int next_block = EvalComparison(cond, left_val, right_val) ? true_block |
| 1676 // jump to false block label. | 1678 : false_block; |
| 1677 __ b(vs, chunk_->GetAssemblyLabel(false_block)); | 1679 EmitGoto(next_block); |
| 1678 } else { | 1680 } else { |
| 1679 EmitCmpI(left, right); | 1681 if (instr->is_double()) { |
| 1682 // Compare left and right operands as doubles and load the |
| 1683 // resulting flags into the normal status register. |
| 1684 __ VFPCompareAndSetFlags(ToDoubleRegister(left), ToDoubleRegister(right)); |
| 1685 // If a NaN is involved, i.e. the result is unordered (V set), |
| 1686 // jump to false block label. |
| 1687 __ b(vs, chunk_->GetAssemblyLabel(false_block)); |
| 1688 } else { |
| 1689 if (right->IsConstantOperand()) { |
| 1690 __ cmp(ToRegister(left), |
| 1691 Operand(ToInteger32(LConstantOperand::cast(right)))); |
| 1692 } else if (left->IsConstantOperand()) { |
| 1693 __ cmp(ToRegister(right), |
| 1694 Operand(ToInteger32(LConstantOperand::cast(left)))); |
| 1695 // We transposed the operands. Reverse the condition. |
| 1696 cond = ReverseCondition(cond); |
| 1697 } else { |
| 1698 __ cmp(ToRegister(left), ToRegister(right)); |
| 1699 } |
| 1700 } |
| 1701 EmitBranch(true_block, false_block, cond); |
| 1680 } | 1702 } |
| 1681 | |
| 1682 Condition cc = TokenToCondition(instr->op(), instr->is_double()); | |
| 1683 EmitBranch(true_block, false_block, cc); | |
| 1684 } | 1703 } |
| 1685 | 1704 |
| 1686 | 1705 |
| 1687 void LCodeGen::DoCmpObjectEqAndBranch(LCmpObjectEqAndBranch* instr) { | 1706 void LCodeGen::DoCmpObjectEqAndBranch(LCmpObjectEqAndBranch* instr) { |
| 1688 Register left = ToRegister(instr->InputAt(0)); | 1707 Register left = ToRegister(instr->InputAt(0)); |
| 1689 Register right = ToRegister(instr->InputAt(1)); | 1708 Register right = ToRegister(instr->InputAt(1)); |
| 1690 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1709 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1691 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1710 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1692 | 1711 |
| 1693 __ cmp(left, Operand(right)); | 1712 __ cmp(left, Operand(right)); |
| (...skipping 2791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4485 ASSERT(osr_pc_offset_ == -1); | 4504 ASSERT(osr_pc_offset_ == -1); |
| 4486 osr_pc_offset_ = masm()->pc_offset(); | 4505 osr_pc_offset_ = masm()->pc_offset(); |
| 4487 } | 4506 } |
| 4488 | 4507 |
| 4489 | 4508 |
| 4490 | 4509 |
| 4491 | 4510 |
| 4492 #undef __ | 4511 #undef __ |
| 4493 | 4512 |
| 4494 } } // namespace v8::internal | 4513 } } // namespace v8::internal |
| OLD | NEW |