• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 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_READ_BARRIER_CONFIG_H_
18 #define ART_RUNTIME_READ_BARRIER_CONFIG_H_
19 
20 // This is a mixed C-C++ header file that has a global section at the start
21 // and a C++ section at the end, because asm_support.h is a C header file and
22 // cannot include any C++ syntax.
23 
24 // Global (C) part.
25 
26 // Uncomment one of the following two and the two fields in
27 // Object.java (libcore) to enable baker, or
28 // table-lookup read barriers.
29 
30 #ifdef ART_USE_READ_BARRIER
31 #if ART_READ_BARRIER_TYPE_IS_BAKER
32 #define USE_BAKER_READ_BARRIER
33 #elif ART_READ_BARRIER_TYPE_IS_TABLELOOKUP
34 #define USE_TABLE_LOOKUP_READ_BARRIER
35 #else
36 #error "ART read barrier type must be set"
37 #endif
38 #endif  // ART_USE_READ_BARRIER
39 
40 #if defined(USE_BAKER_READ_BARRIER) || defined(USE_TABLE_LOOKUP_READ_BARRIER)
41 #define USE_READ_BARRIER
42 #endif
43 
44 // Reserve marking register (and its refreshing logic) for all GCs as nterp
45 // requires it. In the future if and when nterp is made independent of
46 // read-barrier, we can switch back to the current behavior by making this
47 // definition conditional on USE_BAKER_READ_BARRIER and setting
48 // kReserveMarkingRegister to kUseBakerReadBarrier.
49 #define RESERVE_MARKING_REGISTER
50 
51 // C++-specific configuration part..
52 
53 #ifdef __cplusplus
54 
55 #include "base/globals.h"
56 
57 namespace art {
58 
59 #ifdef USE_BAKER_READ_BARRIER
60 static constexpr bool kUseBakerReadBarrier = true;
61 #else
62 static constexpr bool kUseBakerReadBarrier = false;
63 #endif
64 
65 // Read comment for RESERVE_MARKING_REGISTER above
66 static constexpr bool kReserveMarkingRegister = true;
67 
68 #ifdef USE_TABLE_LOOKUP_READ_BARRIER
69 static constexpr bool kUseTableLookupReadBarrier = true;
70 #else
71 static constexpr bool kUseTableLookupReadBarrier = false;
72 #endif
73 
74 // Only if read-barrier isn't forced (see build/art.go) but is selected, that we need
75 // to see if we support userfaultfd GC. All the other cases can be constexpr here.
76 #ifdef ART_FORCE_USE_READ_BARRIER
77 constexpr bool gUseReadBarrier = kUseBakerReadBarrier || kUseTableLookupReadBarrier;
78 constexpr bool gUseUserfaultfd = !gUseReadBarrier;
79 static_assert(!gUseUserfaultfd);
80 #else
81 #ifndef ART_USE_READ_BARRIER
82 constexpr bool gUseReadBarrier = false;
83 #ifdef ART_DEFAULT_GC_TYPE_IS_CMC
84 constexpr bool gUseUserfaultfd = true;
85 #else
86 constexpr bool gUseUserfaultfd = false;
87 #endif
88 #else
89 extern const bool gUseReadBarrier;
90 extern const bool gUseUserfaultfd;
91 #endif
92 #endif
93 
94 // Disabled for performance reasons.
95 static constexpr bool kCheckDebugDisallowReadBarrierCount = kIsDebugBuild;
96 
97 }  // namespace art
98 
99 #endif  // __cplusplus
100 
101 #endif  // ART_RUNTIME_READ_BARRIER_CONFIG_H_
102