Commit 4cab8099 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[ro-heap] Remove ReadOnlyHeap::Instance

This removes the static ReadOnlyHeap::Instance method replacing it with
PopulateReadOnlySpaceStatistics on the way to removing the global
ReadOnlyHeap object.

Bug: v8:10454
Change-Id: Ic78c898ff99c6a7dac023d2b5230fbbbf6f36f46
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2179805
Commit-Queue: Dan Elphick <delphick@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Auto-Submit: Dan Elphick <delphick@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67545}
parent 8c830bfd
...@@ -123,19 +123,21 @@ namespace internal { ...@@ -123,19 +123,21 @@ namespace internal {
enum class ArgumentsType; enum class ArgumentsType;
template <ArgumentsType> template <ArgumentsType>
class Arguments; class Arguments;
template <typename T>
class CustomArguments;
class DeferredHandles; class DeferredHandles;
class FunctionCallbackArguments;
class GlobalHandles;
class Heap; class Heap;
class HeapObject; class HeapObject;
class ExternalString; class ExternalString;
class Isolate; class Isolate;
class LocalEmbedderHeapTracer; class LocalEmbedderHeapTracer;
class MicrotaskQueue; class MicrotaskQueue;
struct ScriptStreamingData;
template<typename T> class CustomArguments;
class PropertyCallbackArguments; class PropertyCallbackArguments;
class FunctionCallbackArguments; class ReadOnlyHeap;
class GlobalHandles;
class ScopedExternalStringLock; class ScopedExternalStringLock;
struct ScriptStreamingData;
class ThreadLocalTop; class ThreadLocalTop;
namespace wasm { namespace wasm {
...@@ -7557,6 +7559,7 @@ class V8_EXPORT SharedMemoryStatistics { ...@@ -7557,6 +7559,7 @@ class V8_EXPORT SharedMemoryStatistics {
size_t read_only_space_physical_size_; size_t read_only_space_physical_size_;
friend class V8; friend class V8;
friend class internal::ReadOnlyHeap;
}; };
/** /**
......
...@@ -5803,17 +5803,7 @@ void v8::V8::InitializeExternalStartupDataFromFile(const char* snapshot_blob) { ...@@ -5803,17 +5803,7 @@ void v8::V8::InitializeExternalStartupDataFromFile(const char* snapshot_blob) {
const char* v8::V8::GetVersion() { return i::Version::GetVersion(); } const char* v8::V8::GetVersion() { return i::Version::GetVersion(); }
void V8::GetSharedMemoryStatistics(SharedMemoryStatistics* statistics) { void V8::GetSharedMemoryStatistics(SharedMemoryStatistics* statistics) {
#ifdef V8_SHARED_RO_HEAP i::ReadOnlyHeap::PopulateReadOnlySpaceStatistics(statistics);
i::ReadOnlySpace* ro_space = i::ReadOnlyHeap::Instance()->read_only_space();
statistics->read_only_space_size_ = ro_space->CommittedMemory();
statistics->read_only_space_used_size_ = ro_space->SizeOfObjects();
statistics->read_only_space_physical_size_ =
ro_space->CommittedPhysicalMemory();
#else
statistics->read_only_space_size_ = 0;
statistics->read_only_space_used_size_ = 0;
statistics->read_only_space_physical_size_ = 0;
#endif // V8_SHARED_RO_HEAP
} }
template <typename ObjectType> template <typename ObjectType>
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <cstring> #include <cstring>
#include "include/v8.h"
#include "src/base/lazy-instance.h" #include "src/base/lazy-instance.h"
#include "src/base/lsan.h" #include "src/base/lsan.h"
#include "src/base/platform/mutex.h" #include "src/base/platform/mutex.h"
...@@ -160,10 +161,24 @@ void ReadOnlyHeap::OnHeapTearDown() { ...@@ -160,10 +161,24 @@ void ReadOnlyHeap::OnHeapTearDown() {
#endif #endif
} }
#ifdef V8_SHARED_RO_HEAP
// static // static
const ReadOnlyHeap* ReadOnlyHeap::Instance() { return shared_ro_heap_; } void ReadOnlyHeap::PopulateReadOnlySpaceStatistics(
#endif SharedMemoryStatistics* statistics) {
statistics->read_only_space_size_ = 0;
statistics->read_only_space_used_size_ = 0;
statistics->read_only_space_physical_size_ = 0;
#ifdef V8_SHARED_RO_HEAP
std::shared_ptr<ReadOnlyArtifacts> artifacts =
read_only_artifacts_.Get().lock();
if (artifacts) {
auto ro_space = artifacts->shared_read_only_space();
statistics->read_only_space_size_ = ro_space->CommittedMemory();
statistics->read_only_space_used_size_ = ro_space->SizeOfObjects();
statistics->read_only_space_physical_size_ =
ro_space->CommittedPhysicalMemory();
}
#endif // V8_SHARED_RO_HEAP
}
// static // static
bool ReadOnlyHeap::Contains(Address address) { bool ReadOnlyHeap::Contains(Address address) {
......
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
#include "src/roots/roots.h" #include "src/roots/roots.h"
namespace v8 { namespace v8 {
class SharedMemoryStatistics;
namespace internal { namespace internal {
class Isolate; class Isolate;
...@@ -47,10 +50,10 @@ class ReadOnlyHeap final { ...@@ -47,10 +50,10 @@ class ReadOnlyHeap final {
// Indicates that the current isolate no longer requires the read-only heap // Indicates that the current isolate no longer requires the read-only heap
// and it may be safely disposed of. // and it may be safely disposed of.
void OnHeapTearDown(); void OnHeapTearDown();
// If the read-only heap is shared, then populate |statistics| with its stats,
#ifdef V8_SHARED_RO_HEAP // otherwise the read-only heap stats are set to 0.
static const ReadOnlyHeap* Instance(); static void PopulateReadOnlySpaceStatistics(
#endif SharedMemoryStatistics* statistics);
// Returns whether the address is within the read-only space. // Returns whether the address is within the read-only space.
V8_EXPORT_PRIVATE static bool Contains(Address address); V8_EXPORT_PRIVATE static bool Contains(Address address);
......
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