Index: utils/kernel-service/kernel-service.dart |
diff --git a/utils/kernel-service/kernel-service.dart b/utils/kernel-service/kernel-service.dart |
index ae3410f04d754ea374197849043dc81970043180..5b7ca5031c378a729bd9740d5777ef6e21fe4d27 100644 |
--- a/utils/kernel-service/kernel-service.dart |
+++ b/utils/kernel-service/kernel-service.dart |
@@ -36,103 +36,70 @@ import 'package:kernel/target/targets.dart' show TargetFlags; |
import 'package:kernel/target/vm_fasta.dart' show VmFastaTarget; |
const bool verbose = const bool.fromEnvironment('DFE_VERBOSE'); |
- |
const bool strongMode = const bool.fromEnvironment('DFE_STRONG_MODE'); |
-Future<CompilationResult> _parseScriptInFileSystem( |
- Uri script, FileSystem fileSystem, |
- {bool verbose: false, bool strongMode: false}) async { |
- final Uri packagesUri = (Platform.packageConfig != null) |
+// Process a request from the runtime. See KernelIsolate::CompileToKernel in |
+// kernel_isolate.cc and Loader::SendKernelRequest in loader.cc. |
+Future _processLoadRequest(request) async { |
+ if (verbose) print("DFE: request: $request"); |
+ |
+ int tag = request[0]; |
+ final SendPort port = request[1]; |
+ final String inputFileUri = request[2]; |
+ final Uri script = Uri.base.resolve(inputFileUri); |
+ |
+ FileSystem fileSystem = request.length > 3 |
+ ? _buildFileSystem(request[3]) |
+ : PhysicalFileSystem.instance; |
+ |
+ Uri packagesUri = (Platform.packageConfig != null) |
? Uri.parse(Platform.packageConfig) |
: null; |
- final Uri patchedSdk = Uri.base |
+ Uri sdkSummary = Uri.base |
.resolveUri(new Uri.file(Platform.resolvedExecutable)) |
- .resolveUri(new Uri.directory("patched_sdk")); |
- |
- if (verbose) { |
- print("""DFE: Requesting compilation { |
- scriptUri: ${script} |
- packagesUri: ${packagesUri} |
- patchedSdk: ${patchedSdk} |
-}"""); |
- } |
- |
- try { |
- var errors = <String>[]; |
- var options = new CompilerOptions() |
- ..strongMode = strongMode |
- ..fileSystem = fileSystem |
- ..target = new VmFastaTarget(new TargetFlags(strongMode: strongMode)) |
- ..packagesFileUri = packagesUri |
+ .resolveUri(new Uri.directory("patched_sdk")) |
// TODO(sigmund): use outline.dill when the mixin transformer is modular. |
- ..sdkSummary = patchedSdk.resolve('platform.dill') |
- ..verbose = verbose |
- ..onError = (CompilationError e) => errors.add(e.message); |
+ .resolve('platform.dill'); |
- Program program = await kernelForProgram(script, options); |
- if (errors.isNotEmpty) return new CompilationResult.errors(errors); |
- |
- // We serialize the program excluding platform.dill because the VM has these |
- // sources built-in. Everything loaded as a summary in [kernelForProgram] is |
- // marked `external`, so we can use that bit to decide what to excluce. |
- // TODO(sigmund): remove the following line (Issue #30111) |
- program.libraries.forEach((e) => e.isExternal = false); |
- return new CompilationResult.ok( |
- serializeProgram(program, filter: (lib) => !lib.isExternal)); |
- } catch (err, stack) { |
- return new CompilationResult.crash(err, stack); |
- } |
-} |
- |
-Future<CompilationResult> _processLoadRequestImpl( |
- String inputFilePathOrUri, FileSystem fileSystem) { |
- Uri scriptUri = Uri.parse(inputFilePathOrUri); |
- |
- // Because we serve both Loader and bootstrapping requests we need to |
- // duplicate the logic from _resolveScriptUri(...) here and attempt to |
- // resolve schemaless uris using current working directory. |
- if (!scriptUri.hasScheme) { |
- // Script does not have a scheme, assume that it is a path, |
- // resolve it against the working directory. |
- scriptUri = Uri.base.resolveUri(new Uri.file(inputFilePathOrUri)); |
- } |
- |
- if (!scriptUri.isScheme('file')) { |
- // TODO(vegorov): Reuse loader code to support other schemes. |
- return new Future<CompilationResult>.value(new CompilationResult.errors( |
- ["Expected 'file' scheme for a script uri: got ${scriptUri.scheme}"])); |
- } |
- return _parseScriptInFileSystem(scriptUri, fileSystem, |
- verbose: verbose, strongMode: strongMode); |
-} |
- |
-// Process a request from the runtime. See KernelIsolate::CompileToKernel in |
-// kernel_isolate.cc and Loader::SendKernelRequest in loader.cc. |
-Future _processLoadRequest(request) async { |
if (verbose) { |
- print("DFE: request: $request"); |
+ print("DFE: scriptUri: ${script}"); |
print("DFE: Platform.packageConfig: ${Platform.packageConfig}"); |
+ print("DFE: packagesUri: ${packagesUri}"); |
print("DFE: Platform.resolvedExecutable: ${Platform.resolvedExecutable}"); |
+ print("DFE: sdkSummary: ${sdkSummary}"); |
} |
- int tag = request[0]; |
- final SendPort port = request[1]; |
- final String inputFileUrl = request[2]; |
- FileSystem fileSystem = request.length > 3 |
- ? _buildFileSystem(request[3]) |
- : PhysicalFileSystem.instance; |
+ var errors = <String>[]; |
+ var options = new CompilerOptions() |
+ ..strongMode = strongMode |
+ ..fileSystem = fileSystem |
+ ..target = new VmFastaTarget(new TargetFlags(strongMode: strongMode)) |
+ ..packagesFileUri = packagesUri |
+ ..sdkSummary = sdkSummary |
+ ..verbose = verbose |
+ ..onError = (CompilationError e) => errors.add(e.message); |
CompilationResult result; |
try { |
- result = await _processLoadRequestImpl(inputFileUrl, fileSystem); |
+ Program program = await kernelForProgram(script, options); |
+ if (errors.isNotEmpty) { |
+ result = new CompilationResult.errors(errors); |
+ } else { |
+ // We serialize the program excluding platform.dill because the VM has |
+ // these sources built-in. Everything loaded as a summary in |
+ // [kernelForProgram] is marked `external`, so we can use that bit to |
+ // decide what to excluce. |
+ // TODO(sigmund): remove the following line (Issue #30111) |
+ program.libraries.forEach((e) => e.isExternal = false); |
+ result = new CompilationResult.ok( |
+ serializeProgram(program, filter: (lib) => !lib.isExternal)); |
+ } |
} catch (error, stack) { |
result = new CompilationResult.crash(error, stack); |
} |
- if (verbose) { |
- print("DFE:> ${result}"); |
- } |
+ if (verbose) print("DFE:> ${result}"); |
// Check whether this is a Loader request or a bootstrapping request from |
// KernelIsolate::CompileToKernel. |
@@ -144,7 +111,7 @@ Future _processLoadRequest(request) async { |
if (result.status != Status.ok) { |
tag = -tag; |
} |
- port.send([tag, inputFileUrl, inputFileUrl, null, result.payload]); |
+ port.send([tag, inputFileUri, inputFileUri, null, result.payload]); |
} |
} |