| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "v8.h" | 5 #include "v8.h" |
| 6 | 6 |
| 7 #include "compiler.h" | 7 #include "compiler.h" |
| 8 | 8 |
| 9 #include "bootstrapper.h" | 9 #include "bootstrapper.h" |
| 10 #include "codegen.h" | 10 #include "codegen.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 ? new List<OffsetRange>(2) : NULL; | 103 ? new List<OffsetRange>(2) : NULL; |
| 104 for (int i = 0; i < DependentCode::kGroupCount; i++) { | 104 for (int i = 0; i < DependentCode::kGroupCount; i++) { |
| 105 dependencies_[i] = NULL; | 105 dependencies_[i] = NULL; |
| 106 } | 106 } |
| 107 if (mode == STUB) { | 107 if (mode == STUB) { |
| 108 mode_ = STUB; | 108 mode_ = STUB; |
| 109 return; | 109 return; |
| 110 } | 110 } |
| 111 mode_ = mode; | 111 mode_ = mode; |
| 112 abort_due_to_dependency_ = false; | 112 abort_due_to_dependency_ = false; |
| 113 if (script_->type()->value() == Script::TYPE_NATIVE) { | 113 if (script_->type()->value() == Script::TYPE_NATIVE) MarkAsNative(); |
| 114 MarkAsNative(); | 114 if (isolate_->debugger()->is_active()) MarkAsDebug(); |
| 115 } | 115 |
| 116 if (!shared_info_.is_null()) { | 116 if (!shared_info_.is_null()) { |
| 117 ASSERT(strict_mode() == SLOPPY); | 117 ASSERT(strict_mode() == SLOPPY); |
| 118 SetStrictMode(shared_info_->strict_mode()); | 118 SetStrictMode(shared_info_->strict_mode()); |
| 119 } | 119 } |
| 120 set_bailout_reason(kUnknown); | 120 set_bailout_reason(kUnknown); |
| 121 | 121 |
| 122 if (!shared_info().is_null() && shared_info()->is_compiled()) { | 122 if (!shared_info().is_null() && shared_info()->is_compiled()) { |
| 123 // We should initialize the CompilationInfo feedback vector from the | 123 // We should initialize the CompilationInfo feedback vector from the |
| 124 // passed in shared info, rather than creating a new one. | 124 // passed in shared info, rather than creating a new one. |
| 125 feedback_vector_ = Handle<FixedArray>(shared_info()->feedback_vector(), | 125 feedback_vector_ = Handle<FixedArray>(shared_info()->feedback_vector(), |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 #define DEF_VISIT(type) \ | 272 #define DEF_VISIT(type) \ |
| 273 virtual void Visit##type(type* node) V8_OVERRIDE { \ | 273 virtual void Visit##type(type* node) V8_OVERRIDE { \ |
| 274 HOptimizedGraphBuilder::Visit##type(node); \ | 274 HOptimizedGraphBuilder::Visit##type(node); \ |
| 275 } | 275 } |
| 276 MODULE_NODE_LIST(DEF_VISIT) | 276 MODULE_NODE_LIST(DEF_VISIT) |
| 277 DECLARATION_NODE_LIST(DEF_VISIT) | 277 DECLARATION_NODE_LIST(DEF_VISIT) |
| 278 #undef DEF_VISIT | 278 #undef DEF_VISIT |
| 279 }; | 279 }; |
| 280 | 280 |
| 281 | 281 |
| 282 // Determine whether to use the full compiler for all code. If the flag | |
| 283 // --always-full-compiler is specified this is the case. For the virtual frame | |
| 284 // based compiler the full compiler is also used if a debugger is connected, as | |
| 285 // the code from the full compiler supports mode precise break points. For the | |
| 286 // crankshaft adaptive compiler debugging the optimized code is not possible at | |
| 287 // all. However crankshaft support recompilation of functions, so in this case | |
| 288 // the full compiler need not be be used if a debugger is attached, but only if | |
| 289 // break points has actually been set. | |
| 290 static bool IsDebuggerActive(Isolate* isolate) { | |
| 291 return isolate->use_crankshaft() ? | |
| 292 isolate->debug()->has_break_points() : | |
| 293 isolate->debugger()->IsDebuggerActive(); | |
| 294 } | |
| 295 | |
| 296 | |
| 297 OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() { | 282 OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() { |
| 298 ASSERT(isolate()->use_crankshaft()); | 283 ASSERT(isolate()->use_crankshaft()); |
| 299 ASSERT(info()->IsOptimizing()); | 284 ASSERT(info()->IsOptimizing()); |
| 300 ASSERT(!info()->IsCompilingForDebugging()); | 285 ASSERT(!info()->IsCompilingForDebugging()); |
| 301 | 286 |
| 302 // We should never arrive here if there is no code object on the | 287 // We should never arrive here if there is no code object on the |
| 303 // shared function object. | 288 // shared function object. |
| 304 ASSERT(info()->shared_info()->code()->kind() == Code::FUNCTION); | 289 ASSERT(info()->shared_info()->code()->kind() == Code::FUNCTION); |
| 305 | 290 |
| 306 // We should never arrive here if optimization has been disabled on the | 291 // We should never arrive here if optimization has been disabled on the |
| 307 // shared function info. | 292 // shared function info. |
| 308 ASSERT(!info()->shared_info()->optimization_disabled()); | 293 ASSERT(!info()->shared_info()->optimization_disabled()); |
| 309 | 294 |
| 310 // Fall back to using the full code generator if it's not possible | 295 // Fall back to using the full code generator if it's not possible |
| 311 // to use the Hydrogen-based optimizing compiler. We already have | 296 // to use the Hydrogen-based optimizing compiler. We already have |
| 312 // generated code for this from the shared function object. | 297 // generated code for this from the shared function object. |
| 313 if (FLAG_always_full_compiler) return AbortOptimization(); | 298 if (FLAG_always_full_compiler) return AbortOptimization(); |
| 314 if (IsDebuggerActive(isolate())) return AbortOptimization(kDebuggerIsActive); | 299 |
| 300 // Do not use crankshaft if compiling for debugging. |
| 301 if (info()->is_debug()) return AbortOptimization(kDebuggerIsActive); |
| 315 | 302 |
| 316 // Limit the number of times we re-compile a functions with | 303 // Limit the number of times we re-compile a functions with |
| 317 // the optimizing compiler. | 304 // the optimizing compiler. |
| 318 const int kMaxOptCount = | 305 const int kMaxOptCount = |
| 319 FLAG_deopt_every_n_times == 0 ? FLAG_max_opt_count : 1000; | 306 FLAG_deopt_every_n_times == 0 ? FLAG_max_opt_count : 1000; |
| 320 if (info()->opt_count() > kMaxOptCount) { | 307 if (info()->opt_count() > kMaxOptCount) { |
| 321 return AbortAndDisableOptimization(kOptimizedTooManyTimes); | 308 return AbortAndDisableOptimization(kOptimizedTooManyTimes); |
| 322 } | 309 } |
| 323 | 310 |
| 324 // Due to an encoding limit on LUnallocated operands in the Lithium | 311 // Due to an encoding limit on LUnallocated operands in the Lithium |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 // the same flags as the previous version, that is flags which can change | 691 // the same flags as the previous version, that is flags which can change |
| 705 // the code generated. The current method of mapping from already compiled | 692 // the code generated. The current method of mapping from already compiled |
| 706 // full code without debug break slots to full code with debug break slots | 693 // full code without debug break slots to full code with debug break slots |
| 707 // depends on the generated code is otherwise exactly the same. | 694 // depends on the generated code is otherwise exactly the same. |
| 708 // If compilation fails, just keep the existing code. | 695 // If compilation fails, just keep the existing code. |
| 709 MaybeHandle<Code> Compiler::GetCodeForDebugging(Handle<JSFunction> function) { | 696 MaybeHandle<Code> Compiler::GetCodeForDebugging(Handle<JSFunction> function) { |
| 710 CompilationInfoWithZone info(function); | 697 CompilationInfoWithZone info(function); |
| 711 Isolate* isolate = info.isolate(); | 698 Isolate* isolate = info.isolate(); |
| 712 VMState<COMPILER> state(isolate); | 699 VMState<COMPILER> state(isolate); |
| 713 | 700 |
| 701 info.MarkAsDebug(); |
| 702 |
| 714 ASSERT(!isolate->has_pending_exception()); | 703 ASSERT(!isolate->has_pending_exception()); |
| 715 Handle<Code> old_code(function->shared()->code()); | 704 Handle<Code> old_code(function->shared()->code()); |
| 716 ASSERT(old_code->kind() == Code::FUNCTION); | 705 ASSERT(old_code->kind() == Code::FUNCTION); |
| 717 ASSERT(!old_code->has_debug_break_slots()); | 706 ASSERT(!old_code->has_debug_break_slots()); |
| 718 | 707 |
| 719 info.MarkCompilingForDebugging(); | 708 info.MarkCompilingForDebugging(); |
| 720 if (old_code->is_compiled_optimizable()) { | 709 if (old_code->is_compiled_optimizable()) { |
| 721 info.EnableDeoptimizationSupport(); | 710 info.EnableDeoptimizationSupport(); |
| 722 } else { | 711 } else { |
| 723 info.MarkNonOptimizable(); | 712 info.MarkNonOptimizable(); |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1296 AllowHandleDereference allow_deref; | 1285 AllowHandleDereference allow_deref; |
| 1297 bool tracing_on = info()->IsStub() | 1286 bool tracing_on = info()->IsStub() |
| 1298 ? FLAG_trace_hydrogen_stubs | 1287 ? FLAG_trace_hydrogen_stubs |
| 1299 : (FLAG_trace_hydrogen && | 1288 : (FLAG_trace_hydrogen && |
| 1300 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1289 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
| 1301 return (tracing_on && | 1290 return (tracing_on && |
| 1302 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1291 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
| 1303 } | 1292 } |
| 1304 | 1293 |
| 1305 } } // namespace v8::internal | 1294 } } // namespace v8::internal |
| OLD | NEW |