Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
dart::IsolateGroup Class Reference

#include <isolate.h>

Inheritance diagram for dart::IsolateGroup:
dart::IntrusiveDListEntry< IsolateGroup >

Public Member Functions

 IsolateGroup (std::shared_ptr< IsolateGroupSource > source, void *embedder_data, ObjectStore *object_store, Dart_IsolateFlags api_flags, bool is_vm_isolate)
 
 IsolateGroup (std::shared_ptr< IsolateGroupSource > source, void *embedder_data, Dart_IsolateFlags api_flags, bool is_vm_isolate)
 
 ~IsolateGroup ()
 
void RehashConstants (Become *become)
 
IsolateGroupSourcesource () const
 
std::shared_ptr< IsolateGroupSourceshareable_source () const
 
bool is_vm_isolate () const
 
void * embedder_data () const
 
bool initial_spawn_successful ()
 
void set_initial_spawn_successful ()
 
Heapheap () const
 
BackgroundCompilerbackground_compiler () const
 
intptr_t optimization_counter_threshold () const
 
GroupDebuggerdebugger () const
 
IdleTimeHandleridle_time_handler ()
 
void RegisterIsolate (Isolate *isolate)
 
void UnregisterIsolate (Isolate *isolate)
 
bool UnregisterIsolateDecrementCount ()
 
bool ContainsOnlyOneIsolate ()
 
void RunWithLockedGroup (std::function< void()> fun)
 
void ScheduleInterrupts (uword interrupt_bits)
 
ThreadRegistrythread_registry () const
 
SafepointHandlersafepoint_handler ()
 
void CreateHeap (bool is_vm_isolate, bool is_service_or_kernel_isolate)
 
void SetupImagePage (const uint8_t *snapshot_buffer, bool is_executable)
 
void Shutdown ()
 
 ISOLATE_GROUP_METRIC_LIST (ISOLATE_METRIC_ACCESSOR)
 
void UpdateLastAllocationProfileAccumulatorResetTimestamp ()
 
int64_t last_allocationprofile_accumulator_reset_timestamp () const
 
void UpdateLastAllocationProfileGCTimestamp ()
 
int64_t last_allocationprofile_gc_timestamp () const
 
DispatchTabledispatch_table () const
 
void set_dispatch_table (DispatchTable *table)
 
const uint8_t * dispatch_table_snapshot () const
 
void set_dispatch_table_snapshot (const uint8_t *snapshot)
 
intptr_t dispatch_table_snapshot_size () const
 
void set_dispatch_table_snapshot_size (intptr_t size)
 
ClassTableAllocatorclass_table_allocator ()
 
ClassPtr * cached_class_table_table ()
 
void set_cached_class_table_table (ClassPtr *cached_class_table_table)
 
void set_object_store (ObjectStore *object_store)
 
void set_obfuscation_map (const char **map)
 
const char ** obfuscation_map () const
 
Randomrandom ()
 
bool is_system_isolate_group () const
 
void FlagsCopyTo (Dart_IsolateFlags *api_flags)
 
void FlagsCopyFrom (const Dart_IsolateFlags &api_flags)
 
bool should_load_vmservice () const
 
void set_should_load_vmservice (bool value)
 
void set_asserts (bool value)
 
void set_branch_coverage (bool value)
 
bool HasAttemptedReload () const
 
void SetHasAttemptedReload (bool value)
 
void MaybeIncreaseReloadEveryNStackOverflowChecks ()
 
intptr_t reload_every_n_stack_overflow_checks () const
 
void set_use_osr (bool use_osr)
 
ClassTableclass_table () const
 
ClassTableheap_walk_class_table () const
 
void CloneClassTableForReload ()
 
void RestoreOriginalClassTable ()
 
void DropOriginalClassTable ()
 
StoreBufferstore_buffer () const
 
ObjectStoreobject_store () const
 
Mutexsymbols_mutex ()
 
Mutextype_canonicalization_mutex ()
 
Mutextype_arguments_canonicalization_mutex ()
 
Mutexsubtype_test_cache_mutex ()
 
Mutexmegamorphic_table_mutex ()
 
Mutextype_feedback_mutex ()
 
Mutexpatchable_call_mutex ()
 
Mutexconstant_canonicalization_mutex ()
 
Mutexkernel_data_lib_cache_mutex ()
 
Mutexkernel_data_class_cache_mutex ()
 
Mutexkernel_constants_mutex ()
 
Mutexinitializer_functions_mutex ()
 
SafepointRwLockprogram_lock ()
 
void IncreaseMutatorCount (Isolate *mutator, bool is_nested_reenter)
 
void DecreaseMutatorCount (Isolate *mutator, bool is_nested_exit)
 
intptr_t MutatorCount () const
 
bool HasTagHandler () const
 
ObjectPtr CallTagHandler (Dart_LibraryTag tag, const Object &arg1, const Object &arg2)
 
Dart_LibraryTagHandler library_tag_handler () const
 
void set_library_tag_handler (Dart_LibraryTagHandler handler)
 
Dart_DeferredLoadHandler deferred_load_handler () const
 
void set_deferred_load_handler (Dart_DeferredLoadHandler handler)
 
void ReleaseStoreBuffers ()
 
void FlushMarkingStacks ()
 
void EnableIncrementalBarrier (MarkingStack *marking_stack, MarkingStack *deferred_marking_stack)
 
void DisableIncrementalBarrier ()
 
MarkingStackmarking_stack () const
 
MarkingStackdeferred_marking_stack () const
 
void ForEachIsolate (std::function< void(Isolate *isolate)> function, bool at_safepoint=false)
 
IsolateFirstIsolate () const
 
IsolateFirstIsolateLocked () const
 
void RunWithStoppedMutatorsCallable (Callable *single_current_mutator, Callable *otherwise, bool use_force_growth_in_otherwise=false)
 
template<typename T , typename S >
void RunWithStoppedMutators (T single_current_mutator, S otherwise, bool use_force_growth_in_otherwise=false)
 
template<typename T >
void RunWithStoppedMutators (T function, bool use_force_growth=false)
 
void PrintJSON (JSONStream *stream, bool ref=true)
 
void PrintToJSONObject (JSONObject *jsobj, bool ref)
 
void PrintMemoryUsageJSON (JSONStream *stream)
 
bool ReloadSources (JSONStream *js, bool force_reload, const char *root_script_url=nullptr, const char *packages_url=nullptr, bool dont_delete_reload_context=false)
 
bool ReloadKernel (JSONStream *js, bool force_reload, const uint8_t *kernel_buffer=nullptr, intptr_t kernel_buffer_size=0, bool dont_delete_reload_context=false)
 
void set_last_reload_timestamp (int64_t value)
 
int64_t last_reload_timestamp () const
 
IsolateGroupReloadContextreload_context ()
 
ProgramReloadContextprogram_reload_context ()
 
void DeleteReloadContext ()
 
bool CanReload ()
 
bool IsReloading () const
 
Becomebecome () const
 
void set_become (Become *become)
 
uint64_t id () const
 
int64_t UptimeMicros () const
 
ApiStateapi_state () const
 
void VisitObjectPointers (ObjectPointerVisitor *visitor, ValidationPolicy validate_frames)
 
void VisitSharedPointers (ObjectPointerVisitor *visitor)
 
void VisitStackPointers (ObjectPointerVisitor *visitor, ValidationPolicy validate_frames)
 
void VisitObjectIdRingPointers (ObjectPointerVisitor *visitor)
 
void VisitWeakPersistentHandles (HandleVisitor *visitor)
 
bool all_classes_finalized () const
 
void set_all_classes_finalized (bool value)
 
bool remapping_cids () const
 
void set_remapping_cids (bool value)
 
void RememberLiveTemporaries ()
 
void DeferredMarkLiveTemporaries ()
 
ArrayPtr saved_unlinked_calls () const
 
void set_saved_unlinked_calls (const Array &saved_unlinked_calls)
 
FieldTableinitial_field_table () const
 
std::shared_ptr< FieldTableinitial_field_table_shareable ()
 
void set_initial_field_table (std::shared_ptr< FieldTable > field_table)
 
MutatorThreadPoolthread_pool ()
 
void RegisterClass (const Class &cls)
 
void RegisterStaticField (const Field &field, const Object &initial_value)
 
void FreeStaticField (const Field &field)
 
IsolateEnterTemporaryIsolate ()
 
- Public Member Functions inherited from dart::IntrusiveDListEntry< IsolateGroup >
 IntrusiveDListEntry ()
 
 ~IntrusiveDListEntry ()
 

Static Public Member Functions

static intptr_t class_table_offset ()
 
static intptr_t cached_class_table_table_offset ()
 
static intptr_t object_store_offset ()
 
static void FlagsInitialize (Dart_IsolateFlags *api_flags)
 
static IsolateGroupCurrent ()
 
static void Init ()
 
static void Cleanup ()
 
static void ForEach (std::function< void(IsolateGroup *)> action)
 
static void RunWithIsolateGroup (uint64_t id, std::function< void(IsolateGroup *)> action, std::function< void()> not_found)
 
static void RegisterIsolateGroup (IsolateGroup *isolate_group)
 
static void UnregisterIsolateGroup (IsolateGroup *isolate_group)
 
static bool HasApplicationIsolateGroups ()
 
static bool HasOnlyVMIsolateGroup ()
 
static bool IsSystemIsolateGroup (const IsolateGroup *group)
 
static void ExitTemporaryIsolate ()
 

Friends

class Dart
 
class Heap
 
class StackFrame
 
class Isolate
 

Detailed Description

Definition at line 267 of file isolate.h.

Constructor & Destructor Documentation

◆ IsolateGroup() [1/2]

dart::IsolateGroup::IsolateGroup ( std::shared_ptr< IsolateGroupSource source,
void *  embedder_data,
ObjectStore object_store,
Dart_IsolateFlags  api_flags,
bool  is_vm_isolate 
)

Definition at line 325 of file isolate.cc.

