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

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

Issue 1299653003: Migrate LongJumpScope to Thread. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Assert current isolate. Created 5 years, 4 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
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/precompiler.cc » ('j') | 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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 439
440 void Parser::SetPosition(intptr_t position) { 440 void Parser::SetPosition(intptr_t position) {
441 tokens_iterator_.SetCurrentPosition(position); 441 tokens_iterator_.SetCurrentPosition(position);
442 token_kind_ = Token::kILLEGAL; 442 token_kind_ = Token::kILLEGAL;
443 } 443 }
444 444
445 445
446 void Parser::ParseCompilationUnit(const Library& library, 446 void Parser::ParseCompilationUnit(const Library& library,
447 const Script& script) { 447 const Script& script) {
448 Thread* thread = Thread::Current(); 448 Thread* thread = Thread::Current();
449 ASSERT(thread->isolate()->long_jump_base()->IsSafeToJump()); 449 ASSERT(thread->long_jump_base()->IsSafeToJump());
450 CSTAT_TIMER_SCOPE(thread->isolate(), parser_timer); 450 CSTAT_TIMER_SCOPE(thread->isolate(), parser_timer);
451 VMTagScope tagScope(thread, VMTag::kCompileTopLevelTagId); 451 VMTagScope tagScope(thread, VMTag::kCompileTopLevelTagId);
452 Parser parser(script, library, 0); 452 Parser parser(script, library, 0);
453 parser.ParseTopLevel(); 453 parser.ParseTopLevel();
454 } 454 }
455 455
456 456
457 void Parser::ComputeCurrentToken() { 457 void Parser::ComputeCurrentToken() {
458 ASSERT(token_kind_ == Token::kILLEGAL); 458 ASSERT(token_kind_ == Token::kILLEGAL);
459 token_kind_ = tokens_iterator_.CurrentTokenKind(); 459 token_kind_ = tokens_iterator_.CurrentTokenKind();
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 fields(GrowableObjectArray::Handle(GrowableObjectArray::New())), 765 fields(GrowableObjectArray::Handle(GrowableObjectArray::New())),
766 functions(GrowableObjectArray::Handle(GrowableObjectArray::New())) { } 766 functions(GrowableObjectArray::Handle(GrowableObjectArray::New())) { }
767 767
768 GrowableObjectArray& fields; 768 GrowableObjectArray& fields;
769 GrowableObjectArray& functions; 769 GrowableObjectArray& functions;
770 }; 770 };
771 771
772 772
773 void Parser::ParseClass(const Class& cls) { 773 void Parser::ParseClass(const Class& cls) {
774 if (!cls.is_synthesized_class()) { 774 if (!cls.is_synthesized_class()) {
775 Isolate* isolate = Isolate::Current(); 775 Thread* thread = Thread::Current();
776 Isolate* isolate = thread->isolate();
777 Zone* zone = thread->zone();
776 CSTAT_TIMER_SCOPE(isolate, parser_timer); 778 CSTAT_TIMER_SCOPE(isolate, parser_timer);
777 ASSERT(isolate->long_jump_base()->IsSafeToJump()); 779 ASSERT(thread->long_jump_base()->IsSafeToJump());
778 const Script& script = Script::Handle(isolate, cls.script()); 780 const Script& script = Script::Handle(zone, cls.script());
779 const Library& lib = Library::Handle(isolate, cls.library()); 781 const Library& lib = Library::Handle(zone, cls.library());
780 Parser parser(script, lib, cls.token_pos()); 782 Parser parser(script, lib, cls.token_pos());
781 parser.ParseClassDefinition(cls); 783 parser.ParseClassDefinition(cls);
782 } else if (cls.is_enum_class()) { 784 } else if (cls.is_enum_class()) {
783 Isolate* isolate = Isolate::Current(); 785 Thread* thread = Thread::Current();
786 Isolate* isolate = thread->isolate();
787 Zone* zone = thread->zone();
784 CSTAT_TIMER_SCOPE(isolate, parser_timer); 788 CSTAT_TIMER_SCOPE(isolate, parser_timer);
785 ASSERT(isolate->long_jump_base()->IsSafeToJump()); 789 ASSERT(thread->long_jump_base()->IsSafeToJump());
786 const Script& script = Script::Handle(isolate, cls.script()); 790 const Script& script = Script::Handle(zone, cls.script());
787 const Library& lib = Library::Handle(isolate, cls.library()); 791 const Library& lib = Library::Handle(zone, cls.library());
788 Parser parser(script, lib, cls.token_pos()); 792 Parser parser(script, lib, cls.token_pos());
789 parser.ParseEnumDefinition(cls); 793 parser.ParseEnumDefinition(cls);
790 } 794 }
791 } 795 }
792 796
793 797
794 RawObject* Parser::ParseFunctionParameters(const Function& func) { 798 RawObject* Parser::ParseFunctionParameters(const Function& func) {
795 ASSERT(!func.IsNull()); 799 ASSERT(!func.IsNull());
796 Thread* thread = Thread::Current(); 800 Thread* thread = Thread::Current();
797 Isolate* isolate = thread->isolate(); 801 Isolate* isolate = thread->isolate();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 void Parser::ParseFunction(ParsedFunction* parsed_function) { 878 void Parser::ParseFunction(ParsedFunction* parsed_function) {
875 Thread* thread = parsed_function->thread(); 879 Thread* thread = parsed_function->thread();
876 ASSERT(thread == Thread::Current()); 880 ASSERT(thread == Thread::Current());
877 Isolate* isolate = thread->isolate(); 881 Isolate* isolate = thread->isolate();
878 Zone* zone = thread->zone(); 882 Zone* zone = thread->zone();
879 CSTAT_TIMER_SCOPE(isolate, parser_timer); 883 CSTAT_TIMER_SCOPE(isolate, parser_timer);
880 INC_STAT(isolate, num_functions_compiled, 1); 884 INC_STAT(isolate, num_functions_compiled, 1);
881 VMTagScope tagScope(thread, VMTag::kCompileParseFunctionTagId, 885 VMTagScope tagScope(thread, VMTag::kCompileParseFunctionTagId,
882 FLAG_profile_vm); 886 FLAG_profile_vm);
883 887
884 ASSERT(isolate->long_jump_base()->IsSafeToJump()); 888 ASSERT(thread->long_jump_base()->IsSafeToJump());
885 ASSERT(parsed_function != NULL); 889 ASSERT(parsed_function != NULL);
886 const Function& func = parsed_function->function(); 890 const Function& func = parsed_function->function();
887 const Script& script = Script::Handle(zone, func.script()); 891 const Script& script = Script::Handle(zone, func.script());
888 Parser parser(script, parsed_function, func.token_pos()); 892 Parser parser(script, parsed_function, func.token_pos());
889 SequenceNode* node_sequence = NULL; 893 SequenceNode* node_sequence = NULL;
890 Array& default_parameter_values = Array::ZoneHandle(zone, Array::null()); 894 Array& default_parameter_values = Array::ZoneHandle(zone, Array::null());
891 switch (func.kind()) { 895 switch (func.kind()) {
892 case RawFunction::kClosureFunction: 896 case RawFunction::kClosureFunction:
893 if (func.IsImplicitClosureFunction()) { 897 if (func.IsImplicitClosureFunction()) {
894 node_sequence = 898 node_sequence =
(...skipping 11136 matching lines...) Expand 10 before | Expand all | Expand 10 after
12031 constructor, arg_values, args_descriptor); 12035 constructor, arg_values, args_descriptor);
12032 } 12036 }
12033 if (result.IsError()) { 12037 if (result.IsError()) {
12034 // An exception may not occur in every parse attempt, i.e., the 12038 // An exception may not occur in every parse attempt, i.e., the
12035 // generated AST is not deterministic. Therefore mark the function as 12039 // generated AST is not deterministic. Therefore mark the function as
12036 // not optimizable. 12040 // not optimizable.
12037 current_function().SetIsOptimizable(false); 12041 current_function().SetIsOptimizable(false);
12038 if (result.IsUnhandledException()) { 12042 if (result.IsUnhandledException()) {
12039 return result.raw(); 12043 return result.raw();
12040 } else { 12044 } else {
12041 I->long_jump_base()->Jump(1, Error::Cast(result)); 12045 thread()->long_jump_base()->Jump(1, Error::Cast(result));
12042 UNREACHABLE(); 12046 UNREACHABLE();
12043 return Object::null(); 12047 return Object::null();
12044 } 12048 }
12045 } else { 12049 } else {
12046 if (constructor.IsFactory()) { 12050 if (constructor.IsFactory()) {
12047 // The factory method returns the allocated object. 12051 // The factory method returns the allocated object.
12048 instance ^= result.raw(); 12052 instance ^= result.raw();
12049 } 12053 }
12050 return TryCanonicalize(instance, TokenPos()); 12054 return TryCanonicalize(instance, TokenPos());
12051 } 12055 }
(...skipping 2144 matching lines...) Expand 10 before | Expand all | Expand 10 after
14196 void Parser::SkipQualIdent() { 14200 void Parser::SkipQualIdent() {
14197 ASSERT(IsIdentifier()); 14201 ASSERT(IsIdentifier());
14198 ConsumeToken(); 14202 ConsumeToken();
14199 if (CurrentToken() == Token::kPERIOD) { 14203 if (CurrentToken() == Token::kPERIOD) {
14200 ConsumeToken(); // Consume the kPERIOD token. 14204 ConsumeToken(); // Consume the kPERIOD token.
14201 ExpectIdentifier("identifier expected after '.'"); 14205 ExpectIdentifier("identifier expected after '.'");
14202 } 14206 }
14203 } 14207 }
14204 14208
14205 } // namespace dart 14209 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/precompiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698