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 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_GLOBALS_H_ |
| 18 | #define ART_RUNTIME_GLOBALS_H_ |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 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> |
Hiroshi Yamauchi | 9d04a20 | 2014-01-31 13:35:49 -0800 | [diff] [blame] | 22 | #include "brooks_pointer.h" |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 23 | |
Carl Shapiro | 6b6b5f0 | 2011-06-21 15:05:09 -0700 | [diff] [blame] | 24 | namespace art { |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 25 | |
| 26 | typedef uint8_t byte; |
| 27 | typedef intptr_t word; |
| 28 | typedef uintptr_t uword; |
| 29 | |
Mathieu Chartier | 5048223 | 2013-11-21 11:48:14 -0800 | [diff] [blame] | 30 | static constexpr size_t KB = 1024; |
| 31 | static constexpr size_t MB = KB * KB; |
| 32 | static constexpr size_t GB = KB * KB * KB; |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 33 | |
Mathieu Chartier | 5048223 | 2013-11-21 11:48:14 -0800 | [diff] [blame] | 34 | static constexpr size_t kWordSize = sizeof(word); |
| 35 | static constexpr size_t kPointerSize = sizeof(void*); |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 36 | |
Mathieu Chartier | 5048223 | 2013-11-21 11:48:14 -0800 | [diff] [blame] | 37 | static constexpr size_t kBitsPerByte = 8; |
| 38 | static constexpr size_t kBitsPerByteLog2 = 3; |
| 39 | static constexpr int kBitsPerWord = kWordSize * kBitsPerByte; |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 40 | static constexpr size_t kWordHighBitMask = static_cast<size_t>(1) << (kBitsPerWord - 1); |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 41 | |
Ian Rogers | 0d666d8 | 2011-08-14 16:03:46 -0700 | [diff] [blame] | 42 | // Required stack alignment |
Mathieu Chartier | 5048223 | 2013-11-21 11:48:14 -0800 | [diff] [blame] | 43 | static constexpr size_t kStackAlignment = 16; |
Brian Carlstrom | 0024d6c | 2011-08-09 08:26:12 -0700 | [diff] [blame] | 44 | |
Ian Rogers | 408f79a | 2011-08-23 18:22:33 -0700 | [diff] [blame] | 45 | // Required object alignment |
Mathieu Chartier | 5048223 | 2013-11-21 11:48:14 -0800 | [diff] [blame] | 46 | static constexpr size_t kObjectAlignment = 8; |
Ian Rogers | 408f79a | 2011-08-23 18:22:33 -0700 | [diff] [blame] | 47 | |
Logan Chien | 468a7b1 | 2012-05-25 20:56:35 +0800 | [diff] [blame] | 48 | // ARM instruction alignment. ARM processors require code to be 4-byte aligned, |
| 49 | // but ARM ELF requires 8.. |
Mathieu Chartier | 5048223 | 2013-11-21 11:48:14 -0800 | [diff] [blame] | 50 | static constexpr size_t kArmAlignment = 8; |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 51 | |
Elliott Hughes | 742e25e | 2012-04-24 18:11:08 -0700 | [diff] [blame] | 52 | // MIPS instruction alignment. MIPS processors require code to be 4-byte aligned. |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 53 | // TODO: Can this be 4? |
Mathieu Chartier | 5048223 | 2013-11-21 11:48:14 -0800 | [diff] [blame] | 54 | static constexpr size_t kMipsAlignment = 8; |
Elliott Hughes | 742e25e | 2012-04-24 18:11:08 -0700 | [diff] [blame] | 55 | |
Elliott Hughes | 942df41 | 2012-03-26 09:46:56 -0700 | [diff] [blame] | 56 | // X86 instruction alignment. This is the recommended alignment for maximum performance. |
Mathieu Chartier | 5048223 | 2013-11-21 11:48:14 -0800 | [diff] [blame] | 57 | static constexpr size_t kX86Alignment = 16; |
Ian Rogers | b41b33b | 2012-03-20 14:22:54 -0700 | [diff] [blame] | 58 | |
Elliott Hughes | 942df41 | 2012-03-26 09:46:56 -0700 | [diff] [blame] | 59 | // System page size. We check this against sysconf(_SC_PAGE_SIZE) at runtime, but use a simple |
| 60 | // compile-time constant so the compiler can generate better code. |
Mathieu Chartier | 5048223 | 2013-11-21 11:48:14 -0800 | [diff] [blame] | 61 | static constexpr int kPageSize = 4096; |
Brian Carlstrom | b0460ea | 2011-07-29 10:08:05 -0700 | [diff] [blame] | 62 | |
Elliott Hughes | 67d9200 | 2012-03-26 15:08:51 -0700 | [diff] [blame] | 63 | // Whether or not this is a debug build. Useful in conditionals where NDEBUG isn't. |
| 64 | #if defined(NDEBUG) |
Mathieu Chartier | 5048223 | 2013-11-21 11:48:14 -0800 | [diff] [blame] | 65 | static constexpr bool kIsDebugBuild = false; |
Elliott Hughes | 67d9200 | 2012-03-26 15:08:51 -0700 | [diff] [blame] | 66 | #else |
Mathieu Chartier | 5048223 | 2013-11-21 11:48:14 -0800 | [diff] [blame] | 67 | static constexpr bool kIsDebugBuild = true; |
Elliott Hughes | 67d9200 | 2012-03-26 15:08:51 -0700 | [diff] [blame] | 68 | #endif |
| 69 | |
Brian Carlstrom | bcc2926 | 2012-11-02 11:36:03 -0700 | [diff] [blame] | 70 | // Whether or not this is a target (vs host) build. Useful in conditionals where ART_TARGET isn't. |
| 71 | #if defined(ART_TARGET) |
Mathieu Chartier | 5048223 | 2013-11-21 11:48:14 -0800 | [diff] [blame] | 72 | static constexpr bool kIsTargetBuild = true; |
Brian Carlstrom | bcc2926 | 2012-11-02 11:36:03 -0700 | [diff] [blame] | 73 | #else |
Mathieu Chartier | 5048223 | 2013-11-21 11:48:14 -0800 | [diff] [blame] | 74 | static constexpr bool kIsTargetBuild = false; |
Brian Carlstrom | bcc2926 | 2012-11-02 11:36:03 -0700 | [diff] [blame] | 75 | #endif |
| 76 | |
Mathieu Chartier | 46bc778 | 2013-11-12 17:03:02 -0800 | [diff] [blame] | 77 | #if defined(ART_USE_PORTABLE_COMPILER) |
Mathieu Chartier | 5048223 | 2013-11-21 11:48:14 -0800 | [diff] [blame] | 78 | static constexpr bool kUsePortableCompiler = true; |
Mathieu Chartier | 46bc778 | 2013-11-12 17:03:02 -0800 | [diff] [blame] | 79 | #else |
Mathieu Chartier | 5048223 | 2013-11-21 11:48:14 -0800 | [diff] [blame] | 80 | static constexpr bool kUsePortableCompiler = false; |
Mathieu Chartier | 46bc778 | 2013-11-12 17:03:02 -0800 | [diff] [blame] | 81 | #endif |
| 82 | |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 83 | // Garbage collector constants. |
Mathieu Chartier | 5048223 | 2013-11-21 11:48:14 -0800 | [diff] [blame] | 84 | static constexpr bool kMovingCollector = true && !kUsePortableCompiler; |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 85 | // True if we allow moving classes. |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame] | 86 | static constexpr bool kMovingClasses = true; |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 87 | // True if we allow moving fields. |
| 88 | static constexpr bool kMovingFields = false; |
| 89 | // True if we allow moving methods. |
| 90 | static constexpr bool kMovingMethods = false; |
| 91 | |
Hiroshi Yamauchi | be1ca55 | 2014-01-15 11:46:48 -0800 | [diff] [blame] | 92 | // If true, the quick compiler embeds class pointers in the compiled |
| 93 | // code, if possible. |
| 94 | static constexpr bool kEmbedClassInCode = true; |
| 95 | |
Hiroshi Yamauchi | 9d04a20 | 2014-01-31 13:35:49 -0800 | [diff] [blame] | 96 | #ifdef USE_BROOKS_POINTER |
| 97 | static constexpr bool kUseBrooksPointer = true; |
| 98 | #else |
| 99 | static constexpr bool kUseBrooksPointer = false; |
| 100 | #endif |
| 101 | |
Carl Shapiro | 6b6b5f0 | 2011-06-21 15:05:09 -0700 | [diff] [blame] | 102 | } // namespace art |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 103 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 104 | #endif // ART_RUNTIME_GLOBALS_H_ |