-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathkernel_isolate.h
148 lines (122 loc) · 4.57 KB
/
kernel_isolate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef RUNTIME_VM_KERNEL_ISOLATE_H_
#define RUNTIME_VM_KERNEL_ISOLATE_H_
#include <vector>
#include "include/dart_api.h"
#include "include/dart_native_api.h"
#include "vm/allocation.h"
#include "vm/dart.h"
#include "vm/experimental_features.h"
#include "vm/os_thread.h"
namespace dart {
// TODO(33433): The kernel service does not belong in the VM.
class KernelIsolate : public AllStatic {
#if !defined(DART_PRECOMPILED_RUNTIME)
public:
static const char* kName;
// Tags used to indicate different requests to the dart frontend.
//
// Current tags include the following:
// 0 - Perform normal compilation.
// 1 - Update in-memory file system with in-memory sources (used by tests).
// 2 - Accept last compilation result.
// 3 - APP JIT snapshot training run for kernel_service.
// 4 - Compile expressions in context (used by expression evaluation).
// 5 - Generate dependencies used to create a dependencies file.
// 6 - Triggers shutdown of the kernel isolate.
// 7 - Reject last compilation result.
static constexpr int kCompileTag = 0;
static constexpr int kUpdateSourcesTag = 1;
static constexpr int kAcceptTag = 2;
static constexpr int kTrainTag = 3;
static constexpr int kCompileExpressionTag = 4;
static constexpr int kListDependenciesTag = 5;
static constexpr int kNotifyIsolateShutdown = 6;
static constexpr int kRejectTag = 7;
static void InitializeState();
static bool Start();
static void Shutdown();
static bool Exists();
static bool IsRunning();
static Dart_Port WaitForKernelPort();
static Dart_Port KernelPort() { return kernel_port_; }
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 Dart_KernelCompilationResult AcceptCompilation();
static Dart_KernelCompilationResult RejectCompilation();
static Dart_KernelCompilationResult UpdateInMemorySources(
int source_files_count,
Dart_SourceFile source_files[]);
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 Dart_KernelCompilationResult ListDependencies();
static void NotifyAboutIsolateGroupShutdown(
const IsolateGroup* isolate_group);
static void AddExperimentalFlag(const char* value);
static bool GetExperimentalFlag(ExperimentalFeature feature);
protected:
static void InitCallback(Isolate* I);
static void SetKernelIsolate(Isolate* isolate);
static void SetLoadPort(Dart_Port port);
static void FinishedExiting();
static void FinishedInitializing();
static void InitializingFailed();
static Dart_IsolateGroupCreateCallback create_group_callback() {
return create_group_callback_;
}
static Dart_IsolateGroupCreateCallback create_group_callback_;
static Monitor* monitor_;
enum State {
kNotStarted,
kStopped,
kStarting,
kStarted,
kStopping,
};
static State state_;
static Isolate* isolate_;
static Dart_Port kernel_port_;
static MallocGrowableArray<char*>* experimental_flags_;
#else
public:
static bool IsRunning() { return false; }
static void Shutdown() {}
static void NotifyAboutIsolateGroupShutdown(
const IsolateGroup* isolate_group) {}
static bool GetExperimentalFlag(const char* value) { return false; }
protected:
static void SetKernelIsolate(Isolate* isolate) { UNREACHABLE(); }
#endif // !defined(DART_PRECOMPILED_RUNTIME)
friend class Dart;
friend class Isolate;
friend class RunKernelTask;
};
} // namespace dart
#endif // RUNTIME_VM_KERNEL_ISOLATE_H_