Commit 50173924 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[api] Tweak SharedMemoryStatistics Api

Move the API from Isolate to V8 and add better memory fields.

Bug: v8:7464
Change-Id: Ic82c7c74ac8f20a2f2cb896dc0203fdd0b5d8d5f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1905546Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64856}
parent bfe13285
......@@ -7457,21 +7457,23 @@ typedef size_t (*NearHeapLimitCallback)(void* data, size_t current_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.
* v8::V8::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_; }
size_t read_only_space_size() { return read_only_space_size_; }
size_t read_only_space_used_size() { return read_only_space_used_size_; }
size_t read_only_space_physical_size() {
return read_only_space_physical_size_;
}
private:
size_t total_read_only_space_size_;
size_t total_size_;
size_t read_only_space_size_;
size_t read_only_space_used_size_;
size_t read_only_space_physical_size_;
friend class V8;
friend class Isolate;
};
/**
......@@ -8441,11 +8443,6 @@ 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.
*/
......@@ -9470,6 +9467,11 @@ class V8_EXPORT V8 {
UnhandledExceptionCallback unhandled_exception_callback);
#endif
/**
* Get statistics about the shared memory usage.
*/
static void GetSharedMemoryStatistics(SharedMemoryStatistics* statistics);
private:
V8();
......
......@@ -5709,7 +5709,9 @@ bool v8::V8::Dispose() {
}
SharedMemoryStatistics::SharedMemoryStatistics()
: total_read_only_space_size_(0), total_size_(0) {}
: read_only_space_size_(0),
read_only_space_used_size_(0),
read_only_space_physical_size_(0) {}
HeapStatistics::HeapStatistics()
: total_heap_size_(0),
......@@ -5763,6 +5765,12 @@ void v8::V8::InitializeExternalStartupDataFromFile(const char* snapshot_blob) {
const char* v8::V8::GetVersion() { return i::Version::GetVersion(); }
void V8::GetSharedMemoryStatistics(SharedMemoryStatistics* statistics) {
statistics->read_only_space_size_ = 0;
statistics->read_only_space_used_size_ = 0;
statistics->read_only_space_physical_size_ = 0;
}
template <typename ObjectType>
struct InvokeBootstrapper;
......@@ -8475,11 +8483,6 @@ 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