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

Side by Side Diff: src/compiler.cc

Issue 9207002: Add a deoptimization count to each function to limit number of re-compilations. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 11 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
Jakob Kummerow 2012/01/16 11:41:25 nit: 2012
fschneider 2012/01/19 10:26:11 Done.
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
11 // with the distribution. 11 // with the distribution.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 #endif 135 #endif
136 } 136 }
137 137
138 138
139 static bool AlwaysFullCompiler() { 139 static bool AlwaysFullCompiler() {
140 return FLAG_always_full_compiler || is_debugging_active(); 140 return FLAG_always_full_compiler || is_debugging_active();
141 } 141 }
142 142
143 143
144 static void FinishOptimization(Handle<JSFunction> function, int64_t start) { 144 static void FinishOptimization(Handle<JSFunction> function, int64_t start) {
145 int opt_count = function->shared()->opt_count();
146 function->shared()->set_opt_count(opt_count + 1);
147 double ms = static_cast<double>(OS::Ticks() - start) / 1000; 145 double ms = static_cast<double>(OS::Ticks() - start) / 1000;
148 if (FLAG_trace_opt) { 146 if (FLAG_trace_opt) {
149 PrintF("[optimizing: "); 147 PrintF("[optimizing: ");
150 function->PrintName(); 148 function->PrintName();
151 PrintF(" / %" V8PRIxPTR, reinterpret_cast<intptr_t>(*function)); 149 PrintF(" / %" V8PRIxPTR, reinterpret_cast<intptr_t>(*function));
152 PrintF(" - took %0.3f ms]\n", ms); 150 PrintF(" - took %0.3f ms]\n", ms);
153 } 151 }
154 if (FLAG_trace_opt_stats) { 152 if (FLAG_trace_opt_stats) {
155 static double compilation_time = 0.0; 153 static double compilation_time = 0.0;
156 static int compiled_functions = 0; 154 static int compiled_functions = 0;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 ASSERT(!info->shared_info()->optimization_disabled()); 190 ASSERT(!info->shared_info()->optimization_disabled());
193 191
194 // Fall back to using the full code generator if it's not possible 192 // Fall back to using the full code generator if it's not possible
195 // to use the Hydrogen-based optimizing compiler. We already have 193 // to use the Hydrogen-based optimizing compiler. We already have
196 // generated code for this from the shared function object. 194 // generated code for this from the shared function object.
197 if (AlwaysFullCompiler() || !FLAG_use_hydrogen) { 195 if (AlwaysFullCompiler() || !FLAG_use_hydrogen) {
198 info->SetCode(code); 196 info->SetCode(code);
199 return true; 197 return true;
200 } 198 }
201 199
202 // Limit the number of times we re-compile a functions with
203 // the optimizing compiler.
204 const int kMaxOptCount =
205 FLAG_deopt_every_n_times == 0 ? Compiler::kDefaultMaxOptCount : 1000;
206 if (info->shared_info()->opt_count() > kMaxOptCount) {
207 info->AbortOptimization();
208 Handle<JSFunction> closure = info->closure();
209 info->shared_info()->DisableOptimization(*closure);
210 // True indicates the compilation pipeline is still going, not
211 // necessarily that we optimized the code.
212 return true;
213 }
214
215 // Due to an encoding limit on LUnallocated operands in the Lithium 200 // Due to an encoding limit on LUnallocated operands in the Lithium
216 // language, we cannot optimize functions with too many formal parameters 201 // language, we cannot optimize functions with too many formal parameters
217 // or perform on-stack replacement for function with too many 202 // or perform on-stack replacement for function with too many
218 // stack-allocated local variables. 203 // stack-allocated local variables.
219 // 204 //
220 // The encoding is as a signed value, with parameters and receiver using 205 // The encoding is as a signed value, with parameters and receiver using
221 // the negative indices and locals the non-negative ones. 206 // the negative indices and locals the non-negative ones.
222 const int parameter_limit = -LUnallocated::kMinFixedIndex; 207 const int parameter_limit = -LUnallocated::kMinFixedIndex;
223 const int locals_limit = LUnallocated::kMaxFixedIndex; 208 const int locals_limit = LUnallocated::kMaxFixedIndex;
224 Scope* scope = info->scope(); 209 Scope* scope = info->scope();
225 if ((scope->num_parameters() + 1) > parameter_limit || 210 if ((scope->num_parameters() + 1) > parameter_limit ||
226 (info->osr_ast_id() != AstNode::kNoNumber && 211 (info->osr_ast_id() != AstNode::kNoNumber &&
227 scope->num_parameters() + 1 + scope->num_stack_slots() > locals_limit)) { 212 scope->num_parameters() + 1 + scope->num_stack_slots() > locals_limit)) {
228 info->AbortOptimization(); 213 info->AbortOptimization();
229 Handle<JSFunction> closure = info->closure(); 214 info->shared_info()->DisableOptimization();
230 info->shared_info()->DisableOptimization(*closure);
231 // True indicates the compilation pipeline is still going, not 215 // True indicates the compilation pipeline is still going, not
232 // necessarily that we optimized the code. 216 // necessarily that we optimized the code.
233 return true; 217 return true;
234 } 218 }
235 219
236 // Take --hydrogen-filter into account. 220 // Take --hydrogen-filter into account.
237 Vector<const char> filter = CStrVector(FLAG_hydrogen_filter); 221 Vector<const char> filter = CStrVector(FLAG_hydrogen_filter);
238 Handle<String> name = info->function()->debug_name(); 222 Handle<String> name = info->function()->debug_name();
239 bool match = filter.is_empty() || name->IsEqualTo(filter); 223 bool match = filter.is_empty() || name->IsEqualTo(filter);
240 if (!match) { 224 if (!match) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 FinishOptimization(info->closure(), start); 282 FinishOptimization(info->closure(), start);
299 return true; 283 return true;
300 } 284 }
301 } 285 }
302 286
303 // Keep using the shared code. 287 // Keep using the shared code.
304 info->AbortOptimization(); 288 info->AbortOptimization();
305 if (!builder.inline_bailout()) { 289 if (!builder.inline_bailout()) {
306 // Mark the shared code as unoptimizable unless it was an inlined 290 // Mark the shared code as unoptimizable unless it was an inlined
307 // function that bailed out. 291 // function that bailed out.
308 Handle<JSFunction> closure = info->closure(); 292 info->shared_info()->DisableOptimization();
309 info->shared_info()->DisableOptimization(*closure);
310 } 293 }
311 // True indicates the compilation pipeline is still going, not necessarily 294 // True indicates the compilation pipeline is still going, not necessarily
312 // that we optimized the code. 295 // that we optimized the code.
313 return true; 296 return true;
314 } 297 }
315 298
316 299
317 static bool GenerateCode(CompilationInfo* info) { 300 static bool GenerateCode(CompilationInfo* info) {
318 return info->IsCompilingForDebugging() || !V8::UseCrankshaft() ? 301 return info->IsCompilingForDebugging() || !V8::UseCrankshaft() ?
319 FullCodeGenerator::MakeCode(info) : 302 FullCodeGenerator::MakeCode(info) :
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 } 769 }
787 } 770 }
788 771
789 GDBJIT(AddCode(Handle<String>(shared->DebugName()), 772 GDBJIT(AddCode(Handle<String>(shared->DebugName()),
790 Handle<Script>(info->script()), 773 Handle<Script>(info->script()),
791 Handle<Code>(info->code()), 774 Handle<Code>(info->code()),
792 info)); 775 info));
793 } 776 }
794 777
795 } } // namespace v8::internal 778 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698