dart-sdk/runtime/vm/thread_state.cc
Ryan Macnak fbcacd7c05 Reapply "[vm] Streamline Zones."
Fix imprecision in Zone::SizeInBytes that was finally noticed by vm/cc/AllocateZone because the size of the initial inline buffer changed.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/47399
Change-Id: I152d24d03a59b21267a9a24e5d929b51af57af71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215980
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-10-14 00:10:12 +00:00

73 lines
1.7 KiB
C++

// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "vm/thread_state.h"
#include "vm/handles_impl.h"
#include "vm/zone.h"
namespace dart {
ThreadState::ThreadState(bool is_os_thread) : BaseThread(is_os_thread) {}
ThreadState::~ThreadState() {}
bool ThreadState::ZoneIsOwnedByThread(Zone* zone) const {
ASSERT(zone != nullptr);
Zone* current = zone_;
while (current != nullptr) {
if (current == zone) {
return true;
}
current = current->previous();
}
return false;
}
bool ThreadState::IsValidZoneHandle(Dart_Handle object) const {
Zone* zone = this->zone();
while (zone != NULL) {
if (zone->handles()->IsValidZoneHandle(reinterpret_cast<uword>(object))) {
return true;
}
zone = zone->previous();
}
return false;
}
intptr_t ThreadState::CountZoneHandles() const {
intptr_t count = 0;
Zone* zone = this->zone();
while (zone != NULL) {
count += zone->handles()->CountZoneHandles();
zone = zone->previous();
}
ASSERT(count >= 0);
return count;
}
bool ThreadState::IsValidScopedHandle(Dart_Handle object) const {
Zone* zone = this->zone();
while (zone != NULL) {
if (zone->handles()->IsValidScopedHandle(reinterpret_cast<uword>(object))) {
return true;
}
zone = zone->previous();
}
return false;
}
intptr_t ThreadState::CountScopedHandles() const {
intptr_t count = 0;
Zone* zone = this->zone();
while (zone != NULL) {
count += zone->handles()->CountScopedHandles();
zone = zone->previous();
}
ASSERT(count >= 0);
return count;
}
} // namespace dart