mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[VM/Runtime] Inline first zone in a StackZone when we are not using
fibers. TEST=ci Change-Id: I1308b2450d77ac83c89208acb7d18ad1be5bdcbf Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243856 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Siva Annamalai <asiva@google.com>
This commit is contained in:
parent
df21baa407
commit
d856e058ea
|
@ -320,19 +320,25 @@ char* Zone::VPrint(const char* format, va_list args) {
|
|||
}
|
||||
|
||||
StackZone::StackZone(ThreadState* thread)
|
||||
#if defined(DART_USE_ABSL)
|
||||
// DART_USE_ABSL encodes the use of fibers in the Dart VM for threading.
|
||||
: StackResource(thread), zone_(new Zone()) {
|
||||
#else
|
||||
: StackResource(thread), zone_() {
|
||||
#endif // defined(DART_USE_ABSL)
|
||||
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>(GetZone()));
|
||||
}
|
||||
|
||||
// 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* lzone = GetZone();
|
||||
lzone->Link(thread->zone());
|
||||
thread->set_zone(lzone);
|
||||
}
|
||||
|
||||
StackZone::~StackZone() {
|
||||
|
@ -340,15 +346,19 @@ StackZone::~StackZone() {
|
|||
// chain of handle blocks we're about the mutate.
|
||||
ASSERT(Thread::Current()->MayAllocateHandles());
|
||||
|
||||
ASSERT(thread()->zone() == zone_);
|
||||
thread()->set_zone(zone_->previous_);
|
||||
Zone* lzone = GetZone();
|
||||
ASSERT(thread()->zone() == lzone);
|
||||
thread()->set_zone(lzone->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>(lzone));
|
||||
}
|
||||
|
||||
#if defined(DART_USE_ABSL)
|
||||
// DART_USE_ABSL encodes the use of fibers in the Dart VM for threading.
|
||||
delete zone_;
|
||||
#endif // defined(DART_USE_ABSL)
|
||||
}
|
||||
|
||||
} // namespace dart
|
||||
|
|
|
@ -192,6 +192,8 @@ class StackZone : public StackResource {
|
|||
// Delete all memory associated with the zone.
|
||||
virtual ~StackZone();
|
||||
|
||||
// DART_USE_ABSL encodes the use of fibers in the Dart VM for threading,
|
||||
#if defined(DART_USE_ABSL)
|
||||
// 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(); }
|
||||
|
@ -200,9 +202,34 @@ class StackZone : public StackResource {
|
|||
intptr_t CapacityInBytes() const { return zone_->CapacityInBytes(); }
|
||||
|
||||
Zone* GetZone() { return zone_; }
|
||||
#else
|
||||
// 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();
|
||||
}
|
||||
|
||||
// Computes the used space in the zone.
|
||||
intptr_t CapacityInBytes() const {
|
||||
return zone_.CapacityInBytes();
|
||||
}
|
||||
|
||||
Zone* GetZone() {
|
||||
return &zone_;
|
||||
}
|
||||
#endif // defined(DART_USE_ABSL)
|
||||
|
||||
private:
|
||||
#if defined(DART_USE_ABSL)
|
||||
// When fibers are used we have to make do with a smaller stack size and hence
|
||||
// the first zone is allocated instead of being a stack resource.
|
||||
Zone* zone_;
|
||||
#else
|
||||
// For regular configurations that have larger stack sizes it is ok to
|
||||
// have the first zone be a stack resource, avoids the overhead of a malloc
|
||||
// call for every stack zone creation.
|
||||
Zone zone_;
|
||||
#endif // defined(DART_USE_ABSL)
|
||||
|
||||
template <typename T>
|
||||
friend class GrowableArray;
|
||||
|
|
Loading…
Reference in a new issue