| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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" |
| 11 #include "vm/ic_data.h" | |
| 12 #include "vm/instructions.h" | 11 #include "vm/instructions.h" |
| 13 #include "vm/object.h" | 12 #include "vm/object.h" |
| 14 #include "vm/raw_object.h" | 13 #include "vm/raw_object.h" |
| 15 | 14 |
| 16 namespace dart { | 15 namespace dart { |
| 17 | 16 |
| 18 // The pattern of a Dart call is: | 17 // The pattern of a Dart call is: |
| 19 // 00: 48 bb imm64 mov RBX, immediate 1 | 18 // 00: 48 bb imm64 mov RBX, immediate 1 |
| 20 // 10: 49 ba imm64 mov R10, immediate 2 | 19 // 10: 49 ba imm64 mov R10, immediate 2 |
| 21 // 20: 49 bb imm64 mov R11, target_address | 20 // 20: 49 bb imm64 mov R11, target_address |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 Function& f = Function::Handle(); | 97 Function& f = Function::Handle(); |
| 99 f ^= reinterpret_cast<RawObject*>(immediate_one()); | 98 f ^= reinterpret_cast<RawObject*>(immediate_one()); |
| 100 return f.raw(); | 99 return f.raw(); |
| 101 } | 100 } |
| 102 | 101 |
| 103 private: | 102 private: |
| 104 DISALLOW_IMPLICIT_CONSTRUCTORS(StaticCall); | 103 DISALLOW_IMPLICIT_CONSTRUCTORS(StaticCall); |
| 105 }; | 104 }; |
| 106 | 105 |
| 107 | 106 |
| 108 // A Dart instance call passes the ic-data array in RBX. | 107 // A Dart instance call passes the ic-data in RBX. |
| 109 class InstanceCall : public DartCallPattern { | 108 class InstanceCall : public DartCallPattern { |
| 110 public: | 109 public: |
| 111 explicit InstanceCall(uword return_address) | 110 explicit InstanceCall(uword return_address) |
| 112 : DartCallPattern(return_address) {} | 111 : DartCallPattern(return_address) {} |
| 113 | 112 |
| 114 RawArray* ic_data() const { | 113 RawICData* ic_data() const { |
| 115 Array& array = Array::Handle(); | 114 ICData& ic_data = ICData::Handle(); |
| 116 array ^= reinterpret_cast<RawObject*>(immediate_one()); | 115 ic_data ^= reinterpret_cast<RawObject*>(immediate_one()); |
| 117 return array.raw(); | 116 return ic_data.raw(); |
| 118 } | 117 } |
| 119 | 118 |
| 120 void SetIcData(const Array& value) { | 119 void SetIcData(const ICData& value) { |
| 121 set_immediate_one(reinterpret_cast<int64_t>(value.raw())); | 120 set_immediate_one(reinterpret_cast<int64_t>(value.raw())); |
| 122 } | 121 } |
| 123 | 122 |
| 124 private: | 123 private: |
| 125 DISALLOW_IMPLICIT_CONSTRUCTORS(InstanceCall); | 124 DISALLOW_IMPLICIT_CONSTRUCTORS(InstanceCall); |
| 126 }; | 125 }; |
| 127 | 126 |
| 128 | 127 |
| 129 void CodePatcher::GetStaticCallAt(uword return_address, | 128 void CodePatcher::GetStaticCallAt(uword return_address, |
| 130 Function* function, | 129 Function* function, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 int* num_named_arguments, | 222 int* num_named_arguments, |
| 224 uword* target) { | 223 uword* target) { |
| 225 ASSERT(function_name != NULL); | 224 ASSERT(function_name != NULL); |
| 226 ASSERT(num_arguments != NULL); | 225 ASSERT(num_arguments != NULL); |
| 227 ASSERT(num_named_arguments != NULL); | 226 ASSERT(num_named_arguments != NULL); |
| 228 ASSERT(target != NULL); | 227 ASSERT(target != NULL); |
| 229 InstanceCall call(return_address); | 228 InstanceCall call(return_address); |
| 230 *num_arguments = call.argument_count(); | 229 *num_arguments = call.argument_count(); |
| 231 *num_named_arguments = call.named_argument_count(); | 230 *num_named_arguments = call.named_argument_count(); |
| 232 *target = call.target(); | 231 *target = call.target(); |
| 233 ICData ic_data(Array::ZoneHandle(call.ic_data())); | 232 const ICData& ic_data = ICData::Handle(call.ic_data()); |
| 234 *function_name = ic_data.FunctionName(); | 233 *function_name = ic_data.target_name(); |
| 235 } | 234 } |
| 236 | 235 |
| 237 | 236 |
| 238 RawArray* CodePatcher::GetInstanceCallIcDataAt(uword return_address) { | 237 RawICData* CodePatcher::GetInstanceCallIcDataAt(uword return_address) { |
| 239 InstanceCall call(return_address); | 238 InstanceCall call(return_address); |
| 240 return call.ic_data(); | 239 return call.ic_data(); |
| 241 } | 240 } |
| 242 | 241 |
| 243 | 242 |
| 244 void CodePatcher::SetInstanceCallIcDataAt(uword return_address, | |
| 245 const Array& ic_data) { | |
| 246 InstanceCall call(return_address); | |
| 247 call.SetIcData(ic_data); | |
| 248 } | |
| 249 | |
| 250 | |
| 251 intptr_t CodePatcher::InstanceCallSizeInBytes() { | 243 intptr_t CodePatcher::InstanceCallSizeInBytes() { |
| 252 return DartCallPattern::kCallPatternSize; | 244 return DartCallPattern::kCallPatternSize; |
| 253 } | 245 } |
| 254 | 246 |
| 255 } // namespace dart | 247 } // namespace dart |
| 256 | 248 |
| 257 #endif // defined TARGET_ARCH_X64 | 249 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |