mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
Outline the StackZone's Zone
Bug: https://github.com/dart-lang/sdk/issues/36100 Change-Id: I17cdf438c19fcc66ceb09c23348654eb752dd3cb Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103560 Commit-Queue: Liam Appelbe <liama@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
This commit is contained in:
parent
cd2188f2f5
commit
6e1f628f19
|
@ -331,19 +331,20 @@ char* Zone::VPrint(const char* format, va_list args) {
|
|||
return OS::VSCreate(this, format, args);
|
||||
}
|
||||
|
||||
StackZone::StackZone(ThreadState* thread) : StackResource(thread), zone_() {
|
||||
StackZone::StackZone(ThreadState* thread)
|
||||
: StackResource(thread), zone_(new Zone()) {
|
||||
if (FLAG_trace_zones) {
|
||||
OS::PrintErr("*** Starting a new Stack zone 0x%" Px "(0x%" Px ")\n",
|
||||
reinterpret_cast<intptr_t>(this),
|
||||
reinterpret_cast<intptr_t>(&zone_));
|
||||
reinterpret_cast<intptr_t>(zone_));
|
||||
}
|
||||
|
||||
// This thread must be preventing safepoints or the GC could be visiting the
|
||||
// chain of handle blocks we're about the mutate.
|
||||
ASSERT(Thread::Current()->MayAllocateHandles());
|
||||
|
||||
zone_.Link(thread->zone());
|
||||
thread->set_zone(&zone_);
|
||||
zone_->Link(thread->zone());
|
||||
thread->set_zone(zone_);
|
||||
}
|
||||
|
||||
StackZone::~StackZone() {
|
||||
|
@ -351,13 +352,15 @@ StackZone::~StackZone() {
|
|||
// chain of handle blocks we're about the mutate.
|
||||
ASSERT(Thread::Current()->MayAllocateHandles());
|
||||
|
||||
ASSERT(thread()->zone() == &zone_);
|
||||
thread()->set_zone(zone_.previous_);
|
||||
ASSERT(thread()->zone() == zone_);
|
||||
thread()->set_zone(zone_->previous_);
|
||||
if (FLAG_trace_zones) {
|
||||
OS::PrintErr("*** Deleting Stack zone 0x%" Px "(0x%" Px ")\n",
|
||||
reinterpret_cast<intptr_t>(this),
|
||||
reinterpret_cast<intptr_t>(&zone_));
|
||||
reinterpret_cast<intptr_t>(zone_));
|
||||
}
|
||||
|
||||
delete zone_;
|
||||
}
|
||||
|
||||
} // namespace dart
|
||||
|
|
|
@ -177,19 +177,19 @@ class StackZone : public StackResource {
|
|||
explicit StackZone(ThreadState* thread);
|
||||
|
||||
// Delete all memory associated with the zone.
|
||||
~StackZone();
|
||||
virtual ~StackZone();
|
||||
|
||||
// Compute the total size of this zone. This includes wasted space that is
|
||||
// due to internal fragmentation in the segments.
|
||||
uintptr_t SizeInBytes() const { return zone_.SizeInBytes(); }
|
||||
uintptr_t SizeInBytes() const { return zone_->SizeInBytes(); }
|
||||
|
||||
// Computes the used space in the zone.
|
||||
intptr_t CapacityInBytes() const { return zone_.CapacityInBytes(); }
|
||||
intptr_t CapacityInBytes() const { return zone_->CapacityInBytes(); }
|
||||
|
||||
Zone* GetZone() { return &zone_; }
|
||||
Zone* GetZone() { return zone_; }
|
||||
|
||||
private:
|
||||
Zone zone_;
|
||||
Zone* zone_;
|
||||
|
||||
template <typename T>
|
||||
friend class GrowableArray;
|
||||
|
|
Loading…
Reference in a new issue