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

Unified Diff: pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart

Issue 1408353009: dart2js cps: Do not propagate InvokeMethodDirectly receiver. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add comment Created 5 years, 1 month 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/tree_ir/optimization/statement_rewriter.dart
diff --git a/pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart b/pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart
index 0091ef9bf94891b4b33e9de8ca931d801e1b1718..0639b9127411b8569aed4bc216e8b1798bf627d6 100644
--- a/pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart
+++ b/pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart
@@ -7,6 +7,7 @@ library tree_ir.optimization.statement_rewriter;
import 'optimization.dart' show Pass;
import '../tree_ir_nodes.dart';
import '../../io/source_information.dart';
+import '../../elements/elements.dart';
/**
* Translates to direct-style.
@@ -513,7 +514,19 @@ class StatementRewriter extends Transformer implements Pass {
Expression visitInvokeMethodDirectly(InvokeMethodDirectly node) {
_rewriteList(node.arguments);
- node.receiver = visitExpression(node.receiver);
+ // The target function might not exist before the enclosing class has been
+ // instantitated for the first time. If the receiver might be the first
+ // instantiation of its class, we cannot propgate it into the receiver
+ // expression, because the target function is evaluated before the receiver.
+ // Calls to constructor bodies are compiled so that the receiver is
+ // evaluated first, so they are safe.
+ if (node.target is! ConstructorBodyElement) {
+ inEmptyEnvironment(() {
+ node.receiver = visitExpression(node.receiver);
+ });
+ } else {
+ node.receiver = visitExpression(node.receiver);
+ }
return node;
}
« 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