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

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: Save/restore node count in FunctionState, 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
« no previous file with comments | « src/hydrogen.h ('k') | src/isolate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 39a68cc6e1e946b1b006c1ef2caa4d5dbcc390a9..38d9f424eab40039b17552196edb5fc5f27e9897 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -4646,13 +4646,46 @@ 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");
+ if (!target->shared()->is_compiled()) {
ulan 2011/11/29 14:06:52 Is it OK? It doesn't affect performance.
+ // Do not inline a function that was never executed before.
+ // It might be lazily parsed, so the node count might be unknown.
+ TraceInline(target, caller, "target was never executed before");
return false;
}
+ if (FLAG_limit_inlining) {
+ int ast_node_count = target_shared->ast_node_count();
+
+ 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, "hard cumulative AST node limit is 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 ||
+ !target_shared->is_primitive()) {
+ TraceInline(target, caller, "soft cumulative AST node limit is reached "
+ "and the target is not a small primitive.");
+ return false;
+ }
+ }
+ }
+
// Target must be inlineable.
if (!target->IsInlineable()) {
TraceInline(target, caller, "target not inlineable");
@@ -4693,14 +4726,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 +4745,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 +4847,7 @@ bool HGraphBuilder::TryInline(Call* expr, bool drop_extra) {
}
// Update inlined nodes count.
- inlined_count_ += nodes_added;
+ inlined_count_ += function->ast_node_count();
TraceInline(target, caller, NULL);
« no previous file with comments | « src/hydrogen.h ('k') | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698