[vm] Globally intercept new (zone) DoesNotExtendZoneAllocated().

Cf. 479430235c

TEST=ci
Change-Id: Ice55e5083096591b1c7e1243a12ea4aa160efb0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209740
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
This commit is contained in:
Ryan Macnak 2021-08-10 21:10:01 +00:00 committed by commit-bot@chromium.org
parent f21c9d54ea
commit ae0880a5c0
3 changed files with 5 additions and 7 deletions

View file

@ -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_

View file

@ -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<uword>(&buffer_)),
: position_(reinterpret_cast<uword>(&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();
}

View file

@ -141,10 +141,6 @@ class Zone {
template <class ElementType>
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.