Disable optimization of Atomic::LoadJavaData for x86 targets.
Bug: http://b/34287931
The latest compiler exposes an issue on the fugu target where optimizing
LoadJavaData triggers a boot loop. This change suppresses that issue by
disabling optimization of this routine only on x86 targets.
Test: Fugu and ARM validation of new compiler.
Change-Id: Id369968cdf9fc95a306fb785c68e95b0ffa0027d
diff --git a/runtime/atomic.h b/runtime/atomic.h
index e2a7259..090e56a 100644
--- a/runtime/atomic.h
+++ b/runtime/atomic.h
@@ -201,6 +201,11 @@
return this->load(std::memory_order_acquire);
}
+ // Disable optimizations for Atomic::LoadJavaData on x86 devices.
+ // Bug: http://b/34287931
+#if defined(DISABLE_LOAD_JAVA_DATA_OPTIMIZATIONS)
+ #pragma clang optimize off
+#endif
// Word tearing allowed, but may race.
// TODO: Optimize?
// There has been some discussion of eventually disallowing word
@@ -208,6 +213,9 @@
T LoadJavaData() const {
return this->load(std::memory_order_relaxed);
}
+#if defined(DISABLE_LOAD_JAVA_DATA_OPTIMIZATIONS)
+ #pragma clang optimize on
+#endif
// Load from memory with a total ordering.
// Corresponds exactly to a Java volatile load.
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 035cead..0abea9f 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -14,6 +14,12 @@
* limitations under the License.
*/
+// Disable optimizations for Atomic::LoadJavaData on x86 devices.
+// Bug: http://b/34287931
+#if defined(__i386__)
+#define DISABLE_LOAD_JAVA_DATA_OPTIMIZATIONS
+#endif
+
#include "class_linker.h"
#include <algorithm>