Flutter Engine
The Flutter Engine
kernel_isolate.h
Go to the documentation of this file.
1// Copyright (c) 2016, 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#ifndef RUNTIME_VM_KERNEL_ISOLATE_H_
6#define RUNTIME_VM_KERNEL_ISOLATE_H_
7
8#include <vector>
9
10#include "include/dart_api.h"
12
13#include "vm/allocation.h"
14#include "vm/dart.h"
16#include "vm/os_thread.h"
17
18namespace dart {
19
20// TODO(33433): The kernel service does not belong in the VM.
21
22class KernelIsolate : public AllStatic {
23#if !defined(DART_PRECOMPILED_RUNTIME)
24
25 public:
26 static const char* kName;
27
28 // Tags used to indicate different requests to the dart frontend.
29 //
30 // Current tags include the following:
31 // 0 - Perform normal compilation.
32 // 1 - Update in-memory file system with in-memory sources (used by tests).
33 // 2 - Accept last compilation result.
34 // 3 - APP JIT snapshot training run for kernel_service.
35 // 4 - Compile expressions in context (used by expression evaluation).
36 // 5 - Generate dependencies used to create a dependencies file.
37 // 6 - Triggers shutdown of the kernel isolate.
38 // 7 - Reject last compilation result.
39 static constexpr int kCompileTag = 0;
40 static constexpr int kUpdateSourcesTag = 1;
41 static constexpr int kAcceptTag = 2;
42 static constexpr int kTrainTag = 3;
43 static constexpr int kCompileExpressionTag = 4;
44 static constexpr int kListDependenciesTag = 5;
45 static constexpr int kNotifyIsolateShutdown = 6;
46 static constexpr int kRejectTag = 7;
47
48 static void InitializeState();
49 static bool Start();
50 static void Shutdown();
51
52 static bool Exists();
53 static bool IsRunning();
55 static Dart_Port KernelPort() { return kernel_port_; }
56
58 const char* script_uri,
59 const uint8_t* platform_kernel,
60 intptr_t platform_kernel_size,
61 int source_files_count = 0,
62 Dart_SourceFile source_files[] = nullptr,
63 bool incremental_compile = true,
64 bool for_snapshot = false,
65 bool embed_sources = true,
66 const char* package_config = nullptr,
67 const char* multiroot_filepaths = nullptr,
68 const char* multiroot_scheme = nullptr,
71
75 int source_files_count,
76 Dart_SourceFile source_files[]);
77
79 const uint8_t* platform_kernel,
80 intptr_t platform_kernel_size,
81 const char* expression,
82 const Array& definitions,
83 const Array& definition_types,
84 const Array& type_definitions,
85 const Array& type_bounds,
86 const Array& type_defaults,
87 const char* library_url,
88 const char* klass,
89 const char* method,
90 TokenPosition token_pos,
91 char const* script_uri,
92 bool is_static);
93
95
97 const IsolateGroup* isolate_group);
98
99 static void AddExperimentalFlag(const char* value);
100 static bool GetExperimentalFlag(ExperimentalFeature feature);
101
102 protected:
103 static void InitCallback(Isolate* I);
104 static void SetKernelIsolate(Isolate* isolate);
105 static void SetLoadPort(Dart_Port port);
106 static void FinishedExiting();
107 static void FinishedInitializing();
108 static void InitializingFailed();
111 }
112
115 enum State {
121 };
122 static State state_;
125
127#else
128
129 public:
130 static bool IsRunning() { return false; }
131 static void Shutdown() {}
133 const IsolateGroup* isolate_group) {}
134 static bool GetExperimentalFlag(const char* value) { return false; }
135
136 protected:
137 static void SetKernelIsolate(Isolate* isolate) { UNREACHABLE(); }
138
139#endif // !defined(DART_PRECOMPILED_RUNTIME)
140
141 friend class Dart;
142 friend class Isolate;
143 friend class RunKernelTask;
144};
145
146} // namespace dart
147
148#endif // RUNTIME_VM_KERNEL_ISOLATE_H_
#define UNREACHABLE()
Definition: assert.h:248
static constexpr int kListDependenciesTag
static constexpr int kCompileExpressionTag
static void InitializingFailed()
static void SetLoadPort(Dart_Port port)
static void FinishedExiting()
static Dart_KernelCompilationResult ListDependencies()
static Dart_IsolateGroupCreateCallback create_group_callback_
static Dart_KernelCompilationResult UpdateInMemorySources(int source_files_count, Dart_SourceFile source_files[])
static Dart_KernelCompilationResult CompileToKernel(const char *script_uri, const uint8_t *platform_kernel, intptr_t platform_kernel_size, int source_files_count=0, Dart_SourceFile source_files[]=nullptr, bool incremental_compile=true, bool for_snapshot=false, bool embed_sources=true, const char *package_config=nullptr, const char *multiroot_filepaths=nullptr, const char *multiroot_scheme=nullptr, Dart_KernelCompilationVerbosityLevel verbosity=Dart_KernelCompilationVerbosityLevel_All)
static void InitializeState()
static bool IsRunning()
static constexpr int kNotifyIsolateShutdown
static Dart_KernelCompilationResult CompileExpressionToKernel(const uint8_t *platform_kernel, intptr_t platform_kernel_size, const char *expression, const Array &definitions, const Array &definition_types, const Array &type_definitions, const Array &type_bounds, const Array &type_defaults, const char *library_url, const char *klass, const char *method, TokenPosition token_pos, char const *script_uri, bool is_static)
static void NotifyAboutIsolateGroupShutdown(const IsolateGroup *isolate_group)
static Dart_Port WaitForKernelPort()
static constexpr int kUpdateSourcesTag
static void FinishedInitializing()
static void Shutdown()
static Dart_KernelCompilationResult RejectCompilation()
static void AddExperimentalFlag(const char *value)
static constexpr int kAcceptTag
static Monitor * monitor_
static Dart_KernelCompilationResult AcceptCompilation()
static bool GetExperimentalFlag(ExperimentalFeature feature)
static void InitCallback(Isolate *I)
static Dart_Port KernelPort()
static Dart_Port kernel_port_
static bool Exists()
static Dart_IsolateGroupCreateCallback create_group_callback()
friend class Isolate
static void SetKernelIsolate(Isolate *isolate)
static constexpr int kTrainTag
static Isolate * isolate_
static constexpr int kCompileTag
static const char * kName
static MallocGrowableArray< char * > * experimental_flags_
static constexpr int kRejectTag
Dart_Isolate(* Dart_IsolateGroupCreateCallback)(const char *script_uri, const char *main, const char *package_root, const char *package_config, Dart_IsolateFlags *flags, void *isolate_data, char **error)
Definition: dart_api.h:654
int64_t Dart_Port
Definition: dart_api.h:1525
Dart_KernelCompilationVerbosityLevel
Definition: dart_api.h:3798
@ Dart_KernelCompilationVerbosityLevel_All
Definition: dart_api.h:3802
uint8_t value
Definition: dart_vm.cc:33
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 port
Definition: switches.h:87
Definition: SkMD5.cpp:134