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 #ifndef V8_FRAMES_INL_H_ | 5 #ifndef V8_FRAMES_INL_H_ |
6 #define V8_FRAMES_INL_H_ | 6 #define V8_FRAMES_INL_H_ |
7 | 7 |
8 #include "src/frames.h" | 8 #include "src/frames.h" |
9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
10 #include "src/v8memory.h" | 10 #include "src/v8memory.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 } | 201 } |
202 | 202 |
203 | 203 |
204 inline JavaScriptFrame::JavaScriptFrame(StackFrameIteratorBase* iterator) | 204 inline JavaScriptFrame::JavaScriptFrame(StackFrameIteratorBase* iterator) |
205 : StandardFrame(iterator) { | 205 : StandardFrame(iterator) { |
206 } | 206 } |
207 | 207 |
208 | 208 |
209 Address JavaScriptFrame::GetParameterSlot(int index) const { | 209 Address JavaScriptFrame::GetParameterSlot(int index) const { |
210 int param_count = ComputeParametersCount(); | 210 int param_count = ComputeParametersCount(); |
211 ASSERT(-1 <= index && index < param_count); | 211 DCHECK(-1 <= index && index < param_count); |
212 int parameter_offset = (param_count - index - 1) * kPointerSize; | 212 int parameter_offset = (param_count - index - 1) * kPointerSize; |
213 return caller_sp() + parameter_offset; | 213 return caller_sp() + parameter_offset; |
214 } | 214 } |
215 | 215 |
216 | 216 |
217 Object* JavaScriptFrame::GetParameter(int index) const { | 217 Object* JavaScriptFrame::GetParameter(int index) const { |
218 return Memory::Object_at(GetParameterSlot(index)); | 218 return Memory::Object_at(GetParameterSlot(index)); |
219 } | 219 } |
220 | 220 |
221 | 221 |
222 inline Address JavaScriptFrame::GetOperandSlot(int index) const { | 222 inline Address JavaScriptFrame::GetOperandSlot(int index) const { |
223 Address base = fp() + JavaScriptFrameConstants::kLocal0Offset; | 223 Address base = fp() + JavaScriptFrameConstants::kLocal0Offset; |
224 ASSERT(IsAddressAligned(base, kPointerSize)); | 224 DCHECK(IsAddressAligned(base, kPointerSize)); |
225 ASSERT_EQ(type(), JAVA_SCRIPT); | 225 DCHECK_EQ(type(), JAVA_SCRIPT); |
226 ASSERT_LT(index, ComputeOperandsCount()); | 226 DCHECK_LT(index, ComputeOperandsCount()); |
227 ASSERT_LE(0, index); | 227 DCHECK_LE(0, index); |
228 // Operand stack grows down. | 228 // Operand stack grows down. |
229 return base - index * kPointerSize; | 229 return base - index * kPointerSize; |
230 } | 230 } |
231 | 231 |
232 | 232 |
233 inline Object* JavaScriptFrame::GetOperand(int index) const { | 233 inline Object* JavaScriptFrame::GetOperand(int index) const { |
234 return Memory::Object_at(GetOperandSlot(index)); | 234 return Memory::Object_at(GetOperandSlot(index)); |
235 } | 235 } |
236 | 236 |
237 | 237 |
238 inline int JavaScriptFrame::ComputeOperandsCount() const { | 238 inline int JavaScriptFrame::ComputeOperandsCount() const { |
239 Address base = fp() + JavaScriptFrameConstants::kLocal0Offset; | 239 Address base = fp() + JavaScriptFrameConstants::kLocal0Offset; |
240 // Base points to low address of first operand and stack grows down, so add | 240 // Base points to low address of first operand and stack grows down, so add |
241 // kPointerSize to get the actual stack size. | 241 // kPointerSize to get the actual stack size. |
242 intptr_t stack_size_in_bytes = (base + kPointerSize) - sp(); | 242 intptr_t stack_size_in_bytes = (base + kPointerSize) - sp(); |
243 ASSERT(IsAligned(stack_size_in_bytes, kPointerSize)); | 243 DCHECK(IsAligned(stack_size_in_bytes, kPointerSize)); |
244 ASSERT(type() == JAVA_SCRIPT); | 244 DCHECK(type() == JAVA_SCRIPT); |
245 ASSERT(stack_size_in_bytes >= 0); | 245 DCHECK(stack_size_in_bytes >= 0); |
246 return static_cast<int>(stack_size_in_bytes >> kPointerSizeLog2); | 246 return static_cast<int>(stack_size_in_bytes >> kPointerSizeLog2); |
247 } | 247 } |
248 | 248 |
249 | 249 |
250 inline Object* JavaScriptFrame::receiver() const { | 250 inline Object* JavaScriptFrame::receiver() const { |
251 return GetParameter(-1); | 251 return GetParameter(-1); |
252 } | 252 } |
253 | 253 |
254 | 254 |
255 inline void JavaScriptFrame::set_receiver(Object* value) { | 255 inline void JavaScriptFrame::set_receiver(Object* value) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 if (!done()) Advance(); | 310 if (!done()) Advance(); |
311 } | 311 } |
312 | 312 |
313 | 313 |
314 inline JavaScriptFrame* JavaScriptFrameIterator::frame() const { | 314 inline JavaScriptFrame* JavaScriptFrameIterator::frame() const { |
315 // TODO(1233797): The frame hierarchy needs to change. It's | 315 // TODO(1233797): The frame hierarchy needs to change. It's |
316 // problematic that we can't use the safe-cast operator to cast to | 316 // problematic that we can't use the safe-cast operator to cast to |
317 // the JavaScript frame type, because we may encounter arguments | 317 // the JavaScript frame type, because we may encounter arguments |
318 // adaptor frames. | 318 // adaptor frames. |
319 StackFrame* frame = iterator_.frame(); | 319 StackFrame* frame = iterator_.frame(); |
320 ASSERT(frame->is_java_script() || frame->is_arguments_adaptor()); | 320 DCHECK(frame->is_java_script() || frame->is_arguments_adaptor()); |
321 return static_cast<JavaScriptFrame*>(frame); | 321 return static_cast<JavaScriptFrame*>(frame); |
322 } | 322 } |
323 | 323 |
324 | 324 |
325 inline StackFrame* SafeStackFrameIterator::frame() const { | 325 inline StackFrame* SafeStackFrameIterator::frame() const { |
326 ASSERT(!done()); | 326 DCHECK(!done()); |
327 ASSERT(frame_->is_java_script() || frame_->is_exit()); | 327 DCHECK(frame_->is_java_script() || frame_->is_exit()); |
328 return frame_; | 328 return frame_; |
329 } | 329 } |
330 | 330 |
331 | 331 |
332 } } // namespace v8::internal | 332 } } // namespace v8::internal |
333 | 333 |
334 #endif // V8_FRAMES_INL_H_ | 334 #endif // V8_FRAMES_INL_H_ |
OLD | NEW |