| OLD | NEW |
| 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 // Class for patching compiled code. | 4 // Class for patching compiled code. |
| 5 | 5 |
| 6 #ifndef VM_CODE_PATCHER_H_ | 6 #ifndef VM_CODE_PATCHER_H_ |
| 7 #define VM_CODE_PATCHER_H_ | 7 #define VM_CODE_PATCHER_H_ |
| 8 | 8 |
| 9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
| 10 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 // Forward declaration. | 13 // Forward declaration. |
| 14 class Array; | 14 class Array; |
| 15 class Code; | 15 class Code; |
| 16 class ExternalLabel; | 16 class ExternalLabel; |
| 17 class Function; | 17 class Function; |
| 18 class ICData; |
| 18 class RawArray; | 19 class RawArray; |
| 19 class RawICData; | 20 class RawICData; |
| 20 class String; | 21 class String; |
| 21 | 22 |
| 22 class CodePatcher : public AllStatic { | 23 class CodePatcher : public AllStatic { |
| 23 public: | 24 public: |
| 24 // Dart static calls have a distinct, machine-dependent code pattern. | 25 // Dart static calls have a distinct, machine-dependent code pattern. |
| 25 | 26 |
| 26 // Patch static call to the new target. | 27 // Patch static call to the new target. |
| 27 static void PatchStaticCallAt(uword addr, uword new_target_address); | 28 static void PatchStaticCallAt(uword addr, uword new_target_address); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 38 // Returns true if the code can be patched with a jump at beginnning (checks | 39 // Returns true if the code can be patched with a jump at beginnning (checks |
| 39 // that there are no conflicts with object pointers). Used in ASSERTs. | 40 // that there are no conflicts with object pointers). Used in ASSERTs. |
| 40 static bool CodeIsPatchable(const Code& code); | 41 static bool CodeIsPatchable(const Code& code); |
| 41 | 42 |
| 42 // Returns true if the code before return_address is a static | 43 // Returns true if the code before return_address is a static |
| 43 // or dynamic Dart call. | 44 // or dynamic Dart call. |
| 44 static bool IsDartCall(uword return_address); | 45 static bool IsDartCall(uword return_address); |
| 45 | 46 |
| 46 static uword GetStaticCallTargetAt(uword return_address); | 47 static uword GetStaticCallTargetAt(uword return_address); |
| 47 | 48 |
| 48 // Get instance call information. | 49 // Get instance call information. Returns the call target and sets each |
| 49 static void GetInstanceCallAt(uword return_address, | 50 // of the output parameters ic_data and arguments_descriptor if they are |
| 50 String* function_name, | 51 // non-NULL. |
| 51 int* num_arguments, | 52 static uword GetInstanceCallAt(uword return_address, |
| 52 int* num_named_arguments, | 53 ICData* ic_data, |
| 53 uword* target); | 54 Array* arguments_descriptor); |
| 54 | |
| 55 static RawICData* GetInstanceCallIcDataAt(uword return_address); | |
| 56 | 55 |
| 57 static intptr_t InstanceCallSizeInBytes(); | 56 static intptr_t InstanceCallSizeInBytes(); |
| 58 | 57 |
| 59 static void InsertCallAt(uword start, uword target); | 58 static void InsertCallAt(uword start, uword target); |
| 60 }; | 59 }; |
| 61 | 60 |
| 62 } // namespace dart | 61 } // namespace dart |
| 63 | 62 |
| 64 #endif // VM_CODE_PATCHER_H_ | 63 #endif // VM_CODE_PATCHER_H_ |
| OLD | NEW |