OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 1678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1689 Label generic_heap_number_comparison; | 1689 Label generic_heap_number_comparison; |
1690 { | 1690 { |
1691 Label not_identical; | 1691 Label not_identical; |
1692 __ cmp(eax, edx); | 1692 __ cmp(eax, edx); |
1693 __ j(not_equal, ¬_identical); | 1693 __ j(not_equal, ¬_identical); |
1694 | 1694 |
1695 if (cc != equal) { | 1695 if (cc != equal) { |
1696 // Check for undefined. undefined OP undefined is false even though | 1696 // Check for undefined. undefined OP undefined is false even though |
1697 // undefined == undefined. | 1697 // undefined == undefined. |
1698 __ cmp(edx, isolate()->factory()->undefined_value()); | 1698 __ cmp(edx, isolate()->factory()->undefined_value()); |
1699 if (strong()) { | 1699 if (is_strong(strength())) { |
1700 // In strong mode, this comparison must throw, so call the runtime. | 1700 // In strong mode, this comparison must throw, so call the runtime. |
1701 __ j(equal, &runtime_call, Label::kFar); | 1701 __ j(equal, &runtime_call, Label::kFar); |
1702 } else { | 1702 } else { |
1703 Label check_for_nan; | 1703 Label check_for_nan; |
1704 __ j(not_equal, &check_for_nan, Label::kNear); | 1704 __ j(not_equal, &check_for_nan, Label::kNear); |
1705 __ Move(eax, Immediate(Smi::FromInt(NegativeComparisonResult(cc)))); | 1705 __ Move(eax, Immediate(Smi::FromInt(NegativeComparisonResult(cc)))); |
1706 __ ret(0); | 1706 __ ret(0); |
1707 __ bind(&check_for_nan); | 1707 __ bind(&check_for_nan); |
1708 } | 1708 } |
1709 } | 1709 } |
1710 | 1710 |
1711 // Test for NaN. Compare heap numbers in a general way, | 1711 // Test for NaN. Compare heap numbers in a general way, |
1712 // to hanlde NaNs correctly. | 1712 // to hanlde NaNs correctly. |
1713 __ cmp(FieldOperand(edx, HeapObject::kMapOffset), | 1713 __ cmp(FieldOperand(edx, HeapObject::kMapOffset), |
1714 Immediate(isolate()->factory()->heap_number_map())); | 1714 Immediate(isolate()->factory()->heap_number_map())); |
1715 __ j(equal, &generic_heap_number_comparison, Label::kNear); | 1715 __ j(equal, &generic_heap_number_comparison, Label::kNear); |
1716 if (cc != equal) { | 1716 if (cc != equal) { |
1717 __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset)); | 1717 __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset)); |
1718 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); | 1718 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); |
1719 // Call runtime on identical JSObjects. Otherwise return equal. | 1719 // Call runtime on identical JSObjects. Otherwise return equal. |
1720 __ cmpb(ecx, static_cast<uint8_t>(FIRST_SPEC_OBJECT_TYPE)); | 1720 __ cmpb(ecx, static_cast<uint8_t>(FIRST_SPEC_OBJECT_TYPE)); |
1721 __ j(above_equal, &runtime_call, Label::kFar); | 1721 __ j(above_equal, &runtime_call, Label::kFar); |
1722 // Call runtime on identical symbols since we need to throw a TypeError. | 1722 // Call runtime on identical symbols since we need to throw a TypeError. |
1723 __ cmpb(ecx, static_cast<uint8_t>(SYMBOL_TYPE)); | 1723 __ cmpb(ecx, static_cast<uint8_t>(SYMBOL_TYPE)); |
1724 __ j(equal, &runtime_call, Label::kFar); | 1724 __ j(equal, &runtime_call, Label::kFar); |
1725 if (strong()) { | 1725 if (is_strong(strength())) { |
1726 // We have already tested for smis and heap numbers, so if both | 1726 // We have already tested for smis and heap numbers, so if both |
1727 // arguments are not strings we must proceed to the slow case. | 1727 // arguments are not strings we must proceed to the slow case. |
1728 __ test(ecx, Immediate(kIsNotStringMask)); | 1728 __ test(ecx, Immediate(kIsNotStringMask)); |
1729 __ j(not_zero, &runtime_call, Label::kFar); | 1729 __ j(not_zero, &runtime_call, Label::kFar); |
1730 } | 1730 } |
1731 } | 1731 } |
1732 __ Move(eax, Immediate(Smi::FromInt(EQUAL))); | 1732 __ Move(eax, Immediate(Smi::FromInt(EQUAL))); |
1733 __ ret(0); | 1733 __ ret(0); |
1734 | 1734 |
1735 | 1735 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1907 // Push arguments below the return address. | 1907 // Push arguments below the return address. |
1908 __ pop(ecx); | 1908 __ pop(ecx); |
1909 __ push(edx); | 1909 __ push(edx); |
1910 __ push(eax); | 1910 __ push(eax); |
1911 | 1911 |
1912 // Figure out which native to call and setup the arguments. | 1912 // Figure out which native to call and setup the arguments. |
1913 Builtins::JavaScript builtin; | 1913 Builtins::JavaScript builtin; |
1914 if (cc == equal) { | 1914 if (cc == equal) { |
1915 builtin = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS; | 1915 builtin = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS; |
1916 } else { | 1916 } else { |
1917 builtin = strong() ? Builtins::COMPARE_STRONG : Builtins::COMPARE; | 1917 builtin = |
| 1918 is_strong(strength()) ? Builtins::COMPARE_STRONG : Builtins::COMPARE; |
1918 __ push(Immediate(Smi::FromInt(NegativeComparisonResult(cc)))); | 1919 __ push(Immediate(Smi::FromInt(NegativeComparisonResult(cc)))); |
1919 } | 1920 } |
1920 | 1921 |
1921 // Restore return address on the stack. | 1922 // Restore return address on the stack. |
1922 __ push(ecx); | 1923 __ push(ecx); |
1923 | 1924 |
1924 // Call the native; it returns -1 (less), 0 (equal), or 1 (greater) | 1925 // Call the native; it returns -1 (less), 0 (equal), or 1 (greater) |
1925 // tagged as a small integer. | 1926 // tagged as a small integer. |
1926 __ InvokeBuiltin(builtin, JUMP_FUNCTION); | 1927 __ InvokeBuiltin(builtin, JUMP_FUNCTION); |
1927 | 1928 |
(...skipping 1710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3638 // Performing mov, because xor would destroy the flag register. | 3639 // Performing mov, because xor would destroy the flag register. |
3639 __ mov(eax, 0); // equal | 3640 __ mov(eax, 0); // equal |
3640 __ mov(ecx, Immediate(Smi::FromInt(1))); | 3641 __ mov(ecx, Immediate(Smi::FromInt(1))); |
3641 __ cmov(above, eax, ecx); | 3642 __ cmov(above, eax, ecx); |
3642 __ mov(ecx, Immediate(Smi::FromInt(-1))); | 3643 __ mov(ecx, Immediate(Smi::FromInt(-1))); |
3643 __ cmov(below, eax, ecx); | 3644 __ cmov(below, eax, ecx); |
3644 __ ret(0); | 3645 __ ret(0); |
3645 | 3646 |
3646 __ bind(&unordered); | 3647 __ bind(&unordered); |
3647 __ bind(&generic_stub); | 3648 __ bind(&generic_stub); |
3648 CompareICStub stub(isolate(), op(), strong(), CompareICState::GENERIC, | 3649 CompareICStub stub(isolate(), op(), strength(), CompareICState::GENERIC, |
3649 CompareICState::GENERIC, CompareICState::GENERIC); | 3650 CompareICState::GENERIC, CompareICState::GENERIC); |
3650 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET); | 3651 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET); |
3651 | 3652 |
3652 __ bind(&maybe_undefined1); | 3653 __ bind(&maybe_undefined1); |
3653 if (Token::IsOrderedRelationalCompareOp(op())) { | 3654 if (Token::IsOrderedRelationalCompareOp(op())) { |
3654 __ cmp(eax, Immediate(isolate()->factory()->undefined_value())); | 3655 __ cmp(eax, Immediate(isolate()->factory()->undefined_value())); |
3655 __ j(not_equal, &miss); | 3656 __ j(not_equal, &miss); |
3656 __ JumpIfSmi(edx, &unordered); | 3657 __ JumpIfSmi(edx, &unordered); |
3657 __ CmpObjectType(edx, HEAP_NUMBER_TYPE, ecx); | 3658 __ CmpObjectType(edx, HEAP_NUMBER_TYPE, ecx); |
3658 __ j(not_equal, &maybe_undefined2, Label::kNear); | 3659 __ j(not_equal, &maybe_undefined2, Label::kNear); |
(...skipping 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5477 Operand(ebp, 7 * kPointerSize), NULL); | 5478 Operand(ebp, 7 * kPointerSize), NULL); |
5478 } | 5479 } |
5479 | 5480 |
5480 | 5481 |
5481 #undef __ | 5482 #undef __ |
5482 | 5483 |
5483 } // namespace internal | 5484 } // namespace internal |
5484 } // namespace v8 | 5485 } // namespace v8 |
5485 | 5486 |
5486 #endif // V8_TARGET_ARCH_IA32 | 5487 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |