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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 !function()->dont_optimize() && | 242 !function()->dont_optimize() && |
243 function()->scope()->AllowsLazyCompilation() && | 243 function()->scope()->AllowsLazyCompilation() && |
244 (shared_info().is_null() || !shared_info()->optimization_disabled()); | 244 (shared_info().is_null() || !shared_info()->optimization_disabled()); |
245 } | 245 } |
246 | 246 |
247 | 247 |
248 void CompilationInfo::PrepareForCompilation(Scope* scope) { | 248 void CompilationInfo::PrepareForCompilation(Scope* scope) { |
249 ASSERT(scope_ == NULL); | 249 ASSERT(scope_ == NULL); |
250 scope_ = scope; | 250 scope_ = scope; |
251 function()->ProcessFeedbackSlots(isolate_); | 251 function()->ProcessFeedbackSlots(isolate_); |
252 int length = function()->slot_count(); | |
253 // Allocate the feedback vector too. | |
254 feedback_vector_ = isolate()->factory()->NewFixedArray(length, TENURED); | |
255 // Ensure we can skip the write barrier | |
256 ASSERT_EQ(isolate()->heap()->uninitialized_symbol(), | |
257 *TypeFeedbackInfo::UninitializedSentinel(isolate())); | |
258 for (int i = 0; i < length; i++) { | |
259 feedback_vector_->set(i, | |
Benedikt Meurer
2014/03/14 09:22:08
Nit: funky indentation.
| |
260 *TypeFeedbackInfo::UninitializedSentinel(isolate()), | |
261 SKIP_WRITE_BARRIER); | |
262 } | |
252 } | 263 } |
253 | 264 |
254 | 265 |
255 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { | 266 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { |
256 public: | 267 public: |
257 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) | 268 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) |
258 : HOptimizedGraphBuilder(info) { | 269 : HOptimizedGraphBuilder(info) { |
259 } | 270 } |
260 | 271 |
261 #define DEF_VISIT(type) \ | 272 #define DEF_VISIT(type) \ |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
563 Handle<SharedFunctionInfo> shared = info->shared_info(); | 574 Handle<SharedFunctionInfo> shared = info->shared_info(); |
564 Handle<ScopeInfo> scope_info = | 575 Handle<ScopeInfo> scope_info = |
565 ScopeInfo::Create(info->scope(), info->zone()); | 576 ScopeInfo::Create(info->scope(), info->zone()); |
566 shared->set_scope_info(*scope_info); | 577 shared->set_scope_info(*scope_info); |
567 | 578 |
568 Handle<Code> code = info->code(); | 579 Handle<Code> code = info->code(); |
569 CHECK(code->kind() == Code::FUNCTION); | 580 CHECK(code->kind() == Code::FUNCTION); |
570 shared->ReplaceCode(*code); | 581 shared->ReplaceCode(*code); |
571 if (shared->optimization_disabled()) code->set_optimizable(false); | 582 if (shared->optimization_disabled()) code->set_optimizable(false); |
572 | 583 |
584 shared->set_feedback_vector(*info->feedback_vector()); | |
585 | |
573 // Set the expected number of properties for instances. | 586 // Set the expected number of properties for instances. |
574 FunctionLiteral* lit = info->function(); | 587 FunctionLiteral* lit = info->function(); |
575 int expected = lit->expected_property_count(); | 588 int expected = lit->expected_property_count(); |
576 SetExpectedNofPropertiesFromEstimate(shared, expected); | 589 SetExpectedNofPropertiesFromEstimate(shared, expected); |
577 | 590 |
578 // Check the function has compiled code. | 591 // Check the function has compiled code. |
579 ASSERT(shared->is_compiled()); | 592 ASSERT(shared->is_compiled()); |
580 shared->set_dont_optimize_reason(lit->dont_optimize_reason()); | 593 shared->set_dont_optimize_reason(lit->dont_optimize_reason()); |
581 shared->set_dont_inline(lit->flags()->Contains(kDontInline)); | 594 shared->set_dont_inline(lit->flags()->Contains(kDontInline)); |
582 shared->set_ast_node_count(lit->ast_node_count()); | 595 shared->set_ast_node_count(lit->ast_node_count()); |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
816 return Handle<SharedFunctionInfo>::null(); | 829 return Handle<SharedFunctionInfo>::null(); |
817 } | 830 } |
818 | 831 |
819 // Allocate function. | 832 // Allocate function. |
820 ASSERT(!info->code().is_null()); | 833 ASSERT(!info->code().is_null()); |
821 result = isolate->factory()->NewSharedFunctionInfo( | 834 result = isolate->factory()->NewSharedFunctionInfo( |
822 lit->name(), | 835 lit->name(), |
823 lit->materialized_literal_count(), | 836 lit->materialized_literal_count(), |
824 lit->is_generator(), | 837 lit->is_generator(), |
825 info->code(), | 838 info->code(), |
826 ScopeInfo::Create(info->scope(), info->zone())); | 839 ScopeInfo::Create(info->scope(), info->zone()), |
840 info->feedback_vector()); | |
827 | 841 |
828 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); | 842 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); |
829 SetFunctionInfo(result, lit, true, script); | 843 SetFunctionInfo(result, lit, true, script); |
830 | 844 |
831 Handle<String> script_name = script->name()->IsString() | 845 Handle<String> script_name = script->name()->IsString() |
832 ? Handle<String>(String::cast(script->name())) | 846 ? Handle<String>(String::cast(script->name())) |
833 : isolate->factory()->empty_string(); | 847 : isolate->factory()->empty_string(); |
834 Logger::LogEventsAndTags log_tag = info->is_eval() | 848 Logger::LogEventsAndTags log_tag = info->is_eval() |
835 ? Logger::EVAL_TAG | 849 ? Logger::EVAL_TAG |
836 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script); | 850 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1015 } else { | 1029 } else { |
1016 return Handle<SharedFunctionInfo>::null(); | 1030 return Handle<SharedFunctionInfo>::null(); |
1017 } | 1031 } |
1018 | 1032 |
1019 // Create a shared function info object. | 1033 // Create a shared function info object. |
1020 Handle<SharedFunctionInfo> result = | 1034 Handle<SharedFunctionInfo> result = |
1021 factory->NewSharedFunctionInfo(literal->name(), | 1035 factory->NewSharedFunctionInfo(literal->name(), |
1022 literal->materialized_literal_count(), | 1036 literal->materialized_literal_count(), |
1023 literal->is_generator(), | 1037 literal->is_generator(), |
1024 info.code(), | 1038 info.code(), |
1025 scope_info); | 1039 scope_info, |
1040 info.feedback_vector()); | |
1026 SetFunctionInfo(result, literal, false, script); | 1041 SetFunctionInfo(result, literal, false, script); |
1027 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); | 1042 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); |
1028 result->set_allows_lazy_compilation(allow_lazy); | 1043 result->set_allows_lazy_compilation(allow_lazy); |
1029 result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx); | 1044 result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx); |
1030 | 1045 |
1031 // Set the expected number of properties for instances and return | 1046 // Set the expected number of properties for instances and return |
1032 // the resulting function. | 1047 // the resulting function. |
1033 SetExpectedNofPropertiesFromEstimate(result, | 1048 SetExpectedNofPropertiesFromEstimate(result, |
1034 literal->expected_property_count()); | 1049 literal->expected_property_count()); |
1035 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone()); | 1050 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone()); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1292 AllowHandleDereference allow_deref; | 1307 AllowHandleDereference allow_deref; |
1293 bool tracing_on = info()->IsStub() | 1308 bool tracing_on = info()->IsStub() |
1294 ? FLAG_trace_hydrogen_stubs | 1309 ? FLAG_trace_hydrogen_stubs |
1295 : (FLAG_trace_hydrogen && | 1310 : (FLAG_trace_hydrogen && |
1296 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1311 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
1297 return (tracing_on && | 1312 return (tracing_on && |
1298 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1313 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
1299 } | 1314 } |
1300 | 1315 |
1301 } } // namespace v8::internal | 1316 } } // namespace v8::internal |
OLD | NEW |