• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <memory>
9 
10 #include "src/deoptimizer/deoptimized-frame-info.h"
11 #include "src/execution/isolate.h"
12 #include "src/execution/v8threads.h"
13 #include "src/objects/objects.h"
14 
15 namespace v8 {
16 namespace internal {
17 
18 class JavaScriptFrame;
19 class CommonFrame;
20 class WasmFrame;
21 
22 class FrameInspector {
23  public:
24   FrameInspector(CommonFrame* frame, int inlined_frame_index, Isolate* isolate);
25   FrameInspector(const FrameInspector&) = delete;
26   FrameInspector& operator=(const FrameInspector&) = delete;
27 
28   ~FrameInspector();
29 
GetFunction()30   Handle<JSFunction> GetFunction() const { return function_; }
GetScript()31   Handle<Script> GetScript() { return script_; }
32   Handle<Object> GetParameter(int index);
33   Handle<Object> GetExpression(int index);
GetSourcePosition()34   int GetSourcePosition() { return source_position_; }
IsConstructor()35   bool IsConstructor() { return is_constructor_; }
36   Handle<Object> GetContext();
GetReceiver()37   Handle<Object> GetReceiver() { return receiver_; }
38 
39   Handle<String> GetFunctionName();
40 
41 #if V8_ENABLE_WEBASSEMBLY
42   bool IsWasm();
43 #endif  // V8_ENABLE_WEBASSEMBLY
44   bool IsJavaScript();
45 
46   JavaScriptFrame* javascript_frame();
47 
inlined_frame_index()48   int inlined_frame_index() const { return inlined_frame_index_; }
49 
50  private:
51   bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info,
52                                          Handle<String> parameter_name);
53 
54   CommonFrame* frame_;
55   int inlined_frame_index_;
56   std::unique_ptr<DeoptimizedFrameInfo> deoptimized_frame_;
57   Isolate* isolate_;
58   Handle<Script> script_;
59   Handle<Object> receiver_;
60   Handle<JSFunction> function_;
61   int source_position_ = -1;
62   bool is_optimized_ = false;
63   bool is_constructor_ = false;
64 };
65 
66 class RedirectActiveFunctions : public ThreadVisitor {
67  public:
68   enum class Mode {
69     kUseOriginalBytecode,
70     kUseDebugBytecode,
71   };
72 
73   explicit RedirectActiveFunctions(SharedFunctionInfo shared, Mode mode);
74 
75   void VisitThread(Isolate* isolate, ThreadLocalTop* top) override;
76 
77  private:
78   SharedFunctionInfo shared_;
79   Mode mode_;
80   DISALLOW_GARBAGE_COLLECTION(no_gc_)
81 };
82 
83 }  // namespace internal
84 }  // namespace v8
85 
86 #endif  // V8_DEBUG_DEBUG_FRAMES_H_
87