Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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)
333 Timeline::Init();
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 }
766 Timeline::Cleanup();
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
802
806
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 DEBUG_ONLY(IG->heap()->Verify("InitializeIsolate", kForbidMarked));
924
925#if !defined(DART_PRECOMPILED_RUNTIME)
927#endif
928
929 if (snapshot_data == nullptr || kernel_buffer != nullptr) {
930 auto object_store = IG->object_store();
931 error ^= object_store->PreallocateObjects();
932 if (!error.IsNull()) {
933 return error.ptr();
934 }
935 }
936
937 if (FLAG_print_class_table) {
938 IG->class_table()->Print();
939 }
940
941 return Error::null();
942}
943
945 bool is_first_isolate_in_group,
946 void* isolate_data) {
947 auto I = T->isolate();
948 auto IG = T->isolate_group();
949 auto Z = T->zone();
950
951 // If a static field gets registered in [IsolateGroup::RegisterStaticField]:
952 //
953 // * before this block it will ignore this isolate. The [Clone] of the
954 // initial field table will pick up the new value.
955 // * after this block it will add the new static field to this isolate.
956 {
957 SafepointReadRwLocker reader(T, IG->program_lock());
958 I->set_field_table(T, IG->initial_field_table()->Clone(I));
959 I->field_table()->MarkReadyToUse();
960 }
961
962 const auto& out_of_memory =
963 Object::Handle(IG->object_store()->out_of_memory());
964 const auto& error = Error::Handle(
965 Z, I->isolate_object_store()->PreallocateObjects(out_of_memory));
966 if (!error.IsNull()) {
967 return error.ptr();
968 }
969
970 I->set_init_callback_data(isolate_data);
971
972#if !defined(PRODUCT)
975 } else {
976 I->message_handler()->set_should_pause_on_start(
977 FLAG_pause_isolates_on_start);
978 I->message_handler()->set_should_pause_on_exit(FLAG_pause_isolates_on_exit);
979 }
980#endif // !defined(PRODUCT)
981
983#if !defined(PRODUCT)
984 I->debugger()->NotifyIsolateCreated();
985#endif
986
987 // Create tag table.
989 // Set up default UserTag.
990 const UserTag& default_tag = UserTag::Handle(UserTag::DefaultTag());
991 I->set_current_tag(default_tag);
992
993 I->init_loaded_prefixes_set_storage();
994
995 return Error::null();
996}
997
999 bool is_vm_isolate,
1000 Snapshot::Kind kind) {
1001 TextBuffer buffer(64);
1002
1003// Different fields are included for DEBUG/RELEASE/PRODUCT.
1004#if defined(DEBUG)
1005 buffer.AddString("debug");
1006#elif defined(PRODUCT)
1007 buffer.AddString("product");
1008#else
1009 buffer.AddString("release");
1010#endif
1011
1012#define ADD_FLAG(name, value) \
1013 do { \
1014 buffer.AddString(value ? (" " #name) : (" no-" #name)); \
1015 } while (0);
1016#define ADD_P(name, T, DV, C) ADD_FLAG(name, FLAG_##name)
1017#define ADD_R(name, PV, T, DV, C) ADD_FLAG(name, FLAG_##name)
1018#define ADD_C(name, PCV, PV, T, DV, C) ADD_FLAG(name, FLAG_##name)
1019#define ADD_D(name, T, DV, C) ADD_FLAG(name, FLAG_##name)
1020
1021#define ADD_ISOLATE_GROUP_FLAG(name, isolate_flag, flag) \
1022 do { \
1023 const bool value = \
1024 isolate_group != nullptr ? isolate_group->name() : flag; \
1025 ADD_FLAG(name, value); \
1026 } while (0);
1027
1028 if (Snapshot::IncludesCode(kind)) {
1030
1032
1033 if (kind == Snapshot::kFullJIT) {
1034 // Enabling assertions affects deopt ids.
1035 //
1036 // This flag is only used at compile time for AOT, so it's only relevant
1037 // when running JIT snapshots. We can omit this flag for AOT snapshots so
1038 // feature verification won't fail if --enable-snapshots isn't provided
1039 // at runtime.
1040 ADD_ISOLATE_GROUP_FLAG(asserts, enable_asserts, FLAG_enable_asserts);
1041 ADD_ISOLATE_GROUP_FLAG(use_field_guards, use_field_guards,
1042 FLAG_use_field_guards);
1043 ADD_ISOLATE_GROUP_FLAG(use_osr, use_osr, FLAG_use_osr);
1044 ADD_ISOLATE_GROUP_FLAG(branch_coverage, branch_coverage,
1045 FLAG_branch_coverage);
1046 }
1047
1048 // Generated code must match the host architecture and ABI. We check the
1049 // strong condition of matching on operating system so that
1050 // Platform.isAndroid etc can be compile-time constants.
1051#if defined(TARGET_ARCH_IA32)
1052 buffer.AddString(" ia32");
1053#elif defined(TARGET_ARCH_X64)
1054 buffer.AddString(" x64");
1055#elif defined(TARGET_ARCH_ARM)
1056 buffer.AddString(" arm");
1057#elif defined(TARGET_ARCH_ARM64)
1058 buffer.AddString(" arm64");
1059#elif defined(TARGET_ARCH_RISCV32)
1060 buffer.AddString(" riscv32");
1061#elif defined(TARGET_ARCH_RISCV64)
1062 buffer.AddString(" riscv64");
1063#else
1064#error What architecture?
1065#endif
1066
1067#if defined(DART_TARGET_OS_ANDROID)
1068 buffer.AddString(" android");
1069#elif defined(DART_TARGET_OS_FUCHSIA)
1070 buffer.AddString(" fuchsia");
1071#elif defined(DART_TARGET_OS_MACOS)
1072#if defined(DART_TARGET_OS_MACOS_IOS)
1073 buffer.AddString(" ios");
1074#else
1075 buffer.AddString(" macos");
1076#endif
1077#elif defined(DART_TARGET_OS_LINUX)
1078 buffer.AddString(" linux");
1079#elif defined(DART_TARGET_OS_WINDOWS)
1080 buffer.AddString(" windows");
1081#else
1082#error What operating system?
1083#endif
1084
1085#if defined(DART_COMPRESSED_POINTERS)
1086 buffer.AddString(" compressed-pointers");
1087#else
1088 buffer.AddString(" no-compressed-pointers");
1089#endif
1090 }
1091
1092#undef ADD_ISOLATE_FLAG
1093#undef ADD_D
1094#undef ADD_C
1095#undef ADD_R
1096#undef ADD_P
1097#undef ADD_FLAG
1098
1099 return buffer.Steal();
1100}
1101
1103 Thread* thread = Thread::Current();
1105 Isolate* isolate = thread->isolate();
1106 void* isolate_group_data = isolate->group()->embedder_data();
1107 void* isolate_data = isolate->init_callback_data();
1109 if (callback != nullptr) {
1110 TransitionVMToNative transition(thread);
1111 (callback)(isolate_group_data, isolate_data);
1112 }
1113}
1114
1116 T->isolate()->Shutdown();
1117}
1118
1120 return OS::GetCurrentMonotonicMicros() - Dart::start_time_micros_;
1121}
1122
1125 ASSERT(predefined_handles_ != nullptr);
1126 uword handle = predefined_handles_->handles_.AllocateScopedHandle();
1127#if defined(DEBUG)
1128 *reinterpret_cast<uword*>(handle + kOffsetOfIsZoneHandle * kWordSize) = 0;
1129#endif
1130 return handle;
1131}
1132
1135 ASSERT(predefined_handles_ != nullptr);
1136 return predefined_handles_->api_handles_.AllocateHandle();
1137}
1138
1140 ASSERT(predefined_handles_ != nullptr);
1141 return predefined_handles_->handles_.IsValidScopedHandle(address);
1142}
1143
1145 ASSERT(predefined_handles_ != nullptr);
1146 return predefined_handles_->api_handles_.IsValidHandle(handle);
1147}
1148
1149} // namespace dart
int count
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:4979
static void Cleanup()
static void RegisterExternal(Dart_CodeObserver observer)
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 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:1139
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:1115
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:1119
static char * FeaturesString(IsolateGroup *isolate_group, bool is_vm_snapshot, Snapshot::Kind kind)
Definition dart.cc:998
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:1144
static uword AllocateReadOnlyHandle()
Definition dart.cc:1123
static void ResetActiveApiCall()
Definition dart.cc:807
static void RunShutdownCallback()
Definition dart.cc:1102
static LocalHandle * AllocateReadOnlyApiHandle()
Definition dart.cc:1133
static ErrorPtr InitializeIsolate(Thread *T, bool is_first_isolate_in_group, void *isolate_data)
Definition dart.cc:944
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 bool Initialized()
Definition flags.h:72
static void Cleanup()
Definition flags.cc:185
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:11118
uword AllocateScopedHandle()
Definition handles.h:96
bool IsValidScopedHandle(uword handle) const
@ kOld
Definition heap.h:39
void PrintSizes() const
Definition heap.cc:782
bool Verify(const char *msg, MarkExpectation mark_expectation=kForbidMarked)
Definition heap.cc:760
static void Init()
Definition object.cc:17295
static void Cleanup()
Definition object.cc:17306
static void SetFileModifiedCallback(Dart_FileModifiedCallback callback)
void * embedder_data() const
Definition isolate.h:290
Heap * heap() const
Definition isolate.h:295
ClassTable * class_table() const
Definition isolate.h:491
static bool HasOnlyVMIsolateGroup()
Definition isolate.cc:718
void set_object_store(ObjectStore *object_store)
Definition isolate.cc:1036
static void RegisterIsolateGroup(IsolateGroup *isolate_group)
Definition isolate.cc:698
static bool HasApplicationIsolateGroups()
Definition isolate.cc:708
static void Init()
Definition isolate.cc:728
static void ForEach(std::function< void(IsolateGroup *)> action)
Definition isolate.cc:677
static void Cleanup()
Definition isolate.cc:736
static bool IsSystemIsolate(const Isolate *isolate)
Definition isolate.h:1398
static void DisableIsolateCreation()
Definition isolate.cc:3544
static Isolate * Current()
Definition isolate.h:939
IsolateObjectStore * isolate_object_store() const
Definition isolate.h:960
static void KillAllSystemIsolates(LibMsgId msg_id)
Definition isolate.cc:3655
static void FlagsInitialize(Dart_IsolateFlags *api_flags)
Definition isolate.cc:1612
static void SetShutdownCallback(Dart_IsolateShutdownCallback cb)
Definition isolate.h:1167
static void KillAllIsolates(LibMsgId msg_id)
Definition isolate.cc:3650
static intptr_t IsolateListLength()
Definition isolate.cc:3495
void * init_callback_data() const
Definition isolate.h:1021
Dart_IsolateShutdownCallback on_shutdown_callback()
Definition isolate.h:975
IsolateGroup * group() const
Definition isolate.h:990
static void SetCleanupCallback(Dart_IsolateCleanupCallback cb)
Definition isolate.h:1174
static void SetInitializeCallback_(Dart_InitializeIsolateCallback cb)
Definition isolate.h:1160
static void SetGroupCleanupCallback(Dart_IsolateGroupCleanupCallback cb)
Definition isolate.h:1181
static void SetRegisterKernelBlobCallback(Dart_RegisterKernelBlobCallback cb)
Definition isolate.h:1187
static void SetCreateGroupCallback(Dart_IsolateGroupCreateCallback cb)
Definition isolate.h:1153
static void SetUnregisterKernelBlobCallback(Dart_UnregisterKernelBlobCallback cb)
Definition isolate.h:1194
const char * name() const
Definition isolate.h:996
static void InitializeState()
static bool IsRunning()
LocalHandle * AllocateHandle()
bool IsValidHandle(Dart_Handle object) const
static void PrintSizes(Thread *thread)
static void SetCurrent(OSThread *current)
Definition os_thread.h:182
static void Init()
Definition os_thread.cc:177
static OSThread * Current()
Definition os_thread.h:175
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:1677
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:599
static void Init()
Definition profiler.cc:567
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:24083
static StringPtr New(const char *cstr, Heap::Space space=Heap::kNew)
Definition object.cc:23777
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
static Thread * Current()
Definition thread.h:361
ExecutionState execution_state() const
Definition thread.h:1027
Isolate * isolate() const
Definition thread.h:533
IsolateGroup * isolate_group() const
Definition thread.h:540
static void EnterIsolate(Isolate *isolate)
Definition thread.cc:366
static void ExitIsolate(bool isolate_shutdown=false)
Definition thread.cc:423
static UserTagPtr DefaultTag()
Definition object.cc:27053
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:806
void(* Dart_FileCloseCallback)(void *stream)
Definition dart_api.h:819
void(* Dart_FileReadCallback)(uint8_t **data, intptr_t *file_length, void *stream)
Definition dart_api.h:791
struct _Dart_Handle * Dart_Handle
Definition dart_api.h:258
bool(* Dart_EntropySource)(uint8_t *buffer, intptr_t length)
Definition dart_api.h:821
void(* Dart_ThreadStartCallback)(void)
Definition dart_api.h:753
void *(* Dart_FileOpenCallback)(const char *name, bool write)
Definition dart_api.h:775
void(* Dart_IsolateShutdownCallback)(void *isolate_group_data, void *isolate_data)
Definition dart_api.h:710
void(* Dart_ThreadExitCallback)(void)
Definition dart_api.h:762
char *(* Dart_DwarfStackTraceFootnoteCallback)(void *addresses[], intptr_t count)
Definition dart_api.h:4088
const EmbeddedViewParams * params
#define ASSERT(E)
SkBitmap source
Definition examples.cpp:28
#define FATAL(error)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
static const uint8_t buffer[]
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
#define DECLARE_FLAG(type, name)
Definition flags.h:14
#define DEFINE_FLAG(type, name, default_value, comment)
Definition flags.h:16
Win32Message message
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
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
static bool OnlyVmIsolateLeft()
Definition dart.cc:554
static constexpr intptr_t kElfPageSize
Definition elf.h:31
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
#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)
Definition SkMD5.cpp:134
static void Init()
constexpr bool kTargetUsesThreadSanitizer
#define NOT_IN_PRECOMPILED_RUNTIME(code)
Definition globals.h:113
#define NOT_IN_PRODUCT(code)
Definition globals.h:84
#define ONLY_IN_PRECOMPILED(code)
Definition globals.h:101