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

Side by Side Diff: src/ia32/macro-assembler-ia32.cc

Issue 1304633002: Correctify instanceof and make it optimizable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Add MIPS/MIPS64 ports. Created 5 years, 4 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/ia32/macro-assembler-ia32.h ('k') | src/interface-descriptors.h » ('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/base/division-by-constant.h" 8 #include "src/base/division-by-constant.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 1777 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 bind(&loop); 1788 bind(&loop);
1789 JumpIfSmi(result, &done); 1789 JumpIfSmi(result, &done);
1790 CmpObjectType(result, MAP_TYPE, temp); 1790 CmpObjectType(result, MAP_TYPE, temp);
1791 j(not_equal, &done); 1791 j(not_equal, &done);
1792 mov(result, FieldOperand(result, Map::kConstructorOrBackPointerOffset)); 1792 mov(result, FieldOperand(result, Map::kConstructorOrBackPointerOffset));
1793 jmp(&loop); 1793 jmp(&loop);
1794 bind(&done); 1794 bind(&done);
1795 } 1795 }
1796 1796
1797 1797
1798 void MacroAssembler::TryGetFunctionPrototype(Register function, 1798 void MacroAssembler::TryGetFunctionPrototype(Register function, Register result,
1799 Register result, 1799 Register scratch, Label* miss) {
1800 Register scratch,
1801 Label* miss,
1802 bool miss_on_bound_function) {
1803 Label non_instance;
1804 if (miss_on_bound_function) {
1805 // Check that the receiver isn't a smi.
1806 JumpIfSmi(function, miss);
1807
1808 // Check that the function really is a function.
1809 CmpObjectType(function, JS_FUNCTION_TYPE, result);
1810 j(not_equal, miss);
1811
1812 // If a bound function, go to miss label.
1813 mov(scratch,
1814 FieldOperand(function, JSFunction::kSharedFunctionInfoOffset));
1815 BooleanBitTest(scratch, SharedFunctionInfo::kCompilerHintsOffset,
1816 SharedFunctionInfo::kBoundFunction);
1817 j(not_zero, miss);
1818
1819 // Make sure that the function has an instance prototype.
1820 movzx_b(scratch, FieldOperand(result, Map::kBitFieldOffset));
1821 test(scratch, Immediate(1 << Map::kHasNonInstancePrototype));
1822 j(not_zero, &non_instance);
1823 }
1824
1825 // Get the prototype or initial map from the function. 1800 // Get the prototype or initial map from the function.
1826 mov(result, 1801 mov(result,
1827 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); 1802 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset));
1828 1803
1829 // If the prototype or initial map is the hole, don't return it and 1804 // If the prototype or initial map is the hole, don't return it and
1830 // simply miss the cache instead. This will allow us to allocate a 1805 // simply miss the cache instead. This will allow us to allocate a
1831 // prototype object on-demand in the runtime system. 1806 // prototype object on-demand in the runtime system.
1832 cmp(result, Immediate(isolate()->factory()->the_hole_value())); 1807 cmp(result, Immediate(isolate()->factory()->the_hole_value()));
1833 j(equal, miss); 1808 j(equal, miss);
1834 1809
1835 // If the function does not have an initial map, we're done. 1810 // If the function does not have an initial map, we're done.
1836 Label done; 1811 Label done;
1837 CmpObjectType(result, MAP_TYPE, scratch); 1812 CmpObjectType(result, MAP_TYPE, scratch);
1838 j(not_equal, &done); 1813 j(not_equal, &done, Label::kNear);
1839 1814
1840 // Get the prototype from the initial map. 1815 // Get the prototype from the initial map.
1841 mov(result, FieldOperand(result, Map::kPrototypeOffset)); 1816 mov(result, FieldOperand(result, Map::kPrototypeOffset));
1842 1817
1843 if (miss_on_bound_function) {
1844 jmp(&done);
1845
1846 // Non-instance prototype: Fetch prototype from constructor field
1847 // in initial map.
1848 bind(&non_instance);
1849 GetMapConstructor(result, result, scratch);
1850 }
1851
1852 // All done. 1818 // All done.
1853 bind(&done); 1819 bind(&done);
1854 } 1820 }
1855 1821
1856 1822
1857 void MacroAssembler::CallStub(CodeStub* stub, TypeFeedbackId ast_id) { 1823 void MacroAssembler::CallStub(CodeStub* stub, TypeFeedbackId ast_id) {
1858 DCHECK(AllowThisStubCall(stub)); // Calls are not allowed in some stubs. 1824 DCHECK(AllowThisStubCall(stub)); // Calls are not allowed in some stubs.
1859 call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id); 1825 call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id);
1860 } 1826 }
1861 1827
(...skipping 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after
3220 mov(eax, dividend); 3186 mov(eax, dividend);
3221 shr(eax, 31); 3187 shr(eax, 31);
3222 add(edx, eax); 3188 add(edx, eax);
3223 } 3189 }
3224 3190
3225 3191
3226 } // namespace internal 3192 } // namespace internal
3227 } // namespace v8 3193 } // namespace v8
3228 3194
3229 #endif // V8_TARGET_ARCH_IA32 3195 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/interface-descriptors.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698