Chromium Code Reviews| 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(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 Loading... | |
| 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 // Allocate the feedback vector too. | |
| 263 ASSERT_EQ(isolate()->heap()->the_hole_value(), | |
| 264 *TypeFeedbackInfo::UninitializedSentinel(isolate())); | |
|
Benedikt Meurer
2014/03/05 07:22:56
Nit: indentation
mvstanton
2014/03/05 08:48:02
Done.
| |
| 265 int length = function()->slot_count(); | |
| 266 if (feedback_vector_.is_null()) { | |
| 267 feedback_vector_ = isolate()->factory()->NewFixedArrayWithHoles(length, | |
|
Benedikt Meurer
2014/03/05 07:22:56
Nit: put arguments on next line.
mvstanton
2014/03/05 08:48:02
Done.
| |
| 268 TENURED); | |
| 269 } | |
| 270 ASSERT(feedback_vector_->length() == length); | |
| 253 } | 271 } |
| 254 | 272 |
| 255 | 273 |
| 256 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { | 274 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { |
| 257 public: | 275 public: |
| 258 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) | 276 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) |
| 259 : HOptimizedGraphBuilder(info) { | 277 : HOptimizedGraphBuilder(info) { |
| 260 } | 278 } |
| 261 | 279 |
| 262 #define DEF_VISIT(type) \ | 280 #define DEF_VISIT(type) \ |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 564 Handle<SharedFunctionInfo> shared = info->shared_info(); | 582 Handle<SharedFunctionInfo> shared = info->shared_info(); |
| 565 Handle<ScopeInfo> scope_info = | 583 Handle<ScopeInfo> scope_info = |
| 566 ScopeInfo::Create(info->scope(), info->zone()); | 584 ScopeInfo::Create(info->scope(), info->zone()); |
| 567 shared->set_scope_info(*scope_info); | 585 shared->set_scope_info(*scope_info); |
| 568 | 586 |
| 569 Handle<Code> code = info->code(); | 587 Handle<Code> code = info->code(); |
| 570 CHECK(code->kind() == Code::FUNCTION); | 588 CHECK(code->kind() == Code::FUNCTION); |
| 571 shared->ReplaceCode(*code); | 589 shared->ReplaceCode(*code); |
| 572 if (shared->optimization_disabled()) code->set_optimizable(false); | 590 if (shared->optimization_disabled()) code->set_optimizable(false); |
| 573 | 591 |
| 592 shared->set_feedback_vector(*(info->feedback_vector())); | |
|
Benedikt Meurer
2014/03/05 07:22:56
Nit: *info->feedback_vector()
mvstanton
2014/03/05 08:48:02
Done.
| |
| 593 | |
| 574 // Set the expected number of properties for instances. | 594 // Set the expected number of properties for instances. |
| 575 FunctionLiteral* lit = info->function(); | 595 FunctionLiteral* lit = info->function(); |
| 576 int expected = lit->expected_property_count(); | 596 int expected = lit->expected_property_count(); |
| 577 SetExpectedNofPropertiesFromEstimate(shared, expected); | 597 SetExpectedNofPropertiesFromEstimate(shared, expected); |
| 578 | 598 |
| 579 // Check the function has compiled code. | 599 // Check the function has compiled code. |
| 580 ASSERT(shared->is_compiled()); | 600 ASSERT(shared->is_compiled()); |
| 581 shared->set_dont_optimize_reason(lit->dont_optimize_reason()); | 601 shared->set_dont_optimize_reason(lit->dont_optimize_reason()); |
| 582 shared->set_dont_inline(lit->flags()->Contains(kDontInline)); | 602 shared->set_dont_inline(lit->flags()->Contains(kDontInline)); |
| 583 shared->set_ast_node_count(lit->ast_node_count()); | 603 shared->set_ast_node_count(lit->ast_node_count()); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 819 return Handle<SharedFunctionInfo>::null(); | 839 return Handle<SharedFunctionInfo>::null(); |
| 820 } | 840 } |
| 821 | 841 |
| 822 // Allocate function. | 842 // Allocate function. |
| 823 ASSERT(!info->code().is_null()); | 843 ASSERT(!info->code().is_null()); |
| 824 result = isolate->factory()->NewSharedFunctionInfo( | 844 result = isolate->factory()->NewSharedFunctionInfo( |
| 825 lit->name(), | 845 lit->name(), |
| 826 lit->materialized_literal_count(), | 846 lit->materialized_literal_count(), |
| 827 lit->is_generator(), | 847 lit->is_generator(), |
| 828 info->code(), | 848 info->code(), |
| 829 ScopeInfo::Create(info->scope(), info->zone())); | 849 ScopeInfo::Create(info->scope(), info->zone()), |
| 850 info->feedback_vector()); | |
| 830 | 851 |
| 831 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); | 852 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); |
| 832 SetFunctionInfo(result, lit, true, script); | 853 SetFunctionInfo(result, lit, true, script); |
| 833 | 854 |
| 834 Handle<String> script_name = script->name()->IsString() | 855 Handle<String> script_name = script->name()->IsString() |
| 835 ? Handle<String>(String::cast(script->name())) | 856 ? Handle<String>(String::cast(script->name())) |
| 836 : isolate->factory()->empty_string(); | 857 : isolate->factory()->empty_string(); |
| 837 Logger::LogEventsAndTags log_tag = info->is_eval() | 858 Logger::LogEventsAndTags log_tag = info->is_eval() |
| 838 ? Logger::EVAL_TAG | 859 ? Logger::EVAL_TAG |
| 839 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script); | 860 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1030 } else { | 1051 } else { |
| 1031 return Handle<SharedFunctionInfo>::null(); | 1052 return Handle<SharedFunctionInfo>::null(); |
| 1032 } | 1053 } |
| 1033 | 1054 |
| 1034 // Create a shared function info object. | 1055 // Create a shared function info object. |
| 1035 Handle<SharedFunctionInfo> result = | 1056 Handle<SharedFunctionInfo> result = |
| 1036 factory->NewSharedFunctionInfo(literal->name(), | 1057 factory->NewSharedFunctionInfo(literal->name(), |
| 1037 literal->materialized_literal_count(), | 1058 literal->materialized_literal_count(), |
| 1038 literal->is_generator(), | 1059 literal->is_generator(), |
| 1039 info.code(), | 1060 info.code(), |
| 1040 scope_info); | 1061 scope_info, |
| 1062 info.feedback_vector()); | |
| 1041 SetFunctionInfo(result, literal, false, script); | 1063 SetFunctionInfo(result, literal, false, script); |
| 1042 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); | 1064 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); |
| 1043 result->set_allows_lazy_compilation(allow_lazy); | 1065 result->set_allows_lazy_compilation(allow_lazy); |
| 1044 result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx); | 1066 result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx); |
| 1045 | 1067 |
| 1046 // Set the expected number of properties for instances and return | 1068 // Set the expected number of properties for instances and return |
| 1047 // the resulting function. | 1069 // the resulting function. |
| 1048 SetExpectedNofPropertiesFromEstimate(result, | 1070 SetExpectedNofPropertiesFromEstimate(result, |
| 1049 literal->expected_property_count()); | 1071 literal->expected_property_count()); |
| 1050 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone()); | 1072 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone()); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1311 AllowHandleDereference allow_deref; | 1333 AllowHandleDereference allow_deref; |
| 1312 bool tracing_on = info()->IsStub() | 1334 bool tracing_on = info()->IsStub() |
| 1313 ? FLAG_trace_hydrogen_stubs | 1335 ? FLAG_trace_hydrogen_stubs |
| 1314 : (FLAG_trace_hydrogen && | 1336 : (FLAG_trace_hydrogen && |
| 1315 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1337 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
| 1316 return (tracing_on && | 1338 return (tracing_on && |
| 1317 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1339 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
| 1318 } | 1340 } |
| 1319 | 1341 |
| 1320 } } // namespace v8::internal | 1342 } } // namespace v8::internal |
| OLD | NEW |