• 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 
45 // C++-specific configuration part..
46 
47 #ifdef __cplusplus
48 
49 #include "base/globals.h"
50 
51 namespace art {
52 
53 #ifdef USE_BAKER_READ_BARRIER
54 static constexpr bool kUseBakerReadBarrier = true;
55 #else
56 static constexpr bool kUseBakerReadBarrier = false;
57 #endif
58 
59 #ifdef USE_TABLE_LOOKUP_READ_BARRIER
60 static constexpr bool kUseTableLookupReadBarrier = true;
61 #else
62 static constexpr bool kUseTableLookupReadBarrier = false;
63 #endif
64 
65 static constexpr bool kUseReadBarrier = kUseBakerReadBarrier || kUseTableLookupReadBarrier;
66 
67 // Debugging flag that forces the generation of read barriers, but
68 // does not trigger the use of the concurrent copying GC.
69 //
70 // TODO: Remove this flag when the read barriers compiler
71 // instrumentation is completed.
72 static constexpr bool kForceReadBarrier = false;
73 // TODO: Likewise, remove this flag when kForceReadBarrier is removed
74 // and replace it with kUseReadBarrier.
75 static constexpr bool kEmitCompilerReadBarrier = kForceReadBarrier || kUseReadBarrier;
76 
77 // Disabled for performance reasons.
78 static constexpr bool kCheckDebugDisallowReadBarrierCount = kIsDebugBuild;
79 
80 }  // namespace art
81 
82 #endif  // __cplusplus
83 
84 #endif  // ART_RUNTIME_READ_BARRIER_CONFIG_H_
85