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

Side by Side Diff: src/mips64/debug-mips64.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/mips64/assembler-mips64-inl.h ('k') | src/objects.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 5
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #if V8_TARGET_ARCH_MIPS64 9 #if V8_TARGET_ARCH_MIPS64
10 10
11 #include "src/codegen.h" 11 #include "src/codegen.h"
12 #include "src/debug.h" 12 #include "src/debug.h"
13 13
14 namespace v8 { 14 namespace v8 {
15 namespace internal { 15 namespace internal {
16 16
17 bool BreakLocationIterator::IsDebugBreakAtReturn() { 17 void BreakLocation::SetDebugBreakAtReturn() {
18 return Debug::IsDebugBreakAtReturn(rinfo());
19 }
20
21
22 void BreakLocationIterator::SetDebugBreakAtReturn() {
23 // Mips return sequence: 18 // Mips return sequence:
24 // mov sp, fp 19 // mov sp, fp
25 // lw fp, sp(0) 20 // lw fp, sp(0)
26 // lw ra, sp(4) 21 // lw ra, sp(4)
27 // addiu sp, sp, 8 22 // addiu sp, sp, 8
28 // addiu sp, sp, N 23 // addiu sp, sp, N
29 // jr ra 24 // jr ra
30 // nop (in branch delay slot) 25 // nop (in branch delay slot)
31 26
32 // Make sure this constant matches the number if instructions we emit. 27 // Make sure this constant matches the number if instructions we emit.
33 DCHECK(Assembler::kJSReturnSequenceInstructions == 7); 28 DCHECK(Assembler::kJSReturnSequenceInstructions == 7);
34 CodePatcher patcher(rinfo()->pc(), Assembler::kJSReturnSequenceInstructions); 29 CodePatcher patcher(pc(), Assembler::kJSReturnSequenceInstructions);
35 // li and Call pseudo-instructions emit 6 + 2 instructions. 30 // li and Call pseudo-instructions emit 6 + 2 instructions.
36 patcher.masm()->li(v8::internal::t9, Operand(reinterpret_cast<int64_t>( 31 patcher.masm()->li(v8::internal::t9, Operand(reinterpret_cast<int64_t>(
37 debug_info_->GetIsolate()->builtins()->Return_DebugBreak()->entry())), 32 debug_info_->GetIsolate()->builtins()->Return_DebugBreak()->entry())),
38 ADDRESS_LOAD); 33 ADDRESS_LOAD);
39 patcher.masm()->Call(v8::internal::t9); 34 patcher.masm()->Call(v8::internal::t9);
40 // Place nop to match return sequence size. 35 // Place nop to match return sequence size.
41 patcher.masm()->nop(); 36 patcher.masm()->nop();
42 // TODO(mips): Open issue about using breakpoint instruction instead of nops. 37 // TODO(mips): Open issue about using breakpoint instruction instead of nops.
43 // patcher.masm()->bkpt(0); 38 // patcher.masm()->bkpt(0);
44 } 39 }
45 40
46 41
47 // Restore the JS frame exit code. 42 void BreakLocation::SetDebugBreakAtSlot() {
48 void BreakLocationIterator::ClearDebugBreakAtReturn() {
49 rinfo()->PatchCode(original_rinfo()->pc(),
50 Assembler::kJSReturnSequenceInstructions);
51 }
52
53
54 // A debug break in the exit code is identified by the JS frame exit code
55 // having been patched with li/call psuedo-instrunction (liu/ori/jalr).
56 bool Debug::IsDebugBreakAtReturn(RelocInfo* rinfo) {
57 DCHECK(RelocInfo::IsJSReturn(rinfo->rmode()));
58 return rinfo->IsPatchedReturnSequence();
59 }
60
61
62 bool BreakLocationIterator::IsDebugBreakAtSlot() {
63 DCHECK(IsDebugBreakSlot());
64 // Check whether the debug break slot instructions have been patched.
65 return rinfo()->IsPatchedDebugBreakSlotSequence();
66 }
67
68
69 void BreakLocationIterator::SetDebugBreakAtSlot() {
70 DCHECK(IsDebugBreakSlot()); 43 DCHECK(IsDebugBreakSlot());
71 // Patch the code changing the debug break slot code from: 44 // Patch the code changing the debug break slot code from:
72 // nop(DEBUG_BREAK_NOP) - nop(1) is sll(zero_reg, zero_reg, 1) 45 // nop(DEBUG_BREAK_NOP) - nop(1) is sll(zero_reg, zero_reg, 1)
73 // nop(DEBUG_BREAK_NOP) 46 // nop(DEBUG_BREAK_NOP)
74 // nop(DEBUG_BREAK_NOP) 47 // nop(DEBUG_BREAK_NOP)
75 // nop(DEBUG_BREAK_NOP) 48 // nop(DEBUG_BREAK_NOP)
76 // nop(DEBUG_BREAK_NOP) 49 // nop(DEBUG_BREAK_NOP)
77 // nop(DEBUG_BREAK_NOP) 50 // nop(DEBUG_BREAK_NOP)
78 // to a call to the debug break slot code. 51 // to a call to the debug break slot code.
79 // li t9, address (4-instruction sequence on mips64) 52 // li t9, address (4-instruction sequence on mips64)
80 // call t9 (jalr t9 / nop instruction pair) 53 // call t9 (jalr t9 / nop instruction pair)
81 CodePatcher patcher(rinfo()->pc(), Assembler::kDebugBreakSlotInstructions); 54 CodePatcher patcher(pc(), Assembler::kDebugBreakSlotInstructions);
82 patcher.masm()->li(v8::internal::t9, 55 patcher.masm()->li(v8::internal::t9,
83 Operand(reinterpret_cast<int64_t>( 56 Operand(reinterpret_cast<int64_t>(
84 debug_info_->GetIsolate()->builtins()->Slot_DebugBreak()->entry())), 57 debug_info_->GetIsolate()->builtins()->Slot_DebugBreak()->entry())),
85 ADDRESS_LOAD); 58 ADDRESS_LOAD);
86 patcher.masm()->Call(v8::internal::t9); 59 patcher.masm()->Call(v8::internal::t9);
87 } 60 }
88 61
89 62
90 void BreakLocationIterator::ClearDebugBreakAtSlot() {
91 DCHECK(IsDebugBreakSlot());
92 rinfo()->PatchCode(original_rinfo()->pc(),
93 Assembler::kDebugBreakSlotInstructions);
94 }
95
96
97 #define __ ACCESS_MASM(masm) 63 #define __ ACCESS_MASM(masm)
98 64
99 65
100 66
101 static void Generate_DebugBreakCallHelper(MacroAssembler* masm, 67 static void Generate_DebugBreakCallHelper(MacroAssembler* masm,
102 RegList object_regs, 68 RegList object_regs,
103 RegList non_object_regs) { 69 RegList non_object_regs) {
104 { 70 {
105 FrameScope scope(masm, StackFrame::INTERNAL); 71 FrameScope scope(masm, StackFrame::INTERNAL);
106 72
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 } 291 }
326 292
327 293
328 const bool LiveEdit::kFrameDropperSupported = true; 294 const bool LiveEdit::kFrameDropperSupported = true;
329 295
330 #undef __ 296 #undef __
331 297
332 } } // namespace v8::internal 298 } } // namespace v8::internal
333 299
334 #endif // V8_TARGET_ARCH_MIPS64 300 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips64/assembler-mips64-inl.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698