OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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()->NewFixedArray(length, TENURED); | |
Benedikt Meurer
2014/04/28 19:17:00
How about adding a factory wrapper for Heap::Alloc
mvstanton
2014/04/30 08:31:18
Great idea, done, but I went ahead and made the fa
| |
264 // Ensure we can skip the write barrier | |
265 ASSERT_EQ(isolate()->heap()->uninitialized_symbol(), | |
266 *TypeFeedbackInfo::UninitializedSentinel(isolate())); | |
267 for (int i = 0; i < length; i++) { | |
268 feedback_vector_->set( | |
269 i, | |
270 *TypeFeedbackInfo::UninitializedSentinel(isolate()), | |
271 SKIP_WRITE_BARRIER); | |
272 } | |
273 } | |
274 ASSERT(feedback_vector_->length() == length); | |
253 } | 275 } |
254 | 276 |
255 | 277 |
256 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { | 278 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { |
257 public: | 279 public: |
258 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) | 280 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) |
259 : HOptimizedGraphBuilder(info) { | 281 : HOptimizedGraphBuilder(info) { |
260 } | 282 } |
261 | 283 |
262 #define DEF_VISIT(type) \ | 284 #define DEF_VISIT(type) \ |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
564 Handle<SharedFunctionInfo> shared = info->shared_info(); | 586 Handle<SharedFunctionInfo> shared = info->shared_info(); |
565 Handle<ScopeInfo> scope_info = | 587 Handle<ScopeInfo> scope_info = |
566 ScopeInfo::Create(info->scope(), info->zone()); | 588 ScopeInfo::Create(info->scope(), info->zone()); |
567 shared->set_scope_info(*scope_info); | 589 shared->set_scope_info(*scope_info); |
568 | 590 |
569 Handle<Code> code = info->code(); | 591 Handle<Code> code = info->code(); |
570 CHECK(code->kind() == Code::FUNCTION); | 592 CHECK(code->kind() == Code::FUNCTION); |
571 shared->ReplaceCode(*code); | 593 shared->ReplaceCode(*code); |
572 if (shared->optimization_disabled()) code->set_optimizable(false); | 594 if (shared->optimization_disabled()) code->set_optimizable(false); |
573 | 595 |
596 shared->set_feedback_vector(*info->feedback_vector()); | |
597 | |
574 // Set the expected number of properties for instances. | 598 // Set the expected number of properties for instances. |
575 FunctionLiteral* lit = info->function(); | 599 FunctionLiteral* lit = info->function(); |
576 int expected = lit->expected_property_count(); | 600 int expected = lit->expected_property_count(); |
577 SetExpectedNofPropertiesFromEstimate(shared, expected); | 601 SetExpectedNofPropertiesFromEstimate(shared, expected); |
578 | 602 |
579 // Check the function has compiled code. | 603 // Check the function has compiled code. |
580 ASSERT(shared->is_compiled()); | 604 ASSERT(shared->is_compiled()); |
581 shared->set_dont_optimize_reason(lit->dont_optimize_reason()); | 605 shared->set_dont_optimize_reason(lit->dont_optimize_reason()); |
582 shared->set_dont_inline(lit->flags()->Contains(kDontInline)); | 606 shared->set_dont_inline(lit->flags()->Contains(kDontInline)); |
583 shared->set_ast_node_count(lit->ast_node_count()); | 607 shared->set_ast_node_count(lit->ast_node_count()); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
822 return Handle<SharedFunctionInfo>::null(); | 846 return Handle<SharedFunctionInfo>::null(); |
823 } | 847 } |
824 | 848 |
825 // Allocate function. | 849 // Allocate function. |
826 ASSERT(!info->code().is_null()); | 850 ASSERT(!info->code().is_null()); |
827 result = isolate->factory()->NewSharedFunctionInfo( | 851 result = isolate->factory()->NewSharedFunctionInfo( |
828 lit->name(), | 852 lit->name(), |
829 lit->materialized_literal_count(), | 853 lit->materialized_literal_count(), |
830 lit->is_generator(), | 854 lit->is_generator(), |
831 info->code(), | 855 info->code(), |
832 ScopeInfo::Create(info->scope(), info->zone())); | 856 ScopeInfo::Create(info->scope(), info->zone()), |
857 info->feedback_vector()); | |
833 | 858 |
834 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); | 859 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); |
835 SetFunctionInfo(result, lit, true, script); | 860 SetFunctionInfo(result, lit, true, script); |
836 | 861 |
837 Handle<String> script_name = script->name()->IsString() | 862 Handle<String> script_name = script->name()->IsString() |
838 ? Handle<String>(String::cast(script->name())) | 863 ? Handle<String>(String::cast(script->name())) |
839 : isolate->factory()->empty_string(); | 864 : isolate->factory()->empty_string(); |
840 Logger::LogEventsAndTags log_tag = info->is_eval() | 865 Logger::LogEventsAndTags log_tag = info->is_eval() |
841 ? Logger::EVAL_TAG | 866 ? Logger::EVAL_TAG |
842 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script); | 867 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1020 } else { | 1045 } else { |
1021 return Handle<SharedFunctionInfo>::null(); | 1046 return Handle<SharedFunctionInfo>::null(); |
1022 } | 1047 } |
1023 | 1048 |
1024 // Create a shared function info object. | 1049 // Create a shared function info object. |
1025 Handle<SharedFunctionInfo> result = | 1050 Handle<SharedFunctionInfo> result = |
1026 factory->NewSharedFunctionInfo(literal->name(), | 1051 factory->NewSharedFunctionInfo(literal->name(), |
1027 literal->materialized_literal_count(), | 1052 literal->materialized_literal_count(), |
1028 literal->is_generator(), | 1053 literal->is_generator(), |
1029 info.code(), | 1054 info.code(), |
1030 scope_info); | 1055 scope_info, |
1056 info.feedback_vector()); | |
1031 SetFunctionInfo(result, literal, false, script); | 1057 SetFunctionInfo(result, literal, false, script); |
1032 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); | 1058 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); |
1033 result->set_allows_lazy_compilation(allow_lazy); | 1059 result->set_allows_lazy_compilation(allow_lazy); |
1034 result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx); | 1060 result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx); |
1035 | 1061 |
1036 // Set the expected number of properties for instances and return | 1062 // Set the expected number of properties for instances and return |
1037 // the resulting function. | 1063 // the resulting function. |
1038 SetExpectedNofPropertiesFromEstimate(result, | 1064 SetExpectedNofPropertiesFromEstimate(result, |
1039 literal->expected_property_count()); | 1065 literal->expected_property_count()); |
1040 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone()); | 1066 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone()); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1302 AllowHandleDereference allow_deref; | 1328 AllowHandleDereference allow_deref; |
1303 bool tracing_on = info()->IsStub() | 1329 bool tracing_on = info()->IsStub() |
1304 ? FLAG_trace_hydrogen_stubs | 1330 ? FLAG_trace_hydrogen_stubs |
1305 : (FLAG_trace_hydrogen && | 1331 : (FLAG_trace_hydrogen && |
1306 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1332 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
1307 return (tracing_on && | 1333 return (tracing_on && |
1308 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1334 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
1309 } | 1335 } |
1310 | 1336 |
1311 } } // namespace v8::internal | 1337 } } // namespace v8::internal |
OLD | NEW |