• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef SRC_NODE_V8_H_
2 #define SRC_NODE_V8_H_
3 
4 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5 
6 #include <sstream>
7 #include "aliased_buffer.h"
8 #include "base_object.h"
9 #include "json_utils.h"
10 #include "node_snapshotable.h"
11 #include "util.h"
12 #include "v8.h"
13 
14 namespace node {
15 class Environment;
16 struct InternalFieldInfoBase;
17 
18 namespace v8_utils {
19 class BindingData : public SnapshotableObject {
20  public:
21   BindingData(Realm* realm, v8::Local<v8::Object> obj);
22 
23   using InternalFieldInfo = InternalFieldInfoBase;
24 
25   SERIALIZABLE_OBJECT_METHODS()
26   SET_BINDING_ID(v8_binding_data)
27 
28   AliasedFloat64Array heap_statistics_buffer;
29   AliasedFloat64Array heap_space_statistics_buffer;
30   AliasedFloat64Array heap_code_statistics_buffer;
31 
32   void MemoryInfo(MemoryTracker* tracker) const override;
33   SET_SELF_SIZE(BindingData)
34   SET_MEMORY_INFO_NAME(BindingData)
35 };
36 
37 class GCProfiler : public BaseObject {
38  public:
39   enum class GCProfilerState { kInitialized, kStarted, kStopped };
40   GCProfiler(Environment* env, v8::Local<v8::Object> object);
41   inline ~GCProfiler() override;
42   static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
43   static void Start(const v8::FunctionCallbackInfo<v8::Value>& args);
44   static void Stop(const v8::FunctionCallbackInfo<v8::Value>& args);
45 
46   JSONWriter* writer();
47 
48   std::ostringstream* out_stream();
49 
50   SET_NO_MEMORY_INFO()
51   SET_MEMORY_INFO_NAME(GCProfiler)
52   SET_SELF_SIZE(GCProfiler)
53 
54   uint64_t start_time;
55   uint8_t current_gc_type;
56   GCProfilerState state;
57 
58  private:
59   std::ostringstream out_stream_;
60   JSONWriter writer_;
61 };
62 
63 }  // namespace v8_utils
64 
65 }  // namespace node
66 
67 #endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
68 
69 #endif  // SRC_NODE_V8_H_
70