• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
23 namespace art {
24 
25 typedef uint8_t byte;
26 typedef intptr_t word;
27 typedef uintptr_t uword;
28 
29 const size_t KB = 1024;
30 const size_t MB = KB * KB;
31 const size_t GB = KB * KB * KB;
32 
33 const int kWordSize = sizeof(word);
34 const int kPointerSize = sizeof(void*);
35 
36 const int kBitsPerByte = 8;
37 const int kBitsPerByteLog2 = 3;
38 const int kBitsPerWord = kWordSize * kBitsPerByte;
39 const int kWordHighBitMask = 1 << (kBitsPerWord - 1);
40 
41 // Required stack alignment
42 const int kStackAlignment = 16;
43 
44 // Required object alignment
45 const int kObjectAlignment = 8;
46 
47 // ARM instruction alignment. ARM processors require code to be 4-byte aligned,
48 // but ARM ELF requires 8..
49 const int kArmAlignment = 8;
50 
51 // MIPS instruction alignment.  MIPS processors require code to be 4-byte aligned.
52 // TODO: Can this be 4?
53 const int kMipsAlignment = 8;
54 
55 // X86 instruction alignment. This is the recommended alignment for maximum performance.
56 const 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.
60 const int kPageSize = 4096;
61 
62 // Whether or not this is a debug build. Useful in conditionals where NDEBUG isn't.
63 #if defined(NDEBUG)
64 const bool kIsDebugBuild = false;
65 #else
66 const 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)
71 const bool kIsTargetBuild = true;
72 #else
73 const bool kIsTargetBuild = false;
74 #endif
75 
76 }  // namespace art
77 
78 #endif  // ART_RUNTIME_GLOBALS_H_
79