Index: pkg/front_end/tool/fasta_perf.dart |
diff --git a/pkg/front_end/tool/fasta_perf.dart b/pkg/front_end/tool/fasta_perf.dart |
index d105768f015edaf4686bd8051ba077bbb6be41d6..4b666f317d091f22fd28d97afa5df6e2b5ee28cd 100644 |
--- a/pkg/front_end/tool/fasta_perf.dart |
+++ b/pkg/front_end/tool/fasta_perf.dart |
@@ -9,15 +9,21 @@ import 'dart:async'; |
import 'dart:io'; |
import 'package:analyzer/src/fasta/ast_builder.dart'; |
-import 'package:front_end/front_end.dart'; |
import 'package:front_end/physical_file_system.dart'; |
+import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget; |
+import 'package:front_end/src/fasta/kernel/kernel_target.dart' |
+ show KernelTarget; |
import 'package:front_end/src/fasta/parser.dart'; |
import 'package:front_end/src/fasta/scanner.dart'; |
import 'package:front_end/src/fasta/scanner/io.dart' show readBytesFromFileSync; |
import 'package:front_end/src/fasta/source/directive_listener.dart'; |
+import 'package:front_end/src/fasta/ticker.dart' show Ticker; |
import 'package:front_end/src/fasta/translate_uri.dart' show TranslateUri; |
-import 'package:front_end/src/fasta/parser/native_support.dart' |
+import 'package:front_end/src/fasta/translate_uri.dart'; |
+import 'package:front_end/src/fasta/parser/dart_vm_native.dart' |
show skipNativeClause; |
+import 'package:kernel/target/targets.dart' show TargetFlags; |
+import 'package:kernel/target/vm_fasta.dart' show VmFastaTarget; |
/// Cumulative total number of chars scanned. |
int inputSize = 0; |
@@ -44,9 +50,11 @@ main(List<String> args) async { |
'kernel_gen_e2e': () async { |
await generateKernel(entryUri); |
}, |
- 'kernel_gen_e2e_sum': () async { |
- await generateKernel(entryUri, compileSdk: false); |
- }, |
+ // TODO(sigmund): enable once we add a build step to create the |
+ // platform.dill files. |
+ // 'kernel_gen_e2e_sum': () async { |
+ // await generateKernel(entryUri, compileSdk: false); |
+ // }, |
}; |
var handler = handlers[bench]; |
@@ -68,17 +76,16 @@ main(List<String> args) async { |
} |
} |
-// TODO(sigmund): use `perf.dart::_findSdkPath` here when fasta can patch the |
-// sdk directly. |
-Uri sdkRoot = |
- Uri.base.resolve(Platform.resolvedExecutable).resolve('patched_sdk/'); |
- |
/// Translates `dart:*` and `package:*` URIs to resolved URIs. |
TranslateUri uriResolver; |
/// Preliminary set up to be able to correctly resolve URIs on the given |
/// program. |
Future setup(Uri entryUri) async { |
+ // TODO(sigmund): use `perf.dart::_findSdkPath` here when fasta can patch the |
+ // sdk directly. |
+ var sdkRoot = |
+ Uri.base.resolve(Platform.resolvedExecutable).resolve('patched_sdk/'); |
uriResolver = await TranslateUri.parse(PhysicalFileSystem.instance, sdkRoot); |
} |
@@ -165,7 +172,7 @@ Set<String> extractDirectiveUris(List<int> contents) { |
class DirectiveListenerWithNative extends DirectiveListener { |
@override |
- Token handleNativeClause(Token token) => skipNativeClause(token, true); |
+ Token handleNativeClause(Token token) => skipNativeClause(token); |
} |
/// Parses every file in [files] and reports the time spent doing so. |
@@ -200,6 +207,7 @@ class _PartialAstBuilder extends AstBuilder { |
} |
// Invoke the fasta kernel generator for the program starting in [entryUri] |
+// TODO(sigmund): update to use the frontend api once fasta is being hit. |
generateKernel(Uri entryUri, |
{bool compileSdk: true, bool strongMode: false}) async { |
// TODO(sigmund): this is here only to compute the input size, |
@@ -207,15 +215,11 @@ generateKernel(Uri entryUri, |
scanReachableFiles(entryUri); |
var timer = new Stopwatch()..start(); |
- var options = new CompilerOptions() |
- ..sdkRoot = sdkRoot |
- ..chaseDependencies = true |
- ..packagesFileUri = Uri.base.resolve('.packages') |
- ..compileSdk = compileSdk; |
- if (!compileSdk) { |
- options.sdkSummary = sdkRoot.resolve('outline.dill'); |
- } |
- |
+ final Ticker ticker = new Ticker(); |
+ final DillTarget dillTarget = new DillTarget(ticker, uriResolver, |
+ new VmFastaTarget(new TargetFlags(strongMode: strongMode))); |
+ final KernelTarget kernelTarget = |
+ new KernelTarget(PhysicalFileSystem.instance, dillTarget, uriResolver); |
var entrypoints = [ |
entryUri, |
// These extra libraries are added to match the same set of libraries |
@@ -232,11 +236,20 @@ generateKernel(Uri entryUri, |
Uri.parse('dart:mirrors'), |
Uri.parse('dart:typed_data'), |
]; |
- var program = await kernelForBuildUnit(entrypoints, options); |
+ entrypoints.forEach(kernelTarget.read); |
+ if (!compileSdk) { |
+ dillTarget.read( |
+ Uri.base.resolve(Platform.resolvedExecutable).resolve('platform.dill')); |
+ } |
+ await dillTarget.buildOutlines(); |
+ await kernelTarget.buildOutlines(); |
+ var program = await kernelTarget.buildProgram(); |
+ if (kernelTarget.errors.isNotEmpty) { |
+ throw kernelTarget.errors.first; |
+ } |
timer.stop(); |
- var name = 'kernel_gen_e2e${compileSdk ? "" : "_sum"}'; |
- report(name, timer.elapsedMicroseconds); |
+ report('kernel_gen_e2e', timer.elapsedMicroseconds); |
return program; |
} |