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

Side by Side Diff: src/compiler.cc

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

Powered by Google App Engine
This is Rietveld 408576698