blob: 4d33196c9847d44857ca65fbf2006a04be7cc597 [file] [log] [blame]
Elliott Hughes2faa5f12012-01-30 14:42:07 -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 */
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070016
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_GLOBALS_H_
18#define ART_RUNTIME_GLOBALS_H_
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070019
Carl Shapiro1fb86202011-06-27 17:43:13 -070020#include <stddef.h>
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070021#include <stdint.h>
Hiroshi Yamauchi800ac2d2014-04-02 17:32:54 -070022#include "read_barrier_c.h"
Hiroshi Yamauchi6e83c172014-05-01 21:25:41 -070023#include "read_barrier_option.h"
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070024
Carl Shapiro6b6b5f02011-06-21 15:05:09 -070025namespace art {
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070026
Mathieu Chartier50482232013-11-21 11:48:14 -080027static constexpr size_t KB = 1024;
28static constexpr size_t MB = KB * KB;
29static constexpr size_t GB = KB * KB * KB;
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070030
Andreas Gampe242947d2014-04-03 13:31:32 -070031// Runtime sizes.
Mathieu Chartier50482232013-11-21 11:48:14 -080032static constexpr size_t kBitsPerByte = 8;
33static constexpr size_t kBitsPerByteLog2 = 3;
Ian Rogers13735952014-10-08 12:43:28 -070034static constexpr int kBitsPerIntPtrT = sizeof(intptr_t) * kBitsPerByte;
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070035
Ian Rogers0d666d82011-08-14 16:03:46 -070036// Required stack alignment
Mathieu Chartier50482232013-11-21 11:48:14 -080037static constexpr size_t kStackAlignment = 16;
Brian Carlstrom0024d6c2011-08-09 08:26:12 -070038
Elliott Hughes942df412012-03-26 09:46:56 -070039// 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.
Mathieu Chartier50482232013-11-21 11:48:14 -080041static constexpr int kPageSize = 4096;
Brian Carlstromb0460ea2011-07-29 10:08:05 -070042
Mathieu Chartiera8e8f9c2014-04-09 14:51:05 -070043// Required object alignment
44static constexpr size_t kObjectAlignment = 8;
45static constexpr size_t kLargeObjectAlignment = kPageSize;
46
Elliott Hughes67d92002012-03-26 15:08:51 -070047// Whether or not this is a debug build. Useful in conditionals where NDEBUG isn't.
48#if defined(NDEBUG)
Mathieu Chartier50482232013-11-21 11:48:14 -080049static constexpr bool kIsDebugBuild = false;
Elliott Hughes67d92002012-03-26 15:08:51 -070050#else
Mathieu Chartier50482232013-11-21 11:48:14 -080051static constexpr bool kIsDebugBuild = true;
Elliott Hughes67d92002012-03-26 15:08:51 -070052#endif
53
Brian Carlstrombcc29262012-11-02 11:36:03 -070054// Whether or not this is a target (vs host) build. Useful in conditionals where ART_TARGET isn't.
55#if defined(ART_TARGET)
Mathieu Chartier50482232013-11-21 11:48:14 -080056static constexpr bool kIsTargetBuild = true;
Brian Carlstrombcc29262012-11-02 11:36:03 -070057#else
Mathieu Chartier50482232013-11-21 11:48:14 -080058static constexpr bool kIsTargetBuild = false;
Brian Carlstrombcc29262012-11-02 11:36:03 -070059#endif
60
Mathieu Chartier46bc7782013-11-12 17:03:02 -080061#if defined(ART_USE_PORTABLE_COMPILER)
Mathieu Chartier50482232013-11-21 11:48:14 -080062static constexpr bool kUsePortableCompiler = true;
Mathieu Chartier46bc7782013-11-12 17:03:02 -080063#else
Mathieu Chartier50482232013-11-21 11:48:14 -080064static constexpr bool kUsePortableCompiler = false;
Mathieu Chartier46bc7782013-11-12 17:03:02 -080065#endif
66
Mathieu Chartier590fee92013-09-13 13:46:47 -070067// Garbage collector constants.
Mathieu Chartier50482232013-11-21 11:48:14 -080068static constexpr bool kMovingCollector = true && !kUsePortableCompiler;
Mathieu Chartier52e4b432014-06-10 11:22:31 -070069static 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;
Mathieu Chartier590fee92013-09-13 13:46:47 -070072// True if we allow moving classes.
Mathieu Chartier52e4b432014-06-10 11:22:31 -070073static constexpr bool kMovingClasses = !kMarkCompactSupport;
Mathieu Chartier590fee92013-09-13 13:46:47 -070074// True if we allow moving fields.
75static constexpr bool kMovingFields = false;
76// True if we allow moving methods.
77static constexpr bool kMovingMethods = false;
78
Hiroshi Yamauchibe1ca552014-01-15 11:46:48 -080079// If true, the quick compiler embeds class pointers in the compiled
80// code, if possible.
81static constexpr bool kEmbedClassInCode = true;
82
Hiroshi Yamauchi624468c2014-03-31 15:14:47 -070083#ifdef USE_BAKER_READ_BARRIER
84static constexpr bool kUseBakerReadBarrier = true;
Hiroshi Yamauchi9d04a202014-01-31 13:35:49 -080085#else
Hiroshi Yamauchi624468c2014-03-31 15:14:47 -070086static constexpr bool kUseBakerReadBarrier = false;
Hiroshi Yamauchi9d04a202014-01-31 13:35:49 -080087#endif
88
Hiroshi Yamauchi624468c2014-03-31 15:14:47 -070089#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
Hiroshi Yamauchie63a7452014-02-27 14:44:36 -080097// If true, references within the heap are poisoned (negated).
98static constexpr bool kPoisonHeapReferences = false;
99
Ian Rogerse63db272014-07-15 15:36:11 -0700100// Kinds of tracing clocks.
101enum TraceClockSource {
102 kTraceClockSourceThreadCpu,
103 kTraceClockSourceWall,
104 kTraceClockSourceDual, // Both wall and thread CPU clocks.
105};
106
107#if defined(HAVE_POSIX_CLOCKS)
108static constexpr TraceClockSource kDefaultTraceClockSource = kTraceClockSourceDual;
109#else
110static constexpr TraceClockSource kDefaultTraceClockSource = kTraceClockSourceWall;
111#endif
112
Alex Light6e183f22014-07-18 14:57:04 -0700113static constexpr bool kDefaultMustRelocate = true;
114
Zheng Xu5667fdb2014-10-23 18:29:55 +0800115static constexpr bool kArm32QuickCodeUseSoftFloat = false;
116
Carl Shapiro6b6b5f02011-06-21 15:05:09 -0700117} // namespace art
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -0700118
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700119#endif // ART_RUNTIME_GLOBALS_H_