Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 4628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4639 CallKind call_kind = (expr->expression()->AsProperty() == NULL) | 4639 CallKind call_kind = (expr->expression()->AsProperty() == NULL) |
| 4640 ? CALL_AS_FUNCTION | 4640 ? CALL_AS_FUNCTION |
| 4641 : CALL_AS_METHOD; | 4641 : CALL_AS_METHOD; |
| 4642 | 4642 |
| 4643 // Precondition: call is monomorphic and we have found a target with the | 4643 // Precondition: call is monomorphic and we have found a target with the |
| 4644 // appropriate arity. | 4644 // appropriate arity. |
| 4645 Handle<JSFunction> caller = info()->closure(); | 4645 Handle<JSFunction> caller = info()->closure(); |
| 4646 Handle<JSFunction> target = expr->target(); | 4646 Handle<JSFunction> target = expr->target(); |
| 4647 Handle<SharedFunctionInfo> target_shared(target->shared()); | 4647 Handle<SharedFunctionInfo> target_shared(target->shared()); |
| 4648 | 4648 |
| 4649 // Do a quick check on source code length to avoid parsing large | 4649 int ast_node_count = target_shared->ast_node_count(); |
|
Kevin Millikin (Chromium)
2011/11/24 13:15:56
Move this inside the if where it's used.
ulan
2011/11/25 09:11:15
Now I use to increment "inlined_count_".
| |
| 4650 // inlining candidates. | 4650 |
| 4651 if (FLAG_limit_inlining && target->shared()->SourceSize() > kMaxSourceSize) { | 4651 if (FLAG_limit_inlining) { |
| 4652 TraceInline(target, caller, "target text too big"); | 4652 if (ast_node_count > kMaxInlinedSize) { |
|
Kevin Millikin (Chromium)
2011/11/24 13:15:56
All of these need some comment about what we're tr
ulan
2011/11/25 09:11:15
Done.
| |
| 4653 return false; | 4653 TraceInline(target, caller, "target AST is too large"); |
| 4654 return false; | |
| 4655 } | |
| 4656 | |
| 4657 if (target->shared()->SourceSize() > kMaxSourceSize) { | |
|
Kevin Millikin (Chromium)
2011/11/24 13:15:56
I wonder if we can just get rid of this now?
ulan
2011/11/25 09:11:15
Unfortunately, removing it regresses the delta blu
| |
| 4658 TraceInline(target, caller, "target text too big"); | |
| 4659 return false; | |
| 4660 } | |
| 4661 | |
| 4662 if (inlined_count_ > kMaxInlinedNodesSoft) { | |
|
Kevin Millikin (Chromium)
2011/11/24 13:15:56
OK, but the logic is hard to follow because it doe
ulan
2011/11/25 09:11:15
Done.
| |
| 4663 if (ast_node_count > kMaxInlinedPrimitiveSize || | |
| 4664 inlined_count_ > kMaxInlinedNodesHard || | |
| 4665 !target_shared->is_primitive()) { | |
| 4666 TraceInline(target, caller, "cumulative AST node limit reached"); | |
| 4667 return false; | |
| 4668 } | |
| 4669 } | |
| 4654 } | 4670 } |
| 4655 | 4671 |
| 4656 // Target must be inlineable. | 4672 // Target must be inlineable. |
| 4657 if (!target->IsInlineable()) { | 4673 if (!target->IsInlineable()) { |
| 4658 TraceInline(target, caller, "target not inlineable"); | 4674 TraceInline(target, caller, "target not inlineable"); |
| 4659 return false; | 4675 return false; |
| 4660 } | 4676 } |
| 4661 | 4677 |
| 4662 #if !defined(V8_TARGET_ARCH_IA32) | 4678 #if !defined(V8_TARGET_ARCH_IA32) |
| 4663 // Target must be able to use caller's context. | 4679 // Target must be able to use caller's context. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 4686 // Don't inline recursive functions. | 4702 // Don't inline recursive functions. |
| 4687 for (FunctionState* state = function_state(); | 4703 for (FunctionState* state = function_state(); |
| 4688 state != NULL; | 4704 state != NULL; |
| 4689 state = state->outer()) { | 4705 state = state->outer()) { |
| 4690 if (state->compilation_info()->closure()->shared() == *target_shared) { | 4706 if (state->compilation_info()->closure()->shared() == *target_shared) { |
| 4691 TraceInline(target, caller, "target is recursive"); | 4707 TraceInline(target, caller, "target is recursive"); |
| 4692 return false; | 4708 return false; |
| 4693 } | 4709 } |
| 4694 } | 4710 } |
| 4695 | 4711 |
| 4696 // We don't want to add more than a certain number of nodes from inlining. | |
| 4697 if (FLAG_limit_inlining && inlined_count_ > kMaxInlinedNodes) { | |
| 4698 TraceInline(target, caller, "cumulative AST node limit reached"); | |
| 4699 return false; | |
| 4700 } | |
| 4701 | |
| 4702 int count_before = AstNode::Count(); | 4712 int count_before = AstNode::Count(); |
|
Kevin Millikin (Chromium)
2011/11/24 13:15:56
Please remove this, because it's only used to comp
ulan
2011/11/25 09:11:15
Done.
| |
| 4703 | 4713 |
| 4704 // Parse and allocate variables. | 4714 // Parse and allocate variables. |
| 4705 CompilationInfo target_info(target); | 4715 CompilationInfo target_info(target); |
| 4706 if (!ParserApi::Parse(&target_info) || | 4716 if (!ParserApi::Parse(&target_info) || |
| 4707 !Scope::Analyze(&target_info)) { | 4717 !Scope::Analyze(&target_info)) { |
| 4708 if (target_info.isolate()->has_pending_exception()) { | 4718 if (target_info.isolate()->has_pending_exception()) { |
| 4709 // Parse or scope error, never optimize this function. | 4719 // Parse or scope error, never optimize this function. |
| 4710 SetStackOverflow(); | 4720 SetStackOverflow(); |
| 4711 target_shared->DisableOptimization(*target); | 4721 target_shared->DisableOptimization(*target); |
| 4712 } | 4722 } |
| 4713 TraceInline(target, caller, "parse failure"); | 4723 TraceInline(target, caller, "parse failure"); |
| 4714 return false; | 4724 return false; |
| 4715 } | 4725 } |
| 4716 | 4726 |
| 4717 if (target_info.scope()->num_heap_slots() > 0) { | 4727 if (target_info.scope()->num_heap_slots() > 0) { |
| 4718 TraceInline(target, caller, "target has context-allocated variables"); | 4728 TraceInline(target, caller, "target has context-allocated variables"); |
| 4719 return false; | 4729 return false; |
| 4720 } | 4730 } |
| 4721 FunctionLiteral* function = target_info.function(); | 4731 FunctionLiteral* function = target_info.function(); |
| 4722 | 4732 |
| 4723 // Count the number of AST nodes added by inlining this call. | 4733 // Count the number of AST nodes added by inlining this call. |
| 4724 int nodes_added = AstNode::Count() - count_before; | 4734 int nodes_added = AstNode::Count() - count_before; |
| 4725 if (FLAG_limit_inlining && nodes_added > kMaxInlinedSize) { | |
| 4726 TraceInline(target, caller, "target AST is too large"); | |
| 4727 return false; | |
| 4728 } | |
| 4729 | 4735 |
| 4730 // Don't inline functions that uses the arguments object or that | 4736 // Don't inline functions that uses the arguments object or that |
| 4731 // have a mismatching number of parameters. | 4737 // have a mismatching number of parameters. |
| 4732 int arity = expr->arguments()->length(); | 4738 int arity = expr->arguments()->length(); |
| 4733 if (function->scope()->arguments() != NULL || | 4739 if (function->scope()->arguments() != NULL || |
| 4734 arity != target_shared->formal_parameter_count()) { | 4740 arity != target_shared->formal_parameter_count()) { |
| 4735 TraceInline(target, caller, "target requires special argument handling"); | 4741 TraceInline(target, caller, "target requires special argument handling"); |
| 4736 return false; | 4742 return false; |
| 4737 } | 4743 } |
| 4738 | 4744 |
| (...skipping 2413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7152 } | 7158 } |
| 7153 } | 7159 } |
| 7154 | 7160 |
| 7155 #ifdef DEBUG | 7161 #ifdef DEBUG |
| 7156 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 7162 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 7157 if (allocator_ != NULL) allocator_->Verify(); | 7163 if (allocator_ != NULL) allocator_->Verify(); |
| 7158 #endif | 7164 #endif |
| 7159 } | 7165 } |
| 7160 | 7166 |
| 7161 } } // namespace v8::internal | 7167 } } // namespace v8::internal |
| OLD | NEW |