OLD | NEW |
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_MIPS | 9 #if V8_TARGET_ARCH_MIPS |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 // Mips return sequence: | 23 // Mips return sequence: |
24 // mov sp, fp | 24 // mov sp, fp |
25 // lw fp, sp(0) | 25 // lw fp, sp(0) |
26 // lw ra, sp(4) | 26 // lw ra, sp(4) |
27 // addiu sp, sp, 8 | 27 // addiu sp, sp, 8 |
28 // addiu sp, sp, N | 28 // addiu sp, sp, N |
29 // jr ra | 29 // jr ra |
30 // nop (in branch delay slot) | 30 // nop (in branch delay slot) |
31 | 31 |
32 // Make sure this constant matches the number if instrucntions we emit. | 32 // Make sure this constant matches the number if instrucntions we emit. |
33 ASSERT(Assembler::kJSReturnSequenceInstructions == 7); | 33 DCHECK(Assembler::kJSReturnSequenceInstructions == 7); |
34 CodePatcher patcher(rinfo()->pc(), Assembler::kJSReturnSequenceInstructions); | 34 CodePatcher patcher(rinfo()->pc(), Assembler::kJSReturnSequenceInstructions); |
35 // li and Call pseudo-instructions emit two instructions each. | 35 // li and Call pseudo-instructions emit two instructions each. |
36 patcher.masm()->li(v8::internal::t9, Operand(reinterpret_cast<int32_t>( | 36 patcher.masm()->li(v8::internal::t9, Operand(reinterpret_cast<int32_t>( |
37 debug_info_->GetIsolate()->builtins()->Return_DebugBreak()->entry()))); | 37 debug_info_->GetIsolate()->builtins()->Return_DebugBreak()->entry()))); |
38 patcher.masm()->Call(v8::internal::t9); | 38 patcher.masm()->Call(v8::internal::t9); |
39 patcher.masm()->nop(); | 39 patcher.masm()->nop(); |
40 patcher.masm()->nop(); | 40 patcher.masm()->nop(); |
41 patcher.masm()->nop(); | 41 patcher.masm()->nop(); |
42 | 42 |
43 // TODO(mips): Open issue about using breakpoint instruction instead of nops. | 43 // TODO(mips): Open issue about using breakpoint instruction instead of nops. |
44 // patcher.masm()->bkpt(0); | 44 // patcher.masm()->bkpt(0); |
45 } | 45 } |
46 | 46 |
47 | 47 |
48 // Restore the JS frame exit code. | 48 // Restore the JS frame exit code. |
49 void BreakLocationIterator::ClearDebugBreakAtReturn() { | 49 void BreakLocationIterator::ClearDebugBreakAtReturn() { |
50 rinfo()->PatchCode(original_rinfo()->pc(), | 50 rinfo()->PatchCode(original_rinfo()->pc(), |
51 Assembler::kJSReturnSequenceInstructions); | 51 Assembler::kJSReturnSequenceInstructions); |
52 } | 52 } |
53 | 53 |
54 | 54 |
55 // A debug break in the exit code is identified by the JS frame exit code | 55 // A debug break in the exit code is identified by the JS frame exit code |
56 // having been patched with li/call psuedo-instrunction (liu/ori/jalr). | 56 // having been patched with li/call psuedo-instrunction (liu/ori/jalr). |
57 bool Debug::IsDebugBreakAtReturn(RelocInfo* rinfo) { | 57 bool Debug::IsDebugBreakAtReturn(RelocInfo* rinfo) { |
58 ASSERT(RelocInfo::IsJSReturn(rinfo->rmode())); | 58 DCHECK(RelocInfo::IsJSReturn(rinfo->rmode())); |
59 return rinfo->IsPatchedReturnSequence(); | 59 return rinfo->IsPatchedReturnSequence(); |
60 } | 60 } |
61 | 61 |
62 | 62 |
63 bool BreakLocationIterator::IsDebugBreakAtSlot() { | 63 bool BreakLocationIterator::IsDebugBreakAtSlot() { |
64 ASSERT(IsDebugBreakSlot()); | 64 DCHECK(IsDebugBreakSlot()); |
65 // Check whether the debug break slot instructions have been patched. | 65 // Check whether the debug break slot instructions have been patched. |
66 return rinfo()->IsPatchedDebugBreakSlotSequence(); | 66 return rinfo()->IsPatchedDebugBreakSlotSequence(); |
67 } | 67 } |
68 | 68 |
69 | 69 |
70 void BreakLocationIterator::SetDebugBreakAtSlot() { | 70 void BreakLocationIterator::SetDebugBreakAtSlot() { |
71 ASSERT(IsDebugBreakSlot()); | 71 DCHECK(IsDebugBreakSlot()); |
72 // Patch the code changing the debug break slot code from: | 72 // Patch the code changing the debug break slot code from: |
73 // nop(DEBUG_BREAK_NOP) - nop(1) is sll(zero_reg, zero_reg, 1) | 73 // nop(DEBUG_BREAK_NOP) - nop(1) is sll(zero_reg, zero_reg, 1) |
74 // nop(DEBUG_BREAK_NOP) | 74 // nop(DEBUG_BREAK_NOP) |
75 // nop(DEBUG_BREAK_NOP) | 75 // nop(DEBUG_BREAK_NOP) |
76 // nop(DEBUG_BREAK_NOP) | 76 // nop(DEBUG_BREAK_NOP) |
77 // to a call to the debug break slot code. | 77 // to a call to the debug break slot code. |
78 // li t9, address (lui t9 / ori t9 instruction pair) | 78 // li t9, address (lui t9 / ori t9 instruction pair) |
79 // call t9 (jalr t9 / nop instruction pair) | 79 // call t9 (jalr t9 / nop instruction pair) |
80 CodePatcher patcher(rinfo()->pc(), Assembler::kDebugBreakSlotInstructions); | 80 CodePatcher patcher(rinfo()->pc(), Assembler::kDebugBreakSlotInstructions); |
81 patcher.masm()->li(v8::internal::t9, Operand(reinterpret_cast<int32_t>( | 81 patcher.masm()->li(v8::internal::t9, Operand(reinterpret_cast<int32_t>( |
82 debug_info_->GetIsolate()->builtins()->Slot_DebugBreak()->entry()))); | 82 debug_info_->GetIsolate()->builtins()->Slot_DebugBreak()->entry()))); |
83 patcher.masm()->Call(v8::internal::t9); | 83 patcher.masm()->Call(v8::internal::t9); |
84 } | 84 } |
85 | 85 |
86 | 86 |
87 void BreakLocationIterator::ClearDebugBreakAtSlot() { | 87 void BreakLocationIterator::ClearDebugBreakAtSlot() { |
88 ASSERT(IsDebugBreakSlot()); | 88 DCHECK(IsDebugBreakSlot()); |
89 rinfo()->PatchCode(original_rinfo()->pc(), | 89 rinfo()->PatchCode(original_rinfo()->pc(), |
90 Assembler::kDebugBreakSlotInstructions); | 90 Assembler::kDebugBreakSlotInstructions); |
91 } | 91 } |
92 | 92 |
93 | 93 |
94 #define __ ACCESS_MASM(masm) | 94 #define __ ACCESS_MASM(masm) |
95 | 95 |
96 | 96 |
97 | 97 |
98 static void Generate_DebugBreakCallHelper(MacroAssembler* masm, | 98 static void Generate_DebugBreakCallHelper(MacroAssembler* masm, |
99 RegList object_regs, | 99 RegList object_regs, |
100 RegList non_object_regs) { | 100 RegList non_object_regs) { |
101 { | 101 { |
102 FrameScope scope(masm, StackFrame::INTERNAL); | 102 FrameScope scope(masm, StackFrame::INTERNAL); |
103 | 103 |
104 // Load padding words on stack. | 104 // Load padding words on stack. |
105 __ li(at, Operand(Smi::FromInt(LiveEdit::kFramePaddingValue))); | 105 __ li(at, Operand(Smi::FromInt(LiveEdit::kFramePaddingValue))); |
106 __ Subu(sp, sp, | 106 __ Subu(sp, sp, |
107 Operand(kPointerSize * LiveEdit::kFramePaddingInitialSize)); | 107 Operand(kPointerSize * LiveEdit::kFramePaddingInitialSize)); |
108 for (int i = LiveEdit::kFramePaddingInitialSize - 1; i >= 0; i--) { | 108 for (int i = LiveEdit::kFramePaddingInitialSize - 1; i >= 0; i--) { |
109 __ sw(at, MemOperand(sp, kPointerSize * i)); | 109 __ sw(at, MemOperand(sp, kPointerSize * i)); |
110 } | 110 } |
111 __ li(at, Operand(Smi::FromInt(LiveEdit::kFramePaddingInitialSize))); | 111 __ li(at, Operand(Smi::FromInt(LiveEdit::kFramePaddingInitialSize))); |
112 __ push(at); | 112 __ push(at); |
113 | 113 |
114 // Store the registers containing live values on the expression stack to | 114 // Store the registers containing live values on the expression stack to |
115 // make sure that these are correctly updated during GC. Non object values | 115 // make sure that these are correctly updated during GC. Non object values |
116 // are stored as a smi causing it to be untouched by GC. | 116 // are stored as a smi causing it to be untouched by GC. |
117 ASSERT((object_regs & ~kJSCallerSaved) == 0); | 117 DCHECK((object_regs & ~kJSCallerSaved) == 0); |
118 ASSERT((non_object_regs & ~kJSCallerSaved) == 0); | 118 DCHECK((non_object_regs & ~kJSCallerSaved) == 0); |
119 ASSERT((object_regs & non_object_regs) == 0); | 119 DCHECK((object_regs & non_object_regs) == 0); |
120 if ((object_regs | non_object_regs) != 0) { | 120 if ((object_regs | non_object_regs) != 0) { |
121 for (int i = 0; i < kNumJSCallerSaved; i++) { | 121 for (int i = 0; i < kNumJSCallerSaved; i++) { |
122 int r = JSCallerSavedCode(i); | 122 int r = JSCallerSavedCode(i); |
123 Register reg = { r }; | 123 Register reg = { r }; |
124 if ((non_object_regs & (1 << r)) != 0) { | 124 if ((non_object_regs & (1 << r)) != 0) { |
125 if (FLAG_debug_code) { | 125 if (FLAG_debug_code) { |
126 __ And(at, reg, 0xc0000000); | 126 __ And(at, reg, 0xc0000000); |
127 __ Assert(eq, kUnableToEncodeValueAsSmi, at, Operand(zero_reg)); | 127 __ Assert(eq, kUnableToEncodeValueAsSmi, at, Operand(zero_reg)); |
128 } | 128 } |
129 __ sll(reg, reg, kSmiTagSize); | 129 __ sll(reg, reg, kSmiTagSize); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 void DebugCodegen::GenerateSlot(MacroAssembler* masm) { | 269 void DebugCodegen::GenerateSlot(MacroAssembler* masm) { |
270 // Generate enough nop's to make space for a call instruction. Avoid emitting | 270 // Generate enough nop's to make space for a call instruction. Avoid emitting |
271 // the trampoline pool in the debug break slot code. | 271 // the trampoline pool in the debug break slot code. |
272 Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm); | 272 Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm); |
273 Label check_codesize; | 273 Label check_codesize; |
274 __ bind(&check_codesize); | 274 __ bind(&check_codesize); |
275 __ RecordDebugBreakSlot(); | 275 __ RecordDebugBreakSlot(); |
276 for (int i = 0; i < Assembler::kDebugBreakSlotInstructions; i++) { | 276 for (int i = 0; i < Assembler::kDebugBreakSlotInstructions; i++) { |
277 __ nop(MacroAssembler::DEBUG_BREAK_NOP); | 277 __ nop(MacroAssembler::DEBUG_BREAK_NOP); |
278 } | 278 } |
279 ASSERT_EQ(Assembler::kDebugBreakSlotInstructions, | 279 DCHECK_EQ(Assembler::kDebugBreakSlotInstructions, |
280 masm->InstructionsGeneratedSince(&check_codesize)); | 280 masm->InstructionsGeneratedSince(&check_codesize)); |
281 } | 281 } |
282 | 282 |
283 | 283 |
284 void DebugCodegen::GenerateSlotDebugBreak(MacroAssembler* masm) { | 284 void DebugCodegen::GenerateSlotDebugBreak(MacroAssembler* masm) { |
285 // In the places where a debug break slot is inserted no registers can contain | 285 // In the places where a debug break slot is inserted no registers can contain |
286 // object pointers. | 286 // object pointers. |
287 Generate_DebugBreakCallHelper(masm, 0, 0); | 287 Generate_DebugBreakCallHelper(masm, 0, 0); |
288 } | 288 } |
289 | 289 |
(...skipping 28 matching lines...) Expand all Loading... |
318 } | 318 } |
319 | 319 |
320 | 320 |
321 const bool LiveEdit::kFrameDropperSupported = true; | 321 const bool LiveEdit::kFrameDropperSupported = true; |
322 | 322 |
323 #undef __ | 323 #undef __ |
324 | 324 |
325 } } // namespace v8::internal | 325 } } // namespace v8::internal |
326 | 326 |
327 #endif // V8_TARGET_ARCH_MIPS | 327 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |