HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Pie
|
9.0.0_r8
下载
查看原文件
收藏
根目录
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
#include "src/ast/ast.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/parse-info.h" #include "src/parsing/parsing.h" #include "src/parsing/rewriter.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), seen_script_scope_(false) { if (!frame_inspector->GetContext()->IsContext()) { // Optimized frame, context or function cannot be materialized. Give up. return; } context_ = Handle
::cast(frame_inspector->GetContext()); // We should not instantiate a ScopeIterator for wasm frames. DCHECK(frame_inspector->GetScript()->type() != Script::TYPE_WASM); // 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()->IsUndefined(isolate)) { 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()); // Find the break point where execution has stopped. BreakLocation location = BreakLocation::FromFrame(debug_info, GetFrame()); 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(ExtendedScopeInfo(scope_info, shared_info->start_position(), shared_info->end_position())); } if (!collect_non_locals) return; } // Reparse the code and analyze the scopes. // Check whether we are in global, eval or function code. std::unique_ptr
info; if (scope_info->scope_type() != FUNCTION_SCOPE) { // Global or eval code. Handle
登录后可以享受更多权益
您还没有登录,登录后您可以:
收藏Android系统代码
收藏喜欢的文章
多个平台共享账号
去登录
首次使用?从这里
注册