summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Stelios Ioannou <stelios.ioannou@linaro.org> 2021-06-14 15:49:26 +0100
committer Stelios Ioannou <stelios.ioannou@linaro.org> 2021-06-22 10:04:04 +0100
commitd9696b79c886b9a23b4a77063fac4a3e03e0406d (patch)
tree9a850d015fcaca721e9309b777f2775202ae3672
parent59edf4b8f09d02c10fa87831573151c6b99c3149 (diff)
ART: Fix for no-opt debug (-O0) builds
Currently, the build process of debug builds with no optimization fails due to missing symbol definitions. For example, it throws errors like the following one: ld.lld: error: undefined symbol: art::gc::collector::MarkSweep::MarkStackTask<false>::kMaxSize This patch changes the missing symbols from constants to constant expressions as a way to fix those issues. The optimized builds get away with this issue because the values are optimized to be inlined and not referenced. The code at https://godbolt.org/z/3oYKoPzGj depicts similar behaviour. Additionally, there are comments describing why this issue occurs. Test: ART_DEBUG_OPT_FLAG="-O0" art/tools/buildbot-build.sh --host Change-Id: I66b5cfc885dfdfc82e3e4008b1e40fd68c19c999
-rw-r--r--compiler/utils/assembler.h2
-rw-r--r--compiler/utils/managed_register.h2
-rw-r--r--runtime/class_table.h2
-rw-r--r--runtime/gc/allocator/rosalloc.h8
-rw-r--r--runtime/gc/collector/mark_sweep.cc2
5 files changed, 8 insertions, 8 deletions
diff --git a/compiler/utils/assembler.h b/compiler/utils/assembler.h
index 67f38bcbe6..4b4fb14df6 100644
--- a/compiler/utils/assembler.h
+++ b/compiler/utils/assembler.h
@@ -250,7 +250,7 @@ class AssemblerBuffer {
// The limit is set to kMinimumGap bytes before the end of the data area.
// This leaves enough space for the longest possible instruction and allows
// for a single, fast space check per instruction.
- static const int kMinimumGap = 32;
+ static constexpr int kMinimumGap = 32;
ArenaAllocator* const allocator_;
uint8_t* contents_;
diff --git a/compiler/utils/managed_register.h b/compiler/utils/managed_register.h
index 2afdc046ff..a3b33ba94d 100644
--- a/compiler/utils/managed_register.h
+++ b/compiler/utils/managed_register.h
@@ -74,7 +74,7 @@ class ManagedRegister : public ValueObject {
explicit constexpr ManagedRegister(int reg_id) : id_(reg_id) { }
protected:
- static const int kNoRegister = -1;
+ static constexpr int kNoRegister = -1;
constexpr ManagedRegister() : id_(kNoRegister) { }
diff --git a/runtime/class_table.h b/runtime/class_table.h
index dfae1fd9e4..0ea62456f1 100644
--- a/runtime/class_table.h
+++ b/runtime/class_table.h
@@ -98,7 +98,7 @@ class ClassTable {
// Data contains the class pointer GcRoot as well as the low bits of the descriptor hash.
mutable Atomic<uint32_t> data_;
- static const uint32_t kHashMask = kObjectAlignment - 1;
+ static constexpr uint32_t kHashMask = kObjectAlignment - 1;
};
using DescriptorHashPair = std::pair<const char*, uint32_t>;
diff --git a/runtime/gc/allocator/rosalloc.h b/runtime/gc/allocator/rosalloc.h
index a5bfd8f5d7..9a09c88927 100644
--- a/runtime/gc/allocator/rosalloc.h
+++ b/runtime/gc/allocator/rosalloc.h
@@ -621,7 +621,7 @@ class RosAlloc {
// A memory allocation request larger than this size is treated as a large object and allocated
// at a page-granularity.
- static const size_t kLargeSizeThreshold = 2048;
+ static constexpr size_t kLargeSizeThreshold = 2048;
// If true, check that the returned memory is actually zero.
static constexpr bool kCheckZeroMemory = kIsDebugBuild;
@@ -662,14 +662,14 @@ class RosAlloc {
// We use thread-local runs for the size brackets whose indexes
// are less than this index. We use shared (current) runs for the rest.
// Sync this with the length of Thread::rosalloc_runs_.
- static const size_t kNumThreadLocalSizeBrackets = 16;
+ static constexpr size_t kNumThreadLocalSizeBrackets = 16;
static_assert(kNumThreadLocalSizeBrackets == kNumRosAllocThreadLocalSizeBracketsInThread,
"Mismatch between kNumThreadLocalSizeBrackets and "
"kNumRosAllocThreadLocalSizeBracketsInThread");
// The size of the largest bracket we use thread-local runs for.
// This should be equal to bracketSizes[kNumThreadLocalSizeBrackets - 1].
- static const size_t kMaxThreadLocalBracketSize = 128;
+ static constexpr size_t kMaxThreadLocalBracketSize = 128;
// We use regular (8 or 16-bytes increment) runs for the size brackets whose indexes are less than
// this index.
@@ -677,7 +677,7 @@ class RosAlloc {
// The size of the largest regular (8 or 16-byte increment) bracket. Non-regular brackets are the
// 1 KB and the 2 KB brackets. This should be equal to bracketSizes[kNumRegularSizeBrackets - 1].
- static const size_t kMaxRegularBracketSize = 512;
+ static constexpr size_t kMaxRegularBracketSize = 512;
// The bracket size increment for the thread-local brackets (<= kMaxThreadLocalBracketSize bytes).
static constexpr size_t kThreadLocalBracketQuantumSize = 8;
diff --git a/runtime/gc/collector/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc
index 9e5cb9c314..ebac36dc7b 100644
--- a/runtime/gc/collector/mark_sweep.cc
+++ b/runtime/gc/collector/mark_sweep.cc
@@ -688,7 +688,7 @@ class MarkSweep::MarkStackTask : public Task {
}
}
- static const size_t kMaxSize = 1 * KB;
+ static constexpr size_t kMaxSize = 1 * KB;
protected:
class MarkObjectParallelVisitor {