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

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

Issue 1696163002: dart2js cps: Count size of JS expressions in inliner. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Rebase Created 4 years, 10 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/inline.dart
diff --git a/pkg/compiler/lib/src/cps_ir/inline.dart b/pkg/compiler/lib/src/cps_ir/inline.dart
index 28ea3d5543c4ec50f757fb8766077d249681950e..d6096afea0902b5527a739cf13c606a3c6028633 100644
--- a/pkg/compiler/lib/src/cps_ir/inline.dart
+++ b/pkg/compiler/lib/src/cps_ir/inline.dart
@@ -18,6 +18,7 @@ import '../types/types.dart' show
FlatTypeMask, ForwardingTypeMask, TypeMask, UnionTypeMask;
import '../universe/call_structure.dart' show CallStructure;
import '../universe/selector.dart' show Selector;
+import 'package:js_ast/js_ast.dart' as js;
/// Inlining stack entries.
///
@@ -259,8 +260,32 @@ class SizeVisitor extends TrampolineRecursiveVisitor {
--size;
}
}
+
+ processForeignCode(ForeignCode node) {
+ // Count the number of nodes in the JS fragment, and discount the size
+ // originally added by LetPrim.
+ JsSizeVisitor visitor = new JsSizeVisitor();
+ node.codeTemplate.ast.accept(visitor);
+ size += visitor.size - 1;
+ }
+}
+
+class JsSizeVisitor extends js.BaseVisitor {
+ int size = 0;
+
+ visitNode(js.Node node) {
+ ++size;
+ return super.visitNode(node);
+ }
+
+ visitInterpolatedExpression(js.InterpolatedExpression node) {
+ // Suppress call to visitNode. Placeholders should not be counted, because
+ // the argument has already been counted, and will in most cases be inserted
+ // directly in the placeholder.
+ }
}
+
class InliningVisitor extends TrampolineRecursiveVisitor {
final Inliner _inliner;
« 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