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

Unified Diff: src/hydrogen.cc

Issue 8700001: Relax inlining limits for simple leaf functions (second version). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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..3313e6e842bcbf8bd5e6cf353ea0ed2802570bc8 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -4646,13 +4646,44 @@ 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_inlineable()) {
+ TraceInline(target, caller, "target has non-trivial declarations"
+ " or statements.");
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 the soft limit is reached.
+ // See comments of AstNode::IsInlineable for definition of "primitive".
+ if (ast_node_count > kMaxInlinedPrimitiveSize ||
+ !target_shared->is_primitive()) {
+ TraceInline(target, caller, "cumulative AST node limit reached (soft)");
+ return false;
+ }
+ }
+ }
+
// Target must be inlineable.
if (!target->IsInlineable()) {
TraceInline(target, caller, "target not inlineable");
@@ -4693,14 +4724,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) ||
@@ -4718,14 +4741,8 @@ bool HGraphBuilder::TryInline(Call* expr, bool drop_extra) {
TraceInline(target, caller, "target has context-allocated variables");
return false;
}
- 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;
- }
+ FunctionLiteral* function = target_info.function();
// Don't inline functions that uses the arguments object or that
// have a mismatching number of parameters.
@@ -4736,23 +4753,6 @@ bool HGraphBuilder::TryInline(Call* expr, bool drop_extra) {
return false;
}
- // All declarations must be inlineable.
- ZoneList<Declaration*>* decls = target_info.scope()->declarations();
- int decl_count = decls->length();
- for (int i = 0; i < decl_count; ++i) {
- if (!decls->at(i)->IsInlineable()) {
- TraceInline(target, caller, "target has non-trivial declaration");
- return false;
- }
- }
- // All statements in the body must be inlineable.
- for (int i = 0, count = function->body()->length(); i < count; ++i) {
- if (!function->body()->at(i)->IsInlineable()) {
- TraceInline(target, caller, "target contains unsupported syntax");
- return false;
- }
- }
-
// Generate the deoptimization data for the unoptimized version of
// the target function if we don't already have it.
if (!target_shared->has_deoptimization_support()) {
@@ -4829,7 +4829,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);
« 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