blob: 81d350b24ed68acc9b693befdc3056fbd0da44e3 [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;
Albert Mingkun Yang0b4d1462018-11-29 13:25:35 +000043// When using the Concurrent Copying (CC) collector, if
44// `ART_USE_GENERATIONAL_CC` is true, enable generational collection by default,
45// i.e. use sticky-bit CC for minor collections and (full) CC for major
46// collections.
47// This default value can be overridden with the runtime option
48// `-Xgc:[no]generational_cc`.
Andreas Gampe5a0430d2019-01-04 14:33:57 -080049//
Albert Mingkun Yang0b4d1462018-11-29 13:25:35 +000050// TODO(b/67628039): Consider either:
51// - renaming this to a better descriptive name (e.g.
52// `ART_USE_GENERATIONAL_CC_BY_DEFAULT`); or
53// - removing `ART_USE_GENERATIONAL_CC` and having a fixed default value.
54// Any of these changes will require adjusting users of this preprocessor
55// directive and the corresponding build system environment variable (e.g. in
56// ART's continuous testing).
57#ifdef ART_USE_GENERATIONAL_CC
58static constexpr bool kEnableGenerationalCCByDefault = true;
Andreas Gampe5a0430d2019-01-04 14:33:57 -080059#else
Albert Mingkun Yang0b4d1462018-11-29 13:25:35 +000060static constexpr bool kEnableGenerationalCCByDefault = false;
Andreas Gampe5a0430d2019-01-04 14:33:57 -080061#endif
62
63// If true, enable the tlab allocator by default.
64#ifdef ART_USE_TLAB
65static constexpr bool kUseTlab = true;
66#else
67static constexpr bool kUseTlab = false;
68#endif
69
70// Kinds of tracing clocks.
71enum class TraceClockSource {
72 kThreadCpu,
73 kWall,
74 kDual, // Both wall and thread CPU clocks.
75};
76
77#if defined(__linux__)
78static constexpr TraceClockSource kDefaultTraceClockSource = TraceClockSource::kDual;
79#else
80static constexpr TraceClockSource kDefaultTraceClockSource = TraceClockSource::kWall;
81#endif
82
83static constexpr bool kDefaultMustRelocate = true;
84
85// Size of a heap reference.
86static constexpr size_t kHeapReferenceSize = sizeof(uint32_t);
87
88} // namespace art
89
90#endif // ART_RUNTIME_RUNTIME_GLOBALS_H_