#ifndef V8_HEAP_CPPGC_PLATFORM_H_
#define V8_HEAP_CPPGC_PLATFORM_H_
#include <string>
#include "include/cppgc/platform.h"
#include "include/cppgc/source-location.h"
#include "src/base/macros.h"
namespace cppgc::internal {
class HeapBase;
class V8_EXPORT_PRIVATE FatalOutOfMemoryHandler final {
public:
using Callback = void(const std::string&, SourceLocation, HeapBase*);
FatalOutOfMemoryHandler() = default;
explicit FatalOutOfMemoryHandler(HeapBase* heap) : heap_(heap) {}
[[noreturn]] void operator()(
const std::string& reason = std::string(),
SourceLocation = SourceLocation::Current()) const;
void SetCustomHandler(Callback*);
FatalOutOfMemoryHandler(const FatalOutOfMemoryHandler&) = delete;
FatalOutOfMemoryHandler& operator=(const FatalOutOfMemoryHandler&) = delete;
private:
HeapBase* heap_ = nullptr;
Callback* custom_handler_ = nullptr;
};
FatalOutOfMemoryHandler& GetGlobalOOMHandler();
PageAllocator& GetGlobalPageAllocator();
}
#endif