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/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/ast-expression-rewriter.h" | 9 #include "src/ast/ast-expression-rewriter.h" |
10 #include "src/ast/ast-expression-visitor.h" | 10 #include "src/ast/ast-expression-visitor.h" |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 FunctionLiteral* Parser::ParseProgram(Isolate* isolate, ParseInfo* info) { | 832 FunctionLiteral* Parser::ParseProgram(Isolate* isolate, ParseInfo* info) { |
833 // TODO(bmeurer): We temporarily need to pass allow_nesting = true here, | 833 // TODO(bmeurer): We temporarily need to pass allow_nesting = true here, |
834 // see comment for HistogramTimerScope class. | 834 // see comment for HistogramTimerScope class. |
835 | 835 |
836 // It's OK to use the Isolate & counters here, since this function is only | 836 // It's OK to use the Isolate & counters here, since this function is only |
837 // called in the main thread. | 837 // called in the main thread. |
838 DCHECK(parsing_on_main_thread_); | 838 DCHECK(parsing_on_main_thread_); |
839 | 839 |
840 HistogramTimerScope timer_scope(isolate->counters()->parse(), true); | 840 HistogramTimerScope timer_scope(isolate->counters()->parse(), true); |
841 RuntimeCallTimerScope runtime_timer(isolate, &RuntimeCallStats::Parse); | 841 RuntimeCallTimerScope runtime_timer(isolate, &RuntimeCallStats::Parse); |
842 TRACE_EVENT0("v8", "V8.Parse"); | 842 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.Parse"); |
843 Handle<String> source(String::cast(info->script()->source())); | 843 Handle<String> source(String::cast(info->script()->source())); |
844 isolate->counters()->total_parse_size()->Increment(source->length()); | 844 isolate->counters()->total_parse_size()->Increment(source->length()); |
845 base::ElapsedTimer timer; | 845 base::ElapsedTimer timer; |
846 if (FLAG_trace_parse) { | 846 if (FLAG_trace_parse) { |
847 timer.Start(); | 847 timer.Start(); |
848 } | 848 } |
849 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone()); | 849 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone()); |
850 | 850 |
851 // Initialize parser state. | 851 // Initialize parser state. |
852 CompleteParserRecorder recorder; | 852 CompleteParserRecorder recorder; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 return result; | 1000 return result; |
1001 } | 1001 } |
1002 | 1002 |
1003 | 1003 |
1004 FunctionLiteral* Parser::ParseLazy(Isolate* isolate, ParseInfo* info) { | 1004 FunctionLiteral* Parser::ParseLazy(Isolate* isolate, ParseInfo* info) { |
1005 // It's OK to use the Isolate & counters here, since this function is only | 1005 // It's OK to use the Isolate & counters here, since this function is only |
1006 // called in the main thread. | 1006 // called in the main thread. |
1007 DCHECK(parsing_on_main_thread_); | 1007 DCHECK(parsing_on_main_thread_); |
1008 RuntimeCallTimerScope runtime_timer(isolate, &RuntimeCallStats::ParseLazy); | 1008 RuntimeCallTimerScope runtime_timer(isolate, &RuntimeCallStats::ParseLazy); |
1009 HistogramTimerScope timer_scope(isolate->counters()->parse_lazy()); | 1009 HistogramTimerScope timer_scope(isolate->counters()->parse_lazy()); |
1010 TRACE_EVENT0("v8", "V8.ParseLazy"); | 1010 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.ParseLazy"); |
1011 Handle<String> source(String::cast(info->script()->source())); | 1011 Handle<String> source(String::cast(info->script()->source())); |
1012 isolate->counters()->total_parse_size()->Increment(source->length()); | 1012 isolate->counters()->total_parse_size()->Increment(source->length()); |
1013 base::ElapsedTimer timer; | 1013 base::ElapsedTimer timer; |
1014 if (FLAG_trace_parse) { | 1014 if (FLAG_trace_parse) { |
1015 timer.Start(); | 1015 timer.Start(); |
1016 } | 1016 } |
1017 Handle<SharedFunctionInfo> shared_info = info->shared_info(); | 1017 Handle<SharedFunctionInfo> shared_info = info->shared_info(); |
1018 | 1018 |
1019 // Initialize parser state. | 1019 // Initialize parser state. |
1020 source = String::Flatten(source); | 1020 source = String::Flatten(source); |
(...skipping 3866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4887 } | 4887 } |
4888 | 4888 |
4889 | 4889 |
4890 PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser( | 4890 PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser( |
4891 SingletonLogger* logger, Scanner::BookmarkScope* bookmark) { | 4891 SingletonLogger* logger, Scanner::BookmarkScope* bookmark) { |
4892 // This function may be called on a background thread too; record only the | 4892 // This function may be called on a background thread too; record only the |
4893 // main thread preparse times. | 4893 // main thread preparse times. |
4894 if (pre_parse_timer_ != NULL) { | 4894 if (pre_parse_timer_ != NULL) { |
4895 pre_parse_timer_->Start(); | 4895 pre_parse_timer_->Start(); |
4896 } | 4896 } |
4897 TRACE_EVENT0("v8", "V8.PreParse"); | 4897 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.PreParse"); |
4898 | 4898 |
4899 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); | 4899 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); |
4900 | 4900 |
4901 if (reusable_preparser_ == NULL) { | 4901 if (reusable_preparser_ == NULL) { |
4902 reusable_preparser_ = new PreParser(zone(), &scanner_, ast_value_factory(), | 4902 reusable_preparser_ = new PreParser(zone(), &scanner_, ast_value_factory(), |
4903 NULL, stack_limit_); | 4903 NULL, stack_limit_); |
4904 reusable_preparser_->set_allow_lazy(true); | 4904 reusable_preparser_->set_allow_lazy(true); |
4905 #define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name()); | 4905 #define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name()); |
4906 SET_ALLOW(natives); | 4906 SET_ALLOW(natives); |
4907 SET_ALLOW(harmony_do_expressions); | 4907 SET_ALLOW(harmony_do_expressions); |
(...skipping 2084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6992 | 6992 |
6993 #ifdef DEBUG | 6993 #ifdef DEBUG |
6994 void Parser::Print(AstNode* node) { | 6994 void Parser::Print(AstNode* node) { |
6995 ast_value_factory()->Internalize(Isolate::Current()); | 6995 ast_value_factory()->Internalize(Isolate::Current()); |
6996 node->Print(Isolate::Current()); | 6996 node->Print(Isolate::Current()); |
6997 } | 6997 } |
6998 #endif // DEBUG | 6998 #endif // DEBUG |
6999 | 6999 |
7000 } // namespace internal | 7000 } // namespace internal |
7001 } // namespace v8 | 7001 } // namespace v8 |
OLD | NEW |