| 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 RUNTIME_VM_CODE_PATCHER_H_ | 6 #ifndef RUNTIME_VM_CODE_PATCHER_H_ |
| 7 #define RUNTIME_VM_CODE_PATCHER_H_ | 7 #define RUNTIME_VM_CODE_PATCHER_H_ |
| 8 | 8 |
| 9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
| 10 #include "vm/native_entry.h" | 10 #include "vm/native_entry.h" |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 // Forward declaration. | 14 // Forward declaration. |
| 15 class Array; | 15 class Array; |
| 16 class Code; | 16 class Code; |
| 17 class ExternalLabel; | 17 class ExternalLabel; |
| 18 class Function; | 18 class Function; |
| 19 class ICData; | 19 class ICData; |
| 20 class RawArray; | 20 class RawArray; |
| 21 class RawCode; | 21 class RawCode; |
| 22 class RawFunction; | 22 class RawFunction; |
| 23 class RawICData; | 23 class RawICData; |
| 24 class RawObject; | 24 class RawObject; |
| 25 class String; | 25 class String; |
| 26 | 26 |
| 27 | |
| 28 // Stack-allocated class to create a scope where the specified region | 27 // Stack-allocated class to create a scope where the specified region |
| 29 // [address, address + size] has write access enabled. This is used | 28 // [address, address + size] has write access enabled. This is used |
| 30 // when patching generated code. Access is reset to read-execute in | 29 // when patching generated code. Access is reset to read-execute in |
| 31 // the destructor of this scope. | 30 // the destructor of this scope. |
| 32 class WritableInstructionsScope : public ValueObject { | 31 class WritableInstructionsScope : public ValueObject { |
| 33 public: | 32 public: |
| 34 WritableInstructionsScope(uword address, intptr_t size); | 33 WritableInstructionsScope(uword address, intptr_t size); |
| 35 ~WritableInstructionsScope(); | 34 ~WritableInstructionsScope(); |
| 36 | 35 |
| 37 private: | 36 private: |
| 38 const uword address_; | 37 const uword address_; |
| 39 const intptr_t size_; | 38 const intptr_t size_; |
| 40 }; | 39 }; |
| 41 | 40 |
| 42 | |
| 43 class CodePatcher : public AllStatic { | 41 class CodePatcher : public AllStatic { |
| 44 public: | 42 public: |
| 45 // Dart static calls have a distinct, machine-dependent code pattern. | 43 // Dart static calls have a distinct, machine-dependent code pattern. |
| 46 | 44 |
| 47 // Patch static call before return_address in given code to the new target. | 45 // Patch static call before return_address in given code to the new target. |
| 48 static void PatchStaticCallAt(uword return_address, | 46 static void PatchStaticCallAt(uword return_address, |
| 49 const Code& code, | 47 const Code& code, |
| 50 const Code& new_target); | 48 const Code& new_target); |
| 51 | 49 |
| 52 // Return the target address of the static call before return_address | 50 // Return the target address of the static call before return_address |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 87 |
| 90 static void PatchNativeCallAt(uword return_address, | 88 static void PatchNativeCallAt(uword return_address, |
| 91 const Code& code, | 89 const Code& code, |
| 92 NativeFunction target, | 90 NativeFunction target, |
| 93 const Code& trampoline); | 91 const Code& trampoline); |
| 94 }; | 92 }; |
| 95 | 93 |
| 96 } // namespace dart | 94 } // namespace dart |
| 97 | 95 |
| 98 #endif // RUNTIME_VM_CODE_PATCHER_H_ | 96 #endif // RUNTIME_VM_CODE_PATCHER_H_ |
| OLD | NEW |