ART: Write bit fields together in ComputeSpecialAccessorInfo().
Avoid function calls between storing individual bit fields
to allow the compiler (gcc/clang) to merge those writes
together. Valgrind then marks the memory as "defined" while
individual bit field writes would leave it "undefined" and
later trigger the valgrind error:
Conditional jump or move depends on uninitialised value(s)
on DCHECK()s using the bit fields.
Bug: 27552451
Change-Id: If6de5cbe231f99da0f974a0fc9a36c14e3dc071e
diff --git a/runtime/quick/inline_method_analyser.cc b/runtime/quick/inline_method_analyser.cc
index 9b10f2e..c7ccee2 100644
--- a/runtime/quick/inline_method_analyser.cc
+++ b/runtime/quick/inline_method_analyser.cc
@@ -744,9 +744,12 @@
return false;
}
DCHECK_GE(field->GetOffset().Int32Value(), 0);
+ // Do not interleave function calls with bit field writes to placate valgrind. Bug: 27552451.
+ uint32_t field_offset = field->GetOffset().Uint32Value();
+ bool is_volatile = field->IsVolatile();
result->field_idx = field_idx;
- result->field_offset = field->GetOffset().Int32Value();
- result->is_volatile = field->IsVolatile();
+ result->field_offset = field_offset;
+ result->is_volatile = is_volatile ? 1u : 0u;
return true;
}