330 : class_table_(nullptr),
331 cached_class_table_table_(nullptr),
332 object_store_(object_store),
333 class_table_allocator_(),
334 is_vm_isolate_(is_vm_isolate),
335 embedder_data_(embedder_data),
336 thread_pool_(),
337 isolates_lock_(new SafepointRwLock()),
338 isolates_(),
339 start_time_micros_(OS::GetCurrentMonotonicMicros()),
340 is_system_isolate_group_(source->flags.is_system_isolate),
341 random_(),
342#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
343 last_reload_timestamp_(OS::GetCurrentTimeMillis()),
344 reload_every_n_stack_overflow_checks_(FLAG_reload_every),
345#endif
346 source_(std::move(source)),
347 api_state_(new ApiState()),
348 thread_registry_(new ThreadRegistry()),
349 safepoint_handler_(new SafepointHandler(this)),
350 store_buffer_(new StoreBuffer()),
351 heap_(nullptr),
352 saved_unlinked_calls_(Array::null()),
353 initial_field_table_(new FieldTable(/*isolate=*/nullptr)),
354#if !defined(DART_PRECOMPILED_RUNTIME)
355 background_compiler_(new BackgroundCompiler(this)),
356#endif
357 symbols_mutex_(NOT_IN_PRODUCT("IsolateGroup::symbols_mutex_")),
358 type_canonicalization_mutex_(
359 NOT_IN_PRODUCT("IsolateGroup::type_canonicalization_mutex_")),
360 type_arguments_canonicalization_mutex_(NOT_IN_PRODUCT(
361 "IsolateGroup::type_arguments_canonicalization_mutex_")),
362 subtype_test_cache_mutex_(
363 NOT_IN_PRODUCT("IsolateGroup::subtype_test_cache_mutex_")),
364 megamorphic_table_mutex_(
365 NOT_IN_PRODUCT("IsolateGroup::megamorphic_table_mutex_")),
366 type_feedback_mutex_(
367 NOT_IN_PRODUCT("IsolateGroup::type_feedback_mutex_")),
368 patchable_call_mutex_(
369 NOT_IN_PRODUCT("IsolateGroup::patchable_call_mutex_")),
370 constant_canonicalization_mutex_(
371 NOT_IN_PRODUCT("IsolateGroup::constant_canonicalization_mutex_")),
372 kernel_data_lib_cache_mutex_(
373 NOT_IN_PRODUCT("IsolateGroup::kernel_data_lib_cache_mutex_")),
374 kernel_data_class_cache_mutex_(
375 NOT_IN_PRODUCT("IsolateGroup::kernel_data_class_cache_mutex_")),
376 kernel_constants_mutex_(
377 NOT_IN_PRODUCT("IsolateGroup::kernel_constants_mutex_")),
378 field_list_mutex_(NOT_IN_PRODUCT("Isolate::field_list_mutex_")),
379 boxed_field_list_(GrowableObjectArray::null()),
380 program_lock_(new SafepointRwLock()),
381 active_mutators_monitor_(new Monitor()),
382 max_active_mutators_(Scavenger::MaxMutatorThreadCount())
383#if !defined(PRODUCT)
384 ,
385 debugger_(new GroupDebugger(this))
386#endif
387{
388 FlagsCopyFrom(api_flags);
389 if (!is_vm_isolate) {
390 thread_pool_.reset(
391 new MutatorThreadPool(this, FLAG_disable_thread_pool_limit
392 ? 0
393 : Scavenger::MaxMutatorThreadCount()));
394 }
395 {
396 WriteRwLocker wl(ThreadState::Current(), isolate_groups_rwlock_);
397 // Keep isolate IDs less than 2^53 so web clients of the service
398 // protocol can process it properly.
399 //
400 // See https://github.com/dart-lang/sdk/issues/53081.
401 id_ = isolate_group_random_->NextJSInt();
402 }
403 heap_walk_class_table_ = class_table_ =
404 new ClassTable(&class_table_allocator_);
405 cached_class_table_table_.store(class_table_->table());
406}
void store(T arg, std::memory_order order=std::memory_order_release)
Definition atomic.h:104
Dart_IsolateFlags flags
Definition isolate.h:196
void * embedder_data() const
Definition isolate.h:290
void FlagsCopyFrom(const Dart_IsolateFlags &api_flags)
Definition isolate.cc:1586
ObjectStore * object_store() const
Definition isolate.h:505
IsolateGroupSource * source() const
Definition isolate.h:285
bool is_vm_isolate() const
Definition isolate.h:289
static int64_t GetCurrentTimeMillis()
static int64_t GetCurrentMonotonicMicros()
static ObjectPtr null()
Definition object.h:433
uint64_t NextJSInt()
Definition random.h:37
static intptr_t MaxMutatorThreadCount()
Definition scavenger.h:228
static ThreadState * Current()
#define NOT_IN_PRODUCT(code)
Definition globals.h:84

◆ IsolateGroup() [2/2]

dart::IsolateGroup::IsolateGroup ( std::shared_ptr< IsolateGroupSource source,
void *  embedder_data,
Dart_IsolateFlags  api_flags,
bool  is_vm_isolate 
)

Definition at line 408 of file isolate.cc.

414 new ObjectStore(),
415 api_flags,
417 if (object_store() != nullptr) {
419 }
420}
IsolateGroup(std::shared_ptr< IsolateGroupSource > source, void *embedder_data, ObjectStore *object_store, Dart_IsolateFlags api_flags, bool is_vm_isolate)
Definition isolate.cc:325

◆ ~IsolateGroup()

dart::IsolateGroup::~IsolateGroup ( )

Definition at line 422 of file isolate.cc.

422 {
423 // Ensure we destroy the heap before the other members.
424 heap_ = nullptr;
425 ASSERT(marking_stack_ == nullptr);
426
427 if (obfuscation_map_ != nullptr) {
428 for (intptr_t i = 0; obfuscation_map_[i] != nullptr; i++) {
429 delete[] obfuscation_map_[i];
430 }
431 delete[] obfuscation_map_;
432 }
433
434 class_table_allocator_.Free(class_table_);
435 if (heap_walk_class_table_ != class_table_) {
436 class_table_allocator_.Free(heap_walk_class_table_);
437 }
438
439#if !defined(PRODUCT)
440 delete debugger_;
441 debugger_ = nullptr;
442#endif
443}
void Free(ClassTable *table)
#define ASSERT(E)

Member Function Documentation

◆ all_classes_finalized()

bool dart::IsolateGroup::all_classes_finalized ( ) const
inline

Definition at line 706 of file isolate.h.

706 {
707 return AllClassesFinalizedBit::decode(isolate_group_flags_);
708 }

◆ api_state()

ApiState * dart::IsolateGroup::api_state ( ) const
inline

Definition at line 693 of file isolate.h.

693{ return api_state_.get(); }

◆ background_compiler()

BackgroundCompiler * dart::IsolateGroup::background_compiler ( ) const
inline

Definition at line 297 of file isolate.h.

297 {
298#if defined(DART_PRECOMPILED_RUNTIME)
299 return nullptr;
300#else
301 return background_compiler_.get();
302#endif
303 }

◆ become()

Become * dart::IsolateGroup::become ( ) const
inline

Definition at line 670 of file isolate.h.

670{ return become_; }

◆ cached_class_table_table()

ClassPtr * dart::IsolateGroup::cached_class_table_table ( )
inline

Definition at line 389 of file isolate.h.

389 {
390 return cached_class_table_table_.load();
391 }
T load(std::memory_order order=std::memory_order_acquire) const
Definition atomic.h:101

◆ cached_class_table_table_offset()

static intptr_t dart::IsolateGroup::cached_class_table_table_offset ( )
inlinestatic

Definition at line 395 of file isolate.h.

395 {
396 COMPILE_ASSERT(sizeof(IsolateGroup::cached_class_table_table_) ==
397 kWordSize);
398 return OFFSET_OF(IsolateGroup, cached_class_table_table_);
399 }
#define COMPILE_ASSERT(expr)
Definition assert.h:339
constexpr intptr_t kWordSize
Definition globals.h:509
#define OFFSET_OF(type, field)
Definition globals.h:138

◆ CallTagHandler()

ObjectPtr dart::IsolateGroup::CallTagHandler ( Dart_LibraryTag  tag,
const Object arg1,
const Object arg2 
)

Definition at line 1889 of file isolate.cc.

1891 {
1892 Thread* thread = Thread::Current();
1893 Api::Scope api_scope(thread);
1894 Dart_Handle api_arg1 = Api::NewHandle(thread, arg1.ptr());
1895 Dart_Handle api_arg2 = Api::NewHandle(thread, arg2.ptr());
1896 Dart_Handle api_result;
1897 {
1898 TransitionVMToNative transition(thread);
1900 api_result = library_tag_handler()(tag, api_arg1, api_arg2);
1901 }
1902 return Api::UnwrapHandle(api_result);
1903}
static Dart_Handle NewHandle(Thread *thread, ObjectPtr raw)
static ObjectPtr UnwrapHandle(Dart_Handle object)
Dart_LibraryTagHandler library_tag_handler() const
Definition isolate.h:550
bool HasTagHandler() const
Definition isolate.h:546
static Thread * Current()
Definition thread.h:361
struct _Dart_Handle * Dart_Handle
Definition dart_api.h:258

◆ CanReload()

bool dart::IsolateGroup::CanReload ( )

Definition at line 2006 of file isolate.cc.

2006 {
2007 // We only call this method on the mutator thread. Normally the caller is
2008 // inside of the "reloadSources" service OOB message handler. Though
2009 // we also use it in the slow path of StackOverflowCheck in the artificial
2010 // --hot-reload-test-mode like flags.
2011 //
2012 // During reload itself we don't process OOB messages and don't execute Dart
2013 // code, so the caller should implicitly have a guarantee we're not reloading
2014 // already.
2015 RELEASE_ASSERT(!Thread::Current()->OwnsReloadSafepoint());
2016
2017 // We only allow reload to take place from the point on where the first
2018 // isolate within an isolate group has setup it's root library. From that
2019 // point on it's safe to perform hot-reload.
2020 auto thread = Thread::Current();
2021 if (object_store()->root_library() == Library::null()) {
2022 return false;
2023 }
2024
2025 // We only care about the current thread's [NoReloadScope]. If we're inside
2026 // one we cannot reload right now. Though if another isolate's mutator
2027 // thread is inside such a scope, the multi-isolate reload will simply wait
2028 // until it's out of that scope again.
2029 if (thread->no_reload_scope_depth_ != 0) {
2030 return false;
2031 }
2032
2033 return !IsolateGroup::IsSystemIsolateGroup(this) &&
2035}
#define RELEASE_ASSERT(cond)
Definition assert.h:327
static bool IsSystemIsolateGroup(const IsolateGroup *group)
Definition isolate.cc:3559
bool HasStackHeadroom()
Definition os_thread.h:132
static OSThread * Current()
Definition os_thread.h:175
constexpr intptr_t KB
Definition globals.h:528

◆ class_table()

ClassTable * dart::IsolateGroup::class_table ( ) const
inline

Definition at line 491 of file isolate.h.

491{ return class_table_; }

◆ class_table_allocator()

ClassTableAllocator * dart::IsolateGroup::class_table_allocator ( )
inline

Definition at line 380 of file isolate.h.

380 {
381 return &class_table_allocator_;
382 }

◆ class_table_offset()

static intptr_t dart::IsolateGroup::class_table_offset ( )
inlinestatic

Definition at line 384 of file isolate.h.

384 {
385 COMPILE_ASSERT(sizeof(IsolateGroup::class_table_) == kWordSize);
386 return OFFSET_OF(IsolateGroup, class_table_);
387 }

