Commit 47bfa8f7 authored by sigbjornf's avatar sigbjornf Committed by Commit bot

Statically disallow delete' over heap collection objects.

Explicitly deleting heap-allocated heap collection objects isn't
allowed nor meaningful, the garbage collector handles their lifetimes
precisely. The implementation of 'delete' over these collection objects
delegate to a allocator-trait class's free() method, so by not providing
it for heap collection objects, compilation fails if 'delete' is ever
attempted instantiated & used over these objects.

As MSVC performs method instantiation more eagerly, we're unable to
statically catch such inappropriate uses of 'delete' at compile time.
Rely on a run-time NOTREACHED() instead.

R=
BUG=

Review-Url: https://codereview.chromium.org/2021103002
Cr-Commit-Position: refs/heads/master@{#396788}
parent 8a5ede2a
......@@ -105,7 +105,20 @@ public:
{
return reinterpret_cast<Return>(ThreadHeap::allocate<Metadata>(size, IsEagerlyFinalizedType<Metadata>::value));
}
static void free(void* address) { }
#if OS(WIN) && COMPILER(MSVC)
// MSVC eagerly instantiates the unused 'operator delete',
// provide a version that asserts and fails at run-time if
// used.
// Elsewhere we expect compilation to fail if 'delete' is
// attempted used and instantiated with a HeapAllocator-based
// object, as HeapAllocator::free is not provided.
static void free(void*)
{
NOTREACHED();
}
#endif
template<typename T>
static void* newArray(size_t bytes)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment