Commit 276b13cb authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[api] Create SharedMemoryStatistics API

Creates new APIs to get Shared Memory statistics like the size of
read-only space and potentially the memory used by shared array buffers.

Currently all shared memory statistics are zero.

Bug: v8:7464
Change-Id: Ib8d58f885beaa1d65ccef7b64dd4f3db4149bca3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1900465
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64831}
parent 51dbe16c
......@@ -7453,10 +7453,31 @@ typedef void (*InterruptCallback)(Isolate* isolate, void* data);
typedef size_t (*NearHeapLimitCallback)(void* data, size_t current_heap_limit,
size_t initial_heap_limit);
/**
* Collection of shared per-process V8 memory information.
*
* Instances of this class can be passed to
* v8::Isolate::GetSharedMemoryStatistics to get shared memory statistics from
* V8.
*/
class V8_EXPORT SharedMemoryStatistics {
public:
SharedMemoryStatistics();
size_t total_read_only_space_size() { return total_read_only_space_size_; }
size_t total_size() { return total_size_; }
private:
size_t total_read_only_space_size_;
size_t total_size_;
friend class V8;
friend class Isolate;
};
/**
* Collection of V8 heap information.
*
* Instances of this class can be passed to v8::V8::HeapStatistics to
* Instances of this class can be passed to v8::Isolate::GetHeapStatistics to
* get heap statistics from V8.
*/
class V8_EXPORT HeapStatistics {
......@@ -8420,6 +8441,11 @@ class V8_EXPORT Isolate {
template <class T>
V8_INLINE MaybeLocal<T> GetDataFromSnapshotOnce(size_t index);
/**
* Get statistics about the shared memory usage.
*/
void GetSharedMemoryStatistics(SharedMemoryStatistics* statistics);
/**
* Get statistics about the heap memory usage.
*/
......
......@@ -5708,6 +5708,9 @@ bool v8::V8::Dispose() {
return true;
}
SharedMemoryStatistics::SharedMemoryStatistics()
: total_read_only_space_size_(0), total_size_(0) {}
HeapStatistics::HeapStatistics()
: total_heap_size_(0),
total_heap_size_executable_(0),
......@@ -8470,6 +8473,11 @@ i::Address* Isolate::GetDataFromSnapshotOnce(size_t index) {
return GetSerializedDataFromFixedArray(i_isolate, list, index);
}
void Isolate::GetSharedMemoryStatistics(SharedMemoryStatistics* statistics) {
statistics->total_read_only_space_size_ = 0;
statistics->total_size_ = 0;
}
void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
i::Heap* heap = isolate->heap();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment