OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation()); | 647 function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation()); |
648 function_info->set_allows_lazy_compilation_without_context( | 648 function_info->set_allows_lazy_compilation_without_context( |
649 lit->AllowsLazyCompilationWithoutContext()); | 649 lit->AllowsLazyCompilationWithoutContext()); |
650 function_info->set_strict_mode(lit->strict_mode()); | 650 function_info->set_strict_mode(lit->strict_mode()); |
651 function_info->set_uses_arguments(lit->scope()->arguments() != NULL); | 651 function_info->set_uses_arguments(lit->scope()->arguments() != NULL); |
652 function_info->set_has_duplicate_parameters(lit->has_duplicate_parameters()); | 652 function_info->set_has_duplicate_parameters(lit->has_duplicate_parameters()); |
653 function_info->set_ast_node_count(lit->ast_node_count()); | 653 function_info->set_ast_node_count(lit->ast_node_count()); |
654 function_info->set_is_function(lit->is_function()); | 654 function_info->set_is_function(lit->is_function()); |
655 function_info->set_bailout_reason(lit->dont_optimize_reason()); | 655 function_info->set_bailout_reason(lit->dont_optimize_reason()); |
656 function_info->set_dont_cache(lit->flags()->Contains(kDontCache)); | 656 function_info->set_dont_cache(lit->flags()->Contains(kDontCache)); |
657 function_info->set_is_generator(lit->is_generator()); | 657 function_info->set_kind(lit->kind()); |
658 function_info->set_is_arrow(lit->is_arrow()); | |
659 } | 658 } |
660 | 659 |
661 | 660 |
662 static bool CompileUnoptimizedCode(CompilationInfo* info) { | 661 static bool CompileUnoptimizedCode(CompilationInfo* info) { |
663 DCHECK(AllowCompilation::IsAllowed(info->isolate())); | 662 DCHECK(AllowCompilation::IsAllowed(info->isolate())); |
664 DCHECK(info->function() != NULL); | 663 DCHECK(info->function() != NULL); |
665 if (!Rewriter::Rewrite(info)) return false; | 664 if (!Rewriter::Rewrite(info)) return false; |
666 if (!Scope::Analyze(info)) return false; | 665 if (!Scope::Analyze(info)) return false; |
667 DCHECK(info->scope() != NULL); | 666 DCHECK(info->scope() != NULL); |
668 | 667 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 HistogramTimerScope timer(rate); | 863 HistogramTimerScope timer(rate); |
865 | 864 |
866 // Compile the code. | 865 // Compile the code. |
867 if (!CompileUnoptimizedCode(info)) { | 866 if (!CompileUnoptimizedCode(info)) { |
868 return Handle<SharedFunctionInfo>::null(); | 867 return Handle<SharedFunctionInfo>::null(); |
869 } | 868 } |
870 | 869 |
871 // Allocate function. | 870 // Allocate function. |
872 DCHECK(!info->code().is_null()); | 871 DCHECK(!info->code().is_null()); |
873 result = isolate->factory()->NewSharedFunctionInfo( | 872 result = isolate->factory()->NewSharedFunctionInfo( |
874 lit->name(), lit->materialized_literal_count(), lit->is_generator(), | 873 lit->name(), lit->materialized_literal_count(), lit->kind(), |
875 lit->is_arrow(), info->code(), | 874 info->code(), ScopeInfo::Create(info->scope(), info->zone()), |
876 ScopeInfo::Create(info->scope(), info->zone()), | |
877 info->feedback_vector()); | 875 info->feedback_vector()); |
878 | 876 |
879 DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position()); | 877 DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position()); |
880 SetFunctionInfo(result, lit, true, script); | 878 SetFunctionInfo(result, lit, true, script); |
881 | 879 |
882 Handle<String> script_name = script->name()->IsString() | 880 Handle<String> script_name = script->name()->IsString() |
883 ? Handle<String>(String::cast(script->name())) | 881 ? Handle<String>(String::cast(script->name())) |
884 : isolate->factory()->empty_string(); | 882 : isolate->factory()->empty_string(); |
885 Logger::LogEventsAndTags log_tag = info->is_eval() | 883 Logger::LogEventsAndTags log_tag = info->is_eval() |
886 ? Logger::EVAL_TAG | 884 ? Logger::EVAL_TAG |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 scope_info = Handle<ScopeInfo>(ScopeInfo::Empty(isolate)); | 1085 scope_info = Handle<ScopeInfo>(ScopeInfo::Empty(isolate)); |
1088 } else if (FullCodeGenerator::MakeCode(&info)) { | 1086 } else if (FullCodeGenerator::MakeCode(&info)) { |
1089 DCHECK(!info.code().is_null()); | 1087 DCHECK(!info.code().is_null()); |
1090 scope_info = ScopeInfo::Create(info.scope(), info.zone()); | 1088 scope_info = ScopeInfo::Create(info.scope(), info.zone()); |
1091 } else { | 1089 } else { |
1092 return Handle<SharedFunctionInfo>::null(); | 1090 return Handle<SharedFunctionInfo>::null(); |
1093 } | 1091 } |
1094 | 1092 |
1095 // Create a shared function info object. | 1093 // Create a shared function info object. |
1096 Handle<SharedFunctionInfo> result = factory->NewSharedFunctionInfo( | 1094 Handle<SharedFunctionInfo> result = factory->NewSharedFunctionInfo( |
1097 literal->name(), literal->materialized_literal_count(), | 1095 literal->name(), literal->materialized_literal_count(), literal->kind(), |
1098 literal->is_generator(), literal->is_arrow(), info.code(), scope_info, | 1096 info.code(), scope_info, info.feedback_vector()); |
1099 info.feedback_vector()); | |
1100 SetFunctionInfo(result, literal, false, script); | 1097 SetFunctionInfo(result, literal, false, script); |
1101 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); | 1098 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); |
1102 result->set_allows_lazy_compilation(allow_lazy); | 1099 result->set_allows_lazy_compilation(allow_lazy); |
1103 result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx); | 1100 result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx); |
1104 | 1101 |
1105 // Set the expected number of properties for instances and return | 1102 // Set the expected number of properties for instances and return |
1106 // the resulting function. | 1103 // the resulting function. |
1107 SetExpectedNofPropertiesFromEstimate(result, | 1104 SetExpectedNofPropertiesFromEstimate(result, |
1108 literal->expected_property_count()); | 1105 literal->expected_property_count()); |
1109 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone()); | 1106 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone()); |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 AllowHandleDereference allow_deref; | 1382 AllowHandleDereference allow_deref; |
1386 bool tracing_on = info()->IsStub() | 1383 bool tracing_on = info()->IsStub() |
1387 ? FLAG_trace_hydrogen_stubs | 1384 ? FLAG_trace_hydrogen_stubs |
1388 : (FLAG_trace_hydrogen && | 1385 : (FLAG_trace_hydrogen && |
1389 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1386 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
1390 return (tracing_on && | 1387 return (tracing_on && |
1391 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1388 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
1392 } | 1389 } |
1393 | 1390 |
1394 } } // namespace v8::internal | 1391 } } // namespace v8::internal |
OLD | NEW |