| 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/isolate.h" | 5 #include "src/isolate.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include <fstream> // NOLINT(readability/streams) | 9 #include <fstream> // NOLINT(readability/streams) |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 | 314 |
| 315 | 315 |
| 316 // Determines whether the given stack frame should be displayed in | 316 // Determines whether the given stack frame should be displayed in |
| 317 // a stack trace. The caller is the error constructor that asked | 317 // a stack trace. The caller is the error constructor that asked |
| 318 // for the stack trace to be collected. The first time a construct | 318 // for the stack trace to be collected. The first time a construct |
| 319 // call to this function is encountered it is skipped. The seen_caller | 319 // call to this function is encountered it is skipped. The seen_caller |
| 320 // in/out parameter is used to remember if the caller has been seen | 320 // in/out parameter is used to remember if the caller has been seen |
| 321 // yet. | 321 // yet. |
| 322 static bool IsVisibleInStackTrace(JSFunction* fun, | 322 static bool IsVisibleInStackTrace(JSFunction* fun, |
| 323 Object* caller, | 323 Object* caller, |
| 324 Object* receiver, | |
| 325 bool* seen_caller) { | 324 bool* seen_caller) { |
| 326 if ((fun == caller) && !(*seen_caller)) { | 325 if ((fun == caller) && !(*seen_caller)) { |
| 327 *seen_caller = true; | 326 *seen_caller = true; |
| 328 return false; | 327 return false; |
| 329 } | 328 } |
| 330 // Skip all frames until we've seen the caller. | 329 // Skip all frames until we've seen the caller. |
| 331 if (!(*seen_caller)) return false; | 330 if (!(*seen_caller)) return false; |
| 332 // Functions defined in native scripts are not visible unless directly | 331 // Functions defined in native scripts are not visible unless directly |
| 333 // exposed, in which case the native flag is set. | 332 // exposed, in which case the native flag is set. |
| 334 // The --builtins-in-stack-traces command line flag allows including | 333 // The --builtins-in-stack-traces command line flag allows including |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 case StackFrame::INTERPRETED: { | 389 case StackFrame::INTERPRETED: { |
| 391 JavaScriptFrame* js_frame = JavaScriptFrame::cast(frame); | 390 JavaScriptFrame* js_frame = JavaScriptFrame::cast(frame); |
| 392 // Set initial size to the maximum inlining level + 1 for the outermost | 391 // Set initial size to the maximum inlining level + 1 for the outermost |
| 393 // function. | 392 // function. |
| 394 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); | 393 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); |
| 395 js_frame->Summarize(&frames); | 394 js_frame->Summarize(&frames); |
| 396 for (int i = frames.length() - 1; i >= 0; i--) { | 395 for (int i = frames.length() - 1; i >= 0; i--) { |
| 397 Handle<JSFunction> fun = frames[i].function(); | 396 Handle<JSFunction> fun = frames[i].function(); |
| 398 Handle<Object> recv = frames[i].receiver(); | 397 Handle<Object> recv = frames[i].receiver(); |
| 399 // Filter out internal frames that we do not want to show. | 398 // Filter out internal frames that we do not want to show. |
| 400 if (!IsVisibleInStackTrace(*fun, *caller, *recv, &seen_caller)) { | 399 if (!IsVisibleInStackTrace(*fun, *caller, &seen_caller)) continue; |
| 401 continue; | |
| 402 } | |
| 403 // Filter out frames from other security contexts. | 400 // Filter out frames from other security contexts. |
| 404 if (!this->context()->HasSameSecurityTokenAs(fun->context())) { | 401 if (!this->context()->HasSameSecurityTokenAs(fun->context())) { |
| 405 continue; | 402 continue; |
| 406 } | 403 } |
| 407 elements = MaybeGrow(this, elements, cursor, cursor + 4); | 404 elements = MaybeGrow(this, elements, cursor, cursor + 4); |
| 408 | 405 |
| 409 Handle<AbstractCode> abstract_code = frames[i].abstract_code(); | 406 Handle<AbstractCode> abstract_code = frames[i].abstract_code(); |
| 410 | 407 |
| 411 Handle<Smi> offset(Smi::FromInt(frames[i].code_offset()), this); | 408 Handle<Smi> offset(Smi::FromInt(frames[i].code_offset()), this); |
| 412 // The stack trace API should not expose receivers and function | 409 // The stack trace API should not expose receivers and function |
| (...skipping 2643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3056 // Then check whether this scope intercepts. | 3053 // Then check whether this scope intercepts. |
| 3057 if ((flag & intercept_mask_)) { | 3054 if ((flag & intercept_mask_)) { |
| 3058 intercepted_flags_ |= flag; | 3055 intercepted_flags_ |= flag; |
| 3059 return true; | 3056 return true; |
| 3060 } | 3057 } |
| 3061 return false; | 3058 return false; |
| 3062 } | 3059 } |
| 3063 | 3060 |
| 3064 } // namespace internal | 3061 } // namespace internal |
| 3065 } // namespace v8 | 3062 } // namespace v8 |
| OLD | NEW |