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

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

Issue 10080015: Implement checked mode in new compiler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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/stub_code_ia32.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/code_generator.h" 8 #include "vm/code_generator.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/object_store.h" 10 #include "vm/object_store.h"
(...skipping 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 Label ic_cache_one_arg; 1722 Label ic_cache_one_arg;
1723 __ movq(RCX, FieldAddress(RBX, ICData::num_args_tested_offset())); 1723 __ movq(RCX, FieldAddress(RBX, ICData::num_args_tested_offset()));
1724 __ cmpq(RCX, Immediate(1)); 1724 __ cmpq(RCX, Immediate(1));
1725 __ j(EQUAL, &ic_cache_one_arg, Assembler::kNearJump); 1725 __ j(EQUAL, &ic_cache_one_arg, Assembler::kNearJump);
1726 __ jmp(&StubCode::TwoArgsCheckInlineCacheLabel()); 1726 __ jmp(&StubCode::TwoArgsCheckInlineCacheLabel());
1727 __ Bind(&ic_cache_one_arg); 1727 __ Bind(&ic_cache_one_arg);
1728 __ jmp(&StubCode::OneArgCheckInlineCacheLabel()); 1728 __ jmp(&StubCode::OneArgCheckInlineCacheLabel());
1729 } 1729 }
1730 1730
1731 1731
1732 // Check if an instance class is a subtype of class/interface using simple
1733 // superchain and interface array traversal. Does not take type parameters into
1734 // account.
1735 // RAX: instance (preserved)
1736 // RCX: class/interface to test against (is class of instance a subtype of it).
1737 // (preserved).
1738 // Result in RBX: 1 is subtype, 0 maybe not.
1739 // Must preserve RDX.
1740 // Destroys RBX, R13, R10.
1732 void StubCode::GenerateIsRawSubTypeStub(Assembler* assembler) { 1741 void StubCode::GenerateIsRawSubTypeStub(Assembler* assembler) {
1733 __ Unimplemented("IsRawSubType Stub"); 1742 const Immediate raw_null =
1743 Immediate(reinterpret_cast<intptr_t>(Object::null()));
1744 Label test_class, not_found, found, class_loaded_in_R10, smi_value;
1745 __ EnterFrame(0);
1746 __ testq(RAX, Immediate(kSmiTagMask));
1747 __ j(ZERO, &smi_value, Assembler::kNearJump);
1748 __ movq(R10, FieldAddress(RAX, Object::class_offset()));
1749 __ jmp(&class_loaded_in_R10, Assembler::kNearJump);
1750 __ Bind(&smi_value);
1751 __ movq(R10, FieldAddress(CTX, Context::isolate_offset()));
1752 __ movq(R10, Address(R10, Isolate::object_store_offset()));
1753 __ movq(R10, Address(R10, ObjectStore::smi_class_offset()));
1754 __ Bind(&class_loaded_in_R10);
1755
1756 __ movzxb(RBX, FieldAddress(RCX, Class::is_interface_offset()));
1757 // Check if we are comparing against class or interface.
1758 __ cmpq(RBX, Immediate(0));
1759 __ j(EQUAL, &test_class, Assembler::kNearJump);
1760
1761 // Get interfaces array from instance class.
1762 __ movq(RBX, FieldAddress(R10, Class::interfaces_offset()));
1763 __ cmpq(RBX, raw_null);
1764 __ j(EQUAL, &not_found, Assembler::kNearJump);
1765 __ movq(R13, FieldAddress(RBX, Array::length_offset()));
1766 // R13: array index.
1767 // RBX: interface array.
1768 // RCX: interface searched
1769 Label array_loop;
1770 __ Bind(&array_loop);
1771 __ subq(R13, Immediate(Smi::RawValue(1)));
1772 // __ cmpq(R13, Immediate(0));
1773 __ j(LESS, &not_found, Assembler::kNearJump);
1774 // R13 is Smi therefore TIMES_4 instead of TIMES_8.
1775 // Get type from array.
1776 __ movq(R10, FieldAddress(RBX, R13, TIMES_4, Array::data_offset()));
1777 __ movq(R10, FieldAddress(R10, Type::type_class_offset()));
1778 __ cmpq(R10, RCX);
1779 __ j(EQUAL, &found, Assembler::kNearJump);
1780 __ jmp(&array_loop, Assembler::kNearJump);
1781
1782 __ Bind(&not_found);
1783 __ xorq(RBX, RBX);
1784 __ LeaveFrame();
1785 __ ret();
1786
1787 __ Bind(&found);
1788 __ movq(RBX, Immediate(1));
1789 __ LeaveFrame();
1790 __ ret();
1791
1792 __ Bind(&test_class);
1793 // RCX: test class.
1794 __ cmpq(R10, RCX);
1795 __ j(EQUAL, &found, Assembler::kNearJump);
1796
1797 // Check superclasses using a loop (faster than runtime call).
1798 Label super_loop;
1799 __ Bind(&super_loop);
1800 // R10: class -> super.
1801 __ movq(R10, FieldAddress(R10, Class::super_type_offset()));
1802 // The supertype of Object is a null object.
1803 __ cmpq(R10, raw_null);
1804 __ j(EQUAL, &not_found, Assembler::kNearJump);
1805 __ movq(R10, FieldAddress(R10, Type::type_class_offset()));
1806 __ cmpq(RCX, R10);
1807 __ j(NOT_EQUAL, &super_loop, Assembler::kNearJump);
1808 __ jmp(&found, Assembler::kNearJump);
1734 } 1809 }
1735 1810
1736 } // namespace dart 1811 } // namespace dart
1737 1812
1738 #endif // defined TARGET_ARCH_X64 1813 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/stub_code_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698