diff options
author | 2023-05-15 15:42:52 +0000 | |
---|---|---|
committer | 2023-05-16 12:26:06 +0000 | |
commit | d7d1e20dbd905ccbce5a669f512bb8fa564c2da6 (patch) | |
tree | 1569e79a287b4d684c74b722ace48ac4cb7623cf /compiler/optimizing/code_generator.h | |
parent | 9939267f44f997972a05d9cb9c12d97b73596bd8 (diff) |
Fix libart-compiler ReadBarrier flag init order
`gCompilerReadBarrierOption` from libart-compiler depends on
`gUseReadBarrier` from libart. When both libraries are static linked, the
initialization order is not guaranteed to be correct.
The fix is to replace `gCompilerReadBarrierOption` with a function, so
that it is initialized on first use.
Test: m test-art-host-gtest
Test: m test-art-host-gtest (with static linked libart/libart-compiler)
Bug: 186902856
Change-Id: I386c64c3bd7b42391623b5cded5757366d847b3f
Diffstat (limited to 'compiler/optimizing/code_generator.h')
-rw-r--r-- | compiler/optimizing/code_generator.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/optimizing/code_generator.h b/compiler/optimizing/code_generator.h index 9872efaa4a..576f363a67 100644 --- a/compiler/optimizing/code_generator.h +++ b/compiler/optimizing/code_generator.h @@ -59,8 +59,12 @@ static int32_t constexpr kPrimIntMax = 0x7fffffff; // Maximum value for a primitive long. static int64_t constexpr kPrimLongMax = INT64_C(0x7fffffffffffffff); -static const ReadBarrierOption gCompilerReadBarrierOption = - gUseReadBarrier ? kWithReadBarrier : kWithoutReadBarrier; +// Depending on configuration, `gUseReadBarrier` can be a static const variable. +// Static variable initialization order across different compilation units is not defined, +// so function is used instead of static variable `gCompilerReadBarrierOption`. +inline ReadBarrierOption GetCompilerReadBarrierOption() { + return gUseReadBarrier ? kWithReadBarrier : kWithoutReadBarrier; +} constexpr size_t status_lsb_position = SubtypeCheckBits::BitStructSizeOf(); constexpr size_t status_byte_offset = |