• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
11 namespace v8 {
12 namespace internal {
13 
IncrementExternalBackingStoreBytes(ExternalBackingStoreType type,size_t amount)14 void 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 
DecrementExternalBackingStoreBytes(ExternalBackingStoreType type,size_t amount)22 void 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 
MoveExternalBackingStoreBytes(ExternalBackingStoreType type,MemoryChunk * from,MemoryChunk * to,size_t amount)30 void 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 
owner_identity()42 AllocationSpace 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