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

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

Issue 11275290: Count per check hits in ICData. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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
« runtime/vm/object.cc ('K') | « 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 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 __ j(EQUAL, &found); // Break. 1624 __ j(EQUAL, &found); // Break.
1625 } 1625 }
1626 } 1626 }
1627 __ Bind(&update); 1627 __ Bind(&update);
1628 // Reload receiver class ID. It has not been destroyed when num_args == 1. 1628 // Reload receiver class ID. It has not been destroyed when num_args == 1.
1629 if (num_args > 1) { 1629 if (num_args > 1) {
1630 __ movq(RAX, FieldAddress(R10, Array::data_offset())); 1630 __ movq(RAX, FieldAddress(R10, Array::data_offset()));
1631 __ movq(RAX, Address(RSP, RAX, TIMES_4, 0)); 1631 __ movq(RAX, Address(RSP, RAX, TIMES_4, 0));
1632 __ call(&get_class_id_as_smi); 1632 __ call(&get_class_id_as_smi);
1633 } 1633 }
1634 // Each test entry has (1 + num_args) array elements. 1634
1635 const intptr_t entry_size = (num_args + 1) * kWordSize; 1635 const intptr_t entry_size = ICData::TestEntryLengthFor(num_args) * kWordSize;
1636 __ addq(R12, Immediate(entry_size)); // Next entry. 1636 __ addq(R12, Immediate(entry_size)); // Next entry.
1637 __ movq(R13, Address(R12, 0)); // Next class ID. 1637 __ movq(R13, Address(R12, 0)); // Next class ID.
1638 1638
1639 __ Bind(&test); 1639 __ Bind(&test);
1640 __ cmpq(R13, Immediate(Smi::RawValue(kIllegalCid))); // Done? 1640 __ cmpq(R13, Immediate(Smi::RawValue(kIllegalCid))); // Done?
1641 __ j(NOT_EQUAL, &loop, Assembler::kNearJump); 1641 __ j(NOT_EQUAL, &loop, Assembler::kNearJump);
1642 1642
1643 // IC miss. 1643 // IC miss.
1644 const Immediate raw_null = 1644 const Immediate raw_null =
1645 Immediate(reinterpret_cast<intptr_t>(Object::null())); 1645 Immediate(reinterpret_cast<intptr_t>(Object::null()));
(...skipping 30 matching lines...) Expand all
1676 Label call_target_function; 1676 Label call_target_function;
1677 __ cmpq(RAX, raw_null); 1677 __ cmpq(RAX, raw_null);
1678 __ j(NOT_EQUAL, &call_target_function, Assembler::kNearJump); 1678 __ j(NOT_EQUAL, &call_target_function, Assembler::kNearJump);
1679 // NoSuchMethod or closure. 1679 // NoSuchMethod or closure.
1680 // Mark IC call that it may be a closure call that does not collect 1680 // Mark IC call that it may be a closure call that does not collect
1681 // type feedback. 1681 // type feedback.
1682 __ movb(FieldAddress(RBX, ICData::is_closure_call_offset()), Immediate(1)); 1682 __ movb(FieldAddress(RBX, ICData::is_closure_call_offset()), Immediate(1));
1683 __ jmp(&StubCode::InstanceFunctionLookupLabel()); 1683 __ jmp(&StubCode::InstanceFunctionLookupLabel());
1684 1684
1685 __ Bind(&found); 1685 __ Bind(&found);
1686 // R12: Pointer to an IC data check group (classes + target) 1686 // R12: Pointer to an IC data check group.
1687 __ movq(RAX, Address(R12, kWordSize * num_args)); // Target function. 1687 const intptr_t target_offset = ICData::TargetIndexFor(num_args) * kWordSize;
1688 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize;
1689 __ movq(RAX, Address(R12, target_offset));
1690 __ addq(Address(R12, count_offset), Immediate(Smi::RawValue(1)));
1691 __ j(NO_OVERFLOW, &call_target_function);
1692 __ movq(Address(R12, count_offset),
1693 Immediate(Smi::RawValue(Smi::kMaxValue)));
1688 1694
1689 __ Bind(&call_target_function); 1695 __ Bind(&call_target_function);
1690 // RAX: Target function. 1696 // RAX: Target function.
1691 __ movq(RAX, FieldAddress(RAX, Function::code_offset())); 1697 __ movq(RAX, FieldAddress(RAX, Function::code_offset()));
1692 __ movq(RAX, FieldAddress(RAX, Code::instructions_offset())); 1698 __ movq(RAX, FieldAddress(RAX, Code::instructions_offset()));
1693 __ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); 1699 __ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
1694 __ jmp(RAX); 1700 __ jmp(RAX);
1695 1701
1696 __ Bind(&get_class_id_as_smi); 1702 __ Bind(&get_class_id_as_smi);
1697 Label not_smi; 1703 Label not_smi;
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 2008
2003 // Implements equality operator when one of the arguments is null 2009 // Implements equality operator when one of the arguments is null
2004 // (identity check) and updates ICData if necessary. 2010 // (identity check) and updates ICData if necessary.
2005 // TOS + 0: return address 2011 // TOS + 0: return address
2006 // TOS + 1: right argument 2012 // TOS + 1: right argument
2007 // TOS + 2: left argument 2013 // TOS + 2: left argument
2008 // RBX: ICData. 2014 // RBX: ICData.
2009 // RAX: result. 2015 // RAX: result.
2010 // TODO(srdjan): Move to VM stubs once Boolean objects become VM objects. 2016 // TODO(srdjan): Move to VM stubs once Boolean objects become VM objects.
2011 void StubCode::GenerateEqualityWithNullArgStub(Assembler* assembler) { 2017 void StubCode::GenerateEqualityWithNullArgStub(Assembler* assembler) {
2018 static const intptr_t kNumArgsTested = 2;
2012 #if defined(DEBUG) 2019 #if defined(DEBUG)
2013 { Label ok; 2020 { Label ok;
2014 __ movq(RCX, FieldAddress(RBX, ICData::num_args_tested_offset())); 2021 __ movq(RCX, FieldAddress(RBX, ICData::num_args_tested_offset()));
2015 __ cmpq(RCX, Immediate(2)); 2022 __ cmpq(RCX, Immediate(kNumArgsTested));
2016 __ j(EQUAL, &ok, Assembler::kNearJump); 2023 __ j(EQUAL, &ok, Assembler::kNearJump);
2017 __ Stop("Incorrect ICData for equality"); 2024 __ Stop("Incorrect ICData for equality");
2018 __ Bind(&ok); 2025 __ Bind(&ok);
2019 } 2026 }
2020 #endif // DEBUG 2027 #endif // DEBUG
2021 // Check IC data, update if needed. 2028 // Check IC data, update if needed.
2022 // RBX: IC data object (preserved). 2029 // RBX: IC data object (preserved).
2023 __ movq(R12, FieldAddress(RBX, ICData::ic_data_offset())); 2030 __ movq(R12, FieldAddress(RBX, ICData::ic_data_offset()));
2024 // R12: ic_data_array with check entries: classes and target functions. 2031 // R12: ic_data_array with check entries: classes and target functions.
2025 __ leaq(R12, FieldAddress(R12, Array::data_offset())); 2032 __ leaq(R12, FieldAddress(R12, Array::data_offset()));
2026 // R12: points directly to the first ic data array element. 2033 // R12: points directly to the first ic data array element.
2027 2034
2028 Label get_class_id_as_smi, no_match, loop, compute_result; 2035 Label get_class_id_as_smi, no_match, loop, compute_result, found;
2029 __ Bind(&loop); 2036 __ Bind(&loop);
2030 // Check left. 2037 // Check left.
2031 __ movq(RAX, Address(RSP, 2 * kWordSize)); 2038 __ movq(RAX, Address(RSP, 2 * kWordSize));
2032 __ call(&get_class_id_as_smi); 2039 __ call(&get_class_id_as_smi);
2033 __ movq(R13, Address(R12, 0 * kWordSize)); 2040 __ movq(R13, Address(R12, 0 * kWordSize));
2034 __ cmpq(RAX, R13); // Class id match? 2041 __ cmpq(RAX, R13); // Class id match?
2035 __ j(NOT_EQUAL, &no_match, Assembler::kNearJump); 2042 __ j(NOT_EQUAL, &no_match, Assembler::kNearJump);
2036 // Check right. 2043 // Check right.
2037 __ movq(RAX, Address(RSP, 1 * kWordSize)); 2044 __ movq(RAX, Address(RSP, 1 * kWordSize));
2038 __ call(&get_class_id_as_smi); 2045 __ call(&get_class_id_as_smi);
2039 __ movq(R13, Address(R12, 1 * kWordSize)); 2046 __ movq(R13, Address(R12, 1 * kWordSize));
2040 __ cmpq(RAX, R13); // Class id match? 2047 __ cmpq(RAX, R13); // Class id match?
2041 __ j(EQUAL, &compute_result, Assembler::kNearJump); 2048 __ j(EQUAL, &found, Assembler::kNearJump);
2042 __ Bind(&no_match); 2049 __ Bind(&no_match);
2043 // Each test entry has (1 + 2) array elements (2 arguments, 1 target). 2050 // Next check group.
2044 __ addq(R12, Immediate(kWordSize * (1 + 2))); // Next element. 2051 __ addq(R12, Immediate(
2052 kWordSize * ICData::TestEntryLengthFor(kNumArgsTested)));
2045 __ cmpq(R13, Immediate(Smi::RawValue(kIllegalCid))); // Done? 2053 __ cmpq(R13, Immediate(Smi::RawValue(kIllegalCid))); // Done?
2046 __ j(NOT_EQUAL, &loop, Assembler::kNearJump); 2054 __ j(NOT_EQUAL, &loop, Assembler::kNearJump);
2047 Label update_ic_data; 2055 Label update_ic_data;
2048 __ jmp(&update_ic_data); 2056 __ jmp(&update_ic_data);
2049 2057
2058 __ Bind(&found);
2059 const intptr_t count_offset =
2060 ICData::CountIndexFor(kNumArgsTested) * kWordSize;
2061 __ addq(Address(R12, count_offset), Immediate(Smi::RawValue(1)));
2062 __ j(NO_OVERFLOW, &compute_result);
2063 __ movq(Address(R12, count_offset),
2064 Immediate(Smi::RawValue(Smi::kMaxValue)));
2065
2050 __ Bind(&compute_result); 2066 __ Bind(&compute_result);
2051 Label true_label; 2067 Label true_label;
2052 __ movq(RAX, Address(RSP, 1 * kWordSize)); 2068 __ movq(RAX, Address(RSP, 1 * kWordSize));
2053 __ cmpq(RAX, Address(RSP, 2 * kWordSize)); 2069 __ cmpq(RAX, Address(RSP, 2 * kWordSize));
2054 __ j(EQUAL, &true_label, Assembler::kNearJump); 2070 __ j(EQUAL, &true_label, Assembler::kNearJump);
2055 __ LoadObject(RAX, Bool::ZoneHandle(Bool::False())); 2071 __ LoadObject(RAX, Bool::ZoneHandle(Bool::False()));
2056 __ ret(); 2072 __ ret();
2057 __ Bind(&true_label); 2073 __ Bind(&true_label);
2058 __ LoadObject(RAX, Bool::ZoneHandle(Bool::True())); 2074 __ LoadObject(RAX, Bool::ZoneHandle(Bool::True()));
2059 __ ret(); 2075 __ ret();
(...skipping 22 matching lines...) Expand all
2082 __ pushq(RAX); // arg 1 2098 __ pushq(RAX); // arg 1
2083 __ PushObject(equal_name); // Target's name. 2099 __ PushObject(equal_name); // Target's name.
2084 __ pushq(RBX); // ICData 2100 __ pushq(RBX); // ICData
2085 __ CallRuntime(kUpdateICDataTwoArgsRuntimeEntry); 2101 __ CallRuntime(kUpdateICDataTwoArgsRuntimeEntry);
2086 __ Drop(4); 2102 __ Drop(4);
2087 __ LeaveFrame(); 2103 __ LeaveFrame();
2088 2104
2089 __ jmp(&compute_result, Assembler::kNearJump); 2105 __ jmp(&compute_result, Assembler::kNearJump);
2090 } 2106 }
2091 2107
2092 // Calls to runtime to ooptimized give function 2108 // Calls to runtime to optimized give function
Kevin Millikin (Google) 2012/11/13 20:59:33 While you're fixing ooptimized, you might as well
Vyacheslav Egorov (Google) 2012/12/17 12:54:16 Done.
2093 // RDX: function to be reoptimized. 2109 // RDX: function to be reoptimized.
2094 // RAX: result of function being optimized (preserved). 2110 // RAX: result of function being optimized (preserved).
2095 void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) { 2111 void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) {
2096 AssemblerMacros::EnterStubFrame(assembler); 2112 AssemblerMacros::EnterStubFrame(assembler);
2097 __ pushq(RAX); 2113 __ pushq(RAX);
2098 __ pushq(RDX); 2114 __ pushq(RDX);
2099 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry); 2115 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry);
2100 __ popq(RDX); 2116 __ popq(RDX);
2101 __ popq(RAX); 2117 __ popq(RAX);
2102 __ LeaveFrame(); 2118 __ LeaveFrame();
2103 __ ret(); 2119 __ ret();
2104 } 2120 }
2105 2121
2106 } // namespace dart 2122 } // namespace dart
2107 2123
2108 #endif // defined TARGET_ARCH_X64 2124 #endif // defined TARGET_ARCH_X64
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/stub_code_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698