diff --git a/runtime/vm/allocation.h b/runtime/vm/allocation.h index fc4be724ad7..fd1bdfa26a4 100644 --- a/runtime/vm/allocation.h +++ b/runtime/vm/allocation.h @@ -75,4 +75,8 @@ class ZoneAllocated { } // namespace dart +// Prevent use of `new (zone) DoesNotExtendZoneAllocated()`, which places the +// DoesNotExtendZoneAllocated on top of the Zone. +void* operator new(size_t size, dart::Zone* zone) = delete; + #endif // RUNTIME_VM_ALLOCATION_H_ diff --git a/runtime/vm/zone.cc b/runtime/vm/zone.cc index 744c8a5425f..5fa1efc2691 100644 --- a/runtime/vm/zone.cc +++ b/runtime/vm/zone.cc @@ -163,8 +163,7 @@ void Zone::Segment::DecrementMemoryCapacity(uintptr_t size) { // is created within a new thread or ApiNativeScope when calculating high // watermarks or memory consumption. Zone::Zone() - : canary_(kCanary), - position_(reinterpret_cast(&buffer_)), + : position_(reinterpret_cast(&buffer_)), limit_(position_ + kInitialChunkSize), head_(NULL), large_segments_(NULL), @@ -179,7 +178,6 @@ Zone::Zone() } Zone::~Zone() { - ASSERT(canary_ == kCanary); if (FLAG_trace_zones) { DumpZoneSizes(); } diff --git a/runtime/vm/zone.h b/runtime/vm/zone.h index e4a00309db1..b30f446d121 100644 --- a/runtime/vm/zone.h +++ b/runtime/vm/zone.h @@ -141,10 +141,6 @@ class Zone { template static inline void CheckLength(intptr_t len); - // Guard against `new (zone) DoesNotExtendZoneAllocated()`. - static constexpr uint64_t kCanary = 0x656e6f7a74726164ull; // "dartzone" - uint64_t canary_; - // The free region in the current (head) segment or the initial buffer is // represented as the half-open interval [position, limit). The 'position' // variable is guaranteed to be aligned as dictated by kAlignment.