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

Unified Diff: pkg/front_end/tool/fasta_perf.dart

Issue 2976543002: Reapply "Tweak public APIs and use them in patch_sdk, dart2js, and kernel-service."" (Closed)
Patch Set: fix Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
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 4b666f317d091f22fd28d97afa5df6e2b5ee28cd..d105768f015edaf4686bd8051ba077bbb6be41d6 100644
--- a/pkg/front_end/tool/fasta_perf.dart
+++ b/pkg/front_end/tool/fasta_perf.dart
@@ -9,21 +9,15 @@ 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/translate_uri.dart';
-import 'package:front_end/src/fasta/parser/dart_vm_native.dart'
+import 'package:front_end/src/fasta/parser/native_support.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;
@@ -50,11 +44,9 @@ main(List<String> args) async {
'kernel_gen_e2e': () async {
await generateKernel(entryUri);
},
- // 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);
- // },
+ 'kernel_gen_e2e_sum': () async {
+ await generateKernel(entryUri, compileSdk: false);
+ },
};
var handler = handlers[bench];
@@ -76,16 +68,17 @@ 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);
}
@@ -172,7 +165,7 @@ Set<String> extractDirectiveUris(List<int> contents) {
class DirectiveListenerWithNative extends DirectiveListener {
@override
- Token handleNativeClause(Token token) => skipNativeClause(token);
+ Token handleNativeClause(Token token) => skipNativeClause(token, true);
}
/// Parses every file in [files] and reports the time spent doing so.
@@ -207,7 +200,6 @@ 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,
@@ -215,11 +207,15 @@ generateKernel(Uri entryUri,
scanReachableFiles(entryUri);
var timer = new Stopwatch()..start();
- 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 options = new CompilerOptions()
+ ..sdkRoot = sdkRoot
+ ..chaseDependencies = true
+ ..packagesFileUri = Uri.base.resolve('.packages')
+ ..compileSdk = compileSdk;
+ if (!compileSdk) {
+ options.sdkSummary = sdkRoot.resolve('outline.dill');
+ }
+
var entrypoints = [
entryUri,
// These extra libraries are added to match the same set of libraries
@@ -236,20 +232,11 @@ generateKernel(Uri entryUri,
Uri.parse('dart:mirrors'),
Uri.parse('dart:typed_data'),
];
- entrypoints.forEach(kernelTarget.read);
+ var program = await kernelForBuildUnit(entrypoints, options);
- 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();
- report('kernel_gen_e2e', timer.elapsedMicroseconds);
+ var name = 'kernel_gen_e2e${compileSdk ? "" : "_sum"}';
+ report(name, timer.elapsedMicroseconds);
return program;
}

Powered by Google App Engine
This is Rietveld 408576698