Skip to content

Commit 5017392

Browse files
danelphickCommit Bot
authored andcommitted
[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/+/1905546 Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Commit-Queue: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#64856}
1 parent bfe1328 commit 5017392

2 files changed

Lines changed: 23 additions & 18 deletions

File tree

include/v8.h

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7457,21 +7457,23 @@ typedef size_t (*NearHeapLimitCallback)(void* data, size_t current_heap_limit,
74577457
* Collection of shared per-process V8 memory information.
74587458
*
74597459
* Instances of this class can be passed to
7460-
* v8::Isolate::GetSharedMemoryStatistics to get shared memory statistics from
7461-
* V8.
7460+
* v8::V8::GetSharedMemoryStatistics to get shared memory statistics from V8.
74627461
*/
74637462
class V8_EXPORT SharedMemoryStatistics {
74647463
public:
74657464
SharedMemoryStatistics();
7466-
size_t total_read_only_space_size() { return total_read_only_space_size_; }
7467-
size_t total_size() { return total_size_; }
7465+
size_t read_only_space_size() { return read_only_space_size_; }
7466+
size_t read_only_space_used_size() { return read_only_space_used_size_; }
7467+
size_t read_only_space_physical_size() {
7468+
return read_only_space_physical_size_;
7469+
}
74687470

74697471
private:
7470-
size_t total_read_only_space_size_;
7471-
size_t total_size_;
7472+
size_t read_only_space_size_;
7473+
size_t read_only_space_used_size_;
7474+
size_t read_only_space_physical_size_;
74727475

74737476
friend class V8;
7474-
friend class Isolate;
74757477
};
74767478

74777479
/**
@@ -8441,11 +8443,6 @@ class V8_EXPORT Isolate {
84418443
template <class T>
84428444
V8_INLINE MaybeLocal<T> GetDataFromSnapshotOnce(size_t index);
84438445

8444-
/**
8445-
* Get statistics about the shared memory usage.
8446-
*/
8447-
void GetSharedMemoryStatistics(SharedMemoryStatistics* statistics);
8448-
84498446
/**
84508447
* Get statistics about the heap memory usage.
84518448
*/
@@ -9470,6 +9467,11 @@ class V8_EXPORT V8 {
94709467
UnhandledExceptionCallback unhandled_exception_callback);
94719468
#endif
94729469

9470+
/**
9471+
* Get statistics about the shared memory usage.
9472+
*/
9473+
static void GetSharedMemoryStatistics(SharedMemoryStatistics* statistics);
9474+
94739475
private:
94749476
V8();
94759477

src/api/api.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5709,7 +5709,9 @@ bool v8::V8::Dispose() {
57095709
}
57105710

57115711
SharedMemoryStatistics::SharedMemoryStatistics()
5712-
: total_read_only_space_size_(0), total_size_(0) {}
5712+
: read_only_space_size_(0),
5713+
read_only_space_used_size_(0),
5714+
read_only_space_physical_size_(0) {}
57135715

57145716
HeapStatistics::HeapStatistics()
57155717
: total_heap_size_(0),
@@ -5763,6 +5765,12 @@ void v8::V8::InitializeExternalStartupDataFromFile(const char* snapshot_blob) {
57635765

57645766
const char* v8::V8::GetVersion() { return i::Version::GetVersion(); }
57655767

5768+
void V8::GetSharedMemoryStatistics(SharedMemoryStatistics* statistics) {
5769+
statistics->read_only_space_size_ = 0;
5770+
statistics->read_only_space_used_size_ = 0;
5771+
statistics->read_only_space_physical_size_ = 0;
5772+
}
5773+
57665774
template <typename ObjectType>
57675775
struct InvokeBootstrapper;
57685776

@@ -8475,11 +8483,6 @@ i::Address* Isolate::GetDataFromSnapshotOnce(size_t index) {
84758483
return GetSerializedDataFromFixedArray(i_isolate, list, index);
84768484
}
84778485

8478-
void Isolate::GetSharedMemoryStatistics(SharedMemoryStatistics* statistics) {
8479-
statistics->total_read_only_space_size_ = 0;
8480-
statistics->total_size_ = 0;
8481-
}
8482-
84838486
void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) {
84848487
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
84858488
i::Heap* heap = isolate->heap();

0 commit comments

Comments
 (0)