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() != |