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

Unified Diff: pkg/compiler/lib/src/cps_ir/type_propagation.dart

Issue 1320143002: dart2js: A bit more inlining of static invocations. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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/cps_ir/type_propagation.dart
diff --git a/pkg/compiler/lib/src/cps_ir/type_propagation.dart b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
index 99a816ce2cf7ff01cb3cb419472c3ee8171e4223..ab1b0c0a702eb24620a8a90947f7d2caa029d0fe 100644
--- a/pkg/compiler/lib/src/cps_ir/type_propagation.dart
+++ b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
@@ -1709,15 +1709,33 @@ class TransformingVisitor extends LeafVisitor {
// The target might not have an AST, for example if it deferred.
if (!node.target.hasNode) return false;
- // An expression is non-expansive (in a sense) if it is just a call to
- // a foreign function.
+ // True if an expression is non-expansive, in the sense defined by this
+ // predicate.
asgerf 2015/08/28 14:09:26 This comment is a tautology, it might as well not
bool isNonExpansive(ast.Expression expr) {
+ if (expr is ast.LiteralNull ||
+ expr is ast.LiteralBool ||
+ expr is ast.LiteralInt ||
+ expr is ast.LiteralDouble) {
+ return true;
+ }
if (expr is ast.Send) {
SendStructure structure =
node.target.treeElements.getSendStructure(expr);
if (structure is InvokeStructure) {
+ // Calls to foreign functions.
return structure.semantics.kind == AccessKind.TOPLEVEL_METHOD &&
backend.isForeign(structure.semantics.element);
+ } else if (structure is IsStructure || structure is IsNotStructure) {
+ // is and is! checks on nonexpansive expressions.
+ return isNonExpansive(expr.receiver);
+ } else if (structure is EqualsStructure ||
+ structure is NotEqualsStructure) {
+ // == and != on nonexpansive expressions.
+ return isNonExpansive(expr.receiver) &&
+ isNonExpansive(expr.argumentsNode.nodes.head);
+ } else if (structure is GetStructure) {
+ // Parameters.
+ return structure.semantics.kind == AccessKind.PARAMETER;
}
}
return false;
« 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