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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); | 112 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); |
113 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() | 113 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() |
114 ? new List<OffsetRange>(2) : NULL; | 114 ? new List<OffsetRange>(2) : NULL; |
115 for (int i = 0; i < DependentCode::kGroupCount; i++) { | 115 for (int i = 0; i < DependentCode::kGroupCount; i++) { |
116 dependencies_[i] = NULL; | 116 dependencies_[i] = NULL; |
117 } | 117 } |
118 if (mode == STUB) { | 118 if (mode == STUB) { |
119 mode_ = STUB; | 119 mode_ = STUB; |
120 return; | 120 return; |
121 } | 121 } |
122 mode_ = V8::UseCrankshaft() ? mode : NONOPT; | 122 mode_ = isolate->use_crankshaft() ? mode : NONOPT; |
123 abort_due_to_dependency_ = false; | 123 abort_due_to_dependency_ = false; |
124 if (script_->type()->value() == Script::TYPE_NATIVE) { | 124 if (script_->type()->value() == Script::TYPE_NATIVE) { |
125 MarkAsNative(); | 125 MarkAsNative(); |
126 } | 126 } |
127 if (!shared_info_.is_null()) { | 127 if (!shared_info_.is_null()) { |
128 ASSERT(language_mode() == CLASSIC_MODE); | 128 ASSERT(language_mode() == CLASSIC_MODE); |
129 SetLanguageMode(shared_info_->language_mode()); | 129 SetLanguageMode(shared_info_->language_mode()); |
130 } | 130 } |
131 set_bailout_reason(kUnknown); | 131 set_bailout_reason(kUnknown); |
132 } | 132 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 // Determine whether to use the full compiler for all code. If the flag | 235 // Determine whether to use the full compiler for all code. If the flag |
236 // --always-full-compiler is specified this is the case. For the virtual frame | 236 // --always-full-compiler is specified this is the case. For the virtual frame |
237 // based compiler the full compiler is also used if a debugger is connected, as | 237 // based compiler the full compiler is also used if a debugger is connected, as |
238 // the code from the full compiler supports mode precise break points. For the | 238 // the code from the full compiler supports mode precise break points. For the |
239 // crankshaft adaptive compiler debugging the optimized code is not possible at | 239 // crankshaft adaptive compiler debugging the optimized code is not possible at |
240 // all. However crankshaft support recompilation of functions, so in this case | 240 // all. However crankshaft support recompilation of functions, so in this case |
241 // the full compiler need not be be used if a debugger is attached, but only if | 241 // the full compiler need not be be used if a debugger is attached, but only if |
242 // break points has actually been set. | 242 // break points has actually been set. |
243 static bool IsDebuggerActive(Isolate* isolate) { | 243 static bool IsDebuggerActive(Isolate* isolate) { |
244 #ifdef ENABLE_DEBUGGER_SUPPORT | 244 #ifdef ENABLE_DEBUGGER_SUPPORT |
245 return V8::UseCrankshaft() ? | 245 return isolate->use_crankshaft() ? |
246 isolate->debug()->has_break_points() : | 246 isolate->debug()->has_break_points() : |
247 isolate->debugger()->IsDebuggerActive(); | 247 isolate->debugger()->IsDebuggerActive(); |
248 #else | 248 #else |
249 return false; | 249 return false; |
250 #endif | 250 #endif |
251 } | 251 } |
252 | 252 |
253 | 253 |
254 static bool AlwaysFullCompiler(Isolate* isolate) { | 254 static bool AlwaysFullCompiler(Isolate* isolate) { |
255 return FLAG_always_full_compiler || IsDebuggerActive(isolate); | 255 return FLAG_always_full_compiler || IsDebuggerActive(isolate); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 if (status != OptimizingCompiler::SUCCEEDED) { | 303 if (status != OptimizingCompiler::SUCCEEDED) { |
304 status = compiler.AbortOptimization(); | 304 status = compiler.AbortOptimization(); |
305 return status != OptimizingCompiler::FAILED; | 305 return status != OptimizingCompiler::FAILED; |
306 } | 306 } |
307 status = compiler.GenerateAndInstallCode(); | 307 status = compiler.GenerateAndInstallCode(); |
308 return status != OptimizingCompiler::FAILED; | 308 return status != OptimizingCompiler::FAILED; |
309 } | 309 } |
310 | 310 |
311 | 311 |
312 OptimizingCompiler::Status OptimizingCompiler::CreateGraph() { | 312 OptimizingCompiler::Status OptimizingCompiler::CreateGraph() { |
313 ASSERT(V8::UseCrankshaft()); | 313 ASSERT(isolate()->use_crankshaft()); |
314 ASSERT(info()->IsOptimizing()); | 314 ASSERT(info()->IsOptimizing()); |
315 ASSERT(!info()->IsCompilingForDebugging()); | 315 ASSERT(!info()->IsCompilingForDebugging()); |
316 | 316 |
317 // 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 |
318 // shared function object. | 318 // shared function object. |
319 ASSERT(info()->shared_info()->code()->kind() == Code::FUNCTION); | 319 ASSERT(info()->shared_info()->code()->kind() == Code::FUNCTION); |
320 | 320 |
321 // 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 |
322 // shared function info. | 322 // shared function info. |
323 ASSERT(!info()->shared_info()->optimization_disabled()); | 323 ASSERT(!info()->shared_info()->optimization_disabled()); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 return AbortOptimization(); | 492 return AbortOptimization(); |
493 } | 493 } |
494 info()->SetCode(optimized_code); | 494 info()->SetCode(optimized_code); |
495 } | 495 } |
496 RecordOptimizationStats(); | 496 RecordOptimizationStats(); |
497 return SetLastStatus(SUCCEEDED); | 497 return SetLastStatus(SUCCEEDED); |
498 } | 498 } |
499 | 499 |
500 | 500 |
501 static bool GenerateCode(CompilationInfo* info) { | 501 static bool GenerateCode(CompilationInfo* info) { |
502 bool is_optimizing = V8::UseCrankshaft() && | 502 bool is_optimizing = info->isolate()->use_crankshaft() && |
503 !info->IsCompilingForDebugging() && | 503 !info->IsCompilingForDebugging() && |
504 info->IsOptimizing(); | 504 info->IsOptimizing(); |
505 if (is_optimizing) { | 505 if (is_optimizing) { |
506 Logger::TimerEventScope timer( | 506 Logger::TimerEventScope timer( |
507 info->isolate(), Logger::TimerEventScope::v8_recompile_synchronous); | 507 info->isolate(), Logger::TimerEventScope::v8_recompile_synchronous); |
508 return MakeCrankshaftCode(info); | 508 return MakeCrankshaftCode(info); |
509 } else { | 509 } else { |
510 if (info->IsOptimizing()) { | 510 if (info->IsOptimizing()) { |
511 // Have the CompilationInfo decide if the compilation should be | 511 // Have the CompilationInfo decide if the compilation should be |
512 // BASE or NONOPT. | 512 // BASE or NONOPT. |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 FunctionLiteral* lit = info->function(); | 831 FunctionLiteral* lit = info->function(); |
832 int expected = lit->expected_property_count(); | 832 int expected = lit->expected_property_count(); |
833 SetExpectedNofPropertiesFromEstimate(shared, expected); | 833 SetExpectedNofPropertiesFromEstimate(shared, expected); |
834 | 834 |
835 // Check the function has compiled code. | 835 // Check the function has compiled code. |
836 ASSERT(shared->is_compiled()); | 836 ASSERT(shared->is_compiled()); |
837 shared->set_dont_optimize(lit->flags()->Contains(kDontOptimize)); | 837 shared->set_dont_optimize(lit->flags()->Contains(kDontOptimize)); |
838 shared->set_dont_inline(lit->flags()->Contains(kDontInline)); | 838 shared->set_dont_inline(lit->flags()->Contains(kDontInline)); |
839 shared->set_ast_node_count(lit->ast_node_count()); | 839 shared->set_ast_node_count(lit->ast_node_count()); |
840 | 840 |
841 if (V8::UseCrankshaft() && | 841 if (info->isolate()->use_crankshaft() && |
842 !function.is_null() && | 842 !function.is_null() && |
843 !shared->optimization_disabled()) { | 843 !shared->optimization_disabled()) { |
844 // If we're asked to always optimize, we compile the optimized | 844 // If we're asked to always optimize, we compile the optimized |
845 // version of the function right away - unless the debugger is | 845 // version of the function right away - unless the debugger is |
846 // active as it makes no sense to compile optimized code then. | 846 // active as it makes no sense to compile optimized code then. |
847 if (FLAG_always_opt && | 847 if (FLAG_always_opt && |
848 !Isolate::Current()->DebuggerHasBreakPoints()) { | 848 !Isolate::Current()->DebuggerHasBreakPoints()) { |
849 CompilationInfoWithZone optimized(function); | 849 CompilationInfoWithZone optimized(function); |
850 optimized.SetOptimizing(BailoutId::None()); | 850 optimized.SetOptimizing(BailoutId::None()); |
851 return Compiler::CompileLazy(&optimized); | 851 return Compiler::CompileLazy(&optimized); |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 AllowHandleDereference allow_deref; | 1256 AllowHandleDereference allow_deref; |
1257 bool tracing_on = info()->IsStub() | 1257 bool tracing_on = info()->IsStub() |
1258 ? FLAG_trace_hydrogen_stubs | 1258 ? FLAG_trace_hydrogen_stubs |
1259 : (FLAG_trace_hydrogen && | 1259 : (FLAG_trace_hydrogen && |
1260 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1260 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
1261 return (tracing_on && | 1261 return (tracing_on && |
1262 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1262 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
1263 } | 1263 } |
1264 | 1264 |
1265 } } // namespace v8::internal | 1265 } } // namespace v8::internal |
OLD | NEW |