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

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

Issue 10910224: Using type feedback, eliminate store barriers for indexed stores. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/assembler_macros.h" 9 #include "vm/assembler_macros.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 if (num_args == 1) { 1590 if (num_args == 1) {
1591 __ call(&get_class_id_as_smi); 1591 __ call(&get_class_id_as_smi);
1592 // RAX: receiver's class id as Smi. 1592 // RAX: receiver's class id as Smi.
1593 __ Bind(&loop); 1593 __ Bind(&loop);
1594 __ movq(R13, Address(R12, 0)); // Get class if (Smi) to check. 1594 __ movq(R13, Address(R12, 0)); // Get class if (Smi) to check.
1595 __ cmpq(RAX, R13); // Match? 1595 __ cmpq(RAX, R13); // Match?
1596 __ j(EQUAL, &found, Assembler::kNearJump); 1596 __ j(EQUAL, &found, Assembler::kNearJump);
1597 __ addq(R12, Immediate(kWordSize * 2)); // Next element (class + target). 1597 __ addq(R12, Immediate(kWordSize * 2)); // Next element (class + target).
1598 __ cmpq(R13, Immediate(Smi::RawValue(kIllegalCid))); // Done? 1598 __ cmpq(R13, Immediate(Smi::RawValue(kIllegalCid))); // Done?
1599 __ j(NOT_EQUAL, &loop, Assembler::kNearJump); 1599 __ j(NOT_EQUAL, &loop, Assembler::kNearJump);
1600 } else if (num_args == 2) { 1600 } else {
1601 Label no_match; 1601 Label no_match;
1602 __ Bind(&loop); 1602 __ Bind(&loop);
1603 // Get receiver. 1603 for (int i = 0; i < num_args; i++) {
1604 __ movq(RAX, FieldAddress(R10, Array::data_offset())); 1604 __ movq(RAX, FieldAddress(R10, Array::data_offset()));
1605 __ movq(RAX, Address(RSP, RAX, TIMES_4, 0)); // RAX is Smi. 1605 __ movq(RAX, Address(RSP, RAX, TIMES_4, - i * kWordSize));
1606 __ call(&get_class_id_as_smi); 1606 __ call(&get_class_id_as_smi);
1607 __ movq(R13, Address(R12, 0)); // Get class id from IC data to check. 1607 __ movq(R13, Address(R12, i * kWordSize));
1608 __ cmpq(RAX, R13); // Class id match? 1608 __ cmpq(RAX, R13); // Class id match?
1609 __ j(NOT_EQUAL, &no_match, Assembler::kNearJump); 1609 if (i < (num_args - 1)) {
1610 // Check second. 1610 __ j(NOT_EQUAL, &no_match);
1611 // Get next argument. 1611 } else {
1612 __ movq(RAX, FieldAddress(R10, Array::data_offset())); 1612 // Last check, all checks before matched.
1613 __ movq(RAX, Address(RSP, RAX, TIMES_4, -kWordSize)); // RAX is Smi. 1613 __ j(EQUAL, &found);
1614 __ call(&get_class_id_as_smi); 1614 }
1615 __ movq(R13, Address(R12, kWordSize)); // Get class id from IC data. 1615 }
1616 __ cmpq(RAX, R13); // Class id match?
1617 __ j(EQUAL, &found);
1618 __ Bind(&no_match); 1616 __ Bind(&no_match);
1617 // Each test entry has (1 + num_args) array elements.
1619 __ addq(R12, Immediate(kWordSize * (1 + num_args))); // Next element. 1618 __ addq(R12, Immediate(kWordSize * (1 + num_args))); // Next element.
1620 __ cmpq(R13, Immediate(Smi::RawValue(kIllegalCid))); // Done? 1619 __ cmpq(R13, Immediate(Smi::RawValue(kIllegalCid))); // Done?
1621 __ j(NOT_EQUAL, &loop, Assembler::kNearJump); 1620 __ j(NOT_EQUAL, &loop, Assembler::kNearJump);
1622 } 1621 }
1623 1622
1624 __ Bind(&ic_miss); 1623 __ Bind(&ic_miss);
1625 // Compute address of arguments (first read number of arguments from argument 1624 // Compute address of arguments (first read number of arguments from argument
1626 // descriptor array and then compute address on the stack). 1625 // descriptor array and then compute address on the stack).
1627 __ movq(RAX, FieldAddress(R10, Array::data_offset())); 1626 __ movq(RAX, FieldAddress(R10, Array::data_offset()));
1628 __ leaq(RAX, Address(RSP, RAX, TIMES_4, 0)); // RAX is Smi. 1627 __ leaq(RAX, Address(RSP, RAX, TIMES_4, 0)); // RAX is Smi.
1629 AssemblerMacros::EnterStubFrame(assembler); 1628 AssemblerMacros::EnterStubFrame(assembler);
1630 __ pushq(R10); // Preserve arguments array. 1629 __ pushq(R10); // Preserve arguments array.
1631 __ pushq(RBX); // Preserve IC data array 1630 __ pushq(RBX); // Preserve IC data array
1632 __ pushq(raw_null); // Setup space on stack for result (target code object). 1631 __ pushq(raw_null); // Setup space on stack for result (target code object).
1633 // Push call arguments. 1632 // Push call arguments.
1634 for (intptr_t i = 0; i < num_args; i++) { 1633 for (intptr_t i = 0; i < num_args; i++) {
1635 __ movq(R10, Address(RAX, -kWordSize * i)); 1634 __ movq(R10, Address(RAX, -kWordSize * i));
1636 __ pushq(R10); 1635 __ pushq(R10);
1637 } 1636 }
1638 if (num_args == 1) { 1637 if (num_args == 1) {
1639 __ CallRuntime(kInlineCacheMissHandlerOneArgRuntimeEntry); 1638 __ CallRuntime(kInlineCacheMissHandlerOneArgRuntimeEntry);
1640 } else if (num_args == 2) { 1639 } else if (num_args == 2) {
1641 __ CallRuntime(kInlineCacheMissHandlerTwoArgsRuntimeEntry); 1640 __ CallRuntime(kInlineCacheMissHandlerTwoArgsRuntimeEntry);
1641 } else if (num_args == 3) {
1642 __ CallRuntime(kInlineCacheMissHandlerThreeArgsRuntimeEntry);
1642 } else { 1643 } else {
1643 UNIMPLEMENTED(); 1644 UNIMPLEMENTED();
1644 } 1645 }
1645 // Remove call arguments pushed earlier. 1646 // Remove call arguments pushed earlier.
1646 for (intptr_t i = 0; i < num_args; i++) { 1647 for (intptr_t i = 0; i < num_args; i++) {
1647 __ popq(RAX); 1648 __ popq(RAX);
1648 } 1649 }
1649 __ popq(RAX); // Pop returned code object into RAX (null if not found). 1650 __ popq(RAX); // Pop returned code object into RAX (null if not found).
1650 __ popq(RBX); // Restore IC data array. 1651 __ popq(RBX); // Restore IC data array.
1651 __ popq(R10); // Restore arguments array. 1652 __ popq(R10); // Restore arguments array.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 void StubCode::GenerateOneArgCheckInlineCacheStub(Assembler* assembler) { 1697 void StubCode::GenerateOneArgCheckInlineCacheStub(Assembler* assembler) {
1697 return GenerateNArgsCheckInlineCacheStub(assembler, 1); 1698 return GenerateNArgsCheckInlineCacheStub(assembler, 1);
1698 } 1699 }
1699 1700
1700 1701
1701 void StubCode::GenerateTwoArgsCheckInlineCacheStub(Assembler* assembler) { 1702 void StubCode::GenerateTwoArgsCheckInlineCacheStub(Assembler* assembler) {
1702 return GenerateNArgsCheckInlineCacheStub(assembler, 2); 1703 return GenerateNArgsCheckInlineCacheStub(assembler, 2);
1703 } 1704 }
1704 1705
1705 1706
1707 void StubCode::GenerateThreeArgsCheckInlineCacheStub(Assembler* assembler) {
1708 return GenerateNArgsCheckInlineCacheStub(assembler, 3);
1709 }
1710
1711
1706 // RBX: Function object. 1712 // RBX: Function object.
1707 // R10: Arguments array. 1713 // R10: Arguments array.
1708 // TOS(0): return address (Dart code). 1714 // TOS(0): return address (Dart code).
1709 void StubCode::GenerateBreakpointStaticStub(Assembler* assembler) { 1715 void StubCode::GenerateBreakpointStaticStub(Assembler* assembler) {
1710 AssemblerMacros::EnterStubFrame(assembler); 1716 AssemblerMacros::EnterStubFrame(assembler);
1711 __ pushq(R10); 1717 __ pushq(R10);
1712 __ pushq(RBX); 1718 __ pushq(RBX);
1713 __ CallRuntime(kBreakpointStaticHandlerRuntimeEntry); 1719 __ CallRuntime(kBreakpointStaticHandlerRuntimeEntry);
1714 __ popq(RBX); 1720 __ popq(RBX);
1715 __ popq(R10); 1721 __ popq(R10);
(...skipping 28 matching lines...) Expand all
1744 void StubCode::GenerateBreakpointDynamicStub(Assembler* assembler) { 1750 void StubCode::GenerateBreakpointDynamicStub(Assembler* assembler) {
1745 AssemblerMacros::EnterStubFrame(assembler); 1751 AssemblerMacros::EnterStubFrame(assembler);
1746 __ pushq(RBX); 1752 __ pushq(RBX);
1747 __ pushq(R10); 1753 __ pushq(R10);
1748 __ CallRuntime(kBreakpointDynamicHandlerRuntimeEntry); 1754 __ CallRuntime(kBreakpointDynamicHandlerRuntimeEntry);
1749 __ popq(R10); 1755 __ popq(R10);
1750 __ popq(RBX); 1756 __ popq(RBX);
1751 __ LeaveFrame(); 1757 __ LeaveFrame();
1752 1758
1753 // Find out which dispatch stub to call. 1759 // Find out which dispatch stub to call.
1754 Label ic_cache_one_arg; 1760 Label test_two, test_three, test_four;
1755 __ movq(RCX, FieldAddress(RBX, ICData::num_args_tested_offset())); 1761 __ movq(RCX, FieldAddress(RBX, ICData::num_args_tested_offset()));
1756 __ cmpq(RCX, Immediate(1)); 1762 __ cmpq(RCX, Immediate(1));
1757 __ j(EQUAL, &ic_cache_one_arg, Assembler::kNearJump); 1763 __ j(NOT_EQUAL, &test_two, Assembler::kNearJump);
1764 __ jmp(&StubCode::OneArgCheckInlineCacheLabel());
1765 __ Bind(&test_two);
1766 __ cmpl(RCX, Immediate(2));
1767 __ j(NOT_EQUAL, &test_three, Assembler::kNearJump);
1758 __ jmp(&StubCode::TwoArgsCheckInlineCacheLabel()); 1768 __ jmp(&StubCode::TwoArgsCheckInlineCacheLabel());
1759 __ Bind(&ic_cache_one_arg); 1769 __ Bind(&test_three);
1760 __ jmp(&StubCode::OneArgCheckInlineCacheLabel()); 1770 __ cmpl(RCX, Immediate(3));
1771 __ j(NOT_EQUAL, &test_four, Assembler::kNearJump);
1772 __ jmp(&StubCode::ThreeArgsCheckInlineCacheLabel());
1773 __ Bind(&test_four);
1774 __ Stop("Unsupported number of arguments tested.");
1761 } 1775 }
1762 1776
1763 1777
1764 // Used to check class and type arguments. Arguments passed on stack: 1778 // Used to check class and type arguments. Arguments passed on stack:
1765 // TOS + 0: return address. 1779 // TOS + 0: return address.
1766 // TOS + 1: instantiator type arguments (can be NULL). 1780 // TOS + 1: instantiator type arguments (can be NULL).
1767 // TOS + 2: instance. 1781 // TOS + 2: instance.
1768 // TOS + 3: SubtypeTestCache. 1782 // TOS + 3: SubtypeTestCache.
1769 // Result in RCX: null -> not found, otherwise result (true or false). 1783 // Result in RCX: null -> not found, otherwise result (true or false).
1770 static void GenerateSubtypeNTestCacheStub(Assembler* assembler, int n) { 1784 static void GenerateSubtypeNTestCacheStub(Assembler* assembler, int n) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 void StubCode::GenerateJumpToErrorHandlerStub(Assembler* assembler) { 1923 void StubCode::GenerateJumpToErrorHandlerStub(Assembler* assembler) {
1910 __ movq(RAX, RCX); // error object. 1924 __ movq(RAX, RCX); // error object.
1911 __ movq(RBP, RDX); // target frame_pointer. 1925 __ movq(RBP, RDX); // target frame_pointer.
1912 __ movq(RSP, RSI); // target stack_pointer. 1926 __ movq(RSP, RSI); // target stack_pointer.
1913 __ jmp(RDI); // Jump to the exception handler code. 1927 __ jmp(RDI); // Jump to the exception handler code.
1914 } 1928 }
1915 1929
1916 } // namespace dart 1930 } // namespace dart
1917 1931
1918 #endif // defined TARGET_ARCH_X64 1932 #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