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

Side by Side Diff: src/compiler.cc

Issue 2504153002: [TypeFeedbackVector] Root literal arrays in function literals slots (Closed)
Patch Set: REBASE. Created 3 years, 12 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/code-stubs.cc ('k') | src/compiler/ast-graph-builder.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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 // Record the function compilation event. 494 // Record the function compilation event.
495 RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, info); 495 RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, info);
496 496
497 return info->code(); 497 return info->code();
498 } 498 }
499 499
500 MUST_USE_RESULT MaybeHandle<Code> GetCodeFromOptimizedCodeMap( 500 MUST_USE_RESULT MaybeHandle<Code> GetCodeFromOptimizedCodeMap(
501 Handle<JSFunction> function, BailoutId osr_ast_id) { 501 Handle<JSFunction> function, BailoutId osr_ast_id) {
502 Handle<SharedFunctionInfo> shared(function->shared()); 502 Handle<SharedFunctionInfo> shared(function->shared());
503 DisallowHeapAllocation no_gc; 503 DisallowHeapAllocation no_gc;
504 CodeAndLiterals cached = shared->SearchOptimizedCodeMap( 504 Code* code = shared->SearchOptimizedCodeMap(
505 function->context()->native_context(), osr_ast_id); 505 function->context()->native_context(), osr_ast_id);
506 if (cached.code != nullptr) { 506 if (code != nullptr) {
507 // Caching of optimized code enabled and optimized code found. 507 // Caching of optimized code enabled and optimized code found.
508 if (cached.literals != nullptr) function->set_literals(cached.literals); 508 DCHECK(!code->marked_for_deoptimization());
509 DCHECK(!cached.code->marked_for_deoptimization());
510 DCHECK(function->shared()->is_compiled()); 509 DCHECK(function->shared()->is_compiled());
511 return Handle<Code>(cached.code); 510 return Handle<Code>(code);
512 } 511 }
513 return MaybeHandle<Code>(); 512 return MaybeHandle<Code>();
514 } 513 }
515 514
516 void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { 515 void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) {
517 Handle<Code> code = info->code(); 516 Handle<Code> code = info->code();
518 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do. 517 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do.
519 518
520 // Function context specialization folds-in the function context, 519 // Function context specialization folds-in the function context,
521 // so no sharing can occur. 520 // so no sharing can occur.
522 if (info->is_function_context_specializing()) return; 521 if (info->is_function_context_specializing()) return;
523 // Frame specialization implies function context specialization. 522 // Frame specialization implies function context specialization.
524 DCHECK(!info->is_frame_specializing()); 523 DCHECK(!info->is_frame_specializing());
525 524
526 // TODO(4764): When compiling for OSR from bytecode, BailoutId might derive 525 // TODO(4764): When compiling for OSR from bytecode, BailoutId might derive
527 // from bytecode offset and overlap with actual BailoutId. No caching! 526 // from bytecode offset and overlap with actual BailoutId. No caching!
528 if (info->is_osr() && info->is_optimizing_from_bytecode()) return; 527 if (info->is_osr() && info->is_optimizing_from_bytecode()) return;
529 528
530 // Cache optimized context-specific code. 529 // Cache optimized context-specific code.
531 Handle<JSFunction> function = info->closure(); 530 Handle<JSFunction> function = info->closure();
532 Handle<SharedFunctionInfo> shared(function->shared()); 531 Handle<SharedFunctionInfo> shared(function->shared());
533 Handle<LiteralsArray> literals(function->literals());
534 Handle<Context> native_context(function->context()->native_context()); 532 Handle<Context> native_context(function->context()->native_context());
535 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, 533 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code,
536 literals, info->osr_ast_id()); 534 info->osr_ast_id());
537 } 535 }
538 536
539 bool Renumber(ParseInfo* parse_info) { 537 bool Renumber(ParseInfo* parse_info) {
540 if (!AstNumbering::Renumber(parse_info->isolate(), parse_info->zone(), 538 if (!AstNumbering::Renumber(parse_info->isolate(), parse_info->zone(),
541 parse_info->literal())) { 539 parse_info->literal())) {
542 return false; 540 return false;
543 } 541 }
544 Handle<SharedFunctionInfo> shared_info = parse_info->shared_info(); 542 Handle<SharedFunctionInfo> shared_info = parse_info->shared_info();
545 if (!shared_info.is_null()) { 543 if (!shared_info.is_null()) {
546 FunctionLiteral* lit = parse_info->literal(); 544 FunctionLiteral* lit = parse_info->literal();
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 // 3) The code may have already been invalidated due to dependency change. 779 // 3) The code may have already been invalidated due to dependency change.
782 // 4) Code generation may have failed. 780 // 4) Code generation may have failed.
783 if (job->state() == CompilationJob::State::kReadyToFinalize) { 781 if (job->state() == CompilationJob::State::kReadyToFinalize) {
784 if (shared->optimization_disabled()) { 782 if (shared->optimization_disabled()) {
785 job->RetryOptimization(kOptimizationDisabled); 783 job->RetryOptimization(kOptimizationDisabled);
786 } else if (info->dependencies()->HasAborted()) { 784 } else if (info->dependencies()->HasAborted()) {
787 job->RetryOptimization(kBailedOutDueToDependencyChange); 785 job->RetryOptimization(kBailedOutDueToDependencyChange);
788 } else if (job->FinalizeJob() == CompilationJob::SUCCEEDED) { 786 } else if (job->FinalizeJob() == CompilationJob::SUCCEEDED) {
789 job->RecordOptimizedCompilationStats(); 787 job->RecordOptimizedCompilationStats();
790 RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, info); 788 RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, info);
791 if (shared 789 if (shared->SearchOptimizedCodeMap(info->context()->native_context(),
792 ->SearchOptimizedCodeMap(info->context()->native_context(), 790 info->osr_ast_id()) == nullptr) {
793 info->osr_ast_id())
794 .code == nullptr) {
795 InsertCodeIntoOptimizedCodeMap(info); 791 InsertCodeIntoOptimizedCodeMap(info);
796 } 792 }
797 if (FLAG_trace_opt) { 793 if (FLAG_trace_opt) {
798 PrintF("[completed optimizing "); 794 PrintF("[completed optimizing ");
799 info->closure()->ShortPrint(); 795 info->closure()->ShortPrint();
800 PrintF("]\n"); 796 PrintF("]\n");
801 } 797 }
802 info->closure()->ReplaceCode(*info->code()); 798 info->closure()->ReplaceCode(*info->code());
803 return CompilationJob::SUCCEEDED; 799 return CompilationJob::SUCCEEDED;
804 } 800 }
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 void Compiler::PostInstantiation(Handle<JSFunction> function, 1722 void Compiler::PostInstantiation(Handle<JSFunction> function,
1727 PretenureFlag pretenure) { 1723 PretenureFlag pretenure) {
1728 Handle<SharedFunctionInfo> shared(function->shared()); 1724 Handle<SharedFunctionInfo> shared(function->shared());
1729 1725
1730 if (FLAG_always_opt && shared->allows_lazy_compilation() && 1726 if (FLAG_always_opt && shared->allows_lazy_compilation() &&
1731 !function->shared()->HasAsmWasmData() && 1727 !function->shared()->HasAsmWasmData() &&
1732 function->shared()->is_compiled()) { 1728 function->shared()->is_compiled()) {
1733 function->MarkForOptimization(); 1729 function->MarkForOptimization();
1734 } 1730 }
1735 1731
1736 CodeAndLiterals cached = shared->SearchOptimizedCodeMap( 1732 Code* code = shared->SearchOptimizedCodeMap(
1737 function->context()->native_context(), BailoutId::None()); 1733 function->context()->native_context(), BailoutId::None());
1738 if (cached.code != nullptr) { 1734 if (code != nullptr) {
1739 // Caching of optimized code enabled and optimized code found. 1735 // Caching of optimized code enabled and optimized code found.
1740 DCHECK(!cached.code->marked_for_deoptimization()); 1736 DCHECK(!code->marked_for_deoptimization());
1741 DCHECK(function->shared()->is_compiled()); 1737 DCHECK(function->shared()->is_compiled());
1742 function->ReplaceCode(cached.code); 1738 function->ReplaceCode(code);
1743 } 1739 }
1744 1740
1745 if (cached.literals != nullptr) { 1741 if (shared->is_compiled()) {
1746 DCHECK(shared->is_compiled());
1747 function->set_literals(cached.literals);
1748 } else if (shared->is_compiled()) {
1749 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. 1742 // TODO(mvstanton): pass pretenure flag to EnsureLiterals.
1750 JSFunction::EnsureLiterals(function); 1743 JSFunction::EnsureLiterals(function);
1751 } 1744 }
1752 } 1745 }
1753 1746
1754 } // namespace internal 1747 } // namespace internal
1755 } // namespace v8 1748 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/compiler/ast-graph-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698