diff --git a/include/cppgc/garbage-collected.h b/include/cppgc/garbage-collected.h index 75d127ee9c..6737c8be49 100644 --- a/include/cppgc/garbage-collected.h +++ b/include/cppgc/garbage-collected.h @@ -62,7 +62,8 @@ class GarbageCollected { // virtual destructor requires an unambiguous, accessible 'operator delete'. void operator delete(void*) { #ifdef V8_ENABLE_CHECKS - internal::Abort(); + internal::Fatal( + "Manually deleting a garbage collected object is not allowed"); #endif // V8_ENABLE_CHECKS } void operator delete[](void*) = delete; diff --git a/include/cppgc/platform.h b/include/cppgc/platform.h index 3276a26b65..5d5f8796ad 100644 --- a/include/cppgc/platform.h +++ b/include/cppgc/platform.h @@ -7,6 +7,7 @@ #include +#include "cppgc/source-location.h" #include "v8-platform.h" // NOLINT(build/include_directory) #include "v8config.h" // NOLINT(build/include_directory) @@ -145,7 +146,8 @@ V8_EXPORT void ShutdownProcess(); namespace internal { -V8_EXPORT void Abort(); +V8_EXPORT void Fatal(const std::string& reason = std::string(), + const SourceLocation& = SourceLocation::Current()); } // namespace internal diff --git a/src/heap/cppgc/platform.cc b/src/heap/cppgc/platform.cc index fd769ae469..ba5d2a18d0 100644 --- a/src/heap/cppgc/platform.cc +++ b/src/heap/cppgc/platform.cc @@ -16,7 +16,13 @@ namespace cppgc { namespace internal { -void Abort() { v8::base::OS::Abort(); } +void Fatal(const std::string& reason, const SourceLocation& loc) { +#ifdef DEBUG + V8_Fatal(loc.FileName(), static_cast(loc.Line()), "%s", reason.c_str()); +#else // !DEBUG + V8_Fatal("%s", reason.c_str()); +#endif // !DEBUG +} void FatalOutOfMemoryHandler::operator()(const std::string& reason, const SourceLocation& loc) const {