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

Unified Diff: pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart

Issue 2831493003: dart2js: --fast-startup: cache prototypes in local in tear-off setup (Closed)
Patch Set: add comments Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
diff --git a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
index e12847056c39984e0b7a9e3aaff588d105e8d99a..bf53dae59e3e5d17595e6801855705e53e438049 100644
--- a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
@@ -1026,8 +1026,9 @@ class FragmentEmitter {
{
"container": container,
"getterName": js.quoteName(method.tearOffName),
- "isStatic": new js.LiteralBool(method.isStatic),
- "isIntercepted": new js.LiteralBool(isIntercepted),
+ // 'Truthy' values are ok for `isStatic` and `isIntercepted`.
+ "isStatic": js.number(method.isStatic ? 1 : 0),
+ "isIntercepted": js.number(isIntercepted ? 1 : 0),
"requiredParameterCount": js.number(requiredParameterCount),
"optionalParameterDefaultValues": optionalParameterDefaultValues,
"callNames": callNameArray,
@@ -1046,6 +1047,7 @@ class FragmentEmitter {
/// Emits the section that installs tear-off getters.
js.Statement emitInstallTearOffs(Fragment fragment) {
List<js.Statement> inits = <js.Statement>[];
+ js.Expression temp;
for (Library library in fragment.libraries) {
for (StaticMethod method in library.statics) {
@@ -1059,11 +1061,20 @@ class FragmentEmitter {
}
}
for (Class cls in library.classes) {
- for (InstanceMethod method in cls.methods) {
- if (method.needsTearOff) {
- js.Expression container = js.js("#.prototype", classReference(cls));
- inits.add(emitInstallTearOff(container, method));
+ var methods = cls.methods.where((m) => m.needsTearOff).toList();
+ js.Expression container = js.js("#.prototype", classReference(cls));
+ js.Expression reference = container;
+ if (methods.length > 1) {
+ if (temp == null) {
+ inits.add(js.js.statement('var _;'));
+ temp = js.js('_');
}
+ // First call uses assignment to temp to cache the container.
+ reference = js.js('# = #', [temp, container]);
+ }
+ for (InstanceMethod method in methods) {
+ inits.add(emitInstallTearOff(reference, method));
+ reference = temp; // Second and subsequent calls use temp.
}
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698