Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(702)

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 1683643002: Mark null and undefined as undetectable, and use it to handle abstract equality comparison in the g… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/heap.cc ('k') | src/mips/code-stubs-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after
1830 } 1830 }
1831 #ifdef DEBUG 1831 #ifdef DEBUG
1832 __ Abort(kUnexpectedFallThroughFromStringComparison); 1832 __ Abort(kUnexpectedFallThroughFromStringComparison);
1833 #endif 1833 #endif
1834 1834
1835 __ bind(&check_unequal_objects); 1835 __ bind(&check_unequal_objects);
1836 if (cc == equal && !strict()) { 1836 if (cc == equal && !strict()) {
1837 // Non-strict equality. Objects are unequal if 1837 // Non-strict equality. Objects are unequal if
1838 // they are both JSObjects and not undetectable, 1838 // they are both JSObjects and not undetectable,
1839 // and their pointers are different. 1839 // and their pointers are different.
1840 Label return_unequal; 1840 Label return_unequal, undetectable;
1841 // At most one is a smi, so we can test for smi by adding the two. 1841 // At most one is a smi, so we can test for smi by adding the two.
1842 // A smi plus a heap object has the low bit set, a heap object plus 1842 // A smi plus a heap object has the low bit set, a heap object plus
1843 // a heap object has the low bit clear. 1843 // a heap object has the low bit clear.
1844 STATIC_ASSERT(kSmiTag == 0); 1844 STATIC_ASSERT(kSmiTag == 0);
1845 STATIC_ASSERT(kSmiTagMask == 1); 1845 STATIC_ASSERT(kSmiTagMask == 1);
1846 __ lea(ecx, Operand(eax, edx, times_1, 0)); 1846 __ lea(ecx, Operand(eax, edx, times_1, 0));
1847 __ test(ecx, Immediate(kSmiTagMask)); 1847 __ test(ecx, Immediate(kSmiTagMask));
1848 __ j(not_zero, &runtime_call, Label::kNear); 1848 __ j(not_zero, &runtime_call, Label::kNear);
1849 __ CmpObjectType(eax, FIRST_JS_RECEIVER_TYPE, ecx); 1849
1850 __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset));
1851 __ mov(ebx, FieldOperand(edx, HeapObject::kMapOffset));
1852
1853 __ test_b(FieldOperand(ebx, Map::kBitFieldOffset),
1854 1 << Map::kIsUndetectable);
1855 __ j(not_zero, &undetectable, Label::kNear);
1856 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset),
1857 1 << Map::kIsUndetectable);
1858 __ j(not_zero, &return_unequal, Label::kNear);
1859
1860 __ CmpInstanceType(ebx, FIRST_JS_RECEIVER_TYPE);
1850 __ j(below, &runtime_call, Label::kNear); 1861 __ j(below, &runtime_call, Label::kNear);
1851 __ CmpObjectType(edx, FIRST_JS_RECEIVER_TYPE, ebx); 1862 __ CmpInstanceType(ecx, FIRST_JS_RECEIVER_TYPE);
1852 __ j(below, &runtime_call, Label::kNear); 1863 __ j(below, &runtime_call, Label::kNear);
1853 // We do not bail out after this point. Both are JSObjects, and 1864
1854 // they are equal if and only if both are undetectable. 1865 __ bind(&return_unequal);
1855 // The and of the undetectable flags is 1 if and only if they are equal. 1866 // Return non-equal by returning the non-zero object pointer in eax.
1867 __ ret(0); // eax, edx were pushed
1868
1869 __ bind(&undetectable);
1856 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1870 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset),
1857 1 << Map::kIsUndetectable); 1871 1 << Map::kIsUndetectable);
1858 __ j(zero, &return_unequal, Label::kNear); 1872 __ j(zero, &return_unequal, Label::kNear);
1859 __ test_b(FieldOperand(ebx, Map::kBitFieldOffset),
1860 1 << Map::kIsUndetectable);
1861 __ j(zero, &return_unequal, Label::kNear);
1862 // The objects are both undetectable, so they both compare as the value
1863 // undefined, and are equal.
1864 __ Move(eax, Immediate(EQUAL)); 1873 __ Move(eax, Immediate(EQUAL));
1865 __ bind(&return_unequal); 1874 __ ret(0); // eax, edx were pushed
1866 // Return non-equal by returning the non-zero object pointer in eax,
1867 // or return equal if we fell through to here.
1868 __ ret(0); // rax, rdx were pushed
1869 } 1875 }
1870 __ bind(&runtime_call); 1876 __ bind(&runtime_call);
1871 1877
1872 // Push arguments below the return address. 1878 // Push arguments below the return address.
1873 __ pop(ecx); 1879 __ pop(ecx);
1874 __ push(edx); 1880 __ push(edx);
1875 __ push(eax); 1881 __ push(eax);
1876 1882
1877 // Figure out which native to call and setup the arguments. 1883 // Figure out which native to call and setup the arguments.
1878 if (cc == equal) { 1884 if (cc == equal) {
(...skipping 3981 matching lines...) Expand 10 before | Expand all | Expand 10 after
5860 return_value_operand, NULL); 5866 return_value_operand, NULL);
5861 } 5867 }
5862 5868
5863 5869
5864 #undef __ 5870 #undef __
5865 5871
5866 } // namespace internal 5872 } // namespace internal
5867 } // namespace v8 5873 } // namespace v8
5868 5874
5869 #endif // V8_TARGET_ARCH_IA32 5875 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/heap/heap.cc ('k') | src/mips/code-stubs-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698