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 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
6 | 6 |
7 #include "src/debug/debug.h" | 7 #include "src/debug/debug.h" |
8 | 8 |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/debug/liveedit.h" | 10 #include "src/debug/liveedit.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 } | 57 } |
58 | 58 |
59 void DebugCodegen::GenerateDebugBreakStub(MacroAssembler* masm, | 59 void DebugCodegen::GenerateDebugBreakStub(MacroAssembler* masm, |
60 DebugBreakCallHelperMode mode) { | 60 DebugBreakCallHelperMode mode) { |
61 __ RecordComment("Debug break"); | 61 __ RecordComment("Debug break"); |
62 | 62 |
63 // Enter an internal frame. | 63 // Enter an internal frame. |
64 { | 64 { |
65 FrameScope scope(masm, StackFrame::INTERNAL); | 65 FrameScope scope(masm, StackFrame::INTERNAL); |
66 | 66 |
67 // Load padding words on stack. | |
68 for (int i = 0; i < LiveEdit::kFramePaddingInitialSize; i++) { | |
69 __ push(Immediate(Smi::FromInt(LiveEdit::kFramePaddingValue))); | |
70 } | |
71 __ push(Immediate(Smi::FromInt(LiveEdit::kFramePaddingInitialSize))); | |
72 | |
73 // Push arguments for DebugBreak call. | 67 // Push arguments for DebugBreak call. |
74 if (mode == SAVE_RESULT_REGISTER) { | 68 if (mode == SAVE_RESULT_REGISTER) { |
75 // Break on return. | 69 // Break on return. |
76 __ push(eax); | 70 __ push(eax); |
77 } else { | 71 } else { |
78 // Non-return breaks. | 72 // Non-return breaks. |
79 __ Push(masm->isolate()->factory()->the_hole_value()); | 73 __ Push(masm->isolate()->factory()->the_hole_value()); |
80 } | 74 } |
81 __ Move(eax, Immediate(1)); | 75 __ Move(eax, Immediate(1)); |
82 __ mov(ebx, | 76 __ mov(ebx, |
83 Immediate(ExternalReference( | 77 Immediate(ExternalReference( |
84 Runtime::FunctionForId(Runtime::kDebugBreak), masm->isolate()))); | 78 Runtime::FunctionForId(Runtime::kDebugBreak), masm->isolate()))); |
85 | 79 |
86 CEntryStub ceb(masm->isolate(), 1); | 80 CEntryStub ceb(masm->isolate(), 1); |
87 __ CallStub(&ceb); | 81 __ CallStub(&ceb); |
88 | 82 |
89 if (FLAG_debug_code) { | 83 if (FLAG_debug_code) { |
90 for (int i = 0; i < kNumJSCallerSaved; ++i) { | 84 for (int i = 0; i < kNumJSCallerSaved; ++i) { |
91 Register reg = {JSCallerSavedCode(i)}; | 85 Register reg = {JSCallerSavedCode(i)}; |
92 // Do not clobber eax if mode is SAVE_RESULT_REGISTER. It will | 86 // Do not clobber eax if mode is SAVE_RESULT_REGISTER. It will |
93 // contain return value of the function. | 87 // contain return value of the function. |
94 if (!(reg.is(eax) && (mode == SAVE_RESULT_REGISTER))) { | 88 if (!(reg.is(eax) && (mode == SAVE_RESULT_REGISTER))) { |
95 __ Move(reg, Immediate(kDebugZapValue)); | 89 __ Move(reg, Immediate(kDebugZapValue)); |
96 } | 90 } |
97 } | 91 } |
98 } | 92 } |
99 | |
100 __ pop(ebx); | |
101 // We divide stored value by 2 (untagging) and multiply it by word's size. | |
102 STATIC_ASSERT(kSmiTagSize == 1 && kSmiShiftSize == 0); | |
103 __ lea(esp, Operand(esp, ebx, times_half_pointer_size, 0)); | |
104 | |
105 // Get rid of the internal frame. | 93 // Get rid of the internal frame. |
106 } | 94 } |
107 | 95 |
108 // This call did not replace a call , so there will be an unwanted | 96 __ MaybeDropFrames(); |
109 // return address left on the stack. Here we get rid of that. | |
110 __ add(esp, Immediate(kPointerSize)); | |
111 | 97 |
112 // Now that the break point has been handled, resume normal execution by | 98 // Return to caller. |
113 // jumping to the target address intended by the caller and that was | 99 __ ret(0); |
114 // overwritten by the address of DebugBreakXXX. | 100 } |
115 ExternalReference after_break_target = | 101 |
116 ExternalReference::debug_after_break_target_address(masm->isolate()); | 102 void DebugCodegen::GenerateHandleDebuggerStatement(MacroAssembler* masm) { |
117 __ jmp(Operand::StaticVariable(after_break_target)); | 103 { |
| 104 FrameScope scope(masm, StackFrame::INTERNAL); |
| 105 __ CallRuntime(Runtime::kHandleDebuggerStatement, 0); |
| 106 } |
| 107 __ MaybeDropFrames(); |
| 108 |
| 109 // Return to caller. |
| 110 __ ret(0); |
| 111 } |
| 112 |
| 113 void DebugCodegen::GenerateFrameDropperTrampoline(MacroAssembler* masm) { |
| 114 // Frame is being dropped: |
| 115 // - Drop to the target frame specified by ebx. |
| 116 // - Look up current function on the frame. |
| 117 // - Leave the frame. |
| 118 // - Restart the frame by calling the function. |
| 119 __ mov(ebp, ebx); |
| 120 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
| 121 __ leave(); |
| 122 |
| 123 __ mov(ebx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
| 124 __ mov(ebx, |
| 125 FieldOperand(ebx, SharedFunctionInfo::kFormalParameterCountOffset)); |
| 126 |
| 127 ParameterCount dummy(ebx); |
| 128 __ InvokeFunction(edi, dummy, dummy, JUMP_FUNCTION, |
| 129 CheckDebugStepCallWrapper()); |
118 } | 130 } |
119 | 131 |
120 | 132 |
121 void DebugCodegen::GenerateFrameDropperLiveEdit(MacroAssembler* masm) { | |
122 // We do not know our frame height, but set esp based on ebp. | |
123 __ lea(esp, Operand(ebp, FrameDropperFrameConstants::kFunctionOffset)); | |
124 __ pop(edi); // Function. | |
125 __ add(esp, Immediate(-FrameDropperFrameConstants::kCodeOffset)); // INTERNAL | |
126 // frame | |
127 // marker | |
128 // and code | |
129 __ pop(ebp); | |
130 | |
131 ParameterCount dummy(0); | |
132 __ CheckDebugHook(edi, no_reg, dummy, dummy); | |
133 | |
134 // Load context from the function. | |
135 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | |
136 | |
137 // Clear new.target register as a safety measure. | |
138 __ mov(edx, masm->isolate()->factory()->undefined_value()); | |
139 | |
140 // Get function code. | |
141 __ mov(ebx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | |
142 __ mov(ebx, FieldOperand(ebx, SharedFunctionInfo::kCodeOffset)); | |
143 __ lea(ebx, FieldOperand(ebx, Code::kHeaderSize)); | |
144 | |
145 // Re-run JSFunction, edi is function, esi is context. | |
146 __ jmp(ebx); | |
147 } | |
148 | |
149 | |
150 const bool LiveEdit::kFrameDropperSupported = true; | 133 const bool LiveEdit::kFrameDropperSupported = true; |
151 | 134 |
152 #undef __ | 135 #undef __ |
153 | 136 |
154 } // namespace internal | 137 } // namespace internal |
155 } // namespace v8 | 138 } // namespace v8 |
156 | 139 |
157 #endif // V8_TARGET_ARCH_IA32 | 140 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |