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

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

Issue 12806007: Add asserts to catch missing deoptimization info early. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 | « no previous file | runtime/vm/deopt_instructions.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 10 matching lines...) Expand all
21 CPU::FlushICache(code_address, num_bytes); 21 CPU::FlushICache(code_address, num_bytes);
22 // The buffer is not executed. No need to flush. 22 // The buffer is not executed. No need to flush.
23 } 23 }
24 24
25 25
26 // 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
27 // entry point. 27 // entry point.
28 void CodePatcher::PatchEntry(const Code& code) { 28 void CodePatcher::PatchEntry(const Code& code) {
29 const uword patch_addr = code.GetPcForDeoptId(Isolate::kNoDeoptId, 29 const uword patch_addr = code.GetPcForDeoptId(Isolate::kNoDeoptId,
30 PcDescriptors::kEntryPatch); 30 PcDescriptors::kEntryPatch);
31 ASSERT(patch_addr != 0);
31 JumpPattern jmp_entry(patch_addr); 32 JumpPattern jmp_entry(patch_addr);
32 ASSERT(!jmp_entry.IsValid()); 33 ASSERT(!jmp_entry.IsValid());
33 const uword patch_buffer = code.GetPatchCodePc(); 34 const uword patch_buffer = code.GetPatchCodePc();
34 ASSERT(patch_buffer != 0); 35 ASSERT(patch_buffer != 0);
35 JumpPattern jmp_patch(patch_buffer); 36 JumpPattern jmp_patch(patch_buffer);
36 ASSERT(jmp_patch.IsValid()); 37 ASSERT(jmp_patch.IsValid());
37 const uword jump_target = jmp_patch.TargetAddress(); 38 const uword jump_target = jmp_patch.TargetAddress();
38 SwapCode(jmp_patch.pattern_length_in_bytes(), 39 SwapCode(jmp_patch.pattern_length_in_bytes(),
39 reinterpret_cast<char*>(patch_addr), 40 reinterpret_cast<char*>(patch_addr),
40 reinterpret_cast<char*>(patch_buffer)); 41 reinterpret_cast<char*>(patch_buffer));
41 jmp_entry.SetTargetAddress(jump_target); 42 jmp_entry.SetTargetAddress(jump_target);
42 } 43 }
43 44
44 45
45 // The entry point is a jmp instruction, the patch code buffer contains 46 // The entry point is a jmp instruction, the patch code buffer contains
46 // original code, the entry point contains the jump instruction. 47 // original code, the entry point contains the jump instruction.
47 void CodePatcher::RestoreEntry(const Code& code) { 48 void CodePatcher::RestoreEntry(const Code& code) {
48 const uword patch_addr = code.GetPcForDeoptId(Isolate::kNoDeoptId, 49 const uword patch_addr = code.GetPcForDeoptId(Isolate::kNoDeoptId,
49 PcDescriptors::kEntryPatch); 50 PcDescriptors::kEntryPatch);
51 ASSERT(patch_addr != 0);
50 JumpPattern jmp_entry(patch_addr); 52 JumpPattern jmp_entry(patch_addr);
51 ASSERT(jmp_entry.IsValid()); 53 ASSERT(jmp_entry.IsValid());
52 const uword jump_target = jmp_entry.TargetAddress(); 54 const uword jump_target = jmp_entry.TargetAddress();
53 const uword patch_buffer = code.GetPatchCodePc(); 55 const uword patch_buffer = code.GetPatchCodePc();
54 ASSERT(patch_buffer != 0); 56 ASSERT(patch_buffer != 0);
55 // 'patch_buffer' contains original entry code. 57 // 'patch_buffer' contains original entry code.
56 JumpPattern jmp_patch(patch_buffer); 58 JumpPattern jmp_patch(patch_buffer);
57 ASSERT(!jmp_patch.IsValid()); 59 ASSERT(!jmp_patch.IsValid());
58 SwapCode(jmp_patch.pattern_length_in_bytes(), 60 SwapCode(jmp_patch.pattern_length_in_bytes(),
59 reinterpret_cast<char*>(patch_addr), 61 reinterpret_cast<char*>(patch_addr),
(...skipping 20 matching lines...) Expand all
80 const uword obj_start = code.GetPointerOffsetAt(i) + code.EntryPoint(); 82 const uword obj_start = code.GetPointerOffsetAt(i) + code.EntryPoint();
81 const uword obj_end = obj_start + kWordSize; 83 const uword obj_end = obj_start + kWordSize;
82 if ((obj_start < limit) && (obj_end > patch_addr)) { 84 if ((obj_start < limit) && (obj_end > patch_addr)) {
83 return false; 85 return false;
84 } 86 }
85 } 87 }
86 return true; 88 return true;
87 } 89 }
88 90
89 } // namespace dart 91 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/deopt_instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698