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

Unified Diff: src/hydrogen.cc

Issue 8677008: Relax inlining limits for simple leaf functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rename "heavy" and add comments. Created 9 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
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 39a68cc6e1e946b1b006c1ef2caa4d5dbcc390a9..284c53629e23a50ba2e8f5f5102f98dd251e4a4c 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -4646,11 +4646,37 @@ bool HGraphBuilder::TryInline(Call* expr, bool drop_extra) {
Handle<JSFunction> target = expr->target();
Handle<SharedFunctionInfo> target_shared(target->shared());
- // Do a quick check on source code length to avoid parsing large
- // inlining candidates.
- if (FLAG_limit_inlining && target->shared()->SourceSize() > kMaxSourceSize) {
- TraceInline(target, caller, "target text too big");
- return false;
+ int ast_node_count = target_shared->ast_node_count();
+
+ if (FLAG_limit_inlining) {
+ if (ast_node_count > kMaxInlinedSize) {
+ // Never inline big functions.
+ TraceInline(target, caller, "target AST is too large");
+ return false;
+ }
+
+ if (target->shared()->SourceSize() > kMaxSourceSize) {
+ // Never inline big functions.
+ TraceInline(target, caller, "target text too big");
+ return false;
+ }
+
+ if (inlined_count_ > kMaxInlinedNodesHard) {
+ // Do not inline after the hard limit is reached.
+ TraceInline(target, caller, "cumulative AST node limit reached");
+ return false;
+ }
+
+ if (inlined_count_ > kMaxInlinedNodesSoft) {
+ // Inline only small "primitive" functions after reaching the soft limit,
+ // where "primitive" is defined by syntactic criterion.
+ if (ast_node_count > kMaxInlinedPrimitiveSize ||
+ inlined_count_ > kMaxInlinedNodesHard ||
Kevin Millikin (Chromium) 2011/11/28 12:11:59 I think 'inlined_count_ > MaxInlinedNodesHard' is
ulan 2011/11/29 14:06:52 Done.
+ !target_shared->is_primitive()) {
+ TraceInline(target, caller, "cumulative AST node limit reached");
Kevin Millikin (Chromium) 2011/11/28 12:11:59 This should be a distinct bailout message from the
ulan 2011/11/29 14:06:52 Done.
+ return false;
+ }
+ }
}
// Target must be inlineable.
@@ -4693,14 +4719,6 @@ bool HGraphBuilder::TryInline(Call* expr, bool drop_extra) {
}
}
- // We don't want to add more than a certain number of nodes from inlining.
- if (FLAG_limit_inlining && inlined_count_ > kMaxInlinedNodes) {
- TraceInline(target, caller, "cumulative AST node limit reached");
- return false;
- }
-
- int count_before = AstNode::Count();
-
// Parse and allocate variables.
CompilationInfo target_info(target);
if (!ParserApi::Parse(&target_info) ||
@@ -4720,13 +4738,6 @@ bool HGraphBuilder::TryInline(Call* expr, bool drop_extra) {
}
FunctionLiteral* function = target_info.function();
- // Count the number of AST nodes added by inlining this call.
- int nodes_added = AstNode::Count() - count_before;
- if (FLAG_limit_inlining && nodes_added > kMaxInlinedSize) {
- TraceInline(target, caller, "target AST is too large");
- return false;
- }
-
// Don't inline functions that uses the arguments object or that
// have a mismatching number of parameters.
int arity = expr->arguments()->length();
@@ -4829,7 +4840,7 @@ bool HGraphBuilder::TryInline(Call* expr, bool drop_extra) {
}
// Update inlined nodes count.
- inlined_count_ += nodes_added;
+ inlined_count_ += ast_node_count;
TraceInline(target, caller, NULL);

Powered by Google App Engine
This is Rietveld 408576698