Commit 2e9c972b authored by Samuel Groß's avatar Samuel Groß Committed by V8 LUCI CQ

Expose the size of the virtual memory cage

This CL exposes the size of the virtual memory cage to the embedder
through V8::GetVirtualMemoryCageSizeInBytes(). This will for example be
useful to collect metrics about the cage reservation, such as how
frequently it fails, in the future. While collecting these metrics
directly in V8 would also be possible, it would require access to an
Isolate, which is not yet available when the cage is initialized. As
such, it is easier to enable the embedder to collect these metrics.

Bug: chromium:1218005
Change-Id: Ie9c9ca7d1cd158ec024be6ab2418f50083b06d6e
Cq-Include-Trybots: luci.v8.try:v8_linux64_heap_sandbox_dbg_ng
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3172762Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Samuel Groß <saelo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76969}
parent 4a310e10
......@@ -219,6 +219,14 @@ class V8_EXPORT V8 {
* cage and V8.
*/
static PageAllocator* GetVirtualMemoryCagePageAllocator();
/**
* Returns the size of the virtual memory cage in bytes.
*
* If the cage has not been initialized, or if the initialization failed,
* this returns zero.
*/
static size_t GetVirtualMemoryCageSizeInBytes();
#endif
/**
......
......@@ -6115,6 +6115,14 @@ PageAllocator* v8::V8::GetVirtualMemoryCagePageAllocator() {
CHECK(i::GetProcessWideVirtualMemoryCage()->is_initialized());
return i::GetProcessWideVirtualMemoryCage()->page_allocator();
}
size_t v8::V8::GetVirtualMemoryCageSizeInBytes() {
if (!i::GetProcessWideVirtualMemoryCage()->is_initialized()) {
return 0;
} else {
return i::GetProcessWideVirtualMemoryCage()->size();
}
}
#endif
void V8::GetSharedMemoryStatistics(SharedMemoryStatistics* statistics) {
......
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