Files
sdk/runtime/vm/thread_registry.h
T
Ryan Macnak d36adbacaf [vm] Remove the VM isolate.
The former contents of the VM isolate are now included into each isolate group. This makes each isolate group's heap independent, and in particular allows each heap to be allocated to a separate pointer cage (not done in this CL).

The duplicated stubs that allowed PC relative calls are removed, since the originals can now be the target of PC relative calls.

The bootstrapping needing to load an AppJIT or AppAOT snapshot is reduced to allocating the oddballs. The code is entirely dropped in the AOT runtime, but the JIT runtime still has it to allow for flags to affect the compilation of the stub code. Further refactoring might be able to remove this for the JIT runtime too, with only gen_snapshot knowing how to bootstrap.

Class serialization no longer distinguishes predefined classes.

The page containing null is marked as never-evacuate. null, false and true must not move because the compiler relies on their low bits having certain patterns for some optimizations. (Previously, the entire VM isolate heap never moved.)

Compaction is disabled for IA32. Due to register pressure, some stub calls must not use a scratch register and embed the address of Code.

The page containing the call-through-safepoint stub is frozen when running with --write-protect-code and the stub is created at runtime (instead of loaded from an AppJIT or AppAOT snapshot). This stub must remain executable even during a safepoint, as a foreign call might during return during a safepoint and only block after the stub directs it to the runtime.

The snapshot symbols are renamed to kDartSnapshotData and kDartSnapshotText. There is no need to distinguish the VM isolate's snapshot, and snaphots are per isolate group not per isolate. Aliases with the old names are added to ease migration.

Some global flags that were automatically set based on the VM isolate's snapshot are now isolate group flags and automatically set by the isolate group's snapshot.

TEST=ci
Change-Id: Iee82016057d609112e9b021d178fc3d4d18b5044
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500621
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-18 11:35:03 -07:00

77 lines
2.4 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();
void FlushMarkingStacks();
intptr_t StealActiveMutators(ThreadPool* pool);
// 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_bootstrapping);
void ReturnThreadLocked(Thread* thread);
void AddToActiveListLocked(Thread* thread);
void RemoveFromActiveListLocked(Thread* thread);
Thread* GetFromFreelistLocked(bool is_bootstrapping);
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_