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/compiler.h" | 5 #include "src/compiler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "src/ast/ast-numbering.h" | 9 #include "src/ast/ast-numbering.h" |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 Logger::LogEventsAndTags log_tag = Logger::ToNativeByScript(tag, *script); | 783 Logger::LogEventsAndTags log_tag = Logger::ToNativeByScript(tag, *script); |
784 PROFILE(info->isolate(), | 784 PROFILE(info->isolate(), |
785 CodeCreateEvent(log_tag, *abstract_code, *shared, info, script_name, | 785 CodeCreateEvent(log_tag, *abstract_code, *shared, info, script_name, |
786 line_num, column_num)); | 786 line_num, column_num)); |
787 } | 787 } |
788 } | 788 } |
789 | 789 |
790 bool CompileUnoptimizedCode(CompilationInfo* info) { | 790 bool CompileUnoptimizedCode(CompilationInfo* info) { |
791 DCHECK(AllowCompilation::IsAllowed(info->isolate())); | 791 DCHECK(AllowCompilation::IsAllowed(info->isolate())); |
792 if (!Compiler::Analyze(info->parse_info()) || | 792 if (!Compiler::Analyze(info->parse_info()) || |
793 !FullCodeGenerator::MakeCode(info)) { | 793 !(info->EnsureFeedbackVector(), FullCodeGenerator::MakeCode(info))) { |
794 Isolate* isolate = info->isolate(); | 794 Isolate* isolate = info->isolate(); |
795 if (!isolate->has_pending_exception()) isolate->StackOverflow(); | 795 if (!isolate->has_pending_exception()) isolate->StackOverflow(); |
796 return false; | 796 return false; |
797 } | 797 } |
798 return true; | 798 return true; |
799 } | 799 } |
800 | 800 |
801 bool UseIgnition(CompilationInfo* info) { | 801 bool UseIgnition(CompilationInfo* info) { |
802 // TODO(4681): Generator functions are not yet supported. | 802 // TODO(4681): Generator functions are not yet supported. |
803 if ((info->has_shared_info() && info->shared_info()->is_generator()) || | 803 if ((info->has_shared_info() && info->shared_info()->is_generator()) || |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 size += code->CodeSize(); | 836 size += code->CodeSize(); |
837 size += code->relocation_info()->Size(); | 837 size += code->relocation_info()->Size(); |
838 size += code->deoptimization_data()->Size(); | 838 size += code->deoptimization_data()->Size(); |
839 size += code->handler_table()->Size(); | 839 size += code->handler_table()->Size(); |
840 } | 840 } |
841 return size; | 841 return size; |
842 } | 842 } |
843 | 843 |
844 bool GenerateBaselineCode(CompilationInfo* info) { | 844 bool GenerateBaselineCode(CompilationInfo* info) { |
845 bool success; | 845 bool success; |
| 846 info->EnsureFeedbackVector(); |
846 if (FLAG_ignition && UseIgnition(info)) { | 847 if (FLAG_ignition && UseIgnition(info)) { |
847 success = interpreter::Interpreter::MakeBytecode(info); | 848 success = interpreter::Interpreter::MakeBytecode(info); |
848 } else { | 849 } else { |
849 success = FullCodeGenerator::MakeCode(info); | 850 success = FullCodeGenerator::MakeCode(info); |
850 } | 851 } |
851 if (success) { | 852 if (success) { |
852 Isolate* isolate = info->isolate(); | 853 Isolate* isolate = info->isolate(); |
853 Counters* counters = isolate->counters(); | 854 Counters* counters = isolate->counters(); |
854 counters->total_baseline_code_size()->Increment(CodeAndMetadataSize(info)); | 855 counters->total_baseline_code_size()->Increment(CodeAndMetadataSize(info)); |
855 counters->total_baseline_compile_count()->Increment(1); | 856 counters->total_baseline_compile_count()->Increment(1); |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1451 parse_info->set_scope(info->scope()); | 1452 parse_info->set_scope(info->scope()); |
1452 parse_info->set_context(info->context()); | 1453 parse_info->set_context(info->context()); |
1453 unoptimized.EnableDeoptimizationSupport(); | 1454 unoptimized.EnableDeoptimizationSupport(); |
1454 // If the current code has reloc info for serialization, also include | 1455 // If the current code has reloc info for serialization, also include |
1455 // reloc info for serialization for the new code, so that deopt support | 1456 // reloc info for serialization for the new code, so that deopt support |
1456 // can be added without losing IC state. | 1457 // can be added without losing IC state. |
1457 if (shared->code()->kind() == Code::FUNCTION && | 1458 if (shared->code()->kind() == Code::FUNCTION && |
1458 shared->code()->has_reloc_info_for_serialization()) { | 1459 shared->code()->has_reloc_info_for_serialization()) { |
1459 unoptimized.PrepareForSerializing(); | 1460 unoptimized.PrepareForSerializing(); |
1460 } | 1461 } |
| 1462 unoptimized.EnsureFeedbackVector(); |
1461 if (!FullCodeGenerator::MakeCode(&unoptimized)) return false; | 1463 if (!FullCodeGenerator::MakeCode(&unoptimized)) return false; |
1462 | 1464 |
1463 shared->EnableDeoptimizationSupport(*unoptimized.code()); | 1465 shared->EnableDeoptimizationSupport(*unoptimized.code()); |
1464 shared->set_feedback_vector(*unoptimized.feedback_vector()); | 1466 shared->set_feedback_vector(*unoptimized.feedback_vector()); |
1465 | 1467 |
1466 info->MarkAsCompiled(); | 1468 info->MarkAsCompiled(); |
1467 | 1469 |
1468 // The scope info might not have been set if a lazily compiled | 1470 // The scope info might not have been set if a lazily compiled |
1469 // function is inlined before being called for the first time. | 1471 // function is inlined before being called for the first time. |
1470 if (shared->scope_info() == ScopeInfo::Empty(info->isolate())) { | 1472 if (shared->scope_info() == ScopeInfo::Empty(info->isolate())) { |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1950 MaybeHandle<Code> code; | 1952 MaybeHandle<Code> code; |
1951 if (cached.code != nullptr) code = handle(cached.code); | 1953 if (cached.code != nullptr) code = handle(cached.code); |
1952 Handle<Context> native_context(function->context()->native_context()); | 1954 Handle<Context> native_context(function->context()->native_context()); |
1953 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, | 1955 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
1954 literals, BailoutId::None()); | 1956 literals, BailoutId::None()); |
1955 } | 1957 } |
1956 } | 1958 } |
1957 | 1959 |
1958 } // namespace internal | 1960 } // namespace internal |
1959 } // namespace v8 | 1961 } // namespace v8 |
OLD | NEW |