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

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

Issue 1265923002: Debugger: move implementation to a separate folder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 years, 4 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/x87/assembler-x87-inl.h ('k') | src/x87/macro-assembler-x87.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "src/v8.h"
6
7 #if V8_TARGET_ARCH_X87
8
9 #include "src/codegen.h"
10 #include "src/debug.h"
11
12
13 namespace v8 {
14 namespace internal {
15
16 #define __ ACCESS_MASM(masm)
17
18
19 void EmitDebugBreakSlot(MacroAssembler* masm) {
20 Label check_codesize;
21 __ bind(&check_codesize);
22 __ Nop(Assembler::kDebugBreakSlotLength);
23 DCHECK_EQ(Assembler::kDebugBreakSlotLength,
24 masm->SizeOfCodeGeneratedSince(&check_codesize));
25 }
26
27
28 void DebugCodegen::GenerateSlot(MacroAssembler* masm, RelocInfo::Mode mode,
29 int call_argc) {
30 // Generate enough nop's to make space for a call instruction.
31 masm->RecordDebugBreakSlot(mode, call_argc);
32 EmitDebugBreakSlot(masm);
33 }
34
35
36 void DebugCodegen::ClearDebugBreakSlot(Address pc) {
37 CodePatcher patcher(pc, Assembler::kDebugBreakSlotLength);
38 EmitDebugBreakSlot(patcher.masm());
39 }
40
41
42 void DebugCodegen::PatchDebugBreakSlot(Address pc, Handle<Code> code) {
43 DCHECK_EQ(Code::BUILTIN, code->kind());
44 static const int kSize = Assembler::kDebugBreakSlotLength;
45 CodePatcher patcher(pc, kSize);
46
47 // Add a label for checking the size of the code used for returning.
48 Label check_codesize;
49 patcher.masm()->bind(&check_codesize);
50 patcher.masm()->call(code->entry(), RelocInfo::NONE32);
51 // Check that the size of the code generated is as expected.
52 DCHECK_EQ(kSize, patcher.masm()->SizeOfCodeGeneratedSince(&check_codesize));
53 }
54
55
56 void DebugCodegen::GenerateDebugBreakStub(MacroAssembler* masm,
57 DebugBreakCallHelperMode mode) {
58 __ RecordComment("Debug break");
59
60 // Enter an internal frame.
61 {
62 FrameScope scope(masm, StackFrame::INTERNAL);
63
64 // Load padding words on stack.
65 for (int i = 0; i < LiveEdit::kFramePaddingInitialSize; i++) {
66 __ push(Immediate(Smi::FromInt(LiveEdit::kFramePaddingValue)));
67 }
68 __ push(Immediate(Smi::FromInt(LiveEdit::kFramePaddingInitialSize)));
69
70 if (mode == SAVE_RESULT_REGISTER) __ push(eax);
71
72 __ Move(eax, Immediate(0)); // No arguments.
73 __ mov(ebx,
74 Immediate(ExternalReference(
75 Runtime::FunctionForId(Runtime::kDebugBreak), masm->isolate())));
76
77 CEntryStub ceb(masm->isolate(), 1);
78 __ CallStub(&ceb);
79
80 if (FLAG_debug_code) {
81 for (int i = 0; i < kNumJSCallerSaved; ++i) {
82 Register reg = {JSCallerSavedCode(i)};
83 __ Move(reg, Immediate(kDebugZapValue));
84 }
85 }
86
87 if (mode == SAVE_RESULT_REGISTER) __ pop(eax);
88
89 __ pop(ebx);
90 // We divide stored value by 2 (untagging) and multiply it by word's size.
91 STATIC_ASSERT(kSmiTagSize == 1 && kSmiShiftSize == 0);
92 __ lea(esp, Operand(esp, ebx, times_half_pointer_size, 0));
93
94 // Get rid of the internal frame.
95 }
96
97 // This call did not replace a call , so there will be an unwanted
98 // return address left on the stack. Here we get rid of that.
99 __ add(esp, Immediate(kPointerSize));
100
101 // Now that the break point has been handled, resume normal execution by
102 // jumping to the target address intended by the caller and that was
103 // overwritten by the address of DebugBreakXXX.
104 ExternalReference after_break_target =
105 ExternalReference::debug_after_break_target_address(masm->isolate());
106 __ jmp(Operand::StaticVariable(after_break_target));
107 }
108
109
110 void DebugCodegen::GeneratePlainReturnLiveEdit(MacroAssembler* masm) {
111 masm->ret(0);
112 }
113
114
115 void DebugCodegen::GenerateFrameDropperLiveEdit(MacroAssembler* masm) {
116 ExternalReference restarter_frame_function_slot =
117 ExternalReference::debug_restarter_frame_function_pointer_address(
118 masm->isolate());
119 __ mov(Operand::StaticVariable(restarter_frame_function_slot), Immediate(0));
120
121 // We do not know our frame height, but set esp based on ebp.
122 __ lea(esp, Operand(ebp, -1 * kPointerSize));
123
124 __ pop(edi); // Function.
125 __ pop(ebp);
126
127 // Load context from the function.
128 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
129
130 // Get function code.
131 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
132 __ mov(edx, FieldOperand(edx, SharedFunctionInfo::kCodeOffset));
133 __ lea(edx, FieldOperand(edx, Code::kHeaderSize));
134
135 // Re-run JSFunction, edi is function, esi is context.
136 __ jmp(edx);
137 }
138
139
140 const bool LiveEdit::kFrameDropperSupported = true;
141
142 #undef __
143
144 } // namespace internal
145 } // namespace v8
146
147 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/x87/assembler-x87-inl.h ('k') | src/x87/macro-assembler-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698