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

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

Issue 11438017: Pass IC data and arguments descriptor to IC miss runtime functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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/code_patcher_ia32_test.cc ('k') | runtime/vm/code_patcher_x64_test.cc » ('j') | 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" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
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/code_patcher.h" 9 #include "vm/code_patcher.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 void set_target(uword target) const { 48 void set_target(uword target) const {
49 uword* target_addr = reinterpret_cast<uword*>(start_ + 20 + 2); 49 uword* target_addr = reinterpret_cast<uword*>(start_ + 20 + 2);
50 *target_addr = target; 50 *target_addr = target;
51 CPU::FlushICache(start_ + 20, 2 + 8); 51 CPU::FlushICache(start_ + 20, 2 + 8);
52 } 52 }
53 53
54 RawObject* immediate_one() const { 54 RawObject* immediate_one() const {
55 return *reinterpret_cast<RawObject**>(start_ + 0 + 2); 55 return *reinterpret_cast<RawObject**>(start_ + 0 + 2);
56 } 56 }
57 57
58 void set_immediate_one(uint64_t value) {
59 uint64_t* target_addr = reinterpret_cast<uint64_t*>(start_ + 0 + 2);
60 *target_addr = value;
61 CPU::FlushICache(start_ + 0, 2 + 8);
62 }
63
64 RawObject* immediate_two() const { 58 RawObject* immediate_two() const {
65 return *reinterpret_cast<RawObject**>(start_ + 10 + 2); 59 return *reinterpret_cast<RawObject**>(start_ + 10 + 2);
66 } 60 }
67 61
68 intptr_t argument_count() const { 62 private:
69 ArgumentsDescriptor args_desc(immediate_two());
70 return args_desc.Count();
71 }
72
73 intptr_t named_argument_count() const {
74 ArgumentsDescriptor args_desc(immediate_two());
75 return args_desc.NamedCount();
76 }
77
78 uword start_; 63 uword start_;
79 DISALLOW_IMPLICIT_CONSTRUCTORS(DartCallPattern); 64 DISALLOW_IMPLICIT_CONSTRUCTORS(DartCallPattern);
80 }; 65 };
81 66
82 67
83 // A Dart instance call passes the ic-data in RBX. 68 // A Dart instance call passes the ic-data in RBX.
84 // The expected pattern of a dart instance call: 69 // The expected pattern of a dart instance call:
85 // mov RBX, ic-data 70 // mov RBX, ic-data
86 // mov R10, arguments_descriptor_array 71 // mov R10, arguments_descriptor_array
87 // mov R11, target_address 72 // mov R11, target_address
88 // call R11 73 // call R11
89 // <- return address 74 // <- return address
90 class InstanceCall : public DartCallPattern { 75 class InstanceCall : public DartCallPattern {
91 public: 76 public:
92 explicit InstanceCall(uword return_address) 77 explicit InstanceCall(uword return_address)
93 : DartCallPattern(return_address) {} 78 : DartCallPattern(return_address) {}
94 79
95 RawICData* ic_data() const { 80 RawObject* ic_data() const { return immediate_one(); }
96 ICData& ic_data = ICData::Handle(); 81 RawObject* arguments_descriptor() const { return immediate_two(); }
97 ic_data ^= immediate_one();
98 return ic_data.raw();
99 }
100 82
101 private: 83 private:
102 DISALLOW_IMPLICIT_CONSTRUCTORS(InstanceCall); 84 DISALLOW_IMPLICIT_CONSTRUCTORS(InstanceCall);
103 }; 85 };
104 86
105 87
106 // The expected pattern of a dart static call: 88 // The expected pattern of a dart static call:
107 // mov R10, arguments_descriptor_array (10 bytes) 89 // mov R10, arguments_descriptor_array (10 bytes)
108 // mov R11, target_address (10 bytes) 90 // mov R11, target_address (10 bytes)
109 // call R11 (3 bytes) 91 // call R11 (3 bytes)
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 205 }
224 return true; 206 return true;
225 } 207 }
226 208
227 209
228 bool CodePatcher::IsDartCall(uword return_address) { 210 bool CodePatcher::IsDartCall(uword return_address) {
229 return DartCallPattern::IsValid(return_address); 211 return DartCallPattern::IsValid(return_address);
230 } 212 }
231 213
232 214
233 void CodePatcher::GetInstanceCallAt(uword return_address, 215 uword CodePatcher::GetInstanceCallAt(uword return_address,
234 String* function_name, 216 ICData* ic_data,
235 int* num_arguments, 217 Array* arguments_descriptor) {
236 int* num_named_arguments,
237 uword* target) {
238 ASSERT(num_arguments != NULL);
239 ASSERT(num_named_arguments != NULL);
240 ASSERT(target != NULL);
241 InstanceCall call(return_address); 218 InstanceCall call(return_address);
242 *num_arguments = call.argument_count(); 219 if (ic_data != NULL) {
243 *num_named_arguments = call.named_argument_count(); 220 *ic_data ^= call.ic_data();
244 *target = call.target();
245 const ICData& ic_data = ICData::Handle(call.ic_data());
246 if (function_name != NULL) {
247 *function_name = ic_data.target_name();
248 } 221 }
222 if (arguments_descriptor != NULL) {
223 *arguments_descriptor ^= call.arguments_descriptor();
224 }
225 return call.target();
249 } 226 }
250 227
251 228
252 RawICData* CodePatcher::GetInstanceCallIcDataAt(uword return_address) {
253 InstanceCall call(return_address);
254 return call.ic_data();
255 }
256
257
258 intptr_t CodePatcher::InstanceCallSizeInBytes() { 229 intptr_t CodePatcher::InstanceCallSizeInBytes() {
259 return DartCallPattern::kCallPatternSize; 230 return DartCallPattern::kCallPatternSize;
260 } 231 }
261 232
262 233
263 void CodePatcher::InsertCallAt(uword start, uword target) { 234 void CodePatcher::InsertCallAt(uword start, uword target) {
264 *reinterpret_cast<uint8_t*>(start) = 0xE8; 235 *reinterpret_cast<uint8_t*>(start) = 0xE8;
265 ShortCallPattern call(start); 236 ShortCallPattern call(start);
266 call.SetTargetAddress(target); 237 call.SetTargetAddress(target);
267 CPU::FlushICache(start, ShortCallPattern::InstructionLength()); 238 CPU::FlushICache(start, ShortCallPattern::InstructionLength());
268 } 239 }
269 240
270 241
271 } // namespace dart 242 } // namespace dart
272 243
273 #endif // defined TARGET_ARCH_X64 244 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/code_patcher_ia32_test.cc ('k') | runtime/vm/code_patcher_x64_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698