◆ Cleanup()

void dart::IsolateGroup::Cleanup ( )
static

Definition at line 736 of file isolate.cc.

736 {
737 delete isolate_group_random_;
738 isolate_group_random_ = nullptr;
739 delete isolate_groups_rwlock_;
740 isolate_groups_rwlock_ = nullptr;
741 ASSERT(isolate_groups_->IsEmpty());
742 delete isolate_groups_;
743 isolate_groups_ = nullptr;
744}

◆ CloneClassTableForReload()

void dart::IsolateGroup::CloneClassTableForReload ( )

Definition at line 3771 of file isolate.cc.

3771 {
3772 RELEASE_ASSERT(class_table_ == heap_walk_class_table_);
3773 class_table_ = class_table_->Clone();
3775}
ClassTable * Clone() const
void set_cached_class_table_table(ClassPtr *cached_class_table_table)
Definition isolate.h:392

◆ constant_canonicalization_mutex()

Mutex * dart::IsolateGroup::constant_canonicalization_mutex ( )
inline

Definition at line 515 of file isolate.h.

515 {
516 return &constant_canonicalization_mutex_;
517 }

◆ ContainsOnlyOneIsolate()

bool dart::IsolateGroup::ContainsOnlyOneIsolate ( )

Definition at line 452 of file isolate.cc.

452 {
453 SafepointReadRwLocker ml(Thread::Current(), isolates_lock_.get());
454 // We do allow 0 here as well, because the background compiler might call
455 // this method while the mutator thread is in shutdown procedure and
456 // unregistered itself already.
457 return isolate_count_ == 0 || isolate_count_ == 1;
458}

◆ CreateHeap()

void dart::IsolateGroup::CreateHeap ( bool  is_vm_isolate,
bool  is_service_or_kernel_isolate 
)

Definition at line 476 of file isolate.cc.

477 {
480 ? 0 // New gen size 0; VM isolate should only allocate in old.
481 : FLAG_new_gen_semi_max_size * MBInWords,
482 (is_service_or_kernel_isolate ? kDefaultMaxOldGenHeapSize
483 : FLAG_old_gen_heap_size) *
484 MBInWords);
485
486#define ISOLATE_GROUP_METRIC_CONSTRUCTORS(type, variable, name, unit) \
487 metric_##variable##_.InitInstance(this, name, nullptr, Metric::unit);
489#undef ISOLATE_GROUP_METRIC_CONSTRUCTORS
490}
static void Init(IsolateGroup *isolate_group, bool is_vm_isolate, intptr_t max_new_gen_words, intptr_t max_old_gen_words)
Definition heap.cc:693
#define ISOLATE_GROUP_METRIC_LIST(V)
Definition metrics.h:37
constexpr intptr_t MBInWords
Definition globals.h:537
const intptr_t kDefaultMaxOldGenHeapSize
Definition globals.h:62
#define ISOLATE_GROUP_METRIC_CONSTRUCTORS(type, variable, name, unit)

◆ Current()

static IsolateGroup * dart::IsolateGroup::Current ( )
inlinestatic

Definition at line 534 of file isolate.h.

534 {
535 Thread* thread = Thread::Current();
536 return thread == nullptr ? nullptr : thread->isolate_group();
537 }

◆ debugger()

GroupDebugger * dart::IsolateGroup::debugger ( ) const
inline

Definition at line 314 of file isolate.h.

314{ return debugger_; }

◆ DecreaseMutatorCount()

void dart::IsolateGroup::DecreaseMutatorCount ( Isolate mutator,
bool  is_nested_exit 
)

Definition at line 612 of file isolate.cc.

612 {
613 ASSERT(mutator->group() == this);
614
615 // If the mutator thread has an active stack and runs on our thread pool we
616 // will mark the worker as blocked, thereby possibly spawning a new worker for
617 // pending tasks (if there are any).
618 if (is_nested_exit) {
619 ASSERT(mutator->mutator_thread() != nullptr);
621 }
622
623 {
624 // NOTE: This is performance critical code, we should avoid monitors and use
625 // std::atomics in the fast case (where active_mutators <
626 // max_active_mutators) and only use monitors in the uncommon case.
627 MonitorLocker ml(active_mutators_monitor_.get());
628 ASSERT(active_mutators_ <= max_active_mutators_);
629 active_mutators_--;
630 if (waiting_mutators_ > 0) {
631 ml.Notify();
632 }
633 }
634}
MutatorThreadPool * thread_pool()
Definition isolate.h:736
void MarkCurrentWorkerAsBlocked()

◆ deferred_load_handler()

Dart_DeferredLoadHandler dart::IsolateGroup::deferred_load_handler ( ) const
inline

Definition at line 556 of file isolate.h.

556 {
557 return deferred_load_handler_;
558 }

◆ deferred_marking_stack()

MarkingStack * dart::IsolateGroup::deferred_marking_stack ( ) const
inline

Definition at line 571 of file isolate.h.

571 {
572 return deferred_marking_stack_;
573 }

◆ DeferredMarkLiveTemporaries()

void dart::IsolateGroup::DeferredMarkLiveTemporaries ( )

Definition at line 2956 of file isolate.cc.

2956 {
2958 [&](Isolate* isolate) { isolate->DeferredMarkLiveTemporaries(); },
2959 /*at_safepoint=*/true);
2960}
void ForEachIsolate(std::function< void(Isolate *isolate)> function, bool at_safepoint=false)
Definition isolate.cc:2798
friend class Isolate
Definition isolate.h:750

◆ DeleteReloadContext()

void dart::IsolateGroup::DeleteReloadContext ( )

Definition at line 2095 of file isolate.cc.

2095 {
2096 GcSafepointOperationScope safepoint_scope(Thread::Current());
2097 group_reload_context_.reset();
2098
2099 delete program_reload_context_;
2100 program_reload_context_ = nullptr;
2101}

◆ DisableIncrementalBarrier()

void dart::IsolateGroup::DisableIncrementalBarrier ( )

Definition at line 2791 of file isolate.cc.

2791 {
2793 ASSERT(marking_stack_ != nullptr);
2794 marking_stack_ = nullptr;
2795 deferred_marking_stack_ = nullptr;
2796}
ThreadRegistry * thread_registry() const
Definition isolate.h:332

◆ dispatch_table()

DispatchTable * dart::IsolateGroup::dispatch_table ( ) const
inline

Definition at line 363 of file isolate.h.

363{ return dispatch_table_.get(); }

◆ dispatch_table_snapshot()

const uint8_t * dart::IsolateGroup::dispatch_table_snapshot ( ) const
inline

Definition at line 367 of file isolate.h.

367 {
368 return dispatch_table_snapshot_;
369 }

◆ dispatch_table_snapshot_size()

intptr_t dart::IsolateGroup::dispatch_table_snapshot_size ( ) const
inline

Definition at line 373 of file isolate.h.

373 {
374 return dispatch_table_snapshot_size_;
375 }

◆ DropOriginalClassTable()

void dart::IsolateGroup::DropOriginalClassTable ( )

Definition at line 3784 of file isolate.cc.

3784 {
3785 RELEASE_ASSERT(class_table_ != heap_walk_class_table_);
3786 class_table_allocator_.Free(heap_walk_class_table_);
3787 heap_walk_class_table_ = class_table_;
3788 set_cached_class_table_table(class_table_->table());
3789}

◆ embedder_data()

void * dart::IsolateGroup::embedder_data ( ) const
inline

Definition at line 290 of file isolate.h.

290{ return embedder_data_; }

◆ EnableIncrementalBarrier()

void dart::IsolateGroup::EnableIncrementalBarrier ( MarkingStack marking_stack,
MarkingStack deferred_marking_stack 
)

Definition at line 2781 of file isolate.cc.

2783 {
2784 ASSERT(marking_stack_ == nullptr);
2785 marking_stack_ = marking_stack;
2786 deferred_marking_stack_ = deferred_marking_stack;
2788 ASSERT(Thread::Current()->is_marking());
2789}
MarkingStack * deferred_marking_stack() const
Definition isolate.h:571
MarkingStack * marking_stack() const
Definition isolate.h:570

◆ EnterTemporaryIsolate()

Isolate * dart::IsolateGroup::EnterTemporaryIsolate ( )

Definition at line 835 of file isolate.cc.

835 {
838 Isolate* const isolate = Isolate::InitIsolate("temp", this, flags);
839 ASSERT(isolate != nullptr);
840 ASSERT(Isolate::Current() == isolate);
841 return isolate;
842}
static Isolate * Current()
Definition isolate.h:939
static void FlagsInitialize(Dart_IsolateFlags *api_flags)
Definition isolate.cc:1612
FlutterSemanticsFlag flags

◆ ExitTemporaryIsolate()

void dart::IsolateGroup::ExitTemporaryIsolate ( )
static

Definition at line 844 of file isolate.cc.

844 {
845 Thread* thread = Thread::Current();
846 ASSERT(thread != nullptr);
847 thread->set_execution_state(Thread::kThreadInVM);
848 Dart::ShutdownIsolate(thread);
849}
static void ShutdownIsolate(Thread *T)
Definition dart.cc:1115

◆ FirstIsolate()

Isolate * dart::IsolateGroup::FirstIsolate ( ) const

Definition at line 2825 of file isolate.cc.

2825 {
2826 SafepointReadRwLocker ml(Thread::Current(), isolates_lock_.get());
2827 return FirstIsolateLocked();
2828}
Isolate * FirstIsolateLocked() const
Definition isolate.cc:2830

◆ FirstIsolateLocked()

Isolate * dart::IsolateGroup::FirstIsolateLocked ( ) const

Definition at line 2830 of file isolate.cc.

2830 {
2831 return isolates_.IsEmpty() ? nullptr : isolates_.First();
2832}

◆ FlagsCopyFrom()

void dart::IsolateGroup::FlagsCopyFrom ( const Dart_IsolateFlags api_flags)

Definition at line 1586 of file isolate.cc.

1586 {
1587#if defined(DART_PRECOMPILER)
1588#define FLAG_FOR_PRECOMPILER(action) action
1589#else
1590#define FLAG_FOR_PRECOMPILER(action)
1591#endif
1592
1593#if !defined(PRODUCT)
1594#define FLAG_FOR_NONPRODUCT(action) action
1595#else
1596#define FLAG_FOR_NONPRODUCT(action)
1597#endif
1598
1599#define FLAG_FOR_PRODUCT(action) action
1600
1601#define SET_FROM_FLAG(when, name, bitname, isolate_flag, flag) \
1602 FLAG_FOR_##when(isolate_group_flags_ = bitname##Bit::update( \
1603 api_flags.isolate_flag, isolate_group_flags_));
1604
1606#undef FLAG_FOR_NONPRODUCT
1607#undef FLAG_FOR_PRECOMPILER
1608#undef FLAG_FOR_PRODUCT
1609#undef SET_FROM_FLAG
1610}
#define BOOL_ISOLATE_GROUP_FLAG_LIST(V)
Definition isolate.h:136
#define SET_FROM_FLAG(when, name, bitname, isolate_flag, flag)

