Flutter Engine
The Flutter Engine
dart.cc
Go to the documentation of this file.
1// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#include <memory>
6#include <utility>
7
8#include "vm/dart.h"
9
12
13#include "vm/app_snapshot.h"
14#include "vm/code_observers.h"
17#include "vm/cpu.h"
18#include "vm/dart_api_state.h"
19#include "vm/dart_entry.h"
20#include "vm/debugger.h"
21#if defined(DART_PRECOMPILED_RUNTIME) && defined(DART_TARGET_OS_LINUX)
22#include "vm/elf.h"
23#endif
25#include "vm/flags.h"
26#include "vm/handles.h"
27#include "vm/heap/become.h"
28#include "vm/heap/freelist.h"
29#include "vm/heap/heap.h"
31#include "vm/isolate.h"
32#include "vm/isolate_reload.h"
33#include "vm/kernel_isolate.h"
34#include "vm/message_handler.h"
35#include "vm/metrics.h"
36#include "vm/native_entry.h"
37#include "vm/object.h"
38#include "vm/object_id_ring.h"
39#include "vm/object_store.h"
40#include "vm/port.h"
41#include "vm/profiler.h"
44#include "vm/service_isolate.h"
45#include "vm/simulator.h"
46#include "vm/snapshot.h"
47#include "vm/stack_frame.h"
48#include "vm/stub_code.h"
49#include "vm/symbols.h"
50#include "vm/tags.h"
52#include "vm/thread_pool.h"
53#include "vm/timeline.h"
55#include "vm/virtual_memory.h"
56#include "vm/zone.h"
57
58namespace dart {
59
60DECLARE_FLAG(bool, print_class_table);
61DEFINE_FLAG(bool, trace_shutdown, false, "Trace VM shutdown on stderr");
62
63Isolate* Dart::vm_isolate_ = nullptr;
64int64_t Dart::start_time_micros_ = 0;
65ThreadPool* Dart::thread_pool_ = nullptr;
66DebugInfo* Dart::pprof_symbol_generator_ = nullptr;
67ReadOnlyHandles* Dart::predefined_handles_ = nullptr;
68Snapshot::Kind Dart::vm_snapshot_kind_ = Snapshot::kInvalid;
69Dart_ThreadStartCallback Dart::thread_start_callback_ = nullptr;
70Dart_ThreadExitCallback Dart::thread_exit_callback_ = nullptr;
71Dart_FileOpenCallback Dart::file_open_callback_ = nullptr;
72Dart_FileReadCallback Dart::file_read_callback_ = nullptr;
73Dart_FileWriteCallback Dart::file_write_callback_ = nullptr;
74Dart_FileCloseCallback Dart::file_close_callback_ = nullptr;
75Dart_EntropySource Dart::entropy_source_callback_ = nullptr;
76Dart_DwarfStackTraceFootnoteCallback Dart::dwarf_stacktrace_footnote_callback_ =
77 nullptr;
78
79// Structure for managing read-only global handles allocation used for
80// creating global read-only handles that are pre created and initialized
81// for use across all isolates. Having these global pre created handles
82// stored in the vm isolate ensures that we don't constantly create and
83// destroy handles for read-only objects referred in the VM code
84// (e.g: symbols, null object, empty array etc.)
85// The ReadOnlyHandles C++ Wrapper around VMHandles which is a ValueObject is
86// to ensure that the handles area is not trashed by automatic running of C++
87// static destructors when 'exit()" is called by any isolate. There might be
88// other isolates running at the same time and trashing the handles area will
89// have unintended consequences.
91 public:
93
94 private:
95 VMHandles handles_;
96 LocalHandles api_handles_;
97
98 friend class Dart;
100};
101
103 public:
104 static bool SetInitializing() {
105 ASSERT(in_use_count_.load() == 0);
106 uint8_t expected = kUnInitialized;
107 return state_.compare_exchange_strong(expected, kInitializing);
108 }
109
110 static void ResetInitializing() {
111 ASSERT(in_use_count_.load() == 0);
112 uint8_t expected = kInitializing;
113 bool result = state_.compare_exchange_strong(expected, kUnInitialized);
114 ASSERT(result);
115 }
116
117 static void SetInitialized() {
118 ASSERT(in_use_count_.load() == 0);
119 uint8_t expected = kInitializing;
120 bool result = state_.compare_exchange_strong(expected, kInitialized);
121 ASSERT(result);
122 }
123
124 static bool IsInitialized() { return state_.load() == kInitialized; }
125
126 static bool SetCleaningup() {
127 uint8_t expected = kInitialized;
128 return state_.compare_exchange_strong(expected, kCleaningup);
129 }
130
131 static void SetUnInitialized() {
132 while (in_use_count_.load() > 0) {
133 OS::Sleep(1); // Sleep for 1 millis waiting for it to not be in use.
134 }
135 uint8_t expected = kCleaningup;
136 bool result = state_.compare_exchange_strong(expected, kUnInitialized);
137 ASSERT(result);
138 }
139
140 static bool SetInUse() {
141 if (state_.load() != kInitialized) {
142 return false;
143 }
144 in_use_count_ += 1;
145 return true;
146 }
147
148 static void ResetInUse() {
149 uint8_t value = state_.load();
150 ASSERT((value == kInitialized) || (value == kCleaningup));
151 in_use_count_ -= 1;
152 }
153
154 private:
155 static constexpr uint8_t kUnInitialized = 0;
156 static constexpr uint8_t kInitializing = 1;
157 static constexpr uint8_t kInitialized = 2;
158 static constexpr uint8_t kCleaningup = 3;
159
160 static std::atomic<uint8_t> state_;
161 static std::atomic<uint64_t> in_use_count_;
162};
163std::atomic<uint8_t> DartInitializationState::state_ = {kUnInitialized};
164std::atomic<uint64_t> DartInitializationState::in_use_count_ = {0};
165
166#if defined(DART_PRECOMPILER) || defined(DART_PRECOMPILED_RUNTIME)
167static void CheckOffsets() {
168#if !defined(IS_SIMARM_HOST64)
169 // These offsets are embedded in precompiled instructions. We need the
170 // compiler and the runtime to agree.
171 bool ok = true;
172#define CHECK_OFFSET(expr, offset) \
173 if ((expr) != (offset)) { \
174 OS::PrintErr("%s got %" Pd ", %s expected %" Pd "\n", #expr, \
175 static_cast<intptr_t>(expr), #offset, \
176 static_cast<intptr_t>(offset)); \
177 ok = false; \
178 }
179
180// No consistency checks needed for these constructs.
181#define CHECK_ARRAY_SIZEOF(Class, Name, ElementOffset)
182#define CHECK_PAYLOAD_SIZEOF(Class, Name, HeaderSize)
183
184#if defined(DART_PRECOMPILED_RUNTIME)
185#define CHECK_FIELD(Class, Name) \
186 CHECK_OFFSET(Class::Name(), AOT_##Class##_##Name);
187#define CHECK_ARRAY(Class, Name) \
188 CHECK_OFFSET(Class::ArrayTraits::elements_start_offset(), \
189 AOT_##Class##_elements_start_offset); \
190 CHECK_OFFSET(Class::ArrayTraits::kElementSize, AOT_##Class##_element_size)
191#define CHECK_SIZEOF(Class, Name, What) \
192 CHECK_OFFSET(sizeof(What), AOT_##Class##_##Name);
193#define CHECK_RANGE(Class, Getter, Type, First, Last, Filter) \
194 for (intptr_t i = static_cast<intptr_t>(First); \
195 i <= static_cast<intptr_t>(Last); i++) { \
196 if (Filter(static_cast<Type>(i))) { \
197 CHECK_OFFSET(Class::Getter(static_cast<Type>(i)), \
198 AOT_##Class##_##Getter[i]); \
199 } \
200 }
201#define CHECK_CONSTANT(Class, Name) \
202 CHECK_OFFSET(Class::Name, AOT_##Class##_##Name);
203#else
204#define CHECK_FIELD(Class, Name) CHECK_OFFSET(Class::Name(), Class##_##Name);
205#define CHECK_ARRAY(Class, Name) \
206 CHECK_OFFSET(Class::ArrayTraits::elements_start_offset(), \
207 Class##_elements_start_offset); \
208 CHECK_OFFSET(Class::ArrayTraits::kElementSize, Class##_element_size);
209#if defined(DART_PRECOMPILER)
210// Objects in precompiler may have extra fields only used during
211// precompilation (such as Class::target_instance_size_in_words_),
212// so size of objects in precompiler doesn't necessarily match
213// size of objects at run time.
214#define CHECK_SIZEOF(Class, Name, What)
215#else
216#define CHECK_SIZEOF(Class, Name, What) \
217 CHECK_OFFSET(sizeof(What), Class##_##Name);
218#endif // defined(DART_PRECOMPILER)
219#define CHECK_RANGE(Class, Getter, Type, First, Last, Filter) \
220 for (intptr_t i = static_cast<intptr_t>(First); \
221 i <= static_cast<intptr_t>(Last); i++) { \
222 if (Filter(static_cast<Type>(i))) { \
223 CHECK_OFFSET(Class::Getter(static_cast<Type>(i)), Class##_##Getter[i]); \
224 } \
225 }
226#define CHECK_CONSTANT(Class, Name) CHECK_OFFSET(Class::Name, Class##_##Name);
227#endif // defined(DART_PRECOMPILED_RUNTIME)
228
229 COMMON_OFFSETS_LIST(CHECK_FIELD, CHECK_ARRAY, CHECK_SIZEOF,
230 CHECK_ARRAY_SIZEOF, CHECK_PAYLOAD_SIZEOF, CHECK_RANGE,
231 CHECK_CONSTANT)
232
234 CHECK_FIELD, CHECK_ARRAY, CHECK_SIZEOF, CHECK_ARRAY_SIZEOF,
235 CHECK_PAYLOAD_SIZEOF, CHECK_RANGE, CHECK_CONSTANT))
236
237 ONLY_IN_PRECOMPILED(AOT_OFFSETS_LIST(CHECK_FIELD, CHECK_ARRAY, CHECK_SIZEOF,
238 CHECK_ARRAY_SIZEOF, CHECK_PAYLOAD_SIZEOF,
239 CHECK_RANGE, CHECK_CONSTANT))
240
241 if (!ok) {
242 FATAL(
243 "CheckOffsets failed. Try updating offsets by running "
244 "./tools/run_offsets_extractor.dart");
245 }
246#undef CHECK_FIELD
247#undef CHECK_ARRAY
248#undef CHECK_ARRAY_STRUCTFIELD
249#undef CHECK_SIZEOF
250#undef CHECK_RANGE
251#undef CHECK_CONSTANT
252#undef CHECK_OFFSET
253#undef CHECK_PAYLOAD_SIZEOF
254#endif // !defined(IS_SIMARM_HOST64)
255}
256#endif // defined(DART_PRECOMPILER) || defined(DART_PRECOMPILED_RUNTIME)
257
258char* Dart::DartInit(const Dart_InitializeParams* params) {
259#if defined(DART_PRECOMPILER) || defined(DART_PRECOMPILED_RUNTIME)
260 CheckOffsets();
261#elif defined(ARCH_IS_64_BIT) != defined(TARGET_ARCH_IS_64_BIT)
262 return Utils::StrDup(
263 "JIT cannot simulate target architecture with different word size than "
264 "host");
265#endif
266
267#if defined(DART_HOST_OS_MACOS) && !defined(DART_HOST_OS_IOS)
269 if (error != nullptr) {
270 return error;
271 }
272#endif
273
274 if (!Flags::Initialized()) {
275 return Utils::StrDup("VM initialization failed-VM Flags not initialized.");
276 }
277 if (vm_isolate_ != nullptr) {
278 return Utils::StrDup("VM initialization is in an inconsistent state.");
279 }
280
281 const Snapshot* snapshot = nullptr;
282 if (params->vm_snapshot_data != nullptr) {
283 snapshot = Snapshot::SetupFromBuffer(params->vm_snapshot_data);
284 if (snapshot == nullptr) {
285 return Utils::StrDup("Invalid vm isolate snapshot seen");
286 }
287 }
288
289 // We are initializing the VM. We will take the VM-global flags used
290 // during snapshot generation time also at runtime (this avoids the need
291 // for the embedder to pass the same flags used during snapshot generation
292 // also to the runtime).
293 if (snapshot != nullptr) {
294 char* error =
296 if (error != nullptr) {
297 return error;
298 }
299 }
300
302
303 set_thread_start_callback(params->thread_start);
304 set_thread_exit_callback(params->thread_exit);
305 SetFileCallbacks(params->file_open, params->file_read, params->file_write,
306 params->file_close);
307 set_entropy_source_callback(params->entropy_source);
308 OS::Init();
310 if (params->code_observer != nullptr) {
312 }
313 start_time_micros_ = OS::GetCurrentMonotonicMicros();
314#if defined(DART_HOST_OS_FUCHSIA)
315 VirtualMemory::Init(params->vmex_resource);
316#else
318#endif
319
320#if defined(DART_PRECOMPILED_RUNTIME) && defined(DART_TARGET_OS_LINUX)
322 return Utils::SCreate(
323 "Incompatible page size for AOT compiled ELF: expected at most %" Pd
324 ", got %" Pd "",
326 }
327#endif
328
330 Random::Init();
331 Zone::Init();
332#if defined(SUPPORT_TIMELINE)
334 TimelineBeginEndScope tbes(Timeline::GetVMStream(), "Dart::Init");
335#endif
337 Isolate::InitVM();
343 Api::Init();
345 Page::Init();
350
351#if defined(USING_SIMULATOR)
353#endif
354 // Create the read-only handles area.
355 ASSERT(predefined_handles_ == nullptr);
356 predefined_handles_ = new ReadOnlyHandles();
357 // Create the VM isolate and finish the VM initialization.
358 ASSERT(thread_pool_ == nullptr);
359 thread_pool_ = new ThreadPool();
360 {
361 ASSERT(vm_isolate_ == nullptr);
363 const bool is_vm_isolate = true;
364
365 // Setup default flags for the VM isolate.
366 Dart_IsolateFlags api_flags;
367 Isolate::FlagsInitialize(&api_flags);
368 api_flags.is_system_isolate = true;
369
370 // We make a fake [IsolateGroupSource] here, since the "vm-isolate" is not
371 // really an isolate itself - it acts more as a container for VM-global
372 // objects.
373 std::unique_ptr<IsolateGroupSource> source(new IsolateGroupSource(
374 kVmIsolateName, kVmIsolateName, params->vm_snapshot_data,
375 params->vm_snapshot_instructions, nullptr, -1, api_flags));
376 // ObjectStore should be created later, after null objects are initialized.
377 auto group = new IsolateGroup(std::move(source), /*embedder_data=*/nullptr,
378 /*object_store=*/nullptr, api_flags,
379 /*is_vm_isolate*/ true);
380 group->CreateHeap(/*is_vm_isolate=*/true,
381 /*is_service_or_kernel_isolate=*/false);
383 vm_isolate_ =
384 Isolate::InitIsolate(kVmIsolateName, group, api_flags, is_vm_isolate);
385 group->set_initial_spawn_successful();
386
387 // Verify assumptions about executing in the VM isolate.
388 ASSERT(vm_isolate_ == Isolate::Current());
389 ASSERT(vm_isolate_ == Thread::Current()->isolate());
390
391 Thread* T = Thread::Current();
392 ASSERT(T != nullptr);
393 StackZone zone(T);
394 HandleScope handle_scope(T);
395 Object::InitNullAndBool(vm_isolate_->group());
396 vm_isolate_->isolate_group_->set_object_store(new ObjectStore());
397 vm_isolate_->isolate_object_store()->Init();
398 vm_isolate_->finalizers_ = GrowableObjectArray::null();
399 Object::Init(vm_isolate_->group());
402 ICData::Init();
403 if (params->vm_snapshot_data != nullptr) {
404#if defined(SUPPORT_TIMELINE)
405 TimelineBeginEndScope tbes(Timeline::GetVMStream(), "ReadVMSnapshot");
406#endif
407 ASSERT(snapshot != nullptr);
408 vm_snapshot_kind_ = snapshot->kind();
409
410 if (Snapshot::IncludesCode(vm_snapshot_kind_)) {
411 if (vm_snapshot_kind_ == Snapshot::kFullAOT) {
412#if !defined(DART_PRECOMPILED_RUNTIME)
413 return Utils::StrDup("JIT runtime cannot run a precompiled snapshot");
414#endif
415 }
416 if (params->vm_snapshot_instructions == nullptr) {
417 return Utils::StrDup("Missing instructions snapshot");
418 }
419 } else if (Snapshot::IsFull(vm_snapshot_kind_)) {
420#if defined(DART_PRECOMPILED_RUNTIME)
421 return Utils::StrDup(
422 "Precompiled runtime requires a precompiled snapshot");
423#else
425 Object::FinishInit(vm_isolate_->group());
426#endif
427 } else {
428 return Utils::StrDup("Invalid vm isolate snapshot seen");
429 }
430 FullSnapshotReader reader(snapshot, params->vm_snapshot_instructions, T);
431 const Error& error = Error::Handle(reader.ReadVMSnapshot());
432 if (!error.IsNull()) {
433 // Must copy before leaving the zone.
434 return Utils::StrDup(error.ToErrorCString());
435 }
436
437 Object::FinishInit(vm_isolate_->group());
438#if defined(SUPPORT_TIMELINE)
439 if (tbes.enabled()) {
440 tbes.SetNumArguments(2);
441 tbes.FormatArgument(0, "snapshotSize", "%" Pd, snapshot->length());
442 tbes.FormatArgument(
443 1, "heapSize", "%" Pd,
444 vm_isolate_group()->heap()->UsedInWords(Heap::kOld) * kWordSize);
445 }
446#endif // !defined(PRODUCT)
447 if (FLAG_trace_isolates) {
448 OS::PrintErr("Size of vm isolate snapshot = %" Pd "\n",
449 snapshot->length());
452 intptr_t size;
453 intptr_t capacity;
454 Symbols::GetStats(vm_isolate_->group(), &size, &capacity);
455 OS::PrintErr("VM Isolate: Number of symbols : %" Pd "\n", size);
456 OS::PrintErr("VM Isolate: Symbol table capacity : %" Pd "\n", capacity);
457 }
458 } else {
459#if defined(DART_PRECOMPILED_RUNTIME)
460 return Utils::StrDup(
461 "Precompiled runtime requires a precompiled snapshot");
462#else
463 vm_snapshot_kind_ = Snapshot::kNone;
465 Object::FinishInit(vm_isolate_->group());
466 Symbols::Init(vm_isolate_->group());
467#endif
468 }
469 // We need to initialize the constants here for the vm isolate thread due to
470 // bootstrapping issues.
471 T->InitVMConstants();
472#if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
473 // Dart VM requires at least SSE2.
475 return Utils::StrDup("SSE2 is required.");
476 }
477#endif
478 {
479#if defined(SUPPORT_TIMELINE)
480 TimelineBeginEndScope tbes(Timeline::GetVMStream(), "FinalizeVMIsolate");
481#endif
482 Object::FinalizeVMIsolate(vm_isolate_->group());
483 }
484#if defined(DEBUG)
485 vm_isolate_group()->heap()->Verify("Dart::DartInit", kRequireMarked);
486#endif
487 }
489 // Allocate the "persistent" scoped handles for the predefined API
490 // values (such as Dart_True, Dart_False and Dart_Null).
492
493 Thread::ExitIsolate(); // Unregister the VM isolate from this thread.
495 Isolate::SetInitializeCallback_(params->initialize_isolate);
496 Isolate::SetShutdownCallback(params->shutdown_isolate);
497 Isolate::SetCleanupCallback(params->cleanup_isolate);
499 Isolate::SetRegisterKernelBlobCallback(params->register_kernel_blob);
500 Isolate::SetUnregisterKernelBlobCallback(params->unregister_kernel_blob);
501
502#ifndef PRODUCT
503 const bool support_service = true;
504 Service::SetGetServiceAssetsCallback(params->get_service_assets);
505#else
506 const bool support_service = false;
507#endif
508
509 const bool is_dart2_aot_precompiler =
510 FLAG_precompiled_mode && !kDartPrecompiledRuntime;
511
512 if (!is_dart2_aot_precompiler &&
513 (support_service || !kDartPrecompiledRuntime)) {
515 }
516
517#ifndef DART_PRECOMPILED_RUNTIME
518 if (params->start_kernel_isolate) {
520 }
521#endif // DART_PRECOMPILED_RUNTIME
522
523 return nullptr;
524}
525
528 return Utils::StrDup(
529 "Bad VM initialization state, "
530 "already initialized or "
531 "multiple threads initializing the VM.");
532 }
533 char* retval = DartInit(params);
534 if (retval != nullptr) {
536 return retval;
537 }
539 return nullptr;
540}
541
542static void DumpAliveIsolates(intptr_t num_attempts,
543 bool only_application_isolates) {
545 group->ForEachIsolate([&](Isolate* isolate) {
546 if (!only_application_isolates || !Isolate::IsSystemIsolate(isolate)) {
547 OS::PrintErr("Attempt:%" Pd " waiting for isolate %s to check in\n",
548 num_attempts, isolate->name());
549 }
550 });
551 });
552}
553
554static bool OnlyVmIsolateLeft() {
555 intptr_t count = 0;
556 bool found_vm_isolate = false;
558 group->ForEachIsolate([&](Isolate* isolate) {
559 count++;
560 if (isolate == Dart::vm_isolate()) {
561 found_vm_isolate = true;
562 }
563 });
564 });
565 return count == 1 && found_vm_isolate;
566}
567
568// This waits until only the VM, service and kernel isolates are in the list.
569void Dart::WaitForApplicationIsolateShutdown() {
570 ASSERT(!Isolate::creation_enabled_);
571 MonitorLocker ml(Isolate::isolate_creation_monitor_);
572 intptr_t num_attempts = 0;
574 Monitor::WaitResult retval = ml.Wait(1000);
575 if (retval == Monitor::kTimedOut) {
576 num_attempts += 1;
577 if (num_attempts > 10) {
578 DumpAliveIsolates(num_attempts, /*only_application_isolates=*/true);
579 }
580 }
581 }
582}
583
584// This waits until only the VM isolate remains in the list.
585void Dart::WaitForIsolateShutdown() {
586 int64_t start_time = 0;
587 if (FLAG_trace_shutdown) {
588 start_time = UptimeMillis();
589 OS::PrintErr("[+%" Pd64
590 "ms] SHUTDOWN: Waiting for service "
591 "and kernel isolates to shutdown\n",
592 start_time);
593 }
594 ASSERT(!Isolate::creation_enabled_);
595 MonitorLocker ml(Isolate::isolate_creation_monitor_);
596 intptr_t num_attempts = 0;
598 Monitor::WaitResult retval = ml.Wait(1000);
599 if (retval == Monitor::kTimedOut) {
600 num_attempts += 1;
601 if (num_attempts > 10) {
602 DumpAliveIsolates(num_attempts, /*only_application_isolates=*/false);
603 }
604 if (FLAG_trace_shutdown) {
605 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: %" Pd
606 " time out waiting for "
607 "service and kernel isolates to shutdown\n",
608 UptimeMillis(), num_attempts);
609 }
610 }
611 }
612 if (FLAG_trace_shutdown) {
613 int64_t stop_time = UptimeMillis();
614 OS::PrintErr("[+%" Pd64
615 "ms] SHUTDOWN: Done waiting for service "
616 "and kernel isolates to shutdown\n",
617 stop_time);
618 if ((stop_time - start_time) > 500) {
619 OS::PrintErr("[+%" Pd64
620 "ms] SHUTDOWN: waited too long for service "
621 "and kernel isolates to shutdown\n",
622 (stop_time - start_time));
623 }
624 }
625
627}
628
630 ASSERT(Isolate::Current() == nullptr);
632 return Utils::StrDup("VM already terminated.");
633 }
634 ASSERT(vm_isolate_ != nullptr);
635
636 if (FLAG_trace_shutdown) {
637 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Starting shutdown\n",
638 UptimeMillis());
639 }
640
641#if !defined(PRODUCT)
642 if (FLAG_trace_shutdown) {
643 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Shutting down profiling\n",
644 UptimeMillis());
645 }
647#endif // !defined(PRODUCT)
648
650
651 // Disable the creation of new isolates.
652 if (FLAG_trace_shutdown) {
653 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Disabling isolate creation\n",
654 UptimeMillis());
655 }
657
658 // Send the OOB Kill message to all remaining application isolates.
659 if (FLAG_trace_shutdown) {
660 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Killing all app isolates\n",
661 UptimeMillis());
662 }
664
665 // Wait for all isolates, but the service and the vm isolate to shut down.
666 // Only do that if there is a service isolate running.
668 if (FLAG_trace_shutdown) {
669 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Shutting down app isolates\n",
670 UptimeMillis());
671 }
672 WaitForApplicationIsolateShutdown();
673 if (FLAG_trace_shutdown) {
674 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Done shutting down app isolates\n",
675 UptimeMillis());
676 }
677 }
678
680
681 // Shutdown the kernel isolate.
682 if (FLAG_trace_shutdown) {
683 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Shutting down kernel isolate\n",
684 UptimeMillis());
685 }
687
688 // Shutdown the service isolate.
689 if (FLAG_trace_shutdown) {
690 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Shutting down service isolate\n",
691 UptimeMillis());
692 }
694
695 // Wait for the remaining isolate (service/kernel isolate) to shutdown
696 // before shutting down the thread pool.
697 WaitForIsolateShutdown();
698
699 // Shutdown the thread pool. On return, all thread pool threads have exited.
700 if (FLAG_trace_shutdown) {
701 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Deleting thread pool\n",
702 UptimeMillis());
703 }
705 thread_pool_->Shutdown();
706 delete thread_pool_;
707 thread_pool_ = nullptr;
708 if (FLAG_trace_shutdown) {
709 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Done deleting thread pool\n",
710 UptimeMillis());
711 }
712
713 Api::Cleanup();
714 delete predefined_handles_;
715 predefined_handles_ = nullptr;
716
717 // Set the VM isolate as current isolate.
718 if (FLAG_trace_shutdown) {
719 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Cleaning up vm isolate\n",
720 UptimeMillis());
721 }
722
723 // If Dart_Cleanup() is called on a thread which hasn't invoked any Dart API
724 // functions before, entering the "vm-isolate" will cause lazy creation of a
725 // OSThread (which is attached to the current thread via TLS).
726 //
727 // If we run in PRODUCT mode this lazy creation of OSThread can happen here,
728 // which is why disabling the OSThread creation has to come after entering the
729 // "vm-isolate".
730 Thread::EnterIsolate(vm_isolate_);
731
732 // Disable creation of any new OSThread structures which means no more new
733 // threads can do an EnterIsolate. This must come after isolate shutdown
734 // because new threads may need to be spawned to shutdown the isolates.
735 // This must come after deletion of the thread pool to avoid a race in which
736 // a thread spawned by the thread pool does not exit through the thread
737 // pool, messing up its bookkeeping.
738 if (FLAG_trace_shutdown) {
739 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Disabling OS Thread creation\n",
740 UptimeMillis());
741 }
743
745 vm_isolate_ = nullptr;
761#if defined(SUPPORT_TIMELINE)
762 if (FLAG_trace_shutdown) {
763 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Shutting down timeline\n",
764 UptimeMillis());
765 }
767#endif
770 // Delete the current thread's TLS and set it's TLS to null.
771 // If it is the last thread then the destructor would call
772 // OSThread::Cleanup.
773 OSThread* os_thread = OSThread::Current();
774 OSThread::SetCurrent(nullptr);
775 delete os_thread;
776 if (FLAG_trace_shutdown) {
777 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Deleted os_thread\n",
778 UptimeMillis());
779 }
780
781 if (FLAG_trace_shutdown) {
782 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Deleting code observers\n",
783 UptimeMillis());
784 }
786 OS::Cleanup();
787 if (FLAG_trace_shutdown) {
788 OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Done\n", UptimeMillis());
789 }
791#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
793 Service::SetEmbedderStreamCallbacks(nullptr, nullptr);
794#endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
796 return nullptr;
797}
798
801}
802
805}
806
809}
810
811Isolate* Dart::CreateIsolate(const char* name_prefix,
812 const Dart_IsolateFlags& api_flags,
813 IsolateGroup* isolate_group) {
814 // Create a new isolate.
815 Isolate* isolate =
816 Isolate::InitIsolate(name_prefix, isolate_group, api_flags);
817 return isolate;
818}
819
821 Thread* T,
822 const uint8_t* snapshot_data,
823 const uint8_t* snapshot_instructions,
824 const uint8_t* kernel_buffer,
825 intptr_t kernel_buffer_size) {
826 auto IG = T->isolate_group();
827 Error& error = Error::Handle(T->zone());
828 error = Object::Init(IG, kernel_buffer, kernel_buffer_size);
829 if (!error.IsNull()) {
830 return error.ptr();
831 }
832 if (snapshot_data != nullptr && kernel_buffer == nullptr) {
833 // Read the snapshot and setup the initial state.
834#if defined(SUPPORT_TIMELINE)
835 TimelineBeginEndScope tbes(T, Timeline::GetIsolateStream(),
836 "ReadProgramSnapshot");
837#endif // defined(SUPPORT_TIMELINE)
838 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_data);
839 if (snapshot == nullptr) {
840 const String& message = String::Handle(String::New("Invalid snapshot"));
841 return ApiError::New(message);
842 }
843 if (!IsSnapshotCompatible(vm_snapshot_kind_, snapshot->kind())) {
845 "Incompatible snapshot kinds: vm '%s', isolate '%s'",
846 Snapshot::KindToCString(vm_snapshot_kind_),
847 Snapshot::KindToCString(snapshot->kind())));
848 return ApiError::New(message);
849 }
850 if (FLAG_trace_isolates) {
851 OS::PrintErr("Size of isolate snapshot = %" Pd "\n", snapshot->length());
852 }
853 FullSnapshotReader reader(snapshot, snapshot_instructions, T);
854 const Error& error = Error::Handle(reader.ReadProgramSnapshot());
855 if (!error.IsNull()) {
856 return error.ptr();
857 }
858
859 T->SetupDartMutatorStateDependingOnSnapshot(IG);
860
861#if defined(SUPPORT_TIMELINE)
862 if (tbes.enabled()) {
863 tbes.SetNumArguments(2);
864 tbes.FormatArgument(0, "snapshotSize", "%" Pd, snapshot->length());
865 tbes.FormatArgument(1, "heapSize", "%" Pd,
866 IG->heap()->UsedInWords(Heap::kOld) * kWordSize);
867 }
868#endif // defined(SUPPORT_TIMELINE)
869 if (FLAG_trace_isolates) {
870 IG->heap()->PrintSizes();
872 }
873 } else {
874 if ((vm_snapshot_kind_ != Snapshot::kNone) && kernel_buffer == nullptr) {
875 const String& message =
876 String::Handle(String::New("Missing isolate snapshot"));
877 return ApiError::New(message);
878 }
879 }
880#if !defined(PRODUCT) || defined(FORCE_INCLUDE_SAMPLING_HEAP_PROFILER)
881 IG->class_table()->PopulateUserVisibleNames();
882#endif
883
884 return Error::null();
885}
886
887#if !defined(DART_PRECOMPILED_RUNTIME)
888// The runtime assumes it can create certain kinds of objects at-will without
889// a check whether their class need to be finalized first.
890//
891// Some of those objects can end up flowing to user code (i.e. their class is a
892// subclass of [Instance]).
893//
894// We therefore ensure that classes are finalized before objects of them are
895// created or at least before such objects can reach user code.
896static void FinalizeBuiltinClasses(Thread* thread) {
897 auto class_table = thread->isolate_group()->class_table();
898 Class& cls = Class::Handle(thread->zone());
899 for (intptr_t cid = kInstanceCid; cid < kNumPredefinedCids; cid++) {
900 if (class_table->HasValidClassAt(cid)) {
901 cls = class_table->At(cid);
903 }
904 }
905}
906#endif // !defined(DART_PRECOMPILED_RUNTIME)
907
909 const uint8_t* snapshot_data,
910 const uint8_t* snapshot_instructions,
911 const uint8_t* kernel_buffer,
912 intptr_t kernel_buffer_size) {
913 auto& error = Error::Handle(
914 InitIsolateGroupFromSnapshot(T, snapshot_data, snapshot_instructions,
915 kernel_buffer, kernel_buffer_size));
916 if (!error.IsNull()) {
917 return error.ptr();
918 }
919
921
922 auto IG = T->isolate_group();
923 {
924 SafepointReadRwLocker reader(T, IG->program_lock());
925 IG->set_shared_field_table(T, IG->shared_initial_field_table()->Clone(
926 /*for_isolate=*/nullptr,
927 /*for_isolate_group=*/IG));
928 }
929 DEBUG_ONLY(IG->heap()->Verify("InitializeIsolate", kForbidMarked));
930
931#if !defined(DART_PRECOMPILED_RUNTIME)
933#endif
934
935 if (snapshot_data == nullptr || kernel_buffer != nullptr) {
936 auto object_store = IG->object_store();
937 error ^= object_store->PreallocateObjects();
938 if (!error.IsNull()) {
939 return error.ptr();
940 }
941 }
942
943 if (FLAG_print_class_table) {
944 IG->class_table()->Print();
945 }
946
947 return Error::null();
948}
949
951 bool is_first_isolate_in_group,
952 void* isolate_data) {
953 auto I = T->isolate();
954 auto IG = T->isolate_group();
955 auto Z = T->zone();
956
957 // If a static field gets registered in [IsolateGroup::RegisterStaticField]:
958 //
959 // * before this block it will ignore this isolate. The [Clone] of the
960 // initial field table will pick up the new value.
961 // * after this block it will add the new static field to this isolate.
962 {
963 SafepointReadRwLocker reader(T, IG->program_lock());
964 I->set_field_table(T, IG->initial_field_table()->Clone(I));
965 I->field_table()->MarkReadyToUse();
966 }
967
968 const auto& out_of_memory =
969 Object::Handle(IG->object_store()->out_of_memory());
970 const auto& error = Error::Handle(
971 Z, I->isolate_object_store()->PreallocateObjects(out_of_memory));
972 if (!error.IsNull()) {
973 return error.ptr();
974 }
975
976 I->set_init_callback_data(isolate_data);
977
978#if !defined(PRODUCT)
981 } else {
982 I->message_handler()->set_should_pause_on_start(
983 FLAG_pause_isolates_on_start);
984 I->message_handler()->set_should_pause_on_exit(FLAG_pause_isolates_on_exit);
985 }
986#endif // !defined(PRODUCT)
987
989#if !defined(PRODUCT)
990 I->debugger()->NotifyIsolateCreated();
991#endif
992
993 // Create tag table.
995 // Set up default UserTag.
996 const UserTag& default_tag = UserTag::Handle(UserTag::DefaultTag());
997 I->set_current_tag(default_tag);
998
999 I->init_loaded_prefixes_set_storage();
1000
1001 return Error::null();
1002}
1003
1005 bool is_vm_isolate,
1006 Snapshot::Kind kind) {
1007 TextBuffer buffer(64);
1008
1009// Different fields are included for DEBUG/RELEASE/PRODUCT.
1010#if defined(DEBUG)
1011 buffer.AddString("debug");
1012#elif defined(PRODUCT)
1013 buffer.AddString("product");
1014#else
1015 buffer.AddString("release");
1016#endif
1017
1018#define ADD_FLAG(name, value) \
1019 do { \
1020 buffer.AddString(value ? (" " #name) : (" no-" #name)); \
1021 } while (0);
1022#define ADD_P(name, T, DV, C) ADD_FLAG(name, FLAG_##name)
1023#define ADD_R(name, PV, T, DV, C) ADD_FLAG(name, FLAG_##name)
1024#define ADD_C(name, PCV, PV, T, DV, C) ADD_FLAG(name, FLAG_##name)
1025#define ADD_D(name, T, DV, C) ADD_FLAG(name, FLAG_##name)
1026
1027#define ADD_ISOLATE_GROUP_FLAG(name, isolate_flag, flag) \
1028 do { \
1029 const bool value = \
1030 isolate_group != nullptr ? isolate_group->name() : flag; \
1031 ADD_FLAG(name, value); \
1032 } while (0);
1033
1034 if (Snapshot::IncludesCode(kind)) {
1036
1037 ADD_FLAG(tsan, FLAG_target_thread_sanitizer)
1039
1040 if (kind == Snapshot::kFullJIT) {
1041 // Enabling assertions affects deopt ids.
1042 //
1043 // This flag is only used at compile time for AOT, so it's only relevant
1044 // when running JIT snapshots. We can omit this flag for AOT snapshots so
1045 // feature verification won't fail if --enable-snapshots isn't provided
1046 // at runtime.
1047 ADD_ISOLATE_GROUP_FLAG(asserts, enable_asserts, FLAG_enable_asserts);
1048 ADD_ISOLATE_GROUP_FLAG(use_field_guards, use_field_guards,
1049 FLAG_use_field_guards);
1050 ADD_ISOLATE_GROUP_FLAG(use_osr, use_osr, FLAG_use_osr);
1051 ADD_ISOLATE_GROUP_FLAG(branch_coverage, branch_coverage,
1052 FLAG_branch_coverage);
1053 ADD_ISOLATE_GROUP_FLAG(coverage, coverage, FLAG_coverage);
1054 }
1055
1056 // Generated code must match the host architecture and ABI. We check the
1057 // strong condition of matching on operating system so that
1058 // Platform.isAndroid etc can be compile-time constants.
1059#if defined(TARGET_ARCH_IA32)
1060 buffer.AddString(" ia32");
1061#elif defined(TARGET_ARCH_X64)
1062 buffer.AddString(" x64");
1063#elif defined(TARGET_ARCH_ARM)
1064 buffer.AddString(" arm");
1065#elif defined(TARGET_ARCH_ARM64)
1066 buffer.AddString(" arm64");
1067#elif defined(TARGET_ARCH_RISCV32)
1068 buffer.AddString(" riscv32");
1069#elif defined(TARGET_ARCH_RISCV64)
1070 buffer.AddString(" riscv64");
1071#else
1072#error What architecture?
1073#endif
1074
1075#if defined(DART_TARGET_OS_ANDROID)
1076 buffer.AddString(" android");
1077#elif defined(DART_TARGET_OS_FUCHSIA)
1078 buffer.AddString(" fuchsia");
1079#elif defined(DART_TARGET_OS_MACOS)
1080#if defined(DART_TARGET_OS_MACOS_IOS)
1081 buffer.AddString(" ios");
1082#else
1083 buffer.AddString(" macos");
1084#endif
1085#elif defined(DART_TARGET_OS_LINUX)
1086 buffer.AddString(" linux");
1087#elif defined(DART_TARGET_OS_WINDOWS)
1088 buffer.AddString(" windows");
1089#else
1090#error What operating system?
1091#endif
1092
1093#if defined(DART_COMPRESSED_POINTERS)
1094 buffer.AddString(" compressed-pointers");
1095#else
1096 buffer.AddString(" no-compressed-pointers");
1097#endif
1098 }
1099
1100#undef ADD_ISOLATE_FLAG
1101#undef ADD_D
1102#undef ADD_C
1103#undef ADD_R
1104#undef ADD_P
1105#undef ADD_FLAG
1106
1107 return buffer.Steal();
1108}
1109
1111 Thread* thread = Thread::Current();
1113 Isolate* isolate = thread->isolate();
1114 void* isolate_group_data = isolate->group()->embedder_data();
1115 void* isolate_data = isolate->init_callback_data();
1117 if (callback != nullptr) {
1118 TransitionVMToNative transition(thread);
1119 (callback)(isolate_group_data, isolate_data);
1120 }
1121}
1122
1124 T->isolate()->Shutdown();
1125}
1126
1128 return OS::GetCurrentMonotonicMicros() - Dart::start_time_micros_;
1129}
1130
1133 ASSERT(predefined_handles_ != nullptr);
1134 uword handle = predefined_handles_->handles_.AllocateScopedHandle();
1135#if defined(DEBUG)
1136 *reinterpret_cast<uword*>(handle + kOffsetOfIsZoneHandle * kWordSize) = 0;
1137#endif
1138 return handle;
1139}
1140
1143 ASSERT(predefined_handles_ != nullptr);
1144 return predefined_handles_->api_handles_.AllocateHandle();
1145}
1146
1148 ASSERT(predefined_handles_ != nullptr);
1149 return predefined_handles_->handles_.IsValidScopedHandle(address);
1150}
1151
1153 ASSERT(predefined_handles_ != nullptr);
1154 return predefined_handles_->api_handles_.IsValidHandle(handle);
1155}
1156
1157} // namespace dart
int count
Definition: FontMgrTest.cpp:50
static bool ok(int result)
#define IG
#define RELEASE_ASSERT(cond)
Definition: assert.h:327
#define Z
static void Init()
static void InitHandles()
static void Cleanup()
ErrorPtr EnsureIsFinalized(Thread *thread) const
Definition: object.cc:4924
static void Cleanup()
static void RegisterExternal(Dart_CodeObserver observer)
static void Init()
static bool SetInitializing()
Definition: dart.cc:104
static void ResetInitializing()
Definition: dart.cc:110
static bool SetCleaningup()
Definition: dart.cc:126
static bool IsInitialized()
Definition: dart.cc:124
static void SetUnInitialized()
Definition: dart.cc:131
static bool SetInUse()
Definition: dart.cc:140
static void ResetInUse()
Definition: dart.cc:148
static void SetInitialized()
Definition: dart.cc:117
static ErrorPtr InitializeIsolateGroup(Thread *T, const uint8_t *snapshot_data, const uint8_t *snapshot_instructions, const uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
Definition: dart.cc:908
static bool IsReadOnlyHandle(uword address)
Definition: dart.cc:1147
static char * Cleanup()
Definition: dart.cc:629
static void set_thread_start_callback(Dart_ThreadStartCallback cback)
Definition: dart.h:100
static bool IsInitialized()
Definition: dart.cc:799
static void ShutdownIsolate(Thread *T)
Definition: dart.cc:1123
static IsolateGroup * vm_isolate_group()
Definition: dart.h:69
static void set_entropy_source_callback(Dart_EntropySource entropy_source)
Definition: dart.h:132
static bool SetActiveApiCall()
Definition: dart.cc:803
static int64_t UptimeMillis()
Definition: dart.h:76
static Isolate * vm_isolate()
Definition: dart.h:68
static char * Init(const Dart_InitializeParams *params)
Definition: dart.cc:526
static void SetFileCallbacks(Dart_FileOpenCallback file_open, Dart_FileReadCallback file_read, Dart_FileWriteCallback file_write, Dart_FileCloseCallback file_close)
Definition: dart.h:109
static int64_t UptimeMicros()
Definition: dart.cc:1127
static char * FeaturesString(IsolateGroup *isolate_group, bool is_vm_snapshot, Snapshot::Kind kind)
Definition: dart.cc:1004
static Isolate * CreateIsolate(const char *name_prefix, const Dart_IsolateFlags &api_flags, IsolateGroup *isolate_group)
Definition: dart.cc:811
static bool IsReadOnlyApiHandle(Dart_Handle handle)
Definition: dart.cc:1152
static uword AllocateReadOnlyHandle()
Definition: dart.cc:1131
static void ResetActiveApiCall()
Definition: dart.cc:807
static void RunShutdownCallback()
Definition: dart.cc:1110
static LocalHandle * AllocateReadOnlyApiHandle()
Definition: dart.cc:1141
static ErrorPtr InitializeIsolate(Thread *T, bool is_first_isolate_in_group, void *isolate_data)
Definition: dart.cc:950
static void set_thread_exit_callback(Dart_ThreadExitCallback cback)
Definition: dart.h:106
static ErrorPtr InitIsolateGroupFromSnapshot(Thread *T, const uint8_t *snapshot_data, const uint8_t *snapshot_instructions, const uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
Definition: dart.cc:820
static void Cleanup()
static bool Initialized()
Definition: flags.h:72
static void Init()
Definition: become.cc:42
static void Init()
Definition: freelist.cc:66
ApiErrorPtr ReadProgramSnapshot()
static GrowableObjectArrayPtr New(Heap::Space space=Heap::kNew)
Definition: object.h:11144
uword AllocateScopedHandle()
Definition: handles.h:96
bool IsValidScopedHandle(uword handle) const
Definition: handles_impl.h:175
@ kOld
Definition: heap.h:39
void PrintSizes() const
Definition: heap.cc:793
bool Verify(const char *msg, MarkExpectation mark_expectation=kForbidMarked)
Definition: heap.cc:771
static void Init()
Definition: object.cc:17248
static void Cleanup()
Definition: object.cc:17259
static void SetFileModifiedCallback(Dart_FileModifiedCallback callback)
void * embedder_data() const
Definition: isolate.h:291
Heap * heap() const
Definition: isolate.h:296
ClassTable * class_table() const
Definition: isolate.h:496
static bool HasOnlyVMIsolateGroup()
Definition: isolate.cc:724
void set_object_store(ObjectStore *object_store)
Definition: isolate.cc:1072
static void RegisterIsolateGroup(IsolateGroup *isolate_group)
Definition: isolate.cc:704
static bool HasApplicationIsolateGroups()
Definition: isolate.cc:714
static void Init()
Definition: isolate.cc:734
static void ForEach(std::function< void(IsolateGroup *)> action)
Definition: isolate.cc:683
static void Cleanup()
Definition: isolate.cc:742
static bool IsSystemIsolate(const Isolate *isolate)
Definition: isolate.h:1445
static void DisableIsolateCreation()
Definition: isolate.cc:3590
@ kInternalKillMsg
Definition: isolate.h:973
static Isolate * Current()
Definition: isolate.h:986
IsolateObjectStore * isolate_object_store() const
Definition: isolate.h:1007
static void KillAllSystemIsolates(LibMsgId msg_id)
Definition: isolate.cc:3701
static void FlagsInitialize(Dart_IsolateFlags *api_flags)
Definition: isolate.cc:1648
static void SetShutdownCallback(Dart_IsolateShutdownCallback cb)
Definition: isolate.h:1214
static void KillAllIsolates(LibMsgId msg_id)
Definition: isolate.cc:3696
static intptr_t IsolateListLength()
Definition: isolate.cc:3541
void * init_callback_data() const
Definition: isolate.h:1068
Dart_IsolateShutdownCallback on_shutdown_callback()
Definition: isolate.h:1022
IsolateGroup * group() const
Definition: isolate.h:1037
static void SetCleanupCallback(Dart_IsolateCleanupCallback cb)
Definition: isolate.h:1221
static void SetInitializeCallback_(Dart_InitializeIsolateCallback cb)
Definition: isolate.h:1207
static void SetGroupCleanupCallback(Dart_IsolateGroupCleanupCallback cb)
Definition: isolate.h:1228
static void SetRegisterKernelBlobCallback(Dart_RegisterKernelBlobCallback cb)
Definition: isolate.h:1234
static void SetCreateGroupCallback(Dart_IsolateGroupCreateCallback cb)
Definition: isolate.h:1200
static void SetUnregisterKernelBlobCallback(Dart_UnregisterKernelBlobCallback cb)
Definition: isolate.h:1241
const char * name() const
Definition: isolate.h:1043
static void InitializeState()
static bool IsRunning()
static void Shutdown()
LocalHandle * AllocateHandle()
bool IsValidHandle(Dart_Handle object) const
static void PrintSizes(Thread *thread)
static void SetCurrent(OSThread *current)
Definition: os_thread.h:186
static void Init()
Definition: os_thread.cc:177
static OSThread * Current()
Definition: os_thread.h:179
static void DisableOSThreadCreation()
Definition: os_thread.cc:247
static int64_t GetCurrentMonotonicMicros()
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static void Sleep(int64_t millis)
static void Init()
static void Cleanup()
static void Cleanup()
Definition: object.cc:1364
static void InitNullAndBool(IsolateGroup *isolate_group)
Definition: object.cc:554
static ObjectPtr null()
Definition: object.h:433
static void FinishInit(IsolateGroup *isolate_group)
Definition: object.cc:1351
static void FinalizeVMIsolate(IsolateGroup *isolate_group)
Definition: object.cc:1470
static Object & Handle()
Definition: object.h:407
static void Init(IsolateGroup *isolate_group)
Definition: object.cc:721
static void VerifyBuiltinVtables()
Definition: object.cc:1634
static void Cleanup()
static void Init()
Definition: page.cc:31
static void Cleanup()
Definition: page.cc:45
static void Init()
Definition: port.cc:248
static void Cleanup()
Definition: port.cc:261
static void Cleanup()
Definition: profiler.cc:605
static void Init()
Definition: profiler.cc:573
static void Cleanup()
Definition: random.cc:88
static void Init()
Definition: random.cc:81
static bool SendIsolateStartupMessage()
static void MaybeMakeServiceIsolate(Isolate *isolate)
static void SetGetServiceAssetsCallback(Dart_GetVMServiceAssetsArchive get_service_assets)
Definition: service.cc:1441
static void SetEmbedderStreamCallbacks(Dart_ServiceStreamListenCallback listen_callback, Dart_ServiceStreamCancelCallback cancel_callback)
Definition: service.cc:1434
static void Init()
Definition: service.cc:97
static void Cleanup()
Definition: service.cc:119
static void Init()
static char * InitializeGlobalVMFlagsFromSnapshot(const Snapshot *snapshot)
Kind kind() const
Definition: snapshot.h:60
static bool IsFull(Kind kind)
Definition: snapshot.h:63
static const Snapshot * SetupFromBuffer(const void *raw_memory)
Definition: snapshot.cc:30
static const char * KindToCString(Kind kind)
Definition: snapshot.cc:12
intptr_t length() const
Definition: snapshot.h:56
static bool IncludesCode(Kind kind)
Definition: snapshot.h:67
static StringPtr NewFormatted(const char *format,...) PRINTF_ATTRIBUTE(1
Definition: object.cc:24004
static StringPtr New(const char *cstr, Heap::Space space=Heap::kNew)
Definition: object.cc:23698
static void Init()
Definition: stub_code.cc:46
static void Cleanup()
Definition: stub_code.cc:124
static void GetStats(IsolateGroup *isolate_group, intptr_t *size, intptr_t *capacity)
Definition: symbols.cc:180
static void Init(IsolateGroup *isolate_group)
Definition: symbols.cc:80
static void Init()
Definition: cpu_arm.h:70
static bool sse2_supported()
Definition: cpu_ia32.h:60
static void Cleanup()
Definition: cpu_arm.h:71
Zone * zone() const
Definition: thread_state.h:37
static Thread * Current()
Definition: thread.h:362
ExecutionState execution_state() const
Definition: thread.h:1040
Isolate * isolate() const
Definition: thread.h:534
IsolateGroup * isolate_group() const
Definition: thread.h:541
static void EnterIsolate(Isolate *isolate)
Definition: thread.cc:371
static void ExitIsolate(bool isolate_shutdown=false)
Definition: thread.cc:428
static UserTagPtr DefaultTag()
Definition: object.cc:26974
static void Cleanup()
Definition: tags.cc:191
static void Init()
Definition: tags.cc:187
static char * StrDup(const char *s)
static char * SCreate(const char *format,...) PRINTF_ATTRIBUTE(1
Definition: utils.cc:231
static void Init()
static intptr_t PageSize()
static void Cleanup()
static void Init()
Definition: zone.cc:58
static void Cleanup()
Definition: zone.cc:63
#define ADD_ISOLATE_GROUP_FLAG(name, isolate_flag, flag)
#define ADD_P(name, T, DV, C)
#define ADD_D(name, T, DV, C)
#define ADD_FLAG(name, value)
#define ADD_R(name, PV, T, DV, C)
#define ADD_C(name, PCV, PV, T, DV, C)
void(* Dart_FileWriteCallback)(const void *data, intptr_t length, void *stream)
Definition: dart_api.h:807
void(* Dart_FileCloseCallback)(void *stream)
Definition: dart_api.h:820
void(* Dart_FileReadCallback)(uint8_t **data, intptr_t *file_length, void *stream)
Definition: dart_api.h:792
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
bool(* Dart_EntropySource)(uint8_t *buffer, intptr_t length)
Definition: dart_api.h:822
void(* Dart_ThreadStartCallback)(void)
Definition: dart_api.h:754
void *(* Dart_FileOpenCallback)(const char *name, bool write)
Definition: dart_api.h:776
void(* Dart_IsolateShutdownCallback)(void *isolate_group_data, void *isolate_data)
Definition: dart_api.h:711
void(* Dart_ThreadExitCallback)(void)
Definition: dart_api.h:763
char *(* Dart_DwarfStackTraceFootnoteCallback)(void *addresses[], intptr_t count)
Definition: dart_api.h:4145
const EmbeddedViewParams * params
#define ASSERT(E)
SkBitmap source
Definition: examples.cpp:28
#define FATAL(error)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
const uint8_t uint32_t uint32_t GError ** error
uint8_t value
GAsyncResult * result
#define VM_GLOBAL_FLAG_LIST(P, R, C, D)
Definition: flag_list.h:58
constexpr bool kDartPrecompiledRuntime
Definition: flag_list.h:20
void Init()
Win32Message message
Definition: dart_vm.cc:33
static void DumpAliveIsolates(intptr_t num_attempts, bool only_application_isolates)
Definition: dart.cc:542
@ kNumPredefinedCids
Definition: class_id.h:257
static constexpr uint8_t kUnInitialized
static void FinalizeBuiltinClasses(Thread *thread)
Definition: dart.cc:896
uintptr_t uword
Definition: globals.h:501
DEFINE_FLAG(bool, print_cluster_information, false, "Print information about clusters written to snapshot")
const intptr_t cid
@ kRequireMarked
Definition: verifier.h:21
@ kForbidMarked
Definition: verifier.h:21
char * CheckIsAtLeastMinRequiredMacOSVersion()
constexpr intptr_t kWordSize
Definition: globals.h:509
static bool IsSnapshotCompatible(Snapshot::Kind vm_kind, Snapshot::Kind isolate_kind)
Definition: snapshot.h:108
constexpr bool FLAG_target_memory_sanitizer
Definition: flags.h:174
static bool OnlyVmIsolateLeft()
Definition: dart.cc:554
NOT_IN_PRODUCT(LibraryPtr ReloadTestScript(const char *script))
static constexpr intptr_t kElfPageSize
Definition: elf.h:31
DECLARE_FLAG(bool, show_invisible_frames)
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 defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
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
#define DEBUG_ONLY(code)
Definition: globals.h:141
#define Pd64
Definition: globals.h:416
#define Pd
Definition: globals.h:408
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: globals.h:581
#define T
Definition: precompiler.cc:65
#define JIT_OFFSETS_LIST(FIELD, ARRAY, SIZEOF, ARRAY_SIZEOF, PAYLOAD_SIZEOF, RANGE, CONSTANT)
#define AOT_OFFSETS_LIST(FIELD, ARRAY, SIZEOF, ARRAY_SIZEOF, PAYLOAD_SIZEOF, RANGE, CONSTANT)
#define COMMON_OFFSETS_LIST(FIELD, ARRAY, SIZEOF, ARRAY_SIZEOF, PAYLOAD_SIZEOF, RANGE, CONSTANT)
bool is_system_isolate
Definition: dart_api.h:592
Definition: SkMD5.cpp:134
static void Init()
Definition: stack_frame.cc:98
#define NOT_IN_PRECOMPILED_RUNTIME(code)
Definition: globals.h:113
#define ONLY_IN_PRECOMPILED(code)
Definition: globals.h:101