Elliott Hughes | 2faa5f1 | 2012-01-30 14:42:07 -0800 | [diff] [blame] | 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 | */ |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 16 | |
| 17 | #ifndef ART_SRC_GLOBALS_H_ |
| 18 | #define ART_SRC_GLOBALS_H_ |
| 19 | |
Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 20 | #include <stddef.h> |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 21 | #include <stdint.h> |
| 22 | |
Carl Shapiro | 6b6b5f0 | 2011-06-21 15:05:09 -0700 | [diff] [blame] | 23 | namespace art { |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 24 | |
| 25 | typedef uint8_t byte; |
| 26 | typedef intptr_t word; |
| 27 | typedef uintptr_t uword; |
| 28 | |
Carl Shapiro | 69759ea | 2011-07-21 18:13:35 -0700 | [diff] [blame] | 29 | const size_t KB = 1024; |
| 30 | const size_t MB = KB * KB; |
| 31 | const size_t GB = KB * KB * KB; |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 32 | |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 33 | const int kWordSize = sizeof(word); |
| 34 | const int kPointerSize = sizeof(void*); |
| 35 | |
| 36 | const int kBitsPerByte = 8; |
| 37 | const int kBitsPerByteLog2 = 3; |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 38 | const int kBitsPerWord = kWordSize * kBitsPerByte; |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 39 | |
Ian Rogers | 0d666d8 | 2011-08-14 16:03:46 -0700 | [diff] [blame] | 40 | // Required stack alignment |
| 41 | const int kStackAlignment = 16; |
Brian Carlstrom | 0024d6c | 2011-08-09 08:26:12 -0700 | [diff] [blame] | 42 | |
Ian Rogers | 408f79a | 2011-08-23 18:22:33 -0700 | [diff] [blame] | 43 | // Required object alignment |
| 44 | const int kObjectAlignment = 8; |
| 45 | |
Elliott Hughes | 942df41 | 2012-03-26 09:46:56 -0700 | [diff] [blame] | 46 | // ARM instruction alignment. ARM processors require code to be 4-byte aligned. |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 47 | const int kArmAlignment = 4; |
| 48 | |
Elliott Hughes | 942df41 | 2012-03-26 09:46:56 -0700 | [diff] [blame] | 49 | // X86 instruction alignment. This is the recommended alignment for maximum performance. |
Ian Rogers | b41b33b | 2012-03-20 14:22:54 -0700 | [diff] [blame] | 50 | const int kX86Alignment = 16; |
| 51 | |
Elliott Hughes | 942df41 | 2012-03-26 09:46:56 -0700 | [diff] [blame] | 52 | // System page size. We check this against sysconf(_SC_PAGE_SIZE) at runtime, but use a simple |
| 53 | // compile-time constant so the compiler can generate better code. |
Brian Carlstrom | b0460ea | 2011-07-29 10:08:05 -0700 | [diff] [blame] | 54 | const int kPageSize = 4096; |
| 55 | |
Elliott Hughes | 67d9200 | 2012-03-26 15:08:51 -0700 | [diff] [blame] | 56 | // Whether or not this is a debug build. Useful in conditionals where NDEBUG isn't. |
| 57 | #if defined(NDEBUG) |
| 58 | const bool kIsDebugBuild = false; |
| 59 | #else |
| 60 | const bool kIsDebugBuild = true; |
| 61 | #endif |
| 62 | |
Carl Shapiro | 6b6b5f0 | 2011-06-21 15:05:09 -0700 | [diff] [blame] | 63 | } // namespace art |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 64 | |
| 65 | #endif // ART_SRC_GLOBALS_H_ |