HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Nougat 7.0
|
7.0.0_r31
下载
查看原文件
收藏
根目录
external
v8
src
debug
debug-scopes.cc
// Copyright 2015 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/debug/debug-scopes.h" #include "src/ast/scopes.h" #include "src/debug/debug.h" #include "src/frames-inl.h" #include "src/globals.h" #include "src/isolate-inl.h" #include "src/parsing/parser.h" namespace v8 { namespace internal { ScopeIterator::ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector, ScopeIterator::Option option) : isolate_(isolate), frame_inspector_(frame_inspector), nested_scope_chain_(4), non_locals_(nullptr), seen_script_scope_(false), failed_(false) { if (!frame_inspector->GetContext()->IsContext() || !frame_inspector->GetFunction()->IsJSFunction()) { // Optimized frame, context or function cannot be materialized. Give up. return; } context_ = Handle
(Context::cast(frame_inspector->GetContext())); // Catch the case when the debugger stops in an internal function. Handle
function = GetFunction(); Handle
shared_info(function->shared()); Handle
scope_info(shared_info->scope_info()); if (shared_info->script() == isolate->heap()->undefined_value()) { while (context_->closure() == *function) { context_ = Handle
(context_->previous(), isolate_); } return; } // Currently it takes too much time to find nested scopes due to script // parsing. Sometimes we want to run the ScopeIterator as fast as possible // (for example, while collecting async call stacks on every // addEventListener call), even if we drop some nested scopes. // Later we may optimize getting the nested scopes (cache the result?) // and include nested scopes into the "fast" iteration case as well. bool ignore_nested_scopes = (option == IGNORE_NESTED_SCOPES); bool collect_non_locals = (option == COLLECT_NON_LOCALS); if (!ignore_nested_scopes && shared_info->HasDebugInfo()) { // The source position at return is always the end of the function, // which is not consistent with the current scope chain. Therefore all // nested with, catch and block contexts are skipped, and we can only // inspect the function scope. // This can only happen if we set a break point inside right before the // return, which requires a debug info to be available. Handle
debug_info(shared_info->GetDebugInfo()); // PC points to the instruction after the current one, possibly a break // location as well. So the "- 1" to exclude it from the search. Address call_pc = GetFrame()->pc() - 1; // Find the break point where execution has stopped. BreakLocation location = BreakLocation::FromAddress(debug_info, call_pc); ignore_nested_scopes = location.IsReturn(); } if (ignore_nested_scopes) { if (scope_info->HasContext()) { context_ = Handle
(context_->declaration_context(), isolate_); } else { while (context_->closure() == *function) { context_ = Handle
(context_->previous(), isolate_); } } if (scope_info->scope_type() == FUNCTION_SCOPE) { nested_scope_chain_.Add(scope_info); } if (!collect_non_locals) return; } // Reparse the code and analyze the scopes. Scope* scope = NULL; // Check whether we are in global, eval or function code. Zone zone; if (scope_info->scope_type() != FUNCTION_SCOPE) { // Global or eval code. Handle
登录后可以享受更多权益
您还没有登录,登录后您可以:
收藏Android系统代码
收藏喜欢的文章
多个平台共享账号
去登录
首次使用?从这里
注册