Coverage Report

Created: 2025-10-31 09:06

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/node/src/node_main_instance.h
Line
Count
Source
1
#ifndef SRC_NODE_MAIN_INSTANCE_H_
2
#define SRC_NODE_MAIN_INSTANCE_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include <cstddef>
7
#include <memory>
8
9
#include "node.h"
10
#include "node_exit_code.h"
11
#include "util.h"
12
#include "uv.h"
13
#include "v8.h"
14
15
namespace node {
16
17
class ExternalReferenceRegistry;
18
struct EnvSerializeInfo;
19
struct SnapshotData;
20
21
// TODO(joyeecheung): align this with the Worker/WorkerThreadData class.
22
// We may be able to create an abstract class to reuse some of the routines.
23
class NodeMainInstance {
24
 public:
25
  // Create a main instance that owns the isolate
26
  NodeMainInstance(const SnapshotData* snapshot_data,
27
                   uv_loop_t* event_loop,
28
                   MultiIsolatePlatform* platform,
29
                   const std::vector<std::string>& args,
30
                   const std::vector<std::string>& exec_args);
31
  ~NodeMainInstance();
32
33
  // Start running the Node.js instances, return the exit code when finished.
34
  ExitCode Run();
35
  void Run(ExitCode* exit_code, Environment* env);
36
37
0
  IsolateData* isolate_data() { return isolate_data_.get(); }
38
39
  DeleteFnPtr<Environment, FreeEnvironment> CreateMainEnvironment(
40
      ExitCode* exit_code);
41
42
  NodeMainInstance(const NodeMainInstance&) = delete;
43
  NodeMainInstance& operator=(const NodeMainInstance&) = delete;
44
  NodeMainInstance(NodeMainInstance&&) = delete;
45
  NodeMainInstance& operator=(NodeMainInstance&&) = delete;
46
47
 private:
48
  NodeMainInstance(v8::Isolate* isolate,
49
                   uv_loop_t* event_loop,
50
                   MultiIsolatePlatform* platform,
51
                   const std::vector<std::string>& args,
52
                   const std::vector<std::string>& exec_args);
53
54
  std::vector<std::string> args_;
55
  std::vector<std::string> exec_args_;
56
  std::unique_ptr<ArrayBufferAllocator> array_buffer_allocator_;
57
  v8::Isolate* isolate_;
58
  MultiIsolatePlatform* platform_;
59
  std::unique_ptr<IsolateData> isolate_data_;
60
  std::unique_ptr<v8::Isolate::CreateParams> isolate_params_;
61
  const SnapshotData* snapshot_data_ = nullptr;
62
};
63
64
}  // namespace node
65
66
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
67
#endif  // SRC_NODE_MAIN_INSTANCE_H_