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 #include "src/frames.h" | 5 #include "src/frames.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
10 #include "src/ast/scopeinfo.h" | 10 #include "src/ast/scopeinfo.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 if (type == StackFrame::NONE) return NULL; | 114 if (type == StackFrame::NONE) return NULL; |
115 StackFrame* result = SingletonFor(type); | 115 StackFrame* result = SingletonFor(type); |
116 DCHECK(result != NULL); | 116 DCHECK(result != NULL); |
117 result->state_ = *state; | 117 result->state_ = *state; |
118 return result; | 118 return result; |
119 } | 119 } |
120 | 120 |
121 | 121 |
122 StackFrame* StackFrameIteratorBase::SingletonFor(StackFrame::Type type) { | 122 StackFrame* StackFrameIteratorBase::SingletonFor(StackFrame::Type type) { |
123 #define FRAME_TYPE_CASE(type, field) \ | 123 #define FRAME_TYPE_CASE(type, field) \ |
124 case StackFrame::type: result = &field##_; break; | 124 case StackFrame::type: \ |
125 return &field##_; | |
125 | 126 |
126 StackFrame* result = NULL; | |
127 switch (type) { | 127 switch (type) { |
128 case StackFrame::NONE: return NULL; | 128 case StackFrame::NONE: return NULL; |
129 STACK_FRAME_TYPE_LIST(FRAME_TYPE_CASE) | 129 STACK_FRAME_TYPE_LIST(FRAME_TYPE_CASE) |
130 default: break; | 130 default: break; |
131 } | 131 } |
132 return result; | 132 return NULL; |
133 | 133 |
134 #undef FRAME_TYPE_CASE | 134 #undef FRAME_TYPE_CASE |
135 } | 135 } |
136 | 136 |
137 | 137 |
138 // ------------------------------------------------------------------------- | 138 // ------------------------------------------------------------------------- |
139 | 139 |
140 | 140 |
141 JavaScriptFrameIterator::JavaScriptFrameIterator( | 141 JavaScriptFrameIterator::JavaScriptFrameIterator( |
142 Isolate* isolate, StackFrame::Id id) | 142 Isolate* isolate, StackFrame::Id id) |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 // The frame anyways will be skipped. | 227 // The frame anyways will be skipped. |
228 type = StackFrame::JAVA_SCRIPT; | 228 type = StackFrame::JAVA_SCRIPT; |
229 // Top frame is incomplete so we cannot reliably determine its type. | 229 // Top frame is incomplete so we cannot reliably determine its type. |
230 top_frame_type_ = StackFrame::NONE; | 230 top_frame_type_ = StackFrame::NONE; |
231 } | 231 } |
232 } else { | 232 } else { |
233 return; | 233 return; |
234 } | 234 } |
235 if (SingletonFor(type) == NULL) return; | 235 if (SingletonFor(type) == NULL) return; |
236 frame_ = SingletonFor(type, &state); | 236 frame_ = SingletonFor(type, &state); |
237 if (frame_ == NULL) return; | 237 DCHECK(frame_); |
titzer
2016/01/27 08:29:00
Did you run this through the trybots yet? I might
alph
2016/01/27 17:37:14
AFAICT it cannot return NULL if the previous call
| |
238 | 238 |
239 Advance(); | 239 Advance(); |
240 | 240 |
241 if (frame_ != NULL && !frame_->is_exit() && | 241 if (frame_ != NULL && !frame_->is_exit() && |
242 external_callback_scope_ != NULL && | 242 external_callback_scope_ != NULL && |
243 external_callback_scope_->scope_address() < frame_->fp()) { | 243 external_callback_scope_->scope_address() < frame_->fp()) { |
244 // Skip top ExternalCallbackScope if we already advanced to a JS frame | 244 // Skip top ExternalCallbackScope if we already advanced to a JS frame |
245 // under it. Sampler will anyways take this top external callback. | 245 // under it. Sampler will anyways take this top external callback. |
246 external_callback_scope_ = external_callback_scope_->previous(); | 246 external_callback_scope_ = external_callback_scope_->previous(); |
247 } | 247 } |
(...skipping 17 matching lines...) Expand all Loading... | |
265 Address last_sp = last_frame->sp(), last_fp = last_frame->fp(); | 265 Address last_sp = last_frame->sp(), last_fp = last_frame->fp(); |
266 // Before advancing to the next stack frame, perform pointer validity tests. | 266 // Before advancing to the next stack frame, perform pointer validity tests. |
267 if (!IsValidFrame(last_frame) || !IsValidCaller(last_frame)) { | 267 if (!IsValidFrame(last_frame) || !IsValidCaller(last_frame)) { |
268 frame_ = NULL; | 268 frame_ = NULL; |
269 return; | 269 return; |
270 } | 270 } |
271 | 271 |
272 // Advance to the previous frame. | 272 // Advance to the previous frame. |
273 StackFrame::State state; | 273 StackFrame::State state; |
274 StackFrame::Type type = frame_->GetCallerState(&state); | 274 StackFrame::Type type = frame_->GetCallerState(&state); |
275 if (SingletonFor(type) == NULL) { | |
yurys
2016/01/26 23:55:57
Maybe if (type < 0 || type >= StackFrame::NUMBER_O
alph
2016/01/27 00:19:36
I like mine more. Moreover it is used elsewhere (l
yurys
2016/01/27 00:22:14
Acknowledged.
| |
276 frame_ = NULL; | |
277 return; | |
278 } | |
275 frame_ = SingletonFor(type, &state); | 279 frame_ = SingletonFor(type, &state); |
276 if (frame_ == NULL) return; | 280 DCHECK(frame_); |
277 | 281 |
278 // Check that we have actually moved to the previous frame in the stack. | 282 // Check that we have actually moved to the previous frame in the stack. |
279 if (frame_->sp() < last_sp || frame_->fp() < last_fp) { | 283 if (frame_->sp() < last_sp || frame_->fp() < last_fp) { |
280 frame_ = NULL; | 284 frame_ = NULL; |
281 } | 285 } |
282 } | 286 } |
283 | 287 |
284 | 288 |
285 bool SafeStackFrameIterator::IsValidFrame(StackFrame* frame) const { | 289 bool SafeStackFrameIterator::IsValidFrame(StackFrame* frame) const { |
286 return IsValidStackAddress(frame->sp()) && IsValidStackAddress(frame->fp()); | 290 return IsValidStackAddress(frame->sp()) && IsValidStackAddress(frame->fp()); |
(...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1616 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 1620 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
1617 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 1621 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
1618 list.Add(frame, zone); | 1622 list.Add(frame, zone); |
1619 } | 1623 } |
1620 return list.ToVector(); | 1624 return list.ToVector(); |
1621 } | 1625 } |
1622 | 1626 |
1623 | 1627 |
1624 } // namespace internal | 1628 } // namespace internal |
1625 } // namespace v8 | 1629 } // namespace v8 |
OLD | NEW |