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 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/asmjs/asm-js.h" | 10 #include "src/asmjs/asm-js.h" |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
726 void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { | 726 void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { |
727 Handle<Code> code = info->code(); | 727 Handle<Code> code = info->code(); |
728 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do. | 728 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do. |
729 | 729 |
730 // Function context specialization folds-in the function context, | 730 // Function context specialization folds-in the function context, |
731 // so no sharing can occur. | 731 // so no sharing can occur. |
732 if (info->is_function_context_specializing()) return; | 732 if (info->is_function_context_specializing()) return; |
733 // Frame specialization implies function context specialization. | 733 // Frame specialization implies function context specialization. |
734 DCHECK(!info->is_frame_specializing()); | 734 DCHECK(!info->is_frame_specializing()); |
735 | 735 |
736 // TODO(4764): When compiling for OSR from bytecode, BailoutId might derive | |
737 // from bytecode offset and overlap with actual BailoutId. No caching! | |
738 if (info->is_osr() && info->is_optimizing_from_bytecode()) return; | |
739 | |
740 // Cache optimized context-specific code. | 736 // Cache optimized context-specific code. |
741 Handle<JSFunction> function = info->closure(); | 737 Handle<JSFunction> function = info->closure(); |
742 Handle<SharedFunctionInfo> shared(function->shared()); | 738 Handle<SharedFunctionInfo> shared(function->shared()); |
743 Handle<Context> native_context(function->context()->native_context()); | 739 Handle<Context> native_context(function->context()->native_context()); |
744 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, | 740 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
745 info->osr_ast_id()); | 741 info->osr_ast_id()); |
746 } | 742 } |
747 | 743 |
748 bool GetOptimizedCodeNow(CompilationJob* job) { | 744 bool GetOptimizedCodeNow(CompilationJob* job) { |
749 CompilationInfo* info = job->info(); | 745 CompilationInfo* info = job->info(); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
845 BailoutId osr_ast_id = BailoutId::None(), | 841 BailoutId osr_ast_id = BailoutId::None(), |
846 JavaScriptFrame* osr_frame = nullptr) { | 842 JavaScriptFrame* osr_frame = nullptr) { |
847 Isolate* isolate = function->GetIsolate(); | 843 Isolate* isolate = function->GetIsolate(); |
848 Handle<SharedFunctionInfo> shared(function->shared(), isolate); | 844 Handle<SharedFunctionInfo> shared(function->shared(), isolate); |
849 | 845 |
850 bool ignition_osr = osr_frame && osr_frame->is_interpreted(); | 846 bool ignition_osr = osr_frame && osr_frame->is_interpreted(); |
851 DCHECK_IMPLIES(ignition_osr, !osr_ast_id.IsNone()); | 847 DCHECK_IMPLIES(ignition_osr, !osr_ast_id.IsNone()); |
852 DCHECK_IMPLIES(ignition_osr, FLAG_ignition_osr); | 848 DCHECK_IMPLIES(ignition_osr, FLAG_ignition_osr); |
853 | 849 |
854 Handle<Code> cached_code; | 850 Handle<Code> cached_code; |
855 // TODO(4764): When compiling for OSR from bytecode, BailoutId might derive | 851 if (GetCodeFromOptimizedCodeMap(function, osr_ast_id) |
856 // from bytecode offset and overlap with actual BailoutId. No lookup! | |
857 if (!ignition_osr && | |
858 GetCodeFromOptimizedCodeMap(function, osr_ast_id) | |
859 .ToHandle(&cached_code)) { | 852 .ToHandle(&cached_code)) { |
860 if (FLAG_trace_opt) { | 853 if (FLAG_trace_opt) { |
861 PrintF("[found optimized code for "); | 854 PrintF("[found optimized code for "); |
862 function->ShortPrint(); | 855 function->ShortPrint(); |
863 if (!osr_ast_id.IsNone()) { | 856 if (!osr_ast_id.IsNone()) { |
864 PrintF(" at OSR AST id %d", osr_ast_id.ToInt()); | 857 PrintF(" at OSR AST id %d", osr_ast_id.ToInt()); |
865 } | 858 } |
866 PrintF("]\n"); | 859 PrintF("]\n"); |
867 } | 860 } |
868 return cached_code; | 861 return cached_code; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
912 info->AbortOptimization(kDeoptimizedTooManyTimes); | 905 info->AbortOptimization(kDeoptimizedTooManyTimes); |
913 return MaybeHandle<Code>(); | 906 return MaybeHandle<Code>(); |
914 } | 907 } |
915 | 908 |
916 TimerEventScope<TimerEventOptimizeCode> optimize_code_timer(isolate); | 909 TimerEventScope<TimerEventOptimizeCode> optimize_code_timer(isolate); |
917 RuntimeCallTimerScope runtimeTimer(isolate, &RuntimeCallStats::OptimizeCode); | 910 RuntimeCallTimerScope runtimeTimer(isolate, &RuntimeCallStats::OptimizeCode); |
918 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.OptimizeCode"); | 911 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.OptimizeCode"); |
919 | 912 |
920 // TurboFan can optimize directly from existing bytecode. | 913 // TurboFan can optimize directly from existing bytecode. |
921 if (use_turbofan && ShouldUseIgnition(info)) { | 914 if (use_turbofan && ShouldUseIgnition(info)) { |
922 if (info->is_osr() && !ignition_osr) return MaybeHandle<Code>(); | 915 if (info->is_osr() && !ignition_osr) return MaybeHandle<Code>(); |
Michael Starzinger
2017/04/06 08:09:42
Now that --ignition-staging is no more, and the as
Benedikt Meurer
2017/04/06 10:34:55
Done.
| |
923 DCHECK(shared->HasBytecodeArray()); | 916 DCHECK(shared->HasBytecodeArray()); |
924 info->MarkAsOptimizeFromBytecode(); | 917 info->MarkAsOptimizeFromBytecode(); |
925 } | 918 } |
926 | 919 |
927 // Verify that OSR compilations are delegated to the correct graph builder. | 920 // Verify that OSR compilations are delegated to the correct graph builder. |
928 // Depending on the underlying frame the semantics of the {BailoutId} differ | 921 // Depending on the underlying frame the semantics of the {BailoutId} differ |
929 // and the various graph builders hard-code a certain semantic: | 922 // and the various graph builders hard-code a certain semantic: |
930 // - Interpreter : The BailoutId represents a bytecode offset. | 923 // - Interpreter : The BailoutId represents a bytecode offset. |
931 // - FullCodegen : The BailoutId represents the id of an AST node. | 924 // - FullCodegen : The BailoutId represents the id of an AST node. |
932 DCHECK_IMPLIES(info->is_osr() && ignition_osr, | 925 DCHECK_IMPLIES(info->is_osr() && ignition_osr, |
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1892 } | 1885 } |
1893 | 1886 |
1894 if (shared->is_compiled()) { | 1887 if (shared->is_compiled()) { |
1895 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 1888 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. |
1896 JSFunction::EnsureLiterals(function); | 1889 JSFunction::EnsureLiterals(function); |
1897 } | 1890 } |
1898 } | 1891 } |
1899 | 1892 |
1900 } // namespace internal | 1893 } // namespace internal |
1901 } // namespace v8 | 1894 } // namespace v8 |
OLD | NEW |