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

Side by Side Diff: src/compiler.cc

Issue 2448933002: [compiler] Make SFI "optimize" flag a "tier up" flag (Closed)
Patch Set: Rebase Created 4 years, 1 month 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
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 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 Compiler::ConcurrencyMode mode, 627 Compiler::ConcurrencyMode mode,
628 BailoutId osr_ast_id = BailoutId::None(), 628 BailoutId osr_ast_id = BailoutId::None(),
629 JavaScriptFrame* osr_frame = nullptr) { 629 JavaScriptFrame* osr_frame = nullptr) {
630 Isolate* isolate = function->GetIsolate(); 630 Isolate* isolate = function->GetIsolate();
631 Handle<SharedFunctionInfo> shared(function->shared(), isolate); 631 Handle<SharedFunctionInfo> shared(function->shared(), isolate);
632 632
633 bool ignition_osr = osr_frame && osr_frame->is_interpreted(); 633 bool ignition_osr = osr_frame && osr_frame->is_interpreted();
634 DCHECK_IMPLIES(ignition_osr, !osr_ast_id.IsNone()); 634 DCHECK_IMPLIES(ignition_osr, !osr_ast_id.IsNone());
635 DCHECK_IMPLIES(ignition_osr, FLAG_ignition_osr); 635 DCHECK_IMPLIES(ignition_osr, FLAG_ignition_osr);
636 636
637 // Shared function no longer needs to be tiered up
638 shared->set_was_marked_for_tier_up(false);
639
637 // Flag combination --ignition-osr --no-turbo-from-bytecode is unsupported. 640 // Flag combination --ignition-osr --no-turbo-from-bytecode is unsupported.
638 if (ignition_osr && !FLAG_turbo_from_bytecode) return MaybeHandle<Code>(); 641 if (ignition_osr && !FLAG_turbo_from_bytecode) return MaybeHandle<Code>();
639 642
640 Handle<Code> cached_code; 643 Handle<Code> cached_code;
641 // TODO(4764): When compiling for OSR from bytecode, BailoutId might derive 644 // TODO(4764): When compiling for OSR from bytecode, BailoutId might derive
642 // from bytecode offset and overlap with actual BailoutId. No lookup! 645 // from bytecode offset and overlap with actual BailoutId. No lookup!
643 if (!ignition_osr && 646 if (!ignition_osr &&
644 GetCodeFromOptimizedCodeMap(function, osr_ast_id) 647 GetCodeFromOptimizedCodeMap(function, osr_ast_id)
645 .ToHandle(&cached_code)) { 648 .ToHandle(&cached_code)) {
646 if (FLAG_trace_opt) { 649 if (FLAG_trace_opt) {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 } 866 }
864 867
865 MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) { 868 MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) {
866 Isolate* isolate = function->GetIsolate(); 869 Isolate* isolate = function->GetIsolate();
867 VMState<COMPILER> state(isolate); 870 VMState<COMPILER> state(isolate);
868 PostponeInterruptsScope postpone(isolate); 871 PostponeInterruptsScope postpone(isolate);
869 Zone zone(isolate->allocator(), ZONE_NAME); 872 Zone zone(isolate->allocator(), ZONE_NAME);
870 ParseInfo parse_info(&zone, handle(function->shared())); 873 ParseInfo parse_info(&zone, handle(function->shared()));
871 CompilationInfo info(&parse_info, function); 874 CompilationInfo info(&parse_info, function);
872 875
876 // Function no longer needs to be tiered up
877 function->shared()->set_was_marked_for_tier_up(false);
878
873 // Reset profiler ticks, function is no longer considered hot. 879 // Reset profiler ticks, function is no longer considered hot.
874 if (function->shared()->HasBytecodeArray()) { 880 if (function->shared()->HasBytecodeArray()) {
875 function->shared()->set_profiler_ticks(0); 881 function->shared()->set_profiler_ticks(0);
876 } 882 }
877 883
878 // Nothing left to do if the function already has baseline code. 884 // Nothing left to do if the function already has baseline code.
879 if (function->shared()->code()->kind() == Code::FUNCTION) { 885 if (function->shared()->code()->kind() == Code::FUNCTION) {
880 return Handle<Code>(function->shared()->code()); 886 return Handle<Code>(function->shared()->code());
881 } 887 }
882 888
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 .ToHandle(&cached_code)) { 976 .ToHandle(&cached_code)) {
971 if (FLAG_trace_opt) { 977 if (FLAG_trace_opt) {
972 PrintF("[found optimized code for "); 978 PrintF("[found optimized code for ");
973 function->ShortPrint(); 979 function->ShortPrint();
974 PrintF(" during unoptimized compile]\n"); 980 PrintF(" during unoptimized compile]\n");
975 } 981 }
976 DCHECK(function->shared()->is_compiled()); 982 DCHECK(function->shared()->is_compiled());
977 return cached_code; 983 return cached_code;
978 } 984 }
979 985
980 if (function->shared()->was_marked_for_optimization()) { 986 if (function->shared()->was_marked_for_tier_up()) {
981 DCHECK(FLAG_optimize_shared_functions); 987 DCHECK(FLAG_tier_up_shared_functions);
988 DCHECK(function->shared()->is_compiled());
Michael Starzinger 2016/10/27 09:29:59 Can you elaborate why this DCHECK was added? I can
Michael Starzinger 2016/10/27 09:32:21 Actually, I think with code flushing this is not g
Leszek Swirski 2016/10/27 09:40:20 It's here because I put the default case as unreac
982 989
983 function->shared()->set_was_marked_for_optimization(false); 990 function->shared()->set_was_marked_for_tier_up(false);
984 991
985 if (FLAG_trace_opt) { 992 switch (Compiler::NextCompilationTier(*function)) {
986 PrintF("[optimizing function "); 993 case Compiler::BASELINE: {
987 function->PrintName(); 994 if (FLAG_trace_opt) {
988 PrintF(" eagerly because shared function was previously marked]\n"); 995 PrintF("[recompiling function ");
989 } 996 function->ShortPrint();
997 PrintF(
998 " to baseline eagerly (shared function marked for tier up)]\n");
999 }
990 1000
991 Handle<Code> opt_code; 1001 Handle<Code> code;
992 if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT) 1002 if (!GetBaselineCode(function).ToHandle(&code)) {
993 .ToHandle(&opt_code)) { 1003 return code;
994 return opt_code; 1004 }
1005 break;
1006 }
1007 case Compiler::OPTIMIZED: {
1008 if (FLAG_trace_opt) {
1009 PrintF("[optimizing method ");
1010 function->ShortPrint();
1011 PrintF(" eagerly (shared function marked for tier up)]\n");
1012 }
1013
1014 Handle<Code> code;
1015 // TODO(leszeks): Look into performing this compilation concurrently.
1016 if (!GetOptimizedCode(function, Compiler::NOT_CONCURRENT)
1017 .ToHandle(&code)) {
1018 return code;
1019 }
1020 break;
1021 }
1022 default:
1023 UNREACHABLE();
995 } 1024 }
996 } 1025 }
997 1026
998 if (function->shared()->is_compiled()) { 1027 if (function->shared()->is_compiled()) {
999 return Handle<Code>(function->shared()->code()); 1028 return Handle<Code>(function->shared()->code());
1000 } 1029 }
1001 1030
1002 if (function->shared()->HasBytecodeArray()) { 1031 if (function->shared()->HasBytecodeArray()) {
1003 Handle<Code> entry = isolate->builtins()->InterpreterEntryTrampoline(); 1032 Handle<Code> entry = isolate->builtins()->InterpreterEntryTrampoline();
1004 function->shared()->ReplaceCode(*entry); 1033 function->shared()->ReplaceCode(*entry);
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
1830 DCHECK(shared->is_compiled()); 1859 DCHECK(shared->is_compiled());
1831 function->set_literals(cached.literals); 1860 function->set_literals(cached.literals);
1832 } else if (shared->is_compiled()) { 1861 } else if (shared->is_compiled()) {
1833 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. 1862 // TODO(mvstanton): pass pretenure flag to EnsureLiterals.
1834 JSFunction::EnsureLiterals(function); 1863 JSFunction::EnsureLiterals(function);
1835 } 1864 }
1836 } 1865 }
1837 1866
1838 } // namespace internal 1867 } // namespace internal
1839 } // namespace v8 1868 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698