Index: runtime/vm/parser.cc |
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc |
index 5220506471715723ec77beaa3932f6ef96c02b58..3e89badc93c04addb1777957561dbd15b1a2e474 100644 |
--- a/runtime/vm/parser.cc |
+++ b/runtime/vm/parser.cc |
@@ -491,6 +491,20 @@ void Parser::SetPosition(TokenPosition position) { |
} |
+// Set state and increments generational count so that thge background compiler |
+// can detect if loading/top-level-parsing occured during compilation. |
+class TopLevelParsingScope : public StackResource { |
+ public: |
+ explicit TopLevelParsingScope(Thread* thread) : StackResource(thread) { |
+ isolate()->IncrTopLevelParsingCount(); |
+ } |
+ ~TopLevelParsingScope() { |
+ isolate()->DecrTopLevelParsingCount(); |
+ isolate()->IncrLoadingInvalidationGen(); |
+ } |
+}; |
+ |
+ |
void Parser::ParseCompilationUnit(const Library& library, |
const Script& script) { |
Thread* thread = Thread::Current(); |
@@ -507,6 +521,7 @@ void Parser::ParseCompilationUnit(const Library& library, |
} |
#endif |
+ TopLevelParsingScope scope(thread); |
Parser parser(script, library, TokenPosition::kMinSource); |
parser.ParseTopLevel(); |
} |