Line data Source code
1 : // Copyright 2015 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #ifndef V8_DEBUG_DEBUG_FRAMES_H_
6 : #define V8_DEBUG_DEBUG_FRAMES_H_
7 :
8 : #include "src/deoptimizer.h"
9 : #include "src/frames.h"
10 : #include "src/isolate.h"
11 : #include "src/objects.h"
12 :
13 : namespace v8 {
14 : namespace internal {
15 :
16 : // Forward declaration:
17 : namespace wasm {
18 : class InterpretedFrame;
19 : }
20 :
21 : class FrameInspector {
22 : public:
23 : FrameInspector(StandardFrame* frame, int inlined_frame_index,
24 : Isolate* isolate);
25 :
26 : ~FrameInspector();
27 :
28 229547 : FrameSummary& summary() { return frame_summary_; }
29 :
30 : int GetParametersCount();
31 : Handle<JSFunction> GetFunction();
32 : Handle<Script> GetScript();
33 : Handle<Object> GetParameter(int index);
34 : Handle<Object> GetExpression(int index);
35 : int GetSourcePosition();
36 : bool IsConstructor();
37 : Handle<Object> GetContext();
38 :
39 : inline JavaScriptFrame* javascript_frame() {
40 10107844 : return frame_->is_arguments_adaptor() ? ArgumentsAdaptorFrame::cast(frame_)
41 20215688 : : JavaScriptFrame::cast(frame_);
42 : }
43 :
44 : JavaScriptFrame* GetArgumentsFrame() { return javascript_frame(); }
45 : void SetArgumentsFrame(StandardFrame* frame);
46 :
47 : void MaterializeStackLocals(Handle<JSObject> target,
48 : Handle<ScopeInfo> scope_info);
49 :
50 : void MaterializeStackLocals(Handle<JSObject> target,
51 : Handle<JSFunction> function);
52 :
53 : void UpdateStackLocalsFromMaterializedObject(Handle<JSObject> object,
54 : Handle<ScopeInfo> scope_info);
55 :
56 : private:
57 : bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info,
58 : Handle<String> parameter_name);
59 :
60 : StandardFrame* frame_;
61 : FrameSummary frame_summary_;
62 : std::unique_ptr<DeoptimizedFrameInfo> deoptimized_frame_;
63 : std::unique_ptr<wasm::InterpretedFrame> wasm_interpreted_frame_;
64 : Isolate* isolate_;
65 : bool is_optimized_;
66 : bool is_interpreted_;
67 : bool is_bottommost_;
68 : bool has_adapted_arguments_;
69 :
70 : DISALLOW_COPY_AND_ASSIGN(FrameInspector);
71 : };
72 :
73 :
74 : class DebugFrameHelper : public AllStatic {
75 : public:
76 : static SaveContext* FindSavedContextForFrame(Isolate* isolate,
77 : StandardFrame* frame);
78 : // Advances the iterator to the frame that matches the index and returns the
79 : // inlined frame index, or -1 if not found. Skips native JS functions.
80 : static int FindIndexedNonNativeFrame(StackTraceFrameIterator* it, int index);
81 :
82 : // Helper functions for wrapping and unwrapping stack frame ids.
83 229547 : static Smi* WrapFrameId(StackFrame::Id id) {
84 : DCHECK(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4)));
85 459094 : return Smi::FromInt(id >> 2);
86 : }
87 :
88 207841 : static StackFrame::Id UnwrapFrameId(int wrapped) {
89 207841 : return static_cast<StackFrame::Id>(wrapped << 2);
90 : }
91 : };
92 :
93 : } // namespace internal
94 : } // namespace v8
95 :
96 : #endif // V8_DEBUG_DEBUG_FRAMES_H_
|