Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: src/compiler.cc

Issue 2798293002: [turbofan] Allow to reuse OSR code objects. (Closed)
Patch Set: Address comment from Michi. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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>();
923 DCHECK(shared->HasBytecodeArray()); 915 DCHECK(shared->HasBytecodeArray());
924 info->MarkAsOptimizeFromBytecode(); 916 info->MarkAsOptimizeFromBytecode();
925 } 917 }
926 918
927 // Verify that OSR compilations are delegated to the correct graph builder. 919 // Verify that OSR compilations are delegated to the correct graph builder.
928 // Depending on the underlying frame the semantics of the {BailoutId} differ 920 // Depending on the underlying frame the semantics of the {BailoutId} differ
929 // and the various graph builders hard-code a certain semantic: 921 // and the various graph builders hard-code a certain semantic:
930 // - Interpreter : The BailoutId represents a bytecode offset. 922 // - Interpreter : The BailoutId represents a bytecode offset.
931 // - FullCodegen : The BailoutId represents the id of an AST node. 923 // - FullCodegen : The BailoutId represents the id of an AST node.
932 DCHECK_IMPLIES(info->is_osr() && ignition_osr, 924 DCHECK_IMPLIES(info->is_osr() && ignition_osr,
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 } 1884 }
1893 1885
1894 if (shared->is_compiled()) { 1886 if (shared->is_compiled()) {
1895 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. 1887 // TODO(mvstanton): pass pretenure flag to EnsureLiterals.
1896 JSFunction::EnsureLiterals(function); 1888 JSFunction::EnsureLiterals(function);
1897 } 1889 }
1898 } 1890 }
1899 1891
1900 } // namespace internal 1892 } // namespace internal
1901 } // namespace v8 1893 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698