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

Side by Side Diff: src/compiler.cc

Issue 254623002: Simplify feedback vector creation and store in SharedFunctionInfo. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Code comments Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « src/compiler.h ('k') | src/factory.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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 mode_ = mode; 134 mode_ = mode;
135 abort_due_to_dependency_ = false; 135 abort_due_to_dependency_ = false;
136 if (script_->type()->value() == Script::TYPE_NATIVE) { 136 if (script_->type()->value() == Script::TYPE_NATIVE) {
137 MarkAsNative(); 137 MarkAsNative();
138 } 138 }
139 if (!shared_info_.is_null()) { 139 if (!shared_info_.is_null()) {
140 ASSERT(strict_mode() == SLOPPY); 140 ASSERT(strict_mode() == SLOPPY);
141 SetStrictMode(shared_info_->strict_mode()); 141 SetStrictMode(shared_info_->strict_mode());
142 } 142 }
143 set_bailout_reason(kUnknown); 143 set_bailout_reason(kUnknown);
144
145 if (!shared_info().is_null() && shared_info()->is_compiled()) {
146 // We should initialize the CompilationInfo feedback vector from the
147 // passed in shared info, rather than creating a new one.
148 feedback_vector_ = Handle<FixedArray>(shared_info()->feedback_vector(),
149 isolate);
150 }
144 } 151 }
145 152
146 153
147 CompilationInfo::~CompilationInfo() { 154 CompilationInfo::~CompilationInfo() {
148 delete deferred_handles_; 155 delete deferred_handles_;
149 delete no_frame_ranges_; 156 delete no_frame_ranges_;
150 #ifdef DEBUG 157 #ifdef DEBUG
151 // Check that no dependent maps have been added or added dependent maps have 158 // Check that no dependent maps have been added or added dependent maps have
152 // been rolled back or committed. 159 // been rolled back or committed.
153 for (int i = 0; i < DependentCode::kGroupCount; i++) { 160 for (int i = 0; i < DependentCode::kGroupCount; i++) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 !function()->flags()->Contains(kDontSelfOptimize) && 249 !function()->flags()->Contains(kDontSelfOptimize) &&
243 !function()->dont_optimize() && 250 !function()->dont_optimize() &&
244 function()->scope()->AllowsLazyCompilation() && 251 function()->scope()->AllowsLazyCompilation() &&
245 (shared_info().is_null() || !shared_info()->optimization_disabled()); 252 (shared_info().is_null() || !shared_info()->optimization_disabled());
246 } 253 }
247 254
248 255
249 void CompilationInfo::PrepareForCompilation(Scope* scope) { 256 void CompilationInfo::PrepareForCompilation(Scope* scope) {
250 ASSERT(scope_ == NULL); 257 ASSERT(scope_ == NULL);
251 scope_ = scope; 258 scope_ = scope;
252 function()->ProcessFeedbackSlots(isolate_); 259
260 int length = function()->slot_count();
261 if (feedback_vector_.is_null()) {
262 // Allocate the feedback vector too.
263 feedback_vector_ = isolate()->factory()->NewTypeFeedbackVector(length);
264 }
265 ASSERT(feedback_vector_->length() == length);
253 } 266 }
254 267
255 268
256 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { 269 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder {
257 public: 270 public:
258 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) 271 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info)
259 : HOptimizedGraphBuilder(info) { 272 : HOptimizedGraphBuilder(info) {
260 } 273 }
261 274
262 #define DEF_VISIT(type) \ 275 #define DEF_VISIT(type) \
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 Handle<SharedFunctionInfo> shared = info->shared_info(); 577 Handle<SharedFunctionInfo> shared = info->shared_info();
565 Handle<ScopeInfo> scope_info = 578 Handle<ScopeInfo> scope_info =
566 ScopeInfo::Create(info->scope(), info->zone()); 579 ScopeInfo::Create(info->scope(), info->zone());
567 shared->set_scope_info(*scope_info); 580 shared->set_scope_info(*scope_info);
568 581
569 Handle<Code> code = info->code(); 582 Handle<Code> code = info->code();
570 CHECK(code->kind() == Code::FUNCTION); 583 CHECK(code->kind() == Code::FUNCTION);
571 shared->ReplaceCode(*code); 584 shared->ReplaceCode(*code);
572 if (shared->optimization_disabled()) code->set_optimizable(false); 585 if (shared->optimization_disabled()) code->set_optimizable(false);
573 586
587 shared->set_feedback_vector(*info->feedback_vector());
588
574 // Set the expected number of properties for instances. 589 // Set the expected number of properties for instances.
575 FunctionLiteral* lit = info->function(); 590 FunctionLiteral* lit = info->function();
576 int expected = lit->expected_property_count(); 591 int expected = lit->expected_property_count();
577 SetExpectedNofPropertiesFromEstimate(shared, expected); 592 SetExpectedNofPropertiesFromEstimate(shared, expected);
578 593
579 // Check the function has compiled code. 594 // Check the function has compiled code.
580 ASSERT(shared->is_compiled()); 595 ASSERT(shared->is_compiled());
581 shared->set_dont_optimize_reason(lit->dont_optimize_reason()); 596 shared->set_dont_optimize_reason(lit->dont_optimize_reason());
582 shared->set_dont_inline(lit->flags()->Contains(kDontInline)); 597 shared->set_dont_inline(lit->flags()->Contains(kDontInline));
583 shared->set_ast_node_count(lit->ast_node_count()); 598 shared->set_ast_node_count(lit->ast_node_count());
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 return Handle<SharedFunctionInfo>::null(); 837 return Handle<SharedFunctionInfo>::null();
823 } 838 }
824 839
825 // Allocate function. 840 // Allocate function.
826 ASSERT(!info->code().is_null()); 841 ASSERT(!info->code().is_null());
827 result = isolate->factory()->NewSharedFunctionInfo( 842 result = isolate->factory()->NewSharedFunctionInfo(
828 lit->name(), 843 lit->name(),
829 lit->materialized_literal_count(), 844 lit->materialized_literal_count(),
830 lit->is_generator(), 845 lit->is_generator(),
831 info->code(), 846 info->code(),
832 ScopeInfo::Create(info->scope(), info->zone())); 847 ScopeInfo::Create(info->scope(), info->zone()),
848 info->feedback_vector());
833 849
834 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); 850 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position());
835 SetFunctionInfo(result, lit, true, script); 851 SetFunctionInfo(result, lit, true, script);
836 852
837 Handle<String> script_name = script->name()->IsString() 853 Handle<String> script_name = script->name()->IsString()
838 ? Handle<String>(String::cast(script->name())) 854 ? Handle<String>(String::cast(script->name()))
839 : isolate->factory()->empty_string(); 855 : isolate->factory()->empty_string();
840 Logger::LogEventsAndTags log_tag = info->is_eval() 856 Logger::LogEventsAndTags log_tag = info->is_eval()
841 ? Logger::EVAL_TAG 857 ? Logger::EVAL_TAG
842 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script); 858 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 } else { 1036 } else {
1021 return Handle<SharedFunctionInfo>::null(); 1037 return Handle<SharedFunctionInfo>::null();
1022 } 1038 }
1023 1039
1024 // Create a shared function info object. 1040 // Create a shared function info object.
1025 Handle<SharedFunctionInfo> result = 1041 Handle<SharedFunctionInfo> result =
1026 factory->NewSharedFunctionInfo(literal->name(), 1042 factory->NewSharedFunctionInfo(literal->name(),
1027 literal->materialized_literal_count(), 1043 literal->materialized_literal_count(),
1028 literal->is_generator(), 1044 literal->is_generator(),
1029 info.code(), 1045 info.code(),
1030 scope_info); 1046 scope_info,
1047 info.feedback_vector());
1031 SetFunctionInfo(result, literal, false, script); 1048 SetFunctionInfo(result, literal, false, script);
1032 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); 1049 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result);
1033 result->set_allows_lazy_compilation(allow_lazy); 1050 result->set_allows_lazy_compilation(allow_lazy);
1034 result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx); 1051 result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx);
1035 1052
1036 // Set the expected number of properties for instances and return 1053 // Set the expected number of properties for instances and return
1037 // the resulting function. 1054 // the resulting function.
1038 SetExpectedNofPropertiesFromEstimate(result, 1055 SetExpectedNofPropertiesFromEstimate(result,
1039 literal->expected_property_count()); 1056 literal->expected_property_count());
1040 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone()); 1057 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone());
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 AllowHandleDereference allow_deref; 1319 AllowHandleDereference allow_deref;
1303 bool tracing_on = info()->IsStub() 1320 bool tracing_on = info()->IsStub()
1304 ? FLAG_trace_hydrogen_stubs 1321 ? FLAG_trace_hydrogen_stubs
1305 : (FLAG_trace_hydrogen && 1322 : (FLAG_trace_hydrogen &&
1306 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); 1323 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter));
1307 return (tracing_on && 1324 return (tracing_on &&
1308 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); 1325 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL);
1309 } 1326 }
1310 1327
1311 } } // namespace v8::internal 1328 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698