5#ifndef RUNTIME_VM_ISOLATE_H_
6#define RUNTIME_VM_ISOLATE_H_
8#if defined(SHOULD_NOT_INCLUDE_RUNTIME)
9#error "Should not include runtime"
45class BackgroundCompiler;
51class ExternalTypedData;
57class IsolateGroupReloadContext;
58class IsolateMessageHandler;
59class IsolateObjectStore;
60class IsolateProfilerData;
68class ObjectPointerVisitor;
70class PersistentHandle;
71class ProgramReloadContext;
73class SafepointHandler;
76class SampleBlockBuffer;
79class SerializedObjectBuffer;
136#define BOOL_ISOLATE_GROUP_FLAG_LIST(V) \
137 V(PRECOMPILER, obfuscate, Obfuscate, obfuscate, false) \
138 V(NONPRODUCT, asserts, EnableAsserts, enable_asserts, FLAG_enable_asserts) \
139 V(NONPRODUCT, use_field_guards, UseFieldGuards, use_field_guards, \
140 FLAG_use_field_guards) \
141 V(PRODUCT, should_load_vmservice_library, ShouldLoadVmService, \
142 load_vmservice_library, false) \
143 V(NONPRODUCT, use_osr, UseOsr, use_osr, FLAG_use_osr) \
144 V(NONPRODUCT, snapshot_is_dontneed_safe, SnapshotIsDontNeedSafe, \
145 snapshot_is_dontneed_safe, false) \
146 V(NONPRODUCT, branch_coverage, BranchCoverage, branch_coverage, \
147 FLAG_branch_coverage)
151#define BOOL_ISOLATE_FLAG_LIST(V) \
152 V(NONPRODUCT, is_system_isolate, IsSystemIsolate, is_system_isolate, false) \
153 V(NONPRODUCT, is_service_isolate, IsServiceIsolate, is_service_isolate, \
155 V(NONPRODUCT, is_kernel_isolate, IsKernelIsolate, is_kernel_isolate, false)
236 Heap* heap_ =
nullptr;
237 intptr_t disabled_counter_ = 0;
238 int64_t idle_start_time_ = 0;
254 :
ThreadPool(max_pool_size), isolate_group_(isolate_group) {}
282 void ValidateClassTable();
298#if defined(DART_PRECOMPILED_RUNTIME)
301 return background_compiler_.get();
304#if !defined(DART_PRECOMPILED_RUNTIME)
309 return FLAG_optimization_counter_threshold;
336 void SetupImagePage(
const uint8_t* snapshot_buffer,
bool is_executable);
339#define ISOLATE_METRIC_ACCESSOR(type, variable, name, unit) \
340 type* Get##variable##Metric() { return &metric_##variable##_; }
342#undef ISOLATE_METRIC_ACCESSOR
346 last_allocationprofile_accumulator_reset_timestamp_ =
351 return last_allocationprofile_accumulator_reset_timestamp_;
359 return last_allocationprofile_gc_timestamp_;
365 dispatch_table_.reset(
table);
368 return dispatch_table_snapshot_;
371 dispatch_table_snapshot_ = snapshot;
374 return dispatch_table_snapshot_size_;
377 dispatch_table_snapshot_size_ = size;
381 return &class_table_allocator_;
390 return cached_class_table_table_.
load();
419#if defined(DART_PRECOMPILER)
420#define FLAG_FOR_PRECOMPILER(from_field, from_flag) (from_field)
422#define FLAG_FOR_PRECOMPILER(from_field, from_flag) (from_flag)
426#define FLAG_FOR_NONPRODUCT(from_field, from_flag) (from_field)
428#define FLAG_FOR_NONPRODUCT(from_field, from_flag) (from_flag)
431#define FLAG_FOR_PRODUCT(from_field, from_flag) (from_field)
433#define DECLARE_GETTER(when, name, bitname, isolate_flag_name, flag_name) \
434 bool name() const { \
435 return FLAG_FOR_##when(bitname##Bit::decode(isolate_group_flags_), \
439#undef FLAG_FOR_NONPRODUCT
440#undef FLAG_FOR_PRECOMPILER
441#undef FLAG_FOR_PRODUCT
445 return ShouldLoadVmServiceBit::decode(isolate_group_flags_);
448 isolate_group_flags_ =
449 ShouldLoadVmServiceBit::update(
value, isolate_group_flags_);
453 isolate_group_flags_ =
454 EnableAssertsBit::update(
value, isolate_group_flags_);
458 isolate_group_flags_ =
459 BranchCoverageBit::update(
value, isolate_group_flags_);
463#if !defined(DART_PRECOMPILED_RUNTIME)
465 return HasAttemptedReloadBit::decode(isolate_group_flags_);
468 isolate_group_flags_ =
469 HasAttemptedReloadBit::update(
value, isolate_group_flags_);
473 return reload_every_n_stack_overflow_checks_;
484 isolate_group_flags_ = UseOsrBit::update(use_osr, isolate_group_flags_);
509 return &type_arguments_canonicalization_mutex_;
516 return &constant_canonicalization_mutex_;
520 return &kernel_data_class_cache_mutex_;
524#if defined(DART_PRECOMPILED_RUNTIME)
525 Mutex* unlinked_call_map_mutex() {
return &unlinked_call_map_mutex_; }
528#if !defined(DART_PRECOMPILED_RUNTIME)
536 return thread ==
nullptr ? nullptr : thread->
isolate_group();
543 return active_mutators_;
551 return library_tag_handler_;
554 library_tag_handler_ = handler;
557 return deferred_load_handler_;
560 deferred_load_handler_ = handler;
572 return deferred_marking_stack_;
584 bool at_safepoint =
false);
601 bool use_force_growth_in_otherwise =
false);
603 template <
typename T,
typename S>
606 bool use_force_growth_in_otherwise =
false) {
610 use_force_growth_in_otherwise);
613 template <
typename T>
628#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
633 const char* root_script_url =
nullptr,
634 const char* packages_url =
nullptr,
635 bool dont_delete_reload_context =
false);
640 const uint8_t* kernel_buffer =
nullptr,
641 intptr_t kernel_buffer_size = 0,
642 bool dont_delete_reload_context =
false);
645 last_reload_timestamp_ =
value;
650 return group_reload_context_.get();
653 return program_reload_context_;
663#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
664 return group_reload_context_ !=
nullptr;
673 uint64_t
id()
const {
return id_; }
681 std::function<
void()> not_found);
707 return AllClassesFinalizedBit::decode(isolate_group_flags_);
710 isolate_group_flags_ =
711 AllClassesFinalizedBit::update(
value, isolate_group_flags_);
715 return RemappingCidsBit::decode(isolate_group_flags_);
718 isolate_group_flags_ =
719 RemappingCidsBit::update(
value, isolate_group_flags_);
730 return initial_field_table_;
733 initial_field_table_ = field_table;
752#define ISOLATE_GROUP_FLAG_BITS(V) \
753 V(AllClassesFinalized) \
755 V(HasAttemptedReload) \
757 V(ShouldLoadVmService) \
761 V(SnapshotIsDontNeedSafe) \
766#define DECLARE_BIT(Name) k##Name##Bit,
771#define DECLARE_BITFIELD(Name) \
772 class Name##Bit : public BitField<uint32_t, bool, k##Name##Bit, 1> {};
774#undef DECLARE_BITFIELD
776 void set_heap(std::unique_ptr<Heap> value);
779 ClassTable* class_table_;
780 AcqRelAtomic<ClassPtr*> cached_class_table_table_;
781 std::unique_ptr<ObjectStore> object_store_;
784 ClassTableAllocator class_table_allocator_;
785 ClassTable* heap_walk_class_table_;
787 const char** obfuscation_map_ =
nullptr;
789 bool is_vm_isolate_ =
false;
790 void* embedder_data_ =
nullptr;
792 IdleTimeHandler idle_time_handler_;
793 std::unique_ptr<MutatorThreadPool> thread_pool_;
794 std::unique_ptr<SafepointRwLock> isolates_lock_;
795 IntrusiveDList<Isolate> isolates_;
796 intptr_t isolate_count_ = 0;
797 bool initial_spawn_successful_ =
false;
800 int64_t start_time_micros_;
801 bool is_system_isolate_group_;
804#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
805 int64_t last_reload_timestamp_;
806 std::shared_ptr<IsolateGroupReloadContext> group_reload_context_;
808 RelaxedAtomic<intptr_t> reload_every_n_stack_overflow_checks_;
809 ProgramReloadContext* program_reload_context_ =
nullptr;
811 Become* become_ =
nullptr;
813#define ISOLATE_METRIC_VARIABLE(type, variable, name, unit) \
814 type metric_##variable##_;
816#undef ISOLATE_METRIC_VARIABLE
820 int64_t last_allocationprofile_accumulator_reset_timestamp_ = 0;
821 int64_t last_allocationprofile_gc_timestamp_ = 0;
825 MarkingStack* marking_stack_ =
nullptr;
826 MarkingStack* deferred_marking_stack_ =
nullptr;
827 std::shared_ptr<IsolateGroupSource> source_;
828 std::unique_ptr<ApiState> api_state_;
829 std::unique_ptr<ThreadRegistry> thread_registry_;
830 std::unique_ptr<SafepointHandler> safepoint_handler_;
832 static RwLock* isolate_groups_rwlock_;
833 static IntrusiveDList<IsolateGroup>* isolate_groups_;
834 static Random* isolate_group_random_;
838 std::unique_ptr<StoreBuffer> store_buffer_;
839 std::unique_ptr<Heap> heap_;
840 std::unique_ptr<DispatchTable> dispatch_table_;
841 const uint8_t* dispatch_table_snapshot_ =
nullptr;
842 intptr_t dispatch_table_snapshot_size_ = 0;
843 ArrayPtr saved_unlinked_calls_;
844 std::shared_ptr<FieldTable> initial_field_table_;
845 uint32_t isolate_group_flags_ = 0;
849 Mutex symbols_mutex_;
850 Mutex type_canonicalization_mutex_;
851 Mutex type_arguments_canonicalization_mutex_;
852 Mutex subtype_test_cache_mutex_;
853 Mutex megamorphic_table_mutex_;
854 Mutex type_feedback_mutex_;
855 Mutex patchable_call_mutex_;
856 Mutex constant_canonicalization_mutex_;
857 Mutex kernel_data_lib_cache_mutex_;
858 Mutex kernel_data_class_cache_mutex_;
859 Mutex kernel_constants_mutex_;
861#if defined(DART_PRECOMPILED_RUNTIME)
862 Mutex unlinked_call_map_mutex_;
865#if !defined(DART_PRECOMPILED_RUNTIME)
866 Mutex initializer_functions_mutex_;
870 Mutex field_list_mutex_;
872 GrowableObjectArrayPtr boxed_field_list_;
877 std::unique_ptr<SafepointRwLock> program_lock_;
880 std::unique_ptr<Monitor> active_mutators_monitor_;
881 intptr_t active_mutators_ = 0;
882 intptr_t waiting_mutators_ = 0;
883 intptr_t max_active_mutators_ = 0;
941 return thread ==
nullptr ? nullptr : thread->
isolate();
961 return isolate_object_store_.get();
965 return message_notify_callback_.load(std::memory_order_relaxed);
969 message_notify_callback_.store(
value, std::memory_order_release);
973 on_shutdown_callback_ =
value;
976 return on_shutdown_callback_;
979 on_cleanup_callback_ =
value;
982 return on_cleanup_callback_;
986 bequest_ = std::move(bequest);
996 const char*
name()
const {
return name_; }
1011 terminate_capability_ =
value;
1018 uint64_t capability);
1029 return environment_callback_;
1032 environment_callback_ =
value;
1048 bool is_runnable()
const {
return LoadIsolateFlagsBit<IsRunnableBit>(); }
1050 UpdateIsolateFlagsBit<IsRunnableBit>(
value);
1051#if !defined(PRODUCT)
1060#if !defined(PRODUCT)
1066 current_sample_block_ = block;
1072 return current_allocation_sample_block_;
1075 current_allocation_sample_block_ = block;
1079 return has_completed_blocks_.
exchange(0) != 0;
1082 return has_completed_blocks_.
exchange(1) == 0;
1092 has_resumption_breakpoints_ =
value;
1095 return has_resumption_breakpoints_;
1104 UpdateIsolateFlagsBit<ResumeRequestBit>(
true);
1117 return UpdateIsolateFlagsBit<ResumeRequestBit>(
false);
1139 bool ErrorsFatal()
const {
return LoadIsolateFlagsBit<ErrorsFatalBit>(); }
1141 UpdateIsolateFlagsBit<ErrorsFatalBit>(
value);
1154 create_group_callback_ = cb;
1157 return create_group_callback_;
1161 initialize_callback_ = cb;
1164 return initialize_callback_;
1168 shutdown_callback_ = cb;
1171 return shutdown_callback_;
1175 cleanup_callback_ = cb;
1178 return cleanup_callback_;
1182 cleanup_group_callback_ = cb;
1185 return cleanup_group_callback_;
1189 register_kernel_blob_callback_ = cb;
1192 return register_kernel_blob_callback_;
1196 unregister_kernel_blob_callback_ = cb;
1199 return unregister_kernel_blob_callback_;
1202#if !defined(PRODUCT)
1210 ASSERT(
value ==
nullptr || deopt_context_ ==
nullptr);
1211 deopt_context_ =
value;
1222 bool keep_isolate_alive);
1230 bool keep_isolate_alive);
1235 return ffi_callback_list_head_;
1239 ASSERT(defer_finalization_count_ >= 0);
1240 return defer_finalization_count_++;
1244 ASSERT(defer_finalization_count_ > 0);
1245 return defer_finalization_count_--;
1249 ASSERT(defer_finalization_count_ >= 0);
1250 return defer_finalization_count_ == 0;
1263#if !defined(PRODUCT)
1269#if !defined(PRODUCT)
1271 return LoadIsolateFlagsBit<ShouldPausePostServiceRequestBit>();
1274 UpdateIsolateFlagsBit<ShouldPausePostServiceRequestBit>(
value);
1289#if !defined(PRODUCT)
1290#define ISOLATE_METRIC_ACCESSOR(type, variable, name, unit) \
1291 type* Get##variable##Metric() { return &metric_##variable##_; }
1293#undef ISOLATE_METRIC_ACCESSOR
1298 GrowableObjectArrayPtr
tag_table()
const {
return tag_table_; }
1316 const String& method_name,
1317 const Array& parameter_keys,
1318 const Array& parameter_values,
1328#if !defined(PRODUCT)
1335 UpdateIsolateFlagsBit<IsVMIsolateBit>(
value);
1339 return LoadIsolateFlagsBit<IsServiceRegisteredBit>();
1342 UpdateIsolateFlagsBit<IsServiceRegisteredBit>(
value);
1350#if defined(DART_PRECOMPILER)
1351#define FLAG_FOR_PRECOMPILER(from_field, from_flag) (from_field)
1353#define FLAG_FOR_PRECOMPILER(from_field, from_flag) (from_flag)
1356#if !defined(PRODUCT)
1357#define FLAG_FOR_NONPRODUCT(from_field, from_flag) (from_field)
1359#define FLAG_FOR_NONPRODUCT(from_field, from_flag) (from_flag)
1362#define FLAG_FOR_PRODUCT(from_field, from_flag) (from_field)
1364#define DECLARE_GETTER(when, name, bitname, isolate_flag_name, flag_name) \
1365 bool name() const { \
1366 return FLAG_FOR_##when(LoadIsolateFlagsBit<bitname##Bit>(), flag_name); \
1369#undef FLAG_FOR_NONPRODUCT
1370#undef FLAG_FOR_PRECOMPILER
1371#undef FLAG_FOR_PRODUCT
1372#undef DECLARE_GETTER
1375 return LoadIsolateFlagsBit<HasAttemptedSteppingBit>();
1378 UpdateIsolateFlagsBit<HasAttemptedSteppingBit>(
value);
1406 return &catch_entry_moves_cache_;
1421 return std::move(regexp_backtracking_stack_cache_);
1425 regexp_backtracking_stack_cache_ = std::move(stack);
1433 return &pointers_to_verify_at_exit_;
1445 static void InitVM();
1446 static Isolate* InitIsolate(
const char* name_prefix,
1455 void RunAndCleanupFinalizersOnShutdown();
1456 void LowLevelShutdown();
1461 static void LowLevelCleanup(
Isolate* isolate);
1463 void BuildName(
const char* name_prefix);
1474 void set_user_tag(
uword tag) { user_tag_ = tag; }
1476 void set_is_system_isolate(
bool is_system_isolate) {
1477 is_system_isolate_ = is_system_isolate;
1480#if !defined(PRODUCT)
1481 GrowableObjectArrayPtr GetAndClearPendingServiceExtensionCalls();
1482 GrowableObjectArrayPtr pending_service_extension_calls()
const {
1483 return pending_service_extension_calls_;
1485 void set_pending_service_extension_calls(
const GrowableObjectArray& value);
1486 GrowableObjectArrayPtr registered_service_extension_handlers()
const {
1487 return registered_service_extension_handlers_;
1489 void set_registered_service_extension_handlers(
1490 const GrowableObjectArray& value);
1495 Zone* current_zone()
const {
1506 uword user_tag_ = 0;
1507 UserTagPtr current_tag_;
1508 UserTagPtr default_tag_;
1509 FieldTable* field_table_ =
nullptr;
1512 GrowableObjectArrayPtr finalizers_;
1513 bool single_step_ =
false;
1514 bool has_resumption_breakpoints_ =
false;
1515 bool is_system_isolate_ =
false;
1519 IdleTimeHandler idle_time_handler_;
1520 std::unique_ptr<IsolateObjectStore> isolate_object_store_;
1522#define ISOLATE_FLAG_BITS(V) \
1526 V(IsServiceIsolate) \
1527 V(IsKernelIsolate) \
1529 V(HasAttemptedStepping) \
1530 V(ShouldPausePostServiceRequest) \
1531 V(IsSystemIsolate) \
1532 V(IsServiceRegistered)
1536#define DECLARE_BIT(Name) k##Name##Bit,
1541#define DECLARE_BITFIELD(Name) \
1542 class Name##Bit : public BitField<uint32_t, bool, k##Name##Bit, 1> {};
1544#undef DECLARE_BITFIELD
1547 bool UpdateIsolateFlagsBit(
bool value) {
1548 return T::decode(value ? isolate_flags_.fetch_or(T::encode(
true),
1549 std::memory_order_relaxed)
1550 : isolate_flags_.fetch_and(
1554 bool LoadIsolateFlagsBit()
const {
1555 return T::decode(isolate_flags_.load(std::memory_order_relaxed));
1557 std::atomic<uint32_t> isolate_flags_;
1561#if !defined(PRODUCT)
1562 Debugger* debugger_ =
nullptr;
1565 RelaxedAtomic<SampleBlock*> current_sample_block_ =
nullptr;
1568 RelaxedAtomic<SampleBlock*> current_allocation_sample_block_ =
nullptr;
1570 RelaxedAtomic<uword> has_completed_blocks_ = {0};
1572 int64_t last_resume_timestamp_;
1574 VMTagCounters vm_tag_counters_;
1577 enum {kPendingHandlerIndex = 0, kPendingMethodNameIndex, kPendingKeysIndex,
1578 kPendingValuesIndex, kPendingReplyPortIndex, kPendingIdIndex,
1580 GrowableObjectArrayPtr pending_service_extension_calls_;
1583 enum {kRegisteredNameIndex = 0, kRegisteredHandlerIndex,
1584 kRegisteredEntrySize};
1585 GrowableObjectArrayPtr registered_service_extension_handlers_;
1588 Monitor* pause_loop_monitor_ =
nullptr;
1590#define ISOLATE_METRIC_VARIABLE(type, variable, name, unit) \
1591 type metric_##variable##_;
1593#undef ISOLATE_METRIC_VARIABLE
1596 ObjectIdRing* object_id_ring_ =
nullptr;
1600 int64_t start_time_micros_;
1601 std::atomic<Dart_MessageNotifyCallback> message_notify_callback_;
1604 char* name_ =
nullptr;
1608 Mutex origin_id_mutex_;
1609 uint64_t pause_capability_ = 0;
1610 uint64_t terminate_capability_ = 0;
1611 void* init_callback_data_ =
nullptr;
1614 Simulator* simulator_ =
nullptr;
1616 IsolateMessageHandler* message_handler_ =
nullptr;
1617 intptr_t defer_finalization_count_ = 0;
1618 DeoptContext* deopt_context_ =
nullptr;
1619 FfiCallbackMetadata::Metadata* ffi_callback_list_head_ =
nullptr;
1620 intptr_t ffi_callback_keep_alive_counter_ = 0;
1622 GrowableObjectArrayPtr tag_table_;
1624 ErrorPtr sticky_error_;
1626 std::unique_ptr<Bequest> bequest_;
1631 Monitor spawn_count_monitor_;
1632 intptr_t spawn_count_ = 0;
1637 DispatchTable* dispatch_table_ =
nullptr;
1640 std::unique_ptr<WeakTable> forward_table_new_;
1641 std::unique_ptr<WeakTable> forward_table_old_;
1646 bool accepts_messages_ =
false;
1648 std::unique_ptr<VirtualMemory> regexp_backtracking_stack_cache_ =
nullptr;
1650 intptr_t wake_pause_event_handler_count_;
1653 intptr_t open_ports_ = 0;
1656 intptr_t open_ports_keepalive_ = 0;
1666#if !defined(PRODUCT)
1667 static void WakePauseEventHandler(
Dart_Isolate isolate);
1671 static bool TryMarkIsolateReady(Isolate* isolate);
1672 static void UnMarkIsolateReady(Isolate* isolate);
1673 static void MaybeNotifyVMShutdown();
1674 bool AcceptsMessagesLocked() {
1676 return accepts_messages_;
1680 static Monitor* isolate_creation_monitor_;
1681 static bool creation_enabled_;
1683 ArrayPtr loaded_prefixes_set_storage_;
1685 MallocGrowableArray<ObjectPtr> pointers_to_verify_at_exit_;
1687#define REUSABLE_FRIEND_DECLARATION(name) \
1688 friend class Reusable##name##HandleScope;
1690#undef REUSABLE_FRIEND_DECLARATION
1713 : new_isolate_(new_isolate), saved_isolate_(
Isolate::Current()) {
1714 if (new_isolate_ ==
nullptr) {
1719 if (saved_isolate_ != new_isolate_) {
1728 if (new_isolate_ ==
nullptr) {
1733 if (saved_isolate_ != new_isolate_) {
1734 ASSERT(saved_isolate_ ==
nullptr);
1751 : isolate_group_(isolate_group) {
1777 outer_ = thread_->no_active_isolate_scope_;
1778 saved_isolate_ = thread_->isolate_;
1780 thread_->no_active_isolate_scope_ =
this;
1781 thread_->isolate_ =
nullptr;
1784 ASSERT(thread_->isolate_ ==
nullptr);
1785 thread_->isolate_ = saved_isolate_;
1786 thread_->no_active_isolate_scope_ = outer_;
1801 thread->no_active_isolate_scope_->saved_isolate_) {}
1806 thread_->isolate_ = isolate;
1809 ASSERT(thread_->isolate_ !=
nullptr);
1810 thread_->isolate_ =
nullptr;
static void encode(uint8_t output[16], const uint32_t input[4])
#define RELEASE_ASSERT(cond)
#define COMPILE_ASSERT(expr)
T load(std::memory_order order=std::memory_order_acquire) const
void store(T arg, std::memory_order order=std::memory_order_release)
ActiveIsolateScope(Thread *thread, Isolate *isolate)
ActiveIsolateScope(Thread *thread)
Thread * scheduled_mutator_thread_
PersistentHandle * TakeHandle()
Bequest(PersistentHandle *handle, Dart_Port beneficiary)
PersistentHandle * handle()
EnterIsolateGroupScope(IsolateGroup *isolate_group)
~EnterIsolateGroupScope()
void InitializeWithHeap(Heap *heap)
bool ShouldNotifyIdle(int64_t *expiry)
bool ShouldCheckForIdle()
void NotifyIdleUsingDefaultDeadline()
void UpdateStartIdleTime()
void NotifyIdle(int64_t deadline)
const uint8_t * script_kernel_buffer
const uint8_t * kernel_buffer
intptr_t script_kernel_size
const intptr_t kernel_buffer_size
IsolateGroupSource(const char *script_uri, const char *name, const uint8_t *snapshot_data, const uint8_t *snapshot_instructions, const uint8_t *kernel_buffer, intptr_t kernel_buffer_size, Dart_IsolateFlags flags)
const uint8_t * snapshot_instructions
const uint8_t * snapshot_data
void add_loaded_blob(Zone *zone_, const ExternalTypedData &external_typed_data)
void IncreaseMutatorCount(Isolate *mutator, bool is_nested_reenter)
GroupDebugger * debugger() const
void RunWithLockedGroup(std::function< void()> fun)
int64_t UptimeMicros() const
void RestoreOriginalClassTable()
void set_use_osr(bool use_osr)
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)
StoreBuffer * store_buffer() const
bool remapping_cids() const
void UnregisterIsolate(Isolate *isolate)
Mutex * kernel_data_class_cache_mutex()
void ForEachIsolate(std::function< void(Isolate *isolate)> function, bool at_safepoint=false)
void set_cached_class_table_table(ClassPtr *cached_class_table_table)
bool UnregisterIsolateDecrementCount()
void DeleteReloadContext()
void VisitStackPointers(ObjectPointerVisitor *visitor, ValidationPolicy validate_frames)
MutatorThreadPool * thread_pool()
bool should_load_vmservice() const
static bool IsSystemIsolateGroup(const IsolateGroup *group)
void ScheduleInterrupts(uword interrupt_bits)
intptr_t optimization_counter_threshold() const
void RegisterClass(const Class &cls)
const char ** obfuscation_map() const
ClassTableAllocator * class_table_allocator()
bool all_classes_finalized() const
void * embedder_data() const
void RehashConstants(Become *become)
void FlagsCopyFrom(const Dart_IsolateFlags &api_flags)
void DropOriginalClassTable()
MarkingStack * deferred_marking_stack() const
void set_should_load_vmservice(bool value)
void set_all_classes_finalized(bool value)
bool initial_spawn_successful()
void set_dispatch_table_snapshot(const uint8_t *snapshot)
bool ContainsOnlyOneIsolate()
void FreeStaticField(const Field &field)
ObjectStore * object_store() const
SafepointRwLock * program_lock()
ClassPtr * cached_class_table_table()
void DisableIncrementalBarrier()
void CloneClassTableForReload()
static IsolateGroup * Current()
std::shared_ptr< IsolateGroupSource > shareable_source() const
Dart_LibraryTagHandler library_tag_handler() const
void RegisterStaticField(const Field &field, const Object &initial_value)
ClassTable * class_table() const
void set_last_reload_timestamp(int64_t value)
static intptr_t class_table_offset()
static bool HasOnlyVMIsolateGroup()
bool is_system_isolate_group() const
void DecreaseMutatorCount(Isolate *mutator, bool is_nested_exit)
void set_initial_field_table(std::shared_ptr< FieldTable > field_table)
Mutex * type_arguments_canonicalization_mutex()
void VisitObjectIdRingPointers(ObjectPointerVisitor *visitor)
IsolateGroupReloadContext * reload_context()
void set_object_store(ObjectStore *object_store)
Mutex * initializer_functions_mutex()
ApiState * api_state() const
FieldTable * initial_field_table() const
intptr_t reload_every_n_stack_overflow_checks() const
void VisitObjectPointers(ObjectPointerVisitor *visitor, ValidationPolicy validate_frames)
void set_library_tag_handler(Dart_LibraryTagHandler handler)
IsolateGroupSource * source() const
bool ReloadSources(JSONStream *js, bool force_reload, const char *root_script_url=nullptr, const char *packages_url=nullptr, bool dont_delete_reload_context=false)
void set_saved_unlinked_calls(const Array &saved_unlinked_calls)
void SetHasAttemptedReload(bool value)
void SetupImagePage(const uint8_t *snapshot_buffer, bool is_executable)
int64_t last_allocationprofile_gc_timestamp() const
ClassTable * heap_walk_class_table() const
Mutex * kernel_constants_mutex()
ArrayPtr saved_unlinked_calls() const
void set_remapping_cids(bool value)
void RunWithStoppedMutators(T single_current_mutator, S otherwise, bool use_force_growth_in_otherwise=false)
Mutex * type_feedback_mutex()
Isolate * FirstIsolateLocked() const
void PrintJSON(JSONStream *stream, bool ref=true)
void EnableIncrementalBarrier(MarkingStack *marking_stack, MarkingStack *deferred_marking_stack)
Mutex * type_canonicalization_mutex()
void ReleaseStoreBuffers()
void set_obfuscation_map(const char **map)
static void ExitTemporaryIsolate()
void RememberLiveTemporaries()
void FlagsCopyTo(Dart_IsolateFlags *api_flags)
void RunWithStoppedMutatorsCallable(Callable *single_current_mutator, Callable *otherwise, bool use_force_growth_in_otherwise=false)
SafepointHandler * safepoint_handler()
void set_initial_spawn_successful()
Mutex * patchable_call_mutex()
intptr_t MutatorCount() const
void set_become(Become *become)
std::shared_ptr< FieldTable > initial_field_table_shareable()
void VisitWeakPersistentHandles(HandleVisitor *visitor)
static void RunWithIsolateGroup(uint64_t id, std::function< void(IsolateGroup *)> action, std::function< void()> not_found)
void set_dispatch_table_snapshot_size(intptr_t size)
void DeferredMarkLiveTemporaries()
Mutex * constant_canonicalization_mutex()
void RegisterIsolate(Isolate *isolate)
int64_t last_reload_timestamp() const
Mutex * kernel_data_lib_cache_mutex()
void MaybeIncreaseReloadEveryNStackOverflowChecks()
void set_branch_coverage(bool value)
intptr_t dispatch_table_snapshot_size() const
DispatchTable * dispatch_table() const
ISOLATE_GROUP_METRIC_LIST(ISOLATE_METRIC_ACCESSOR)
BackgroundCompiler * background_compiler() const
void UpdateLastAllocationProfileAccumulatorResetTimestamp()
static void RegisterIsolateGroup(IsolateGroup *isolate_group)
MarkingStack * marking_stack() const
ThreadRegistry * thread_registry() const
Isolate * FirstIsolate() const
ObjectPtr CallTagHandler(Dart_LibraryTag tag, const Object &arg1, const Object &arg2)
Mutex * megamorphic_table_mutex()
static intptr_t cached_class_table_table_offset()
IdleTimeHandler * idle_time_handler()
bool HasAttemptedReload() const
bool is_vm_isolate() const
Isolate * EnterTemporaryIsolate()
static bool HasApplicationIsolateGroups()
Dart_DeferredLoadHandler deferred_load_handler() const
void PrintToJSONObject(JSONObject *jsobj, bool ref)
static void ForEach(std::function< void(IsolateGroup *)> action)
void FlushMarkingStacks()
const uint8_t * dispatch_table_snapshot() const
void RunWithStoppedMutators(T function, bool use_force_growth=false)
Mutex * subtype_test_cache_mutex()
int64_t last_allocationprofile_accumulator_reset_timestamp() const
ProgramReloadContext * program_reload_context()
void VisitSharedPointers(ObjectPointerVisitor *visitor)
static void FlagsInitialize(Dart_IsolateFlags *api_flags)
void set_deferred_load_handler(Dart_DeferredLoadHandler handler)
void set_asserts(bool value)
void CreateHeap(bool is_vm_isolate, bool is_service_or_kernel_isolate)
void UpdateLastAllocationProfileGCTimestamp()
static intptr_t object_store_offset()
static void UnregisterIsolateGroup(IsolateGroup *isolate_group)
bool HasTagHandler() const
void PrintMemoryUsageJSON(JSONStream *stream)
void set_dispatch_table(DispatchTable *table)
virtual void VisitIsolate(Isolate *isolate)=0
virtual ~IsolateVisitor()
bool IsSystemIsolate(Isolate *isolate) const
static intptr_t user_tag_offset()
void set_forward_table_old(WeakTable *table)
ReceivePortPtr CreateReceivePort(const String &debug_name)
IsolateGroupSource * source() const
void set_should_pause_post_service_request(bool value)
bool AddResumeCapability(const Capability &capability)
intptr_t BlockClassFinalization()
Thread * scheduled_mutator_thread() const
void AddExitListener(const SendPort &listener, const Instance &response)
bool GetAndClearResumeRequest()
void AddErrorListener(const SendPort &listener)
FfiCallbackMetadata::Trampoline CreateAsyncFfiCallback(Zone *zone, const Function &send_function, Dart_Port send_port)
bool TrySetHasCompletedBlocks()
Dart_EnvironmentCallback environment_callback() const
ErrorPtr sticky_error() const
UserTagPtr current_tag() const
Simulator * simulator() const
int64_t last_resume_timestamp() const
FfiCallbackMetadata::Metadata * ffi_callback_list_head()
void set_deopt_context(DeoptContext *value)
static bool IsSystemIsolate(const Isolate *isolate)
FieldTable * field_table() const
static void DisableIsolateCreation()
void ScheduleInterrupts(uword interrupt_bits)
void RememberLiveTemporaries()
@ kDrainServiceExtensionsMsg
ObjectIdRing * object_id_ring() const
static Isolate * Current()
static bool IsVMInternalIsolate(const Isolate *isolate)
void set_on_shutdown_callback(Dart_IsolateShutdownCallback value)
void DeferredMarkLiveTemporaries()
static void KillIfExists(Isolate *isolate, LibMsgId msg_id)
void set_has_resumption_breakpoints(bool value)
static bool IsolateCreationEnabled()
IsolateObjectStore * isolate_object_store() const
void FlagsCopyTo(Dart_IsolateFlags *api_flags) const
bool TakeHasCompletedBlocks()
static intptr_t single_step_offset()
VMTagCounters * vm_tag_counters()
static void KillAllSystemIsolates(LibMsgId msg_id)
static void VisitIsolates(IsolateVisitor *visitor)
Debugger * debugger() const
bool VerifyPauseCapability(const Object &capability) const
ISOLATE_METRIC_LIST(ISOLATE_METRIC_ACCESSOR)
void DeleteFfiCallback(FfiCallbackMetadata::Trampoline callback)
UserTagPtr default_tag() const
MallocGrowableArray< ObjectPtr > * pointers_to_verify_at_exit()
void NotifyExitListeners()
bool IsPrefixLoaded(const LibraryPrefix &prefix) const
void DecrementSpawnCount()
bool RemoveResumeCapability(const Capability &capability)
SafepointHandler * safepoint_handler() const
void PrintJSON(JSONStream *stream, bool ref=true)
bool has_attempted_stepping() const
bool ResumeRequest() const
void SetErrorsFatal(bool value)
MessageHandler * message_handler() const
void set_field_table(Thread *T, FieldTable *field_table)
ObjectPtr CallDeferredLoadHandler(intptr_t id)
intptr_t UnblockClassFinalization()
void PrintPauseEventJSON(JSONStream *stream)
static Dart_IsolateShutdownCallback ShutdownCallback()
bool is_vm_isolate() const
void SetReceivePortKeepAliveState(const ReceivePort &receive_port, bool keep_isolate_alive)
FfiCallbackMetadata::Trampoline CreateIsolateLocalFfiCallback(Zone *zone, const Function &trampoline, const Closure &target, bool keep_isolate_alive)
void SetPrefixIsLoaded(const LibraryPrefix &prefix)
void RegisterServiceExtensionHandler(const String &name, const Instance &closure)
static void FlagsInitialize(Dart_IsolateFlags *api_flags)
void PrintMemoryUsageJSON(JSONStream *stream)
static void SetShutdownCallback(Dart_IsolateShutdownCallback cb)
static void KillAllIsolates(LibMsgId msg_id)
static intptr_t finalizers_offset()
void set_on_cleanup_callback(Dart_IsolateCleanupCallback value)
static std::unique_ptr< char[]> LookupIsolateNameByPort(Dart_Port port)
bool HasPendingMessages()
static intptr_t IsolateListLength()
void set_current_sample_block(SampleBlock *block)
void * init_callback_data() const
uint64_t terminate_capability() const
ThreadRegistry * thread_registry() const
void set_terminate_capability(uint64_t value)
static intptr_t default_tag_offset()
void set_is_runnable(bool value)
void CloseReceivePort(const ReceivePort &receive_port)
void set_last_resume_timestamp()
bool HasDeferredLoadHandler() const
const char * MakeRunnable()
Dart_IsolateShutdownCallback on_shutdown_callback()
GrowableObjectArrayPtr tag_table() const
void set_simulator(Simulator *value)
void SendInternalLibMessage(LibMsgId msg_id, uint64_t capability)
bool VerifyTerminateCapability(const Object &capability) const
void WaitForOutstandingSpawns()
void set_forward_table_new(WeakTable *table)
int64_t UptimeMicros() const
void UpdateNativeCallableKeepIsolateAliveCounter(intptr_t delta)
ObjectIdRing * EnsureObjectIdRing()
static Dart_IsolateCleanupCallback CleanupCallback()
ErrorPtr InvokePendingServiceExtensionCalls()
friend class HeapSnapshotWriter
void MakeRunnableLocked()
SampleBlock * current_sample_block() const
void set_environment_callback(Dart_EnvironmentCallback value)
DART_WARN_UNUSED_RESULT ErrorPtr StealStickyError()
void set_main_port(Dart_Port port)
ErrorPtr PausePostRequest()
bool should_pause_post_service_request() const
static void EnableIsolateCreation()
void AppendServiceExtensionCall(const Instance &closure, const String &method_name, const Array ¶meter_keys, const Array ¶meter_values, const Instance &reply_port, const Instance &id)
HandlerInfoCache * handler_info_cache()
IsolateGroup * group() const
static void SetCleanupCallback(Dart_IsolateCleanupCallback cb)
static intptr_t current_tag_offset()
static void SetInitializeCallback_(Dart_InitializeIsolateCallback cb)
static Dart_IsolateGroupCreateCallback CreateGroupCallback()
void CacheRegexpBacktrackStack(std::unique_ptr< VirtualMemory > stack)
WeakTable * forward_table_old()
void set_current_tag(const UserTag &tag)
bool IsDeoptimizing() const
void set_has_attempted_stepping(bool value)
void set_init_callback_data(void *value)
Dart_MessageNotifyCallback message_notify_callback() const
InstancePtr LookupServiceExtensionHandler(const String &name)
CatchEntryMovesCache * catch_entry_moves_cache()
bool is_service_registered() const
void set_name(const char *name)
static Dart_IsolateGroupCleanupCallback GroupCleanupCallback()
static void SetGroupCleanupCallback(Dart_IsolateGroupCleanupCallback cb)
std::unique_ptr< VirtualMemory > TakeRegexpBacktrackStack()
WeakTable * forward_table_new()
void FlagsCopyFrom(const Dart_IsolateFlags &api_flags)
void set_finalizers(const GrowableObjectArray &value)
void RemoveExitListener(const SendPort &listener)
uint64_t pause_capability() const
static Isolate * LookupIsolateByPort(Dart_Port port)
static Dart_UnregisterKernelBlobCallback UnregisterKernelBlobCallback()
bool NotifyErrorListeners(const char *msg, const char *stacktrace)
bool AllowClassFinalization()
void init_loaded_prefixes_set_storage()
void set_current_allocation_sample_block(SampleBlock *block)
friend Isolate * CreateWithinExistingIsolateGroup(IsolateGroup *g, const char *n, char **e)
void set_is_service_registered(bool value)
void set_tag_table(const GrowableObjectArray &value)
static Dart_InitializeIsolateCallback InitializeCallback()
static void SetRegisterKernelBlobCallback(Dart_RegisterKernelBlobCallback cb)
static void SetCreateGroupCallback(Dart_IsolateGroupCreateCallback cb)
Dart_IsolateCleanupCallback on_cleanup_callback()
friend class IsolateGroup
DeoptContext * deopt_context() const
Thread * mutator_thread() const
static intptr_t has_resumption_breakpoints_offset()
void set_single_step(bool value)
void set_default_tag(const UserTag &tag)
SampleBlock * current_allocation_sample_block() const
void IncrementSpawnCount()
void set_origin_id(Dart_Port id)
static Dart_RegisterKernelBlobCallback RegisterKernelBlobCallback()
void RemoveErrorListener(const SendPort &listener)
void ProcessFreeSampleBlocks(Thread *thread)
void set_message_notify_callback(Dart_MessageNotifyCallback value)
void set_pause_capability(uint64_t value)
Dart_Port main_port() const
static void SetUnregisterKernelBlobCallback(Dart_UnregisterKernelBlobCallback cb)
bool has_resumption_breakpoints() const
void set_is_vm_isolate(bool value)
void SetStickyError(ErrorPtr sticky_error)
const char * name() const
bool HasOpenNativeCallables()
void bequeath(std::unique_ptr< Bequest > bequest)
LambdaCallable(T &lambda)
bool IsOwnedByCurrentThread() const
MutatorThreadPool(IsolateGroup *isolate_group, intptr_t max_pool_size)
virtual ~MutatorThreadPool()
virtual void OnEnterIdleLocked(MonitorLocker *ml)
NoActiveIsolateScope(Thread *thread)
static int64_t GetCurrentTimeMillis()
T exchange(T arg, std::memory_order order=std::memory_order_relaxed)
ThreadState * thread() const
StartIsolateScope(Isolate *new_isolate)
static Thread * Current()
static void ExitIsolateGroupAsHelper(bool bypass_safepoint)
Isolate * isolate() const
IsolateGroup * isolate_group() const
static void EnterIsolate(Isolate *isolate)
static void ExitIsolate(bool isolate_shutdown=false)
static bool EnterIsolateGroupAsHelper(IsolateGroup *isolate_group, TaskKind kind, bool bypass_safepoint)
void(* Dart_UnregisterKernelBlobCallback)(const char *kernel_blob_uri)
Dart_Handle(* Dart_EnvironmentCallback)(Dart_Handle name)
Dart_Isolate(* Dart_IsolateGroupCreateCallback)(const char *script_uri, const char *main, const char *package_root, const char *package_config, Dart_IsolateFlags *flags, void *isolate_data, char **error)
void(* Dart_IsolateCleanupCallback)(void *isolate_group_data, void *isolate_data)
void(* Dart_MessageNotifyCallback)(Dart_Isolate destination_isolate)
const char *(* Dart_RegisterKernelBlobCallback)(const uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
#define DART_WARN_UNUSED_RESULT
struct _Dart_Isolate * Dart_Isolate
bool(* Dart_InitializeIsolateCallback)(void **child_isolate_data, char **error)
void(* Dart_IsolateGroupCleanupCallback)(void *isolate_group_data)
void(* Dart_IsolateShutdownCallback)(void *isolate_group_data, void *isolate_data)
Dart_Handle(* Dart_LibraryTagHandler)(Dart_LibraryTag tag, Dart_Handle library_or_package_map_url, Dart_Handle url)
Dart_Handle(* Dart_DeferredLoadHandler)(intptr_t loading_unit_id)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
constexpr intptr_t kDefaultOptimizationCounterThreshold
Dart_NativeFunction function
#define ISOLATE_METRIC_VARIABLE(type, variable, name, unit)
#define DECLARE_BIT(Name)
#define BOOL_ISOLATE_FLAG_LIST(V)
#define ISOLATE_METRIC_ACCESSOR(type, variable, name, unit)
#define BOOL_ISOLATE_GROUP_FLAG_LIST(V)
#define ISOLATE_GROUP_FLAG_BITS(V)
#define DECLARE_GETTER(when, name, bitname, isolate_flag_name, flag_name)
#define DECLARE_BITFIELD(Name)
#define REUSABLE_FRIEND_DECLARATION(name)
#define ISOLATE_FLAG_BITS(V)
#define ISOLATE_METRIC_LIST(V)
#define ISOLATE_GROUP_METRIC_LIST(V)
void Log(const char *format,...) SK_PRINTF_LIKE(1
FixedCache< intptr_t, ExceptionHandlerInfo, 16 > HandlerInfoCache
FixedCache< intptr_t, CatchEntryMovesRefPtr, 16 > CatchEntryMovesCache
constexpr intptr_t kWordSize
std::function< void(const T &message, const MessageReply< T > &reply)> MessageHandler
#define REUSABLE_HANDLE_LIST(V)
#define NOT_IN_PRECOMPILED(code)
#define NOT_IN_PRODUCT(code)
#define OFFSET_OF(type, field)