| 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 bool IsStrictFrame(JSFunction* fun) { | 351 bool IsStrictFrame(JSFunction* fun) { |
| 352 if (!encountered_strict_function_) { | 352 if (!encountered_strict_function_) { |
| 353 encountered_strict_function_ = is_strict(fun->shared()->language_mode()); | 353 encountered_strict_function_ = is_strict(fun->shared()->language_mode()); |
| 354 } | 354 } |
| 355 return encountered_strict_function_; | 355 return encountered_strict_function_; |
| 356 } | 356 } |
| 357 | 357 |
| 358 // Determines whether the given stack frame should be displayed in a stack | 358 // Determines whether the given stack frame should be displayed in a stack |
| 359 // trace. | 359 // trace. |
| 360 bool IsVisibleInStackTrace(JSFunction* fun) { | 360 bool IsVisibleInStackTrace(JSFunction* fun) { |
| 361 return ShouldIncludeFrame(fun) && IsNotInNativeScript(fun) && | 361 return ShouldIncludeFrame(fun) && IsNotHidden(fun) && |
| 362 IsInSameSecurityContext(fun); | 362 IsInSameSecurityContext(fun); |
| 363 } | 363 } |
| 364 | 364 |
| 365 private: | 365 private: |
| 366 // This mechanism excludes a number of uninteresting frames from the stack | 366 // This mechanism excludes a number of uninteresting frames from the stack |
| 367 // trace. This can be be the first frame (which will be a builtin-exit frame | 367 // trace. This can be be the first frame (which will be a builtin-exit frame |
| 368 // for the error constructor builtin) or every frame until encountering a | 368 // for the error constructor builtin) or every frame until encountering a |
| 369 // user-specified function. | 369 // user-specified function. |
| 370 bool ShouldIncludeFrame(JSFunction* fun) { | 370 bool ShouldIncludeFrame(JSFunction* fun) { |
| 371 switch (mode_) { | 371 switch (mode_) { |
| 372 case SKIP_NONE: | 372 case SKIP_NONE: |
| 373 return true; | 373 return true; |
| 374 case SKIP_FIRST: | 374 case SKIP_FIRST: |
| 375 if (!skip_next_frame_) return true; | 375 if (!skip_next_frame_) return true; |
| 376 skip_next_frame_ = false; | 376 skip_next_frame_ = false; |
| 377 return false; | 377 return false; |
| 378 case SKIP_UNTIL_SEEN: | 378 case SKIP_UNTIL_SEEN: |
| 379 if (skip_next_frame_ && (fun == *caller_)) { | 379 if (skip_next_frame_ && (fun == *caller_)) { |
| 380 skip_next_frame_ = false; | 380 skip_next_frame_ = false; |
| 381 return false; | 381 return false; |
| 382 } | 382 } |
| 383 return !skip_next_frame_; | 383 return !skip_next_frame_; |
| 384 } | 384 } |
| 385 UNREACHABLE(); | 385 UNREACHABLE(); |
| 386 return false; | 386 return false; |
| 387 } | 387 } |
| 388 | 388 |
| 389 bool IsNotInNativeScript(JSFunction* fun) { | 389 bool IsNotHidden(JSFunction* fun) { |
| 390 // Functions defined in native scripts are not visible unless directly | 390 // Functions defined not in user scripts are not visible unless directly |
| 391 // exposed, in which case the native flag is set. | 391 // exposed, in which case the native flag is set. |
| 392 // The --builtins-in-stack-traces command line flag allows including | 392 // The --builtins-in-stack-traces command line flag allows including |
| 393 // internal call sites in the stack trace for debugging purposes. | 393 // internal call sites in the stack trace for debugging purposes. |
| 394 if (!FLAG_builtins_in_stack_traces && fun->shared()->IsBuiltin()) { | 394 if (!FLAG_builtins_in_stack_traces && !fun->shared()->IsUserJavaScript()) { |
| 395 return fun->shared()->native(); | 395 return fun->shared()->native(); |
| 396 } | 396 } |
| 397 return true; | 397 return true; |
| 398 } | 398 } |
| 399 | 399 |
| 400 bool IsInSameSecurityContext(JSFunction* fun) { | 400 bool IsInSameSecurityContext(JSFunction* fun) { |
| 401 return isolate_->context()->HasSameSecurityTokenAs(fun->context()); | 401 return isolate_->context()->HasSameSecurityTokenAs(fun->context()); |
| 402 } | 402 } |
| 403 | 403 |
| 404 Isolate* isolate_; | 404 Isolate* isolate_; |
| (...skipping 3099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3504 // Then check whether this scope intercepts. | 3504 // Then check whether this scope intercepts. |
| 3505 if ((flag & intercept_mask_)) { | 3505 if ((flag & intercept_mask_)) { |
| 3506 intercepted_flags_ |= flag; | 3506 intercepted_flags_ |= flag; |
| 3507 return true; | 3507 return true; |
| 3508 } | 3508 } |
| 3509 return false; | 3509 return false; |
| 3510 } | 3510 } |
| 3511 | 3511 |
| 3512 } // namespace internal | 3512 } // namespace internal |
| 3513 } // namespace v8 | 3513 } // namespace v8 |
| OLD | NEW |