blob: 793291a00834327ccbee04d23981c8bb194d3cb2 [file] [log] [blame]
Andreas Gampe5a0430d2019-01-04 14:33:57 -08001/*
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_RUNTIME_GLOBALS_H_
18#define ART_RUNTIME_RUNTIME_GLOBALS_H_
19
20#include "base/globals.h"
21
22namespace art {
23
24// Size of Dex virtual registers.
25static constexpr size_t kVRegSize = 4;
26
27// Returns whether the given memory offset can be used for generating
28// an implicit null check.
29static inline bool CanDoImplicitNullCheckOn(uintptr_t offset) {
30 return offset < kPageSize;
31}
32
33// Required object alignment
34static constexpr size_t kObjectAlignmentShift = 3;
35static constexpr size_t kObjectAlignment = 1u << kObjectAlignmentShift;
36static constexpr size_t kLargeObjectAlignment = kPageSize;
37
38// Garbage collector constants.
39static constexpr bool kMovingCollector = true;
40static constexpr bool kMarkCompactSupport = false && kMovingCollector;
41// True if we allow moving classes.
42static constexpr bool kMovingClasses = !kMarkCompactSupport;
43// If true, enable generational collection when using the Concurrent Copying
44// (CC) collector, i.e. use sticky-bit CC for minor collections and (full) CC
45// for major collections.
46//
47// Generational CC collection is currently only compatible with Baker read
48// barriers.
49#if defined(ART_USE_GENERATIONAL_CC) && defined(ART_READ_BARRIER_TYPE_IS_BAKER)
50static constexpr bool kEnableGenerationalConcurrentCopyingCollection = true;
51#else
52static constexpr bool kEnableGenerationalConcurrentCopyingCollection = false;
53#endif
54
55// If true, enable the tlab allocator by default.
56#ifdef ART_USE_TLAB
57static constexpr bool kUseTlab = true;
58#else
59static constexpr bool kUseTlab = false;
60#endif
61
62// Kinds of tracing clocks.
63enum class TraceClockSource {
64 kThreadCpu,
65 kWall,
66 kDual, // Both wall and thread CPU clocks.
67};
68
69#if defined(__linux__)
70static constexpr TraceClockSource kDefaultTraceClockSource = TraceClockSource::kDual;
71#else
72static constexpr TraceClockSource kDefaultTraceClockSource = TraceClockSource::kWall;
73#endif
74
75static constexpr bool kDefaultMustRelocate = true;
76
77// Size of a heap reference.
78static constexpr size_t kHeapReferenceSize = sizeof(uint32_t);
79
80} // namespace art
81
82#endif // ART_RUNTIME_RUNTIME_GLOBALS_H_