Flutter Engine
The Flutter Engine
thread_state.cc
Go to the documentation of this file.
1// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#include "vm/thread_state.h"
6
7#include "vm/handles_impl.h"
8#include "vm/zone.h"
9
10namespace dart {
11
12ThreadState::ThreadState(bool is_os_thread) : BaseThread(is_os_thread) {}
13
15
17 ASSERT(zone != nullptr);
18 Zone* current = zone_;
19 while (current != nullptr) {
20 if (current == zone) {
21 return true;
22 }
23 current = current->previous();
24 }
25 return false;
26}
27
29 Zone* zone = this->zone();
30 while (zone != nullptr) {
31 if (zone->handles()->IsValidZoneHandle(reinterpret_cast<uword>(object))) {
32 return true;
33 }
34 zone = zone->previous();
35 }
36 return false;
37}
38
40 intptr_t count = 0;
41 Zone* zone = this->zone();
42 while (zone != nullptr) {
44 zone = zone->previous();
45 }
46 ASSERT(count >= 0);
47 return count;
48}
49
51 Zone* zone = this->zone();
52 while (zone != nullptr) {
53 if (zone->handles()->IsValidScopedHandle(reinterpret_cast<uword>(object))) {
54 return true;
55 }
56 zone = zone->previous();
57 }
58 return false;
59}
60
62 intptr_t count = 0;
63 Zone* zone = this->zone();
64 while (zone != nullptr) {
66 zone = zone->previous();
67 }
68 ASSERT(count >= 0);
69 return count;
70}
71
72} // namespace dart
int count
Definition: FontMgrTest.cpp:50
friend class ThreadState
Definition: os_thread.h:79
int CountZoneHandles() const
Definition: handles_impl.h:228
bool IsValidZoneHandle(uword handle) const
Definition: handles_impl.h:188
int CountScopedHandles() const
Definition: handles_impl.h:212
bool IsValidScopedHandle(uword handle) const
Definition: handles_impl.h:175
bool ZoneIsOwnedByThread(Zone *zone) const
Definition: thread_state.cc:16
Zone * zone() const
Definition: thread_state.h:37
bool IsValidZoneHandle(Dart_Handle object) const
Definition: thread_state.cc:28
virtual ~ThreadState()
Definition: thread_state.cc:14
bool IsValidScopedHandle(Dart_Handle object) const
Definition: thread_state.cc:50
intptr_t CountScopedHandles() const
Definition: thread_state.cc:61
intptr_t CountZoneHandles() const
Definition: thread_state.cc:39
VMHandles * handles()
Definition: zone.h:73
Zone * previous() const
Definition: zone.h:77
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
#define ASSERT(E)
Definition: dart_vm.cc:33
uintptr_t uword
Definition: globals.h:501