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

Side by Side Diff: src/ia32/debug-ia32.cc

Issue 967323002: Refactor BreakLocationIterator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: static_cast instead Created 5 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
« no previous file with comments | « src/ia32/assembler-ia32.cc ('k') | src/mips/assembler-mips.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_IA32 7 #if V8_TARGET_ARCH_IA32
8 8
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/debug.h" 10 #include "src/debug.h"
11 11
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 15
16 bool BreakLocationIterator::IsDebugBreakAtReturn() { 16
17 return Debug::IsDebugBreakAtReturn(rinfo()); 17 // Patch the code at the current PC with a call to the target address.
18 // Additional guard int3 instructions can be added if required.
19 void PatchCodeWithCall(Address pc, Address target, int guard_bytes) {
20 // Call instruction takes up 5 bytes and int3 takes up one byte.
21 static const int kCallCodeSize = 5;
22 int code_size = kCallCodeSize + guard_bytes;
23
24 // Create a code patcher.
25 CodePatcher patcher(pc, code_size);
26
27 // Add a label for checking the size of the code used for returning.
28 #ifdef DEBUG
29 Label check_codesize;
30 patcher.masm()->bind(&check_codesize);
31 #endif
32
33 // Patch the code.
34 patcher.masm()->call(target, RelocInfo::NONE32);
35
36 // Check that the size of the code generated is as expected.
37 DCHECK_EQ(kCallCodeSize,
38 patcher.masm()->SizeOfCodeGeneratedSince(&check_codesize));
39
40 // Add the requested number of int3 instructions after the call.
41 DCHECK_GE(guard_bytes, 0);
42 for (int i = 0; i < guard_bytes; i++) {
43 patcher.masm()->int3();
44 }
45
46 CpuFeatures::FlushICache(pc, code_size);
18 } 47 }
19 48
20 49
21 // Patch the JS frame exit code with a debug break call. See 50 // Patch the JS frame exit code with a debug break call. See
22 // CodeGenerator::VisitReturnStatement and VirtualFrame::Exit in codegen-ia32.cc 51 // CodeGenerator::VisitReturnStatement and VirtualFrame::Exit in codegen-ia32.cc
23 // for the precise return instructions sequence. 52 // for the precise return instructions sequence.
24 void BreakLocationIterator::SetDebugBreakAtReturn() { 53 void BreakLocation::SetDebugBreakAtReturn() {
25 DCHECK(Assembler::kJSReturnSequenceLength >= 54 DCHECK(Assembler::kJSReturnSequenceLength >=
26 Assembler::kCallInstructionLength); 55 Assembler::kCallInstructionLength);
27 rinfo()->PatchCodeWithCall( 56 PatchCodeWithCall(
28 debug_info_->GetIsolate()->builtins()->Return_DebugBreak()->entry(), 57 pc(), debug_info_->GetIsolate()->builtins()->Return_DebugBreak()->entry(),
29 Assembler::kJSReturnSequenceLength - Assembler::kCallInstructionLength); 58 Assembler::kJSReturnSequenceLength - Assembler::kCallInstructionLength);
30 } 59 }
31 60
32 61
33 // Restore the JS frame exit code. 62 void BreakLocation::SetDebugBreakAtSlot() {
34 void BreakLocationIterator::ClearDebugBreakAtReturn() {
35 rinfo()->PatchCode(original_rinfo()->pc(),
36 Assembler::kJSReturnSequenceLength);
37 }
38
39
40 // A debug break in the frame exit code is identified by the JS frame exit code
41 // having been patched with a call instruction.
42 bool Debug::IsDebugBreakAtReturn(RelocInfo* rinfo) {
43 DCHECK(RelocInfo::IsJSReturn(rinfo->rmode()));
44 return rinfo->IsPatchedReturnSequence();
45 }
46
47
48 bool BreakLocationIterator::IsDebugBreakAtSlot() {
49 DCHECK(IsDebugBreakSlot());
50 // Check whether the debug break slot instructions have been patched.
51 return rinfo()->IsPatchedDebugBreakSlotSequence();
52 }
53
54
55 void BreakLocationIterator::SetDebugBreakAtSlot() {
56 DCHECK(IsDebugBreakSlot()); 63 DCHECK(IsDebugBreakSlot());
57 Isolate* isolate = debug_info_->GetIsolate(); 64 Isolate* isolate = debug_info_->GetIsolate();
58 rinfo()->PatchCodeWithCall( 65 PatchCodeWithCall(
59 isolate->builtins()->Slot_DebugBreak()->entry(), 66 pc(), isolate->builtins()->Slot_DebugBreak()->entry(),
60 Assembler::kDebugBreakSlotLength - Assembler::kCallInstructionLength); 67 Assembler::kDebugBreakSlotLength - Assembler::kCallInstructionLength);
61 } 68 }
62 69
63 70
64 void BreakLocationIterator::ClearDebugBreakAtSlot() {
65 DCHECK(IsDebugBreakSlot());
66 rinfo()->PatchCode(original_rinfo()->pc(), Assembler::kDebugBreakSlotLength);
67 }
68
69
70 #define __ ACCESS_MASM(masm) 71 #define __ ACCESS_MASM(masm)
71 72
72 static void Generate_DebugBreakCallHelper(MacroAssembler* masm, 73 static void Generate_DebugBreakCallHelper(MacroAssembler* masm,
73 RegList object_regs, 74 RegList object_regs,
74 RegList non_object_regs, 75 RegList non_object_regs,
75 bool convert_call_to_jmp) { 76 bool convert_call_to_jmp) {
76 // Enter an internal frame. 77 // Enter an internal frame.
77 { 78 {
78 FrameScope scope(masm, StackFrame::INTERNAL); 79 FrameScope scope(masm, StackFrame::INTERNAL);
79 80
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 322 }
322 323
323 324
324 const bool LiveEdit::kFrameDropperSupported = true; 325 const bool LiveEdit::kFrameDropperSupported = true;
325 326
326 #undef __ 327 #undef __
327 328
328 } } // namespace v8::internal 329 } } // namespace v8::internal
329 330
330 #endif // V8_TARGET_ARCH_IA32 331 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/assembler-ia32.cc ('k') | src/mips/assembler-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698