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 {
enum class ArgumentsType;
template <ArgumentsType>
class Arguments;
template <typename T>
class CustomArguments;
class DeferredHandles;
class FunctionCallbackArguments;
class GlobalHandles;
class Heap;
class HeapObject;
class ExternalString;
class Isolate;
class LocalEmbedderHeapTracer;
class MicrotaskQueue;
struct ScriptStreamingData;
template<typename T> class CustomArguments;
class PropertyCallbackArguments;
class FunctionCallbackArguments;
class GlobalHandles;
class ReadOnlyHeap;
class ScopedExternalStringLock;
struct ScriptStreamingData;
class ThreadLocalTop;
namespace wasm {
......@@ -7557,6 +7559,7 @@ class V8_EXPORT SharedMemoryStatistics {
size_t read_only_space_physical_size_;
friend class V8;
friend class internal::ReadOnlyHeap;
};
/**
......
......@@ -5803,17 +5803,7 @@ void v8::V8::InitializeExternalStartupDataFromFile(const char* snapshot_blob) {
const char* v8::V8::GetVersion() { return i::Version::GetVersion(); }
void V8::GetSharedMemoryStatistics(SharedMemoryStatistics* statistics) {
#ifdef V8_SHARED_RO_HEAP
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
i::ReadOnlyHeap::PopulateReadOnlySpaceStatistics(statistics);
}
template <typename ObjectType>
......
......@@ -6,6 +6,7 @@
#include <cstring>
#include "include/v8.h"
#include "src/base/lazy-instance.h"
#include "src/base/lsan.h"
#include "src/base/platform/mutex.h"
......@@ -160,10 +161,24 @@ void ReadOnlyHeap::OnHeapTearDown() {
#endif
}
#ifdef V8_SHARED_RO_HEAP
// static
const ReadOnlyHeap* ReadOnlyHeap::Instance() { return shared_ro_heap_; }
#endif
void ReadOnlyHeap::PopulateReadOnlySpaceStatistics(
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
bool ReadOnlyHeap::Contains(Address address) {
......
......@@ -15,6 +15,9 @@
#include "src/roots/roots.h"
namespace v8 {
class SharedMemoryStatistics;
namespace internal {
class Isolate;
......@@ -47,10 +50,10 @@ class ReadOnlyHeap final {
// Indicates that the current isolate no longer requires the read-only heap
// and it may be safely disposed of.
void OnHeapTearDown();
#ifdef V8_SHARED_RO_HEAP
static const ReadOnlyHeap* Instance();
#endif
// If the read-only heap is shared, then populate |statistics| with its stats,
// otherwise the read-only heap stats are set to 0.
static void PopulateReadOnlySpaceStatistics(
SharedMemoryStatistics* statistics);
// Returns whether the address is within the read-only space.
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