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

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

Issue 1318663003: X87: Correctify instanceof and make it optimizable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/x87/macro-assembler-x87.h ('k') | no next file » | 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_X87 5 #if V8_TARGET_ARCH_X87
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 1743 matching lines...) Expand 10 before | Expand all | Expand 10 after
1754 bind(&loop); 1754 bind(&loop);
1755 JumpIfSmi(result, &done); 1755 JumpIfSmi(result, &done);
1756 CmpObjectType(result, MAP_TYPE, temp); 1756 CmpObjectType(result, MAP_TYPE, temp);
1757 j(not_equal, &done); 1757 j(not_equal, &done);
1758 mov(result, FieldOperand(result, Map::kConstructorOrBackPointerOffset)); 1758 mov(result, FieldOperand(result, Map::kConstructorOrBackPointerOffset));
1759 jmp(&loop); 1759 jmp(&loop);
1760 bind(&done); 1760 bind(&done);
1761 } 1761 }
1762 1762
1763 1763
1764 void MacroAssembler::TryGetFunctionPrototype(Register function, 1764 void MacroAssembler::TryGetFunctionPrototype(Register function, Register result,
1765 Register result, 1765 Register scratch, Label* miss) {
1766 Register scratch,
1767 Label* miss,
1768 bool miss_on_bound_function) {
1769 Label non_instance;
1770 if (miss_on_bound_function) {
1771 // Check that the receiver isn't a smi.
1772 JumpIfSmi(function, miss);
1773
1774 // Check that the function really is a function.
1775 CmpObjectType(function, JS_FUNCTION_TYPE, result);
1776 j(not_equal, miss);
1777
1778 // If a bound function, go to miss label.
1779 mov(scratch,
1780 FieldOperand(function, JSFunction::kSharedFunctionInfoOffset));
1781 BooleanBitTest(scratch, SharedFunctionInfo::kCompilerHintsOffset,
1782 SharedFunctionInfo::kBoundFunction);
1783 j(not_zero, miss);
1784
1785 // Make sure that the function has an instance prototype.
1786 movzx_b(scratch, FieldOperand(result, Map::kBitFieldOffset));
1787 test(scratch, Immediate(1 << Map::kHasNonInstancePrototype));
1788 j(not_zero, &non_instance);
1789 }
1790
1791 // Get the prototype or initial map from the function. 1766 // Get the prototype or initial map from the function.
1792 mov(result, 1767 mov(result,
1793 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); 1768 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset));
1794 1769
1795 // If the prototype or initial map is the hole, don't return it and 1770 // If the prototype or initial map is the hole, don't return it and
1796 // simply miss the cache instead. This will allow us to allocate a 1771 // simply miss the cache instead. This will allow us to allocate a
1797 // prototype object on-demand in the runtime system. 1772 // prototype object on-demand in the runtime system.
1798 cmp(result, Immediate(isolate()->factory()->the_hole_value())); 1773 cmp(result, Immediate(isolate()->factory()->the_hole_value()));
1799 j(equal, miss); 1774 j(equal, miss);
1800 1775
1801 // If the function does not have an initial map, we're done. 1776 // If the function does not have an initial map, we're done.
1802 Label done; 1777 Label done;
1803 CmpObjectType(result, MAP_TYPE, scratch); 1778 CmpObjectType(result, MAP_TYPE, scratch);
1804 j(not_equal, &done); 1779 j(not_equal, &done, Label::kNear);
1805 1780
1806 // Get the prototype from the initial map. 1781 // Get the prototype from the initial map.
1807 mov(result, FieldOperand(result, Map::kPrototypeOffset)); 1782 mov(result, FieldOperand(result, Map::kPrototypeOffset));
1808 1783
1809 if (miss_on_bound_function) {
1810 jmp(&done);
1811
1812 // Non-instance prototype: Fetch prototype from constructor field
1813 // in initial map.
1814 bind(&non_instance);
1815 GetMapConstructor(result, result, scratch);
1816 }
1817
1818 // All done. 1784 // All done.
1819 bind(&done); 1785 bind(&done);
1820 } 1786 }
1821 1787
1822 1788
1823 void MacroAssembler::CallStub(CodeStub* stub, TypeFeedbackId ast_id) { 1789 void MacroAssembler::CallStub(CodeStub* stub, TypeFeedbackId ast_id) {
1824 DCHECK(AllowThisStubCall(stub)); // Calls are not allowed in some stubs. 1790 DCHECK(AllowThisStubCall(stub)); // Calls are not allowed in some stubs.
1825 call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id); 1791 call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id);
1826 } 1792 }
1827 1793
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after
3097 mov(eax, dividend); 3063 mov(eax, dividend);
3098 shr(eax, 31); 3064 shr(eax, 31);
3099 add(edx, eax); 3065 add(edx, eax);
3100 } 3066 }
3101 3067
3102 3068
3103 } // namespace internal 3069 } // namespace internal
3104 } // namespace v8 3070 } // namespace v8
3105 3071
3106 #endif // V8_TARGET_ARCH_X87 3072 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/x87/macro-assembler-x87.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698