dae308461c
This CL:
* Moves [Heap]/[SharedClassTable] from [Isolate] to [IsolateGroup], which
will make all isolates in the group use the same heap. The GC will use
the shared class table for object size information.
* Adds support for entering/leaving an isolate group as a helper thread
(e.g. via [Thread::EnterIsolateGroupAsHelper]). The current active
isolate group can be accessed via TLS `IsolateGroup::Current()` or
`Thread::isolate_group_`. When entering as a helper thread there will be
no current isolate.
* Changes the GC to use the above mechanism and ensures GC works without
a currently active isolate. The GC will use information purely available via
[IsolateGroup]. The GC will iterate all isolates within an isolate
group e.g. for scanning roots.
* Makes spawning of new isolates start in their own isolate group.
Once the isolate is fully functional it's heap will be merged into
the original isolate group
* Moves ApiState, containing persistent and weak persistent handles,
from [Isolate] to [IsolateGroup], plus adds appropriate locking.
Issue https://github.com/dart-lang/sdk/issues/36097
Change-Id: Ia8e1d8aa78750e8400864200f4825395a182c004
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126646
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
70 lines
2.1 KiB
C++
70 lines
2.1 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(IsolateGroup* isolate_group_of_interest,
|
|
ObjectPointerVisitor* visitor,
|
|
ValidationPolicy validate_frames);
|
|
|
|
void ReleaseStoreBuffers();
|
|
void AcquireMarkingStacks();
|
|
void ReleaseMarkingStacks();
|
|
|
|
#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_
|