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

Side by Side Diff: src/compiler.cc

Issue 178463007: Moved type feedback vector to SharedFunctionInfo. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE Created 6 years, 9 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(language_mode() == CLASSIC_MODE); 140 ASSERT(language_mode() == CLASSIC_MODE);
141 SetLanguageMode(shared_info_->language_mode()); 141 SetLanguageMode(shared_info_->language_mode());
142 } 142 }
143 set_bailout_reason(kUnknown); 143 set_bailout_reason(kUnknown);
144
145 if (!shared_info().is_null()) {
146 FixedArray* info_feedback_vector = shared_info()->feedback_vector();
147 if (info_feedback_vector->length() > 0) {
148 // We should initialize the CompilationInfo feedback vector from the
149 // passed in shared info, rather than creating a new one.
150 feedback_vector_ = Handle<FixedArray>(info_feedback_vector, isolate);
151 }
152 }
144 } 153 }
145 154
146 155
147 CompilationInfo::~CompilationInfo() { 156 CompilationInfo::~CompilationInfo() {
148 delete deferred_handles_; 157 delete deferred_handles_;
149 delete no_frame_ranges_; 158 delete no_frame_ranges_;
150 #ifdef DEBUG 159 #ifdef DEBUG
151 // Check that no dependent maps have been added or added dependent maps have 160 // Check that no dependent maps have been added or added dependent maps have
152 // been rolled back or committed. 161 // been rolled back or committed.
153 for (int i = 0; i < DependentCode::kGroupCount; i++) { 162 for (int i = 0; i < DependentCode::kGroupCount; i++) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 !function()->dont_optimize() && 252 !function()->dont_optimize() &&
244 function()->scope()->AllowsLazyCompilation() && 253 function()->scope()->AllowsLazyCompilation() &&
245 (shared_info().is_null() || !shared_info()->optimization_disabled()); 254 (shared_info().is_null() || !shared_info()->optimization_disabled());
246 } 255 }
247 256
248 257
249 void CompilationInfo::PrepareForCompilation(Scope* scope) { 258 void CompilationInfo::PrepareForCompilation(Scope* scope) {
250 ASSERT(scope_ == NULL); 259 ASSERT(scope_ == NULL);
251 scope_ = scope; 260 scope_ = scope;
252 function()->ProcessFeedbackSlots(isolate_); 261 function()->ProcessFeedbackSlots(isolate_);
262 int length = function()->slot_count();
263 if (feedback_vector_.is_null()) {
264 // Allocate the feedback vector too.
265 feedback_vector_ = isolate()->factory()->NewFixedArray(length, TENURED);
266 // Ensure we can skip the write barrier
267 ASSERT_EQ(isolate()->heap()->uninitialized_symbol(),
268 *TypeFeedbackInfo::UninitializedSentinel(isolate()));
269 for (int i = 0; i < length; i++) {
270 feedback_vector_->set(i,
271 *TypeFeedbackInfo::UninitializedSentinel(isolate()),
272 SKIP_WRITE_BARRIER);
273 }
274 }
275 ASSERT(feedback_vector_->length() == length);
253 } 276 }
254 277
255 278
256 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { 279 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder {
257 public: 280 public:
258 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) 281 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info)
259 : HOptimizedGraphBuilder(info) { 282 : HOptimizedGraphBuilder(info) {
260 } 283 }
261 284
262 #define DEF_VISIT(type) \ 285 #define DEF_VISIT(type) \
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 Handle<SharedFunctionInfo> shared = info->shared_info(); 587 Handle<SharedFunctionInfo> shared = info->shared_info();
565 Handle<ScopeInfo> scope_info = 588 Handle<ScopeInfo> scope_info =
566 ScopeInfo::Create(info->scope(), info->zone()); 589 ScopeInfo::Create(info->scope(), info->zone());
567 shared->set_scope_info(*scope_info); 590 shared->set_scope_info(*scope_info);
568 591
569 Handle<Code> code = info->code(); 592 Handle<Code> code = info->code();
570 CHECK(code->kind() == Code::FUNCTION); 593 CHECK(code->kind() == Code::FUNCTION);
571 shared->ReplaceCode(*code); 594 shared->ReplaceCode(*code);
572 if (shared->optimization_disabled()) code->set_optimizable(false); 595 if (shared->optimization_disabled()) code->set_optimizable(false);
573 596
597 shared->set_feedback_vector(*info->feedback_vector());
598
574 // Set the expected number of properties for instances. 599 // Set the expected number of properties for instances.
575 FunctionLiteral* lit = info->function(); 600 FunctionLiteral* lit = info->function();
576 int expected = lit->expected_property_count(); 601 int expected = lit->expected_property_count();
577 SetExpectedNofPropertiesFromEstimate(shared, expected); 602 SetExpectedNofPropertiesFromEstimate(shared, expected);
578 603
579 // Check the function has compiled code. 604 // Check the function has compiled code.
580 ASSERT(shared->is_compiled()); 605 ASSERT(shared->is_compiled());
581 shared->set_dont_optimize_reason(lit->dont_optimize_reason()); 606 shared->set_dont_optimize_reason(lit->dont_optimize_reason());
582 shared->set_dont_inline(lit->flags()->Contains(kDontInline)); 607 shared->set_dont_inline(lit->flags()->Contains(kDontInline));
583 shared->set_ast_node_count(lit->ast_node_count()); 608 shared->set_ast_node_count(lit->ast_node_count());
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 return Handle<SharedFunctionInfo>::null(); 844 return Handle<SharedFunctionInfo>::null();
820 } 845 }
821 846
822 // Allocate function. 847 // Allocate function.
823 ASSERT(!info->code().is_null()); 848 ASSERT(!info->code().is_null());
824 result = isolate->factory()->NewSharedFunctionInfo( 849 result = isolate->factory()->NewSharedFunctionInfo(
825 lit->name(), 850 lit->name(),
826 lit->materialized_literal_count(), 851 lit->materialized_literal_count(),
827 lit->is_generator(), 852 lit->is_generator(),
828 info->code(), 853 info->code(),
829 ScopeInfo::Create(info->scope(), info->zone())); 854 ScopeInfo::Create(info->scope(), info->zone()),
855 info->feedback_vector());
830 856
831 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); 857 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position());
832 SetFunctionInfo(result, lit, true, script); 858 SetFunctionInfo(result, lit, true, script);
833 859
834 Handle<String> script_name = script->name()->IsString() 860 Handle<String> script_name = script->name()->IsString()
835 ? Handle<String>(String::cast(script->name())) 861 ? Handle<String>(String::cast(script->name()))
836 : isolate->factory()->empty_string(); 862 : isolate->factory()->empty_string();
837 Logger::LogEventsAndTags log_tag = info->is_eval() 863 Logger::LogEventsAndTags log_tag = info->is_eval()
838 ? Logger::EVAL_TAG 864 ? Logger::EVAL_TAG
839 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script); 865 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 } else { 1052 } else {
1027 return Handle<SharedFunctionInfo>::null(); 1053 return Handle<SharedFunctionInfo>::null();
1028 } 1054 }
1029 1055
1030 // Create a shared function info object. 1056 // Create a shared function info object.
1031 Handle<SharedFunctionInfo> result = 1057 Handle<SharedFunctionInfo> result =
1032 factory->NewSharedFunctionInfo(literal->name(), 1058 factory->NewSharedFunctionInfo(literal->name(),
1033 literal->materialized_literal_count(), 1059 literal->materialized_literal_count(),
1034 literal->is_generator(), 1060 literal->is_generator(),
1035 info.code(), 1061 info.code(),
1036 scope_info); 1062 scope_info,
1063 info.feedback_vector());
1037 SetFunctionInfo(result, literal, false, script); 1064 SetFunctionInfo(result, literal, false, script);
1038 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); 1065 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result);
1039 result->set_allows_lazy_compilation(allow_lazy); 1066 result->set_allows_lazy_compilation(allow_lazy);
1040 result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx); 1067 result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx);
1041 1068
1042 // Set the expected number of properties for instances and return 1069 // Set the expected number of properties for instances and return
1043 // the resulting function. 1070 // the resulting function.
1044 SetExpectedNofPropertiesFromEstimate(result, 1071 SetExpectedNofPropertiesFromEstimate(result,
1045 literal->expected_property_count()); 1072 literal->expected_property_count());
1046 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone()); 1073 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone());
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 AllowHandleDereference allow_deref; 1331 AllowHandleDereference allow_deref;
1305 bool tracing_on = info()->IsStub() 1332 bool tracing_on = info()->IsStub()
1306 ? FLAG_trace_hydrogen_stubs 1333 ? FLAG_trace_hydrogen_stubs
1307 : (FLAG_trace_hydrogen && 1334 : (FLAG_trace_hydrogen &&
1308 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); 1335 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter));
1309 return (tracing_on && 1336 return (tracing_on &&
1310 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); 1337 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL);
1311 } 1338 }
1312 1339
1313 } } // namespace v8::internal 1340 } } // 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