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 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1675 | 1675 |
1676 // Test for NaN. Compare heap numbers in a general way, | 1676 // Test for NaN. Compare heap numbers in a general way, |
1677 // to handle NaNs correctly. | 1677 // to handle NaNs correctly. |
1678 __ cmp(FieldOperand(edx, HeapObject::kMapOffset), | 1678 __ cmp(FieldOperand(edx, HeapObject::kMapOffset), |
1679 Immediate(isolate()->factory()->heap_number_map())); | 1679 Immediate(isolate()->factory()->heap_number_map())); |
1680 __ j(equal, &generic_heap_number_comparison, Label::kNear); | 1680 __ j(equal, &generic_heap_number_comparison, Label::kNear); |
1681 if (cc != equal) { | 1681 if (cc != equal) { |
1682 __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset)); | 1682 __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset)); |
1683 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); | 1683 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); |
1684 // Call runtime on identical JSObjects. Otherwise return equal. | 1684 // Call runtime on identical JSObjects. Otherwise return equal. |
1685 __ cmpb(ecx, static_cast<uint8_t>(FIRST_SPEC_OBJECT_TYPE)); | 1685 __ cmpb(ecx, static_cast<uint8_t>(FIRST_JS_RECEIVER_TYPE)); |
1686 __ j(above_equal, &runtime_call, Label::kFar); | 1686 __ j(above_equal, &runtime_call, Label::kFar); |
1687 // Call runtime on identical symbols since we need to throw a TypeError. | 1687 // Call runtime on identical symbols since we need to throw a TypeError. |
1688 __ cmpb(ecx, static_cast<uint8_t>(SYMBOL_TYPE)); | 1688 __ cmpb(ecx, static_cast<uint8_t>(SYMBOL_TYPE)); |
1689 __ j(equal, &runtime_call, Label::kFar); | 1689 __ j(equal, &runtime_call, Label::kFar); |
1690 // Call runtime on identical SIMD values since we must throw a TypeError. | 1690 // Call runtime on identical SIMD values since we must throw a TypeError. |
1691 __ cmpb(ecx, static_cast<uint8_t>(SIMD128_VALUE_TYPE)); | 1691 __ cmpb(ecx, static_cast<uint8_t>(SIMD128_VALUE_TYPE)); |
1692 __ j(equal, &runtime_call, Label::kFar); | 1692 __ j(equal, &runtime_call, Label::kFar); |
1693 if (is_strong(strength())) { | 1693 if (is_strong(strength())) { |
1694 // We have already tested for smis and heap numbers, so if both | 1694 // We have already tested for smis and heap numbers, so if both |
1695 // arguments are not strings we must proceed to the slow case. | 1695 // arguments are not strings we must proceed to the slow case. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1743 __ ret(0); | 1743 __ ret(0); |
1744 | 1744 |
1745 __ bind(¬_smis); | 1745 __ bind(¬_smis); |
1746 // If either operand is a JSObject or an oddball value, then they are not | 1746 // If either operand is a JSObject or an oddball value, then they are not |
1747 // equal since their pointers are different | 1747 // equal since their pointers are different |
1748 // There is no test for undetectability in strict equality. | 1748 // There is no test for undetectability in strict equality. |
1749 | 1749 |
1750 // Get the type of the first operand. | 1750 // Get the type of the first operand. |
1751 // If the first object is a JS object, we have done pointer comparison. | 1751 // If the first object is a JS object, we have done pointer comparison. |
1752 Label first_non_object; | 1752 Label first_non_object; |
1753 STATIC_ASSERT(LAST_TYPE == LAST_SPEC_OBJECT_TYPE); | 1753 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE); |
1754 __ CmpObjectType(eax, FIRST_SPEC_OBJECT_TYPE, ecx); | 1754 __ CmpObjectType(eax, FIRST_JS_RECEIVER_TYPE, ecx); |
1755 __ j(below, &first_non_object, Label::kNear); | 1755 __ j(below, &first_non_object, Label::kNear); |
1756 | 1756 |
1757 // Return non-zero (eax is not zero) | 1757 // Return non-zero (eax is not zero) |
1758 Label return_not_equal; | 1758 Label return_not_equal; |
1759 STATIC_ASSERT(kHeapObjectTag != 0); | 1759 STATIC_ASSERT(kHeapObjectTag != 0); |
1760 __ bind(&return_not_equal); | 1760 __ bind(&return_not_equal); |
1761 __ ret(0); | 1761 __ ret(0); |
1762 | 1762 |
1763 __ bind(&first_non_object); | 1763 __ bind(&first_non_object); |
1764 // Check for oddballs: true, false, null, undefined. | 1764 // Check for oddballs: true, false, null, undefined. |
1765 __ CmpInstanceType(ecx, ODDBALL_TYPE); | 1765 __ CmpInstanceType(ecx, ODDBALL_TYPE); |
1766 __ j(equal, &return_not_equal); | 1766 __ j(equal, &return_not_equal); |
1767 | 1767 |
1768 __ CmpObjectType(edx, FIRST_SPEC_OBJECT_TYPE, ecx); | 1768 __ CmpObjectType(edx, FIRST_JS_RECEIVER_TYPE, ecx); |
1769 __ j(above_equal, &return_not_equal); | 1769 __ j(above_equal, &return_not_equal); |
1770 | 1770 |
1771 // Check for oddballs: true, false, null, undefined. | 1771 // Check for oddballs: true, false, null, undefined. |
1772 __ CmpInstanceType(ecx, ODDBALL_TYPE); | 1772 __ CmpInstanceType(ecx, ODDBALL_TYPE); |
1773 __ j(equal, &return_not_equal); | 1773 __ j(equal, &return_not_equal); |
1774 | 1774 |
1775 // Fall through to the general case. | 1775 // Fall through to the general case. |
1776 __ bind(&slow); | 1776 __ bind(&slow); |
1777 } | 1777 } |
1778 | 1778 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1842 // and their pointers are different. | 1842 // and their pointers are different. |
1843 Label return_unequal; | 1843 Label return_unequal; |
1844 // At most one is a smi, so we can test for smi by adding the two. | 1844 // At most one is a smi, so we can test for smi by adding the two. |
1845 // A smi plus a heap object has the low bit set, a heap object plus | 1845 // A smi plus a heap object has the low bit set, a heap object plus |
1846 // a heap object has the low bit clear. | 1846 // a heap object has the low bit clear. |
1847 STATIC_ASSERT(kSmiTag == 0); | 1847 STATIC_ASSERT(kSmiTag == 0); |
1848 STATIC_ASSERT(kSmiTagMask == 1); | 1848 STATIC_ASSERT(kSmiTagMask == 1); |
1849 __ lea(ecx, Operand(eax, edx, times_1, 0)); | 1849 __ lea(ecx, Operand(eax, edx, times_1, 0)); |
1850 __ test(ecx, Immediate(kSmiTagMask)); | 1850 __ test(ecx, Immediate(kSmiTagMask)); |
1851 __ j(not_zero, &runtime_call, Label::kNear); | 1851 __ j(not_zero, &runtime_call, Label::kNear); |
1852 __ CmpObjectType(eax, FIRST_SPEC_OBJECT_TYPE, ecx); | 1852 __ CmpObjectType(eax, FIRST_JS_RECEIVER_TYPE, ecx); |
1853 __ j(below, &runtime_call, Label::kNear); | 1853 __ j(below, &runtime_call, Label::kNear); |
1854 __ CmpObjectType(edx, FIRST_SPEC_OBJECT_TYPE, ebx); | 1854 __ CmpObjectType(edx, FIRST_JS_RECEIVER_TYPE, ebx); |
1855 __ j(below, &runtime_call, Label::kNear); | 1855 __ j(below, &runtime_call, Label::kNear); |
1856 // We do not bail out after this point. Both are JSObjects, and | 1856 // We do not bail out after this point. Both are JSObjects, and |
1857 // they are equal if and only if both are undetectable. | 1857 // they are equal if and only if both are undetectable. |
1858 // The and of the undetectable flags is 1 if and only if they are equal. | 1858 // The and of the undetectable flags is 1 if and only if they are equal. |
1859 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), | 1859 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), |
1860 1 << Map::kIsUndetectable); | 1860 1 << Map::kIsUndetectable); |
1861 __ j(zero, &return_unequal, Label::kNear); | 1861 __ j(zero, &return_unequal, Label::kNear); |
1862 __ test_b(FieldOperand(ebx, Map::kBitFieldOffset), | 1862 __ test_b(FieldOperand(ebx, Map::kBitFieldOffset), |
1863 1 << Map::kIsUndetectable); | 1863 1 << Map::kIsUndetectable); |
1864 __ j(zero, &return_unequal, Label::kNear); | 1864 __ j(zero, &return_unequal, Label::kNear); |
(...skipping 3516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5381 Label ok; | 5381 Label ok; |
5382 Register return_value = eax; | 5382 Register return_value = eax; |
5383 Register map = ecx; | 5383 Register map = ecx; |
5384 | 5384 |
5385 __ JumpIfSmi(return_value, &ok, Label::kNear); | 5385 __ JumpIfSmi(return_value, &ok, Label::kNear); |
5386 __ mov(map, FieldOperand(return_value, HeapObject::kMapOffset)); | 5386 __ mov(map, FieldOperand(return_value, HeapObject::kMapOffset)); |
5387 | 5387 |
5388 __ CmpInstanceType(map, LAST_NAME_TYPE); | 5388 __ CmpInstanceType(map, LAST_NAME_TYPE); |
5389 __ j(below_equal, &ok, Label::kNear); | 5389 __ j(below_equal, &ok, Label::kNear); |
5390 | 5390 |
5391 __ CmpInstanceType(map, FIRST_SPEC_OBJECT_TYPE); | 5391 __ CmpInstanceType(map, FIRST_JS_RECEIVER_TYPE); |
5392 __ j(above_equal, &ok, Label::kNear); | 5392 __ j(above_equal, &ok, Label::kNear); |
5393 | 5393 |
5394 __ cmp(map, isolate->factory()->heap_number_map()); | 5394 __ cmp(map, isolate->factory()->heap_number_map()); |
5395 __ j(equal, &ok, Label::kNear); | 5395 __ j(equal, &ok, Label::kNear); |
5396 | 5396 |
5397 __ cmp(return_value, isolate->factory()->undefined_value()); | 5397 __ cmp(return_value, isolate->factory()->undefined_value()); |
5398 __ j(equal, &ok, Label::kNear); | 5398 __ j(equal, &ok, Label::kNear); |
5399 | 5399 |
5400 __ cmp(return_value, isolate->factory()->true_value()); | 5400 __ cmp(return_value, isolate->factory()->true_value()); |
5401 __ j(equal, &ok, Label::kNear); | 5401 __ j(equal, &ok, Label::kNear); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5638 Operand(ebp, 7 * kPointerSize), NULL); | 5638 Operand(ebp, 7 * kPointerSize), NULL); |
5639 } | 5639 } |
5640 | 5640 |
5641 | 5641 |
5642 #undef __ | 5642 #undef __ |
5643 | 5643 |
5644 } // namespace internal | 5644 } // namespace internal |
5645 } // namespace v8 | 5645 } // namespace v8 |
5646 | 5646 |
5647 #endif // V8_TARGET_ARCH_IA32 | 5647 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |