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

Side by Side Diff: src/compiler.cc

Issue 22832002: Consistently use CompilationInfo::AbortOptimization. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 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
« no previous file with comments | « src/compiler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 bool CompilationInfo::ShouldSelfOptimize() { 224 bool CompilationInfo::ShouldSelfOptimize() {
225 return FLAG_self_optimization && 225 return FLAG_self_optimization &&
226 FLAG_crankshaft && 226 FLAG_crankshaft &&
227 !function()->flags()->Contains(kDontSelfOptimize) && 227 !function()->flags()->Contains(kDontSelfOptimize) &&
228 !function()->flags()->Contains(kDontOptimize) && 228 !function()->flags()->Contains(kDontOptimize) &&
229 function()->scope()->AllowsLazyCompilation() && 229 function()->scope()->AllowsLazyCompilation() &&
230 (shared_info().is_null() || !shared_info()->optimization_disabled()); 230 (shared_info().is_null() || !shared_info()->optimization_disabled());
231 } 231 }
232 232
233 233
234 void CompilationInfo::AbortOptimization() {
235 Handle<Code> code(shared_info()->code());
236 SetCode(code);
237 }
238
239
240 // Determine whether to use the full compiler for all code. If the flag 234 // Determine whether to use the full compiler for all code. If the flag
241 // --always-full-compiler is specified this is the case. For the virtual frame 235 // --always-full-compiler is specified this is the case. For the virtual frame
242 // based compiler the full compiler is also used if a debugger is connected, as 236 // based compiler the full compiler is also used if a debugger is connected, as
243 // the code from the full compiler supports mode precise break points. For the 237 // the code from the full compiler supports mode precise break points. For the
244 // crankshaft adaptive compiler debugging the optimized code is not possible at 238 // crankshaft adaptive compiler debugging the optimized code is not possible at
245 // all. However crankshaft support recompilation of functions, so in this case 239 // all. However crankshaft support recompilation of functions, so in this case
246 // the full compiler need not be be used if a debugger is attached, but only if 240 // the full compiler need not be be used if a debugger is attached, but only if
247 // break points has actually been set. 241 // break points has actually been set.
248 static bool IsDebuggerActive(Isolate* isolate) { 242 static bool IsDebuggerActive(Isolate* isolate) {
249 #ifdef ENABLE_DEBUGGER_SUPPORT 243 #ifdef ENABLE_DEBUGGER_SUPPORT
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 309 }
316 310
317 311
318 OptimizingCompiler::Status OptimizingCompiler::CreateGraph() { 312 OptimizingCompiler::Status OptimizingCompiler::CreateGraph() {
319 ASSERT(V8::UseCrankshaft()); 313 ASSERT(V8::UseCrankshaft());
320 ASSERT(info()->IsOptimizing()); 314 ASSERT(info()->IsOptimizing());
321 ASSERT(!info()->IsCompilingForDebugging()); 315 ASSERT(!info()->IsCompilingForDebugging());
322 316
323 // We should never arrive here if there is no code object on the 317 // We should never arrive here if there is no code object on the
324 // shared function object. 318 // shared function object.
325 Handle<Code> code(info()->shared_info()->code()); 319 ASSERT(info()->shared_info()->code()->kind() == Code::FUNCTION);
326 ASSERT(code->kind() == Code::FUNCTION);
327 320
328 // We should never arrive here if optimization has been disabled on the 321 // We should never arrive here if optimization has been disabled on the
329 // shared function info. 322 // shared function info.
330 ASSERT(!info()->shared_info()->optimization_disabled()); 323 ASSERT(!info()->shared_info()->optimization_disabled());
331 324
332 // Fall back to using the full code generator if it's not possible 325 // Fall back to using the full code generator if it's not possible
333 // to use the Hydrogen-based optimizing compiler. We already have 326 // to use the Hydrogen-based optimizing compiler. We already have
334 // generated code for this from the shared function object. 327 // generated code for this from the shared function object.
335 if (AlwaysFullCompiler(isolate())) { 328 if (AlwaysFullCompiler(isolate())) {
336 info()->SetCode(code); 329 info()->AbortOptimization();
337 return SetLastStatus(BAILED_OUT); 330 return SetLastStatus(BAILED_OUT);
338 } 331 }
339 332
340 // Limit the number of times we re-compile a functions with 333 // Limit the number of times we re-compile a functions with
341 // the optimizing compiler. 334 // the optimizing compiler.
342 const int kMaxOptCount = 335 const int kMaxOptCount =
343 FLAG_deopt_every_n_times == 0 ? FLAG_max_opt_count : 1000; 336 FLAG_deopt_every_n_times == 0 ? FLAG_max_opt_count : 1000;
344 if (info()->opt_count() > kMaxOptCount) { 337 if (info()->opt_count() > kMaxOptCount) {
345 info()->set_bailout_reason(kOptimizedTooManyTimes); 338 info()->set_bailout_reason(kOptimizedTooManyTimes);
346 return AbortOptimization(); 339 return AbortOptimization();
(...skipping 15 matching lines...) Expand all
362 355
363 const int locals_limit = LUnallocated::kMaxFixedSlotIndex; 356 const int locals_limit = LUnallocated::kMaxFixedSlotIndex;
364 if (!info()->osr_ast_id().IsNone() && 357 if (!info()->osr_ast_id().IsNone() &&
365 scope->num_parameters() + 1 + scope->num_stack_slots() > locals_limit) { 358 scope->num_parameters() + 1 + scope->num_stack_slots() > locals_limit) {
366 info()->set_bailout_reason(kTooManyParametersLocals); 359 info()->set_bailout_reason(kTooManyParametersLocals);
367 return AbortOptimization(); 360 return AbortOptimization();
368 } 361 }
369 362
370 // Take --hydrogen-filter into account. 363 // Take --hydrogen-filter into account.
371 if (!info()->closure()->PassesHydrogenFilter()) { 364 if (!info()->closure()->PassesHydrogenFilter()) {
372 info()->SetCode(code); 365 info()->AbortOptimization();
373 return SetLastStatus(BAILED_OUT); 366 return SetLastStatus(BAILED_OUT);
374 } 367 }
375 368
376 // Recompile the unoptimized version of the code if the current version 369 // Recompile the unoptimized version of the code if the current version
377 // doesn't have deoptimization support. Alternatively, we may decide to 370 // doesn't have deoptimization support. Alternatively, we may decide to
378 // run the full code generator to get a baseline for the compile-time 371 // run the full code generator to get a baseline for the compile-time
379 // performance of the hydrogen-based compiler. 372 // performance of the hydrogen-based compiler.
380 bool should_recompile = !info()->shared_info()->has_deoptimization_support(); 373 bool should_recompile = !info()->shared_info()->has_deoptimization_support();
381 if (should_recompile || FLAG_hydrogen_stats) { 374 if (should_recompile || FLAG_hydrogen_stats) {
382 int64_t start_ticks = 0; 375 int64_t start_ticks = 0;
383 if (FLAG_hydrogen_stats) { 376 if (FLAG_hydrogen_stats) {
(...skipping 19 matching lines...) Expand all
403 int64_t ticks = OS::Ticks() - start_ticks; 396 int64_t ticks = OS::Ticks() - start_ticks;
404 isolate()->GetHStatistics()->IncrementFullCodeGen(ticks); 397 isolate()->GetHStatistics()->IncrementFullCodeGen(ticks);
405 } 398 }
406 } 399 }
407 400
408 // Check that the unoptimized, shared code is ready for 401 // Check that the unoptimized, shared code is ready for
409 // optimizations. When using the always_opt flag we disregard the 402 // optimizations. When using the always_opt flag we disregard the
410 // optimizable marker in the code object and optimize anyway. This 403 // optimizable marker in the code object and optimize anyway. This
411 // is safe as long as the unoptimized code has deoptimization 404 // is safe as long as the unoptimized code has deoptimization
412 // support. 405 // support.
413 ASSERT(FLAG_always_opt || code->optimizable()); 406 ASSERT(FLAG_always_opt || info()->shared_info()->code()->optimizable());
414 ASSERT(info()->shared_info()->has_deoptimization_support()); 407 ASSERT(info()->shared_info()->has_deoptimization_support());
415 408
416 if (FLAG_trace_hydrogen) { 409 if (FLAG_trace_hydrogen) {
417 Handle<String> name = info()->function()->debug_name(); 410 Handle<String> name = info()->function()->debug_name();
418 PrintF("-----------------------------------------------------------\n"); 411 PrintF("-----------------------------------------------------------\n");
419 PrintF("Compiling method %s using hydrogen\n", *name->ToCString()); 412 PrintF("Compiling method %s using hydrogen\n", *name->ToCString());
420 isolate()->GetHTracer()->TraceCompilation(info()); 413 isolate()->GetHTracer()->TraceCompilation(info());
421 } 414 }
422 415
423 // Type-check the function. 416 // Type-check the function.
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 if (info->shared_info()->SearchOptimizedCodeMap( 1074 if (info->shared_info()->SearchOptimizedCodeMap(
1082 info->closure()->context()->native_context()) == -1) { 1075 info->closure()->context()->native_context()) == -1) {
1083 InsertCodeIntoOptimizedCodeMap(*info); 1076 InsertCodeIntoOptimizedCodeMap(*info);
1084 } 1077 }
1085 if (FLAG_trace_parallel_recompilation) { 1078 if (FLAG_trace_parallel_recompilation) {
1086 PrintF(" ** Optimized code for "); 1079 PrintF(" ** Optimized code for ");
1087 info->closure()->PrintName(); 1080 info->closure()->PrintName();
1088 PrintF(" installed.\n"); 1081 PrintF(" installed.\n");
1089 } 1082 }
1090 } else { 1083 } else {
1091 info->SetCode(Handle<Code>(info->shared_info()->code())); 1084 info->AbortOptimization();
1092 InstallFullCode(*info); 1085 InstallFullCode(*info);
1093 } 1086 }
1094 // Optimized code is finally replacing unoptimized code. Reset the latter's 1087 // Optimized code is finally replacing unoptimized code. Reset the latter's
1095 // profiler ticks to prevent too soon re-opt after a deopt. 1088 // profiler ticks to prevent too soon re-opt after a deopt.
1096 info->shared_info()->code()->set_profiler_ticks(0); 1089 info->shared_info()->code()->set_profiler_ticks(0);
1097 ASSERT(!info->closure()->IsMarkedForInstallingRecompiledCode()); 1090 ASSERT(!info->closure()->IsMarkedForInstallingRecompiledCode());
1098 } 1091 }
1099 1092
1100 1093
1101 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, 1094 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal,
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 // Trace if the appropriate trace flag is set and the phase name's first 1248 // Trace if the appropriate trace flag is set and the phase name's first
1256 // character is in the FLAG_trace_phase command line parameter. 1249 // character is in the FLAG_trace_phase command line parameter.
1257 bool tracing_on = info()->IsStub() ? 1250 bool tracing_on = info()->IsStub() ?
1258 FLAG_trace_hydrogen_stubs : 1251 FLAG_trace_hydrogen_stubs :
1259 FLAG_trace_hydrogen; 1252 FLAG_trace_hydrogen;
1260 return (tracing_on && 1253 return (tracing_on &&
1261 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); 1254 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL);
1262 } 1255 }
1263 1256
1264 } } // namespace v8::internal 1257 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698