globals.h revision fc0e3219edc9a5bf81b166e82fd5db2796eb6a0d
12faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes/* 22faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Copyright (C) 2011 The Android Open Source Project 32faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 42faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 52faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * you may not use this file except in compliance with the License. 62faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * You may obtain a copy of the License at 72faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 82faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 92faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 102faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Unless required by applicable law or agreed to in writing, software 112faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 122faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 132faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * See the License for the specific language governing permissions and 142faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * limitations under the License. 152faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes */ 16a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 17fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#ifndef ART_RUNTIME_GLOBALS_H_ 18fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#define ART_RUNTIME_GLOBALS_H_ 19a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 201fb8620309a4e94d11879aabc33364acfa733904Carl Shapiro#include <stddef.h> 21a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro#include <stdint.h> 22a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 236b6b5f0e67ce03f38223a525612955663bc1799bCarl Shapironamespace art { 24a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 25a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapirotypedef uint8_t byte; 26a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapirotypedef intptr_t word; 27a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapirotypedef uintptr_t uword; 28a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 2969759eaa6fd4386f1e6d8748052ad221087b3476Carl Shapiroconst size_t KB = 1024; 3069759eaa6fd4386f1e6d8748052ad221087b3476Carl Shapiroconst size_t MB = KB * KB; 3169759eaa6fd4386f1e6d8748052ad221087b3476Carl Shapiroconst size_t GB = KB * KB * KB; 326d8dd47f2f65c4476b31672b6f2c7bbf9020fe3aElliott Hughes 33a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiroconst int kWordSize = sizeof(word); 34a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiroconst int kPointerSize = sizeof(void*); 35a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 36a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiroconst int kBitsPerByte = 8; 37a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiroconst int kBitsPerByteLog2 = 3; 380e5d75d5ca2b8a44fab0c862276a466cbab39859Carl Shapiroconst int kBitsPerWord = kWordSize * kBitsPerByte; 39dcf8d7283bd51714f3faa55b631ae4103dc98b51Mathieu Chartierconst int kWordHighBitMask = 1 << (kBitsPerWord - 1); 40a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 410d666d8769714dcbc2acc4dd5b06f0deffa6e0a1Ian Rogers// Required stack alignment 420d666d8769714dcbc2acc4dd5b06f0deffa6e0a1Ian Rogersconst int kStackAlignment = 16; 430024d6cb8043a8967fdfb20561f321b2fe65c41fBrian Carlstrom 44408f79aeb676251ba35667a64e86c20638d7cb0bIan Rogers// Required object alignment 45408f79aeb676251ba35667a64e86c20638d7cb0bIan Rogersconst int kObjectAlignment = 8; 46408f79aeb676251ba35667a64e86c20638d7cb0bIan Rogers 47468a7b1fcb2114ec973e31b5276daea0be62c198Logan Chien// ARM instruction alignment. ARM processors require code to be 4-byte aligned, 48468a7b1fcb2114ec973e31b5276daea0be62c198Logan Chien// but ARM ELF requires 8.. 49468a7b1fcb2114ec973e31b5276daea0be62c198Logan Chienconst int kArmAlignment = 8; 50e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom 51742e25ef8cc9655c7bb27f3c34a7e3b4e3607d99Elliott Hughes// MIPS instruction alignment. MIPS processors require code to be 4-byte aligned. 527fbee0731b14b5bf392a4254f5cd84685ab517dajeffhao// TODO: Can this be 4? 537fbee0731b14b5bf392a4254f5cd84685ab517dajeffhaoconst int kMipsAlignment = 8; 54742e25ef8cc9655c7bb27f3c34a7e3b4e3607d99Elliott Hughes 55942df41c03ddb9f7b47a34fcfc4414d8b8ca8ce1Elliott Hughes// X86 instruction alignment. This is the recommended alignment for maximum performance. 56b41b33b5e5f08083e35f84818b4f44d26feb4a8bIan Rogersconst int kX86Alignment = 16; 57b41b33b5e5f08083e35f84818b4f44d26feb4a8bIan Rogers 58942df41c03ddb9f7b47a34fcfc4414d8b8ca8ce1Elliott Hughes// System page size. We check this against sysconf(_SC_PAGE_SIZE) at runtime, but use a simple 59942df41c03ddb9f7b47a34fcfc4414d8b8ca8ce1Elliott Hughes// compile-time constant so the compiler can generate better code. 60b0460eaa2cb131f1dbdd5a7217bd36b9a9f1b995Brian Carlstromconst int kPageSize = 4096; 61b0460eaa2cb131f1dbdd5a7217bd36b9a9f1b995Brian Carlstrom 6267d920071fe4a0aa8b8bc339e93b18276238c320Elliott Hughes// Whether or not this is a debug build. Useful in conditionals where NDEBUG isn't. 6367d920071fe4a0aa8b8bc339e93b18276238c320Elliott Hughes#if defined(NDEBUG) 6467d920071fe4a0aa8b8bc339e93b18276238c320Elliott Hughesconst bool kIsDebugBuild = false; 6567d920071fe4a0aa8b8bc339e93b18276238c320Elliott Hughes#else 6667d920071fe4a0aa8b8bc339e93b18276238c320Elliott Hughesconst bool kIsDebugBuild = true; 6767d920071fe4a0aa8b8bc339e93b18276238c320Elliott Hughes#endif 6867d920071fe4a0aa8b8bc339e93b18276238c320Elliott Hughes 69bcc2926b9721f94c17ed98fae5264cc98f0e066fBrian Carlstrom// Whether or not this is a target (vs host) build. Useful in conditionals where ART_TARGET isn't. 70bcc2926b9721f94c17ed98fae5264cc98f0e066fBrian Carlstrom#if defined(ART_TARGET) 71bcc2926b9721f94c17ed98fae5264cc98f0e066fBrian Carlstromconst bool kIsTargetBuild = true; 72bcc2926b9721f94c17ed98fae5264cc98f0e066fBrian Carlstrom#else 73bcc2926b9721f94c17ed98fae5264cc98f0e066fBrian Carlstromconst bool kIsTargetBuild = false; 74bcc2926b9721f94c17ed98fae5264cc98f0e066fBrian Carlstrom#endif 75bcc2926b9721f94c17ed98fae5264cc98f0e066fBrian Carlstrom 766b6b5f0e67ce03f38223a525612955663bc1799bCarl Shapiro} // namespace art 77a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 78fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#endif // ART_RUNTIME_GLOBALS_H_ 79