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 3934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3945 | 3945 |
3946 // We don't want to add more than a certain number of nodes from inlining. | 3946 // We don't want to add more than a certain number of nodes from inlining. |
3947 if (FLAG_limit_inlining && inlined_count_ > kMaxInlinedNodes) { | 3947 if (FLAG_limit_inlining && inlined_count_ > kMaxInlinedNodes) { |
3948 if (FLAG_trace_inlining) TraceInline(target, false); | 3948 if (FLAG_trace_inlining) TraceInline(target, false); |
3949 return false; | 3949 return false; |
3950 } | 3950 } |
3951 | 3951 |
3952 int count_before = AstNode::Count(); | 3952 int count_before = AstNode::Count(); |
3953 | 3953 |
3954 // Parse and allocate variables. | 3954 // Parse and allocate variables. |
3955 Handle<SharedFunctionInfo> shared(target->shared()); | 3955 CompilationInfo inner_info(target); |
3956 CompilationInfo inner_info(shared); | |
3957 if (!ParserApi::Parse(&inner_info) || | 3956 if (!ParserApi::Parse(&inner_info) || |
3958 !Scope::Analyze(&inner_info)) { | 3957 !Scope::Analyze(&inner_info)) { |
3959 return false; | 3958 return false; |
3960 } | 3959 } |
3961 FunctionLiteral* function = inner_info.function(); | 3960 FunctionLiteral* function = inner_info.function(); |
3962 | 3961 |
3963 // Count the number of AST nodes added by inlining this call. | 3962 // Count the number of AST nodes added by inlining this call. |
3964 int nodes_added = AstNode::Count() - count_before; | 3963 int nodes_added = AstNode::Count() - count_before; |
3965 if (FLAG_limit_inlining && nodes_added > kMaxInlinedSize) { | 3964 if (FLAG_limit_inlining && nodes_added > kMaxInlinedSize) { |
3966 if (FLAG_trace_inlining) TraceInline(target, false); | 3965 if (FLAG_trace_inlining) TraceInline(target, false); |
3967 return false; | 3966 return false; |
3968 } | 3967 } |
3969 | 3968 |
3970 // Check if we can handle all declarations in the inlined functions. | 3969 // Check if we can handle all declarations in the inlined functions. |
3971 VisitDeclarations(inner_info.scope()->declarations()); | 3970 VisitDeclarations(inner_info.scope()->declarations()); |
3972 if (HasStackOverflow()) { | 3971 if (HasStackOverflow()) { |
3973 ClearStackOverflow(); | 3972 ClearStackOverflow(); |
3974 return false; | 3973 return false; |
3975 } | 3974 } |
3976 | 3975 |
3977 // Don't inline functions that uses the arguments object or that | 3976 // Don't inline functions that uses the arguments object or that |
3978 // have a mismatching number of parameters. | 3977 // have a mismatching number of parameters. |
| 3978 Handle<SharedFunctionInfo> shared(target->shared()); |
3979 int arity = expr->arguments()->length(); | 3979 int arity = expr->arguments()->length(); |
3980 if (function->scope()->arguments() != NULL || | 3980 if (function->scope()->arguments() != NULL || |
3981 arity != target->shared()->formal_parameter_count()) { | 3981 arity != shared->formal_parameter_count()) { |
3982 return false; | 3982 return false; |
3983 } | 3983 } |
3984 | 3984 |
3985 // All statements in the body must be inlineable. | 3985 // All statements in the body must be inlineable. |
3986 for (int i = 0, count = function->body()->length(); i < count; ++i) { | 3986 for (int i = 0, count = function->body()->length(); i < count; ++i) { |
3987 if (!function->body()->at(i)->IsInlineable()) return false; | 3987 if (!function->body()->at(i)->IsInlineable()) return false; |
3988 } | 3988 } |
3989 | 3989 |
3990 // Generate the deoptimization data for the unoptimized version of | 3990 // Generate the deoptimization data for the unoptimized version of |
3991 // the target function if we don't already have it. | 3991 // the target function if we don't already have it. |
(...skipping 1874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5866 } | 5866 } |
5867 } | 5867 } |
5868 | 5868 |
5869 #ifdef DEBUG | 5869 #ifdef DEBUG |
5870 if (graph_ != NULL) graph_->Verify(); | 5870 if (graph_ != NULL) graph_->Verify(); |
5871 if (allocator_ != NULL) allocator_->Verify(); | 5871 if (allocator_ != NULL) allocator_->Verify(); |
5872 #endif | 5872 #endif |
5873 } | 5873 } |
5874 | 5874 |
5875 } } // namespace v8::internal | 5875 } } // namespace v8::internal |
OLD | NEW |