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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_ = V8::UseCrankshaft() ? mode : NONOPT; |
| 123 abort_due_to_dependency_ = false; |
123 if (script_->type()->value() == Script::TYPE_NATIVE) { | 124 if (script_->type()->value() == Script::TYPE_NATIVE) { |
124 MarkAsNative(); | 125 MarkAsNative(); |
125 } | 126 } |
126 if (!shared_info_.is_null()) { | 127 if (!shared_info_.is_null()) { |
127 ASSERT(language_mode() == CLASSIC_MODE); | 128 ASSERT(language_mode() == CLASSIC_MODE); |
128 SetLanguageMode(shared_info_->language_mode()); | 129 SetLanguageMode(shared_info_->language_mode()); |
129 } | 130 } |
130 set_bailout_reason(kUnknown); | 131 set_bailout_reason(kUnknown); |
131 } | 132 } |
132 | 133 |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 ASSERT(!graph_builder_->inline_bailout() || graph_ == NULL); | 440 ASSERT(!graph_builder_->inline_bailout() || graph_ == NULL); |
440 if (graph_ == NULL) { | 441 if (graph_ == NULL) { |
441 if (graph_builder_->inline_bailout()) { | 442 if (graph_builder_->inline_bailout()) { |
442 info_->AbortOptimization(); | 443 info_->AbortOptimization(); |
443 return SetLastStatus(BAILED_OUT); | 444 return SetLastStatus(BAILED_OUT); |
444 } else { | 445 } else { |
445 return AbortOptimization(); | 446 return AbortOptimization(); |
446 } | 447 } |
447 } | 448 } |
448 | 449 |
| 450 if (info()->HasAbortedDueToDependencyChange()) { |
| 451 info_->set_bailout_reason(kBailedOutDueToDependencyChange); |
| 452 info_->AbortOptimization(); |
| 453 return SetLastStatus(BAILED_OUT); |
| 454 } |
| 455 |
449 return SetLastStatus(SUCCEEDED); | 456 return SetLastStatus(SUCCEEDED); |
450 } | 457 } |
451 | 458 |
452 | 459 |
453 OptimizingCompiler::Status OptimizingCompiler::OptimizeGraph() { | 460 OptimizingCompiler::Status OptimizingCompiler::OptimizeGraph() { |
454 DisallowHeapAllocation no_allocation; | 461 DisallowHeapAllocation no_allocation; |
455 DisallowHandleAllocation no_handles; | 462 DisallowHandleAllocation no_handles; |
456 DisallowHandleDereference no_deref; | 463 DisallowHandleDereference no_deref; |
| 464 DisallowCodeDependencyChange no_dependency_change; |
457 | 465 |
458 ASSERT(last_status() == SUCCEEDED); | 466 ASSERT(last_status() == SUCCEEDED); |
459 Timer t(this, &time_taken_to_optimize_); | 467 Timer t(this, &time_taken_to_optimize_); |
460 ASSERT(graph_ != NULL); | 468 ASSERT(graph_ != NULL); |
461 BailoutReason bailout_reason = kNoReason; | 469 BailoutReason bailout_reason = kNoReason; |
462 if (!graph_->Optimize(&bailout_reason)) { | 470 if (!graph_->Optimize(&bailout_reason)) { |
463 if (bailout_reason == kNoReason) graph_builder_->Bailout(bailout_reason); | 471 if (bailout_reason == kNoReason) graph_builder_->Bailout(bailout_reason); |
464 return SetLastStatus(BAILED_OUT); | 472 return SetLastStatus(BAILED_OUT); |
465 } else { | 473 } else { |
466 chunk_ = LChunk::NewChunk(graph_); | 474 chunk_ = LChunk::NewChunk(graph_); |
467 if (chunk_ == NULL) { | 475 if (chunk_ == NULL) { |
468 return SetLastStatus(BAILED_OUT); | 476 return SetLastStatus(BAILED_OUT); |
469 } | 477 } |
470 } | 478 } |
471 return SetLastStatus(SUCCEEDED); | 479 return SetLastStatus(SUCCEEDED); |
472 } | 480 } |
473 | 481 |
474 | 482 |
475 OptimizingCompiler::Status OptimizingCompiler::GenerateAndInstallCode() { | 483 OptimizingCompiler::Status OptimizingCompiler::GenerateAndInstallCode() { |
476 ASSERT(last_status() == SUCCEEDED); | 484 ASSERT(last_status() == SUCCEEDED); |
| 485 ASSERT(!info()->HasAbortedDueToDependencyChange()); |
| 486 DisallowCodeDependencyChange no_dependency_change; |
477 { // Scope for timer. | 487 { // Scope for timer. |
478 Timer timer(this, &time_taken_to_codegen_); | 488 Timer timer(this, &time_taken_to_codegen_); |
479 ASSERT(chunk_ != NULL); | 489 ASSERT(chunk_ != NULL); |
480 ASSERT(graph_ != NULL); | 490 ASSERT(graph_ != NULL); |
481 // Deferred handles reference objects that were accessible during | 491 // Deferred handles reference objects that were accessible during |
482 // graph creation. To make sure that we don't encounter inconsistencies | 492 // graph creation. To make sure that we don't encounter inconsistencies |
483 // between graph creation and code generation, we disallow accessing | 493 // between graph creation and code generation, we disallow accessing |
484 // objects through deferred handles during the latter, with exceptions. | 494 // objects through deferred handles during the latter, with exceptions. |
485 DisallowDeferredHandleDereference no_deferred_handle_deref; | 495 DisallowDeferredHandleDereference no_deferred_handle_deref; |
486 Handle<Code> optimized_code = chunk_->Codegen(); | 496 Handle<Code> optimized_code = chunk_->Codegen(); |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 | 818 |
809 | 819 |
810 static bool InstallFullCode(CompilationInfo* info) { | 820 static bool InstallFullCode(CompilationInfo* info) { |
811 // Update the shared function info with the compiled code and the | 821 // Update the shared function info with the compiled code and the |
812 // scope info. Please note, that the order of the shared function | 822 // scope info. Please note, that the order of the shared function |
813 // info initialization is important since set_scope_info might | 823 // info initialization is important since set_scope_info might |
814 // trigger a GC, causing the ASSERT below to be invalid if the code | 824 // trigger a GC, causing the ASSERT below to be invalid if the code |
815 // was flushed. By setting the code object last we avoid this. | 825 // was flushed. By setting the code object last we avoid this. |
816 Handle<SharedFunctionInfo> shared = info->shared_info(); | 826 Handle<SharedFunctionInfo> shared = info->shared_info(); |
817 Handle<Code> code = info->code(); | 827 Handle<Code> code = info->code(); |
| 828 CHECK(code->kind() == Code::FUNCTION); |
818 Handle<JSFunction> function = info->closure(); | 829 Handle<JSFunction> function = info->closure(); |
819 Handle<ScopeInfo> scope_info = | 830 Handle<ScopeInfo> scope_info = |
820 ScopeInfo::Create(info->scope(), info->zone()); | 831 ScopeInfo::Create(info->scope(), info->zone()); |
821 shared->set_scope_info(*scope_info); | 832 shared->set_scope_info(*scope_info); |
822 shared->ReplaceCode(*code); | 833 shared->ReplaceCode(*code); |
823 if (!function.is_null()) { | 834 if (!function.is_null()) { |
824 function->ReplaceCode(*code); | 835 function->ReplaceCode(*code); |
825 ASSERT(!function->IsOptimized()); | 836 ASSERT(!function->IsOptimized()); |
826 } | 837 } |
827 | 838 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 } | 1063 } |
1053 | 1064 |
1054 Isolate* isolate = info->isolate(); | 1065 Isolate* isolate = info->isolate(); |
1055 VMState<COMPILER> state(isolate); | 1066 VMState<COMPILER> state(isolate); |
1056 Logger::TimerEventScope timer( | 1067 Logger::TimerEventScope timer( |
1057 isolate, Logger::TimerEventScope::v8_recompile_synchronous); | 1068 isolate, Logger::TimerEventScope::v8_recompile_synchronous); |
1058 // If crankshaft succeeded, install the optimized code else install | 1069 // If crankshaft succeeded, install the optimized code else install |
1059 // the unoptimized code. | 1070 // the unoptimized code. |
1060 OptimizingCompiler::Status status = optimizing_compiler->last_status(); | 1071 OptimizingCompiler::Status status = optimizing_compiler->last_status(); |
1061 if (info->HasAbortedDueToDependencyChange()) { | 1072 if (info->HasAbortedDueToDependencyChange()) { |
1062 info->set_bailout_reason(kBailedOutDueToDependentMap); | 1073 info->set_bailout_reason(kBailedOutDueToDependencyChange); |
1063 status = optimizing_compiler->AbortOptimization(); | 1074 status = optimizing_compiler->AbortOptimization(); |
1064 } else if (status != OptimizingCompiler::SUCCEEDED) { | 1075 } else if (status != OptimizingCompiler::SUCCEEDED) { |
1065 info->set_bailout_reason(kFailedBailedOutLastTime); | 1076 info->set_bailout_reason(kFailedBailedOutLastTime); |
1066 status = optimizing_compiler->AbortOptimization(); | 1077 status = optimizing_compiler->AbortOptimization(); |
1067 } else if (isolate->DebuggerHasBreakPoints()) { | 1078 } else if (isolate->DebuggerHasBreakPoints()) { |
1068 info->set_bailout_reason(kDebuggerIsActive); | 1079 info->set_bailout_reason(kDebuggerIsActive); |
1069 status = optimizing_compiler->AbortOptimization(); | 1080 status = optimizing_compiler->AbortOptimization(); |
1070 } else { | 1081 } else { |
1071 status = optimizing_compiler->GenerateAndInstallCode(); | 1082 status = optimizing_compiler->GenerateAndInstallCode(); |
1072 ASSERT(status == OptimizingCompiler::SUCCEEDED || | 1083 ASSERT(status == OptimizingCompiler::SUCCEEDED || |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 // Trace if the appropriate trace flag is set and the phase name's first | 1266 // 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. | 1267 // character is in the FLAG_trace_phase command line parameter. |
1257 bool tracing_on = info()->IsStub() ? | 1268 bool tracing_on = info()->IsStub() ? |
1258 FLAG_trace_hydrogen_stubs : | 1269 FLAG_trace_hydrogen_stubs : |
1259 FLAG_trace_hydrogen; | 1270 FLAG_trace_hydrogen; |
1260 return (tracing_on && | 1271 return (tracing_on && |
1261 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1272 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
1262 } | 1273 } |
1263 | 1274 |
1264 } } // namespace v8::internal | 1275 } } // namespace v8::internal |
OLD | NEW |