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 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 case Token::IN: | 1598 case Token::IN: |
1599 case Token::INSTANCEOF: | 1599 case Token::INSTANCEOF: |
1600 default: | 1600 default: |
1601 UNREACHABLE(); | 1601 UNREACHABLE(); |
1602 } | 1602 } |
1603 return cond; | 1603 return cond; |
1604 } | 1604 } |
1605 | 1605 |
1606 | 1606 |
1607 void LCodeGen::EmitCmpI(LOperand* left, LOperand* right) { | 1607 void LCodeGen::EmitCmpI(LOperand* left, LOperand* right) { |
1608 __ cmp(ToRegister(left), ToOperand(right)); | 1608 __ cmp(ToRegister(left), ToRegister(right)); |
1609 } | 1609 } |
1610 | 1610 |
1611 | 1611 |
1612 void LCodeGen::DoCmpID(LCmpID* instr) { | 1612 void LCodeGen::DoCmpID(LCmpID* instr) { |
1613 LOperand* left = instr->InputAt(0); | 1613 LOperand* left = instr->InputAt(0); |
1614 LOperand* right = instr->InputAt(1); | 1614 LOperand* right = instr->InputAt(1); |
1615 LOperand* result = instr->result(); | 1615 LOperand* result = instr->result(); |
1616 Register scratch = scratch0(); | 1616 Register scratch = scratch0(); |
1617 | 1617 |
1618 Label unordered, done; | 1618 Label unordered, done; |
1619 if (instr->is_double()) { | 1619 if (instr->is_double()) { |
1620 // Compare left and right as doubles and load the | 1620 // Compare left and right as doubles and load the |
1621 // resulting flags into the normal status register. | 1621 // resulting flags into the normal status register. |
1622 __ vcmp(ToDoubleRegister(left), ToDoubleRegister(right)); | 1622 __ VFPCompareAndSetFlags(ToDoubleRegister(left), ToDoubleRegister(right)); |
1623 __ vmrs(pc); | |
1624 // If a NaN is involved, i.e. the result is unordered (V set), | 1623 // If a NaN is involved, i.e. the result is unordered (V set), |
1625 // jump to unordered to return false. | 1624 // jump to unordered to return false. |
1626 __ b(vs, &unordered); | 1625 __ b(vs, &unordered); |
1627 } else { | 1626 } else { |
1628 EmitCmpI(left, right); | 1627 EmitCmpI(left, right); |
1629 } | 1628 } |
1630 | 1629 |
1631 Condition cc = TokenToCondition(instr->op(), instr->is_double()); | 1630 Condition cc = TokenToCondition(instr->op(), instr->is_double()); |
1632 __ LoadRoot(ToRegister(result), Heap::kTrueValueRootIndex); | 1631 __ LoadRoot(ToRegister(result), Heap::kTrueValueRootIndex); |
1633 __ b(cc, &done); | 1632 __ b(cc, &done); |
1634 | 1633 |
1635 __ bind(&unordered); | 1634 __ bind(&unordered); |
1636 __ LoadRoot(ToRegister(result), Heap::kFalseValueRootIndex); | 1635 __ LoadRoot(ToRegister(result), Heap::kFalseValueRootIndex); |
1637 __ bind(&done); | 1636 __ bind(&done); |
1638 } | 1637 } |
1639 | 1638 |
1640 | 1639 |
1641 void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) { | 1640 void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) { |
1642 LOperand* left = instr->InputAt(0); | 1641 LOperand* left = instr->InputAt(0); |
1643 LOperand* right = instr->InputAt(1); | 1642 LOperand* right = instr->InputAt(1); |
1644 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1643 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
1645 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1644 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
1646 | 1645 |
1647 if (instr->is_double()) { | 1646 if (instr->is_double()) { |
1648 // Compare left and right as doubles and load the | 1647 // Compare left and right as doubles and load the |
1649 // resulting flags into the normal status register. | 1648 // resulting flags into the normal status register. |
1650 __ vcmp(ToDoubleRegister(left), ToDoubleRegister(right)); | 1649 __ VFPCompareAndSetFlags(ToDoubleRegister(left), ToDoubleRegister(right)); |
1651 __ vmrs(pc); | |
1652 // If a NaN is involved, i.e. the result is unordered (V set), | 1650 // If a NaN is involved, i.e. the result is unordered (V set), |
1653 // jump to false block label. | 1651 // jump to false block label. |
1654 __ b(vs, chunk_->GetAssemblyLabel(false_block)); | 1652 __ b(vs, chunk_->GetAssemblyLabel(false_block)); |
1655 } else { | 1653 } else { |
1656 EmitCmpI(left, right); | 1654 EmitCmpI(left, right); |
1657 } | 1655 } |
1658 | 1656 |
1659 Condition cc = TokenToCondition(instr->op(), instr->is_double()); | 1657 Condition cc = TokenToCondition(instr->op(), instr->is_double()); |
1660 EmitBranch(true_block, false_block, cc); | 1658 EmitBranch(true_block, false_block, cc); |
1661 } | 1659 } |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2173 return kNoCondition; | 2171 return kNoCondition; |
2174 } | 2172 } |
2175 } | 2173 } |
2176 | 2174 |
2177 | 2175 |
2178 void LCodeGen::DoCmpT(LCmpT* instr) { | 2176 void LCodeGen::DoCmpT(LCmpT* instr) { |
2179 Token::Value op = instr->op(); | 2177 Token::Value op = instr->op(); |
2180 | 2178 |
2181 Handle<Code> ic = CompareIC::GetUninitialized(op); | 2179 Handle<Code> ic = CompareIC::GetUninitialized(op); |
2182 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2180 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
| 2181 __ cmp(r0, Operand(0)); // This instruction also signals no smi code inlined. |
2183 | 2182 |
2184 Condition condition = ComputeCompareCondition(op); | 2183 Condition condition = ComputeCompareCondition(op); |
2185 if (op == Token::GT || op == Token::LTE) { | 2184 if (op == Token::GT || op == Token::LTE) { |
2186 condition = ReverseCondition(condition); | 2185 condition = ReverseCondition(condition); |
2187 } | 2186 } |
2188 __ cmp(r0, Operand(0)); | |
2189 __ LoadRoot(ToRegister(instr->result()), | 2187 __ LoadRoot(ToRegister(instr->result()), |
2190 Heap::kTrueValueRootIndex, | 2188 Heap::kTrueValueRootIndex, |
2191 condition); | 2189 condition); |
2192 __ LoadRoot(ToRegister(instr->result()), | 2190 __ LoadRoot(ToRegister(instr->result()), |
2193 Heap::kFalseValueRootIndex, | 2191 Heap::kFalseValueRootIndex, |
2194 NegateCondition(condition)); | 2192 NegateCondition(condition)); |
2195 } | 2193 } |
2196 | 2194 |
2197 | 2195 |
2198 void LCodeGen::DoCmpTAndBranch(LCmpTAndBranch* instr) { | 2196 void LCodeGen::DoCmpTAndBranch(LCmpTAndBranch* instr) { |
2199 Abort("DoCmpTAndBranch unimplemented."); | 2197 Token::Value op = instr->op(); |
| 2198 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 2199 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 2200 |
| 2201 Handle<Code> ic = CompareIC::GetUninitialized(op); |
| 2202 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
| 2203 |
| 2204 // The compare stub expects compare condition and the input operands |
| 2205 // reversed for GT and LTE. |
| 2206 Condition condition = ComputeCompareCondition(op); |
| 2207 if (op == Token::GT || op == Token::LTE) { |
| 2208 condition = ReverseCondition(condition); |
| 2209 } |
| 2210 __ cmp(r0, Operand(0)); |
| 2211 EmitBranch(true_block, false_block, condition); |
2200 } | 2212 } |
2201 | 2213 |
2202 | 2214 |
2203 void LCodeGen::DoReturn(LReturn* instr) { | 2215 void LCodeGen::DoReturn(LReturn* instr) { |
2204 if (FLAG_trace) { | 2216 if (FLAG_trace) { |
2205 // Push the return value on the stack as the parameter. | 2217 // Push the return value on the stack as the parameter. |
2206 // Runtime::TraceExit returns its parameter in r0. | 2218 // Runtime::TraceExit returns its parameter in r0. |
2207 __ push(r0); | 2219 __ push(r0); |
2208 __ CallRuntime(Runtime::kTraceExit, 1); | 2220 __ CallRuntime(Runtime::kTraceExit, 1); |
2209 } | 2221 } |
(...skipping 1657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3867 | 3879 |
3868 | 3880 |
3869 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { | 3881 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { |
3870 Abort("DoOsrEntry unimplemented."); | 3882 Abort("DoOsrEntry unimplemented."); |
3871 } | 3883 } |
3872 | 3884 |
3873 | 3885 |
3874 #undef __ | 3886 #undef __ |
3875 | 3887 |
3876 } } // namespace v8::internal | 3888 } } // namespace v8::internal |
OLD | NEW |