OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 7063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7074 int nodes_added = InliningAstSize(target); | 7074 int nodes_added = InliningAstSize(target); |
7075 if (nodes_added == kNotInlinable) return false; | 7075 if (nodes_added == kNotInlinable) return false; |
7076 | 7076 |
7077 Handle<JSFunction> caller = info()->closure(); | 7077 Handle<JSFunction> caller = info()->closure(); |
7078 | 7078 |
7079 if (nodes_added > Min(FLAG_max_inlined_nodes, kUnlimitedMaxInlinedNodes)) { | 7079 if (nodes_added > Min(FLAG_max_inlined_nodes, kUnlimitedMaxInlinedNodes)) { |
7080 TraceInline(target, caller, "target AST is too large [early]"); | 7080 TraceInline(target, caller, "target AST is too large [early]"); |
7081 return false; | 7081 return false; |
7082 } | 7082 } |
7083 | 7083 |
7084 Handle<SharedFunctionInfo> target_shared(target->shared()); | |
7085 | |
7086 #if !defined(V8_TARGET_ARCH_IA32) | 7084 #if !defined(V8_TARGET_ARCH_IA32) |
7087 // Target must be able to use caller's context. | 7085 // Target must be able to use caller's context. |
7088 CompilationInfo* outer_info = info(); | 7086 CompilationInfo* outer_info = info(); |
7089 if (target->context() != outer_info->closure()->context() || | 7087 if (target->context() != outer_info->closure()->context() || |
7090 outer_info->scope()->contains_with() || | 7088 outer_info->scope()->contains_with() || |
7091 outer_info->scope()->num_heap_slots() > 0) { | 7089 outer_info->scope()->num_heap_slots() > 0) { |
7092 TraceInline(target, caller, "target requires context change"); | 7090 TraceInline(target, caller, "target requires context change"); |
7093 return false; | 7091 return false; |
7094 } | 7092 } |
7095 #endif | 7093 #endif |
(...skipping 10 matching lines...) Expand all Loading... |
7106 if (env->outer()->frame_type() == JS_FUNCTION) { | 7104 if (env->outer()->frame_type() == JS_FUNCTION) { |
7107 current_level++; | 7105 current_level++; |
7108 } | 7106 } |
7109 env = env->outer(); | 7107 env = env->outer(); |
7110 } | 7108 } |
7111 | 7109 |
7112 // Don't inline recursive functions. | 7110 // Don't inline recursive functions. |
7113 for (FunctionState* state = function_state(); | 7111 for (FunctionState* state = function_state(); |
7114 state != NULL; | 7112 state != NULL; |
7115 state = state->outer()) { | 7113 state = state->outer()) { |
7116 if (state->compilation_info()->closure()->shared() == *target_shared) { | 7114 if (*state->compilation_info()->closure() == *target) { |
7117 TraceInline(target, caller, "target is recursive"); | 7115 TraceInline(target, caller, "target is recursive"); |
7118 return false; | 7116 return false; |
7119 } | 7117 } |
7120 } | 7118 } |
7121 | 7119 |
7122 // We don't want to add more than a certain number of nodes from inlining. | 7120 // We don't want to add more than a certain number of nodes from inlining. |
7123 if (inlined_count_ > Min(FLAG_max_inlined_nodes_cumulative, | 7121 if (inlined_count_ > Min(FLAG_max_inlined_nodes_cumulative, |
7124 kUnlimitedMaxInlinedNodesCumulative)) { | 7122 kUnlimitedMaxInlinedNodesCumulative)) { |
7125 TraceInline(target, caller, "cumulative AST node limit reached"); | 7123 TraceInline(target, caller, "cumulative AST node limit reached"); |
7126 return false; | 7124 return false; |
7127 } | 7125 } |
7128 | 7126 |
7129 // Parse and allocate variables. | 7127 // Parse and allocate variables. |
7130 CompilationInfo target_info(target, zone()); | 7128 CompilationInfo target_info(target, zone()); |
| 7129 Handle<SharedFunctionInfo> target_shared(target->shared()); |
7131 if (!ParserApi::Parse(&target_info, kNoParsingFlags) || | 7130 if (!ParserApi::Parse(&target_info, kNoParsingFlags) || |
7132 !Scope::Analyze(&target_info)) { | 7131 !Scope::Analyze(&target_info)) { |
7133 if (target_info.isolate()->has_pending_exception()) { | 7132 if (target_info.isolate()->has_pending_exception()) { |
7134 // Parse or scope error, never optimize this function. | 7133 // Parse or scope error, never optimize this function. |
7135 SetStackOverflow(); | 7134 SetStackOverflow(); |
7136 target_shared->DisableOptimization("parse/scope error"); | 7135 target_shared->DisableOptimization("parse/scope error"); |
7137 } | 7136 } |
7138 TraceInline(target, caller, "parse failure"); | 7137 TraceInline(target, caller, "parse failure"); |
7139 return false; | 7138 return false; |
7140 } | 7139 } |
(...skipping 3170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10311 } | 10310 } |
10312 } | 10311 } |
10313 | 10312 |
10314 #ifdef DEBUG | 10313 #ifdef DEBUG |
10315 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 10314 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
10316 if (allocator_ != NULL) allocator_->Verify(); | 10315 if (allocator_ != NULL) allocator_->Verify(); |
10317 #endif | 10316 #endif |
10318 } | 10317 } |
10319 | 10318 |
10320 } } // namespace v8::internal | 10319 } } // namespace v8::internal |
OLD | NEW |