◆ FlagsCopyTo()

void dart::IsolateGroup::FlagsCopyTo ( Dart_IsolateFlags api_flags)

Definition at line 1575 of file isolate.cc.

1575 {
1577#define INIT_FROM_FIELD(when, name, bitname, isolate_flag, flag) \
1578 api_flags->isolate_flag = name();
1580#undef INIT_FROM_FIELD
1581 api_flags->is_service_isolate = false;
1582 api_flags->is_kernel_isolate = false;
1583 api_flags->null_safety = true;
1584}
#define DART_FLAGS_CURRENT_VERSION
Definition dart_api.h:582
bool is_service_isolate
Definition dart_api.h:593
#define INIT_FROM_FIELD(when, name, bitname, isolate_flag, flag)

◆ FlagsInitialize()

void dart::IsolateGroup::FlagsInitialize ( Dart_IsolateFlags api_flags)
static

Definition at line 1564 of file isolate.cc.

1564 {
1566#define INIT_FROM_FLAG(when, name, bitname, isolate_flag, flag) \
1567 api_flags->isolate_flag = flag;
1569#undef INIT_FROM_FLAG
1570 api_flags->is_service_isolate = false;
1571 api_flags->is_kernel_isolate = false;
1572 api_flags->null_safety = true;
1573}
#define INIT_FROM_FLAG(when, name, bitname, isolate_flag, flag)

◆ FlushMarkingStacks()

void dart::IsolateGroup::FlushMarkingStacks ( )

Definition at line 2744 of file isolate.cc.

2744 {
2746}

◆ ForEach()

void dart::IsolateGroup::ForEach ( std::function< void(IsolateGroup *)>  action)
static

Definition at line 677 of file isolate.cc.

677 {
678 ReadRwLocker wl(Thread::Current(), isolate_groups_rwlock_);
679 for (auto isolate_group : *isolate_groups_) {
680 action(isolate_group);
681 }
682}

◆ ForEachIsolate()

void dart::IsolateGroup::ForEachIsolate ( std::function< void(Isolate *isolate)>  function,
bool  at_safepoint = false 
)

Definition at line 2798 of file isolate.cc.

2800 {
2801 auto thread = Thread::Current();
2802 if (at_safepoint) {
2803 ASSERT(thread->OwnsSafepoint() ||
2804 (thread->task_kind() == Thread::kMutatorTask) ||
2805 (thread->task_kind() == Thread::kMarkerTask) ||
2806 (thread->task_kind() == Thread::kCompactorTask) ||
2807 (thread->task_kind() == Thread::kScavengerTask));
2808 for (Isolate* isolate : isolates_) {
2809 function(isolate);
2810 }
2811 return;
2812 }
2813 if (thread != nullptr && thread->OwnsSafepoint()) {
2814 for (Isolate* isolate : isolates_) {
2815 function(isolate);
2816 }
2817 return;
2818 }
2819 SafepointReadRwLocker ml(thread, isolates_lock_.get());
2820 for (Isolate* isolate : isolates_) {
2821 function(isolate);
2822 }
2823}
@ kScavengerTask
Definition thread.h:352
@ kCompactorTask
Definition thread.h:351
Dart_NativeFunction function
Definition fuchsia.cc:51

◆ FreeStaticField()

void dart::IsolateGroup::FreeStaticField ( const Field field)

Definition at line 816 of file isolate.cc.

816 {
817#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
818 // This can only be called during hot-reload.
819 ASSERT(program_reload_context() != nullptr);
820#endif
821
822 const intptr_t field_id = field.field_id();
823 initial_field_table()->Free(field_id);
824 ForEachIsolate([&](Isolate* isolate) {
825 auto field_table = isolate->field_table();
826 // The isolate might've just been created and is now participating in
827 // the reload request inside `IsolateGroup::RegisterIsolate()`.
828 // At that point it doesn't have the field table setup yet.
829 if (field_table->IsReadyToUse()) {
830 field_table->Free(field_id);
831 }
832 });
833}
void Free(intptr_t index)
FieldTable * initial_field_table() const
Definition isolate.h:728
ProgramReloadContext * program_reload_context()
Definition isolate.h:652

◆ HasApplicationIsolateGroups()

bool dart::IsolateGroup::HasApplicationIsolateGroups ( )
static

Definition at line 708 of file isolate.cc.

708 {
709 ReadRwLocker wl(ThreadState::Current(), isolate_groups_rwlock_);
710 for (auto group : *isolate_groups_) {
712 return true;
713 }
714 }
715 return false;
716}

◆ HasAttemptedReload()

bool dart::IsolateGroup::HasAttemptedReload ( ) const
inline

Definition at line 464 of file isolate.h.

464 {
465 return HasAttemptedReloadBit::decode(isolate_group_flags_);
466 }

◆ HasOnlyVMIsolateGroup()

bool dart::IsolateGroup::HasOnlyVMIsolateGroup ( )
static

Definition at line 718 of file isolate.cc.

718 {
719 ReadRwLocker wl(ThreadState::Current(), isolate_groups_rwlock_);
720 for (auto group : *isolate_groups_) {
721 if (!group->is_vm_isolate()) {
722 return false;
723 }
724 }
725 return true;
726}

◆ HasTagHandler()

bool dart::IsolateGroup::HasTagHandler ( ) const
inline

Definition at line 546 of file isolate.h.

546{ return library_tag_handler() != nullptr; }

◆ heap()

Heap * dart::IsolateGroup::heap ( ) const
inline

Definition at line 295 of file isolate.h.

295{ return heap_.get(); }

◆ heap_walk_class_table()

ClassTable * dart::IsolateGroup::heap_walk_class_table ( ) const
inline

Definition at line 498 of file isolate.h.

498{ return heap_walk_class_table_; }

◆ id()

uint64_t dart::IsolateGroup::id ( ) const
inline

Definition at line 673 of file isolate.h.

673{ return id_; }

◆ idle_time_handler()

IdleTimeHandler * dart::IsolateGroup::idle_time_handler ( )
inline

Definition at line 317 of file isolate.h.

317{ return &idle_time_handler_; }

◆ IncreaseMutatorCount()

void dart::IsolateGroup::IncreaseMutatorCount ( Isolate mutator,
bool  is_nested_reenter 
)

Definition at line 584 of file isolate.cc.

585 {
586 ASSERT(mutator->group() == this);
587
588 // If the mutator was temporarily blocked on a worker thread, we have to
589 // unblock the worker thread again.
590 if (is_nested_reenter) {
591 ASSERT(mutator->mutator_thread() != nullptr);
593 }
594
595 // Prevent too many mutators from entering the isolate group to avoid
596 // pathological behavior where many threads are fighting for obtaining TLABs.
597 {
598 // NOTE: This is performance critical code, we should avoid monitors and use
599 // std::atomics in the fast case (where active_mutators <
600 // max_active_mutators) and only use monitors in the uncommon case.
601 MonitorLocker ml(active_mutators_monitor_.get());
602 ASSERT(active_mutators_ <= max_active_mutators_);
603 while (active_mutators_ == max_active_mutators_) {
604 waiting_mutators_++;
605 ml.Wait();
606 waiting_mutators_--;
607 }
608 active_mutators_++;
609 }
610}
void MarkCurrentWorkerAsUnBlocked()

◆ Init()

void dart::IsolateGroup::Init ( )
static

Definition at line 728 of file isolate.cc.

728 {
729 ASSERT(isolate_groups_rwlock_ == nullptr);
730 isolate_groups_rwlock_ = new RwLock();
731 ASSERT(isolate_groups_ == nullptr);
732 isolate_groups_ = new IntrusiveDList<IsolateGroup>();
733 isolate_group_random_ = new Random();
734}

◆ initial_field_table()

FieldTable * dart::IsolateGroup::initial_field_table ( ) const
inline

Definition at line 728 of file isolate.h.

728{ return initial_field_table_.get(); }

◆ initial_field_table_shareable()

std::shared_ptr< FieldTable > dart::IsolateGroup::initial_field_table_shareable ( )
inline

Definition at line 729 of file isolate.h.

729 {
730 return initial_field_table_;
731 }

◆ initial_spawn_successful()

bool dart::IsolateGroup::initial_spawn_successful ( )
inline

Definition at line 292 of file isolate.h.

292{ return initial_spawn_successful_; }

◆ initializer_functions_mutex()

Mutex * dart::IsolateGroup::initializer_functions_mutex ( )
inline

Definition at line 529 of file isolate.h.

529{ return &initializer_functions_mutex_; }

◆ is_system_isolate_group()

bool dart::IsolateGroup::is_system_isolate_group ( ) const
inline

Definition at line 412 of file isolate.h.

412{ return is_system_isolate_group_; }

◆ is_vm_isolate()

bool dart::IsolateGroup::is_vm_isolate ( ) const
inline

Definition at line 289 of file isolate.h.

289{ return is_vm_isolate_; }

◆ ISOLATE_GROUP_METRIC_LIST()

dart::IsolateGroup::ISOLATE_GROUP_METRIC_LIST ( ISOLATE_METRIC_ACCESSOR  )

◆ IsReloading()

bool dart::IsolateGroup::IsReloading ( ) const
inline

Definition at line 662 of file isolate.h.

662 {
663#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
664 return group_reload_context_ != nullptr;
665#else
666 return false;
667#endif
668 }

◆ IsSystemIsolateGroup()

bool dart::IsolateGroup::IsSystemIsolateGroup ( const IsolateGroup group)
static

Definition at line 3559 of file isolate.cc.

3559 {
3560 return group->source()->flags.is_system_isolate;
3561}

◆ kernel_constants_mutex()

Mutex * dart::IsolateGroup::kernel_constants_mutex ( )
inline

Definition at line 522 of file isolate.h.

522{ return &kernel_constants_mutex_; }

◆ kernel_data_class_cache_mutex()

Mutex * dart::IsolateGroup::kernel_data_class_cache_mutex ( )
inline

Definition at line 519 of file isolate.h.

519 {
520 return &kernel_data_class_cache_mutex_;
521 }

◆ kernel_data_lib_cache_mutex()

Mutex * dart::IsolateGroup::kernel_data_lib_cache_mutex ( )
inline

Definition at line 518 of file isolate.h.

518{ return &kernel_data_lib_cache_mutex_; }

◆ last_allocationprofile_accumulator_reset_timestamp()

int64_t dart::IsolateGroup::last_allocationprofile_accumulator_reset_timestamp ( ) const
inline

Definition at line 350 of file isolate.h.

