@@ -51,8 +51,25 @@ enum class AllocationStatus {
5151 kOtherFailure // Failed for an unknown reason
5252};
5353
54- size_t GetReservationSize (bool has_guard_regions, size_t byte_capacity,
55- bool is_wasm_memory64) {
54+ base::AddressRegion GetReservedRegion (bool has_guard_regions,
55+ bool is_wasm_memory64, void * buffer_start,
56+ size_t byte_capacity) {
57+ return base::AddressRegion (
58+ reinterpret_cast <Address>(buffer_start),
59+ BackingStore::GetWasmReservationSize (has_guard_regions, byte_capacity,
60+ is_wasm_memory64));
61+ }
62+
63+ void RecordStatus (Isolate* isolate, AllocationStatus status) {
64+ isolate->counters ()->wasm_memory_allocation_result ()->AddSample (
65+ static_cast <int >(status));
66+ }
67+
68+ } // namespace
69+
70+ size_t BackingStore::GetWasmReservationSize (bool has_guard_regions,
71+ size_t byte_capacity,
72+ bool is_wasm_memory64) {
5673#if V8_TARGET_ARCH_64_BIT && V8_ENABLE_WEBASSEMBLY
5774 DCHECK_IMPLIES (is_wasm_memory64 && has_guard_regions,
5875 v8_flags.wasm_memory64_trap_handling );
@@ -73,21 +90,6 @@ size_t GetReservationSize(bool has_guard_regions, size_t byte_capacity,
7390 return byte_capacity;
7491}
7592
76- base::AddressRegion GetReservedRegion (bool has_guard_regions,
77- bool is_wasm_memory64, void * buffer_start,
78- size_t byte_capacity) {
79- return base::AddressRegion (
80- reinterpret_cast <Address>(buffer_start),
81- GetReservationSize (has_guard_regions, byte_capacity, is_wasm_memory64));
82- }
83-
84- void RecordStatus (Isolate* isolate, AllocationStatus status) {
85- isolate->counters ()->wasm_memory_allocation_result ()->AddSample (
86- static_cast <int >(status));
87- }
88-
89- } // namespace
90-
9193// The backing store for a Wasm shared memory remembers all the isolates
9294// with which it has been shared.
9395struct SharedWasmMemoryData {
@@ -169,7 +171,7 @@ BackingStore::~BackingStore() {
169171
170172#if V8_ENABLE_WEBASSEMBLY
171173 if (is_wasm_memory ()) {
172- size_t reservation_size = GetReservationSize (
174+ size_t reservation_size = GetWasmReservationSize (
173175 has_guard_regions (), byte_capacity_, is_wasm_memory64 ());
174176 TRACE_BS (
175177 " BSw:free bs=%p mem=%p (length=%zu, capacity=%zu, reservation=%zu)\n " ,
@@ -319,8 +321,8 @@ std::unique_ptr<BackingStore> BackingStore::TryAllocateAndPartiallyCommitMemory(
319321 };
320322
321323 size_t byte_capacity = maximum_pages * page_size;
322- size_t reservation_size =
323- GetReservationSize ( has_guard_regions, byte_capacity, is_wasm_memory64);
324+ size_t reservation_size = GetWasmReservationSize (
325+ has_guard_regions, byte_capacity, is_wasm_memory64);
324326
325327 // --------------------------------------------------------------------------
326328 // Allocate pages (inaccessible by default).
0 commit comments