mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
![Martin Kustermann](/assets/img/avatar_default.png)
This CL moves the thread registry and the safepoint handler to the [IsolateGroup]. This will cause all threads belonging to the isolate group to safepoint together. => We will therefore start to get an idea of the impact this will have on pause times. So far it was only possible to enter a particular isolate (e.g. as mutator thread or auxiliary thread). This CL adds support for entering an isolate group (instead of a particular isolate) as an auxiliarly thread. The current isolate group is available via `IsolateGroup::Current()`. => This is a preparation step to let GC threads enter the isolate group as auxiliary threads, not associated with a particular isolate but to an isolate group as a whole. Issue https://github.com/dart-lang/sdk/issues/36097 Change-Id: I7069d07130938d370869f02060570143bfeb1b48 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108801 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Martin Kustermann <kustermann@google.com>
70 lines
2.2 KiB
C++
70 lines
2.2 KiB
C++
// Copyright (c) 2015, 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.
|
|
|
|
#ifndef RUNTIME_VM_THREAD_REGISTRY_H_
|
|
#define RUNTIME_VM_THREAD_REGISTRY_H_
|
|
|
|
#include "vm/globals.h"
|
|
#include "vm/growable_array.h"
|
|
#include "vm/isolate.h"
|
|
#include "vm/lockers.h"
|
|
#include "vm/stack_frame.h"
|
|
#include "vm/thread.h"
|
|
|
|
namespace dart {
|
|
|
|
#ifndef PRODUCT
|
|
class JSONStream;
|
|
class JSONArray;
|
|
#endif
|
|
|
|
// Unordered collection of threads relating to a particular isolate.
|
|
class ThreadRegistry {
|
|
public:
|
|
ThreadRegistry() : threads_lock_(), active_list_(NULL), free_list_(NULL) {}
|
|
~ThreadRegistry();
|
|
|
|
void VisitObjectPointers(Isolate* isolate_of_interest,
|
|
ObjectPointerVisitor* visitor,
|
|
ValidationPolicy validate_frames);
|
|
|
|
void ReleaseStoreBuffers(Isolate* isolate_of_interest);
|
|
void AcquireMarkingStacks(Isolate* isolate_of_interest);
|
|
void ReleaseMarkingStacks(Isolate* isolate_of_interest);
|
|
|
|
#ifndef PRODUCT
|
|
void PrintJSON(JSONStream* stream) const;
|
|
#endif
|
|
|
|
intptr_t CountZoneHandles(Isolate* isolate_of_interest) const;
|
|
intptr_t CountScopedHandles(Isolate* isolate_of_interest) const;
|
|
|
|
private:
|
|
Thread* active_list() const { return active_list_; }
|
|
Monitor* threads_lock() const { return &threads_lock_; }
|
|
|
|
Thread* GetFreeThreadLocked(bool is_vm_isolate);
|
|
void ReturnThreadLocked(Thread* thread);
|
|
void AddToActiveListLocked(Thread* thread);
|
|
void RemoveFromActiveListLocked(Thread* thread);
|
|
Thread* GetFromFreelistLocked(bool is_vm_isolate);
|
|
void ReturnToFreelistLocked(Thread* thread);
|
|
|
|
// This monitor protects the threads list for an isolate, it is used whenever
|
|
// we need to iterate over threads (both active and free) in an isolate.
|
|
mutable Monitor threads_lock_;
|
|
Thread* active_list_; // List of active threads in the isolate.
|
|
Thread* free_list_; // Free list of Thread objects that can be reused.
|
|
|
|
friend class Isolate;
|
|
friend class IsolateGroup;
|
|
friend class SafepointHandler;
|
|
friend class Scavenger;
|
|
DISALLOW_COPY_AND_ASSIGN(ThreadRegistry);
|
|
};
|
|
|
|
} // namespace dart
|
|
|
|
#endif // RUNTIME_VM_THREAD_REGISTRY_H_
|