Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: runtime/vm/code_patcher.cc

Issue 1376963002: Cleanup: we are not patching entries any longer (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Address review comments Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/code_patcher.h ('k') | runtime/vm/compiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/cpu.h"
7 #include "vm/instructions.h" 7 #include "vm/instructions.h"
8 #include "vm/object.h" 8 #include "vm/object.h"
9 #include "vm/virtual_memory.h" 9 #include "vm/virtual_memory.h"
10 10
(...skipping 16 matching lines...) Expand all
27 27
28 WritableInstructionsScope::~WritableInstructionsScope() { 28 WritableInstructionsScope::~WritableInstructionsScope() {
29 if (FLAG_write_protect_code) { 29 if (FLAG_write_protect_code) {
30 bool status = VirtualMemory::Protect(reinterpret_cast<void*>(address_), 30 bool status = VirtualMemory::Protect(reinterpret_cast<void*>(address_),
31 size_, 31 size_,
32 VirtualMemory::kReadExecute); 32 VirtualMemory::kReadExecute);
33 ASSERT(status); 33 ASSERT(status);
34 } 34 }
35 } 35 }
36 36
37
38 // The patch code buffer contains the jmp code which will be inserted at
39 // entry point.
40 void CodePatcher::PatchEntry(const Code& code, const Code& new_code) {
41 ASSERT(code.instructions() == code.active_instructions());
42 code.set_active_instructions(new_code.instructions());
43 }
44
45
46 // The entry point is a jmp instruction, the patch code buffer contains
47 // original code, the entry point contains the jump instruction.
48 void CodePatcher::RestoreEntry(const Code& code) {
49 if (!IsEntryPatched(code)) return;
50 ASSERT(code.instructions() != code.active_instructions());
51 code.set_active_instructions(code.instructions());
52 }
53
54
55 bool CodePatcher::IsEntryPatched(const Code& code) {
56 return code.instructions() != code.active_instructions();
57 }
58
59 } // namespace dart 37 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_patcher.h ('k') | runtime/vm/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698