GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: node_process.h Lines: 2 6 33.3 %
Date: 2022-08-31 04:20:31 Branches: 0 0 - %

Line Branch Exec Source
1
#ifndef SRC_NODE_PROCESS_H_
2
#define SRC_NODE_PROCESS_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include "node_snapshotable.h"
7
#include "v8-fast-api-calls.h"
8
#include "v8.h"
9
10
namespace node {
11
12
class Environment;
13
class MemoryTracker;
14
class ExternalReferenceRegistry;
15
16
v8::MaybeLocal<v8::Object> CreateEnvVarProxy(v8::Local<v8::Context> context,
17
                                             v8::Isolate* isolate);
18
19
// Most of the time, it's best to use `console.error` to write
20
// to the process.stderr stream.  However, in some cases, such as
21
// when debugging the stream.Writable class or the process.nextTick
22
// function, it is useful to bypass JavaScript entirely.
23
void RawDebug(const v8::FunctionCallbackInfo<v8::Value>& args);
24
25
v8::MaybeLocal<v8::Value> ProcessEmit(Environment* env,
26
                                      const char* event,
27
                                      v8::Local<v8::Value> message);
28
29
v8::Maybe<bool> ProcessEmitWarningGeneric(Environment* env,
30
                                          const char* warning,
31
                                          const char* type = nullptr,
32
                                          const char* code = nullptr);
33
34
template <typename... Args>
35
inline v8::Maybe<bool> ProcessEmitWarning(Environment* env,
36
                                          const char* fmt,
37
                                          Args&&... args);
38
v8::Maybe<bool> ProcessEmitExperimentalWarning(Environment* env,
39
                                              const char* warning);
40
v8::Maybe<bool> ProcessEmitDeprecationWarning(Environment* env,
41
                                              const char* warning,
42
                                              const char* deprecation_code);
43
44
v8::MaybeLocal<v8::Object> CreateProcessObject(Environment* env);
45
void PatchProcessObject(const v8::FunctionCallbackInfo<v8::Value>& args);
46
47
namespace process {
48
class BindingData : public SnapshotableObject {
49
 public:
50
  void AddMethods();
51
  static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
52
53
  using InternalFieldInfo = InternalFieldInfoBase;
54
55
  SERIALIZABLE_OBJECT_METHODS()
56
  static constexpr FastStringKey type_name{"node::process::BindingData"};
57
  static constexpr EmbedderObjectType type_int =
58
      EmbedderObjectType::k_process_binding_data;
59
60
  BindingData(Environment* env, v8::Local<v8::Object> object);
61
62
  void MemoryInfo(MemoryTracker* tracker) const override;
63
24
  SET_MEMORY_INFO_NAME(BindingData)
64
24
  SET_SELF_SIZE(BindingData)
65
66
  static BindingData* FromV8Value(v8::Local<v8::Value> receiver);
67
  static void NumberImpl(BindingData* receiver);
68
69
  static void FastNumber(v8::Local<v8::Value> receiver) {
70
    NumberImpl(FromV8Value(receiver));
71
  }
72
73
  static void SlowNumber(const v8::FunctionCallbackInfo<v8::Value>& args);
74
75
  static void BigIntImpl(BindingData* receiver);
76
77
  static void FastBigInt(v8::Local<v8::Value> receiver) {
78
    BigIntImpl(FromV8Value(receiver));
79
  }
80
81
  static void SlowBigInt(const v8::FunctionCallbackInfo<v8::Value>& args);
82
83
 private:
84
  static constexpr size_t kBufferSize =
85
      std::max(sizeof(uint64_t), sizeof(uint32_t) * 3);
86
  v8::Global<v8::ArrayBuffer> array_buffer_;
87
  std::shared_ptr<v8::BackingStore> backing_store_;
88
89
  // These need to be static so that we have their addresses available to
90
  // register as external references in the snapshot at environment creation
91
  // time.
92
  static v8::CFunction fast_number_;
93
  static v8::CFunction fast_bigint_;
94
};
95
96
}  // namespace process
97
}  // namespace node
98
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
99
#endif  // SRC_NODE_PROCESS_H_