globals.h revision 590fee9e8972f872301c2d16a575d579ee564bee
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 23namespace art { 24 25typedef uint8_t byte; 26typedef intptr_t word; 27typedef uintptr_t uword; 28 29const size_t KB = 1024; 30const size_t MB = KB * KB; 31const size_t GB = KB * KB * KB; 32 33const size_t kWordSize = sizeof(word); 34const size_t kPointerSize = sizeof(void*); 35 36const size_t kBitsPerByte = 8; 37const size_t kBitsPerByteLog2 = 3; 38const int kBitsPerWord = kWordSize * kBitsPerByte; 39const size_t kWordHighBitMask = 1 << (kBitsPerWord - 1); 40 41// Required stack alignment 42const size_t kStackAlignment = 16; 43 44// Required object alignment 45const size_t kObjectAlignment = 8; 46 47// ARM instruction alignment. ARM processors require code to be 4-byte aligned, 48// but ARM ELF requires 8.. 49const size_t kArmAlignment = 8; 50 51// MIPS instruction alignment. MIPS processors require code to be 4-byte aligned. 52// TODO: Can this be 4? 53const size_t kMipsAlignment = 8; 54 55// X86 instruction alignment. This is the recommended alignment for maximum performance. 56const size_t kX86Alignment = 16; 57 58// 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. 60const int kPageSize = 4096; 61 62// 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 69// 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 76// Garbage collector constants. 77static constexpr bool kMovingCollector = false; 78// True if we allow moving classes. 79static constexpr bool kMovingClasses = false; 80// True if we allow moving fields. 81static constexpr bool kMovingFields = false; 82// True if we allow moving methods. 83static constexpr bool kMovingMethods = false; 84 85} // namespace art 86 87#endif // ART_RUNTIME_GLOBALS_H_ 88