| 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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 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" |
| 11 #include "vm/instructions.h" | 12 #include "vm/instructions.h" |
| 12 #include "vm/object.h" | 13 #include "vm/object.h" |
| 13 #include "vm/raw_object.h" | 14 #include "vm/raw_object.h" |
| 14 | 15 |
| 15 namespace dart { | 16 namespace dart { |
| 16 | 17 |
| 17 // The pattern of a Dart call is: | 18 // The pattern of a Dart call is: |
| 18 // 1: mov ECX, immediate 1 | 19 // 1: mov ECX, immediate 1 |
| 19 // 2: mov EDX, immediate 2 | 20 // 2: mov EDX, immediate 2 |
| 20 // 3: call target_address | 21 // 3: call target_address |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 f ^= reinterpret_cast<RawObject*>(immediate_one()); | 101 f ^= reinterpret_cast<RawObject*>(immediate_one()); |
| 101 return f.raw(); | 102 return f.raw(); |
| 102 } | 103 } |
| 103 | 104 |
| 104 private: | 105 private: |
| 105 DISALLOW_IMPLICIT_CONSTRUCTORS(StaticCall); | 106 DISALLOW_IMPLICIT_CONSTRUCTORS(StaticCall); |
| 106 }; | 107 }; |
| 107 | 108 |
| 108 | 109 |
| 109 // The expected pattern of a dart instance call: | 110 // The expected pattern of a dart instance call: |
| 110 // mov ECX, function_name | 111 // mov ECX, ic-data array |
| 111 // mov EDX, argument_descriptor_array | 112 // mov EDX, argument_descriptor_array |
| 112 // call target_address | 113 // call target_address |
| 113 // <- return address | 114 // <- return address |
| 114 class InstanceCall : public DartCallPattern { | 115 class InstanceCall : public DartCallPattern { |
| 115 public: | 116 public: |
| 116 explicit InstanceCall(uword return_address) | 117 explicit InstanceCall(uword return_address) |
| 117 : DartCallPattern(return_address) {} | 118 : DartCallPattern(return_address) {} |
| 118 | 119 |
| 119 RawString* function_name() const { | 120 RawArray* ic_data() const { |
| 120 String& str = String::Handle(); | 121 Array& array = Array::Handle(); |
| 121 str ^= reinterpret_cast<RawObject*>(immediate_one()); | 122 array ^= reinterpret_cast<RawObject*>(immediate_one()); |
| 122 return str.raw(); | 123 return array.raw(); |
| 123 } | 124 } |
| 124 | 125 |
| 125 private: | 126 private: |
| 126 DISALLOW_IMPLICIT_CONSTRUCTORS(InstanceCall); | 127 DISALLOW_IMPLICIT_CONSTRUCTORS(InstanceCall); |
| 127 }; | 128 }; |
| 128 | 129 |
| 129 | 130 |
| 130 void CodePatcher::GetStaticCallAt(uword return_address, | 131 void CodePatcher::GetStaticCallAt(uword return_address, |
| 131 Function* function, | 132 Function* function, |
| 132 uword* target) { | 133 uword* target) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 int* num_named_arguments, | 238 int* num_named_arguments, |
| 238 uword* target) { | 239 uword* target) { |
| 239 ASSERT(function_name != NULL); | 240 ASSERT(function_name != NULL); |
| 240 ASSERT(num_arguments != NULL); | 241 ASSERT(num_arguments != NULL); |
| 241 ASSERT(num_named_arguments != NULL); | 242 ASSERT(num_named_arguments != NULL); |
| 242 ASSERT(target != NULL); | 243 ASSERT(target != NULL); |
| 243 InstanceCall call(return_address); | 244 InstanceCall call(return_address); |
| 244 *num_arguments = call.argument_count(); | 245 *num_arguments = call.argument_count(); |
| 245 *num_named_arguments = call.named_argument_count(); | 246 *num_named_arguments = call.named_argument_count(); |
| 246 *target = call.target(); | 247 *target = call.target(); |
| 247 *function_name = call.function_name(); | 248 ICData ic_data(Array::ZoneHandle(call.ic_data())); |
| 249 *function_name = ic_data.FunctionName(); |
| 248 } | 250 } |
| 249 | 251 |
| 250 | 252 |
| 251 void CodePatcher::PatchInstanceCallAt(uword return_address, uword new_target) { | 253 void CodePatcher::PatchInstanceCallAt(uword return_address, uword new_target) { |
| 252 InstanceCall call(return_address); | 254 InstanceCall call(return_address); |
| 253 call.set_target(new_target); | 255 call.set_target(new_target); |
| 254 } | 256 } |
| 255 | 257 |
| 256 } // namespace dart | 258 } // namespace dart |
| 257 | 259 |
| 258 #endif // defined TARGET_ARCH_IA32 | 260 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |