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

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

Issue 1834763004: Track loading happening in parallel with background compilation and abort compilation if necessary. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: d Created 4 years, 9 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
« runtime/vm/isolate.h ('K') | « runtime/vm/object.cc ('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 #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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 } 484 }
485 485
486 486
487 void Parser::SetPosition(TokenPosition position) { 487 void Parser::SetPosition(TokenPosition position) {
488 tokens_iterator_.SetCurrentPosition(position); 488 tokens_iterator_.SetCurrentPosition(position);
489 token_kind_ = Token::kILLEGAL; 489 token_kind_ = Token::kILLEGAL;
490 prev_token_pos_ = position; 490 prev_token_pos_ = position;
491 } 491 }
492 492
493 493
494 // Set state and increments generational count so that thge background compiler
495 // can detect if loading/top-level-parsing occured during compilation.
496 class TopLevelParsingScope : public ValueObject {
497 public:
498 explicit TopLevelParsingScope(Isolate* isolate) : isolate_(isolate) {
499 isolate_->set_top_level_parsing(true);
500 isolate_->IncrLoadingInvalidationGen();
501 }
502 ~TopLevelParsingScope() {
503 isolate_->set_top_level_parsing(false);
504 isolate_->IncrLoadingInvalidationGen();
505 }
siva 2016/03/28 17:20:14 Both constructor and destructor are incrementing t
srdjan 2016/03/28 19:54:54 I do not need to differentiate. The only informati
506
507 private:
508 Isolate* isolate_;
509 };
510
511
494 void Parser::ParseCompilationUnit(const Library& library, 512 void Parser::ParseCompilationUnit(const Library& library,
495 const Script& script) { 513 const Script& script) {
496 Thread* thread = Thread::Current(); 514 Thread* thread = Thread::Current();
497 ASSERT(thread->long_jump_base()->IsSafeToJump()); 515 ASSERT(thread->long_jump_base()->IsSafeToJump());
498 CSTAT_TIMER_SCOPE(thread, parser_timer); 516 CSTAT_TIMER_SCOPE(thread, parser_timer);
499 VMTagScope tagScope(thread, VMTag::kCompileTopLevelTagId); 517 VMTagScope tagScope(thread, VMTag::kCompileTopLevelTagId);
500 #ifndef PRODUCT 518 #ifndef PRODUCT
501 TimelineDurationScope tds(thread, 519 TimelineDurationScope tds(thread,
502 Timeline::GetCompilerStream(), 520 Timeline::GetCompilerStream(),
503 "CompileTopLevel"); 521 "CompileTopLevel");
504 if (tds.enabled()) { 522 if (tds.enabled()) {
505 tds.SetNumArguments(1); 523 tds.SetNumArguments(1);
506 tds.CopyArgument(0, "script", String::Handle(script.url()).ToCString()); 524 tds.CopyArgument(0, "script", String::Handle(script.url()).ToCString());
507 } 525 }
508 #endif 526 #endif
509 527
528 TopLevelParsingScope scope(thread->isolate());
510 Parser parser(script, library, TokenPosition::kMinSource); 529 Parser parser(script, library, TokenPosition::kMinSource);
511 parser.ParseTopLevel(); 530 parser.ParseTopLevel();
512 } 531 }
513 532
514 533
515 void Parser::ComputeCurrentToken() { 534 void Parser::ComputeCurrentToken() {
516 ASSERT(token_kind_ == Token::kILLEGAL); 535 ASSERT(token_kind_ == Token::kILLEGAL);
517 token_kind_ = tokens_iterator_.CurrentTokenKind(); 536 token_kind_ = tokens_iterator_.CurrentTokenKind();
518 if (token_kind_ == Token::kERROR) { 537 if (token_kind_ == Token::kERROR) {
519 ReportError(TokenPos(), "%s", CurrentLiteral()->ToCString()); 538 ReportError(TokenPos(), "%s", CurrentLiteral()->ToCString());
(...skipping 13927 matching lines...) Expand 10 before | Expand all | Expand 10 after
14447 const ArgumentListNode& function_args, 14466 const ArgumentListNode& function_args,
14448 const LocalVariable* temp_for_last_arg, 14467 const LocalVariable* temp_for_last_arg,
14449 bool is_super_invocation) { 14468 bool is_super_invocation) {
14450 UNREACHABLE(); 14469 UNREACHABLE();
14451 return NULL; 14470 return NULL;
14452 } 14471 }
14453 14472
14454 } // namespace dart 14473 } // namespace dart
14455 14474
14456 #endif // DART_PRECOMPILED_RUNTIME 14475 #endif // DART_PRECOMPILED_RUNTIME
OLDNEW
« runtime/vm/isolate.h ('K') | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698