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" |
11 #include "src/ast/ast-literal-reindexer.h" | 11 #include "src/ast/ast-literal-reindexer.h" |
12 #include "src/ast/scopeinfo.h" | 12 #include "src/ast/scopeinfo.h" |
13 #include "src/bailout-reason.h" | 13 #include "src/bailout-reason.h" |
14 #include "src/base/platform/platform.h" | 14 #include "src/base/platform/platform.h" |
15 #include "src/bootstrapper.h" | 15 #include "src/bootstrapper.h" |
16 #include "src/char-predicates-inl.h" | 16 #include "src/char-predicates-inl.h" |
17 #include "src/codegen.h" | 17 #include "src/codegen.h" |
18 #include "src/compiler.h" | 18 #include "src/compiler.h" |
19 #include "src/messages.h" | 19 #include "src/messages.h" |
20 #include "src/parsing/parameter-initializer-rewriter.h" | 20 #include "src/parsing/parameter-initializer-rewriter.h" |
21 #include "src/parsing/parser-base.h" | 21 #include "src/parsing/parser-base.h" |
22 #include "src/parsing/rewriter.h" | 22 #include "src/parsing/rewriter.h" |
23 #include "src/parsing/scanner-character-streams.h" | 23 #include "src/parsing/scanner-character-streams.h" |
24 #include "src/runtime/runtime.h" | 24 #include "src/runtime/runtime.h" |
25 #include "src/string-stream.h" | 25 #include "src/string-stream.h" |
| 26 #include "src/tracing/trace-event.h" |
26 | 27 |
27 namespace v8 { | 28 namespace v8 { |
28 namespace internal { | 29 namespace internal { |
29 | 30 |
30 ScriptData::ScriptData(const byte* data, int length) | 31 ScriptData::ScriptData(const byte* data, int length) |
31 : owns_data_(false), rejected_(false), data_(data), length_(length) { | 32 : owns_data_(false), rejected_(false), data_(data), length_(length) { |
32 if (!IsAligned(reinterpret_cast<intptr_t>(data), kPointerAlignment)) { | 33 if (!IsAligned(reinterpret_cast<intptr_t>(data), kPointerAlignment)) { |
33 byte* copy = NewArray<byte>(length); | 34 byte* copy = NewArray<byte>(length); |
34 DCHECK(IsAligned(reinterpret_cast<intptr_t>(copy), kPointerAlignment)); | 35 DCHECK(IsAligned(reinterpret_cast<intptr_t>(copy), kPointerAlignment)); |
35 CopyBytes(copy, data, length); | 36 CopyBytes(copy, data, length); |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 | 789 |
789 FunctionLiteral* Parser::ParseProgram(Isolate* isolate, ParseInfo* info) { | 790 FunctionLiteral* Parser::ParseProgram(Isolate* isolate, ParseInfo* info) { |
790 // TODO(bmeurer): We temporarily need to pass allow_nesting = true here, | 791 // TODO(bmeurer): We temporarily need to pass allow_nesting = true here, |
791 // see comment for HistogramTimerScope class. | 792 // see comment for HistogramTimerScope class. |
792 | 793 |
793 // It's OK to use the Isolate & counters here, since this function is only | 794 // It's OK to use the Isolate & counters here, since this function is only |
794 // called in the main thread. | 795 // called in the main thread. |
795 DCHECK(parsing_on_main_thread_); | 796 DCHECK(parsing_on_main_thread_); |
796 | 797 |
797 HistogramTimerScope timer_scope(isolate->counters()->parse(), true); | 798 HistogramTimerScope timer_scope(isolate->counters()->parse(), true); |
| 799 TRACE_EVENT0("v8", "V8.Parse"); |
798 Handle<String> source(String::cast(info->script()->source())); | 800 Handle<String> source(String::cast(info->script()->source())); |
799 isolate->counters()->total_parse_size()->Increment(source->length()); | 801 isolate->counters()->total_parse_size()->Increment(source->length()); |
800 base::ElapsedTimer timer; | 802 base::ElapsedTimer timer; |
801 if (FLAG_trace_parse) { | 803 if (FLAG_trace_parse) { |
802 timer.Start(); | 804 timer.Start(); |
803 } | 805 } |
804 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone()); | 806 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone()); |
805 | 807 |
806 // Initialize parser state. | 808 // Initialize parser state. |
807 CompleteParserRecorder recorder; | 809 CompleteParserRecorder recorder; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 | 958 |
957 return result; | 959 return result; |
958 } | 960 } |
959 | 961 |
960 | 962 |
961 FunctionLiteral* Parser::ParseLazy(Isolate* isolate, ParseInfo* info) { | 963 FunctionLiteral* Parser::ParseLazy(Isolate* isolate, ParseInfo* info) { |
962 // It's OK to use the Isolate & counters here, since this function is only | 964 // It's OK to use the Isolate & counters here, since this function is only |
963 // called in the main thread. | 965 // called in the main thread. |
964 DCHECK(parsing_on_main_thread_); | 966 DCHECK(parsing_on_main_thread_); |
965 HistogramTimerScope timer_scope(isolate->counters()->parse_lazy()); | 967 HistogramTimerScope timer_scope(isolate->counters()->parse_lazy()); |
| 968 TRACE_EVENT0("v8", "V8.ParseLazy"); |
966 Handle<String> source(String::cast(info->script()->source())); | 969 Handle<String> source(String::cast(info->script()->source())); |
967 isolate->counters()->total_parse_size()->Increment(source->length()); | 970 isolate->counters()->total_parse_size()->Increment(source->length()); |
968 base::ElapsedTimer timer; | 971 base::ElapsedTimer timer; |
969 if (FLAG_trace_parse) { | 972 if (FLAG_trace_parse) { |
970 timer.Start(); | 973 timer.Start(); |
971 } | 974 } |
972 Handle<SharedFunctionInfo> shared_info = info->shared_info(); | 975 Handle<SharedFunctionInfo> shared_info = info->shared_info(); |
973 | 976 |
974 // Initialize parser state. | 977 // Initialize parser state. |
975 source = String::Flatten(source); | 978 source = String::Flatten(source); |
(...skipping 3854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4830 } | 4833 } |
4831 | 4834 |
4832 | 4835 |
4833 PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser( | 4836 PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser( |
4834 SingletonLogger* logger, Scanner::BookmarkScope* bookmark) { | 4837 SingletonLogger* logger, Scanner::BookmarkScope* bookmark) { |
4835 // This function may be called on a background thread too; record only the | 4838 // This function may be called on a background thread too; record only the |
4836 // main thread preparse times. | 4839 // main thread preparse times. |
4837 if (pre_parse_timer_ != NULL) { | 4840 if (pre_parse_timer_ != NULL) { |
4838 pre_parse_timer_->Start(); | 4841 pre_parse_timer_->Start(); |
4839 } | 4842 } |
| 4843 TRACE_EVENT0("v8", "V8.PreParse"); |
| 4844 |
4840 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); | 4845 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); |
4841 | 4846 |
4842 if (reusable_preparser_ == NULL) { | 4847 if (reusable_preparser_ == NULL) { |
4843 reusable_preparser_ = new PreParser(zone(), &scanner_, ast_value_factory(), | 4848 reusable_preparser_ = new PreParser(zone(), &scanner_, ast_value_factory(), |
4844 NULL, stack_limit_); | 4849 NULL, stack_limit_); |
4845 reusable_preparser_->set_allow_lazy(true); | 4850 reusable_preparser_->set_allow_lazy(true); |
4846 #define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name()); | 4851 #define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name()); |
4847 SET_ALLOW(natives); | 4852 SET_ALLOW(natives); |
4848 SET_ALLOW(harmony_sloppy); | 4853 SET_ALLOW(harmony_sloppy); |
4849 SET_ALLOW(harmony_sloppy_let); | 4854 SET_ALLOW(harmony_sloppy_let); |
(...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6399 | 6404 |
6400 statements->Add(get_return, zone); | 6405 statements->Add(get_return, zone); |
6401 statements->Add(check_return, zone); | 6406 statements->Add(check_return, zone); |
6402 statements->Add(call_return, zone); | 6407 statements->Add(call_return, zone); |
6403 statements->Add(validate_output, zone); | 6408 statements->Add(validate_output, zone); |
6404 } | 6409 } |
6405 | 6410 |
6406 | 6411 |
6407 } // namespace internal | 6412 } // namespace internal |
6408 } // namespace v8 | 6413 } // namespace v8 |
OLD | NEW |