dart-sdk/runtime/vm/thread_registry.h
Slava Egorov 425a42e3be Revert "[vm, gc] Mark through new-space."
This reverts commit 5daaa7d9eb.

Reason for revert: internal crashes

Original change's description:
> [vm, gc] Mark through new-space.
>
>   - Initial and final marking no longer visit all of new-space, reducing the STW pause for major GC.
>   - A scavenge during concurrent marking must forward / filter objects in the marking worklist that are moved / collected, increasing the STW pause for minor GC.
>   - Unreachable intergenerational cycles and weak references are collected in the next mark-sweep instead of first requiring enough scavenges to promote the whole cycle or weak target into old-space.
>   - Artificial minor GCs are no longer needed to avoid memory leaks from back-to-back major GCs.
>   - reachabilityBarrier is now just a count of major GCs.
>
> TEST=ci
> Change-Id: I4a6a23273d8ecb78c640f054731d4ceb737bfc4d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325840
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

Change-Id: I8a50074db343c63c14f0487ae8b4f5fee2c4ae76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330720
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-10-18 07:47:39 +00:00

74 lines
2.3 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 group.
class ThreadRegistry {
public:
ThreadRegistry()
: threads_lock_(),
active_list_(nullptr),
free_list_(nullptr),
active_isolates_count_(0) {}
~ThreadRegistry();
void VisitObjectPointers(IsolateGroup* isolate_group_of_interest,
ObjectPointerVisitor* visitor,
ValidationPolicy validate_frames);
void ForEachThread(std::function<void(Thread* thread)> callback);
void ReleaseStoreBuffers();
void AcquireMarkingStacks();
void ReleaseMarkingStacks();
// Concurrent-approximate number of active isolates in the active_list
intptr_t active_isolates_count() { return active_isolates_count_.load(); }
Monitor* threads_lock() const { return &threads_lock_; }
#ifndef PRODUCT
void PrintJSON(JSONStream* stream) const;
#endif
private:
Thread* active_list() const { return active_list_; }
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.
RelaxedAtomic<intptr_t> active_isolates_count_;
friend class Thread;
friend class SafepointHandler;
DISALLOW_COPY_AND_ASSIGN(ThreadRegistry);
};
} // namespace dart
#endif // RUNTIME_VM_THREAD_REGISTRY_H_