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

Side by Side Diff: src/compiler.cc

Issue 2171083004: [interpreter] Implement OSR graph construction from bytecode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_interpreter-osr-2
Patch Set: Fix build on Windows. Created 4 years, 4 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 | src/compiler/bytecode-graph-builder.h » ('j') | 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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { 580 void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) {
581 Handle<Code> code = info->code(); 581 Handle<Code> code = info->code();
582 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do. 582 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do.
583 583
584 // Function context specialization folds-in the function context, 584 // Function context specialization folds-in the function context,
585 // so no sharing can occur. 585 // so no sharing can occur.
586 if (info->is_function_context_specializing()) return; 586 if (info->is_function_context_specializing()) return;
587 // Frame specialization implies function context specialization. 587 // Frame specialization implies function context specialization.
588 DCHECK(!info->is_frame_specializing()); 588 DCHECK(!info->is_frame_specializing());
589 589
590 // TODO(4764): When compiling for OSR from bytecode, BailoutId might derive
591 // from bytecode offset and overlap with actual BailoutId. No caching!
592 if (info->is_osr() && info->is_optimizing_from_bytecode()) return;
593
590 // Cache optimized context-specific code. 594 // Cache optimized context-specific code.
591 Handle<JSFunction> function = info->closure(); 595 Handle<JSFunction> function = info->closure();
592 Handle<SharedFunctionInfo> shared(function->shared()); 596 Handle<SharedFunctionInfo> shared(function->shared());
593 Handle<LiteralsArray> literals(function->literals()); 597 Handle<LiteralsArray> literals(function->literals());
594 Handle<Context> native_context(function->context()->native_context()); 598 Handle<Context> native_context(function->context()->native_context());
595 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, 599 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code,
596 literals, info->osr_ast_id()); 600 literals, info->osr_ast_id());
597 601
598 // Do not cache (native) context-independent code compiled for OSR. 602 // Do not cache (native) context-independent code compiled for OSR.
599 if (code->is_turbofanned() && info->is_osr()) return; 603 if (code->is_turbofanned() && info->is_osr()) return;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 return true; 744 return true;
741 } 745 }
742 746
743 MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function, 747 MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function,
744 Compiler::ConcurrencyMode mode, 748 Compiler::ConcurrencyMode mode,
745 BailoutId osr_ast_id = BailoutId::None(), 749 BailoutId osr_ast_id = BailoutId::None(),
746 JavaScriptFrame* osr_frame = nullptr) { 750 JavaScriptFrame* osr_frame = nullptr) {
747 Isolate* isolate = function->GetIsolate(); 751 Isolate* isolate = function->GetIsolate();
748 Handle<SharedFunctionInfo> shared(function->shared(), isolate); 752 Handle<SharedFunctionInfo> shared(function->shared(), isolate);
749 753
750 // TODO(4764): Remove this guard once OSR graph construction works. 754 bool ignition_osr = osr_frame && osr_frame->is_interpreted();
751 if (!osr_ast_id.IsNone() && osr_frame->is_interpreted()) { 755 DCHECK_IMPLIES(ignition_osr, !osr_ast_id.IsNone());
752 return MaybeHandle<Code>(); 756 DCHECK_IMPLIES(ignition_osr, FLAG_ignition_osr);
753 } 757
758 // Flag combination --ignition-osr --no-turbo-from-bytecode is unsupported.
759 if (ignition_osr && !FLAG_turbo_from_bytecode) return MaybeHandle<Code>();
754 760
755 Handle<Code> cached_code; 761 Handle<Code> cached_code;
756 if (GetCodeFromOptimizedCodeMap(function, osr_ast_id) 762 // TODO(4764): When compiling for OSR from bytecode, BailoutId might derive
763 // from bytecode offset and overlap with actual BailoutId. No lookup!
764 if (!ignition_osr &&
765 GetCodeFromOptimizedCodeMap(function, osr_ast_id)
757 .ToHandle(&cached_code)) { 766 .ToHandle(&cached_code)) {
758 if (FLAG_trace_opt) { 767 if (FLAG_trace_opt) {
759 PrintF("[found optimized code for "); 768 PrintF("[found optimized code for ");
760 function->ShortPrint(); 769 function->ShortPrint();
761 if (!osr_ast_id.IsNone()) { 770 if (!osr_ast_id.IsNone()) {
762 PrintF(" at OSR AST id %d", osr_ast_id.ToInt()); 771 PrintF(" at OSR AST id %d", osr_ast_id.ToInt());
763 } 772 }
764 PrintF("]\n"); 773 PrintF("]\n");
765 } 774 }
766 return cached_code; 775 return cached_code;
767 } 776 }
768 777
769 // Reset profiler ticks, function is no longer considered hot. 778 // Reset profiler ticks, function is no longer considered hot.
770 if (shared->is_compiled()) { 779 if (shared->is_compiled()) {
771 shared->code()->set_profiler_ticks(0); 780 shared->code()->set_profiler_ticks(0);
772 } 781 }
773 782
774 VMState<COMPILER> state(isolate); 783 VMState<COMPILER> state(isolate);
775 DCHECK(!isolate->has_pending_exception()); 784 DCHECK(!isolate->has_pending_exception());
776 PostponeInterruptsScope postpone(isolate); 785 PostponeInterruptsScope postpone(isolate);
777 bool use_turbofan = UseTurboFan(shared); 786 bool use_turbofan = UseTurboFan(shared) || ignition_osr;
778 std::unique_ptr<CompilationJob> job( 787 std::unique_ptr<CompilationJob> job(
779 use_turbofan ? compiler::Pipeline::NewCompilationJob(function) 788 use_turbofan ? compiler::Pipeline::NewCompilationJob(function)
780 : new HCompilationJob(function)); 789 : new HCompilationJob(function));
781 CompilationInfo* info = job->info(); 790 CompilationInfo* info = job->info();
782 ParseInfo* parse_info = info->parse_info(); 791 ParseInfo* parse_info = info->parse_info();
783 792
784 info->SetOptimizingForOsr(osr_ast_id, osr_frame); 793 info->SetOptimizingForOsr(osr_ast_id, osr_frame);
785 794
786 // Do not use Crankshaft/TurboFan if we need to be able to set break points. 795 // Do not use Crankshaft/TurboFan if we need to be able to set break points.
787 if (info->shared_info()->HasDebugInfo()) { 796 if (info->shared_info()->HasDebugInfo()) {
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 DCHECK(shared->is_compiled()); 1927 DCHECK(shared->is_compiled());
1919 function->set_literals(cached.literals); 1928 function->set_literals(cached.literals);
1920 } else if (shared->is_compiled()) { 1929 } else if (shared->is_compiled()) {
1921 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. 1930 // TODO(mvstanton): pass pretenure flag to EnsureLiterals.
1922 JSFunction::EnsureLiterals(function); 1931 JSFunction::EnsureLiterals(function);
1923 } 1932 }
1924 } 1933 }
1925 1934
1926 } // namespace internal 1935 } // namespace internal
1927 } // namespace v8 1936 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/bytecode-graph-builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698