Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: utils/kernel-service/kernel-service.dart

Issue 2665753002: Reapply "Create an app snapshot of the Dart front end." (Closed)
Patch Set: . Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « utils/kernel-service/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 library runtime.tools.kernel_service; 4 library runtime.tools.kernel_service;
5 5
6 // This is an interface to the Dart Kernel parser and Kernel binary generator. 6 // This is an interface to the Dart Kernel parser and Kernel binary generator.
7 // 7 //
8 // It is used by the kernel-isolate to load Dart source code and generate 8 // It is used by the kernel-isolate to load Dart source code and generate
9 // Kernel binary format. 9 // Kernel binary format.
10 // 10 //
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } else { 198 } else {
199 // See loader.cc for the code that handles these replies. 199 // See loader.cc for the code that handles these replies.
200 if (result is CompilationOk) { 200 if (result is CompilationOk) {
201 port.send([tag, inputFileUrl, inputFileUrl, null, result]); 201 port.send([tag, inputFileUrl, inputFileUrl, null, result]);
202 } else { 202 } else {
203 port.send([-tag, inputFileUrl, inputFileUrl, null, result.errorString]); 203 port.send([-tag, inputFileUrl, inputFileUrl, null, result.errorString]);
204 } 204 }
205 } 205 }
206 } 206 }
207 207
208 main() => new RawReceivePort()..handler = _processLoadRequest; 208 // This entry point is used when running in the kernel isolate.
209 start() => new RawReceivePort()..handler = _processLoadRequest;
210
211 // This entry point is used when creating an app snapshot. The argument provides
212 // a script to compile to warm-up generated code.
213 main(args) {
214 // TODO(28532): Enable on Windows.
215 if (Platform.isWindows) return;
216
217 var tag = 1;
218 var scriptUri = args[0];
219 var responsePort = new RawReceivePort();
220 responsePort.handler = (response) {
221 if (response[0] == tag) {
222 // Success.
223 responsePort.close();
224 } else if (response[0] == -tag) {
225 // Compilation error.
226 throw response[4];
227 } else {
228 throw "Unexpected response: $response";
229 }
230 };
231 var request = [tag, responsePort.sendPort, scriptUri];
232 _processLoadRequest(request);
233 }
209 234
210 // This duplicates functionality from the Loader which we can't easily 235 // This duplicates functionality from the Loader which we can't easily
211 // access from here. 236 // access from here.
212 Uri _findPackagesFile(Uri base) async { 237 Uri _findPackagesFile(Uri base) async {
213 var dir = new File.fromUri(base).parent; 238 var dir = new File.fromUri(base).parent;
214 while (true) { 239 while (true) {
215 final packagesFile = dir.uri.resolve(".packages"); 240 final packagesFile = dir.uri.resolve(".packages");
216 if (await new File.fromUri(packagesFile).exists()) { 241 if (await new File.fromUri(packagesFile).exists()) {
217 return packagesFile; 242 return packagesFile;
218 } 243 }
219 if (dir.parent == dir) { 244 if (dir.parent.path == dir.path) {
rmacnak 2017/01/31 01:53:37 This is always true. dart.io.Directory are only eq
Vyacheslav Egorov (Google) 2017/01/31 06:18:02 This code was copied from the Loader code so it ha
Vyacheslav Egorov (Google) 2017/01/31 07:32:22 Ah, disregard this comment. Loader does not have t
220 break; 245 break;
221 } 246 }
222 dir = dir.parent; 247 dir = dir.parent;
223 } 248 }
224 return null; 249 return null;
225 } 250 }
OLDNEW
« no previous file with comments | « utils/kernel-service/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698