Convince tsan that the card table isn't a problem.
Also move the #include <sys/mman.h> into "mem_map.h", since it's
currently not possible to make any use of the latter without the
former. If we care about the pollution, we should offer our own
constants as part of our API.
Change-Id: I01ec451d23c1d8afb8cb8a6660af8d9723faf5f5
diff --git a/src/card_table.cc b/src/card_table.cc
index 0eac91f..d4c391a 100644
--- a/src/card_table.cc
+++ b/src/card_table.cc
@@ -16,7 +16,7 @@
#include "card_table.h"
-#include <sys/mman.h> /* for PROT_* */
+#include <dynamic_annotations.h>
#include "heap.h"
#include "heap_bitmap.h"
@@ -81,6 +81,13 @@
return new CardTable(mem_map.release(), biased_begin, offset);
}
+CardTable::CardTable(MemMap* mem_map, byte* biased_begin, size_t offset)
+ : mem_map_(mem_map), biased_begin_(biased_begin), offset_(offset) {
+ byte* __attribute__((unused)) begin = mem_map_->Begin() + offset_;
+ byte* __attribute__((unused)) end = mem_map_->End();
+ ANNOTATE_BENIGN_RACE_SIZED(begin, (end - begin), "writes to GC card table");
+}
+
void CardTable::ClearNonImageSpaceCards(Heap* heap) {
// TODO: clear just the range of the table that has been modified
const std::vector<Space*>& spaces = heap->GetSpaces();
diff --git a/src/card_table.h b/src/card_table.h
index 9cfa70b..0d5178e 100644
--- a/src/card_table.h
+++ b/src/card_table.h
@@ -71,10 +71,9 @@
// Resets all of the bytes in the card table to clean.
void ClearNonImageSpaceCards(Heap* heap);
- private:
- CardTable(MemMap* begin, byte* biased_begin, size_t offset) :
- mem_map_(begin), biased_begin_(biased_begin), offset_(offset) {}
+ private:
+ CardTable(MemMap* begin, byte* biased_begin, size_t offset);
// Returns the address of the relevant byte in the card table, given an address on the heap.
byte* CardFromAddr(const void *addr) const {
diff --git a/src/compiler.cc b/src/compiler.cc
index 2e17c9b..89f35b3 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -19,7 +19,6 @@
#include <vector>
#include <dlfcn.h>
-#include <sys/mman.h>
#include <unistd.h>
#include "class_linker.h"
diff --git a/src/compiler/codegen/arm/Assemble.cc b/src/compiler/codegen/arm/Assemble.cc
index aca146e..86517fa 100644
--- a/src/compiler/codegen/arm/Assemble.cc
+++ b/src/compiler/codegen/arm/Assemble.cc
@@ -18,7 +18,6 @@
#include "../../CompilerInternals.h"
#include "ArmLIR.h"
#include "Codegen.h"
-#include <sys/mman.h> /* for protection change */
namespace art {
diff --git a/src/compiler/codegen/mips/Assemble.cc b/src/compiler/codegen/mips/Assemble.cc
index c19effe..39ad36b 100644
--- a/src/compiler/codegen/mips/Assemble.cc
+++ b/src/compiler/codegen/mips/Assemble.cc
@@ -18,7 +18,6 @@
#include "../../CompilerInternals.h"
#include "MipsLIR.h"
#include "Codegen.h"
-#include <sys/mman.h> /* for protection change */
namespace art {
diff --git a/src/compiler/codegen/x86/Assemble.cc b/src/compiler/codegen/x86/Assemble.cc
index 671e728..9e0e713 100644
--- a/src/compiler/codegen/x86/Assemble.cc
+++ b/src/compiler/codegen/x86/Assemble.cc
@@ -18,7 +18,6 @@
#include "../../CompilerInternals.h"
#include "X86LIR.h"
#include "Codegen.h"
-#include <sys/mman.h> /* for protection change */
namespace art {
diff --git a/src/dex_file.cc b/src/dex_file.cc
index cca1a30..8f30c73 100644
--- a/src/dex_file.cc
+++ b/src/dex_file.cc
@@ -22,7 +22,6 @@
#include <stdlib.h>
#include <string.h>
#include <sys/file.h>
-#include <sys/mman.h>
#include <sys/stat.h>
#include "class_linker.h"
diff --git a/src/exception_test.cc b/src/exception_test.cc
index 23a437a..2730954 100644
--- a/src/exception_test.cc
+++ b/src/exception_test.cc
@@ -14,15 +14,13 @@
* limitations under the License.
*/
-#include <sys/mman.h>
-
-#include "UniquePtr.h"
#include "class_linker.h"
#include "common_test.h"
#include "dex_file.h"
#include "gtest/gtest.h"
#include "runtime.h"
#include "thread.h"
+#include "UniquePtr.h"
namespace art {
diff --git a/src/heap_bitmap.cc b/src/heap_bitmap.cc
index 5223178..769ee9d 100644
--- a/src/heap_bitmap.cc
+++ b/src/heap_bitmap.cc
@@ -16,10 +16,8 @@
#include "heap_bitmap.h"
-#include <sys/mman.h>
-
-#include "UniquePtr.h"
#include "logging.h"
+#include "UniquePtr.h"
#include "utils.h"
namespace art {
diff --git a/src/image_writer.cc b/src/image_writer.cc
index d1328c1..589d3d7 100644
--- a/src/image_writer.cc
+++ b/src/image_writer.cc
@@ -16,12 +16,10 @@
#include "image_writer.h"
-#include <sys/mman.h>
#include <sys/stat.h>
#include <vector>
-#include "UniquePtr.h"
#include "class_linker.h"
#include "class_loader.h"
#include "compiled_method.h"
@@ -38,6 +36,7 @@
#include "object_utils.h"
#include "runtime.h"
#include "space.h"
+#include "UniquePtr.h"
#include "utils.h"
namespace art {
diff --git a/src/jni_compiler_test.cc b/src/jni_compiler_test.cc
index 2c763b2..f821eee 100644
--- a/src/jni_compiler_test.cc
+++ b/src/jni_compiler_test.cc
@@ -14,9 +14,6 @@
* limitations under the License.
*/
-#include <sys/mman.h>
-
-#include "UniquePtr.h"
#include "class_linker.h"
#include "common_test.h"
#include "dex_file.h"
@@ -27,6 +24,7 @@
#include "runtime.h"
#include "scoped_jni_thread_state.h"
#include "thread.h"
+#include "UniquePtr.h"
extern "C" JNIEXPORT jint JNICALL Java_MyClassNatives_bar(JNIEnv*, jobject, jint count) {
return count + 1;
diff --git a/src/jni_internal.cc b/src/jni_internal.cc
index 87d5449..4f01f7d 100644
--- a/src/jni_internal.cc
+++ b/src/jni_internal.cc
@@ -17,7 +17,6 @@
#include "jni_internal.h"
#include <dlfcn.h>
-#include <sys/mman.h>
#include <cstdarg>
#include <utility>
diff --git a/src/jni_internal_test.cc b/src/jni_internal_test.cc
index b9366c1..2ca2b3c 100644
--- a/src/jni_internal_test.cc
+++ b/src/jni_internal_test.cc
@@ -16,8 +16,6 @@
#include "jni_internal.h"
-#include <sys/mman.h>
-
#include <cmath>
#include "common_test.h"
diff --git a/src/mark_stack.cc b/src/mark_stack.cc
index e269455..e1aa616 100644
--- a/src/mark_stack.cc
+++ b/src/mark_stack.cc
@@ -16,11 +16,9 @@
#include "mark_stack.h"
-#include <sys/mman.h>
-
-#include "UniquePtr.h"
#include "globals.h"
#include "logging.h"
+#include "UniquePtr.h"
#include "utils.h"
namespace art {
diff --git a/src/mem_map.cc b/src/mem_map.cc
index d9ffaeb..c9929cc 100644
--- a/src/mem_map.cc
+++ b/src/mem_map.cc
@@ -16,8 +16,6 @@
#include "mem_map.h"
-#include <sys/mman.h>
-
#include "ScopedFd.h"
#include "stringprintf.h"
#include "utils.h"
diff --git a/src/mem_map.h b/src/mem_map.h
index 9da2a84..3861327 100644
--- a/src/mem_map.h
+++ b/src/mem_map.h
@@ -18,6 +18,7 @@
#define ART_SRC_MEM_MAP_H_
#include <stddef.h>
+#include <sys/mman.h> // For the PROT_* and MAP_* constants.
#include <sys/types.h>
#include "globals.h"
diff --git a/src/oat/jni/jni_compiler.cc b/src/oat/jni/jni_compiler.cc
index 2491586..42d2166 100644
--- a/src/oat/jni/jni_compiler.cc
+++ b/src/oat/jni/jni_compiler.cc
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-#include <sys/mman.h>
#include <vector>
#include "calling_convention.h"
diff --git a/src/oat_file.cc b/src/oat_file.cc
index 15ad11f..81e88dd 100644
--- a/src/oat_file.cc
+++ b/src/oat_file.cc
@@ -16,8 +16,6 @@
#include "oat_file.h"
-#include <sys/mman.h>
-
#include "file.h"
#include "os.h"
#include "stl_util.h"
diff --git a/src/space.cc b/src/space.cc
index 5aceed7..4600443 100644
--- a/src/space.cc
+++ b/src/space.cc
@@ -16,8 +16,6 @@
#include "space.h"
-#include <sys/mman.h>
-
#include "UniquePtr.h"
#include "dlmalloc.h"
#include "file.h"
diff --git a/src/thread.cc b/src/thread.cc
index b177cf8..8ef784f 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -19,7 +19,6 @@
#include <dynamic_annotations.h>
#include <pthread.h>
#include <signal.h>
-#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/time.h>
diff --git a/src/zip_archive.h b/src/zip_archive.h
index 3889fcb..cda3522 100644
--- a/src/zip_archive.h
+++ b/src/zip_archive.h
@@ -18,7 +18,6 @@
#define ART_SRC_ZIP_ARCHIVE_H_
#include <stdint.h>
-#include <sys/mman.h>
#include <zlib.h>
#include "file.h"