350 {
351 return last_allocationprofile_accumulator_reset_timestamp_;
352 }

◆ last_allocationprofile_gc_timestamp()

int64_t dart::IsolateGroup::last_allocationprofile_gc_timestamp ( ) const
inline

Definition at line 358 of file isolate.h.

358 {
359 return last_allocationprofile_gc_timestamp_;
360 }

◆ last_reload_timestamp()

int64_t dart::IsolateGroup::last_reload_timestamp ( ) const
inline

Definition at line 647 of file isolate.h.

647{ return last_reload_timestamp_; }

◆ library_tag_handler()

Dart_LibraryTagHandler dart::IsolateGroup::library_tag_handler ( ) const
inline

Definition at line 550 of file isolate.h.

550 {
551 return library_tag_handler_;
552 }

◆ marking_stack()

MarkingStack * dart::IsolateGroup::marking_stack ( ) const
inline

Definition at line 570 of file isolate.h.

570{ return marking_stack_; }

◆ MaybeIncreaseReloadEveryNStackOverflowChecks()

void dart::IsolateGroup::MaybeIncreaseReloadEveryNStackOverflowChecks ( )

Definition at line 2496 of file isolate.cc.

2496 {
2497 if (FLAG_reload_every_back_off) {
2498 if (reload_every_n_stack_overflow_checks_ < 5000) {
2499 reload_every_n_stack_overflow_checks_ += 99;
2500 } else {
2501 const auto old_value = reload_every_n_stack_overflow_checks_;
2502 reload_every_n_stack_overflow_checks_ = old_value * old_value;
2503 }
2504 // Cap the value.
2505 if (reload_every_n_stack_overflow_checks_ > 1000000) {
2506 reload_every_n_stack_overflow_checks_ = 1000000;
2507 }
2508 }
2509}

◆ megamorphic_table_mutex()

Mutex * dart::IsolateGroup::megamorphic_table_mutex ( )
inline

Definition at line 512 of file isolate.h.

512{ return &megamorphic_table_mutex_; }

◆ MutatorCount()

intptr_t dart::IsolateGroup::MutatorCount ( ) const
inline

Definition at line 541 of file isolate.h.

541 {
542 MonitorLocker ml(active_mutators_monitor_.get());
543 return active_mutators_;
544 }

◆ obfuscation_map()

const char ** dart::IsolateGroup::obfuscation_map ( ) const
inline

Definition at line 408 of file isolate.h.

408{ return obfuscation_map_; }

◆ object_store()

ObjectStore * dart::IsolateGroup::object_store ( ) const
inline

Definition at line 505 of file isolate.h.

505{ return object_store_.get(); }

◆ object_store_offset()

static intptr_t dart::IsolateGroup::object_store_offset ( )
inlinestatic

Definition at line 402 of file isolate.h.

402 {
403 COMPILE_ASSERT(sizeof(IsolateGroup::object_store_) == kWordSize);
404 return OFFSET_OF(IsolateGroup, object_store_);
405 }

◆ optimization_counter_threshold()

intptr_t dart::IsolateGroup::optimization_counter_threshold ( ) const
inline

Definition at line 305 of file isolate.h.

305 {
306 if (IsSystemIsolateGroup(this)) {
308 }
309 return FLAG_optimization_counter_threshold;
310 }
constexpr intptr_t kDefaultOptimizationCounterThreshold
Definition flag_list.h:23

◆ patchable_call_mutex()

Mutex * dart::IsolateGroup::patchable_call_mutex ( )
inline

Definition at line 514 of file isolate.h.

514{ return &patchable_call_mutex_; }

◆ PrintJSON()

void dart::IsolateGroup::PrintJSON ( JSONStream stream,
bool  ref = true 
)

Definition at line 637 of file isolate.cc.

637 {
638 JSONObject jsobj(stream);
639 PrintToJSONObject(&jsobj, ref);
640}
void PrintToJSONObject(JSONObject *jsobj, bool ref)
Definition isolate.cc:642

◆ PrintMemoryUsageJSON()

void dart::IsolateGroup::PrintMemoryUsageJSON ( JSONStream stream)

Definition at line 662 of file isolate.cc.

662 {
663 int64_t used = heap()->TotalUsedInWords();
664 int64_t capacity = heap()->TotalCapacityInWords();
665 int64_t external_used = heap()->TotalExternalInWords();
666
667 JSONObject jsobj(stream);
668 // This is the same "MemoryUsage" that the isolate-specific "getMemoryUsage"
669 // rpc method returns.
670 jsobj.AddProperty("type", "MemoryUsage");
671 jsobj.AddProperty64("heapUsage", used * kWordSize);
672 jsobj.AddProperty64("heapCapacity", capacity * kWordSize);
673 jsobj.AddProperty64("externalUsage", external_used * kWordSize);
674}
intptr_t TotalExternalInWords() const
Definition heap.cc:813
intptr_t TotalCapacityInWords() const
Definition heap.cc:809
intptr_t TotalUsedInWords() const
Definition heap.cc:805
Heap * heap() const
Definition isolate.h:295

◆ PrintToJSONObject()

void dart::IsolateGroup::PrintToJSONObject ( JSONObject jsobj,
bool  ref 
)

Definition at line 642 of file isolate.cc.

642 {
643 jsobj->AddProperty("type", (ref ? "@IsolateGroup" : "IsolateGroup"));
644 jsobj->AddServiceId(ISOLATE_GROUP_SERVICE_ID_FORMAT_STRING, id());
645
646 jsobj->AddProperty("name", source()->script_uri);
647 jsobj->AddPropertyF("number", "%" Pu64 "", id());
648 jsobj->AddProperty("isSystemIsolateGroup", is_system_isolate_group());
649 if (ref) {
650 return;
651 }
652
653 {
654 JSONArray isolate_array(jsobj, "isolates");
655 for (auto it = isolates_.Begin(); it != isolates_.End(); ++it) {
656 Isolate* isolate = *it;
657 isolate_array.AddValue(isolate, /*ref=*/true);
658 }
659 }
660}
bool is_system_isolate_group() const
Definition isolate.h:412
#define Pu64
Definition globals.h:417
#define ISOLATE_GROUP_SERVICE_ID_FORMAT_STRING
Definition service.h:50

◆ program_lock()

SafepointRwLock * dart::IsolateGroup::program_lock ( )
inline

Definition at line 532 of file isolate.h.

532{ return program_lock_.get(); }

◆ program_reload_context()

ProgramReloadContext * dart::IsolateGroup::program_reload_context ( )
inline

Definition at line 652 of file isolate.h.

652 {
653 return program_reload_context_;
654 }

◆ random()

Random * dart::IsolateGroup::random ( )
inline

Definition at line 410 of file isolate.h.

410{ return &random_; }

◆ RegisterClass()

void dart::IsolateGroup::RegisterClass ( const Class cls)

Definition at line 763 of file isolate.cc.

763 {
764#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
765 if (IsReloading()) {
766 program_reload_context()->RegisterClass(cls);
767 return;
768 }
769#endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
770 if (cls.IsTopLevel()) {
772 } else {
773 class_table()->Register(cls);
774 }
775}
void Register(const Class &cls)
void RegisterTopLevel(const Class &cls)
ClassTable * class_table() const
Definition isolate.h:491
bool IsReloading() const
Definition isolate.h:662

◆ RegisterIsolate()

void dart::IsolateGroup::RegisterIsolate ( Isolate isolate)

Definition at line 445 of file isolate.cc.

445 {
446 SafepointWriteRwLocker ml(Thread::Current(), isolates_lock_.get());
447 ASSERT(isolates_lock_->IsCurrentThreadWriter());
448 isolates_.Append(isolate);
449 isolate_count_++;
450}

◆ RegisterIsolateGroup()

void dart::IsolateGroup::RegisterIsolateGroup ( IsolateGroup isolate_group)
static

Definition at line 698 of file isolate.cc.

698 {
699 WriteRwLocker wl(ThreadState::Current(), isolate_groups_rwlock_);
700 isolate_groups_->Append(isolate_group);
701}

◆ RegisterStaticField()

void dart::IsolateGroup::RegisterStaticField ( const Field field,
const Object initial_value 
)

Definition at line 783 of file isolate.cc.

784 {
785 ASSERT(program_lock()->IsCurrentThreadWriter());
786
787 ASSERT(field.is_static());
788 const bool need_to_grow_backing_store =
790 const intptr_t field_id = field.field_id();
791 initial_field_table()->SetAt(field_id, initial_value.ptr());
792
793 SafepointReadRwLocker ml(Thread::Current(), isolates_lock_.get());
794 if (need_to_grow_backing_store) {
795 // We have to stop other isolates from accessing their field state, since
796 // we'll have to grow the backing store.
797 GcSafepointOperationScope scope(Thread::Current());
798 for (auto isolate : isolates_) {
799 auto field_table = isolate->field_table();
800 if (field_table->IsReadyToUse()) {
801 field_table->Register(field, field_id);
802 field_table->SetAt(field_id, initial_value.ptr());
803 }
804 }
805 } else {
806 for (auto isolate : isolates_) {
807 auto field_table = isolate->field_table();
808 if (field_table->IsReadyToUse()) {
809 field_table->Register(field, field_id);
810 field_table->SetAt(field_id, initial_value.ptr());
811 }
812 }
813 }
814}
bool Register(const Field &field, intptr_t expected_field_id=-1)
void SetAt(intptr_t index, ObjectPtr raw_instance, bool concurrent_use=false)
Definition field_table.h:75
SafepointRwLock * program_lock()
Definition isolate.h:532

◆ RehashConstants()

void dart::IsolateGroup::RehashConstants ( Become become)

Definition at line 851 of file isolate.cc.

