1// Copyright 2019 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_THIRD_PARTY_HEAP_API_H_ 6#define V8_HEAP_THIRD_PARTY_HEAP_API_H_ 7 8#include "src/base/address-region.h" 9#include "src/heap/heap.h" 10 11namespace v8 { 12 13class Isolate; 14 15namespace internal { 16namespace third_party_heap { 17 18class Impl; 19 20class Heap { 21 public: 22 static std::unique_ptr<Heap> New(v8::internal::Isolate* isolate); 23 24 static v8::internal::Isolate* GetIsolate(Address address); 25 26 AllocationResult Allocate(size_t size_in_bytes, AllocationType type, 27 AllocationAlignment align); 28 29 Address GetObjectFromInnerPointer(Address inner_pointer); 30 31 const base::AddressRegion& GetCodeRange(); 32 33 bool IsPendingAllocation(HeapObject object); 34 35 static bool InSpace(Address address, AllocationSpace space); 36 37 static bool InOldSpace(Address address); 38 39 static bool InReadOnlySpace(Address address); 40 41 static bool InLargeObjectSpace(Address address); 42 43 static bool IsValidHeapObject(HeapObject object); 44 45 static bool IsImmovable(HeapObject object); 46 47 static bool IsValidCodeObject(HeapObject object); 48 49 void ResetIterator(); 50 HeapObject NextObject(); 51 52 bool CollectGarbage(); 53 54 size_t Capacity(); 55 56 V8_INLINE Impl* impl() { return impl_; } 57 58 private: 59 Impl* impl_ = nullptr; 60}; 61 62} // namespace third_party_heap 63} // namespace internal 64} // namespace v8 65 66#endif // V8_HEAP_THIRD_PARTY_HEAP_API_H_ 67