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

Side by Side Diff: runtime/vm/stub_code_x64.cc

Issue 10409067: More inlined type checking for x64. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/assembler_macros.h" 9 #include "vm/assembler_macros.h"
10 #include "vm/code_generator.h" 10 #include "vm/code_generator.h"
(...skipping 1746 matching lines...) Expand 10 before | Expand all | Expand 10 after
1757 // Used to check class and type arguments. Arguments passed on stack: 1757 // Used to check class and type arguments. Arguments passed on stack:
1758 // TOS + 0: return address. 1758 // TOS + 0: return address.
1759 // TOS + 1: instantiator type arguments (can be NULL). 1759 // TOS + 1: instantiator type arguments (can be NULL).
1760 // TOS + 2: instance. 1760 // TOS + 2: instance.
1761 // TOS + 3: SubtypeTestCache. 1761 // TOS + 3: SubtypeTestCache.
1762 // Result in RCX: null -> not found, otherwise result (true or false). 1762 // Result in RCX: null -> not found, otherwise result (true or false).
1763 static void GenerateSubtypeNTestCacheStub(Assembler* assembler, int n) { 1763 static void GenerateSubtypeNTestCacheStub(Assembler* assembler, int n) {
1764 ASSERT((1 <= n) && (n <= 3)); 1764 ASSERT((1 <= n) && (n <= 3));
1765 const Immediate raw_null = 1765 const Immediate raw_null =
1766 Immediate(reinterpret_cast<intptr_t>(Object::null())); 1766 Immediate(reinterpret_cast<intptr_t>(Object::null()));
1767 // const intptr_t kInstantiatorTypeArgumentsInBytes = 1 * kWordSize; 1767 const intptr_t kInstantiatorTypeArgumentsInBytes = 1 * kWordSize;
1768 const intptr_t kInstanceOffsetInBytes = 2 * kWordSize; 1768 const intptr_t kInstanceOffsetInBytes = 2 * kWordSize;
1769 const intptr_t kCacheOffsetInBytes = 3 * kWordSize; 1769 const intptr_t kCacheOffsetInBytes = 3 * kWordSize;
1770 __ movq(RAX, Address(RSP, kInstanceOffsetInBytes)); 1770 __ movq(RAX, Address(RSP, kInstanceOffsetInBytes));
1771 __ movq(R10, FieldAddress(RAX, Object::class_offset())); 1771 __ movq(R10, FieldAddress(RAX, Object::class_offset()));
1772 // RAX: instance, R10: instance class. 1772 // RAX: instance, R10: instance class.
1773 if (n > 1) { 1773 if (n > 1) {
1774 __ Unimplemented("GenerateSubtypeNTestCacheStub n > 1"); 1774 // Compute instance type arguments into R13.
1775 Label has_no_type_arguments;
1776 __ movq(R13, raw_null);
1777 __ movq(RDI, FieldAddress(R10,
1778 Class::type_arguments_instance_field_offset_offset()));
1779 __ cmpq(RDI, Immediate(Class::kNoTypeArguments));
1780 __ j(EQUAL, &has_no_type_arguments, Assembler::kNearJump);
1781 __ movq(R13, FieldAddress(RAX, RDI, TIMES_1, 0));
1782 __ Bind(&has_no_type_arguments);
1775 } 1783 }
1776 // TODO(srdjan): R13: instance type arguments or null, used only if n > 1. 1784 // R13: instance type arguments or null, used only if n > 1.
1777 __ movq(RDX, Address(RSP, kCacheOffsetInBytes)); 1785 __ movq(RDX, Address(RSP, kCacheOffsetInBytes));
1778 // RDX: SubtypeTestCache. 1786 // RDX: SubtypeTestCache.
1779 __ movq(RDX, FieldAddress(RDX, SubtypeTestCache::cache_offset())); 1787 __ movq(RDX, FieldAddress(RDX, SubtypeTestCache::cache_offset()));
1780 __ addq(RDX, Immediate(Array::data_offset() - kHeapObjectTag)); 1788 __ addq(RDX, Immediate(Array::data_offset() - kHeapObjectTag));
1781 // RDX: Entry start. 1789 // RDX: Entry start.
1782 // R10: instance class. 1790 // R10: instance class.
1783 // R13: instance type arguments 1791 // R13: instance type arguments
1784 Label loop, found, not_found, next_iteration; 1792 Label loop, found, not_found, next_iteration;
1785 __ Bind(&loop); 1793 __ Bind(&loop);
1786 __ movq(RDI, Address(RDX, kWordSize * SubtypeTestCache::kInstanceClass)); 1794 __ movq(RDI, Address(RDX, kWordSize * SubtypeTestCache::kInstanceClass));
1787 __ cmpq(RDI, raw_null); 1795 __ cmpq(RDI, raw_null);
1788 __ j(EQUAL, &not_found, Assembler::kNearJump); 1796 __ j(EQUAL, &not_found, Assembler::kNearJump);
1789 __ cmpq(RDI, R10); 1797 __ cmpq(RDI, R10);
1790 if (n == 1) { 1798 if (n == 1) {
1791 __ j(EQUAL, &found, Assembler::kNearJump); 1799 __ j(EQUAL, &found, Assembler::kNearJump);
1792 } else { 1800 } else {
1793 __ Unimplemented("GenerateSubtypeNTestCacheStub n > 1"); 1801 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump);
1802 __ movq(RDI,
1803 Address(RDX, kWordSize * SubtypeTestCache::kInstanceTypeArguments));
1804 __ cmpq(RDI, R13);
1805 if (n == 2) {
1806 __ j(EQUAL, &found, Assembler::kNearJump);
1807 } else {
1808 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump);
1809 __ movq(RDI,
1810 Address(RDX,
1811 kWordSize * SubtypeTestCache::kInstantiatorTypeArguments));
1812 __ cmpq(RDI, Address(RSP, kInstantiatorTypeArgumentsInBytes));
1813 __ j(EQUAL, &found, Assembler::kNearJump);
1814 }
1794 } 1815 }
1795 1816
1796 __ Bind(&next_iteration); 1817 __ Bind(&next_iteration);
1797 __ addq(RDX, Immediate(kWordSize * SubtypeTestCache::kTestEntryLength)); 1818 __ addq(RDX, Immediate(kWordSize * SubtypeTestCache::kTestEntryLength));
1798 __ jmp(&loop, Assembler::kNearJump); 1819 __ jmp(&loop, Assembler::kNearJump);
1799 // Fall through to not found. 1820 // Fall through to not found.
1800 __ Bind(&not_found); 1821 __ Bind(&not_found);
1801 __ movq(RCX, raw_null); 1822 __ movq(RCX, raw_null);
1802 __ ret(); 1823 __ ret();
1803 1824
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1835 // TOS + 2: instance. 1856 // TOS + 2: instance.
1836 // TOS + 3: cache array. 1857 // TOS + 3: cache array.
1837 // Result in RCX: null -> not found, otherwise result (true or false). 1858 // Result in RCX: null -> not found, otherwise result (true or false).
1838 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) { 1859 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) {
1839 GenerateSubtypeNTestCacheStub(assembler, 3); 1860 GenerateSubtypeNTestCacheStub(assembler, 3);
1840 } 1861 }
1841 1862
1842 } // namespace dart 1863 } // namespace dart
1843 1864
1844 #endif // defined TARGET_ARCH_X64 1865 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698