OLD | NEW |
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 | 4 |
5 /// This is an interface to the Dart Kernel parser and Kernel binary generator. | 5 /// This is an interface to the Dart Kernel parser and Kernel binary generator. |
6 /// | 6 /// |
7 /// It is used by the kernel-isolate to load Dart source code and generate | 7 /// It is used by the kernel-isolate to load Dart source code and generate |
8 /// Kernel binary format. | 8 /// Kernel binary format. |
9 /// | 9 /// |
10 /// This is either invoked as the root script of the Kernel isolate when used | 10 /// This is either invoked as the root script of the Kernel isolate when used |
11 /// as a part of | 11 /// as a part of |
12 /// | 12 /// |
13 /// dart --dfe=utils/kernel-service/kernel-service.dart ... | 13 /// dart --dfe=utils/kernel-service/kernel-service.dart ... |
14 /// | 14 /// |
15 /// invocation or it is invoked as a standalone script to perform training for | 15 /// invocation or it is invoked as a standalone script to perform training for |
16 /// the app-jit snapshot | 16 /// the app-jit snapshot |
17 /// | 17 /// |
18 /// dart utils/kernel-service/kernel-service.dart --train <source-file> | 18 /// dart utils/kernel-service/kernel-service.dart --train <source-file> |
19 /// | 19 /// |
20 /// | 20 /// |
21 library runtime.tools.kernel_service; | 21 library runtime.tools.kernel_service; |
22 | 22 |
23 import 'dart:async'; | 23 import 'dart:async'; |
24 import 'dart:io'; | 24 import 'dart:io'; |
25 import 'dart:isolate'; | 25 import 'dart:isolate'; |
26 | 26 |
| 27 import 'package:front_end/file_system.dart'; |
27 import 'package:front_end/memory_file_system.dart'; | 28 import 'package:front_end/memory_file_system.dart'; |
28 import 'package:front_end/physical_file_system.dart'; | 29 import 'package:front_end/physical_file_system.dart'; |
29 import 'package:front_end/src/fasta/vm.dart' | 30 import 'package:front_end/src/fasta/vm.dart' |
30 show CompilationResult, Status, parseScriptInFileSystem; | 31 show CompilationResult, Status, parseScriptInFileSystem; |
31 | 32 |
32 const bool verbose = const bool.fromEnvironment('DFE_VERBOSE'); | 33 const bool verbose = const bool.fromEnvironment('DFE_VERBOSE'); |
33 | 34 |
34 const bool strongMode = const bool.fromEnvironment('DFE_STRONG_MODE'); | 35 const bool strongMode = const bool.fromEnvironment('DFE_STRONG_MODE'); |
35 | 36 |
36 Future<CompilationResult> _processLoadRequestImpl( | 37 Future<CompilationResult> _processLoadRequestImpl( |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 tag = -tag; | 94 tag = -tag; |
94 } | 95 } |
95 port.send([tag, inputFileUrl, inputFileUrl, null, result.payload]); | 96 port.send([tag, inputFileUrl, inputFileUrl, null, result.payload]); |
96 } | 97 } |
97 } | 98 } |
98 | 99 |
99 // Given namedSources list of interleaved file name string and | 100 // Given namedSources list of interleaved file name string and |
100 // raw file content Uint8List this function builds up and returns | 101 // raw file content Uint8List this function builds up and returns |
101 // MemoryFileSystem instance that can be used instead of | 102 // MemoryFileSystem instance that can be used instead of |
102 // PhysicalFileSystem.instance by the frontend. | 103 // PhysicalFileSystem.instance by the frontend. |
103 FileSystem _buildMemoryFileSystem(List namedSources) { | 104 MemoryFileSystem _buildMemoryFileSystem(List namedSources) { |
104 FileSystem fileSystem = new MemoryFileSystem(Uri.parse('file:///')); | 105 MemoryFileSystem fileSystem = new MemoryFileSystem(Uri.parse('file:///')); |
105 for (int i = 0; i < namedSources.length ~/ 2; i++) { | 106 for (int i = 0; i < namedSources.length ~/ 2; i++) { |
106 fileSystem | 107 fileSystem |
107 .entityForUri(Uri.parse(namedSources[i * 2])) | 108 .entityForUri(Uri.parse(namedSources[i * 2])) |
108 .writeAsBytesSync(namedSources[i * 2 + 1]); | 109 .writeAsBytesSync(namedSources[i * 2 + 1]); |
109 } | 110 } |
110 return fileSystem; | 111 return fileSystem; |
111 } | 112 } |
112 | 113 |
113 train(String scriptUri) { | 114 train(String scriptUri) { |
114 // TODO(28532): Enable on Windows. | 115 // TODO(28532): Enable on Windows. |
(...skipping 19 matching lines...) Expand all Loading... |
134 main([args]) { | 135 main([args]) { |
135 if (args?.length == 2 && args[0] == '--train') { | 136 if (args?.length == 2 && args[0] == '--train') { |
136 // This entry point is used when creating an app snapshot. The argument | 137 // This entry point is used when creating an app snapshot. The argument |
137 // provides a script to compile to warm-up generated code. | 138 // provides a script to compile to warm-up generated code. |
138 train(args[1]); | 139 train(args[1]); |
139 } else { | 140 } else { |
140 // Entry point for the Kernel isolate. | 141 // Entry point for the Kernel isolate. |
141 return new RawReceivePort()..handler = _processLoadRequest; | 142 return new RawReceivePort()..handler = _processLoadRequest; |
142 } | 143 } |
143 } | 144 } |
OLD | NEW |