44#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
55
66#include " base_object.h"
7- #include " memory_tracker-inl .h"
7+ #include " node_mem .h"
88#include " uvwasi.h"
99
1010namespace node {
1111namespace wasi {
1212
1313
14- class WASI : public BaseObject {
14+ class WASI : public BaseObject ,
15+ public mem::NgLibMemoryManager<WASI, uvwasi_mem_t > {
1516 public:
1617 WASI (Environment* env,
1718 v8::Local<v8::Object> object,
1819 uvwasi_options_t * options);
1920 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- }
2421
22+ void MemoryInfo (MemoryTracker* tracker) const override ;
2523 SET_MEMORY_INFO_NAME (WASI)
2624 SET_SELF_SIZE (WASI)
2725
@@ -79,6 +77,11 @@ class WASI : public BaseObject {
7977
8078 static void _SetMemory (const v8::FunctionCallbackInfo<v8::Value>& args);
8179
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+
8285 private:
8386 ~WASI () override ;
8487 inline void readUInt8 (char * memory, uint8_t * value, uint32_t offset);
@@ -92,6 +95,8 @@ class WASI : public BaseObject {
9295 uvwasi_errno_t backingStore (char ** store, size_t * byte_length);
9396 uvwasi_t uvw_;
9497 v8::Global<v8::Object> memory_;
98+ uvwasi_mem_t alloc_info_;
99+ size_t current_uvwasi_memory_ = 0 ;
95100};
96101
97102
0 commit comments