Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: runtime/vm/parser.cc

Issue 1127383008: Fix CompilerStats info (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« runtime/vm/object.cc ('K') | « runtime/vm/parser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/ast_transformer.h" 9 #include "vm/ast_transformer.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 } 437 }
438 438
439 439
440 void Parser::set_current_class(const Class& value) { 440 void Parser::set_current_class(const Class& value) {
441 current_class_ = value.raw(); 441 current_class_ = value.raw();
442 } 442 }
443 443
444 444
445 void Parser::SetPosition(intptr_t position) { 445 void Parser::SetPosition(intptr_t position) {
446 if (position < TokenPos() && position != 0) { 446 if (position < TokenPos() && position != 0) {
447 CompilerStats::num_tokens_rewind += (TokenPos() - position); 447 INC_STAT(I, num_tokens_rewind, (TokenPos() - position));
448 } 448 }
449 tokens_iterator_.SetCurrentPosition(position); 449 tokens_iterator_.SetCurrentPosition(position);
450 token_kind_ = Token::kILLEGAL; 450 token_kind_ = Token::kILLEGAL;
451 } 451 }
452 452
453 453
454 void Parser::ParseCompilationUnit(const Library& library, 454 void Parser::ParseCompilationUnit(const Library& library,
455 const Script& script) { 455 const Script& script) {
456 Isolate* isolate = Isolate::Current(); 456 Isolate* isolate = Isolate::Current();
457 ASSERT(isolate->long_jump_base()->IsSafeToJump()); 457 ASSERT(isolate->long_jump_base()->IsSafeToJump());
458 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); 458 TimerScope timer(FLAG_compiler_stats, &CSTAT_TIMER(parser_timer));
459 VMTagScope tagScope(isolate, VMTag::kCompileTopLevelTagId); 459 VMTagScope tagScope(isolate, VMTag::kCompileTopLevelTagId);
460 Parser parser(script, library, 0); 460 Parser parser(script, library, 0);
461 parser.ParseTopLevel(); 461 parser.ParseTopLevel();
462 } 462 }
463 463
464 464
465 void Parser::ComputeCurrentToken() { 465 void Parser::ComputeCurrentToken() {
466 ASSERT(token_kind_ == Token::kILLEGAL); 466 ASSERT(token_kind_ == Token::kILLEGAL);
467 token_kind_ = tokens_iterator_.CurrentTokenKind(); 467 token_kind_ = tokens_iterator_.CurrentTokenKind();
468 if (token_kind_ == Token::kERROR) { 468 if (token_kind_ == Token::kERROR) {
469 ReportError(TokenPos(), "%s", CurrentLiteral()->ToCString()); 469 ReportError(TokenPos(), "%s", CurrentLiteral()->ToCString());
470 } 470 }
471 } 471 }
472 472
473 473
474 Token::Kind Parser::LookaheadToken(int num_tokens) { 474 Token::Kind Parser::LookaheadToken(int num_tokens) {
475 CompilerStats::num_tokens_lookahead++; 475 INC_STAT(I, num_tokens_lookahead, 1);
476 CompilerStats::num_token_checks++; 476 INC_STAT(I, num_token_checks, 1);
477 return tokens_iterator_.LookaheadTokenKind(num_tokens); 477 return tokens_iterator_.LookaheadTokenKind(num_tokens);
478 } 478 }
479 479
480 480
481 String* Parser::CurrentLiteral() const { 481 String* Parser::CurrentLiteral() const {
482 String& result = 482 String& result =
483 String::ZoneHandle(Z, tokens_iterator_.CurrentLiteral()); 483 String::ZoneHandle(Z, tokens_iterator_.CurrentLiteral());
484 return &result; 484 return &result;
485 } 485 }
486 486
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 functions(GrowableObjectArray::Handle(GrowableObjectArray::New())) { } 767 functions(GrowableObjectArray::Handle(GrowableObjectArray::New())) { }
768 768
769 GrowableObjectArray& fields; 769 GrowableObjectArray& fields;
770 GrowableObjectArray& functions; 770 GrowableObjectArray& functions;
771 }; 771 };
772 772
773 773
774 void Parser::ParseClass(const Class& cls) { 774 void Parser::ParseClass(const Class& cls) {
775 if (!cls.is_synthesized_class()) { 775 if (!cls.is_synthesized_class()) {
776 Isolate* isolate = Isolate::Current(); 776 Isolate* isolate = Isolate::Current();
777 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); 777 TimerScope timer(FLAG_compiler_stats, &CSTAT_TIMER(parser_timer));
778 ASSERT(isolate->long_jump_base()->IsSafeToJump()); 778 ASSERT(isolate->long_jump_base()->IsSafeToJump());
779 const Script& script = Script::Handle(isolate, cls.script()); 779 const Script& script = Script::Handle(isolate, cls.script());
780 const Library& lib = Library::Handle(isolate, cls.library()); 780 const Library& lib = Library::Handle(isolate, cls.library());
781 Parser parser(script, lib, cls.token_pos()); 781 Parser parser(script, lib, cls.token_pos());
782 parser.ParseClassDefinition(cls); 782 parser.ParseClassDefinition(cls);
783 } else if (cls.is_enum_class()) { 783 } else if (cls.is_enum_class()) {
784 Isolate* isolate = Isolate::Current(); 784 Isolate* isolate = Isolate::Current();
785 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); 785 TimerScope timer(FLAG_compiler_stats, &CSTAT_TIMER(parser_timer));
786 ASSERT(isolate->long_jump_base()->IsSafeToJump()); 786 ASSERT(isolate->long_jump_base()->IsSafeToJump());
787 const Script& script = Script::Handle(isolate, cls.script()); 787 const Script& script = Script::Handle(isolate, cls.script());
788 const Library& lib = Library::Handle(isolate, cls.library()); 788 const Library& lib = Library::Handle(isolate, cls.library());
789 Parser parser(script, lib, cls.token_pos()); 789 Parser parser(script, lib, cls.token_pos());
790 parser.ParseEnumDefinition(cls); 790 parser.ParseEnumDefinition(cls);
791 } 791 }
792 } 792 }
793 793
794 794
795 RawObject* Parser::ParseFunctionParameters(const Function& func) { 795 RawObject* Parser::ParseFunctionParameters(const Function& func) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 return error.raw(); 836 return error.raw();
837 } 837 }
838 UNREACHABLE(); 838 UNREACHABLE();
839 return Object::null(); 839 return Object::null();
840 } 840 }
841 841
842 842
843 void Parser::ParseFunction(ParsedFunction* parsed_function) { 843 void Parser::ParseFunction(ParsedFunction* parsed_function) {
844 Isolate* isolate = parsed_function->isolate(); 844 Isolate* isolate = parsed_function->isolate();
845 Zone* zone = parsed_function->zone(); 845 Zone* zone = parsed_function->zone();
846 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); 846 TimerScope timer(FLAG_compiler_stats, &CSTAT_TIMER(parser_timer));
847 CompilerStats::num_functions_compiled++; 847 INC_STAT(isolate, num_functions_compiled, 1);
848 ASSERT(isolate->long_jump_base()->IsSafeToJump()); 848 ASSERT(isolate->long_jump_base()->IsSafeToJump());
849 ASSERT(parsed_function != NULL); 849 ASSERT(parsed_function != NULL);
850 const Function& func = parsed_function->function(); 850 const Function& func = parsed_function->function();
851 const Script& script = Script::Handle(zone, func.script()); 851 const Script& script = Script::Handle(zone, func.script());
852 Parser parser(script, parsed_function, func.token_pos()); 852 Parser parser(script, parsed_function, func.token_pos());
853 SequenceNode* node_sequence = NULL; 853 SequenceNode* node_sequence = NULL;
854 Array& default_parameter_values = Array::ZoneHandle(zone, Array::null()); 854 Array& default_parameter_values = Array::ZoneHandle(zone, Array::null());
855 switch (func.kind()) { 855 switch (func.kind()) {
856 case RawFunction::kClosureFunction: 856 case RawFunction::kClosureFunction:
857 if (func.IsImplicitClosureFunction()) { 857 if (func.IsImplicitClosureFunction()) {
(...skipping 17 matching lines...) Expand all
875 case RawFunction::kImplicitGetter: 875 case RawFunction::kImplicitGetter:
876 ASSERT(!func.is_static()); 876 ASSERT(!func.is_static());
877 node_sequence = parser.ParseInstanceGetter(func); 877 node_sequence = parser.ParseInstanceGetter(func);
878 break; 878 break;
879 case RawFunction::kImplicitSetter: 879 case RawFunction::kImplicitSetter:
880 ASSERT(!func.is_static()); 880 ASSERT(!func.is_static());
881 node_sequence = parser.ParseInstanceSetter(func); 881 node_sequence = parser.ParseInstanceSetter(func);
882 break; 882 break;
883 case RawFunction::kImplicitStaticFinalGetter: 883 case RawFunction::kImplicitStaticFinalGetter:
884 node_sequence = parser.ParseStaticFinalGetter(func); 884 node_sequence = parser.ParseStaticFinalGetter(func);
885 CompilerStats::num_implicit_final_getters++; 885 INC_STAT(isolate, num_implicit_final_getters, 1);
886 break; 886 break;
887 case RawFunction::kMethodExtractor: 887 case RawFunction::kMethodExtractor:
888 node_sequence = parser.ParseMethodExtractor(func); 888 node_sequence = parser.ParseMethodExtractor(func);
889 break; 889 break;
890 case RawFunction::kNoSuchMethodDispatcher: 890 case RawFunction::kNoSuchMethodDispatcher:
891 node_sequence = 891 node_sequence =
892 parser.ParseNoSuchMethodDispatcher(func, &default_parameter_values); 892 parser.ParseNoSuchMethodDispatcher(func, &default_parameter_values);
893 break; 893 break;
894 case RawFunction::kInvokeFieldDispatcher: 894 case RawFunction::kInvokeFieldDispatcher:
895 node_sequence = 895 node_sequence =
(...skipping 3589 matching lines...) Expand 10 before | Expand all | Expand 10 after
4485 } else { 4485 } else {
4486 CheckToken(Token::kLBRACE); 4486 CheckToken(Token::kLBRACE);
4487 SkipBlock(); 4487 SkipBlock();
4488 ExpectToken(Token::kRBRACE); 4488 ExpectToken(Token::kRBRACE);
4489 } 4489 }
4490 } 4490 }
4491 4491
4492 4492
4493 void Parser::ParseClassDefinition(const Class& cls) { 4493 void Parser::ParseClassDefinition(const Class& cls) {
4494 TRACE_PARSER("ParseClassDefinition"); 4494 TRACE_PARSER("ParseClassDefinition");
4495 CompilerStats::num_classes_compiled++; 4495 INC_STAT(I, num_classes_compiled, 1);
4496 set_current_class(cls); 4496 set_current_class(cls);
4497 is_top_level_ = true; 4497 is_top_level_ = true;
4498 String& class_name = String::Handle(Z, cls.Name()); 4498 String& class_name = String::Handle(Z, cls.Name());
4499 SkipMetadata(); 4499 SkipMetadata();
4500 if (is_patch_source() && 4500 if (is_patch_source() &&
4501 (CurrentToken() == Token::kIDENT) && 4501 (CurrentToken() == Token::kIDENT) &&
4502 CurrentLiteral()->Equals("patch")) { 4502 CurrentLiteral()->Equals("patch")) {
4503 ConsumeToken(); 4503 ConsumeToken();
4504 } else if (CurrentToken() == Token::kABSTRACT) { 4504 } else if (CurrentToken() == Token::kABSTRACT) {
4505 ConsumeToken(); 4505 ConsumeToken();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4545 Error& error = Error::Handle(Z); 4545 Error& error = Error::Handle(Z);
4546 if (!orig_class.ApplyPatch(cls, &error)) { 4546 if (!orig_class.ApplyPatch(cls, &error)) {
4547 Report::LongJumpF(error, script_, class_pos, "applying patch failed"); 4547 Report::LongJumpF(error, script_, class_pos, "applying patch failed");
4548 } 4548 }
4549 } 4549 }
4550 } 4550 }
4551 4551
4552 4552
4553 void Parser::ParseEnumDefinition(const Class& cls) { 4553 void Parser::ParseEnumDefinition(const Class& cls) {
4554 TRACE_PARSER("ParseEnumDefinition"); 4554 TRACE_PARSER("ParseEnumDefinition");
4555 CompilerStats::num_classes_compiled++; 4555 INC_STAT(I, num_classes_compiled, 1);
4556 4556
4557 SkipMetadata(); 4557 SkipMetadata();
4558 ExpectToken(Token::kENUM); 4558 ExpectToken(Token::kENUM);
4559 4559
4560 const String& enum_name = String::Handle(Z, cls.Name()); 4560 const String& enum_name = String::Handle(Z, cls.Name());
4561 ClassDesc enum_members(cls, enum_name, false, cls.token_pos()); 4561 ClassDesc enum_members(cls, enum_name, false, cls.token_pos());
4562 4562
4563 // Add instance field 'final int index'. 4563 // Add instance field 'final int index'.
4564 Field& index_field = Field::ZoneHandle(Z); 4564 Field& index_field = Field::ZoneHandle(Z);
4565 const Type& int_type = Type::Handle(Z, Type::IntType()); 4565 const Type& int_type = Type::Handle(Z, Type::IntType());
(...skipping 8912 matching lines...) Expand 10 before | Expand all | Expand 10 after
13478 void Parser::SkipQualIdent() { 13478 void Parser::SkipQualIdent() {
13479 ASSERT(IsIdentifier()); 13479 ASSERT(IsIdentifier());
13480 ConsumeToken(); 13480 ConsumeToken();
13481 if (CurrentToken() == Token::kPERIOD) { 13481 if (CurrentToken() == Token::kPERIOD) {
13482 ConsumeToken(); // Consume the kPERIOD token. 13482 ConsumeToken(); // Consume the kPERIOD token.
13483 ExpectIdentifier("identifier expected after '.'"); 13483 ExpectIdentifier("identifier expected after '.'");
13484 } 13484 }
13485 } 13485 }
13486 13486
13487 } // namespace dart 13487 } // namespace dart
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698