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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation()); | 651 function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation()); |
652 function_info->set_allows_lazy_compilation_without_context( | 652 function_info->set_allows_lazy_compilation_without_context( |
653 lit->AllowsLazyCompilationWithoutContext()); | 653 lit->AllowsLazyCompilationWithoutContext()); |
654 function_info->set_strict_mode(lit->strict_mode()); | 654 function_info->set_strict_mode(lit->strict_mode()); |
655 function_info->set_uses_arguments(lit->scope()->arguments() != NULL); | 655 function_info->set_uses_arguments(lit->scope()->arguments() != NULL); |
656 function_info->set_has_duplicate_parameters(lit->has_duplicate_parameters()); | 656 function_info->set_has_duplicate_parameters(lit->has_duplicate_parameters()); |
657 function_info->set_ast_node_count(lit->ast_node_count()); | 657 function_info->set_ast_node_count(lit->ast_node_count()); |
658 function_info->set_is_function(lit->is_function()); | 658 function_info->set_is_function(lit->is_function()); |
659 function_info->set_bailout_reason(lit->dont_optimize_reason()); | 659 function_info->set_bailout_reason(lit->dont_optimize_reason()); |
660 function_info->set_dont_cache(lit->flags()->Contains(kDontCache)); | 660 function_info->set_dont_cache(lit->flags()->Contains(kDontCache)); |
661 function_info->set_is_generator(lit->is_generator()); | 661 function_info->set_kind(lit->kind()); |
662 function_info->set_is_arrow(lit->is_arrow()); | |
663 } | 662 } |
664 | 663 |
665 | 664 |
666 static bool CompileUnoptimizedCode(CompilationInfo* info) { | 665 static bool CompileUnoptimizedCode(CompilationInfo* info) { |
667 DCHECK(AllowCompilation::IsAllowed(info->isolate())); | 666 DCHECK(AllowCompilation::IsAllowed(info->isolate())); |
668 DCHECK(info->function() != NULL); | 667 DCHECK(info->function() != NULL); |
669 if (!Rewriter::Rewrite(info)) return false; | 668 if (!Rewriter::Rewrite(info)) return false; |
670 if (!Scope::Analyze(info)) return false; | 669 if (!Scope::Analyze(info)) return false; |
671 DCHECK(info->scope() != NULL); | 670 DCHECK(info->scope() != NULL); |
672 | 671 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 HistogramTimerScope timer(rate); | 867 HistogramTimerScope timer(rate); |
869 | 868 |
870 // Compile the code. | 869 // Compile the code. |
871 if (!CompileUnoptimizedCode(info)) { | 870 if (!CompileUnoptimizedCode(info)) { |
872 return Handle<SharedFunctionInfo>::null(); | 871 return Handle<SharedFunctionInfo>::null(); |
873 } | 872 } |
874 | 873 |
875 // Allocate function. | 874 // Allocate function. |
876 DCHECK(!info->code().is_null()); | 875 DCHECK(!info->code().is_null()); |
877 result = isolate->factory()->NewSharedFunctionInfo( | 876 result = isolate->factory()->NewSharedFunctionInfo( |
878 lit->name(), lit->materialized_literal_count(), lit->is_generator(), | 877 lit->name(), lit->materialized_literal_count(), lit->kind(), |
879 lit->is_arrow(), info->code(), | 878 info->code(), ScopeInfo::Create(info->scope(), info->zone()), |
880 ScopeInfo::Create(info->scope(), info->zone()), | |
881 info->feedback_vector()); | 879 info->feedback_vector()); |
882 | 880 |
883 DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position()); | 881 DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position()); |
884 SetFunctionInfo(result, lit, true, script); | 882 SetFunctionInfo(result, lit, true, script); |
885 | 883 |
886 Handle<String> script_name = script->name()->IsString() | 884 Handle<String> script_name = script->name()->IsString() |
887 ? Handle<String>(String::cast(script->name())) | 885 ? Handle<String>(String::cast(script->name())) |
888 : isolate->factory()->empty_string(); | 886 : isolate->factory()->empty_string(); |
889 Logger::LogEventsAndTags log_tag = info->is_eval() | 887 Logger::LogEventsAndTags log_tag = info->is_eval() |
890 ? Logger::EVAL_TAG | 888 ? Logger::EVAL_TAG |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 scope_info = Handle<ScopeInfo>(ScopeInfo::Empty(isolate)); | 1089 scope_info = Handle<ScopeInfo>(ScopeInfo::Empty(isolate)); |
1092 } else if (FullCodeGenerator::MakeCode(&info)) { | 1090 } else if (FullCodeGenerator::MakeCode(&info)) { |
1093 DCHECK(!info.code().is_null()); | 1091 DCHECK(!info.code().is_null()); |
1094 scope_info = ScopeInfo::Create(info.scope(), info.zone()); | 1092 scope_info = ScopeInfo::Create(info.scope(), info.zone()); |
1095 } else { | 1093 } else { |
1096 return Handle<SharedFunctionInfo>::null(); | 1094 return Handle<SharedFunctionInfo>::null(); |
1097 } | 1095 } |
1098 | 1096 |
1099 // Create a shared function info object. | 1097 // Create a shared function info object. |
1100 Handle<SharedFunctionInfo> result = factory->NewSharedFunctionInfo( | 1098 Handle<SharedFunctionInfo> result = factory->NewSharedFunctionInfo( |
1101 literal->name(), literal->materialized_literal_count(), | 1099 literal->name(), literal->materialized_literal_count(), literal->kind(), |
1102 literal->is_generator(), literal->is_arrow(), info.code(), scope_info, | 1100 info.code(), scope_info, info.feedback_vector()); |
1103 info.feedback_vector()); | |
1104 SetFunctionInfo(result, literal, false, script); | 1101 SetFunctionInfo(result, literal, false, script); |
1105 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); | 1102 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); |
1106 result->set_allows_lazy_compilation(allow_lazy); | 1103 result->set_allows_lazy_compilation(allow_lazy); |
1107 result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx); | 1104 result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx); |
1108 | 1105 |
1109 // Set the expected number of properties for instances and return | 1106 // Set the expected number of properties for instances and return |
1110 // the resulting function. | 1107 // the resulting function. |
1111 SetExpectedNofPropertiesFromEstimate(result, | 1108 SetExpectedNofPropertiesFromEstimate(result, |
1112 literal->expected_property_count()); | 1109 literal->expected_property_count()); |
1113 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone()); | 1110 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone()); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 AllowHandleDereference allow_deref; | 1377 AllowHandleDereference allow_deref; |
1381 bool tracing_on = info()->IsStub() | 1378 bool tracing_on = info()->IsStub() |
1382 ? FLAG_trace_hydrogen_stubs | 1379 ? FLAG_trace_hydrogen_stubs |
1383 : (FLAG_trace_hydrogen && | 1380 : (FLAG_trace_hydrogen && |
1384 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1381 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
1385 return (tracing_on && | 1382 return (tracing_on && |
1386 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1383 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
1387 } | 1384 } |
1388 | 1385 |
1389 } } // namespace v8::internal | 1386 } } // namespace v8::internal |
OLD | NEW |