851 {
852 // Even though no individual constant contains a cycle, there can be "cycles"
853 // between the canonical tables if some const instances of A have fields that
854 // are const instance of B and vice versa. So set all the old tables to the
855 // side and clear all the tables attached to the classes before rehashing
856 // instead of resetting and rehash one class at a time.
857
858 Thread* thread = Thread::Current();
859 StackZone stack_zone(thread);
860 Zone* zone = stack_zone.GetZone();
861
862 intptr_t num_cids = class_table()->NumCids();
863 Array** old_constant_tables = zone->Alloc<Array*>(num_cids);
864 for (intptr_t i = 0; i < num_cids; i++) {
865 old_constant_tables[i] = nullptr;
866 }
867
868 Class& cls = Class::Handle(zone);
869 for (intptr_t cid = kInstanceCid; cid < num_cids; cid++) {
870 if (!class_table()->IsValidIndex(cid) ||
871 !class_table()->HasValidClassAt(cid)) {
872 continue;
873 }
874 if ((cid == kTypeArgumentsCid) || IsStringClassId(cid)) {
875 // TypeArguments and Symbols have special tables for canonical objects
876 // that aren't based on address.
877 continue;
878 }
879 if ((cid == kMintCid) || (cid == kDoubleCid)) {
880 // Constants stored as a plain list or in a hashset with a stable
881 // hashcode, which only depends on the actual value of the constant.
882 continue;
883 }
884
885 cls = class_table()->At(cid);
886 if (cls.constants() == Array::null()) continue;
887 old_constant_tables[cid] = &Array::Handle(zone, cls.constants());
888 cls.set_constants(Object::null_array());
889 }
890
891 // Clear invalid hashes.
893
894 Instance& constant = Instance::Handle(zone);
895 Field& field = Field::Handle(zone);
896 String& name = String::Handle(zone);
897 Array& new_values = Array::Handle(zone);
898 Instance& old_value = Instance::Handle(zone);
899 Instance& new_value = Instance::Handle(zone);
900 Instance& deleted = Instance::Handle(zone);
901
902 if (become != nullptr) {
903 for (intptr_t cid = kInstanceCid; cid < num_cids; cid++) {
904 Array* old_constants = old_constant_tables[cid];
905 if (old_constants == nullptr) continue;
906
907 cls = class_table()->At(cid);
908 CanonicalInstancesSet set(zone, old_constants->ptr());
909 CanonicalInstancesSet::Iterator it(&set);
910 while (it.MoveNext()) {
911 constant ^= set.GetKey(it.Current());
912 ASSERT(!constant.IsNull());
913 ASSERT(!constant.InVMIsolateHeap());
914 constant.ClearCanonical();
915 }
916 set.Release();
917 }
918 }
919
920 for (intptr_t cid = kInstanceCid; cid < num_cids; cid++) {
921 Array* old_constants = old_constant_tables[cid];
922 if (old_constants == nullptr) continue;
923
924 cls = class_table()->At(cid);
925 CanonicalInstancesSet set(zone, old_constants->ptr());
926 CanonicalInstancesSet::Iterator it(&set);
927
928 if (cls.is_enum_class() && (become != nullptr)) {
929 field = cls.LookupStaticField(Symbols::_DeletedEnumSentinel());
930 deleted ^= field.StaticConstFieldValue();
931 if (deleted.IsNull()) {
932 deleted = Instance::New(cls, Heap::kOld);
933 field = object_store()->enum_name_field();
934 name = cls.ScrubbedName();
935 name = Symbols::FromConcat(thread, Symbols::_DeletedEnumPrefix(), name);
936 deleted.SetField(field, name);
937 field = object_store()->enum_index_field();
938 new_value = Smi::New(-1);
939 deleted.SetField(field, new_value);
940 field = cls.LookupStaticField(Symbols::_DeletedEnumSentinel());
941 // The static const field contains `Object::null()` instead of
942 // `Object::sentinel()` - so it's not considered an initializing store.
943 field.SetStaticConstFieldValue(deleted,
944 /*assert_initializing_store*/ false);
945 }
946
947 field = cls.LookupField(Symbols::Values());
948 new_values ^= field.StaticConstFieldValue();
949
950 field = object_store()->enum_name_field();
951 while (it.MoveNext()) {
952 old_value ^= set.GetKey(it.Current());
953 ASSERT(old_value.GetClassId() == cid);
954 bool found = false;
955 for (intptr_t j = 0; j < new_values.Length(); j++) {
956 new_value ^= new_values.At(j);
957 ASSERT(new_value.GetClassId() == cid);
958 if (old_value.GetField(field) == new_value.GetField(field)) {
959 found = true;
960 break;
961 }
962 }
963 if (!found) {
964 new_value = deleted.ptr();
965 }
966
967 if (old_value.ptr() != new_value.ptr()) {
968 become->Add(old_value, new_value);
969 }
970 if (new_value.IsCanonical()) {
971 cls.InsertCanonicalConstant(zone, new_value);
972 }
973 }
974 } else {
975 while (it.MoveNext()) {
976 old_value ^= set.GetKey(it.Current());
977 ASSERT(!old_value.IsNull());
978
979 if (become == nullptr) {
980 ASSERT(old_value.IsCanonical());
981 cls.InsertCanonicalConstant(zone, old_value);
982 } else {
983 new_value = old_value.Canonicalize(thread);
984 if (old_value.ptr() != new_value.ptr()) {
985 become->Add(old_value, new_value);
986 }
987 }
988 }
989 }
990 set.Release();
991 }
992
993 // Save memory.
995}
void Add(const Object &before, const Object &after)
Definition become.cc:231
ClassPtr At(intptr_t cid) const
intptr_t NumCids() const
@ kOld
Definition heap.h:39
void ResetCanonicalHashTable()
Definition heap.cc:883
static InstancePtr New(const Class &cls, Heap::Space space=Heap::kNew)
Definition object.cc:20976
Become * become() const
Definition isolate.h:670
static Object & Handle()
Definition object.h:407
static SmiPtr New(intptr_t value)
Definition object.h:9985
static StringPtr FromConcat(Thread *thread, const String &str1, const String &str2)
Definition symbols.cc:235
const char *const name
UnorderedHashSet< CanonicalInstanceTraits > CanonicalInstancesSet
const intptr_t cid
bool IsStringClassId(intptr_t index)
Definition class_id.h:350
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
Definition switches.h:76

◆ ReleaseStoreBuffers()

void dart::IsolateGroup::ReleaseStoreBuffers ( )

Definition at line 2740 of file isolate.cc.

2740 {
2742}

◆ reload_context()

IsolateGroupReloadContext * dart::IsolateGroup::reload_context ( )
inline

Definition at line 649 of file isolate.h.

649 {
650 return group_reload_context_.get();
651 }

◆ reload_every_n_stack_overflow_checks()

intptr_t dart::IsolateGroup::reload_every_n_stack_overflow_checks ( ) const
inline

Definition at line 472 of file isolate.h.

472 {
473 return reload_every_n_stack_overflow_checks_;
474 }

◆ ReloadKernel()

bool dart::IsolateGroup::ReloadKernel ( JSONStream js,
bool  force_reload,
const uint8_t *  kernel_buffer = nullptr,
intptr_t  kernel_buffer_size = 0,
bool  dont_delete_reload_context = false 
)

Definition at line 2066 of file isolate.cc.

2070 {
2071 ASSERT(!IsReloading());
2072
2073 // Ensure all isolates inside the isolate group are paused at a place where we
2074 // can safely do a reload.
2076
2078 std::shared_ptr<IsolateGroupReloadContext> group_reload_context(
2079 new IsolateGroupReloadContext(this, class_table, js));
2080 group_reload_context_ = group_reload_context;
2081
2083 program_reload_context_ =
2084 new ProgramReloadContext(group_reload_context_, this);
2085 const bool success = group_reload_context_->Reload(
2086 force_reload,
2087 /*root_script_url=*/nullptr,
2088 /*packages_url=*/nullptr, kernel_buffer, kernel_buffer_size);
2089 if (!dont_delete_reload_context) {
2091 }
2092 return success;
2093}
void DeleteReloadContext()
Definition isolate.cc:2095
static IsolateGroup * Current()
Definition isolate.h:534
void SetHasAttemptedReload(bool value)
Definition isolate.h:467
#define RELOAD_OPERATION_SCOPE(thread_expr)

◆ ReloadSources()

bool dart::IsolateGroup::ReloadSources ( JSONStream js,
bool  force_reload,
const char *  root_script_url = nullptr,
const char *  packages_url = nullptr,
bool  dont_delete_reload_context = false 
)

Definition at line 2037 of file isolate.cc.

2041 {
2042 ASSERT(!IsReloading());
2043
2044 // Ensure all isolates inside the isolate group are paused at a place where we
2045 // can safely do a reload.
2047
2049 std::shared_ptr<IsolateGroupReloadContext> group_reload_context(
2050 new IsolateGroupReloadContext(this, class_table, js));
2051 group_reload_context_ = group_reload_context;
2052
2054 program_reload_context_ =
2055 new ProgramReloadContext(group_reload_context_, this);
2056 const bool success =
2057 group_reload_context_->Reload(force_reload, root_script_url, packages_url,
2058 /*kernel_buffer=*/nullptr,
2059 /*kernel_buffer_size=*/0);
2060 if (!dont_delete_reload_context) {
2062 }
2063 return success;
2064}

◆ remapping_cids()

bool dart::IsolateGroup::remapping_cids ( ) const
inline

Definition at line 714 of file isolate.h.

714 {
715 return RemappingCidsBit::decode(isolate_group_flags_);
716 }

◆ RememberLiveTemporaries()

void dart::IsolateGroup::RememberLiveTemporaries ( )

Definition at line 2962 of file isolate.cc.

2962 {
2963 ForEachIsolate([&](Isolate* isolate) { isolate->RememberLiveTemporaries(); },
2964 /*at_safepoint=*/true);
2965}

◆ RestoreOriginalClassTable()

void dart::IsolateGroup::RestoreOriginalClassTable ( )

Definition at line 3777 of file isolate.cc.

3777 {
3778 RELEASE_ASSERT(class_table_ != heap_walk_class_table_);
3779 class_table_allocator_.Free(class_table_);
3780 class_table_ = heap_walk_class_table_;
3781 set_cached_class_table_table(class_table_->table());
3782}

◆ RunWithIsolateGroup()

void dart::IsolateGroup::RunWithIsolateGroup ( uint64_t  id,
std::function< void(IsolateGroup *)>  action,
std::function< void()>  not_found 
)
static

Definition at line 684 of file isolate.cc.

687 {
688 ReadRwLocker wl(Thread::Current(), isolate_groups_rwlock_);
689 for (auto isolate_group : *isolate_groups_) {
690 if (isolate_group->id() == id) {
691 action(isolate_group);
692 return;
693 }
694 }
695 not_found();
696}

◆ RunWithLockedGroup()

void dart::IsolateGroup::RunWithLockedGroup ( std::function< void()>  fun)

Definition at line 460 of file isolate.cc.

460 {
461 SafepointWriteRwLocker ml(Thread::Current(), isolates_lock_.get());
462 fun();
463}

◆ RunWithStoppedMutators() [1/2]

template<typename T >
void dart::IsolateGroup::RunWithStoppedMutators ( T  function,
bool  use_force_growth = false 
)
inline

Definition at line 614 of file isolate.h.

614 {
615 LambdaCallable<T> callable(function);
616 RunWithStoppedMutatorsCallable(&callable, &callable, use_force_growth);
617 }
void RunWithStoppedMutatorsCallable(Callable *single_current_mutator, Callable *otherwise, bool use_force_growth_in_otherwise=false)
Definition isolate.cc:2834

◆ RunWithStoppedMutators() [2/2]

template<typename T , typename S >
void dart::IsolateGroup::RunWithStoppedMutators ( T  single_current_mutator,
S  otherwise,
bool  use_force_growth_in_otherwise = false 
)
inline

