1// Copyright 2020 the V8 project authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef V8_HEAP_MEMORY_CHUNK_INL_H_ 6#define V8_HEAP_MEMORY_CHUNK_INL_H_ 7 8#include "src/heap/memory-chunk.h" 9#include "src/heap/spaces-inl.h" 10 11namespace v8 { 12namespace internal { 13 14void MemoryChunk::IncrementExternalBackingStoreBytes( 15 ExternalBackingStoreType type, size_t amount) { 16#ifndef V8_ENABLE_THIRD_PARTY_HEAP 17 base::CheckedIncrement(&external_backing_store_bytes_[type], amount); 18 owner()->IncrementExternalBackingStoreBytes(type, amount); 19#endif 20} 21 22void MemoryChunk::DecrementExternalBackingStoreBytes( 23 ExternalBackingStoreType type, size_t amount) { 24#ifndef V8_ENABLE_THIRD_PARTY_HEAP 25 base::CheckedDecrement(&external_backing_store_bytes_[type], amount); 26 owner()->DecrementExternalBackingStoreBytes(type, amount); 27#endif 28} 29 30void MemoryChunk::MoveExternalBackingStoreBytes(ExternalBackingStoreType type, 31 MemoryChunk* from, 32 MemoryChunk* to, 33 size_t amount) { 34 DCHECK_NOT_NULL(from->owner()); 35 DCHECK_NOT_NULL(to->owner()); 36 base::CheckedDecrement(&(from->external_backing_store_bytes_[type]), amount); 37 base::CheckedIncrement(&(to->external_backing_store_bytes_[type]), amount); 38 Space::MoveExternalBackingStoreBytes(type, from->owner(), to->owner(), 39 amount); 40} 41 42AllocationSpace MemoryChunk::owner_identity() const { 43 if (InReadOnlySpace()) return RO_SPACE; 44 return owner()->identity(); 45} 46 47} // namespace internal 48} // namespace v8 49 50#endif // V8_HEAP_MEMORY_CHUNK_INL_H_ 51