| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/parser.h" | 5 #include "vm/parser.h" |
| 6 #include "vm/flags.h" | 6 #include "vm/flags.h" |
| 7 | 7 |
| 8 #ifndef DART_PRECOMPILED_RUNTIME | 8 #ifndef DART_PRECOMPILED_RUNTIME |
| 9 | 9 |
| 10 #include "lib/invocation_mirror.h" | 10 #include "lib/invocation_mirror.h" |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 prev_token_pos_ = position; | 483 prev_token_pos_ = position; |
| 484 } | 484 } |
| 485 | 485 |
| 486 | 486 |
| 487 void Parser::ParseCompilationUnit(const Library& library, | 487 void Parser::ParseCompilationUnit(const Library& library, |
| 488 const Script& script) { | 488 const Script& script) { |
| 489 Thread* thread = Thread::Current(); | 489 Thread* thread = Thread::Current(); |
| 490 ASSERT(thread->long_jump_base()->IsSafeToJump()); | 490 ASSERT(thread->long_jump_base()->IsSafeToJump()); |
| 491 CSTAT_TIMER_SCOPE(thread, parser_timer); | 491 CSTAT_TIMER_SCOPE(thread, parser_timer); |
| 492 VMTagScope tagScope(thread, VMTag::kCompileTopLevelTagId); | 492 VMTagScope tagScope(thread, VMTag::kCompileTopLevelTagId); |
| 493 #ifndef PRODUCT |
| 493 TimelineDurationScope tds(thread, | 494 TimelineDurationScope tds(thread, |
| 494 thread->isolate()->GetCompilerStream(), | 495 thread->isolate()->GetCompilerStream(), |
| 495 "CompileTopLevel"); | 496 "CompileTopLevel"); |
| 496 if (tds.enabled()) { | 497 if (tds.enabled()) { |
| 497 tds.SetNumArguments(1); | 498 tds.SetNumArguments(1); |
| 498 tds.CopyArgument(0, "script", String::Handle(script.url()).ToCString()); | 499 tds.CopyArgument(0, "script", String::Handle(script.url()).ToCString()); |
| 499 } | 500 } |
| 501 #endif |
| 500 | 502 |
| 501 Parser parser(script, library, TokenPosition::kMinSource); | 503 Parser parser(script, library, TokenPosition::kMinSource); |
| 502 parser.ParseTopLevel(); | 504 parser.ParseTopLevel(); |
| 503 } | 505 } |
| 504 | 506 |
| 505 | 507 |
| 506 void Parser::ComputeCurrentToken() { | 508 void Parser::ComputeCurrentToken() { |
| 507 ASSERT(token_kind_ == Token::kILLEGAL); | 509 ASSERT(token_kind_ == Token::kILLEGAL); |
| 508 token_kind_ = tokens_iterator_.CurrentTokenKind(); | 510 token_kind_ = tokens_iterator_.CurrentTokenKind(); |
| 509 if (token_kind_ == Token::kERROR) { | 511 if (token_kind_ == Token::kERROR) { |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 Zone* zone_; | 849 Zone* zone_; |
| 848 GrowableArray<const Field*> fields_; | 850 GrowableArray<const Field*> fields_; |
| 849 GrowableArray<const Function*> functions_; | 851 GrowableArray<const Function*> functions_; |
| 850 }; | 852 }; |
| 851 | 853 |
| 852 | 854 |
| 853 void Parser::ParseClass(const Class& cls) { | 855 void Parser::ParseClass(const Class& cls) { |
| 854 Thread* thread = Thread::Current(); | 856 Thread* thread = Thread::Current(); |
| 855 Zone* zone = thread->zone(); | 857 Zone* zone = thread->zone(); |
| 856 const int64_t num_tokes_before = STAT_VALUE(thread, num_tokens_consumed); | 858 const int64_t num_tokes_before = STAT_VALUE(thread, num_tokens_consumed); |
| 859 #ifndef PRODUCT |
| 857 TimelineDurationScope tds(thread, | 860 TimelineDurationScope tds(thread, |
| 858 thread->isolate()->GetCompilerStream(), | 861 thread->isolate()->GetCompilerStream(), |
| 859 "ParseClass"); | 862 "ParseClass"); |
| 860 if (tds.enabled()) { | 863 if (tds.enabled()) { |
| 861 tds.SetNumArguments(1); | 864 tds.SetNumArguments(1); |
| 862 tds.CopyArgument(0, "class", String::Handle(cls.Name()).ToCString()); | 865 tds.CopyArgument(0, "class", String::Handle(cls.Name()).ToCString()); |
| 863 } | 866 } |
| 867 #endif |
| 864 if (!cls.is_synthesized_class()) { | 868 if (!cls.is_synthesized_class()) { |
| 865 ASSERT(thread->long_jump_base()->IsSafeToJump()); | 869 ASSERT(thread->long_jump_base()->IsSafeToJump()); |
| 866 CSTAT_TIMER_SCOPE(thread, parser_timer); | 870 CSTAT_TIMER_SCOPE(thread, parser_timer); |
| 867 const Script& script = Script::Handle(zone, cls.script()); | 871 const Script& script = Script::Handle(zone, cls.script()); |
| 868 const Library& lib = Library::Handle(zone, cls.library()); | 872 const Library& lib = Library::Handle(zone, cls.library()); |
| 869 Parser parser(script, lib, cls.token_pos()); | 873 Parser parser(script, lib, cls.token_pos()); |
| 870 parser.ParseClassDefinition(cls); | 874 parser.ParseClassDefinition(cls); |
| 871 } else if (cls.is_enum_class()) { | 875 } else if (cls.is_enum_class()) { |
| 872 ASSERT(thread->long_jump_base()->IsSafeToJump()); | 876 ASSERT(thread->long_jump_base()->IsSafeToJump()); |
| 873 CSTAT_TIMER_SCOPE(thread, parser_timer); | 877 CSTAT_TIMER_SCOPE(thread, parser_timer); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 | 966 |
| 963 | 967 |
| 964 void Parser::ParseFunction(ParsedFunction* parsed_function) { | 968 void Parser::ParseFunction(ParsedFunction* parsed_function) { |
| 965 Thread* thread = parsed_function->thread(); | 969 Thread* thread = parsed_function->thread(); |
| 966 ASSERT(thread == Thread::Current()); | 970 ASSERT(thread == Thread::Current()); |
| 967 Zone* zone = thread->zone(); | 971 Zone* zone = thread->zone(); |
| 968 CSTAT_TIMER_SCOPE(thread, parser_timer); | 972 CSTAT_TIMER_SCOPE(thread, parser_timer); |
| 969 INC_STAT(thread, num_functions_parsed, 1); | 973 INC_STAT(thread, num_functions_parsed, 1); |
| 970 VMTagScope tagScope(thread, VMTag::kCompileParseFunctionTagId, | 974 VMTagScope tagScope(thread, VMTag::kCompileParseFunctionTagId, |
| 971 FLAG_profile_vm); | 975 FLAG_profile_vm); |
| 976 #ifndef PRODUCT |
| 972 TimelineDurationScope tds(thread, | 977 TimelineDurationScope tds(thread, |
| 973 thread->isolate()->GetCompilerStream(), | 978 thread->isolate()->GetCompilerStream(), |
| 974 "ParseFunction"); | 979 "ParseFunction"); |
| 980 #endif // !PRODUCT |
| 975 ASSERT(thread->long_jump_base()->IsSafeToJump()); | 981 ASSERT(thread->long_jump_base()->IsSafeToJump()); |
| 976 ASSERT(parsed_function != NULL); | 982 ASSERT(parsed_function != NULL); |
| 977 const Function& func = parsed_function->function(); | 983 const Function& func = parsed_function->function(); |
| 978 const Script& script = Script::Handle(zone, func.script()); | 984 const Script& script = Script::Handle(zone, func.script()); |
| 979 Parser parser(script, parsed_function, func.token_pos()); | 985 Parser parser(script, parsed_function, func.token_pos()); |
| 986 #ifndef PRODUCT |
| 980 if (tds.enabled()) { | 987 if (tds.enabled()) { |
| 981 tds.SetNumArguments(1); | 988 tds.SetNumArguments(1); |
| 982 tds.CopyArgument(0, "function", String::Handle(func.name()).ToCString()); | 989 tds.CopyArgument(0, "function", String::Handle(func.name()).ToCString()); |
| 983 } | 990 } |
| 991 #endif // !PRODUCT |
| 984 SequenceNode* node_sequence = NULL; | 992 SequenceNode* node_sequence = NULL; |
| 985 switch (func.kind()) { | 993 switch (func.kind()) { |
| 986 case RawFunction::kClosureFunction: | 994 case RawFunction::kClosureFunction: |
| 987 if (func.IsImplicitClosureFunction()) { | 995 if (func.IsImplicitClosureFunction()) { |
| 988 node_sequence = parser.ParseImplicitClosure(func); | 996 node_sequence = parser.ParseImplicitClosure(func); |
| 989 break; | 997 break; |
| 990 } | 998 } |
| 991 if (func.IsConstructorClosureFunction()) { | 999 if (func.IsConstructorClosureFunction()) { |
| 992 node_sequence = parser.ParseConstructorClosure(func); | 1000 node_sequence = parser.ParseConstructorClosure(func); |
| 993 break; | 1001 break; |
| (...skipping 13412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14406 const ArgumentListNode& function_args, | 14414 const ArgumentListNode& function_args, |
| 14407 const LocalVariable* temp_for_last_arg, | 14415 const LocalVariable* temp_for_last_arg, |
| 14408 bool is_super_invocation) { | 14416 bool is_super_invocation) { |
| 14409 UNREACHABLE(); | 14417 UNREACHABLE(); |
| 14410 return NULL; | 14418 return NULL; |
| 14411 } | 14419 } |
| 14412 | 14420 |
| 14413 } // namespace dart | 14421 } // namespace dart |
| 14414 | 14422 |
| 14415 #endif // DART_PRECOMPILED_RUNTIME | 14423 #endif // DART_PRECOMPILED_RUNTIME |
| OLD | NEW |