Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
dart_vm_data.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_RUNTIME_DART_VM_DATA_H_
6#define FLUTTER_RUNTIME_DART_VM_DATA_H_
7
8#include "flutter/fml/macros.h"
9#include "flutter/runtime/dart_snapshot.h"
10
11namespace flutter {
12
13//------------------------------------------------------------------------------
14/// @brief Provides thread-safe access to data that is necessary to
15/// bootstrap a new Dart VM instance. All snapshots referenced by
16/// this object are read-only.
17///
19 public:
20 //----------------------------------------------------------------------------
21 /// @brief Creates a new instance of `DartVMData`. Both the VM and
22 /// isolate snapshot members are optional and may be `nullptr`. If
23 /// `nullptr`, the snapshot resolvers present in the settings
24 /// object are used to infer the snapshots. If the snapshots
25 /// cannot be inferred from the settings object, this method
26 /// return `nullptr`.
27 ///
28 /// @param[in] settings The settings used to infer the VM and
29 /// isolate snapshots if they are not provided
30 /// directly.
31 /// @param[in] vm_snapshot The VM snapshot or `nullptr`.
32 /// @param[in] isolate_snapshot The isolate snapshot or `nullptr`.
33 ///
34 /// @return A new instance of VM data that can be used to bootstrap a Dart
35 /// VM. `nullptr` if the snapshots are not provided and cannot be
36 /// inferred from the settings object.
37 ///
38 static std::shared_ptr<const DartVMData> Create(
39 const Settings& settings,
41 fml::RefPtr<const DartSnapshot> isolate_snapshot);
42
43 //----------------------------------------------------------------------------
44 /// @brief Collect the DartVMData instance.
45 ///
47
48 //----------------------------------------------------------------------------
49 /// @brief The settings object from which the Dart snapshots were
50 /// inferred.
51 ///
52 /// @return The settings.
53 ///
54 const Settings& GetSettings() const;
55
56 //----------------------------------------------------------------------------
57 /// @brief Gets the VM snapshot. This can be in the call to bootstrap
58 /// the Dart VM via `Dart_Initialize`.
59 ///
60 /// @return The VM snapshot.
61 ///
62 const DartSnapshot& GetVMSnapshot() const;
63
64 //----------------------------------------------------------------------------
65 /// @brief Get the isolate snapshot necessary to launch isolates in the
66 /// Dart VM. The Dart VM instance in which these isolates are
67 /// launched must be the same as the VM created using snapshot
68 /// accessed via `GetVMSnapshot`.
69 ///
70 /// @return The isolate snapshot.
71 ///
73
74 //----------------------------------------------------------------------------
75 /// @brief Get the isolate snapshot used to launch the service isolate
76 /// in the Dart VM.
77 ///
78 /// @return The service isolate snapshot.
79 ///
81
82 //----------------------------------------------------------------------------
83 /// @brief Returns whether the service isolate snapshot requires null
84 /// safety in the Dart_IsolateFlags used to create the isolate.
85 ///
86 /// @return True if the snapshot requires null safety.
87 ///
89
90 private:
91 const Settings settings_;
92 const fml::RefPtr<const DartSnapshot> vm_snapshot_;
93 const fml::RefPtr<const DartSnapshot> isolate_snapshot_;
94 const fml::RefPtr<const DartSnapshot> service_isolate_snapshot_;
95
96 DartVMData(const Settings& settings,
98 fml::RefPtr<const DartSnapshot> isolate_snapshot,
99 fml::RefPtr<const DartSnapshot> service_isolate_snapshot);
100
102};
103
104} // namespace flutter
105
106#endif // FLUTTER_RUNTIME_DART_VM_DATA_H_
static sk_sp< Effect > Create()
A read-only Dart heap snapshot, or, read-executable mapping of AOT compiled Dart code.
Provides thread-safe access to data that is necessary to bootstrap a new Dart VM instance....
fml::RefPtr< const DartSnapshot > GetIsolateSnapshot() const
Get the isolate snapshot necessary to launch isolates in the Dart VM. The Dart VM instance in which t...
const DartSnapshot & GetVMSnapshot() const
Gets the VM snapshot. This can be in the call to bootstrap the Dart VM via Dart_Initialize.
~DartVMData()
Collect the DartVMData instance.
bool GetServiceIsolateSnapshotNullSafety() const
Returns whether the service isolate snapshot requires null safety in the Dart_IsolateFlags used to cr...
const Settings & GetSettings() const
The settings object from which the Dart snapshots were inferred.
fml::RefPtr< const DartSnapshot > GetServiceIsolateSnapshot() const
Get the isolate snapshot used to launch the service isolate in the Dart VM.
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27