| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 mode_ = mode; | 133 mode_ = mode; |
| 134 abort_due_to_dependency_ = false; | 134 abort_due_to_dependency_ = false; |
| 135 if (script_->type()->value() == Script::TYPE_NATIVE) { | 135 if (script_->type()->value() == Script::TYPE_NATIVE) { |
| 136 MarkAsNative(); | 136 MarkAsNative(); |
| 137 } | 137 } |
| 138 if (!shared_info_.is_null()) { | 138 if (!shared_info_.is_null()) { |
| 139 ASSERT(strict_mode() == SLOPPY); | 139 ASSERT(strict_mode() == SLOPPY); |
| 140 SetStrictMode(shared_info_->strict_mode()); | 140 SetStrictMode(shared_info_->strict_mode()); |
| 141 } | 141 } |
| 142 set_bailout_reason(kUnknown); | 142 set_bailout_reason(kUnknown); |
| 143 | |
| 144 if (!shared_info().is_null() && shared_info()->is_compiled()) { | |
| 145 // We should initialize the CompilationInfo feedback vector from the | |
| 146 // passed in shared info, rather than creating a new one. | |
| 147 feedback_vector_ = Handle<FixedArray>(shared_info()->feedback_vector(), | |
| 148 isolate); | |
| 149 } | |
| 150 } | 143 } |
| 151 | 144 |
| 152 | 145 |
| 153 CompilationInfo::~CompilationInfo() { | 146 CompilationInfo::~CompilationInfo() { |
| 154 delete deferred_handles_; | 147 delete deferred_handles_; |
| 155 delete no_frame_ranges_; | 148 delete no_frame_ranges_; |
| 156 #ifdef DEBUG | 149 #ifdef DEBUG |
| 157 // Check that no dependent maps have been added or added dependent maps have | 150 // Check that no dependent maps have been added or added dependent maps have |
| 158 // been rolled back or committed. | 151 // been rolled back or committed. |
| 159 for (int i = 0; i < DependentCode::kGroupCount; i++) { | 152 for (int i = 0; i < DependentCode::kGroupCount; i++) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 !function()->dont_optimize() && | 242 !function()->dont_optimize() && |
| 250 function()->scope()->AllowsLazyCompilation() && | 243 function()->scope()->AllowsLazyCompilation() && |
| 251 (shared_info().is_null() || !shared_info()->optimization_disabled()); | 244 (shared_info().is_null() || !shared_info()->optimization_disabled()); |
| 252 } | 245 } |
| 253 | 246 |
| 254 | 247 |
| 255 void CompilationInfo::PrepareForCompilation(Scope* scope) { | 248 void CompilationInfo::PrepareForCompilation(Scope* scope) { |
| 256 ASSERT(scope_ == NULL); | 249 ASSERT(scope_ == NULL); |
| 257 scope_ = scope; | 250 scope_ = scope; |
| 258 function()->ProcessFeedbackSlots(isolate_); | 251 function()->ProcessFeedbackSlots(isolate_); |
| 259 int length = function()->slot_count(); | |
| 260 if (feedback_vector_.is_null()) { | |
| 261 // Allocate the feedback vector too. | |
| 262 feedback_vector_ = isolate()->factory()->NewFixedArray(length, TENURED); | |
| 263 // Ensure we can skip the write barrier | |
| 264 ASSERT_EQ(isolate()->heap()->uninitialized_symbol(), | |
| 265 *TypeFeedbackInfo::UninitializedSentinel(isolate())); | |
| 266 for (int i = 0; i < length; i++) { | |
| 267 feedback_vector_->set(i, | |
| 268 *TypeFeedbackInfo::UninitializedSentinel(isolate()), | |
| 269 SKIP_WRITE_BARRIER); | |
| 270 } | |
| 271 } | |
| 272 ASSERT(feedback_vector_->length() == length); | |
| 273 } | 252 } |
| 274 | 253 |
| 275 | 254 |
| 276 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { | 255 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { |
| 277 public: | 256 public: |
| 278 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) | 257 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) |
| 279 : HOptimizedGraphBuilder(info) { | 258 : HOptimizedGraphBuilder(info) { |
| 280 } | 259 } |
| 281 | 260 |
| 282 #define DEF_VISIT(type) \ | 261 #define DEF_VISIT(type) \ |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 Handle<SharedFunctionInfo> shared = info->shared_info(); | 563 Handle<SharedFunctionInfo> shared = info->shared_info(); |
| 585 Handle<ScopeInfo> scope_info = | 564 Handle<ScopeInfo> scope_info = |
| 586 ScopeInfo::Create(info->scope(), info->zone()); | 565 ScopeInfo::Create(info->scope(), info->zone()); |
| 587 shared->set_scope_info(*scope_info); | 566 shared->set_scope_info(*scope_info); |
| 588 | 567 |
| 589 Handle<Code> code = info->code(); | 568 Handle<Code> code = info->code(); |
| 590 CHECK(code->kind() == Code::FUNCTION); | 569 CHECK(code->kind() == Code::FUNCTION); |
| 591 shared->ReplaceCode(*code); | 570 shared->ReplaceCode(*code); |
| 592 if (shared->optimization_disabled()) code->set_optimizable(false); | 571 if (shared->optimization_disabled()) code->set_optimizable(false); |
| 593 | 572 |
| 594 shared->set_feedback_vector(*info->feedback_vector()); | |
| 595 | |
| 596 // Set the expected number of properties for instances. | 573 // Set the expected number of properties for instances. |
| 597 FunctionLiteral* lit = info->function(); | 574 FunctionLiteral* lit = info->function(); |
| 598 int expected = lit->expected_property_count(); | 575 int expected = lit->expected_property_count(); |
| 599 SetExpectedNofPropertiesFromEstimate(shared, expected); | 576 SetExpectedNofPropertiesFromEstimate(shared, expected); |
| 600 | 577 |
| 601 // Check the function has compiled code. | 578 // Check the function has compiled code. |
| 602 ASSERT(shared->is_compiled()); | 579 ASSERT(shared->is_compiled()); |
| 603 shared->set_dont_optimize_reason(lit->dont_optimize_reason()); | 580 shared->set_dont_optimize_reason(lit->dont_optimize_reason()); |
| 604 shared->set_dont_inline(lit->flags()->Contains(kDontInline)); | 581 shared->set_dont_inline(lit->flags()->Contains(kDontInline)); |
| 605 shared->set_ast_node_count(lit->ast_node_count()); | 582 shared->set_ast_node_count(lit->ast_node_count()); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 return Handle<SharedFunctionInfo>::null(); | 816 return Handle<SharedFunctionInfo>::null(); |
| 840 } | 817 } |
| 841 | 818 |
| 842 // Allocate function. | 819 // Allocate function. |
| 843 ASSERT(!info->code().is_null()); | 820 ASSERT(!info->code().is_null()); |
| 844 result = isolate->factory()->NewSharedFunctionInfo( | 821 result = isolate->factory()->NewSharedFunctionInfo( |
| 845 lit->name(), | 822 lit->name(), |
| 846 lit->materialized_literal_count(), | 823 lit->materialized_literal_count(), |
| 847 lit->is_generator(), | 824 lit->is_generator(), |
| 848 info->code(), | 825 info->code(), |
| 849 ScopeInfo::Create(info->scope(), info->zone()), | 826 ScopeInfo::Create(info->scope(), info->zone())); |
| 850 info->feedback_vector()); | |
| 851 | 827 |
| 852 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); | 828 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); |
| 853 SetFunctionInfo(result, lit, true, script); | 829 SetFunctionInfo(result, lit, true, script); |
| 854 | 830 |
| 855 Handle<String> script_name = script->name()->IsString() | 831 Handle<String> script_name = script->name()->IsString() |
| 856 ? Handle<String>(String::cast(script->name())) | 832 ? Handle<String>(String::cast(script->name())) |
| 857 : isolate->factory()->empty_string(); | 833 : isolate->factory()->empty_string(); |
| 858 Logger::LogEventsAndTags log_tag = info->is_eval() | 834 Logger::LogEventsAndTags log_tag = info->is_eval() |
| 859 ? Logger::EVAL_TAG | 835 ? Logger::EVAL_TAG |
| 860 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script); | 836 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 } else { | 1015 } else { |
| 1040 return Handle<SharedFunctionInfo>::null(); | 1016 return Handle<SharedFunctionInfo>::null(); |
| 1041 } | 1017 } |
| 1042 | 1018 |
| 1043 // Create a shared function info object. | 1019 // Create a shared function info object. |
| 1044 Handle<SharedFunctionInfo> result = | 1020 Handle<SharedFunctionInfo> result = |
| 1045 factory->NewSharedFunctionInfo(literal->name(), | 1021 factory->NewSharedFunctionInfo(literal->name(), |
| 1046 literal->materialized_literal_count(), | 1022 literal->materialized_literal_count(), |
| 1047 literal->is_generator(), | 1023 literal->is_generator(), |
| 1048 info.code(), | 1024 info.code(), |
| 1049 scope_info, | 1025 scope_info); |
| 1050 info.feedback_vector()); | |
| 1051 SetFunctionInfo(result, literal, false, script); | 1026 SetFunctionInfo(result, literal, false, script); |
| 1052 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); | 1027 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); |
| 1053 result->set_allows_lazy_compilation(allow_lazy); | 1028 result->set_allows_lazy_compilation(allow_lazy); |
| 1054 result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx); | 1029 result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx); |
| 1055 | 1030 |
| 1056 // Set the expected number of properties for instances and return | 1031 // Set the expected number of properties for instances and return |
| 1057 // the resulting function. | 1032 // the resulting function. |
| 1058 SetExpectedNofPropertiesFromEstimate(result, | 1033 SetExpectedNofPropertiesFromEstimate(result, |
| 1059 literal->expected_property_count()); | 1034 literal->expected_property_count()); |
| 1060 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone()); | 1035 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone()); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1317 AllowHandleDereference allow_deref; | 1292 AllowHandleDereference allow_deref; |
| 1318 bool tracing_on = info()->IsStub() | 1293 bool tracing_on = info()->IsStub() |
| 1319 ? FLAG_trace_hydrogen_stubs | 1294 ? FLAG_trace_hydrogen_stubs |
| 1320 : (FLAG_trace_hydrogen && | 1295 : (FLAG_trace_hydrogen && |
| 1321 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1296 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
| 1322 return (tracing_on && | 1297 return (tracing_on && |
| 1323 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1298 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
| 1324 } | 1299 } |
| 1325 | 1300 |
| 1326 } } // namespace v8::internal | 1301 } } // namespace v8::internal |
| OLD | NEW |