globals.h revision fc0e3219edc9a5bf81b166e82fd5db2796eb6a0d
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 int kWordSize = sizeof(word); 34const int kPointerSize = sizeof(void*); 35 36const int kBitsPerByte = 8; 37const int kBitsPerByteLog2 = 3; 38const int kBitsPerWord = kWordSize * kBitsPerByte; 39const int kWordHighBitMask = 1 << (kBitsPerWord - 1); 40 41// Required stack alignment 42const int kStackAlignment = 16; 43 44// Required object alignment 45const int kObjectAlignment = 8; 46 47// ARM instruction alignment. ARM processors require code to be 4-byte aligned, 48// but ARM ELF requires 8.. 49const int kArmAlignment = 8; 50 51// MIPS instruction alignment. MIPS processors require code to be 4-byte aligned. 52// TODO: Can this be 4? 53const int kMipsAlignment = 8; 54 55// X86 instruction alignment. This is the recommended alignment for maximum performance. 56const int 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} // namespace art 77 78#endif // ART_RUNTIME_GLOBALS_H_ 79