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

Side by Side Diff: src/compiler.cc

Issue 1210523002: Make sure bound functions never make it into optimized code map. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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/objects.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 8
9 #include "src/ast-numbering.h" 9 #include "src/ast-numbering.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 shared->set_feedback_vector(*info->feedback_vector()); 683 shared->set_feedback_vector(*info->feedback_vector());
684 684
685 return info->code(); 685 return info->code();
686 } 686 }
687 687
688 688
689 MUST_USE_RESULT static MaybeHandle<Code> GetCodeFromOptimizedCodeMap( 689 MUST_USE_RESULT static MaybeHandle<Code> GetCodeFromOptimizedCodeMap(
690 Handle<JSFunction> function, BailoutId osr_ast_id) { 690 Handle<JSFunction> function, BailoutId osr_ast_id) {
691 if (FLAG_cache_optimized_code) { 691 if (FLAG_cache_optimized_code) {
692 Handle<SharedFunctionInfo> shared(function->shared()); 692 Handle<SharedFunctionInfo> shared(function->shared());
693 // Bound functions are not cached.
694 if (shared->bound()) return MaybeHandle<Code>();
695 DisallowHeapAllocation no_gc; 693 DisallowHeapAllocation no_gc;
696 int index = shared->SearchOptimizedCodeMap( 694 int index = shared->SearchOptimizedCodeMap(
697 function->context()->native_context(), osr_ast_id); 695 function->context()->native_context(), osr_ast_id);
698 if (index > 0) { 696 if (index > 0) {
699 if (FLAG_trace_opt) { 697 if (FLAG_trace_opt) {
700 PrintF("[found optimized code for "); 698 PrintF("[found optimized code for ");
701 function->ShortPrint(); 699 function->ShortPrint();
702 if (!osr_ast_id.IsNone()) { 700 if (!osr_ast_id.IsNone()) {
703 PrintF(" at OSR AST id %d", osr_ast_id.ToInt()); 701 PrintF(" at OSR AST id %d", osr_ast_id.ToInt());
704 } 702 }
(...skipping 11 matching lines...) Expand all
716 } 714 }
717 715
718 716
719 static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { 717 static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) {
720 Handle<Code> code = info->code(); 718 Handle<Code> code = info->code();
721 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do. 719 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do.
722 720
723 // Context specialization folds-in the context, so no sharing can occur. 721 // Context specialization folds-in the context, so no sharing can occur.
724 if (code->is_turbofanned() && info->is_context_specializing()) return; 722 if (code->is_turbofanned() && info->is_context_specializing()) return;
725 723
724 // Do not cache bound functions.
725 if (info->closure()->shared()->bound()) return;
726
726 // Cache optimized code. 727 // Cache optimized code.
727 if (FLAG_cache_optimized_code) { 728 if (FLAG_cache_optimized_code) {
728 Handle<JSFunction> function = info->closure(); 729 Handle<JSFunction> function = info->closure();
729 Handle<SharedFunctionInfo> shared(function->shared()); 730 Handle<SharedFunctionInfo> shared(function->shared());
730 // Do not cache bound functions.
731 if (shared->bound()) return;
732 Handle<FixedArray> literals(function->literals()); 731 Handle<FixedArray> literals(function->literals());
733 Handle<Context> native_context(function->context()->native_context()); 732 Handle<Context> native_context(function->context()->native_context());
734 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, 733 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code,
735 literals, info->osr_ast_id()); 734 literals, info->osr_ast_id());
736 } 735 }
737 } 736 }
738 737
739 738
740 static bool Renumber(ParseInfo* parse_info) { 739 static bool Renumber(ParseInfo* parse_info) {
741 if (!AstNumbering::Renumber(parse_info->isolate(), parse_info->zone(), 740 if (!AstNumbering::Renumber(parse_info->isolate(), parse_info->zone(),
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 1567
1569 1568
1570 #if DEBUG 1569 #if DEBUG
1571 void CompilationInfo::PrintAstForTesting() { 1570 void CompilationInfo::PrintAstForTesting() {
1572 PrintF("--- Source from AST ---\n%s\n", 1571 PrintF("--- Source from AST ---\n%s\n",
1573 PrettyPrinter(isolate(), zone()).PrintProgram(function())); 1572 PrettyPrinter(isolate(), zone()).PrintProgram(function()));
1574 } 1573 }
1575 #endif 1574 #endif
1576 } // namespace internal 1575 } // namespace internal
1577 } // namespace v8 1576 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698