blob: 1a25dfa4ddafbec3f059c63f20d1c4ceaf88045a [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>
22
Carl Shapiro6b6b5f02011-06-21 15:05:09 -070023namespace art {
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070024
25typedef uint8_t byte;
26typedef intptr_t word;
27typedef uintptr_t uword;
28
Carl Shapiro69759ea2011-07-21 18:13:35 -070029const size_t KB = 1024;
30const size_t MB = KB * KB;
31const size_t GB = KB * KB * KB;
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070032
Brian Carlstromba150c32013-08-27 17:31:03 -070033const size_t kWordSize = sizeof(word);
34const size_t kPointerSize = sizeof(void*);
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070035
Brian Carlstromba150c32013-08-27 17:31:03 -070036const size_t kBitsPerByte = 8;
37const size_t kBitsPerByteLog2 = 3;
Carl Shapiro0e5d75d2011-07-06 18:28:37 -070038const int kBitsPerWord = kWordSize * kBitsPerByte;
Brian Carlstromba150c32013-08-27 17:31:03 -070039const size_t kWordHighBitMask = 1 << (kBitsPerWord - 1);
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070040
Ian Rogers0d666d82011-08-14 16:03:46 -070041// Required stack alignment
Brian Carlstromba150c32013-08-27 17:31:03 -070042const size_t kStackAlignment = 16;
Brian Carlstrom0024d6c2011-08-09 08:26:12 -070043
Ian Rogers408f79a2011-08-23 18:22:33 -070044// Required object alignment
Brian Carlstromba150c32013-08-27 17:31:03 -070045const size_t kObjectAlignment = 8;
Ian Rogers408f79a2011-08-23 18:22:33 -070046
Logan Chien468a7b12012-05-25 20:56:35 +080047// ARM instruction alignment. ARM processors require code to be 4-byte aligned,
48// but ARM ELF requires 8..
Brian Carlstromba150c32013-08-27 17:31:03 -070049const size_t kArmAlignment = 8;
Brian Carlstrome24fa612011-09-29 00:53:55 -070050
Elliott Hughes742e25e2012-04-24 18:11:08 -070051// MIPS instruction alignment. MIPS processors require code to be 4-byte aligned.
jeffhao7fbee072012-08-24 17:56:54 -070052// TODO: Can this be 4?
Brian Carlstromba150c32013-08-27 17:31:03 -070053const size_t kMipsAlignment = 8;
Elliott Hughes742e25e2012-04-24 18:11:08 -070054
Elliott Hughes942df412012-03-26 09:46:56 -070055// X86 instruction alignment. This is the recommended alignment for maximum performance.
Brian Carlstromba150c32013-08-27 17:31:03 -070056const size_t kX86Alignment = 16;
Ian Rogersb41b33b2012-03-20 14:22:54 -070057
Elliott Hughes942df412012-03-26 09:46:56 -070058// System page size. We check this against sysconf(_SC_PAGE_SIZE) at runtime, but use a simple
59// compile-time constant so the compiler can generate better code.
Brian Carlstromb0460ea2011-07-29 10:08:05 -070060const int kPageSize = 4096;
61
Elliott Hughes67d92002012-03-26 15:08:51 -070062// Whether or not this is a debug build. Useful in conditionals where NDEBUG isn't.
63#if defined(NDEBUG)
64const bool kIsDebugBuild = false;
65#else
66const bool kIsDebugBuild = true;
67#endif
68
Brian Carlstrombcc29262012-11-02 11:36:03 -070069// Whether or not this is a target (vs host) build. Useful in conditionals where ART_TARGET isn't.
70#if defined(ART_TARGET)
71const bool kIsTargetBuild = true;
72#else
73const bool kIsTargetBuild = false;
74#endif
75
Mathieu Chartier46bc7782013-11-12 17:03:02 -080076#if defined(ART_USE_PORTABLE_COMPILER)
77constexpr bool kUsePortableCompiler = true;
78#else
79constexpr bool kUsePortableCompiler = false;
80#endif
81
Mathieu Chartier590fee92013-09-13 13:46:47 -070082// Garbage collector constants.
Mathieu Chartier46bc7782013-11-12 17:03:02 -080083static constexpr bool kMovingCollector = false && !kUsePortableCompiler;
Mathieu Chartier590fee92013-09-13 13:46:47 -070084// True if we allow moving classes.
85static constexpr bool kMovingClasses = false;
86// True if we allow moving fields.
87static constexpr bool kMovingFields = false;
88// True if we allow moving methods.
89static constexpr bool kMovingMethods = false;
90
Carl Shapiro6b6b5f02011-06-21 15:05:09 -070091} // namespace art
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070092
Brian Carlstromfc0e3212013-07-17 14:40:12 -070093#endif // ART_RUNTIME_GLOBALS_H_