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

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

Issue 100103011: Changes to support dprof and Observatory profiler UIs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/code_patcher.h ('k') | runtime/vm/isolate.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 9
10 namespace dart { 10 namespace dart {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 JumpPattern jmp_patch(patch_buffer, code); 58 JumpPattern jmp_patch(patch_buffer, code);
59 ASSERT(!jmp_patch.IsValid()); 59 ASSERT(!jmp_patch.IsValid());
60 SwapCode(jmp_patch.pattern_length_in_bytes(), 60 SwapCode(jmp_patch.pattern_length_in_bytes(),
61 reinterpret_cast<char*>(patch_addr), 61 reinterpret_cast<char*>(patch_addr),
62 reinterpret_cast<char*>(patch_buffer)); 62 reinterpret_cast<char*>(patch_buffer));
63 ASSERT(jmp_patch.IsValid()); 63 ASSERT(jmp_patch.IsValid());
64 jmp_patch.SetTargetAddress(jump_target); 64 jmp_patch.SetTargetAddress(jump_target);
65 } 65 }
66 66
67 67
68 bool CodePatcher::IsEntryPatched(const Code& code) {
69 const uword patch_addr = code.GetPcForDeoptId(Isolate::kNoDeoptId,
70 PcDescriptors::kEntryPatch);
71 if (patch_addr == 0) {
72 return false;
73 }
74 JumpPattern jmp_entry(patch_addr, code);
75 return jmp_entry.IsValid();
76 }
77
78
68 bool CodePatcher::CodeIsPatchable(const Code& code) { 79 bool CodePatcher::CodeIsPatchable(const Code& code) {
69 const uword patch_addr = code.GetPcForDeoptId(Isolate::kNoDeoptId, 80 const uword patch_addr = code.GetPcForDeoptId(Isolate::kNoDeoptId,
70 PcDescriptors::kEntryPatch); 81 PcDescriptors::kEntryPatch);
71 // kEntryPatch may not exist which means the function is not patchable. 82 // kEntryPatch may not exist which means the function is not patchable.
72 if (patch_addr == 0) { 83 if (patch_addr == 0) {
73 return true; 84 return false;
74 } 85 }
75 JumpPattern jmp_entry(patch_addr, code); 86 JumpPattern jmp_entry(patch_addr, code);
76 if (code.Size() < (jmp_entry.pattern_length_in_bytes() * 2)) { 87 if (code.Size() < (jmp_entry.pattern_length_in_bytes() * 2)) {
77 return false; 88 return false;
78 } 89 }
79 const uword limit = patch_addr + jmp_entry.pattern_length_in_bytes(); 90 const uword limit = patch_addr + jmp_entry.pattern_length_in_bytes();
80 // Check no object stored between patch_addr .. limit. 91 // Check no object stored between patch_addr .. limit.
81 for (intptr_t i = 0; i < code.pointer_offsets_length(); i++) { 92 for (intptr_t i = 0; i < code.pointer_offsets_length(); i++) {
82 const uword obj_start = code.GetPointerOffsetAt(i) + code.EntryPoint(); 93 const uword obj_start = code.GetPointerOffsetAt(i) + code.EntryPoint();
83 const uword obj_end = obj_start + kWordSize; 94 const uword obj_end = obj_start + kWordSize;
84 if ((obj_start < limit) && (obj_end > patch_addr)) { 95 if ((obj_start < limit) && (obj_end > patch_addr)) {
85 return false; 96 return false;
86 } 97 }
87 } 98 }
88 return true; 99 return true;
89 } 100 }
90 101
91 } // namespace dart 102 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_patcher.h ('k') | runtime/vm/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698