diff options
author | 2017-06-06 20:46:10 -0700 | |
---|---|---|
committer | 2017-06-09 11:36:45 -0700 | |
commit | b2d18fa4e33ca119654ced872c70fe198b0b2db5 (patch) | |
tree | 9f0e3ac72b9b7b08794e1ecf458620ba19437465 | |
parent | 58794c5c23f46a7476a58e5a10dbeebb6321aa90 (diff) |
ART: Clean up asm_support.h
The includes are only ever really needed for tests. Factor out
generation of the test function into asm_support_check.h
Fix up missing includes, mainly intern_table.h.
Test: m
Test: m test-art-host
Change-Id: I435199e6211e368be0a06c80d8fa95b9593aca31
-rw-r--r-- | compiler/image_writer.cc | 1 | ||||
-rw-r--r-- | compiler/image_writer.h | 1 | ||||
-rw-r--r-- | patchoat/patchoat.cc | 1 | ||||
-rw-r--r-- | runtime/arch/arch_test.cc | 27 | ||||
-rw-r--r-- | runtime/arch/arm/entrypoints_init_arm.cc | 1 | ||||
-rw-r--r-- | runtime/arch/arm64/entrypoints_init_arm64.cc | 1 | ||||
-rw-r--r-- | runtime/asm_support.h | 34 | ||||
-rw-r--r-- | runtime/asm_support_check.h | 65 | ||||
-rw-r--r-- | runtime/jit/jit_code_cache.cc | 1 | ||||
-rw-r--r-- | runtime/mirror/string-inl.h | 5 | ||||
-rw-r--r-- | runtime/mirror/string.cc | 4 | ||||
-rw-r--r-- | runtime/runtime.cc | 1 |
12 files changed, 105 insertions, 37 deletions
diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc index 16c9f10cce..406892e499 100644 --- a/compiler/image_writer.cc +++ b/compiler/image_writer.cc @@ -49,7 +49,6 @@ #include "globals.h" #include "image.h" #include "imt_conflict_table.h" -#include "intern_table.h" #include "jni_internal.h" #include "linear_alloc.h" #include "lock_word.h" diff --git a/compiler/image_writer.h b/compiler/image_writer.h index 3db4fab128..5e2db7d8f7 100644 --- a/compiler/image_writer.h +++ b/compiler/image_writer.h @@ -36,6 +36,7 @@ #include "class_table.h" #include "driver/compiler_driver.h" #include "image.h" +#include "intern_table.h" #include "lock_word.h" #include "mem_map.h" #include "mirror/dex_cache.h" diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc index e750ede8fa..ec3481b622 100644 --- a/patchoat/patchoat.cc +++ b/patchoat/patchoat.cc @@ -40,6 +40,7 @@ #include "elf_file_impl.h" #include "gc/space/image_space.h" #include "image-inl.h" +#include "intern_table.h" #include "mirror/dex_cache.h" #include "mirror/executable.h" #include "mirror/object-inl.h" diff --git a/runtime/arch/arch_test.cc b/runtime/arch/arch_test.cc index ce575f72c1..838ae40838 100644 --- a/runtime/arch/arch_test.cc +++ b/runtime/arch/arch_test.cc @@ -20,9 +20,27 @@ #include "base/callee_save_type.h" #include "common_runtime_test.h" #include "quick/quick_method_frame_info.h" -// Common tests are declared next to the constants. -#define ADD_TEST_EQ(x, y) EXPECT_EQ(x, y); -#include "asm_support.h" + + +// asm_support.h declares tests next to the #defines. We use asm_support_check.h to (safely) +// generate CheckAsmSupportOffsetsAndSizes using gtest's EXPECT for the tests. We also use the +// RETURN_TYPE, HEADER and FOOTER defines from asm_support_check.h to try to ensure that any +// tests are actually generated. + +// Let CheckAsmSupportOffsetsAndSizes return a size_t (the count). +#define ASM_SUPPORT_CHECK_RETURN_TYPE size_t + +// Declare the counter that will be updated per test. +#define ASM_SUPPORT_CHECK_HEADER size_t count = 0; + +// Use EXPECT_EQ for tests, and increment the counter. +#define ADD_TEST_EQ(x, y) EXPECT_EQ(x, y); count++; + +// Return the counter at the end of CheckAsmSupportOffsetsAndSizes. +#define ASM_SUPPORT_CHECK_FOOTER return count; + +// Generate CheckAsmSupportOffsetsAndSizes(). +#include "asm_support_check.h" namespace art { @@ -58,7 +76,8 @@ class ArchTest : public CommonRuntimeTest { }; TEST_F(ArchTest, CheckCommonOffsetsAndSizes) { - CheckAsmSupportOffsetsAndSizes(); + size_t test_count = CheckAsmSupportOffsetsAndSizes(); + EXPECT_GT(test_count, 0u); } // Grab architecture specific constants. diff --git a/runtime/arch/arm/entrypoints_init_arm.cc b/runtime/arch/arm/entrypoints_init_arm.cc index 919b0afc40..8a8d26466f 100644 --- a/runtime/arch/arm/entrypoints_init_arm.cc +++ b/runtime/arch/arm/entrypoints_init_arm.cc @@ -18,6 +18,7 @@ #include <string.h> #include "arch/arm/asm_support_arm.h" +#include "base/bit_utils.h" #include "entrypoints/jni/jni_entrypoints.h" #include "entrypoints/quick/quick_alloc_entrypoints.h" #include "entrypoints/quick/quick_default_externs.h" diff --git a/runtime/arch/arm64/entrypoints_init_arm64.cc b/runtime/arch/arm64/entrypoints_init_arm64.cc index 610cdee683..9bbcef307e 100644 --- a/runtime/arch/arm64/entrypoints_init_arm64.cc +++ b/runtime/arch/arm64/entrypoints_init_arm64.cc @@ -18,6 +18,7 @@ #include <string.h> #include "arch/arm64/asm_support_arm64.h" +#include "base/bit_utils.h" #include "entrypoints/jni/jni_entrypoints.h" #include "entrypoints/quick/quick_alloc_entrypoints.h" #include "entrypoints/quick/quick_default_externs.h" diff --git a/runtime/asm_support.h b/runtime/asm_support.h index f8096feeb9..44c0661e3f 100644 --- a/runtime/asm_support.h +++ b/runtime/asm_support.h @@ -17,24 +17,6 @@ #ifndef ART_RUNTIME_ASM_SUPPORT_H_ #define ART_RUNTIME_ASM_SUPPORT_H_ -#if defined(__cplusplus) -#include "art_method.h" -#include "base/bit_utils.h" -#include "base/callee_save_type.h" -#include "gc/accounting/card_table.h" -#include "gc/allocator/rosalloc.h" -#include "gc/heap.h" -#include "jit/jit.h" -#include "lock_word.h" -#include "mirror/class.h" -#include "mirror/dex_cache.h" -#include "mirror/string.h" -#include "utils/dex_cache_arrays_layout.h" -#include "runtime.h" -#include "stack.h" -#include "thread.h" -#endif - #include "read_barrier_c.h" #if defined(__arm__) || defined(__mips__) @@ -51,14 +33,10 @@ #define SUSPEND_CHECK_INTERVAL 96 #endif -#if defined(__cplusplus) - +// To generate tests related to the constants in this header, either define ADD_TEST_EQ before +// including, or use asm_support_check.h. #ifndef ADD_TEST_EQ // Allow #include-r to replace with their own. -#define ADD_TEST_EQ(x, y) CHECK_EQ(x, y); -#endif - -static inline void CheckAsmSupportOffsetsAndSizes() { -#else +#define DEFINED_ADD_TEST_EQ 1 #define ADD_TEST_EQ(x, y) #endif @@ -76,6 +54,7 @@ ADD_TEST_EQ(static_cast<size_t>(1U << POINTER_SIZE_SHIFT), // Export new defines (for assembly use) by editing cpp-define-generator def files. #define DEFINE_CHECK_EQ ADD_TEST_EQ #include "asm_support_gen.h" +#undef DEFINE_CHECK_EQ // Offset of field Thread::tlsPtr_.exception. #define THREAD_EXCEPTION_OFFSET (THREAD_CARD_TABLE_OFFSET + __SIZEOF_POINTER__) @@ -252,8 +231,9 @@ ADD_TEST_EQ(MIRROR_STRING_VALUE_OFFSET, art::mirror::String::ValueOffset().Int32 #define STRING_COMPRESSION_FEATURE 1 ADD_TEST_EQ(STRING_COMPRESSION_FEATURE, art::mirror::kUseStringCompression); -#if defined(__cplusplus) -} // End of CheckAsmSupportOffsets. +#ifdef DEFINED_ADD_TEST_EQ +#undef ADD_TEST_EQ +#undef DEFINED_ADD_TEST_EQ #endif #endif // ART_RUNTIME_ASM_SUPPORT_H_ diff --git a/runtime/asm_support_check.h b/runtime/asm_support_check.h new file mode 100644 index 0000000000..cc6a578313 --- /dev/null +++ b/runtime/asm_support_check.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_ASM_SUPPORT_CHECK_H_ +#define ART_RUNTIME_ASM_SUPPORT_CHECK_H_ + +#include "art_method.h" +#include "base/bit_utils.h" +#include "base/callee_save_type.h" +#include "gc/accounting/card_table.h" +#include "gc/allocator/rosalloc.h" +#include "gc/heap.h" +#include "jit/jit.h" +#include "lock_word.h" +#include "mirror/class.h" +#include "mirror/dex_cache.h" +#include "mirror/string.h" +#include "utils/dex_cache_arrays_layout.h" +#include "runtime.h" +#include "stack.h" +#include "thread.h" + +#ifndef ADD_TEST_EQ +#define ADD_TEST_EQ(x, y) CHECK_EQ(x, y); +#endif + +#ifndef ASM_SUPPORT_CHECK_RETURN_TYPE +#define ASM_SUPPORT_CHECK_RETURN_TYPE void +#endif + +// Prepare for re-include of asm_support.h. +#ifdef ART_RUNTIME_ASM_SUPPORT_H_ +#undef ART_RUNTIME_ASM_SUPPORT_H_ +#endif + +namespace art { + +static inline ASM_SUPPORT_CHECK_RETURN_TYPE CheckAsmSupportOffsetsAndSizes() { +#ifdef ASM_SUPPORT_CHECK_HEADER + ASM_SUPPORT_CHECK_HEADER +#endif + +#include "asm_support.h" + +#ifdef ASM_SUPPORT_CHECK_FOOTER + ASM_SUPPORT_CHECK_FOOTER +#endif +} + +} // namespace art + +#endif // ART_RUNTIME_ASM_SUPPORT_CHECK_H_ diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc index 0cafac7380..6d20b49c37 100644 --- a/runtime/jit/jit_code_cache.cc +++ b/runtime/jit/jit_code_cache.cc @@ -29,6 +29,7 @@ #include "entrypoints/runtime_asm_entrypoints.h" #include "gc/accounting/bitmap-inl.h" #include "gc/scoped_gc_critical_section.h" +#include "intern_table.h" #include "jit/jit.h" #include "jit/profiling_info.h" #include "linear_alloc.h" diff --git a/runtime/mirror/string-inl.h b/runtime/mirror/string-inl.h index 57b20a193b..75606391ad 100644 --- a/runtime/mirror/string-inl.h +++ b/runtime/mirror/string-inl.h @@ -26,7 +26,6 @@ #include "common_throws.h" #include "gc/heap-inl.h" #include "globals.h" -#include "intern_table.h" #include "runtime.h" #include "thread.h" #include "utf.h" @@ -161,10 +160,6 @@ class SetStringCountAndValueVisitorFromString { const int32_t offset_; }; -inline ObjPtr<String> String::Intern() { - return Runtime::Current()->GetInternTable()->InternWeak(this); -} - inline uint16_t String::CharAt(int32_t index) { int32_t count = GetLength(); if (UNLIKELY((index < 0) || (index >= count))) { diff --git a/runtime/mirror/string.cc b/runtime/mirror/string.cc index d0636932cb..82ff6ddead 100644 --- a/runtime/mirror/string.cc +++ b/runtime/mirror/string.cc @@ -421,5 +421,9 @@ std::string String::PrettyStringDescriptor() { return PrettyDescriptor(ToModifiedUtf8().c_str()); } +ObjPtr<String> String::Intern() { + return Runtime::Current()->GetInternTable()->InternWeak(this); +} + } // namespace mirror } // namespace art diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 743d6f428b..c11e4bd448 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -57,6 +57,7 @@ #include "art_field-inl.h" #include "art_method-inl.h" #include "asm_support.h" +#include "asm_support_check.h" #include "atomic.h" #include "base/arena_allocator.h" #include "base/dumpable.h" |