Definition at line 604 of file isolate.h.

606 {
607 LambdaCallable<T> single_callable(single_current_mutator);
608 LambdaCallable<S> otherwise_callable(otherwise);
609 RunWithStoppedMutatorsCallable(&single_callable, &otherwise_callable,
610 use_force_growth_in_otherwise);
611 }

◆ RunWithStoppedMutatorsCallable()

void dart::IsolateGroup::RunWithStoppedMutatorsCallable ( Callable single_current_mutator,
Callable otherwise,
bool  use_force_growth_in_otherwise = false 
)

Definition at line 2834 of file isolate.cc.

2837 {
2838 auto thread = Thread::Current();
2839 StoppedMutatorsScope stopped_mutators_scope(thread);
2840
2841 if (thread->OwnsSafepoint()) {
2842 RELEASE_ASSERT(thread->OwnsSafepoint());
2843 single_current_mutator->Call();
2844 return;
2845 }
2846
2847 {
2848 SafepointReadRwLocker ml(thread, isolates_lock_.get());
2849 if (thread->IsDartMutatorThread() && ContainsOnlyOneIsolate()) {
2850 single_current_mutator->Call();
2851 return;
2852 }
2853 }
2854
2855 // We use the more strict safepoint operation scope here (which ensures that
2856 // all other threads, including auxiliary threads are at a safepoint), even
2857 // though we only need to ensure that the mutator threads are stopped.
2858 if (use_force_growth_in_otherwise) {
2859 ForceGrowthSafepointOperationScope safepoint_scope(
2861 otherwise->Call();
2862 } else {
2863 DeoptSafepointOperationScope safepoint_scope(thread);
2864 otherwise->Call();
2865 }
2866}
bool ContainsOnlyOneIsolate()
Definition isolate.cc:452
@ kGCAndDeopt
Definition thread.h:293

◆ safepoint_handler()

SafepointHandler * dart::IsolateGroup::safepoint_handler ( )
inline

Definition at line 333 of file isolate.h.

333{ return safepoint_handler_.get(); }

◆ saved_unlinked_calls()

ArrayPtr dart::IsolateGroup::saved_unlinked_calls ( ) const
inline

Definition at line 725 of file isolate.h.

725{ return saved_unlinked_calls_; }

◆ ScheduleInterrupts()

void dart::IsolateGroup::ScheduleInterrupts ( uword  interrupt_bits)

Definition at line 1924 of file isolate.cc.

1924 {
1925 SafepointReadRwLocker ml(Thread::Current(), isolates_lock_.get());
1926 for (Isolate* isolate : isolates_) {
1927 isolate->ScheduleInterrupts(interrupt_bits);
1928 }
1929}

◆ set_all_classes_finalized()

void dart::IsolateGroup::set_all_classes_finalized ( bool  value)
inline

Definition at line 709 of file isolate.h.

709 {
710 isolate_group_flags_ =
711 AllClassesFinalizedBit::update(value, isolate_group_flags_);
712 }

◆ set_asserts()

void dart::IsolateGroup::set_asserts ( bool  value)
inline

Definition at line 452 of file isolate.h.

452 {
453 isolate_group_flags_ =
454 EnableAssertsBit::update(value, isolate_group_flags_);
455 }

◆ set_become()

void dart::IsolateGroup::set_become ( Become become)
inline

Definition at line 671 of file isolate.h.

671{ become_ = become; }

◆ set_branch_coverage()

void dart::IsolateGroup::set_branch_coverage ( bool  value)
inline

Definition at line 457 of file isolate.h.

457 {
458 isolate_group_flags_ =
459 BranchCoverageBit::update(value, isolate_group_flags_);
460 }

◆ set_cached_class_table_table()

void dart::IsolateGroup::set_cached_class_table_table ( ClassPtr *  cached_class_table_table)
inline

Definition at line 392 of file isolate.h.

392 {
393 cached_class_table_table_.store(cached_class_table_table);
394 }
ClassPtr * cached_class_table_table()
Definition isolate.h:389

◆ set_deferred_load_handler()

void dart::IsolateGroup::set_deferred_load_handler ( Dart_DeferredLoadHandler  handler)
inline

Definition at line 559 of file isolate.h.

559 {
560 deferred_load_handler_ = handler;
561 }

◆ set_dispatch_table()

void dart::IsolateGroup::set_dispatch_table ( DispatchTable table)
inline

Definition at line 364 of file isolate.h.

364 {
365 dispatch_table_.reset(table);
366 }
SI F table(const skcms_Curve *curve, F v)

◆ set_dispatch_table_snapshot()

void dart::IsolateGroup::set_dispatch_table_snapshot ( const uint8_t *  snapshot)
inline

Definition at line 370 of file isolate.h.

370 {
371 dispatch_table_snapshot_ = snapshot;
372 }

◆ set_dispatch_table_snapshot_size()

void dart::IsolateGroup::set_dispatch_table_snapshot_size ( intptr_t  size)
inline

Definition at line 376 of file isolate.h.

376 {
377 dispatch_table_snapshot_size_ = size;
378 }
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259

◆ set_initial_field_table()

void dart::IsolateGroup::set_initial_field_table ( std::shared_ptr< FieldTable field_table)
inline

Definition at line 732 of file isolate.h.

732 {
733 initial_field_table_ = field_table;
734 }

◆ set_initial_spawn_successful()

void dart::IsolateGroup::set_initial_spawn_successful ( )
inline

Definition at line 293 of file isolate.h.

293{ initial_spawn_successful_ = true; }

◆ set_last_reload_timestamp()

void dart::IsolateGroup::set_last_reload_timestamp ( int64_t  value)
inline

Definition at line 644 of file isolate.h.

644 {
645 last_reload_timestamp_ = value;
646 }
uint8_t value

◆ set_library_tag_handler()

void dart::IsolateGroup::set_library_tag_handler ( Dart_LibraryTagHandler  handler)
inline

Definition at line 553 of file isolate.h.

553 {
554 library_tag_handler_ = handler;
555 }

◆ set_obfuscation_map()

void dart::IsolateGroup::set_obfuscation_map ( const char **  map)
inline

Definition at line 407 of file isolate.h.

407{ obfuscation_map_ = map; }
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
Definition SkVx.h:680

◆ set_object_store()

void dart::IsolateGroup::set_object_store ( ObjectStore object_store)

Definition at line 1036 of file isolate.cc.

1036 {
1037 object_store_.reset(object_store);
1038}

◆ set_remapping_cids()

void dart::IsolateGroup::set_remapping_cids ( bool  value)
inline

Definition at line 717 of file isolate.h.

717 {
718 isolate_group_flags_ =
719 RemappingCidsBit::update(value, isolate_group_flags_);
720 }

◆ set_saved_unlinked_calls()

void dart::IsolateGroup::set_saved_unlinked_calls ( const Array saved_unlinked_calls)

Definition at line 580 of file isolate.cc.

580 {
581 saved_unlinked_calls_ = saved_unlinked_calls.ptr();
582}
ArrayPtr saved_unlinked_calls() const
Definition isolate.h:725

◆ set_should_load_vmservice()

void dart::IsolateGroup::set_should_load_vmservice ( bool  value)
inline

Definition at line 447 of file isolate.h.

447 {
448 isolate_group_flags_ =
449 ShouldLoadVmServiceBit::update(value, isolate_group_flags_);
450 }

◆ set_use_osr()

void dart::IsolateGroup::set_use_osr ( bool  use_osr)
inline

Definition at line 483 of file isolate.h.

483 {
484 isolate_group_flags_ = UseOsrBit::update(use_osr, isolate_group_flags_);
485 }

◆ SetHasAttemptedReload()

void dart::IsolateGroup::SetHasAttemptedReload ( bool  value)
inline

Definition at line 467 of file isolate.h.

467 {
468 isolate_group_flags_ =
469 HasAttemptedReloadBit::update(value, isolate_group_flags_);
470 }

◆ SetupImagePage()

void dart::IsolateGroup::SetupImagePage ( const uint8_t *  snapshot_buffer,
bool  is_executable 
)

Definition at line 1917 of file isolate.cc.

1918 {
1919 Image image(image_buffer);
1920 heap()->SetupImagePage(image.object_start(), image.object_size(),
1921 is_executable);
1922}
void SetupImagePage(void *pointer, uword size, bool is_executable)
Definition heap.h:276
sk_sp< SkImage > image
Definition examples.cpp:29
CanvasImage Image
Definition dart_ui.cc:55

◆ shareable_source()

std::shared_ptr< IsolateGroupSource > dart::IsolateGroup::shareable_source ( ) const
inline

Definition at line 286 of file isolate.h.

286 {
287 return source_;
288 }

◆ should_load_vmservice()

bool dart::IsolateGroup::should_load_vmservice ( ) const
inline

Definition at line 444 of file isolate.h.

444 {
445 return ShouldLoadVmServiceBit::decode(isolate_group_flags_);
446 }

◆ Shutdown()

void dart::IsolateGroup::Shutdown ( )

Definition at line 492 of file isolate.cc.

492 {
493 char* name = nullptr;
494 // We retrieve the flag value once to avoid the compiler complaining about the
495 // possibly uninitialized value of name, as the compiler is unaware that when
496 // the flag variable is non-const, it is set once during VM initialization and
497 // never changed after, and that modification never runs concurrently with
498 // this method.
499 const bool trace_shutdown = FLAG_trace_shutdown;
500
501 if (trace_shutdown) {
503 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Shutdown starting for group %s\n",
505 }
506 // Ensure to join all threads before waiting for pending GC tasks (the thread
507 // pool can trigger idle notification, which can start new GC tasks).
508 //
509 // (The vm-isolate doesn't have a thread pool.)
510 if (!is_vm_isolate_) {
511 ASSERT(thread_pool_ != nullptr);
512 thread_pool_->Shutdown();
513 thread_pool_.reset();
514 }
515
516 // Needs to happen before starting to destroy the heap so helper tasks like
517 // the SampleBlockProcessor don't try to enter the group during this
518 // tear-down.
520
521 // Wait for any pending GC tasks.
522 if (heap_ != nullptr) {
523 // Wait for any concurrent GC tasks to finish before shutting down.
524 // TODO(rmacnak): Interrupt tasks for faster shutdown.
525 PageSpace* old_space = heap_->old_space();
526 MonitorLocker ml(old_space->tasks_lock());
527 while (old_space->tasks() > 0) {
528 ml.Wait();
529 }
530 // Needs to happen before ~PageSpace so TLS and the thread registry are
531 // still valid.
532 old_space->AbandonMarkingForShutdown();
533 }
534
535 // If the creation of the isolate group (or the first isolate within the
536 // isolate group) failed, we do not invoke the cleanup callback (the
537 // embedder is responsible for handling the creation error).
538 if (initial_spawn_successful_ && !is_vm_isolate_) {
539 auto group_shutdown_callback = Isolate::GroupCleanupCallback();
540 if (group_shutdown_callback != nullptr) {
541 group_shutdown_callback(embedder_data());
542 }
543 }
544
545 delete this;
546
547 // After this isolate group has died we might need to notify a pending
548 // `Dart_Cleanup()` call.
549 {
550 if (trace_shutdown) {
551 OS::PrintErr("[+%" Pd64
552 "ms] SHUTDOWN: Notifying "
553 "isolate group shutdown (%s)\n",
555 }
556 MonitorLocker ml(Isolate::isolate_creation_monitor_);
557 if (!Isolate::creation_enabled_ &&
559 ml.Notify();
560 }
561 if (trace_shutdown) {
562 OS::PrintErr("[+%" Pd64
563 "ms] SHUTDOWN: Done Notifying "
564 "isolate group shutdown (%s)\n",
566 }
567 }
568 if (trace_shutdown) {
569 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Done shutdown for group %s\n",
571 free(name);
572 }
573}
static int64_t UptimeMillis()
Definition dart.h:76
static bool HasApplicationIsolateGroups()
Definition isolate.cc:708
static void UnregisterIsolateGroup(IsolateGroup *isolate_group)
Definition isolate.cc:703
static Dart_IsolateGroupCleanupCallback GroupCleanupCallback()
Definition isolate.h:1184
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static char * StrDup(const char *s)
#define Pd64
Definition globals.h:416

◆ source()

IsolateGroupSource * dart::IsolateGroup::source ( ) const
inline

Definition at line 285 of file isolate.h.

285{ return source_.get(); }

◆ store_buffer()

StoreBuffer * dart::IsolateGroup::store_buffer ( ) const
inline

Definition at line 504 of file isolate.h.

504{ return store_buffer_.get(); }

◆ subtype_test_cache_mutex()

Mutex * dart::IsolateGroup::subtype_test_cache_mutex ( )
inline

Definition at line 511 of file isolate.h.

511{ return &subtype_test_cache_mutex_; }

◆ symbols_mutex()

Mutex * dart::IsolateGroup::symbols_mutex ( )
inline

Definition at line 506 of file isolate.h.

506{ return &symbols_mutex_; }

◆ thread_pool()

MutatorThreadPool * dart::IsolateGroup::thread_pool ( )
inline

Definition at line 736 of file isolate.h.

736{ return thread_pool_.get(); }

◆ thread_registry()

ThreadRegistry * dart::IsolateGroup::thread_registry ( ) const
inline

Definition at line 332 of file isolate.h.

332{ return thread_registry_.get(); }

◆ type_arguments_canonicalization_mutex()

Mutex * dart::IsolateGroup::type_arguments_canonicalization_mutex ( )
inline

Definition at line 508 of file isolate.h.

508 {
509 return &type_arguments_canonicalization_mutex_;
510 }

◆ type_canonicalization_mutex()

Mutex * dart::IsolateGroup::type_canonicalization_mutex ( )
inline

Definition at line 507 of file isolate.h.

507{ return &type_canonicalization_mutex_; }

◆ type_feedback_mutex()

Mutex * dart::IsolateGroup::type_feedback_mutex ( )
inline

Definition at line 513 of file isolate.h.

513{ return &type_feedback_mutex_; }

◆ UnregisterIsolate()

void dart::IsolateGroup::UnregisterIsolate ( Isolate isolate)

Definition at line 465 of file isolate.cc.

465 {
466 SafepointWriteRwLocker ml(Thread::Current(), isolates_lock_.get());
467 isolates_.Remove(isolate);
468}

◆ UnregisterIsolateDecrementCount()

bool dart::IsolateGroup::UnregisterIsolateDecrementCount ( )

Definition at line 470 of file isolate.cc.

470 {
471 SafepointWriteRwLocker ml(Thread::Current(), isolates_lock_.get());
472 isolate_count_--;
473 return isolate_count_ == 0;
474}

◆ UnregisterIsolateGroup()

void dart::IsolateGroup::UnregisterIsolateGroup ( IsolateGroup isolate_group)
static

Definition at line 703 of file isolate.cc.

703 {
704 WriteRwLocker wl(ThreadState::Current(), isolate_groups_rwlock_);
705 isolate_groups_->Remove(isolate_group);
706}

◆ UpdateLastAllocationProfileAccumulatorResetTimestamp()

void dart::IsolateGroup::UpdateLastAllocationProfileAccumulatorResetTimestamp ( )
inline

Definition at line 345 of file isolate.h.

345 {
346 last_allocationprofile_accumulator_reset_timestamp_ =
348 }

◆ UpdateLastAllocationProfileGCTimestamp()

void dart::IsolateGroup::UpdateLastAllocationProfileGCTimestamp ( )
inline

Definition at line 354 of file isolate.h.

354 {
355 last_allocationprofile_gc_timestamp_ = OS::GetCurrentTimeMillis();
356 }

◆ UptimeMicros()

int64_t dart::IsolateGroup::UptimeMicros ( ) const

Definition at line 1946 of file isolate.cc.

1946 {
1947 return OS::GetCurrentMonotonicMicros() - start_time_micros_;
1948}

◆ VisitObjectIdRingPointers()

void dart::IsolateGroup::VisitObjectIdRingPointers ( ObjectPointerVisitor visitor)

Definition at line 2941 of file isolate.cc.

2941 {
2942#if !defined(PRODUCT)
2943 for (Isolate* isolate : isolates_) {
2944 ObjectIdRing* ring = isolate->object_id_ring();
2945 if (ring != nullptr) {
2946 ring->VisitPointers(visitor);
2947 }
2948 }
2949#endif // !defined(PRODUCT)
2950}

◆ VisitObjectPointers()

void dart::IsolateGroup::VisitObjectPointers ( ObjectPointerVisitor visitor,
ValidationPolicy  validate_frames 
)

Definition at line 2868 of file isolate.cc.

2869 {
2870 VisitSharedPointers(visitor);
2871 for (Isolate* isolate : isolates_) {
2872 isolate->VisitObjectPointers(visitor, validate_frames);
2873 }
2874 VisitStackPointers(visitor, validate_frames);
2875}
void VisitStackPointers(ObjectPointerVisitor *visitor, ValidationPolicy validate_frames)
Definition isolate.cc:2924
void VisitSharedPointers(ObjectPointerVisitor *visitor)
Definition isolate.cc:2877

◆ VisitSharedPointers()

void dart::IsolateGroup::VisitSharedPointers ( ObjectPointerVisitor visitor)

Definition at line 2877 of file isolate.cc.

2877 {
2878 // Visit objects in the class table.
2879 class_table()->VisitObjectPointers(visitor);
2882 }
2884 // Visit objects in the object store.
2885 if (object_store() != nullptr) {
2887 }
2888 visitor->VisitPointer(reinterpret_cast<ObjectPtr*>(&saved_unlinked_calls_));
2890
2891 // Visit the boxed_field_list_.
2892 // 'boxed_field_list_' access via mutator and background compilation threads
2893 // is guarded with a monitor. This means that we can visit it only
2894 // when at safepoint or the field_list_mutex_ lock has been taken.
2895 visitor->VisitPointer(reinterpret_cast<ObjectPtr*>(&boxed_field_list_));
2896
2897 NOT_IN_PRECOMPILED(background_compiler()->VisitPointers(visitor));
2898
2899#if !defined(PRODUCT)
2900 if (debugger() != nullptr) {
2901 debugger()->VisitObjectPointers(visitor);
2902 }
2903#endif
2904
2905#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
2906 // Visit objects that are being used for isolate reload.
2907 if (program_reload_context() != nullptr) {
2908 program_reload_context()->VisitObjectPointers(visitor);
2909 program_reload_context()->group_reload_context()->VisitObjectPointers(
2910 visitor);
2911 }
2912#endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
2913
2914 if (source()->loaded_blobs_ != nullptr) {
2915 visitor->VisitPointer(
2916 reinterpret_cast<ObjectPtr*>(&(source()->loaded_blobs_)));
2917 }
2918
2919 if (become() != nullptr) {
2920 become()->VisitObjectPointers(visitor);
2921 }
2922}
void VisitObjectPointersUnlocked(ObjectPointerVisitor *visitor)
void VisitObjectPointers(ObjectPointerVisitor *visitor)
Definition become.cc:236
void VisitObjectPointers(ObjectPointerVisitor *visitor)
void VisitObjectPointers(ObjectPointerVisitor *visitor)
void VisitObjectPointers(ObjectPointerVisitor *visitor)
Definition debugger.cc:3005
GroupDebugger * debugger() const
Definition isolate.h:314
ApiState * api_state() const
Definition isolate.h:693
ClassTable * heap_walk_class_table() const
Definition isolate.h:498
BackgroundCompiler * background_compiler() const
Definition isolate.h:297
void VisitObjectPointers(ObjectPointerVisitor *visitor)
IsolateGroupReloadContext * group_reload_context()
#define NOT_IN_PRECOMPILED(code)
Definition globals.h:100

◆ VisitStackPointers()

void dart::IsolateGroup::VisitStackPointers ( ObjectPointerVisitor visitor,
ValidationPolicy  validate_frames 
)

Definition at line 2924 of file isolate.cc.

2925 {
2926 visitor->set_gc_root_type("stack");
2927
2928 // Visit objects in all threads (e.g. Dart stack, handles in zones), except
2929 // for the mutator threads themselves.
2930 thread_registry()->VisitObjectPointers(this, visitor, validate_frames);
2931
2932 for (Isolate* isolate : isolates_) {
2933 // Visit mutator thread, even if the isolate isn't entered/scheduled
2934 // (there might be live API handles to visit).
2935 isolate->VisitStackPointers(visitor, validate_frames);
2936 }
2937
2938 visitor->clear_gc_root_type();
2939}
void VisitObjectPointers(IsolateGroup *isolate_group_of_interest, ObjectPointerVisitor *visitor, ValidationPolicy validate_frames)

◆ VisitWeakPersistentHandles()

void dart::IsolateGroup::VisitWeakPersistentHandles ( HandleVisitor visitor)

Definition at line 2952 of file isolate.cc.

2952 {
2954}
void VisitWeakHandlesUnlocked(HandleVisitor *visitor)

Friends And Related Symbol Documentation

◆ Dart

friend class Dart
friend

Definition at line 746 of file isolate.h.

◆ Heap

friend class Heap
friend

Definition at line 747 of file isolate.h.

◆ Isolate

friend class Isolate
friend

Definition at line 750 of file isolate.h.

◆ StackFrame

friend class StackFrame
friend

Definition at line 748 of file isolate.h.


The documentation for this class was generated from the following files: