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

Unified Diff: runtime/vm/compiler.cc

Issue 1877973002: Invalidate background compilation only if relevant fields were invalidated. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: sync Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/isolate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/compiler.cc
diff --git a/runtime/vm/compiler.cc b/runtime/vm/compiler.cc
index 9f3c02fe43aad0407ae535f5999b0f6d4bae07d4..7b49cc228c7e2ada1dca9f62b53ec7621399bbd7 100644
--- a/runtime/vm/compiler.cc
+++ b/runtime/vm/compiler.cc
@@ -381,6 +381,9 @@ class CompileParsedFunctionHelper : public ValueObject {
field_invalidation_gen_at_start_(isolate()->field_invalidation_gen()),
loading_invalidation_gen_at_start_(
isolate()->loading_invalidation_gen()) {
+ if (Compiler::IsBackgroundCompilation()) {
+ Isolate::Current()->ClearDisablingFieldList();
siva 2016/04/12 17:46:45 maybe use 'isolate()' here to avoid another Thread
srdjan 2016/04/12 19:47:18 Done in next CL.
+ }
}
bool Compile(CompilationPipeline* pipeline);
@@ -412,6 +415,28 @@ class CompileParsedFunctionHelper : public ValueObject {
};
+// Returns true if any of disabling fields is inside the guarded_fields.
+// The number of guarded_fields and disabling-fields is expected to be small
+// (less than 5).
+static bool CheckDisablingFields(
+ Thread* thread,
+ const ZoneGrowableArray<const Field*>& guarded_fields) {
+ Isolate* isolate = thread->isolate();
+ Zone* zone = thread->zone();
+ Field& field = Field::Handle(zone, isolate->GetDisablingField());
+ while (!field.IsNull()) {
+ for (intptr_t i = 0; i < guarded_fields.length(); i++) {
+ if (guarded_fields.At(i)->raw() == field.raw()) {
+ return true;
+ }
+ }
+ // Get next field.
+ field = isolate->GetDisablingField();
+ }
siva 2016/04/12 17:46:45 This loop acquires/release lock with every access
srdjan 2016/04/12 19:47:18 Since this occurs only while background compiler i
+ return false;
+}
+
+
void CompileParsedFunctionHelper::FinalizeCompilation(
Assembler* assembler,
FlowGraphCompiler* graph_compiler,
@@ -499,10 +524,15 @@ NOT_IN_PRODUCT(
if (!flow_graph->parsed_function().guarded_fields()->is_empty()) {
if (field_invalidation_gen_at_start() !=
isolate()->field_invalidation_gen()) {
- code_is_valid = false;
- if (trace_compiler) {
- THR_Print("--> FAIL: Field invalidation.");
- }
+ const ZoneGrowableArray<const Field*>& guarded_fields =
+ *flow_graph->parsed_function().guarded_fields();
+ bool field_conflict = CheckDisablingFields(thread(), guarded_fields);
+ if (field_conflict) {
+ code_is_valid = false;
+ if (trace_compiler) {
+ THR_Print("--> FAIL: Field invalidation.");
+ }
+ }
}
}
if (loading_invalidation_gen_at_start() !=
« no previous file with comments | « no previous file | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698