HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Android 10
|
10.0.0_r6
下载
查看原文件
收藏
根目录
external
v8
src
debug
debug-stack-trace-iterator.cc
// Copyright 2017 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-stack-trace-iterator.h" #include "src/api-inl.h" #include "src/debug/debug-evaluate.h" #include "src/debug/debug-scope-iterator.h" #include "src/debug/debug.h" #include "src/debug/liveedit.h" #include "src/frames-inl.h" #include "src/isolate.h" namespace v8 { std::unique_ptr
debug::StackTraceIterator::Create( v8::Isolate* isolate, int index) { return std::unique_ptr
( new internal::DebugStackTraceIterator( reinterpret_cast
(isolate), index)); } namespace internal { DebugStackTraceIterator::DebugStackTraceIterator(Isolate* isolate, int index) : isolate_(isolate), iterator_(isolate, isolate->debug()->break_frame_id()), is_top_frame_(true) { if (iterator_.done()) return; std::vector
frames; iterator_.frame()->Summarize(&frames); inlined_frame_index_ = static_cast
(frames.size()); Advance(); for (; !Done() && index > 0; --index) Advance(); } DebugStackTraceIterator::~DebugStackTraceIterator() {} bool DebugStackTraceIterator::Done() const { return iterator_.done(); } void DebugStackTraceIterator::Advance() { while (true) { --inlined_frame_index_; for (; inlined_frame_index_ >= 0; --inlined_frame_index_) { // Omit functions from native and extension scripts. if (FrameSummary::Get(iterator_.frame(), inlined_frame_index_) .is_subject_to_debugging()) { break; } is_top_frame_ = false; } if (inlined_frame_index_ >= 0) { frame_inspector_.reset(new FrameInspector( iterator_.frame(), inlined_frame_index_, isolate_)); break; } is_top_frame_ = false; frame_inspector_.reset(); iterator_.Advance(); if (iterator_.done()) break; std::vector
frames; iterator_.frame()->Summarize(&frames); inlined_frame_index_ = static_cast
(frames.size()); } } int DebugStackTraceIterator::GetContextId() const { DCHECK(!Done()); Handle
context = frame_inspector_->GetContext(); if (context->IsContext()) { Object* value = Context::cast(*context)->native_context()->debug_context_id(); if (value->IsSmi()) return Smi::ToInt(value); } return 0; } v8::MaybeLocal
DebugStackTraceIterator::GetReceiver() const { DCHECK(!Done()); if (frame_inspector_->IsJavaScript() && frame_inspector_->GetFunction()->shared()->kind() == kArrowFunction) { // FrameInspector is not able to get receiver for arrow function. // So let's try to fetch it using same logic as is used to retrieve 'this' // during DebugEvaluate::Local. Handle
function = frame_inspector_->GetFunction(); Handle
context(function->context(), isolate_); // Arrow function defined in top level function without references to // variables may have NativeContext as context. if (!context->IsFunctionContext()) return v8::MaybeLocal
(); ScopeIterator scope_iterator(isolate_, frame_inspector_.get(), ScopeIterator::COLLECT_NON_LOCALS); // We lookup this variable in function context only when it is used in arrow // function otherwise V8 can optimize it out. if (!scope_iterator.GetNonLocals()->Has(isolate_, isolate_->factory()->this_string())) return v8::MaybeLocal
(); Handle
scope_info(context->scope_info(), isolate_); VariableMode mode; InitializationFlag flag; MaybeAssignedFlag maybe_assigned_flag; int slot_index = ScopeInfo::ContextSlotIndex( scope_info, isolate_->factory()->this_string(), &mode, &flag, &maybe_assigned_flag); if (slot_index < 0) return v8::MaybeLocal
(); Handle
value = handle(context->get(slot_index), isolate_); if (value->IsTheHole(isolate_)) return v8::MaybeLocal
(); return Utils::ToLocal(value); } Handle
value = frame_inspector_->GetReceiver(); if (value.is_null() || (value->IsSmi() || !value->IsTheHole(isolate_))) { return Utils::ToLocal(value); } return v8::MaybeLocal
(); } v8::Local
DebugStackTraceIterator::GetReturnValue() const { DCHECK(!Done()); if (frame_inspector_->IsWasm()) return v8::Local
(); bool is_optimized = iterator_.frame()->is_optimized(); if (is_optimized || !is_top_frame_ || !isolate_->debug()->IsBreakAtReturn(iterator_.javascript_frame())) { return v8::Local
(); } return Utils::ToLocal(isolate_->debug()->return_value_handle()); } v8::Local
DebugStackTraceIterator::GetFunctionDebugName() const { DCHECK(!Done()); return Utils::ToLocal(frame_inspector_->GetFunctionName()); } v8::Local
DebugStackTraceIterator::GetScript() const { DCHECK(!Done()); Handle
value = frame_inspector_->GetScript(); if (!value->IsScript()) return v8::Local
(); return ToApiHandle
(Handle
登录后可以享受更多权益
您还没有登录,登录后您可以:
收藏Android系统代码
收藏喜欢的文章
多个平台共享账号
去登录
首次使用?从这里
注册