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 : #include "src/v8threads.h"
13 : #include "src/wasm/wasm-interpreter.h"
14 :
15 : namespace v8 {
16 : namespace internal {
17 :
18 : class FrameInspector {
19 : public:
20 : FrameInspector(StandardFrame* frame, int inlined_frame_index,
21 : Isolate* isolate);
22 :
23 : ~FrameInspector(); // NOLINT (modernize-use-equals-default)
24 :
25 : int GetParametersCount();
26 : Handle<JSFunction> GetFunction() const { return function_; }
27 : Handle<Script> GetScript() { return script_; }
28 : Handle<Object> GetParameter(int index);
29 : Handle<Object> GetExpression(int index);
30 : int GetSourcePosition() { return source_position_; }
31 : bool IsConstructor() { return is_constructor_; }
32 : Handle<Object> GetContext();
33 : Handle<Object> GetReceiver() { return receiver_; }
34 :
35 : Handle<String> GetFunctionName() { return function_name_; }
36 :
37 : bool IsWasm();
38 : bool IsJavaScript();
39 :
40 : inline JavaScriptFrame* javascript_frame() {
41 426370 : return frame_->is_arguments_adaptor() ? ArgumentsAdaptorFrame::cast(frame_)
42 852740 : : JavaScriptFrame::cast(frame_);
43 : }
44 :
45 : int inlined_frame_index() const { return inlined_frame_index_; }
46 :
47 : private:
48 : bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info,
49 : Handle<String> parameter_name);
50 :
51 : StandardFrame* frame_;
52 : int inlined_frame_index_;
53 : std::unique_ptr<DeoptimizedFrameInfo> deoptimized_frame_;
54 : wasm::WasmInterpreter::FramePtr wasm_interpreted_frame_;
55 : Isolate* isolate_;
56 : Handle<Script> script_;
57 : Handle<Object> receiver_;
58 : Handle<JSFunction> function_;
59 : Handle<String> function_name_;
60 : int source_position_ = -1;
61 : bool is_optimized_ = false;
62 : bool is_interpreted_ = false;
63 : bool has_adapted_arguments_ = false;
64 : bool is_constructor_ = false;
65 :
66 : DISALLOW_COPY_AND_ASSIGN(FrameInspector);
67 : };
68 :
69 42404 : class RedirectActiveFunctions : public ThreadVisitor {
70 : public:
71 : enum class Mode {
72 : kUseOriginalBytecode,
73 : kUseDebugBytecode,
74 : };
75 :
76 : explicit RedirectActiveFunctions(SharedFunctionInfo shared, Mode mode);
77 :
78 : void VisitThread(Isolate* isolate, ThreadLocalTop* top) override;
79 :
80 : private:
81 : SharedFunctionInfo shared_;
82 : Mode mode_;
83 : DisallowHeapAllocation no_gc_;
84 : };
85 :
86 : } // namespace internal
87 : } // namespace v8
88 :
89 : #endif // V8_DEBUG_DEBUG_FRAMES_H_
|