debug-frames.h 2.26 KB
Newer Older
1 2 3 4 5 6 7
// 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.

#ifndef V8_DEBUG_DEBUG_FRAMES_H_
#define V8_DEBUG_DEBUG_FRAMES_H_

8 9
#include <memory>

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 16 17

namespace v8 {
namespace internal {

18
class JavaScriptFrame;
19
class CommonFrame;
20
class WasmFrame;
21

22 23
class FrameInspector {
 public:
24
  FrameInspector(CommonFrame* frame, int inlined_frame_index, Isolate* isolate);
25 26
  FrameInspector(const FrameInspector&) = delete;
  FrameInspector& operator=(const FrameInspector&) = delete;
27

28
  ~FrameInspector();
29

30
  Handle<JSFunction> GetFunction() const { return function_; }
31
  Handle<Script> GetScript() { return script_; }
32 33
  Handle<Object> GetParameter(int index);
  Handle<Object> GetExpression(int index);
34 35
  int GetSourcePosition() { return source_position_; }
  bool IsConstructor() { return is_constructor_; }
36
  Handle<Object> GetContext();
37 38
  Handle<Object> GetReceiver() { return receiver_; }

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

48
  int inlined_frame_index() const { return inlined_frame_index_; }
49 50 51 52 53

 private:
  bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info,
                                         Handle<String> parameter_name);

54
  CommonFrame* frame_;
55
  int inlined_frame_index_;
56
  std::unique_ptr<DeoptimizedFrameInfo> deoptimized_frame_;
57
  Isolate* isolate_;
58 59 60 61 62 63
  Handle<Script> script_;
  Handle<Object> receiver_;
  Handle<JSFunction> function_;
  int source_position_ = -1;
  bool is_optimized_ = false;
  bool is_constructor_ = false;
64
};
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79

class RedirectActiveFunctions : public ThreadVisitor {
 public:
  enum class Mode {
    kUseOriginalBytecode,
    kUseDebugBytecode,
  };

  explicit RedirectActiveFunctions(SharedFunctionInfo shared, Mode mode);

  void VisitThread(Isolate* isolate, ThreadLocalTop* top) override;

 private:
  SharedFunctionInfo shared_;
  Mode mode_;
80
  DISALLOW_GARBAGE_COLLECTION(no_gc_)
81 82
};

83 84 85 86
}  // namespace internal
}  // namespace v8

#endif  // V8_DEBUG_DEBUG_FRAMES_H_