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_map_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(kBailedOutDueToDependentMap); | |
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 DisallowMapInvalidation no_map_invalidation; | |
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 DisallowMapInvalidation no_map_invalidation; | |
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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
943 } | 953 } |
944 } else { | 954 } else { |
945 InstallCodeCommon(info); | 955 InstallCodeCommon(info); |
946 | 956 |
947 if (info->IsOptimizing()) { | 957 if (info->IsOptimizing()) { |
948 Handle<Code> code = info->code(); | 958 Handle<Code> code = info->code(); |
949 ASSERT(shared->scope_info() != ScopeInfo::Empty(isolate)); | 959 ASSERT(shared->scope_info() != ScopeInfo::Empty(isolate)); |
950 info->closure()->ReplaceCode(*code); | 960 info->closure()->ReplaceCode(*code); |
951 InsertCodeIntoOptimizedCodeMap(info); | 961 InsertCodeIntoOptimizedCodeMap(info); |
952 return true; | 962 return true; |
953 } else { | 963 } else { |
titzer
2013/08/12 13:28:58
We need to info->AbortOptimization() here if the m
Yang
2013/08/12 13:49:22
Since I introduced a new field, we don't have to d
| |
954 return InstallFullCode(info); | 964 return InstallFullCode(info); |
955 } | 965 } |
956 } | 966 } |
957 } | 967 } |
958 | 968 |
959 ASSERT(info->code().is_null()); | 969 ASSERT(info->code().is_null()); |
960 return false; | 970 return false; |
961 } | 971 } |
962 | 972 |
963 | 973 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1003 | 1013 |
1004 if (Rewriter::Rewrite(*info) && Scope::Analyze(*info)) { | 1014 if (Rewriter::Rewrite(*info) && Scope::Analyze(*info)) { |
1005 OptimizingCompiler* compiler = | 1015 OptimizingCompiler* compiler = |
1006 new(info->zone()) OptimizingCompiler(*info); | 1016 new(info->zone()) OptimizingCompiler(*info); |
1007 OptimizingCompiler::Status status = compiler->CreateGraph(); | 1017 OptimizingCompiler::Status status = compiler->CreateGraph(); |
1008 if (status == OptimizingCompiler::SUCCEEDED) { | 1018 if (status == OptimizingCompiler::SUCCEEDED) { |
1009 info.Detach(); | 1019 info.Detach(); |
1010 shared->code()->set_profiler_ticks(0); | 1020 shared->code()->set_profiler_ticks(0); |
1011 isolate->optimizing_compiler_thread()->QueueForOptimization(compiler); | 1021 isolate->optimizing_compiler_thread()->QueueForOptimization(compiler); |
1012 } else if (status == OptimizingCompiler::BAILED_OUT) { | 1022 } else if (status == OptimizingCompiler::BAILED_OUT) { |
1013 isolate->clear_pending_exception(); | 1023 isolate->clear_pending_exception(); |
titzer
2013/08/12 13:28:58
I think we need a info->AbortOptimization() here.
| |
1014 InstallFullCode(*info); | 1024 InstallFullCode(*info); |
1015 } | 1025 } |
1016 } | 1026 } |
1017 } | 1027 } |
1018 } | 1028 } |
1019 | 1029 |
1020 if (shared->code()->back_edges_patched_for_osr()) { | 1030 if (shared->code()->back_edges_patched_for_osr()) { |
1021 // At this point we either put the function on recompilation queue or | 1031 // At this point we either put the function on recompilation queue or |
1022 // aborted optimization. In either case we want to continue executing | 1032 // aborted optimization. In either case we want to continue executing |
1023 // the unoptimized code without running into OSR. If the unoptimized | 1033 // the unoptimized code without running into OSR. If the unoptimized |
(...skipping 231 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 | 1265 // 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. | 1266 // character is in the FLAG_trace_phase command line parameter. |
1257 bool tracing_on = info()->IsStub() ? | 1267 bool tracing_on = info()->IsStub() ? |
1258 FLAG_trace_hydrogen_stubs : | 1268 FLAG_trace_hydrogen_stubs : |
1259 FLAG_trace_hydrogen; | 1269 FLAG_trace_hydrogen; |
1260 return (tracing_on && | 1270 return (tracing_on && |
1261 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1271 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
1262 } | 1272 } |
1263 | 1273 |
1264 } } // namespace v8::internal | 1274 } } // namespace v8::internal |
OLD | NEW |