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 | 4 |
5 #include "vm/code_patcher.h" | 5 #include "vm/code_patcher.h" |
| 6 #include "vm/cpu.h" |
6 #include "vm/instructions.h" | 7 #include "vm/instructions.h" |
7 #include "vm/object.h" | 8 #include "vm/object.h" |
8 | 9 |
9 namespace dart { | 10 namespace dart { |
10 | 11 |
11 static void SwapCode(intptr_t num_bytes, char* a, char* b) { | 12 static void SwapCode(intptr_t num_bytes, char* code, char* buffer) { |
| 13 uword code_address = reinterpret_cast<uword>(code); |
12 for (intptr_t i = 0; i < num_bytes; i++) { | 14 for (intptr_t i = 0; i < num_bytes; i++) { |
13 char tmp = *a; | 15 char tmp = *code; |
14 *a = *b; | 16 *code = *buffer; |
15 *b = tmp; | 17 *buffer = tmp; |
16 a++; | 18 code++; |
17 b++; | 19 buffer++; |
18 } | 20 } |
| 21 CPU::FlushICache(code_address, num_bytes); |
| 22 // The buffer is not executed. No need to flush. |
19 } | 23 } |
20 | 24 |
21 | 25 |
22 // The patch code buffer contains the jmp code which will be inserted at | 26 // The patch code buffer contains the jmp code which will be inserted at |
23 // entry point. | 27 // entry point. |
24 void CodePatcher::PatchEntry(const Code& code) { | 28 void CodePatcher::PatchEntry(const Code& code) { |
25 const uword patch_addr = code.GetPcForDeoptId(Isolate::kNoDeoptId, | 29 const uword patch_addr = code.GetPcForDeoptId(Isolate::kNoDeoptId, |
26 PcDescriptors::kEntryPatch); | 30 PcDescriptors::kEntryPatch); |
27 JumpPattern jmp_entry(patch_addr); | 31 JumpPattern jmp_entry(patch_addr); |
28 ASSERT(!jmp_entry.IsValid()); | 32 ASSERT(!jmp_entry.IsValid()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 const uword obj_start = code.GetPointerOffsetAt(i) + code.EntryPoint(); | 80 const uword obj_start = code.GetPointerOffsetAt(i) + code.EntryPoint(); |
77 const uword obj_end = obj_start + kWordSize; | 81 const uword obj_end = obj_start + kWordSize; |
78 if ((obj_start < limit) && (obj_end > patch_addr)) { | 82 if ((obj_start < limit) && (obj_end > patch_addr)) { |
79 return false; | 83 return false; |
80 } | 84 } |
81 } | 85 } |
82 return true; | 86 return true; |
83 } | 87 } |
84 | 88 |
85 } // namespace dart | 89 } // namespace dart |
OLD | NEW |