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 "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
391 if (FLAG_hydrogen_stats) { | 391 if (FLAG_hydrogen_stats) { |
392 isolate()->GetHStatistics()->IncrementFullCodeGen(timer.Elapsed()); | 392 isolate()->GetHStatistics()->IncrementFullCodeGen(timer.Elapsed()); |
393 } | 393 } |
394 } | 394 } |
395 | 395 |
396 DCHECK(info()->shared_info()->has_deoptimization_support()); | 396 DCHECK(info()->shared_info()->has_deoptimization_support()); |
397 | 397 |
398 // Check the whitelist for TurboFan. | 398 // Check the whitelist for TurboFan. |
399 if (info()->closure()->PassesFilter(FLAG_turbo_filter) && | 399 if (info()->closure()->PassesFilter(FLAG_turbo_filter) && |
400 // TODO(turbofan): Make try-catch work and remove this bailout. | 400 // TODO(turbofan): Make try-catch work and remove this bailout. |
401 info()->function()->dont_optimize_reason() != kTryCatchStatement && | 401 info()->function()->dont_optimize_reason() != kTryCatchStatement && |
Michael Starzinger
2014/09/18 19:12:34
Please move this blacklist together with the TODO'
titzer
2014/09/19 11:38:21
Done.
| |
402 info()->function()->dont_optimize_reason() != kTryFinallyStatement && | 402 info()->function()->dont_optimize_reason() != kTryFinallyStatement && |
403 // TODO(turbofan): Make ES6 for-of work and remove this bailout. | 403 // TODO(turbofan): Make ES6 for-of work and remove this bailout. |
404 info()->function()->dont_optimize_reason() != kForOfStatement && | 404 info()->function()->dont_optimize_reason() != kForOfStatement && |
405 // TODO(turbofan): Make OSR work and remove this bailout. | 405 // TODO(turbofan): Make OSR work and remove this bailout. |
406 !info()->is_osr()) { | 406 !info()->is_osr()) { |
407 compiler::Pipeline pipeline(info()); | 407 compiler::Pipeline pipeline(info()); |
408 pipeline.GenerateCode(); | 408 pipeline.GenerateCode(); |
409 if (!info()->code().is_null()) { | 409 if (!info()->code().is_null()) { |
410 if (FLAG_turbo_deoptimization) { | 410 if (FLAG_turbo_deoptimization) { |
411 info()->context()->native_context()->AddOptimizedCode(*info()->code()); | 411 info()->context()->native_context()->AddOptimizedCode(*info()->code()); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
616 function_info->set_allows_lazy_compilation_without_context( | 616 function_info->set_allows_lazy_compilation_without_context( |
617 lit->AllowsLazyCompilationWithoutContext()); | 617 lit->AllowsLazyCompilationWithoutContext()); |
618 function_info->set_strict_mode(lit->strict_mode()); | 618 function_info->set_strict_mode(lit->strict_mode()); |
619 function_info->set_uses_arguments(lit->scope()->arguments() != NULL); | 619 function_info->set_uses_arguments(lit->scope()->arguments() != NULL); |
620 function_info->set_has_duplicate_parameters(lit->has_duplicate_parameters()); | 620 function_info->set_has_duplicate_parameters(lit->has_duplicate_parameters()); |
621 function_info->set_ast_node_count(lit->ast_node_count()); | 621 function_info->set_ast_node_count(lit->ast_node_count()); |
622 function_info->set_is_function(lit->is_function()); | 622 function_info->set_is_function(lit->is_function()); |
623 function_info->set_bailout_reason(lit->dont_optimize_reason()); | 623 function_info->set_bailout_reason(lit->dont_optimize_reason()); |
624 function_info->set_dont_cache(lit->flags()->Contains(kDontCache)); | 624 function_info->set_dont_cache(lit->flags()->Contains(kDontCache)); |
625 function_info->set_kind(lit->kind()); | 625 function_info->set_kind(lit->kind()); |
626 function_info->set_asm_function(lit->scope()->asm_function()); | |
626 } | 627 } |
627 | 628 |
628 | 629 |
629 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, | 630 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
630 CompilationInfo* info, | 631 CompilationInfo* info, |
631 Handle<SharedFunctionInfo> shared) { | 632 Handle<SharedFunctionInfo> shared) { |
632 // SharedFunctionInfo is passed separately, because if CompilationInfo | 633 // SharedFunctionInfo is passed separately, because if CompilationInfo |
633 // was created using Script object, it will not have it. | 634 // was created using Script object, it will not have it. |
634 | 635 |
635 // Log the code generation. If source information is available include | 636 // Log the code generation. If source information is available include |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
722 ASSIGN_RETURN_ON_EXCEPTION(info.isolate(), result, | 723 ASSIGN_RETURN_ON_EXCEPTION(info.isolate(), result, |
723 GetUnoptimizedCodeCommon(&info), | 724 GetUnoptimizedCodeCommon(&info), |
724 Code); | 725 Code); |
725 return result; | 726 return result; |
726 } | 727 } |
727 | 728 |
728 | 729 |
729 MaybeHandle<Code> Compiler::GetLazyCode(Handle<JSFunction> function) { | 730 MaybeHandle<Code> Compiler::GetLazyCode(Handle<JSFunction> function) { |
730 DCHECK(!function->GetIsolate()->has_pending_exception()); | 731 DCHECK(!function->GetIsolate()->has_pending_exception()); |
731 DCHECK(!function->is_compiled()); | 732 DCHECK(!function->is_compiled()); |
733 | |
734 if (FLAG_turbo_asm && function->shared()->asm_function()) { | |
735 CompilationInfoWithZone info(function); | |
736 | |
737 VMState<COMPILER> state(info.isolate()); | |
738 PostponeInterruptsScope postpone(info.isolate()); | |
739 | |
740 if (FLAG_trace_opt) { | |
741 // TODO(titzer): record and report full stats here. | |
742 PrintF("[optimizing asm "); | |
743 function->ShortPrint(); | |
744 PrintF("]\n"); | |
745 } | |
746 | |
747 if (!Parser::Parse(&info)) return MaybeHandle<Code>(); | |
Michael Starzinger
2014/09/18 19:12:34
I don't particularly like this duplication, in fac
titzer
2014/09/19 11:38:21
Agreed. We need to factor out into a routine to pa
| |
748 if (!Rewriter::Rewrite(&info)) return MaybeHandle<Code>(); | |
749 if (!Scope::Analyze(&info)) return MaybeHandle<Code>(); | |
750 if (FLAG_turbo_deoptimization && !EnsureDeoptimizationSupport(&info)) { | |
751 return MaybeHandle<Code>(); | |
752 } | |
753 | |
754 info.SetOptimizing(BailoutId::None(), | |
755 Handle<Code>(function->shared()->code())); | |
756 | |
757 info.MarkAsContextSpecializing(); | |
758 info.MarkAsTypingEnabled(); | |
759 info.MarkAsInliningDisabled(); | |
760 compiler::Pipeline pipeline(&info); | |
761 pipeline.GenerateCode(); | |
762 if (!info.code().is_null()) return info.code(); | |
763 } | |
764 | |
732 if (function->shared()->is_compiled()) { | 765 if (function->shared()->is_compiled()) { |
733 return Handle<Code>(function->shared()->code()); | 766 return Handle<Code>(function->shared()->code()); |
734 } | 767 } |
735 | 768 |
736 CompilationInfoWithZone info(function); | 769 CompilationInfoWithZone info(function); |
737 Handle<Code> result; | 770 Handle<Code> result; |
738 ASSIGN_RETURN_ON_EXCEPTION(info.isolate(), result, | 771 ASSIGN_RETURN_ON_EXCEPTION(info.isolate(), result, |
739 GetUnoptimizedCodeCommon(&info), Code); | 772 GetUnoptimizedCodeCommon(&info), Code); |
740 | 773 |
741 if (FLAG_always_opt && | 774 if (FLAG_always_opt && |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1425 AllowHandleDereference allow_deref; | 1458 AllowHandleDereference allow_deref; |
1426 bool tracing_on = info()->IsStub() | 1459 bool tracing_on = info()->IsStub() |
1427 ? FLAG_trace_hydrogen_stubs | 1460 ? FLAG_trace_hydrogen_stubs |
1428 : (FLAG_trace_hydrogen && | 1461 : (FLAG_trace_hydrogen && |
1429 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1462 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
1430 return (tracing_on && | 1463 return (tracing_on && |
1431 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1464 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
1432 } | 1465 } |
1433 | 1466 |
1434 } } // namespace v8::internal | 1467 } } // namespace v8::internal |
OLD | NEW |