globals.h revision 956af0f0cb05422e38c1d22cbef309d16b8a1a12
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
25namespace art {
26
27static constexpr size_t KB = 1024;
28static constexpr size_t MB = KB * KB;
29static constexpr size_t GB = KB * KB * KB;
30
31// Runtime sizes.
32static constexpr size_t kBitsPerByte = 8;
33static constexpr size_t kBitsPerByteLog2 = 3;
34static constexpr int kBitsPerIntPtrT = sizeof(intptr_t) * kBitsPerByte;
35
36// Required stack alignment
37static 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.
41static constexpr int kPageSize = 4096;
42
43// Required object alignment
44static constexpr size_t kObjectAlignment = 8;
45static 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)
49static constexpr bool kIsDebugBuild = false;
50#else
51static 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)
56static constexpr bool kIsTargetBuild = true;
57#else
58static constexpr bool kIsTargetBuild = false;
59#endif
60
61#if defined(ART_USE_OPTIMIZING_COMPILER)
62static constexpr bool kUseOptimizingCompiler = true;
63#else
64static constexpr bool kUseOptimizingCompiler = false;
65#endif
66
67// Garbage collector constants.
68static constexpr bool kMovingCollector = true;
69static constexpr bool kMarkCompactSupport = false && kMovingCollector;
70// True if we allow moving field arrays, this can cause complication with mark compact.
71static constexpr bool kMoveFieldArrays = !kMarkCompactSupport;
72// True if we allow moving classes.
73static constexpr bool kMovingClasses = !kMarkCompactSupport;
74// True if we allow moving fields.
75static constexpr bool kMovingFields = false;
76// True if we allow moving methods.
77static constexpr bool kMovingMethods = false;
78
79// If true, the quick compiler embeds class pointers in the compiled
80// code, if possible.
81static constexpr bool kEmbedClassInCode = true;
82
83#ifdef USE_BAKER_READ_BARRIER
84static constexpr bool kUseBakerReadBarrier = true;
85#else
86static constexpr bool kUseBakerReadBarrier = false;
87#endif
88
89#ifdef USE_BROOKS_READ_BARRIER
90static constexpr bool kUseBrooksReadBarrier = true;
91#else
92static constexpr bool kUseBrooksReadBarrier = false;
93#endif
94
95static constexpr bool kUseBakerOrBrooksReadBarrier = kUseBakerReadBarrier || kUseBrooksReadBarrier;
96
97// If true, references within the heap are poisoned (negated).
98#ifdef ART_HEAP_POISONING
99static constexpr bool kPoisonHeapReferences = true;
100#else
101static constexpr bool kPoisonHeapReferences = false;
102#endif
103
104// Kinds of tracing clocks.
105enum TraceClockSource {
106  kTraceClockSourceThreadCpu,
107  kTraceClockSourceWall,
108  kTraceClockSourceDual,  // Both wall and thread CPU clocks.
109};
110
111#if defined(HAVE_POSIX_CLOCKS)
112static constexpr TraceClockSource kDefaultTraceClockSource = kTraceClockSourceDual;
113#else
114static constexpr TraceClockSource kDefaultTraceClockSource = kTraceClockSourceWall;
115#endif
116
117static constexpr bool kDefaultMustRelocate = true;
118
119static constexpr bool kArm32QuickCodeUseSoftFloat = false;
120
121}  // namespace art
122
123#endif  // ART_RUNTIME_GLOBALS_H_
124