OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #if V8_TARGET_ARCH_PPC | 5 #include "src/v8.h" |
| 6 |
| 7 #if V8_TARGET_ARCH_S390 |
6 | 8 |
7 #include "src/codegen.h" | 9 #include "src/codegen.h" |
8 #include "src/debug/debug.h" | 10 #include "src/debug/debug.h" |
9 | 11 |
10 namespace v8 { | 12 namespace v8 { |
11 namespace internal { | 13 namespace internal { |
12 | 14 |
13 #define __ ACCESS_MASM(masm) | 15 #define __ ACCESS_MASM(masm) |
14 | 16 |
15 | |
16 void EmitDebugBreakSlot(MacroAssembler* masm) { | 17 void EmitDebugBreakSlot(MacroAssembler* masm) { |
17 Label check_size; | 18 Label check_size; |
18 __ bind(&check_size); | 19 __ bind(&check_size); |
19 for (int i = 0; i < Assembler::kDebugBreakSlotInstructions; i++) { | 20 // oill r3, 0 |
20 __ nop(MacroAssembler::DEBUG_BREAK_NOP); | 21 // oill r3, 0 |
| 22 __ nop(Assembler::DEBUG_BREAK_NOP); |
| 23 __ nop(Assembler::DEBUG_BREAK_NOP); |
| 24 |
| 25 // lr r0, r0 64-bit only |
| 26 // lr r0, r0 64-bit only |
| 27 // lr r0, r0 64-bit only |
| 28 for (int i = 8; i < Assembler::kDebugBreakSlotLength; i += 2) { |
| 29 __ nop(); |
21 } | 30 } |
22 DCHECK_EQ(Assembler::kDebugBreakSlotInstructions, | 31 DCHECK_EQ(Assembler::kDebugBreakSlotLength, |
23 masm->InstructionsGeneratedSince(&check_size)); | 32 masm->SizeOfCodeGeneratedSince(&check_size)); |
24 } | 33 } |
25 | 34 |
26 | |
27 void DebugCodegen::GenerateSlot(MacroAssembler* masm, RelocInfo::Mode mode) { | 35 void DebugCodegen::GenerateSlot(MacroAssembler* masm, RelocInfo::Mode mode) { |
28 // Generate enough nop's to make space for a call instruction. Avoid emitting | 36 // Generate enough nop's to make space for a call instruction. |
29 // the trampoline pool in the debug break slot code. | |
30 Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm); | |
31 masm->RecordDebugBreakSlot(mode); | 37 masm->RecordDebugBreakSlot(mode); |
32 EmitDebugBreakSlot(masm); | 38 EmitDebugBreakSlot(masm); |
33 } | 39 } |
34 | 40 |
35 | |
36 void DebugCodegen::ClearDebugBreakSlot(Isolate* isolate, Address pc) { | 41 void DebugCodegen::ClearDebugBreakSlot(Isolate* isolate, Address pc) { |
37 CodePatcher patcher(isolate, pc, Assembler::kDebugBreakSlotInstructions); | 42 CodePatcher patcher(isolate, pc, Assembler::kDebugBreakSlotLength); |
38 EmitDebugBreakSlot(patcher.masm()); | 43 EmitDebugBreakSlot(patcher.masm()); |
39 } | 44 } |
40 | 45 |
41 | |
42 void DebugCodegen::PatchDebugBreakSlot(Isolate* isolate, Address pc, | 46 void DebugCodegen::PatchDebugBreakSlot(Isolate* isolate, Address pc, |
43 Handle<Code> code) { | 47 Handle<Code> code) { |
44 DCHECK_EQ(Code::BUILTIN, code->kind()); | 48 DCHECK_EQ(Code::BUILTIN, code->kind()); |
45 CodePatcher patcher(isolate, pc, Assembler::kDebugBreakSlotInstructions); | 49 CodePatcher patcher(isolate, pc, Assembler::kDebugBreakSlotLength); |
46 // Patch the code changing the debug break slot code from | 50 // Patch the code changing the debug break slot code from |
47 // | 51 // |
48 // ori r3, r3, 0 | 52 // oill r3, 0 |
49 // ori r3, r3, 0 | 53 // oill r3, 0 |
50 // ori r3, r3, 0 | 54 // oill r3, 0 64-bit only |
51 // ori r3, r3, 0 | 55 // lr r0, r0 64-bit only |
52 // ori r3, r3, 0 | |
53 // | 56 // |
54 // to a call to the debug break code, using a FIXED_SEQUENCE. | 57 // to a call to the debug break code, using a FIXED_SEQUENCE. |
55 // | 58 // |
56 // mov r0, <address> | 59 // iilf r14, <address> 6-bytes |
57 // mtlr r0 | 60 // basr r14, r14A 2-bytes |
58 // blrl | |
59 // | 61 // |
60 Assembler::BlockTrampolinePoolScope block_trampoline_pool(patcher.masm()); | 62 // The 64bit sequence has an extra iihf. |
61 patcher.masm()->mov(v8::internal::r0, | 63 // |
| 64 // iihf r14, <high 32-bits address> 6-bytes |
| 65 // iilf r14, <lower 32-bits address> 6-bytes |
| 66 // basr r14, r14 2-bytes |
| 67 patcher.masm()->mov(v8::internal::r14, |
62 Operand(reinterpret_cast<intptr_t>(code->entry()))); | 68 Operand(reinterpret_cast<intptr_t>(code->entry()))); |
63 patcher.masm()->mtctr(v8::internal::r0); | 69 patcher.masm()->basr(v8::internal::r14, v8::internal::r14); |
64 patcher.masm()->bctrl(); | |
65 } | 70 } |
66 | 71 |
67 bool DebugCodegen::DebugBreakSlotIsPatched(Address pc) { | 72 bool DebugCodegen::DebugBreakSlotIsPatched(Address pc) { |
68 Instr current_instr = Assembler::instr_at(pc); | 73 Instr current_instr = Assembler::instr_at(pc); |
69 return !Assembler::IsNop(current_instr, Assembler::DEBUG_BREAK_NOP); | 74 return !Assembler::IsNop(current_instr, Assembler::DEBUG_BREAK_NOP); |
70 } | 75 } |
71 | 76 |
72 void DebugCodegen::GenerateDebugBreakStub(MacroAssembler* masm, | 77 void DebugCodegen::GenerateDebugBreakStub(MacroAssembler* masm, |
73 DebugBreakCallHelperMode mode) { | 78 DebugBreakCallHelperMode mode) { |
74 __ RecordComment("Debug break"); | 79 __ RecordComment("Debug break"); |
75 { | 80 { |
76 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 81 FrameScope scope(masm, StackFrame::INTERNAL); |
77 | 82 |
78 // Load padding words on stack. | 83 // Load padding words on stack. |
79 __ LoadSmiLiteral(ip, Smi::FromInt(LiveEdit::kFramePaddingValue)); | 84 __ LoadSmiLiteral(ip, Smi::FromInt(LiveEdit::kFramePaddingValue)); |
80 for (int i = 0; i < LiveEdit::kFramePaddingInitialSize; i++) { | 85 for (int i = 0; i < LiveEdit::kFramePaddingInitialSize; i++) { |
81 __ push(ip); | 86 __ push(ip); |
82 } | 87 } |
83 __ LoadSmiLiteral(ip, Smi::FromInt(LiveEdit::kFramePaddingInitialSize)); | 88 __ LoadSmiLiteral(ip, Smi::FromInt(LiveEdit::kFramePaddingInitialSize)); |
84 __ push(ip); | 89 __ push(ip); |
85 | 90 |
86 if (mode == SAVE_RESULT_REGISTER) __ push(r3); | 91 if (mode == SAVE_RESULT_REGISTER) __ push(r2); |
87 | 92 |
88 __ mov(r3, Operand::Zero()); // no arguments | 93 __ mov(r2, Operand::Zero()); // no arguments |
89 __ mov(r4, | 94 __ mov(r3, |
90 Operand(ExternalReference( | 95 Operand(ExternalReference( |
91 Runtime::FunctionForId(Runtime::kDebugBreak), masm->isolate()))); | 96 Runtime::FunctionForId(Runtime::kDebugBreak), masm->isolate()))); |
92 | 97 |
93 CEntryStub ceb(masm->isolate(), 1); | 98 CEntryStub ceb(masm->isolate(), 1); |
94 __ CallStub(&ceb); | 99 __ CallStub(&ceb); |
95 | 100 |
96 if (FLAG_debug_code) { | 101 if (FLAG_debug_code) { |
97 for (int i = 0; i < kNumJSCallerSaved; i++) { | 102 for (int i = 0; i < kNumJSCallerSaved; i++) { |
98 Register reg = {JSCallerSavedCode(i)}; | 103 Register reg = {JSCallerSavedCode(i)}; |
99 __ mov(reg, Operand(kDebugZapValue)); | 104 __ mov(reg, Operand(kDebugZapValue)); |
100 } | 105 } |
101 } | 106 } |
102 | 107 |
103 if (mode == SAVE_RESULT_REGISTER) __ pop(r3); | 108 if (mode == SAVE_RESULT_REGISTER) __ pop(r2); |
104 | 109 |
105 // Don't bother removing padding bytes pushed on the stack | 110 // Don't bother removing padding bytes pushed on the stack |
106 // as the frame is going to be restored right away. | 111 // as the frame is going to be restored right away. |
107 | 112 |
108 // Leave the internal frame. | 113 // Leave the internal frame. |
109 } | 114 } |
110 | 115 |
111 // Now that the break point has been handled, resume normal execution by | 116 // Now that the break point has been handled, resume normal execution by |
112 // jumping to the target address intended by the caller and that was | 117 // jumping to the target address intended by the caller and that was |
113 // overwritten by the address of DebugBreakXXX. | 118 // overwritten by the address of DebugBreakXXX. |
114 ExternalReference after_break_target = | 119 ExternalReference after_break_target = |
115 ExternalReference::debug_after_break_target_address(masm->isolate()); | 120 ExternalReference::debug_after_break_target_address(masm->isolate()); |
116 __ mov(ip, Operand(after_break_target)); | 121 __ mov(ip, Operand(after_break_target)); |
117 __ LoadP(ip, MemOperand(ip)); | 122 __ LoadP(ip, MemOperand(ip)); |
118 __ JumpToJSEntry(ip); | 123 __ JumpToJSEntry(ip); |
119 } | 124 } |
120 | 125 |
121 | |
122 void DebugCodegen::GenerateFrameDropperLiveEdit(MacroAssembler* masm) { | 126 void DebugCodegen::GenerateFrameDropperLiveEdit(MacroAssembler* masm) { |
123 // Load the function pointer off of our current stack frame. | 127 // Load the function pointer off of our current stack frame. |
124 __ LoadP(r4, MemOperand(fp, StandardFrameConstants::kConstantPoolOffset - | 128 __ LoadP(r3, MemOperand(fp, StandardFrameConstants::kConstantPoolOffset - |
125 kPointerSize)); | 129 kPointerSize)); |
126 | 130 |
127 // Pop return address and frame | 131 // Pop return address and frame |
128 __ LeaveFrame(StackFrame::INTERNAL); | 132 __ LeaveFrame(StackFrame::INTERNAL); |
129 | 133 |
130 ParameterCount dummy(0); | 134 ParameterCount dummy(0); |
131 __ FloodFunctionIfStepping(r4, no_reg, dummy, dummy); | 135 __ FloodFunctionIfStepping(r3, no_reg, dummy, dummy); |
132 | 136 |
133 // Load context from the function. | 137 // Load context from the function. |
134 __ LoadP(cp, FieldMemOperand(r4, JSFunction::kContextOffset)); | 138 __ LoadP(cp, FieldMemOperand(r3, JSFunction::kContextOffset)); |
135 | 139 |
136 // Clear new.target as a safety measure. | 140 // Clear new.target as a safety measure. |
137 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex); | 141 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); |
138 | 142 |
139 // Get function code. | 143 // Get function code. |
140 __ LoadP(ip, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); | 144 __ LoadP(ip, FieldMemOperand(r3, JSFunction::kSharedFunctionInfoOffset)); |
141 __ LoadP(ip, FieldMemOperand(ip, SharedFunctionInfo::kCodeOffset)); | 145 __ LoadP(ip, FieldMemOperand(ip, SharedFunctionInfo::kCodeOffset)); |
142 __ addi(ip, ip, Operand(Code::kHeaderSize - kHeapObjectTag)); | 146 __ AddP(ip, Operand(Code::kHeaderSize - kHeapObjectTag)); |
143 | 147 |
144 // Re-run JSFunction, r4 is function, cp is context. | 148 // Re-run JSFunction, r3 is function, cp is context. |
145 __ Jump(ip); | 149 __ Jump(ip); |
146 } | 150 } |
147 | 151 |
148 | |
149 const bool LiveEdit::kFrameDropperSupported = true; | 152 const bool LiveEdit::kFrameDropperSupported = true; |
150 | 153 |
151 #undef __ | 154 #undef __ |
152 } // namespace internal | 155 } // namespace internal |
153 } // namespace v8 | 156 } // namespace v8 |
154 | 157 |
155 #endif // V8_TARGET_ARCH_PPC | 158 #endif // V8_TARGET_ARCH_S390 |
OLD | NEW |