1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ART_RUNTIME_GLOBALS_H_ 18 #define ART_RUNTIME_GLOBALS_H_ 19 20 #include <stddef.h> 21 #include <stdint.h> 22 #include "read_barrier_c.h" 23 #include "read_barrier_option.h" 24 25 namespace art { 26 27 static constexpr size_t KB = 1024; 28 static constexpr size_t MB = KB * KB; 29 static constexpr size_t GB = KB * KB * KB; 30 31 // Runtime sizes. 32 static constexpr size_t kBitsPerByte = 8; 33 static constexpr size_t kBitsPerByteLog2 = 3; 34 static constexpr int kBitsPerIntPtrT = sizeof(intptr_t) * kBitsPerByte; 35 36 // Required stack alignment 37 static constexpr size_t kStackAlignment = 16; 38 39 // System page size. We check this against sysconf(_SC_PAGE_SIZE) at runtime, but use a simple 40 // compile-time constant so the compiler can generate better code. 41 static constexpr int kPageSize = 4096; 42 43 // Required object alignment 44 static constexpr size_t kObjectAlignment = 8; 45 static constexpr size_t kLargeObjectAlignment = kPageSize; 46 47 // Whether or not this is a debug build. Useful in conditionals where NDEBUG isn't. 48 #if defined(NDEBUG) 49 static constexpr bool kIsDebugBuild = false; 50 #else 51 static constexpr bool kIsDebugBuild = true; 52 #endif 53 54 // Whether or not this is a target (vs host) build. Useful in conditionals where ART_TARGET isn't. 55 #if defined(ART_TARGET) 56 static constexpr bool kIsTargetBuild = true; 57 #else 58 static constexpr bool kIsTargetBuild = false; 59 #endif 60 61 // Garbage collector constants. 62 static constexpr bool kMovingCollector = true; 63 static constexpr bool kMarkCompactSupport = false && kMovingCollector; 64 // True if we allow moving classes. 65 static constexpr bool kMovingClasses = !kMarkCompactSupport; 66 67 // If true, the quick compiler embeds class pointers in the compiled 68 // code, if possible. 69 static constexpr bool kEmbedClassInCode = true; 70 71 #ifdef USE_BAKER_READ_BARRIER 72 static constexpr bool kUseBakerReadBarrier = true; 73 #else 74 static constexpr bool kUseBakerReadBarrier = false; 75 #endif 76 77 #ifdef USE_BROOKS_READ_BARRIER 78 static constexpr bool kUseBrooksReadBarrier = true; 79 #else 80 static constexpr bool kUseBrooksReadBarrier = false; 81 #endif 82 83 #ifdef USE_TABLE_LOOKUP_READ_BARRIER 84 static constexpr bool kUseTableLookupReadBarrier = true; 85 #else 86 static constexpr bool kUseTableLookupReadBarrier = false; 87 #endif 88 89 static constexpr bool kUseBakerOrBrooksReadBarrier = kUseBakerReadBarrier || kUseBrooksReadBarrier; 90 static constexpr bool kUseReadBarrier = 91 kUseBakerReadBarrier || kUseBrooksReadBarrier || kUseTableLookupReadBarrier; 92 93 // Debugging flag that forces the generation of read barriers, but 94 // does not trigger the use of the concurrent copying GC. 95 // 96 // TODO: Remove this flag when the read barriers compiler 97 // instrumentation is completed. 98 static constexpr bool kForceReadBarrier = false; 99 // TODO: Likewise, remove this flag when kForceReadBarrier is removed 100 // and replace it with kUseReadBarrier. 101 static constexpr bool kEmitCompilerReadBarrier = kForceReadBarrier || kUseReadBarrier; 102 103 // If true, references within the heap are poisoned (negated). 104 #ifdef USE_HEAP_POISONING 105 static constexpr bool kPoisonHeapReferences = true; 106 #else 107 static constexpr bool kPoisonHeapReferences = false; 108 #endif 109 110 // If true, enable the tlab allocator by default. 111 #ifdef ART_USE_TLAB 112 static constexpr bool kUseTlab = true; 113 #else 114 static constexpr bool kUseTlab = false; 115 #endif 116 117 // Kinds of tracing clocks. 118 enum class TraceClockSource { 119 kThreadCpu, 120 kWall, 121 kDual, // Both wall and thread CPU clocks. 122 }; 123 124 #if defined(__linux__) 125 static constexpr TraceClockSource kDefaultTraceClockSource = TraceClockSource::kDual; 126 #else 127 static constexpr TraceClockSource kDefaultTraceClockSource = TraceClockSource::kWall; 128 #endif 129 130 static constexpr bool kDefaultMustRelocate = true; 131 132 static constexpr bool kArm32QuickCodeUseSoftFloat = false; 133 134 } // namespace art 135 136 #endif // ART_RUNTIME_GLOBALS_H_ 137