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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 14052009: Improve optimization of operations on indexables by using more inferred type information and by dis… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix dartc warnings. Created 7 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
Index: sdk/lib/_internal/compiler/implementation/ssa/builder.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
index 667f84007d3ea8eaad1d3c8171761197aefeebda..6798c579251259e432575c6a7d2ae1cd5cf2e4bb 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
@@ -2913,6 +2913,26 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
inputs.add(receiver);
addDynamicSendArgumentsToList(node, inputs);
+ // We prefer to not inline certain operations on indexables,
+ // because the constant folder will handle them better and turn
+ // them into simpler instructions that allow further
+ // optimizations.
+ bool isOptimizableOperationOnIndexable(Selector selector, Element element) {
+ bool isLength = selector.isGetter()
+ && selector.name == const SourceString("length");
+ if (isLength || selector.isIndex()) {
+ DartType classType = element.getEnclosingClass().computeType(compiler);
+ HType type = new HType.nonNullExact(classType, compiler);
+ return type.isIndexable(compiler);
+ } else if (selector.isIndexSet()) {
+ DartType classType = element.getEnclosingClass().computeType(compiler);
+ HType type = new HType.nonNullExact(classType, compiler);
+ return type.isMutableIndexable(compiler);
+ } else {
+ return false;
+ }
+ }
+
Element element = compiler.world.locateSingleElement(selector);
// TODO(ngeoffray): If [element] is a getter, then this send is
// a closure send. We should teach that to [ResolvedVisitor].
@@ -2924,7 +2944,9 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
// inline methods on intercepted classes because the
// optimizers apply their own optimizations on these methods.
&& (!backend.interceptedClasses.contains(element.getEnclosingClass())
- || isThisSend(node))) {
+ || isThisSend(node))
+ // Avoid inlining optimizable operations on indexables.
+ && !isOptimizableOperationOnIndexable(selector, element)) {
if (tryInlineMethod(element, selector, node.arguments, inputs, node)) {
return;
}
@@ -3372,7 +3394,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
ClassElement cls = element.getEnclosingClass();
return new HType.nonNullExact(cls.thisType, compiler);
} else {
- return HType.UNKNOWN;
+ return new HType.inferredTypeForElement(originalElement, compiler);
}
}
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/ssa/invoke_dynamic_specializers.dart » ('j') | tests/html/html.status » ('J')

Powered by Google App Engine
This is Rietveld 408576698