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

Side by Side Diff: src/compiler.cc

Issue 2626863004: Revert of [TypeFeedbackVector] Root literal arrays in function literals slots (Closed)
Patch Set: Created 3 years, 11 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 | « src/builtins/x64/builtins-x64.cc ('k') | src/compiler/js-create-lowering.cc » ('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 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 return info->code(); 590 return info->code();
591 } 591 }
592 592
593 MUST_USE_RESULT MaybeHandle<Code> GetCodeFromOptimizedCodeMap( 593 MUST_USE_RESULT MaybeHandle<Code> GetCodeFromOptimizedCodeMap(
594 Handle<JSFunction> function, BailoutId osr_ast_id) { 594 Handle<JSFunction> function, BailoutId osr_ast_id) {
595 RuntimeCallTimerScope runtimeTimer( 595 RuntimeCallTimerScope runtimeTimer(
596 function->GetIsolate(), 596 function->GetIsolate(),
597 &RuntimeCallStats::CompileGetFromOptimizedCodeMap); 597 &RuntimeCallStats::CompileGetFromOptimizedCodeMap);
598 Handle<SharedFunctionInfo> shared(function->shared()); 598 Handle<SharedFunctionInfo> shared(function->shared());
599 DisallowHeapAllocation no_gc; 599 DisallowHeapAllocation no_gc;
600 Code* code = shared->SearchOptimizedCodeMap( 600 CodeAndLiterals cached = shared->SearchOptimizedCodeMap(
601 function->context()->native_context(), osr_ast_id); 601 function->context()->native_context(), osr_ast_id);
602 if (code != nullptr) { 602 if (cached.code != nullptr) {
603 // Caching of optimized code enabled and optimized code found. 603 // Caching of optimized code enabled and optimized code found.
604 DCHECK(!code->marked_for_deoptimization()); 604 if (cached.literals != nullptr) function->set_literals(cached.literals);
605 DCHECK(!cached.code->marked_for_deoptimization());
605 DCHECK(function->shared()->is_compiled()); 606 DCHECK(function->shared()->is_compiled());
606 return Handle<Code>(code); 607 return Handle<Code>(cached.code);
607 } 608 }
608 return MaybeHandle<Code>(); 609 return MaybeHandle<Code>();
609 } 610 }
610 611
611 void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { 612 void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) {
612 Handle<Code> code = info->code(); 613 Handle<Code> code = info->code();
613 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do. 614 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do.
614 615
615 // Function context specialization folds-in the function context, 616 // Function context specialization folds-in the function context,
616 // so no sharing can occur. 617 // so no sharing can occur.
617 if (info->is_function_context_specializing()) return; 618 if (info->is_function_context_specializing()) return;
618 // Frame specialization implies function context specialization. 619 // Frame specialization implies function context specialization.
619 DCHECK(!info->is_frame_specializing()); 620 DCHECK(!info->is_frame_specializing());
620 621
621 // TODO(4764): When compiling for OSR from bytecode, BailoutId might derive 622 // TODO(4764): When compiling for OSR from bytecode, BailoutId might derive
622 // from bytecode offset and overlap with actual BailoutId. No caching! 623 // from bytecode offset and overlap with actual BailoutId. No caching!
623 if (info->is_osr() && info->is_optimizing_from_bytecode()) return; 624 if (info->is_osr() && info->is_optimizing_from_bytecode()) return;
624 625
625 // Cache optimized context-specific code. 626 // Cache optimized context-specific code.
626 Handle<JSFunction> function = info->closure(); 627 Handle<JSFunction> function = info->closure();
627 Handle<SharedFunctionInfo> shared(function->shared()); 628 Handle<SharedFunctionInfo> shared(function->shared());
629 Handle<LiteralsArray> literals(function->literals());
628 Handle<Context> native_context(function->context()->native_context()); 630 Handle<Context> native_context(function->context()->native_context());
629 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, 631 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code,
630 info->osr_ast_id()); 632 literals, info->osr_ast_id());
631 } 633 }
632 634
633 bool GetOptimizedCodeNow(CompilationJob* job) { 635 bool GetOptimizedCodeNow(CompilationJob* job) {
634 CompilationInfo* info = job->info(); 636 CompilationInfo* info = job->info();
635 Isolate* isolate = info->isolate(); 637 Isolate* isolate = info->isolate();
636 638
637 // Parsing is not required when optimizing from existing bytecode. 639 // Parsing is not required when optimizing from existing bytecode.
638 if (!info->is_optimizing_from_bytecode()) { 640 if (!info->is_optimizing_from_bytecode()) {
639 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; 641 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false;
640 EnsureFeedbackMetadata(info); 642 EnsureFeedbackMetadata(info);
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 // 3) The code may have already been invalidated due to dependency change. 858 // 3) The code may have already been invalidated due to dependency change.
857 // 4) Code generation may have failed. 859 // 4) Code generation may have failed.
858 if (job->state() == CompilationJob::State::kReadyToFinalize) { 860 if (job->state() == CompilationJob::State::kReadyToFinalize) {
859 if (shared->optimization_disabled()) { 861 if (shared->optimization_disabled()) {
860 job->RetryOptimization(kOptimizationDisabled); 862 job->RetryOptimization(kOptimizationDisabled);
861 } else if (info->dependencies()->HasAborted()) { 863 } else if (info->dependencies()->HasAborted()) {
862 job->RetryOptimization(kBailedOutDueToDependencyChange); 864 job->RetryOptimization(kBailedOutDueToDependencyChange);
863 } else if (job->FinalizeJob() == CompilationJob::SUCCEEDED) { 865 } else if (job->FinalizeJob() == CompilationJob::SUCCEEDED) {
864 job->RecordOptimizedCompilationStats(); 866 job->RecordOptimizedCompilationStats();
865 RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, info); 867 RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, info);
866 if (shared->SearchOptimizedCodeMap(info->context()->native_context(), 868 if (shared
867 info->osr_ast_id()) == nullptr) { 869 ->SearchOptimizedCodeMap(info->context()->native_context(),
870 info->osr_ast_id())
871 .code == nullptr) {
868 InsertCodeIntoOptimizedCodeMap(info); 872 InsertCodeIntoOptimizedCodeMap(info);
869 } 873 }
870 if (FLAG_trace_opt) { 874 if (FLAG_trace_opt) {
871 PrintF("[completed optimizing "); 875 PrintF("[completed optimizing ");
872 info->closure()->ShortPrint(); 876 info->closure()->ShortPrint();
873 PrintF("]\n"); 877 PrintF("]\n");
874 } 878 }
875 info->closure()->ReplaceCode(*info->code()); 879 info->closure()->ReplaceCode(*info->code());
876 return CompilationJob::SUCCEEDED; 880 return CompilationJob::SUCCEEDED;
877 } 881 }
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 void Compiler::PostInstantiation(Handle<JSFunction> function, 1749 void Compiler::PostInstantiation(Handle<JSFunction> function,
1746 PretenureFlag pretenure) { 1750 PretenureFlag pretenure) {
1747 Handle<SharedFunctionInfo> shared(function->shared()); 1751 Handle<SharedFunctionInfo> shared(function->shared());
1748 1752
1749 if (FLAG_always_opt && shared->allows_lazy_compilation() && 1753 if (FLAG_always_opt && shared->allows_lazy_compilation() &&
1750 !function->shared()->HasAsmWasmData() && 1754 !function->shared()->HasAsmWasmData() &&
1751 function->shared()->is_compiled()) { 1755 function->shared()->is_compiled()) {
1752 function->MarkForOptimization(); 1756 function->MarkForOptimization();
1753 } 1757 }
1754 1758
1755 Code* code = shared->SearchOptimizedCodeMap( 1759 CodeAndLiterals cached = shared->SearchOptimizedCodeMap(
1756 function->context()->native_context(), BailoutId::None()); 1760 function->context()->native_context(), BailoutId::None());
1757 if (code != nullptr) { 1761 if (cached.code != nullptr) {
1758 // Caching of optimized code enabled and optimized code found. 1762 // Caching of optimized code enabled and optimized code found.
1759 DCHECK(!code->marked_for_deoptimization()); 1763 DCHECK(!cached.code->marked_for_deoptimization());
1760 DCHECK(function->shared()->is_compiled()); 1764 DCHECK(function->shared()->is_compiled());
1761 function->ReplaceCode(code); 1765 function->ReplaceCode(cached.code);
1762 } 1766 }
1763 1767
1764 if (shared->is_compiled()) { 1768 if (cached.literals != nullptr) {
1769 DCHECK(shared->is_compiled());
1770 function->set_literals(cached.literals);
1771 } else if (shared->is_compiled()) {
1765 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. 1772 // TODO(mvstanton): pass pretenure flag to EnsureLiterals.
1766 JSFunction::EnsureLiterals(function); 1773 JSFunction::EnsureLiterals(function);
1767 } 1774 }
1768 } 1775 }
1769 1776
1770 } // namespace internal 1777 } // namespace internal
1771 } // namespace v8 1778 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/x64/builtins-x64.cc ('k') | src/compiler/js-create-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698