4
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
5
6
6
#include " base_object.h"
7
- #include " memory_tracker-inl .h"
7
+ #include " node_mem .h"
8
8
#include " uvwasi.h"
9
9
10
10
namespace node {
11
11
namespace wasi {
12
12
13
13
14
- class WASI : public BaseObject {
14
+ class WASI : public BaseObject ,
15
+ public mem::NgLibMemoryManager<WASI, uvwasi_mem_t > {
15
16
public:
16
17
WASI (Environment* env,
17
18
v8::Local<v8::Object> object,
18
19
uvwasi_options_t * options);
19
20
static void New (const v8::FunctionCallbackInfo<v8::Value>& args);
20
- void MemoryInfo (MemoryTracker* tracker) const override {
21
- /* TODO(cjihrig): Get memory consumption from uvwasi. */
22
- tracker->TrackField (" memory" , memory_);
23
- }
24
21
22
+ void MemoryInfo (MemoryTracker* tracker) const override ;
25
23
SET_MEMORY_INFO_NAME (WASI)
26
24
SET_SELF_SIZE (WASI)
27
25
@@ -79,6 +77,11 @@ class WASI : public BaseObject {
79
77
80
78
static void _SetMemory (const v8::FunctionCallbackInfo<v8::Value>& args);
81
79
80
+ // Implementation for mem::NgLibMemoryManager
81
+ void CheckAllocatedSize (size_t previous_size) const ;
82
+ void IncreaseAllocatedSize (size_t size);
83
+ void DecreaseAllocatedSize (size_t size);
84
+
82
85
private:
83
86
~WASI () override ;
84
87
inline void readUInt8 (char * memory, uint8_t * value, uint32_t offset);
@@ -92,6 +95,8 @@ class WASI : public BaseObject {
92
95
uvwasi_errno_t backingStore (char ** store, size_t * byte_length);
93
96
uvwasi_t uvw_;
94
97
v8::Global<v8::Object> memory_;
98
+ uvwasi_mem_t alloc_info_;
99
+ size_t current_uvwasi_memory_ = 0 ;
95
100
};
96
101
97
102
0 commit comments