diff options
author | 2018-03-02 12:01:51 -0800 | |
---|---|---|
committer | 2018-03-05 13:58:20 -0800 | |
commit | c431b9dc4b23cc950eb313695258df5d89f53b22 (patch) | |
tree | 422273559c3ae52caff0c6b1cf1a62a8312f0e26 | |
parent | f46f46cf5bd32788d5252b7107628a66594a5e98 (diff) |
Move most of runtime/base to libartbase/base
Enforce the layering that code in runtime/base should not depend on
runtime by separating it into libartbase. Some of the code in
runtime/base depends on the Runtime class, so it cannot be moved yet.
Also, some of the tests depend on CommonRuntimeTest, which itself needs
to be factored (in a subsequent CL).
Bug: 22322814
Test: make -j 50 checkbuild
make -j 50 test-art-host
Change-Id: I8b096c1e2542f829eb456b4b057c71421b77d7e2
257 files changed, 926 insertions, 820 deletions
diff --git a/cmdline/cmdline.h b/cmdline/cmdline.h index 60dfdce03b..95ab12324c 100644 --- a/cmdline/cmdline.h +++ b/cmdline/cmdline.h @@ -28,6 +28,7 @@ #include "base/file_utils.h" #include "base/logging.h" +#include "base/mutex.h" #include "base/stringpiece.h" #include "noop_compiler_callbacks.h" #include "runtime.h" @@ -303,6 +304,7 @@ struct CmdlineArgs { template <typename Args = CmdlineArgs> struct CmdlineMain { int Main(int argc, char** argv) { + Locks::Init(); InitLogging(argv, Runtime::Abort); std::unique_ptr<Args> args = std::unique_ptr<Args>(CreateArguments()); args_ = args.get(); diff --git a/cmdline/cmdline_parser_test.cc b/cmdline/cmdline_parser_test.cc index 3cb9731a17..235a2aa90e 100644 --- a/cmdline/cmdline_parser_test.cc +++ b/cmdline/cmdline_parser_test.cc @@ -20,12 +20,13 @@ #include "gtest/gtest.h" +#include "base/mutex.h" +#include "base/utils.h" #include "jdwp_provider.h" #include "experimental_flags.h" #include "parsed_options.h" #include "runtime.h" #include "runtime_options.h" -#include "utils.h" #define EXPECT_NULL(expected) EXPECT_EQ(reinterpret_cast<const void*>(expected), \ reinterpret_cast<void*>(nullptr)); @@ -126,6 +127,7 @@ class CmdlineParserTest : public ::testing::Test { using RuntimeParser = ParsedOptions::RuntimeParser; static void SetUpTestCase() { + art::Locks::Init(); art::InitLogging(nullptr, art::Runtime::Abort); // argv = null } diff --git a/cmdline/cmdline_result.h b/cmdline/cmdline_result.h index e41043abf0..0ae1145a52 100644 --- a/cmdline/cmdline_result.h +++ b/cmdline/cmdline_result.h @@ -18,7 +18,7 @@ #define ART_CMDLINE_CMDLINE_RESULT_H_ #include <assert.h> -#include <utils.h> +#include "base/utils.h" namespace art { // Result of an attempt to process the command line arguments. If fails, specifies diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc index a20313374c..d3e3a51f7a 100644 --- a/compiler/common_compiler_test.cc +++ b/compiler/common_compiler_test.cc @@ -21,6 +21,7 @@ #include "art_method-inl.h" #include "base/callee_save_type.h" #include "base/enums.h" +#include "base/utils.h" #include "class_linker.h" #include "compiled_method-inl.h" #include "dex/descriptors_names.h" @@ -36,7 +37,6 @@ #include "oat_quick_method_header.h" #include "scoped_thread_state_change-inl.h" #include "thread-current-inl.h" -#include "utils.h" namespace art { diff --git a/compiler/compiler.cc b/compiler/compiler.cc index 7c7ae71d77..646040fd9d 100644 --- a/compiler/compiler.cc +++ b/compiler/compiler.cc @@ -19,10 +19,10 @@ #include <android-base/logging.h> #include "base/macros.h" +#include "base/utils.h" #include "dex/code_item_accessors-inl.h" #include "driver/compiler_driver.h" #include "optimizing/optimizing_compiler.h" -#include "utils.h" namespace art { diff --git a/compiler/compiler.h b/compiler/compiler.h index a17e2b5875..f2ec3a9fa3 100644 --- a/compiler/compiler.h +++ b/compiler/compiler.h @@ -18,8 +18,8 @@ #define ART_COMPILER_COMPILER_H_ #include "base/mutex.h" +#include "base/os.h" #include "dex/dex_file.h" -#include "os.h" namespace art { diff --git a/compiler/debug/dwarf/dwarf_test.h b/compiler/debug/dwarf/dwarf_test.h index 5405759c1f..9a7c604ca1 100644 --- a/compiler/debug/dwarf/dwarf_test.h +++ b/compiler/debug/dwarf/dwarf_test.h @@ -26,12 +26,12 @@ #include <set> #include <string> +#include "base/os.h" #include "base/unix_file/fd_file.h" #include "common_runtime_test.h" #include "gtest/gtest.h" #include "linker/elf_builder.h" #include "linker/file_output_stream.h" -#include "os.h" namespace art { namespace dwarf { diff --git a/compiler/debug/elf_symtab_writer.h b/compiler/debug/elf_symtab_writer.h index 1310e8dabd..7a8e29191a 100644 --- a/compiler/debug/elf_symtab_writer.h +++ b/compiler/debug/elf_symtab_writer.h @@ -20,12 +20,12 @@ #include <map> #include <unordered_set> +#include "base/utils.h" #include "debug/debug_info.h" #include "debug/method_debug_info.h" #include "dex/dex_file-inl.h" #include "dex/code_item_accessors.h" #include "linker/elf_builder.h" -#include "utils.h" namespace art { namespace debug { diff --git a/compiler/driver/compiled_method_storage.cc b/compiler/driver/compiled_method_storage.cc index 48477abe5b..a26a985ff9 100644 --- a/compiler/driver/compiled_method_storage.cc +++ b/compiler/driver/compiled_method_storage.cc @@ -21,10 +21,10 @@ #include <android-base/logging.h> +#include "base/utils.h" #include "compiled_method.h" #include "linker/linker_patch.h" #include "thread-current-inl.h" -#include "utils.h" #include "utils/dedupe_set-inl.h" #include "utils/swap_space.h" diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index a3bb4ec34d..8db892bf18 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -29,6 +29,8 @@ #include "base/array_ref.h" #include "base/bit_utils.h" #include "base/mutex.h" +#include "base/os.h" +#include "base/quasi_atomic.h" #include "base/safe_map.h" #include "base/timing_logger.h" #include "class_reference.h" @@ -39,7 +41,6 @@ #include "dex/dex_to_dex_compiler.h" #include "driver/compiled_method_storage.h" #include "method_reference.h" -#include "os.h" #include "thread_pool.h" #include "utils/atomic_dex_ref_map.h" #include "utils/dex_cache_arrays_layout.h" diff --git a/compiler/driver/compiler_options.h b/compiler/driver/compiler_options.h index 18b0913430..05d8805e81 100644 --- a/compiler/driver/compiler_options.h +++ b/compiler/driver/compiler_options.h @@ -22,10 +22,10 @@ #include <vector> #include "base/macros.h" +#include "base/utils.h" #include "compiler_filter.h" #include "globals.h" #include "optimizing/register_allocator.h" -#include "utils.h" namespace art { diff --git a/compiler/driver/dex_compilation_unit.cc b/compiler/driver/dex_compilation_unit.cc index 2e315b5d12..c90c37d54a 100644 --- a/compiler/driver/dex_compilation_unit.cc +++ b/compiler/driver/dex_compilation_unit.cc @@ -16,10 +16,10 @@ #include "dex_compilation_unit.h" +#include "base/utils.h" #include "dex/code_item_accessors-inl.h" #include "dex/descriptors_names.h" #include "mirror/dex_cache.h" -#include "utils.h" namespace art { diff --git a/compiler/jni/quick/jni_compiler.cc b/compiler/jni/quick/jni_compiler.cc index fc44927231..d001cfe4fc 100644 --- a/compiler/jni/quick/jni_compiler.cc +++ b/compiler/jni/quick/jni_compiler.cc @@ -27,6 +27,7 @@ #include "base/enums.h" #include "base/logging.h" // For VLOG. #include "base/macros.h" +#include "base/utils.h" #include "calling_convention.h" #include "class_linker.h" #include "debug/dwarf/debug_frame_opcode_writer.h" @@ -37,7 +38,6 @@ #include "jni_env_ext.h" #include "memory_region.h" #include "thread.h" -#include "utils.h" #include "utils/arm/managed_register_arm.h" #include "utils/arm64/managed_register_arm64.h" #include "utils/assembler.h" diff --git a/compiler/linker/file_output_stream.h b/compiler/linker/file_output_stream.h index 28296a47fd..deb051fca4 100644 --- a/compiler/linker/file_output_stream.h +++ b/compiler/linker/file_output_stream.h @@ -17,9 +17,9 @@ #ifndef ART_COMPILER_LINKER_FILE_OUTPUT_STREAM_H_ #define ART_COMPILER_LINKER_FILE_OUTPUT_STREAM_H_ -#include "output_stream.h" +#include "base/os.h" -#include "os.h" +#include "output_stream.h" namespace art { namespace linker { diff --git a/compiler/optimizing/codegen_test.cc b/compiler/optimizing/codegen_test.cc index ba4040acad..a0fd5ffcb1 100644 --- a/compiler/optimizing/codegen_test.cc +++ b/compiler/optimizing/codegen_test.cc @@ -18,6 +18,7 @@ #include <memory> #include "base/macros.h" +#include "base/utils.h" #include "builder.h" #include "codegen_test_utils.h" #include "dex/dex_file.h" @@ -26,7 +27,6 @@ #include "nodes.h" #include "optimizing_unit_test.h" #include "register_allocator_linear_scan.h" -#include "utils.h" #include "utils/arm/assembler_arm_vixl.h" #include "utils/arm/managed_register_arm.h" #include "utils/mips/managed_register_mips.h" diff --git a/compiler/optimizing/gvn.cc b/compiler/optimizing/gvn.cc index 71c394ec1f..f05159b735 100644 --- a/compiler/optimizing/gvn.cc +++ b/compiler/optimizing/gvn.cc @@ -17,11 +17,11 @@ #include "gvn.h" #include "base/arena_bit_vector.h" +#include "base/bit_vector-inl.h" #include "base/scoped_arena_allocator.h" #include "base/scoped_arena_containers.h" -#include "base/bit_vector-inl.h" +#include "base/utils.h" #include "side_effects_analysis.h" -#include "utils.h" namespace art { diff --git a/compiler/optimizing/intrinsics.cc b/compiler/optimizing/intrinsics.cc index acb830e524..f8dc316e45 100644 --- a/compiler/optimizing/intrinsics.cc +++ b/compiler/optimizing/intrinsics.cc @@ -18,6 +18,7 @@ #include "art_field-inl.h" #include "art_method-inl.h" +#include "base/utils.h" #include "class_linker.h" #include "dex/invoke_type.h" #include "driver/compiler_driver.h" @@ -26,7 +27,6 @@ #include "nodes.h" #include "scoped_thread_state_change-inl.h" #include "thread-current-inl.h" -#include "utils.h" namespace art { diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 99d80d77c5..62550be526 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -26,6 +26,7 @@ #include "base/arena_object.h" #include "base/array_ref.h" #include "base/iteration_range.h" +#include "base/quasi_atomic.h" #include "base/stl_util.h" #include "base/transform_array_ref.h" #include "data_type.h" diff --git a/compiler/optimizing/optimizing_compiler_stats.h b/compiler/optimizing/optimizing_compiler_stats.h index 0023265e50..00194ff1fe 100644 --- a/compiler/optimizing/optimizing_compiler_stats.h +++ b/compiler/optimizing/optimizing_compiler_stats.h @@ -22,9 +22,9 @@ #include <string> #include <type_traits> -#include "atomic.h" +#include "base/atomic.h" +#include "base/globals.h" #include "base/logging.h" // For VLOG_IS_ON. -#include "globals.h" namespace art { diff --git a/compiler/utils/assembler_test_base.h b/compiler/utils/assembler_test_base.h index 1482210ac4..778a01566c 100644 --- a/compiler/utils/assembler_test_base.h +++ b/compiler/utils/assembler_test_base.h @@ -25,9 +25,9 @@ #include "android-base/strings.h" +#include "base/utils.h" #include "common_runtime_test.h" // For ScratchFile #include "exec_utils.h" -#include "utils.h" namespace art { diff --git a/compiler/utils/atomic_dex_ref_map.h b/compiler/utils/atomic_dex_ref_map.h index cabd79e9f1..fc2437999e 100644 --- a/compiler/utils/atomic_dex_ref_map.h +++ b/compiler/utils/atomic_dex_ref_map.h @@ -17,7 +17,7 @@ #ifndef ART_COMPILER_UTILS_ATOMIC_DEX_REF_MAP_H_ #define ART_COMPILER_UTILS_ATOMIC_DEX_REF_MAP_H_ -#include "atomic.h" +#include "base/atomic.h" #include "base/dchecked_vector.h" #include "base/safe_map.h" #include "dex/dex_file_reference.h" diff --git a/compiler/utils/swap_space_test.cc b/compiler/utils/swap_space_test.cc index f4bca59cb3..1650080e66 100644 --- a/compiler/utils/swap_space_test.cc +++ b/compiler/utils/swap_space_test.cc @@ -24,9 +24,9 @@ #include "gtest/gtest.h" +#include "base/os.h" #include "base/unix_file/fd_file.h" #include "common_runtime_test.h" -#include "os.h" namespace art { diff --git a/compiler/utils/test_dex_file_builder_test.cc b/compiler/utils/test_dex_file_builder_test.cc index 736a17edac..788afd8e1a 100644 --- a/compiler/utils/test_dex_file_builder_test.cc +++ b/compiler/utils/test_dex_file_builder_test.cc @@ -16,9 +16,9 @@ #include "test_dex_file_builder.h" +#include "base/utils.h" #include "dex/dex_file-inl.h" #include "gtest/gtest.h" -#include "utils.h" namespace art { diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index 926575e10c..73afbad184 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -46,12 +46,15 @@ #include "base/file_utils.h" #include "base/leb128.h" #include "base/macros.h" +#include "base/mutex.h" +#include "base/os.h" #include "base/scoped_flock.h" #include "base/stl_util.h" #include "base/stringpiece.h" #include "base/time_utils.h" #include "base/timing_logger.h" #include "base/unix_file/fd_file.h" +#include "base/utils.h" #include "class_linker.h" #include "class_loader_context.h" #include "cmdline_parser.h" @@ -89,11 +92,9 @@ #include "mirror/object_array-inl.h" #include "oat_file.h" #include "oat_file_assistant.h" -#include "os.h" #include "runtime.h" #include "runtime_options.h" #include "scoped_thread_state_change-inl.h" -#include "utils.h" #include "vdex_file.h" #include "verifier/verifier_deps.h" #include "well_known_classes.h" @@ -1164,6 +1165,7 @@ class Dex2Oat FINAL { original_argc = argc; original_argv = argv; + Locks::Init(); InitLogging(argv, Runtime::Abort); compiler_options_.reset(new CompilerOptions()); diff --git a/dex2oat/dex2oat_image_test.cc b/dex2oat/dex2oat_image_test.cc index 05592f1806..49b84bb0c6 100644 --- a/dex2oat/dex2oat_image_test.cc +++ b/dex2oat/dex2oat_image_test.cc @@ -29,13 +29,13 @@ #include "base/file_utils.h" #include "base/macros.h" #include "base/unix_file/fd_file.h" +#include "base/utils.h" #include "dex/art_dex_file_loader.h" #include "dex/dex_file-inl.h" #include "dex/dex_file_loader.h" #include "jit/profile_compilation_info.h" #include "method_reference.h" #include "runtime.h" -#include "utils.h" namespace art { @@ -129,9 +129,9 @@ class Dex2oatImageTest : public CommonRuntimeTest { std::string art_file = scratch.GetFilename() + ".art"; std::string oat_file = scratch.GetFilename() + ".oat"; std::string vdex_file = scratch.GetFilename() + ".vdex"; - ret.art_size = GetFileSizeBytes(art_file); - ret.oat_size = GetFileSizeBytes(oat_file); - ret.vdex_size = GetFileSizeBytes(vdex_file); + ret.art_size = OS::GetFileSizeBytes(art_file.c_str()); + ret.oat_size = OS::GetFileSizeBytes(oat_file.c_str()); + ret.vdex_size = OS::GetFileSizeBytes(vdex_file.c_str()); CHECK_GT(ret.art_size, 0u) << art_file; CHECK_GT(ret.oat_size, 0u) << oat_file; CHECK_GT(ret.vdex_size, 0u) << vdex_file; diff --git a/dex2oat/dex2oat_options.h b/dex2oat/dex2oat_options.h index ccc85c8951..cc124c1afa 100644 --- a/dex2oat/dex2oat_options.h +++ b/dex2oat/dex2oat_options.h @@ -21,6 +21,7 @@ #include <string> #include <vector> +#include "arch/instruction_set.h" #include "base/variant_map.h" #include "cmdline_types.h" // TODO: don't need to include this file here #include "compiler.h" diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc index 6b75595005..96dd319946 100644 --- a/dex2oat/dex2oat_test.cc +++ b/dex2oat/dex2oat_test.cc @@ -29,6 +29,7 @@ #include "base/macros.h" #include "base/mutex-inl.h" +#include "base/utils.h" #include "bytecode_utils.h" #include "dex/art_dex_file_loader.h" #include "dex/base64_test_util.h" @@ -40,7 +41,6 @@ #include "jit/profile_compilation_info.h" #include "oat.h" #include "oat_file.h" -#include "utils.h" #include "vdex_file.h" #include "ziparchive/zip_writer.h" diff --git a/dex2oat/linker/elf_writer.h b/dex2oat/linker/elf_writer.h index 7c4774038e..bcf2cd7d4b 100644 --- a/dex2oat/linker/elf_writer.h +++ b/dex2oat/linker/elf_writer.h @@ -25,8 +25,8 @@ #include "base/array_ref.h" #include "base/macros.h" #include "base/mutex.h" +#include "base/os.h" #include "debug/debug_info.h" -#include "os.h" namespace art { diff --git a/dex2oat/linker/elf_writer_quick.cc b/dex2oat/linker/elf_writer_quick.cc index d2e863c2a8..07b02f1033 100644 --- a/dex2oat/linker/elf_writer_quick.cc +++ b/dex2oat/linker/elf_writer_quick.cc @@ -24,6 +24,7 @@ #include "base/casts.h" #include "base/leb128.h" +#include "base/utils.h" #include "compiled_method.h" #include "debug/elf_debug_writer.h" #include "debug/method_debug_info.h" @@ -36,7 +37,6 @@ #include "linker/file_output_stream.h" #include "thread-current-inl.h" #include "thread_pool.h" -#include "utils.h" namespace art { namespace linker { diff --git a/dex2oat/linker/elf_writer_quick.h b/dex2oat/linker/elf_writer_quick.h index e20957c5ce..274d18b858 100644 --- a/dex2oat/linker/elf_writer_quick.h +++ b/dex2oat/linker/elf_writer_quick.h @@ -20,8 +20,8 @@ #include <memory> #include "arch/instruction_set.h" +#include "base/os.h" #include "elf_writer.h" -#include "os.h" namespace art { diff --git a/dex2oat/linker/elf_writer_test.cc b/dex2oat/linker/elf_writer_test.cc index 8427e7b8ce..b2be003b5d 100644 --- a/dex2oat/linker/elf_writer_test.cc +++ b/dex2oat/linker/elf_writer_test.cc @@ -18,13 +18,13 @@ #include "base/file_utils.h" #include "base/unix_file/fd_file.h" +#include "base/utils.h" #include "common_compiler_test.h" #include "elf_file.h" #include "elf_file_impl.h" #include "elf_writer_quick.h" #include "linker/elf_builder.h" #include "oat.h" -#include "utils.h" namespace art { namespace linker { diff --git a/dex2oat/linker/image_test.h b/dex2oat/linker/image_test.h index c6ce951506..319c5fb675 100644 --- a/dex2oat/linker/image_test.h +++ b/dex2oat/linker/image_test.h @@ -28,6 +28,7 @@ #include "art_method-inl.h" #include "base/file_utils.h" #include "base/unix_file/fd_file.h" +#include "base/utils.h" #include "class_linker-inl.h" #include "common_compiler_test.h" #include "compiler_callbacks.h" @@ -46,7 +47,6 @@ #include "oat_writer.h" #include "scoped_thread_state_change-inl.h" #include "signal_catcher.h" -#include "utils.h" namespace art { namespace linker { diff --git a/dex2oat/linker/image_writer.h b/dex2oat/linker/image_writer.h index 856edfb3bc..36bbb47786 100644 --- a/dex2oat/linker/image_writer.h +++ b/dex2oat/linker/image_writer.h @@ -33,7 +33,9 @@ #include "base/enums.h" #include "base/length_prefixed_array.h" #include "base/macros.h" +#include "base/os.h" #include "base/safe_map.h" +#include "base/utils.h" #include "class_table.h" #include "driver/compiler_driver.h" #include "image.h" @@ -43,8 +45,6 @@ #include "mirror/dex_cache.h" #include "oat_file.h" #include "obj_ptr.h" -#include "os.h" -#include "utils.h" namespace art { namespace gc { diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc index 2feb14a357..c72beea6ce 100644 --- a/dex2oat/linker/oat_writer.cc +++ b/dex2oat/linker/oat_writer.cc @@ -27,6 +27,7 @@ #include "base/enums.h" #include "base/file_magic.h" #include "base/logging.h" // For VLOG +#include "base/os.h" #include "base/safe_map.h" #include "base/stl_util.h" #include "base/unix_file/fd_file.h" @@ -60,7 +61,6 @@ #include "mirror/dex_cache-inl.h" #include "mirror/object-inl.h" #include "oat_quick_method_header.h" -#include "os.h" #include "quicken_info.h" #include "scoped_thread_state_change-inl.h" #include "type_lookup_table.h" diff --git a/dex2oat/linker/oat_writer.h b/dex2oat/linker/oat_writer.h index d67e4dedfc..0cb0ef20df 100644 --- a/dex2oat/linker/oat_writer.h +++ b/dex2oat/linker/oat_writer.h @@ -24,6 +24,7 @@ #include "base/array_ref.h" #include "base/dchecked_vector.h" +#include "base/os.h" #include "base/safe_map.h" #include "compiler.h" #include "dex/compact_dex_level.h" @@ -33,7 +34,6 @@ #include "method_reference.h" #include "mirror/class.h" #include "oat.h" -#include "os.h" #include "string_reference.h" #include "type_reference.h" diff --git a/dexdump/dexdump_test.cc b/dexdump/dexdump_test.cc index 559dc8e781..63e0e3f20d 100644 --- a/dexdump/dexdump_test.cc +++ b/dexdump/dexdump_test.cc @@ -22,10 +22,10 @@ #include <unistd.h> #include "arch/instruction_set.h" +#include "base/os.h" +#include "base/utils.h" #include "common_runtime_test.h" #include "exec_utils.h" -#include "os.h" -#include "utils.h" namespace art { diff --git a/dexlayout/compact_dex_writer.h b/dexlayout/compact_dex_writer.h index 0e7d65f9e4..eaf85185f1 100644 --- a/dexlayout/compact_dex_writer.h +++ b/dexlayout/compact_dex_writer.h @@ -22,8 +22,8 @@ #include <memory> // For unique_ptr #include <unordered_map> +#include "base/utils.h" #include "dex_writer.h" -#include "utils.h" namespace art { diff --git a/dexlayout/dex_writer.h b/dexlayout/dex_writer.h index df098c0f6f..db1898bf26 100644 --- a/dexlayout/dex_writer.h +++ b/dexlayout/dex_writer.h @@ -22,13 +22,12 @@ #include <functional> #include <memory> // For unique_ptr +#include "base/os.h" #include "base/unix_file/fd_file.h" #include "dex/compact_dex_level.h" #include "dex_container.h" #include "dex/dex_file.h" #include "dex_ir.h" -#include "mem_map.h" -#include "os.h" #include <queue> diff --git a/dexlayout/dexdiag.cc b/dexlayout/dexdiag.cc index c0d6f02c00..6cb141f688 100644 --- a/dexlayout/dexdiag.cc +++ b/dexlayout/dexdiag.cc @@ -27,6 +27,7 @@ #include "android-base/stringprintf.h" #include "base/logging.h" // For InitLogging. +#include "base/mutex.h" #include "base/stringpiece.h" #include "dexlayout.h" @@ -470,6 +471,7 @@ static int DexDiagMain(int argc, char* argv[]) { } // Art specific set up. + Locks::Init(); InitLogging(argv, Runtime::Abort); MemMap::Init(); diff --git a/dexlayout/dexdiag_test.cc b/dexlayout/dexdiag_test.cc index 9927576400..068949ceba 100644 --- a/dexlayout/dexdiag_test.cc +++ b/dexlayout/dexdiag_test.cc @@ -20,9 +20,9 @@ #include "common_runtime_test.h" #include "base/file_utils.h" +#include "base/os.h" #include "exec_utils.h" #include "oat_file.h" -#include "os.h" namespace art { diff --git a/dexlayout/dexlayout.cc b/dexlayout/dexlayout.cc index 159a4a5ec2..ec0cbe6a60 100644 --- a/dexlayout/dexlayout.cc +++ b/dexlayout/dexlayout.cc @@ -34,6 +34,8 @@ #include "android-base/stringprintf.h" #include "base/logging.h" // For VLOG_IS_ON. +#include "base/os.h" +#include "base/utils.h" #include "dex/art_dex_file_loader.h" #include "dex/descriptors_names.h" #include "dex/dex_file-inl.h" @@ -48,8 +50,6 @@ #include "dex_writer.h" #include "jit/profile_compilation_info.h" #include "mem_map.h" -#include "os.h" -#include "utils.h" namespace art { diff --git a/dexlayout/dexlayout.h b/dexlayout/dexlayout.h index b79a59209d..2bca10ddfb 100644 --- a/dexlayout/dexlayout.h +++ b/dexlayout/dexlayout.h @@ -31,7 +31,6 @@ #include "dex_container.h" #include "dex/dex_file_layout.h" #include "dex_ir.h" -#include "mem_map.h" namespace art { diff --git a/dexlayout/dexlayout_test.cc b/dexlayout/dexlayout_test.cc index 981f9010ee..6719d0848c 100644 --- a/dexlayout/dexlayout_test.cc +++ b/dexlayout/dexlayout_test.cc @@ -22,6 +22,7 @@ #include <unistd.h> #include "base/unix_file/fd_file.h" +#include "base/utils.h" #include "common_runtime_test.h" #include "dex/art_dex_file_loader.h" #include "dex/base64_test_util.h" @@ -31,7 +32,6 @@ #include "dexlayout.h" #include "exec_utils.h" #include "jit/profile_compilation_info.h" -#include "utils.h" namespace art { diff --git a/dexlist/dexlist_test.cc b/dexlist/dexlist_test.cc index ae44848461..0b9adbddb8 100644 --- a/dexlist/dexlist_test.cc +++ b/dexlist/dexlist_test.cc @@ -22,12 +22,12 @@ #include <unistd.h> #include "arch/instruction_set.h" +#include "base/os.h" +#include "base/utils.h" #include "common_runtime_test.h" #include "exec_utils.h" #include "gc/heap.h" #include "gc/space/image_space.h" -#include "os.h" -#include "utils.h" namespace art { diff --git a/dexoptanalyzer/dexoptanalyzer.cc b/dexoptanalyzer/dexoptanalyzer.cc index 6d4b3e3e52..febccf1950 100644 --- a/dexoptanalyzer/dexoptanalyzer.cc +++ b/dexoptanalyzer/dexoptanalyzer.cc @@ -17,19 +17,19 @@ #include <string> #include "base/logging.h" // For InitLogging. +#include "base/mutex.h" +#include "base/os.h" +#include "base/utils.h" #include "android-base/stringprintf.h" #include "android-base/strings.h" #include "base/file_utils.h" -#include "base/logging.h" // For InitLogging. #include "compiler_filter.h" #include "class_loader_context.h" #include "dex/dex_file.h" #include "noop_compiler_callbacks.h" #include "oat_file_assistant.h" -#include "os.h" #include "runtime.h" #include "thread-inl.h" -#include "utils.h" namespace art { @@ -142,6 +142,7 @@ class DexoptAnalyzer FINAL { original_argc = argc; original_argv = argv; + Locks::Init(); InitLogging(argv, Runtime::Abort); // Skip over the command name. argv++; diff --git a/imgdiag/imgdiag.cc b/imgdiag/imgdiag.cc index 8aa638a0e0..ddb8fe1302 100644 --- a/imgdiag/imgdiag.cc +++ b/imgdiag/imgdiag.cc @@ -30,6 +30,7 @@ #include "art_field-inl.h" #include "art_method-inl.h" +#include "base/os.h" #include "base/unix_file/fd_file.h" #include "class_linker.h" #include "gc/heap.h" @@ -40,7 +41,6 @@ #include "oat.h" #include "oat_file.h" #include "oat_file_manager.h" -#include "os.h" #include "scoped_thread_state_change-inl.h" #include "backtrace/BacktraceMap.h" diff --git a/imgdiag/imgdiag_test.cc b/imgdiag/imgdiag_test.cc index 80b0c26b7f..52096f0d7b 100644 --- a/imgdiag/imgdiag_test.cc +++ b/imgdiag/imgdiag_test.cc @@ -24,13 +24,13 @@ #include "android-base/stringprintf.h" #include "arch/instruction_set.h" +#include "base/os.h" +#include "base/utils.h" #include "common_runtime_test.h" #include "exec_utils.h" #include "gc/heap.h" #include "gc/space/image_space.h" -#include "os.h" #include "runtime.h" -#include "utils.h" namespace art { diff --git a/libartbase/Android.bp b/libartbase/Android.bp index 290d39844c..3c61944477 100644 --- a/libartbase/Android.bp +++ b/libartbase/Android.bp @@ -14,15 +14,100 @@ // limitations under the License. // +cc_defaults { + name: "libartbase_defaults", + defaults: ["art_defaults"], + host_supported: true, + srcs: [ + "base/allocator.cc", + "base/bit_vector.cc", + "base/file_magic.cc", + "base/hex_dump.cc", + "base/logging.cc", + "base/os_linux.cc", + "base/runtime_debug.cc", + "base/safe_copy.cc", + "base/scoped_flock.cc", + "base/time_utils.cc", + "base/unix_file/fd_file.cc", + "base/unix_file/random_access_file_utils.cc", + "base/utils.cc", + ], + generated_sources: ["art_libartbase_operator_srcs"], + cflags: ["-DBUILDING_LIBART=1"], + shared_libs: [ + // For common macros. + "libbase", + "liblog", + ], + export_include_dirs: ["."], + // ART's macros.h depends on libbase's macros.h. + // Note: runtime_options.h depends on cmdline. But we don't really want to export this + // generically. dex2oat takes care of it itself. + export_shared_lib_headers: ["libbase"], +} + +gensrcs { + name: "art_libartbase_operator_srcs", + cmd: "$(location generate_operator_out) art/libartbase $(in) > $(out)", + tools: ["generate_operator_out"], + srcs: [ + "base/allocator.h", + "base/callee_save_type.h", + "base/unix_file/fd_file.h", + ], + output_extension: "operator_out.cc", +} + +art_cc_library { + name: "libartbase", + defaults: ["libartbase_defaults"], + // Leave the symbols in the shared library so that stack unwinders can + // produce meaningful name resolution. + strip: { + keep_symbols: true, + }, + shared_libs: ["libbase"], + export_shared_lib_headers: ["libbase"], +} + +art_cc_library { + name: "libartbased", + defaults: [ + "art_debug_defaults", + "libartbase_defaults", + ], + shared_libs: ["libbase"], + export_shared_lib_headers: ["libbase"], +} + +// For now many of these tests still use CommonRuntimeTest, almost universally because of +// ScratchFile and related. +// TODO: Remove CommonRuntimeTest dependency from these tests. art_cc_test { name: "art_libartbase_tests", defaults: [ "art_gtest_defaults", ], srcs: [ + "base/bit_field_test.cc", + "base/bit_string_test.cc", + "base/bit_struct_test.cc", "base/bit_utils_test.cc", + "base/bit_vector_test.cc", "base/hash_set_test.cc", + "base/hex_dump_test.cc", + "base/histogram_test.cc", "base/leb128_test.cc", + "base/logging_test.cc", + "base/safe_copy_test.cc", + "base/scoped_flock_test.cc", + "base/time_utils_test.cc", + "base/transform_array_ref_test.cc", + "base/transform_iterator_test.cc", + "base/unix_file/fd_file_test.cc", + "base/utils_test.cc", + "base/variant_map_test.cc", ], shared_libs: [ "libbase", @@ -36,4 +121,3 @@ cc_library_headers { shared_libs: ["libbase"], export_shared_lib_headers: ["libbase"], } - diff --git a/runtime/base/aborting.h b/libartbase/base/aborting.h index 8906c96ea7..c7089af695 100644 --- a/runtime/base/aborting.h +++ b/libartbase/base/aborting.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_ABORTING_H_ -#define ART_RUNTIME_BASE_ABORTING_H_ +#ifndef ART_LIBARTBASE_BASE_ABORTING_H_ +#define ART_LIBARTBASE_BASE_ABORTING_H_ #include <atomic> @@ -28,4 +28,4 @@ extern std::atomic<unsigned int> gAborting; } // namespace art -#endif // ART_RUNTIME_BASE_ABORTING_H_ +#endif // ART_LIBARTBASE_BASE_ABORTING_H_ diff --git a/runtime/base/allocator.cc b/libartbase/base/allocator.cc index 2da88c3830..a42414507b 100644 --- a/runtime/base/allocator.cc +++ b/libartbase/base/allocator.cc @@ -21,7 +21,7 @@ #include <android-base/logging.h> -#include "atomic.h" +#include "base/atomic.h" namespace art { diff --git a/runtime/base/allocator.h b/libartbase/base/allocator.h index 3cedb66abe..d92fe193e6 100644 --- a/runtime/base/allocator.h +++ b/libartbase/base/allocator.h @@ -14,14 +14,13 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_ALLOCATOR_H_ -#define ART_RUNTIME_BASE_ALLOCATOR_H_ +#ifndef ART_LIBARTBASE_BASE_ALLOCATOR_H_ +#define ART_LIBARTBASE_BASE_ALLOCATOR_H_ #include <type_traits> -#include "atomic.h" +#include "base/atomic.h" #include "base/macros.h" -#include "base/mutex.h" namespace art { @@ -154,4 +153,4 @@ using TrackingAllocator = typename std::conditional<kEnableTrackingAllocator, } // namespace art -#endif // ART_RUNTIME_BASE_ALLOCATOR_H_ +#endif // ART_LIBARTBASE_BASE_ALLOCATOR_H_ diff --git a/runtime/base/array_ref.h b/libartbase/base/array_ref.h index 2753c81bd5..1d7bde6044 100644 --- a/runtime/base/array_ref.h +++ b/libartbase/base/array_ref.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_ARRAY_REF_H_ -#define ART_RUNTIME_BASE_ARRAY_REF_H_ +#ifndef ART_LIBARTBASE_BASE_ARRAY_REF_H_ +#define ART_LIBARTBASE_BASE_ARRAY_REF_H_ #include <type_traits> #include <vector> @@ -206,4 +206,4 @@ bool operator!=(const ArrayRef<T>& lhs, const ArrayRef<T>& rhs) { } // namespace art -#endif // ART_RUNTIME_BASE_ARRAY_REF_H_ +#endif // ART_LIBARTBASE_BASE_ARRAY_REF_H_ diff --git a/runtime/base/array_slice.h b/libartbase/base/array_slice.h index a7bce7dc56..1ef2fbad8b 100644 --- a/runtime/base/array_slice.h +++ b/libartbase/base/array_slice.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_ARRAY_SLICE_H_ -#define ART_RUNTIME_BASE_ARRAY_SLICE_H_ +#ifndef ART_LIBARTBASE_BASE_ARRAY_SLICE_H_ +#define ART_LIBARTBASE_BASE_ARRAY_SLICE_H_ #include "base/bit_utils.h" #include "base/casts.h" @@ -149,4 +149,4 @@ class ArraySlice { } // namespace art -#endif // ART_RUNTIME_BASE_ARRAY_SLICE_H_ +#endif // ART_LIBARTBASE_BASE_ARRAY_SLICE_H_ diff --git a/runtime/atomic.h b/libartbase/base/atomic.h index 0e2f056d3a..fd34cc6143 100644 --- a/runtime/atomic.h +++ b/libartbase/base/atomic.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_ATOMIC_H_ -#define ART_RUNTIME_ATOMIC_H_ +#ifndef ART_LIBARTBASE_BASE_ATOMIC_H_ +#define ART_LIBARTBASE_BASE_ATOMIC_H_ #include <stdint.h> #include <atomic> @@ -24,167 +24,10 @@ #include <android-base/logging.h> -#include "arch/instruction_set.h" #include "base/macros.h" namespace art { -class Mutex; - -// QuasiAtomic encapsulates two separate facilities that we are -// trying to move away from: "quasiatomic" 64 bit operations -// and custom memory fences. For the time being, they remain -// exposed. Clients should be converted to use either class Atomic -// below whenever possible, and should eventually use C++11 atomics. -// The two facilities that do not have a good C++11 analog are -// ThreadFenceForConstructor and Atomic::*JavaData. -// -// NOTE: Two "quasiatomic" operations on the exact same memory address -// are guaranteed to operate atomically with respect to each other, -// but no guarantees are made about quasiatomic operations mixed with -// non-quasiatomic operations on the same address, nor about -// quasiatomic operations that are performed on partially-overlapping -// memory. -class QuasiAtomic { - static constexpr bool NeedSwapMutexes(InstructionSet isa) { - // TODO - mips64 still need this for Cas64 ??? - return (isa == InstructionSet::kMips) || (isa == InstructionSet::kMips64); - } - - public: - static void Startup(); - - static void Shutdown(); - - // Reads the 64-bit value at "addr" without tearing. - static int64_t Read64(volatile const int64_t* addr) { - if (!NeedSwapMutexes(kRuntimeISA)) { - int64_t value; -#if defined(__LP64__) - value = *addr; -#else -#if defined(__arm__) -#if defined(__ARM_FEATURE_LPAE) - // With LPAE support (such as Cortex-A15) then ldrd is defined not to tear. - __asm__ __volatile__("@ QuasiAtomic::Read64\n" - "ldrd %0, %H0, %1" - : "=r" (value) - : "m" (*addr)); -#else - // Exclusive loads are defined not to tear, clearing the exclusive state isn't necessary. - __asm__ __volatile__("@ QuasiAtomic::Read64\n" - "ldrexd %0, %H0, %1" - : "=r" (value) - : "Q" (*addr)); -#endif -#elif defined(__i386__) - __asm__ __volatile__( - "movq %1, %0\n" - : "=x" (value) - : "m" (*addr)); -#else - LOG(FATAL) << "Unsupported architecture"; -#endif -#endif // defined(__LP64__) - return value; - } else { - return SwapMutexRead64(addr); - } - } - - // Writes to the 64-bit value at "addr" without tearing. - static void Write64(volatile int64_t* addr, int64_t value) { - if (!NeedSwapMutexes(kRuntimeISA)) { -#if defined(__LP64__) - *addr = value; -#else -#if defined(__arm__) -#if defined(__ARM_FEATURE_LPAE) - // If we know that ARM architecture has LPAE (such as Cortex-A15) strd is defined not to tear. - __asm__ __volatile__("@ QuasiAtomic::Write64\n" - "strd %1, %H1, %0" - : "=m"(*addr) - : "r" (value)); -#else - // The write is done as a swap so that the cache-line is in the exclusive state for the store. - int64_t prev; - int status; - do { - __asm__ __volatile__("@ QuasiAtomic::Write64\n" - "ldrexd %0, %H0, %2\n" - "strexd %1, %3, %H3, %2" - : "=&r" (prev), "=&r" (status), "+Q"(*addr) - : "r" (value) - : "cc"); - } while (UNLIKELY(status != 0)); -#endif -#elif defined(__i386__) - __asm__ __volatile__( - "movq %1, %0" - : "=m" (*addr) - : "x" (value)); -#else - LOG(FATAL) << "Unsupported architecture"; -#endif -#endif // defined(__LP64__) - } else { - SwapMutexWrite64(addr, value); - } - } - - // Atomically compare the value at "addr" to "old_value", if equal replace it with "new_value" - // and return true. Otherwise, don't swap, and return false. - // This is fully ordered, i.e. it has C++11 memory_order_seq_cst - // semantics (assuming all other accesses use a mutex if this one does). - // This has "strong" semantics; if it fails then it is guaranteed that - // at some point during the execution of Cas64, *addr was not equal to - // old_value. - static bool Cas64(int64_t old_value, int64_t new_value, volatile int64_t* addr) { - if (!NeedSwapMutexes(kRuntimeISA)) { - return __sync_bool_compare_and_swap(addr, old_value, new_value); - } else { - return SwapMutexCas64(old_value, new_value, addr); - } - } - - // Does the architecture provide reasonable atomic long operations or do we fall back on mutexes? - static bool LongAtomicsUseMutexes(InstructionSet isa) { - return NeedSwapMutexes(isa); - } - - static void ThreadFenceAcquire() { - std::atomic_thread_fence(std::memory_order_acquire); - } - - static void ThreadFenceRelease() { - std::atomic_thread_fence(std::memory_order_release); - } - - static void ThreadFenceForConstructor() { - #if defined(__aarch64__) - __asm__ __volatile__("dmb ishst" : : : "memory"); - #else - std::atomic_thread_fence(std::memory_order_release); - #endif - } - - static void ThreadFenceSequentiallyConsistent() { - std::atomic_thread_fence(std::memory_order_seq_cst); - } - - private: - static Mutex* GetSwapMutex(const volatile int64_t* addr); - static int64_t SwapMutexRead64(volatile const int64_t* addr); - static void SwapMutexWrite64(volatile int64_t* addr, int64_t val); - static bool SwapMutexCas64(int64_t old_value, int64_t new_value, volatile int64_t* addr); - - // We stripe across a bunch of different mutexes to reduce contention. - static constexpr size_t kSwapMutexCount = 32; - static std::vector<Mutex*>* gSwapMutexes; - - DISALLOW_COPY_AND_ASSIGN(QuasiAtomic); -}; - template<typename T> class PACKED(sizeof(T)) Atomic : public std::atomic<T> { public: @@ -409,4 +252,4 @@ static_assert(sizeof(Atomic<int64_t>) == sizeof(int64_t), "Weird Atomic<int64> s } // namespace art -#endif // ART_RUNTIME_ATOMIC_H_ +#endif // ART_LIBARTBASE_BASE_ATOMIC_H_ diff --git a/runtime/base/bit_field.h b/libartbase/base/bit_field.h index 86007d6a35..9971735138 100644 --- a/runtime/base/bit_field.h +++ b/libartbase/base/bit_field.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_BIT_FIELD_H_ -#define ART_RUNTIME_BASE_BIT_FIELD_H_ +#ifndef ART_LIBARTBASE_BASE_BIT_FIELD_H_ +#define ART_LIBARTBASE_BASE_BIT_FIELD_H_ #include <android-base/logging.h> @@ -89,4 +89,4 @@ class BitField { } // namespace art -#endif // ART_RUNTIME_BASE_BIT_FIELD_H_ +#endif // ART_LIBARTBASE_BASE_BIT_FIELD_H_ diff --git a/runtime/base/bit_field_test.cc b/libartbase/base/bit_field_test.cc index afeb2c4422..afeb2c4422 100644 --- a/runtime/base/bit_field_test.cc +++ b/libartbase/base/bit_field_test.cc diff --git a/runtime/base/bit_string.h b/libartbase/base/bit_string.h index 7d9fb70de7..0e051f358b 100644 --- a/runtime/base/bit_string.h +++ b/libartbase/base/bit_string.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_BIT_STRING_H_ -#define ART_RUNTIME_BASE_BIT_STRING_H_ +#ifndef ART_LIBARTBASE_BASE_BIT_STRING_H_ +#define ART_LIBARTBASE_BASE_BIT_STRING_H_ #include "base/bit_struct.h" #include "base/bit_utils.h" @@ -296,4 +296,4 @@ inline std::ostream& operator<<(std::ostream& os, const BitString& bit_string) { } // namespace art -#endif // ART_RUNTIME_BASE_BIT_STRING_H_ +#endif // ART_LIBARTBASE_BASE_BIT_STRING_H_ diff --git a/runtime/base/bit_string_test.cc b/libartbase/base/bit_string_test.cc index 23274e3f2f..23274e3f2f 100644 --- a/runtime/base/bit_string_test.cc +++ b/libartbase/base/bit_string_test.cc diff --git a/runtime/base/bit_struct.h b/libartbase/base/bit_struct.h index 7eb63c6b5c..386b896073 100644 --- a/runtime/base/bit_struct.h +++ b/libartbase/base/bit_struct.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_BIT_STRUCT_H_ -#define ART_RUNTIME_BASE_BIT_STRUCT_H_ +#ifndef ART_LIBARTBASE_BASE_BIT_STRUCT_H_ +#define ART_LIBARTBASE_BASE_BIT_STRUCT_H_ #include "base/bit_utils.h" #include "bit_struct_detail.h" @@ -303,4 +303,4 @@ static constexpr size_t BitStructSizeOf() { } // namespace art -#endif // ART_RUNTIME_BASE_BIT_STRUCT_H_ +#endif // ART_LIBARTBASE_BASE_BIT_STRUCT_H_ diff --git a/runtime/base/bit_struct_detail.h b/libartbase/base/bit_struct_detail.h index 24f6c4c85e..facfa61efb 100644 --- a/runtime/base/bit_struct_detail.h +++ b/libartbase/base/bit_struct_detail.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_BIT_STRUCT_DETAIL_H_ -#define ART_RUNTIME_BASE_BIT_STRUCT_DETAIL_H_ +#ifndef ART_LIBARTBASE_BASE_BIT_STRUCT_DETAIL_H_ +#define ART_LIBARTBASE_BASE_BIT_STRUCT_DETAIL_H_ #include "base/bit_utils.h" #include "globals.h" @@ -116,4 +116,4 @@ static constexpr bool ValidateBitStructSize() { } // namespace detail } // namespace art -#endif // ART_RUNTIME_BASE_BIT_STRUCT_DETAIL_H_ +#endif // ART_LIBARTBASE_BASE_BIT_STRUCT_DETAIL_H_ diff --git a/runtime/base/bit_struct_test.cc b/libartbase/base/bit_struct_test.cc index 577682ccce..577682ccce 100644 --- a/runtime/base/bit_struct_test.cc +++ b/libartbase/base/bit_struct_test.cc diff --git a/runtime/base/bit_vector-inl.h b/libartbase/base/bit_vector-inl.h index e67d4e25eb..7a9f4650da 100644 --- a/runtime/base/bit_vector-inl.h +++ b/libartbase/base/bit_vector-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_BIT_VECTOR_INL_H_ -#define ART_RUNTIME_BASE_BIT_VECTOR_INL_H_ +#ifndef ART_LIBARTBASE_BASE_BIT_VECTOR_INL_H_ +#define ART_LIBARTBASE_BASE_BIT_VECTOR_INL_H_ #include "bit_vector.h" @@ -97,4 +97,4 @@ inline bool BitVector::Equal(const BitVector* src) const { } // namespace art -#endif // ART_RUNTIME_BASE_BIT_VECTOR_INL_H_ +#endif // ART_LIBARTBASE_BASE_BIT_VECTOR_INL_H_ diff --git a/runtime/base/bit_vector.cc b/libartbase/base/bit_vector.cc index c706c7ebf2..c706c7ebf2 100644 --- a/runtime/base/bit_vector.cc +++ b/libartbase/base/bit_vector.cc diff --git a/runtime/base/bit_vector.h b/libartbase/base/bit_vector.h index 564092a1a2..2ffa2aa9c9 100644 --- a/runtime/base/bit_vector.h +++ b/libartbase/base/bit_vector.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_BIT_VECTOR_H_ -#define ART_RUNTIME_BASE_BIT_VECTOR_H_ +#ifndef ART_LIBARTBASE_BASE_BIT_VECTOR_H_ +#define ART_LIBARTBASE_BASE_BIT_VECTOR_H_ #include <stdint.h> #include <iterator> @@ -293,4 +293,4 @@ class BitVector { } // namespace art -#endif // ART_RUNTIME_BASE_BIT_VECTOR_H_ +#endif // ART_LIBARTBASE_BASE_BIT_VECTOR_H_ diff --git a/runtime/base/bit_vector_test.cc b/libartbase/base/bit_vector_test.cc index 0e3df76fe2..0e3df76fe2 100644 --- a/runtime/base/bit_vector_test.cc +++ b/libartbase/base/bit_vector_test.cc diff --git a/runtime/base/bounded_fifo.h b/libartbase/base/bounded_fifo.h index 1520770fe6..444f31a55b 100644 --- a/runtime/base/bounded_fifo.h +++ b/libartbase/base/bounded_fifo.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_BOUNDED_FIFO_H_ -#define ART_RUNTIME_BASE_BOUNDED_FIFO_H_ +#ifndef ART_LIBARTBASE_BASE_BOUNDED_FIFO_H_ +#define ART_LIBARTBASE_BASE_BOUNDED_FIFO_H_ #include <android-base/logging.h> @@ -72,4 +72,4 @@ class BoundedFifoPowerOfTwo { } // namespace art -#endif // ART_RUNTIME_BASE_BOUNDED_FIFO_H_ +#endif // ART_LIBARTBASE_BASE_BOUNDED_FIFO_H_ diff --git a/runtime/base/callee_save_type.h b/libartbase/base/callee_save_type.h index e9cd63c3a0..3e44a3a73f 100644 --- a/runtime/base/callee_save_type.h +++ b/libartbase/base/callee_save_type.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_CALLEE_SAVE_TYPE_H_ -#define ART_RUNTIME_BASE_CALLEE_SAVE_TYPE_H_ +#ifndef ART_LIBARTBASE_BASE_CALLEE_SAVE_TYPE_H_ +#define ART_LIBARTBASE_BASE_CALLEE_SAVE_TYPE_H_ #include <cstddef> #include <ostream> @@ -44,4 +44,4 @@ static inline constexpr CalleeSaveType GetCanonicalCalleeSaveType(CalleeSaveType } // namespace art -#endif // ART_RUNTIME_BASE_CALLEE_SAVE_TYPE_H_ +#endif // ART_LIBARTBASE_BASE_CALLEE_SAVE_TYPE_H_ diff --git a/runtime/base/dchecked_vector.h b/libartbase/base/dchecked_vector.h index 7236ac301a..e9ce6d0aaf 100644 --- a/runtime/base/dchecked_vector.h +++ b/libartbase/base/dchecked_vector.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_DCHECKED_VECTOR_H_ -#define ART_RUNTIME_BASE_DCHECKED_VECTOR_H_ +#ifndef ART_LIBARTBASE_BASE_DCHECKED_VECTOR_H_ +#define ART_LIBARTBASE_BASE_DCHECKED_VECTOR_H_ #include <algorithm> #include <type_traits> @@ -225,4 +225,4 @@ bool operator>=(const dchecked_vector<T, Alloc>& lhs, const dchecked_vector<T, A } // namespace art -#endif // ART_RUNTIME_BASE_DCHECKED_VECTOR_H_ +#endif // ART_LIBARTBASE_BASE_DCHECKED_VECTOR_H_ diff --git a/runtime/base/debug_stack.h b/libartbase/base/debug_stack.h index 1331e10a02..f2d93d462a 100644 --- a/runtime/base/debug_stack.h +++ b/libartbase/base/debug_stack.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_DEBUG_STACK_H_ -#define ART_RUNTIME_BASE_DEBUG_STACK_H_ +#ifndef ART_LIBARTBASE_BASE_DEBUG_STACK_H_ +#define ART_LIBARTBASE_BASE_DEBUG_STACK_H_ #include <android-base/logging.h> #include <android-base/macros.h> @@ -144,4 +144,4 @@ class DebugStackIndirectTopRefImpl { } // namespace art -#endif // ART_RUNTIME_BASE_DEBUG_STACK_H_ +#endif // ART_LIBARTBASE_BASE_DEBUG_STACK_H_ diff --git a/runtime/base/file_magic.cc b/libartbase/base/file_magic.cc index 2b9bed0397..2b9bed0397 100644 --- a/runtime/base/file_magic.cc +++ b/libartbase/base/file_magic.cc diff --git a/runtime/base/file_magic.h b/libartbase/base/file_magic.h index e7bd706a5c..53f551cb3a 100644 --- a/runtime/base/file_magic.h +++ b/libartbase/base/file_magic.h @@ -14,13 +14,13 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_FILE_MAGIC_H_ -#define ART_RUNTIME_BASE_FILE_MAGIC_H_ +#ifndef ART_LIBARTBASE_BASE_FILE_MAGIC_H_ +#define ART_LIBARTBASE_BASE_FILE_MAGIC_H_ #include <stdint.h> #include <string> -#include "os.h" +#include "base/os.h" namespace art { @@ -35,4 +35,4 @@ bool IsZipMagic(uint32_t magic); } // namespace art -#endif // ART_RUNTIME_BASE_FILE_MAGIC_H_ +#endif // ART_LIBARTBASE_BASE_FILE_MAGIC_H_ diff --git a/runtime/base/hex_dump.cc b/libartbase/base/hex_dump.cc index bce6b53f4d..bce6b53f4d 100644 --- a/runtime/base/hex_dump.cc +++ b/libartbase/base/hex_dump.cc diff --git a/runtime/base/hex_dump.h b/libartbase/base/hex_dump.h index 2ce0aefe67..55f4d53c2e 100644 --- a/runtime/base/hex_dump.h +++ b/libartbase/base/hex_dump.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_HEX_DUMP_H_ -#define ART_RUNTIME_BASE_HEX_DUMP_H_ +#ifndef ART_LIBARTBASE_BASE_HEX_DUMP_H_ +#define ART_LIBARTBASE_BASE_HEX_DUMP_H_ #include "base/macros.h" @@ -52,4 +52,4 @@ inline std::ostream& operator<<(std::ostream& os, const HexDump& rhs) { } // namespace art -#endif // ART_RUNTIME_BASE_HEX_DUMP_H_ +#endif // ART_LIBARTBASE_BASE_HEX_DUMP_H_ diff --git a/runtime/base/hex_dump_test.cc b/libartbase/base/hex_dump_test.cc index bfd5c75284..bfd5c75284 100644 --- a/runtime/base/hex_dump_test.cc +++ b/libartbase/base/hex_dump_test.cc diff --git a/runtime/base/histogram-inl.h b/libartbase/base/histogram-inl.h index 3ce0140c84..26d01b2883 100644 --- a/runtime/base/histogram-inl.h +++ b/libartbase/base/histogram-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_HISTOGRAM_INL_H_ -#define ART_RUNTIME_BASE_HISTOGRAM_INL_H_ +#ifndef ART_LIBARTBASE_BASE_HISTOGRAM_INL_H_ +#define ART_LIBARTBASE_BASE_HISTOGRAM_INL_H_ #include <algorithm> #include <cmath> @@ -28,7 +28,7 @@ #include "base/bit_utils.h" #include "base/time_utils.h" -#include "utils.h" +#include "base/utils.h" namespace art { @@ -277,4 +277,4 @@ inline double Histogram<Value>::Percentile(double per, const CumulativeData& dat #pragma clang diagnostic pop } // namespace art -#endif // ART_RUNTIME_BASE_HISTOGRAM_INL_H_ +#endif // ART_LIBARTBASE_BASE_HISTOGRAM_INL_H_ diff --git a/runtime/base/histogram.h b/libartbase/base/histogram.h index 7544a9c918..39a1866b4d 100644 --- a/runtime/base/histogram.h +++ b/libartbase/base/histogram.h @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_HISTOGRAM_H_ -#define ART_RUNTIME_BASE_HISTOGRAM_H_ +#ifndef ART_LIBARTBASE_BASE_HISTOGRAM_H_ +#define ART_LIBARTBASE_BASE_HISTOGRAM_H_ #include <string> #include <vector> @@ -128,4 +128,4 @@ template <class Value> class Histogram { }; } // namespace art -#endif // ART_RUNTIME_BASE_HISTOGRAM_H_ +#endif // ART_LIBARTBASE_BASE_HISTOGRAM_H_ diff --git a/runtime/base/histogram_test.cc b/libartbase/base/histogram_test.cc index 7aa5f9037f..7aa5f9037f 100644 --- a/runtime/base/histogram_test.cc +++ b/libartbase/base/histogram_test.cc diff --git a/runtime/base/length_prefixed_array.h b/libartbase/base/length_prefixed_array.h index 2df5a99352..7c09bddd55 100644 --- a/runtime/base/length_prefixed_array.h +++ b/libartbase/base/length_prefixed_array.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_LENGTH_PREFIXED_ARRAY_H_ -#define ART_RUNTIME_BASE_LENGTH_PREFIXED_ARRAY_H_ +#ifndef ART_LIBARTBASE_BASE_LENGTH_PREFIXED_ARRAY_H_ +#define ART_LIBARTBASE_BASE_LENGTH_PREFIXED_ARRAY_H_ #include <stddef.h> // for offsetof() #include <string.h> // for memset() @@ -23,7 +23,7 @@ #include "base/bit_utils.h" #include "base/casts.h" #include "base/iteration_range.h" -#include "stride_iterator.h" +#include "base/stride_iterator.h" namespace art { @@ -118,4 +118,4 @@ IterationRange<StrideIterator<T>> MakeIterationRangeFromLengthPrefixedArray( } // namespace art -#endif // ART_RUNTIME_BASE_LENGTH_PREFIXED_ARRAY_H_ +#endif // ART_LIBARTBASE_BASE_LENGTH_PREFIXED_ARRAY_H_ diff --git a/runtime/base/logging.cc b/libartbase/base/logging.cc index 78d54292d1..37b1f8264a 100644 --- a/runtime/base/logging.cc +++ b/libartbase/base/logging.cc @@ -21,8 +21,6 @@ #include <sstream> #include "aborting.h" -#include "mutex.h" -#include "utils.h" // Headers for LogMessage::LogLine. #ifdef ART_TARGET_ANDROID @@ -59,8 +57,6 @@ void InitLogging(char* argv[], AbortFunction& abort_function) { if (gCmdLine.get() != nullptr) { return; } - // TODO: Move this to a more obvious InitART... - Locks::Init(); // Stash the command line for later use. We can use /proc/self/cmdline on Linux to recover this, // but we don't have that luxury on the Mac, and there are a couple of argv[0] variants that are diff --git a/runtime/base/logging.h b/libartbase/base/logging.h index c562bdf59f..fd5fc74383 100644 --- a/runtime/base/logging.h +++ b/libartbase/base/logging.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_LOGGING_H_ -#define ART_RUNTIME_BASE_LOGGING_H_ +#ifndef ART_LIBARTBASE_BASE_LOGGING_H_ +#define ART_LIBARTBASE_BASE_LOGGING_H_ #include <ostream> #include <sstream> @@ -110,4 +110,4 @@ class LogHelper { } // namespace art -#endif // ART_RUNTIME_BASE_LOGGING_H_ +#endif // ART_LIBARTBASE_BASE_LOGGING_H_ diff --git a/runtime/base/logging_test.cc b/libartbase/base/logging_test.cc index 404e080b03..404e080b03 100644 --- a/runtime/base/logging_test.cc +++ b/libartbase/base/logging_test.cc diff --git a/runtime/os.h b/libartbase/base/os.h index 7130fc3732..4062d90f88 100644 --- a/runtime/os.h +++ b/libartbase/base/os.h @@ -14,8 +14,10 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_OS_H_ -#define ART_RUNTIME_OS_H_ +#ifndef ART_LIBARTBASE_BASE_OS_H_ +#define ART_LIBARTBASE_BASE_OS_H_ + +#include <stdint.h> namespace unix_file { class FdFile; @@ -47,12 +49,15 @@ class OS { static File* OpenFileWithFlags(const char* name, int flags, bool auto_flush = true); // Check if a file exists. - static bool FileExists(const char* name); + static bool FileExists(const char* name, bool check_file_type = true); // Check if a directory exists. static bool DirectoryExists(const char* name); + + // Get the size of a file (or -1 if it does not exist). + static int64_t GetFileSizeBytes(const char* name); }; } // namespace art -#endif // ART_RUNTIME_OS_H_ +#endif // ART_LIBARTBASE_BASE_OS_H_ diff --git a/runtime/os_linux.cc b/libartbase/base/os_linux.cc index 1b3e0000da..6b5a604423 100644 --- a/runtime/os_linux.cc +++ b/libartbase/base/os_linux.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "os.h" +#include "base/os.h" #include <fcntl.h> #include <sys/stat.h> @@ -64,10 +64,14 @@ File* OS::OpenFileWithFlags(const char* name, int flags, bool auto_flush) { return file.release(); } -bool OS::FileExists(const char* name) { +bool OS::FileExists(const char* name, bool check_file_type) { struct stat st; if (stat(name, &st) == 0) { - return S_ISREG(st.st_mode); // TODO: Deal with symlinks? + if (check_file_type) { + return S_ISREG(st.st_mode); // TODO: Deal with symlinks? + } else { + return true; + } } else { return false; } @@ -82,4 +86,13 @@ bool OS::DirectoryExists(const char* name) { } } +int64_t OS::GetFileSizeBytes(const char* name) { + struct stat st; + if (stat(name, &st) == 0) { + return -1; // TODO: Deal with symlinks? + } else { + return st.st_size; + } +} + } // namespace art diff --git a/runtime/base/runtime_debug.cc b/libartbase/base/runtime_debug.cc index 4f8a8ec9c6..4f8a8ec9c6 100644 --- a/runtime/base/runtime_debug.cc +++ b/libartbase/base/runtime_debug.cc diff --git a/runtime/base/runtime_debug.h b/libartbase/base/runtime_debug.h index 89a0361fa7..7d91166aa7 100644 --- a/runtime/base/runtime_debug.h +++ b/libartbase/base/runtime_debug.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_RUNTIME_DEBUG_H_ -#define ART_RUNTIME_BASE_RUNTIME_DEBUG_H_ +#ifndef ART_LIBARTBASE_BASE_RUNTIME_DEBUG_H_ +#define ART_LIBARTBASE_BASE_RUNTIME_DEBUG_H_ namespace art { @@ -58,4 +58,4 @@ void SetRuntimeDebugFlagsEnabled(bool enabled); } // namespace art -#endif // ART_RUNTIME_BASE_RUNTIME_DEBUG_H_ +#endif // ART_LIBARTBASE_BASE_RUNTIME_DEBUG_H_ diff --git a/runtime/base/safe_copy.cc b/libartbase/base/safe_copy.cc index 7ba5cbd3e6..7ba5cbd3e6 100644 --- a/runtime/base/safe_copy.cc +++ b/libartbase/base/safe_copy.cc diff --git a/runtime/base/safe_copy.h b/libartbase/base/safe_copy.h index d0f497c0bd..56cdfecc2d 100644 --- a/runtime/base/safe_copy.h +++ b/libartbase/base/safe_copy.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_SAFE_COPY_H_ -#define ART_RUNTIME_BASE_SAFE_COPY_H_ +#ifndef ART_LIBARTBASE_BASE_SAFE_COPY_H_ +#define ART_LIBARTBASE_BASE_SAFE_COPY_H_ #include <sys/types.h> @@ -28,4 +28,4 @@ ssize_t SafeCopy(void *dst, const void *src, size_t len); } // namespace art -#endif // ART_RUNTIME_BASE_SAFE_COPY_H_ +#endif // ART_LIBARTBASE_BASE_SAFE_COPY_H_ diff --git a/runtime/base/safe_copy_test.cc b/libartbase/base/safe_copy_test.cc index a9ec9528a1..a9ec9528a1 100644 --- a/runtime/base/safe_copy_test.cc +++ b/libartbase/base/safe_copy_test.cc diff --git a/runtime/base/scoped_flock.cc b/libartbase/base/scoped_flock.cc index 514b97bfb1..514b97bfb1 100644 --- a/runtime/base/scoped_flock.cc +++ b/libartbase/base/scoped_flock.cc diff --git a/runtime/base/scoped_flock.h b/libartbase/base/scoped_flock.h index db6c819c6c..476b25748b 100644 --- a/runtime/base/scoped_flock.h +++ b/libartbase/base/scoped_flock.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_SCOPED_FLOCK_H_ -#define ART_RUNTIME_BASE_SCOPED_FLOCK_H_ +#ifndef ART_LIBARTBASE_BASE_SCOPED_FLOCK_H_ +#define ART_LIBARTBASE_BASE_SCOPED_FLOCK_H_ #include <memory> #include <string> @@ -23,8 +23,8 @@ #include <android-base/unique_fd.h> #include "base/macros.h" +#include "base/os.h" #include "base/unix_file/fd_file.h" -#include "os.h" namespace art { @@ -85,4 +85,4 @@ class LockedFileCloseNoFlush { } // namespace art -#endif // ART_RUNTIME_BASE_SCOPED_FLOCK_H_ +#endif // ART_LIBARTBASE_BASE_SCOPED_FLOCK_H_ diff --git a/runtime/base/scoped_flock_test.cc b/libartbase/base/scoped_flock_test.cc index 1b6caaf747..1b6caaf747 100644 --- a/runtime/base/scoped_flock_test.cc +++ b/libartbase/base/scoped_flock_test.cc diff --git a/runtime/stride_iterator.h b/libartbase/base/stride_iterator.h index 511c2c66f2..67c0d3803e 100644 --- a/runtime/stride_iterator.h +++ b/libartbase/base/stride_iterator.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_STRIDE_ITERATOR_H_ -#define ART_RUNTIME_STRIDE_ITERATOR_H_ +#ifndef ART_LIBARTBASE_BASE_STRIDE_ITERATOR_H_ +#define ART_LIBARTBASE_BASE_STRIDE_ITERATOR_H_ #include <iterator> @@ -147,4 +147,4 @@ bool operator>=(const StrideIterator<T>& lhs, const StrideIterator<T>& rhs) { } // namespace art -#endif // ART_RUNTIME_STRIDE_ITERATOR_H_ +#endif // ART_LIBARTBASE_BASE_STRIDE_ITERATOR_H_ diff --git a/runtime/base/strlcpy.h b/libartbase/base/strlcpy.h index de135ea990..98ea34b0a5 100644 --- a/runtime/base/strlcpy.h +++ b/libartbase/base/strlcpy.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_STRLCPY_H_ -#define ART_RUNTIME_BASE_STRLCPY_H_ +#ifndef ART_LIBARTBASE_BASE_STRLCPY_H_ +#define ART_LIBARTBASE_BASE_STRLCPY_H_ #include <cstdio> #include <cstring> @@ -35,4 +35,4 @@ static inline size_t strlcpy(char* dst, const char* src, size_t size) { #endif -#endif // ART_RUNTIME_BASE_STRLCPY_H_ +#endif // ART_LIBARTBASE_BASE_STRLCPY_H_ diff --git a/runtime/base/systrace.h b/libartbase/base/systrace.h index dc2206e420..2ff33e8c84 100644 --- a/runtime/base/systrace.h +++ b/libartbase/base/systrace.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_SYSTRACE_H_ -#define ART_RUNTIME_BASE_SYSTRACE_H_ +#ifndef ART_LIBARTBASE_BASE_SYSTRACE_H_ +#define ART_LIBARTBASE_BASE_SYSTRACE_H_ #define ATRACE_TAG ATRACE_TAG_DALVIK #include <cutils/trace.h> @@ -80,4 +80,4 @@ class ScopedTraceNoStart { } // namespace art -#endif // ART_RUNTIME_BASE_SYSTRACE_H_ +#endif // ART_LIBARTBASE_BASE_SYSTRACE_H_ diff --git a/runtime/base/time_utils.cc b/libartbase/base/time_utils.cc index 3c09d5a36f..3c09d5a36f 100644 --- a/runtime/base/time_utils.cc +++ b/libartbase/base/time_utils.cc diff --git a/runtime/base/time_utils.h b/libartbase/base/time_utils.h index 7648a109fa..811af5d682 100644 --- a/runtime/base/time_utils.h +++ b/libartbase/base/time_utils.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_TIME_UTILS_H_ -#define ART_RUNTIME_BASE_TIME_UTILS_H_ +#ifndef ART_LIBARTBASE_BASE_TIME_UTILS_H_ +#define ART_LIBARTBASE_BASE_TIME_UTILS_H_ #include <stdint.h> #include <time.h> @@ -101,4 +101,4 @@ void InitTimeSpec(bool absolute, int clock, int64_t ms, int32_t ns, timespec* ts } // namespace art -#endif // ART_RUNTIME_BASE_TIME_UTILS_H_ +#endif // ART_LIBARTBASE_BASE_TIME_UTILS_H_ diff --git a/runtime/base/time_utils_test.cc b/libartbase/base/time_utils_test.cc index c553f4ed03..c553f4ed03 100644 --- a/runtime/base/time_utils_test.cc +++ b/libartbase/base/time_utils_test.cc diff --git a/runtime/base/to_str.h b/libartbase/base/to_str.h index 6b1c84c411..74d9584f78 100644 --- a/runtime/base/to_str.h +++ b/libartbase/base/to_str.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_TO_STR_H_ -#define ART_RUNTIME_BASE_TO_STR_H_ +#ifndef ART_LIBARTBASE_BASE_TO_STR_H_ +#define ART_LIBARTBASE_BASE_TO_STR_H_ #include <sstream> @@ -47,4 +47,4 @@ class ToStr { } // namespace art -#endif // ART_RUNTIME_BASE_TO_STR_H_ +#endif // ART_LIBARTBASE_BASE_TO_STR_H_ diff --git a/runtime/base/tracking_safe_map.h b/libartbase/base/tracking_safe_map.h index 2f3984d106..2750de1b94 100644 --- a/runtime/base/tracking_safe_map.h +++ b/libartbase/base/tracking_safe_map.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_TRACKING_SAFE_MAP_H_ -#define ART_RUNTIME_BASE_TRACKING_SAFE_MAP_H_ +#ifndef ART_LIBARTBASE_BASE_TRACKING_SAFE_MAP_H_ +#define ART_LIBARTBASE_BASE_TRACKING_SAFE_MAP_H_ #include "base/allocator.h" #include "base/safe_map.h" @@ -29,4 +29,4 @@ class AllocationTrackingSafeMap : public SafeMap< } // namespace art -#endif // ART_RUNTIME_BASE_TRACKING_SAFE_MAP_H_ +#endif // ART_LIBARTBASE_BASE_TRACKING_SAFE_MAP_H_ diff --git a/runtime/base/transform_array_ref.h b/libartbase/base/transform_array_ref.h index a4e0bc27ed..de2739e2fc 100644 --- a/runtime/base/transform_array_ref.h +++ b/libartbase/base/transform_array_ref.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_TRANSFORM_ARRAY_REF_H_ -#define ART_RUNTIME_BASE_TRANSFORM_ARRAY_REF_H_ +#ifndef ART_LIBARTBASE_BASE_TRANSFORM_ARRAY_REF_H_ +#define ART_LIBARTBASE_BASE_TRANSFORM_ARRAY_REF_H_ #include <type_traits> @@ -193,4 +193,4 @@ TransformArrayRef<const typename Container::value_type, Function> MakeTransformA } // namespace art -#endif // ART_RUNTIME_BASE_TRANSFORM_ARRAY_REF_H_ +#endif // ART_LIBARTBASE_BASE_TRANSFORM_ARRAY_REF_H_ diff --git a/runtime/base/transform_array_ref_test.cc b/libartbase/base/transform_array_ref_test.cc index da0340d36b..da0340d36b 100644 --- a/runtime/base/transform_array_ref_test.cc +++ b/libartbase/base/transform_array_ref_test.cc diff --git a/runtime/base/transform_iterator.h b/libartbase/base/transform_iterator.h index 9c8f822b71..82d9f9e325 100644 --- a/runtime/base/transform_iterator.h +++ b/libartbase/base/transform_iterator.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_TRANSFORM_ITERATOR_H_ -#define ART_RUNTIME_BASE_TRANSFORM_ITERATOR_H_ +#ifndef ART_LIBARTBASE_BASE_TRANSFORM_ITERATOR_H_ +#define ART_LIBARTBASE_BASE_TRANSFORM_ITERATOR_H_ #include <iterator> #include <type_traits> @@ -175,4 +175,4 @@ auto MakeTransformRange(BaseRange& range, Function f) { } // namespace art -#endif // ART_RUNTIME_BASE_TRANSFORM_ITERATOR_H_ +#endif // ART_LIBARTBASE_BASE_TRANSFORM_ITERATOR_H_ diff --git a/runtime/base/transform_iterator_test.cc b/libartbase/base/transform_iterator_test.cc index 63b6e4f531..63b6e4f531 100644 --- a/runtime/base/transform_iterator_test.cc +++ b/libartbase/base/transform_iterator_test.cc diff --git a/runtime/base/unix_file/README b/libartbase/base/unix_file/README index e9aec22954..e9aec22954 100644 --- a/runtime/base/unix_file/README +++ b/libartbase/base/unix_file/README diff --git a/runtime/base/unix_file/fd_file.cc b/libartbase/base/unix_file/fd_file.cc index f9da178de8..f9da178de8 100644 --- a/runtime/base/unix_file/fd_file.cc +++ b/libartbase/base/unix_file/fd_file.cc diff --git a/runtime/base/unix_file/fd_file.h b/libartbase/base/unix_file/fd_file.h index 3fb70f644d..fe3317f64e 100644 --- a/runtime/base/unix_file/fd_file.h +++ b/libartbase/base/unix_file/fd_file.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_UNIX_FILE_FD_FILE_H_ -#define ART_RUNTIME_BASE_UNIX_FILE_FD_FILE_H_ +#ifndef ART_LIBARTBASE_BASE_UNIX_FILE_FD_FILE_H_ +#define ART_LIBARTBASE_BASE_UNIX_FILE_FD_FILE_H_ #include <fcntl.h> @@ -192,4 +192,4 @@ std::ostream& operator<<(std::ostream& os, const FdFile::GuardState& kind); } // namespace unix_file -#endif // ART_RUNTIME_BASE_UNIX_FILE_FD_FILE_H_ +#endif // ART_LIBARTBASE_BASE_UNIX_FILE_FD_FILE_H_ diff --git a/runtime/base/unix_file/fd_file_test.cc b/libartbase/base/unix_file/fd_file_test.cc index 042fbc9284..042fbc9284 100644 --- a/runtime/base/unix_file/fd_file_test.cc +++ b/libartbase/base/unix_file/fd_file_test.cc diff --git a/runtime/base/unix_file/random_access_file.h b/libartbase/base/unix_file/random_access_file.h index 31a6dbe1fc..d2124cc843 100644 --- a/runtime/base/unix_file/random_access_file.h +++ b/libartbase/base/unix_file/random_access_file.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_H_ -#define ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_H_ +#ifndef ART_LIBARTBASE_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_H_ +#define ART_LIBARTBASE_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_H_ #include <stdint.h> @@ -65,4 +65,4 @@ class RandomAccessFile { } // namespace unix_file -#endif // ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_H_ +#endif // ART_LIBARTBASE_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_H_ diff --git a/runtime/base/unix_file/random_access_file_test.h b/libartbase/base/unix_file/random_access_file_test.h index 91858c21de..1de5f7b72c 100644 --- a/runtime/base/unix_file/random_access_file_test.h +++ b/libartbase/base/unix_file/random_access_file_test.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_TEST_H_ -#define ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_TEST_H_ +#ifndef ART_LIBARTBASE_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_TEST_H_ +#define ART_LIBARTBASE_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_TEST_H_ #include <errno.h> #include <memory> @@ -180,4 +180,4 @@ class RandomAccessFileTest : public testing::Test { } // namespace unix_file -#endif // ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_TEST_H_ +#endif // ART_LIBARTBASE_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_TEST_H_ diff --git a/runtime/base/unix_file/random_access_file_utils.cc b/libartbase/base/unix_file/random_access_file_utils.cc index aae65c1cde..aae65c1cde 100644 --- a/runtime/base/unix_file/random_access_file_utils.cc +++ b/libartbase/base/unix_file/random_access_file_utils.cc diff --git a/runtime/base/unix_file/random_access_file_utils.h b/libartbase/base/unix_file/random_access_file_utils.h index 30c81c09aa..47c4c2a57b 100644 --- a/runtime/base/unix_file/random_access_file_utils.h +++ b/libartbase/base/unix_file/random_access_file_utils.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_UTILS_H_ -#define ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_UTILS_H_ +#ifndef ART_LIBARTBASE_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_UTILS_H_ +#define ART_LIBARTBASE_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_UTILS_H_ namespace unix_file { @@ -27,4 +27,4 @@ bool CopyFile(const RandomAccessFile& src, RandomAccessFile* dst); } // namespace unix_file -#endif // ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_UTILS_H_ +#endif // ART_LIBARTBASE_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_UTILS_H_ diff --git a/runtime/utils.cc b/libartbase/base/utils.cc index 7246c3d279..029cffd3ab 100644 --- a/runtime/utils.cc +++ b/libartbase/base/utils.cc @@ -30,8 +30,7 @@ #include "android-base/stringprintf.h" #include "android-base/strings.h" -#include "dex/utf-inl.h" -#include "os.h" +#include "base/os.h" #if defined(__APPLE__) #include <crt_externs.h> diff --git a/runtime/utils.h b/libartbase/base/utils.h index 0c3a0a231a..c8c5b72bf7 100644 --- a/runtime/utils.h +++ b/libartbase/base/utils.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_UTILS_H_ -#define ART_RUNTIME_UTILS_H_ +#ifndef ART_LIBARTBASE_BASE_UTILS_H_ +#define ART_LIBARTBASE_BASE_UTILS_H_ #include <pthread.h> #include <stdlib.h> @@ -25,11 +25,11 @@ #include <android-base/logging.h> -#include "arch/instruction_set.h" #include "base/casts.h" +#include "base/enums.h" +#include "base/globals.h" +#include "base/macros.h" #include "base/stringpiece.h" -#include "dex/primitive.h" -#include "globals.h" namespace art { @@ -260,4 +260,4 @@ static inline size_t HashBytes(const uint8_t* data, size_t len) { } // namespace art -#endif // ART_RUNTIME_UTILS_H_ +#endif // ART_LIBARTBASE_BASE_UTILS_H_ diff --git a/libartbase/base/utils_test.cc b/libartbase/base/utils_test.cc new file mode 100644 index 0000000000..892d1fd5bf --- /dev/null +++ b/libartbase/base/utils_test.cc @@ -0,0 +1,129 @@ +/* + * 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. + */ + +#include "utils.h" + +#include "gtest/gtest.h" + +namespace art { + +class UtilsTest : public testing::Test {}; + +TEST_F(UtilsTest, PrettySize) { + EXPECT_EQ("1GB", PrettySize(1 * GB)); + EXPECT_EQ("2GB", PrettySize(2 * GB)); + if (sizeof(size_t) > sizeof(uint32_t)) { + EXPECT_EQ("100GB", PrettySize(100 * GB)); + } + EXPECT_EQ("1024KB", PrettySize(1 * MB)); + EXPECT_EQ("10MB", PrettySize(10 * MB)); + EXPECT_EQ("100MB", PrettySize(100 * MB)); + EXPECT_EQ("1024B", PrettySize(1 * KB)); + EXPECT_EQ("10KB", PrettySize(10 * KB)); + EXPECT_EQ("100KB", PrettySize(100 * KB)); + EXPECT_EQ("0B", PrettySize(0)); + EXPECT_EQ("1B", PrettySize(1)); + EXPECT_EQ("10B", PrettySize(10)); + EXPECT_EQ("100B", PrettySize(100)); + EXPECT_EQ("512B", PrettySize(512)); +} + +TEST_F(UtilsTest, Split) { + std::vector<std::string> actual; + std::vector<std::string> expected; + + expected.clear(); + + actual.clear(); + Split("", ':', &actual); + EXPECT_EQ(expected, actual); + + actual.clear(); + Split(":", ':', &actual); + EXPECT_EQ(expected, actual); + + expected.clear(); + expected.push_back("foo"); + + actual.clear(); + Split(":foo", ':', &actual); + EXPECT_EQ(expected, actual); + + actual.clear(); + Split("foo:", ':', &actual); + EXPECT_EQ(expected, actual); + + actual.clear(); + Split(":foo:", ':', &actual); + EXPECT_EQ(expected, actual); + + expected.push_back("bar"); + + actual.clear(); + Split("foo:bar", ':', &actual); + EXPECT_EQ(expected, actual); + + actual.clear(); + Split(":foo:bar", ':', &actual); + EXPECT_EQ(expected, actual); + + actual.clear(); + Split("foo:bar:", ':', &actual); + EXPECT_EQ(expected, actual); + + actual.clear(); + Split(":foo:bar:", ':', &actual); + EXPECT_EQ(expected, actual); + + expected.push_back("baz"); + + actual.clear(); + Split("foo:bar:baz", ':', &actual); + EXPECT_EQ(expected, actual); + + actual.clear(); + Split(":foo:bar:baz", ':', &actual); + EXPECT_EQ(expected, actual); + + actual.clear(); + Split("foo:bar:baz:", ':', &actual); + EXPECT_EQ(expected, actual); + + actual.clear(); + Split(":foo:bar:baz:", ':', &actual); + EXPECT_EQ(expected, actual); +} + +TEST_F(UtilsTest, ArrayCount) { + int i[64]; + EXPECT_EQ(ArrayCount(i), 64u); + char c[7]; + EXPECT_EQ(ArrayCount(c), 7u); +} + +TEST_F(UtilsTest, BoundsCheckedCast) { + char buffer[64]; + const char* buffer_end = buffer + ArrayCount(buffer); + EXPECT_EQ(BoundsCheckedCast<const uint64_t*>(nullptr, buffer, buffer_end), nullptr); + EXPECT_EQ(BoundsCheckedCast<const uint64_t*>(buffer, buffer, buffer_end), + reinterpret_cast<const uint64_t*>(buffer)); + EXPECT_EQ(BoundsCheckedCast<const uint64_t*>(buffer + 56, buffer, buffer_end), + reinterpret_cast<const uint64_t*>(buffer + 56)); + EXPECT_EQ(BoundsCheckedCast<const uint64_t*>(buffer - 1, buffer, buffer_end), nullptr); + EXPECT_EQ(BoundsCheckedCast<const uint64_t*>(buffer + 57, buffer, buffer_end), nullptr); +} + +} // namespace art diff --git a/runtime/base/variant_map.h b/libartbase/base/variant_map.h index c480b5162d..4e02c54499 100644 --- a/runtime/base/variant_map.h +++ b/libartbase/base/variant_map.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_BASE_VARIANT_MAP_H_ -#define ART_RUNTIME_BASE_VARIANT_MAP_H_ +#ifndef ART_LIBARTBASE_BASE_VARIANT_MAP_H_ +#define ART_LIBARTBASE_BASE_VARIANT_MAP_H_ #include <memory.h> #include <map> @@ -467,4 +467,4 @@ struct VariantMap { } // namespace art -#endif // ART_RUNTIME_BASE_VARIANT_MAP_H_ +#endif // ART_LIBARTBASE_BASE_VARIANT_MAP_H_ diff --git a/runtime/base/variant_map_test.cc b/libartbase/base/variant_map_test.cc index 4677b6d3b3..4677b6d3b3 100644 --- a/runtime/base/variant_map_test.cc +++ b/libartbase/base/variant_map_test.cc diff --git a/libdexfile/Android.bp b/libdexfile/Android.bp index 797b4590c4..ae4ded58e2 100644 --- a/libdexfile/Android.bp +++ b/libdexfile/Android.bp @@ -24,6 +24,7 @@ cc_defaults { "dex/descriptors_names.cc", "dex/dex_file.cc", "dex/dex_file_exception_helpers.cc", + "dex/dex_file_layout.cc", "dex/dex_file_loader.cc", "dex/dex_file_tracking_registrar.cc", "dex/dex_file_verifier.cc", @@ -54,6 +55,9 @@ cc_defaults { }, generated_sources: ["dexfile_operator_srcs"], shared_libs: [ + // Important note: relying on libartbase's header_lib is perfectly acceptable. + // However, relying on the libartbase shared library introduces further, possibly cyclic, + // dependencies for clients outside of ART. "liblog", // For common macros. "libbase", @@ -77,6 +81,7 @@ gensrcs { tools: ["generate_operator_out"], srcs: [ "dex/dex_file.h", + "dex/dex_file_layout.h", "dex/dex_instruction.h", "dex/dex_instruction_utils.h", "dex/invoke_type.h", diff --git a/runtime/dex/dex_file_layout.cc b/libdexfile/dex/dex_file_layout.cc index d85d61d56b..1e36e05f50 100644 --- a/runtime/dex/dex_file_layout.cc +++ b/libdexfile/dex/dex_file_layout.cc @@ -18,11 +18,27 @@ #include <sys/mman.h> -#include "base/file_utils.h" -#include "dex/dex_file.h" +#include "dex_file.h" namespace art { +int DexLayoutSection::MadviseLargestPageAlignedRegion(const uint8_t* begin, + const uint8_t* end, + int advice) { + DCHECK_LE(begin, end); + begin = AlignUp(begin, kPageSize); + end = AlignDown(end, kPageSize); + if (begin < end) { + // TODO: remove the direct dependency on madvise here. + int result = madvise(const_cast<uint8_t*>(begin), end - begin, advice); + if (result != 0) { + PLOG(WARNING) << "madvise failed " << result; + } + return result; + } + return 0; +} + void DexLayoutSection::Subsection::Madvise(const DexFile* dex_file, int advice) const { DCHECK(dex_file != nullptr); DCHECK_LT(start_offset_, dex_file->Size()); diff --git a/runtime/dex/dex_file_layout.h b/libdexfile/dex/dex_file_layout.h index 793e3b5de7..183aefa5a4 100644 --- a/runtime/dex/dex_file_layout.h +++ b/libdexfile/dex/dex_file_layout.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_DEX_DEX_FILE_LAYOUT_H_ -#define ART_RUNTIME_DEX_DEX_FILE_LAYOUT_H_ +#ifndef ART_LIBDEXFILE_DEX_DEX_FILE_LAYOUT_H_ +#define ART_LIBDEXFILE_DEX_DEX_FILE_LAYOUT_H_ #include <algorithm> #include <cstdint> @@ -96,6 +96,9 @@ class DexLayoutSection { void Madvise(const DexFile* dex_file, int advice) const; }; + // Madvise the largest page-aligned region contained in [begin, end). + static int MadviseLargestPageAlignedRegion(const uint8_t* begin, const uint8_t* end, int advice); + Subsection parts_[static_cast<size_t>(LayoutType::kLayoutTypeCount)]; }; @@ -121,4 +124,4 @@ std::ostream& operator<<(std::ostream& os, const DexLayoutSections& sections); } // namespace art -#endif // ART_RUNTIME_DEX_DEX_FILE_LAYOUT_H_ +#endif // ART_LIBDEXFILE_DEX_DEX_FILE_LAYOUT_H_ diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc index 85c7281102..8069408b5a 100644 --- a/oatdump/oatdump.cc +++ b/oatdump/oatdump.cc @@ -34,6 +34,7 @@ #include "art_field-inl.h" #include "art_method-inl.h" #include "base/bit_utils_iterator.h" +#include "base/os.h" #include "base/safe_map.h" #include "base/stl_util.h" #include "base/unix_file/fd_file.h" @@ -69,7 +70,6 @@ #include "oat.h" #include "oat_file-inl.h" #include "oat_file_manager.h" -#include "os.h" #include "scoped_thread_state_change-inl.h" #include "stack.h" #include "stack_map.h" diff --git a/oatdump/oatdump_test.h b/oatdump/oatdump_test.h index d4bed6b3da..fac0bb234e 100644 --- a/oatdump/oatdump_test.h +++ b/oatdump/oatdump_test.h @@ -25,13 +25,13 @@ #include "arch/instruction_set.h" #include "base/file_utils.h" +#include "base/os.h" #include "base/unix_file/fd_file.h" +#include "base/utils.h" #include "common_runtime_test.h" #include "exec_utils.h" #include "gc/heap.h" #include "gc/space/image_space.h" -#include "os.h" -#include "utils.h" #include <sys/types.h> #include <unistd.h> diff --git a/openjdkjvmti/ti_class.cc b/openjdkjvmti/ti_class.cc index 7a9432656a..e55eec4c30 100644 --- a/openjdkjvmti/ti_class.cc +++ b/openjdkjvmti/ti_class.cc @@ -39,6 +39,7 @@ #include "art_jvmti.h" #include "base/array_ref.h" #include "base/macros.h" +#include "base/utils.h" #include "class_linker.h" #include "class_table-inl.h" #include "common_throws.h" @@ -72,7 +73,6 @@ #include "ti_class_loader-inl.h" #include "ti_phase.h" #include "ti_redefine.h" -#include "utils.h" #include "well_known_classes.h" namespace openjdkjvmti { diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc index 0115772456..3df640902a 100644 --- a/patchoat/patchoat.cc +++ b/patchoat/patchoat.cc @@ -35,11 +35,14 @@ #include "base/file_utils.h" #include "base/leb128.h" #include "base/logging.h" // For InitLogging. +#include "base/mutex.h" #include "base/memory_tool.h" +#include "base/os.h" #include "base/scoped_flock.h" #include "base/stringpiece.h" #include "base/unix_file/fd_file.h" #include "base/unix_file/random_access_file_utils.h" +#include "base/utils.h" #include "elf_file.h" #include "elf_file_impl.h" #include "elf_utils.h" @@ -54,11 +57,9 @@ #include "mirror/reference.h" #include "noop_compiler_callbacks.h" #include "offsets.h" -#include "os.h" #include "runtime.h" #include "scoped_thread_state_change-inl.h" #include "thread.h" -#include "utils.h" namespace art { @@ -1177,6 +1178,7 @@ static int patchoat_verify_image(TimingLogger& timings, } static int patchoat(int argc, char **argv) { + Locks::Init(); InitLogging(argv, Runtime::Abort); MemMap::Init(); const bool debug = kIsDebugBuild; diff --git a/patchoat/patchoat.h b/patchoat/patchoat.h index feba523f56..2b1210b5b1 100644 --- a/patchoat/patchoat.h +++ b/patchoat/patchoat.h @@ -21,12 +21,12 @@ #include "base/enums.h" #include "base/macros.h" #include "base/mutex.h" +#include "base/os.h" #include "elf_file.h" #include "elf_utils.h" #include "gc/accounting/space_bitmap.h" #include "gc/heap.h" #include "gc/space/image_space.h" -#include "os.h" #include "runtime.h" namespace art { diff --git a/profman/profile_assistant.cc b/profman/profile_assistant.cc index a00b1fa5bd..b509fb4027 100644 --- a/profman/profile_assistant.cc +++ b/profman/profile_assistant.cc @@ -16,8 +16,8 @@ #include "profile_assistant.h" +#include "base/os.h" #include "base/unix_file/fd_file.h" -#include "os.h" namespace art { diff --git a/profman/profile_assistant_test.cc b/profman/profile_assistant_test.cc index 6359814615..9494f04a5a 100644 --- a/profman/profile_assistant_test.cc +++ b/profman/profile_assistant_test.cc @@ -19,6 +19,7 @@ #include "android-base/strings.h" #include "art_method-inl.h" #include "base/unix_file/fd_file.h" +#include "base/utils.h" #include "common_runtime_test.h" #include "dex/descriptors_names.h" #include "exec_utils.h" @@ -28,7 +29,6 @@ #include "obj_ptr-inl.h" #include "profile_assistant.h" #include "scoped_thread_state_change-inl.h" -#include "utils.h" namespace art { diff --git a/profman/profman.cc b/profman/profman.cc index 5551c34b60..d1cc56389a 100644 --- a/profman/profman.cc +++ b/profman/profman.cc @@ -34,10 +34,12 @@ #include "base/dumpable.h" #include "base/logging.h" // For InitLogging. +#include "base/mutex.h" #include "base/scoped_flock.h" #include "base/stringpiece.h" #include "base/time_utils.h" #include "base/unix_file/fd_file.h" +#include "base/utils.h" #include "boot_image_profile.h" #include "bytecode_utils.h" #include "dex/art_dex_file_loader.h" @@ -49,7 +51,6 @@ #include "profile_assistant.h" #include "runtime.h" #include "type_reference.h" -#include "utils.h" #include "zip_archive.h" namespace art { @@ -204,6 +205,7 @@ class ProfMan FINAL { original_argc = argc; original_argv = argv; + Locks::Init(); InitLogging(argv, Runtime::Abort); // Skip over the command name. diff --git a/runtime/Android.bp b/runtime/Android.bp index c017c5fed8..daab2326c0 100644 --- a/runtime/Android.bp +++ b/runtime/Android.bp @@ -31,25 +31,14 @@ cc_defaults { "aot_class_linker.cc", "art_field.cc", "art_method.cc", - "atomic.cc", "barrier.cc", - "base/allocator.cc", "base/arena_allocator.cc", "base/arena_bit_vector.cc", - "base/bit_vector.cc", - "base/file_magic.cc", "base/file_utils.cc", - "base/hex_dump.cc", - "base/logging.cc", "base/mutex.cc", - "base/runtime_debug.cc", - "base/safe_copy.cc", + "base/quasi_atomic.cc", "base/scoped_arena_allocator.cc", - "base/scoped_flock.cc", - "base/time_utils.cc", "base/timing_logger.cc", - "base/unix_file/fd_file.cc", - "base/unix_file/random_access_file_utils.cc", "cha.cc", "check_jni.cc", "class_linker.cc", @@ -60,7 +49,6 @@ cc_defaults { "debugger.cc", "dex/art_dex_file_loader.cc", "dex/dex_file_annotations.cc", - "dex/dex_file_layout.cc", "dex_to_dex_decompiler.cc", "elf_file.cc", "exec_utils.cc", @@ -192,7 +180,6 @@ cc_defaults { "oat_quick_method_header.cc", "object_lock.cc", "offsets.cc", - "os_linux.cc", "parsed_options.cc", "plugin.cc", "quick_exception_handler.cc", @@ -215,7 +202,6 @@ cc_defaults { "trace.cc", "transaction.cc", "type_lookup_table.cc", - "utils.cc", "vdex_file.cc", "verifier/instruction_flags.cc", "verifier/method_verifier.cc", @@ -406,7 +392,6 @@ cc_defaults { ], header_libs: [ "art_cmdlineparser_headers", - "art_libartbase_headers", "libnativehelper_header_only", "jni_platform_headers", ], @@ -440,13 +425,9 @@ gensrcs { tools: ["generate_operator_out"], srcs: [ "arch/instruction_set.h", - "base/allocator.h", - "base/callee_save_type.h", "base/mutex.h", - "base/unix_file/fd_file.h", "class_status.h", "debugger.h", - "dex/dex_file_layout.h", "gc_root.h", "gc/allocator_type.h", "gc/allocator/rosalloc.h", @@ -487,8 +468,15 @@ art_cc_library { strip: { keep_symbols: true, }, - shared_libs: ["libdexfile"], - export_shared_lib_headers: ["libdexfile"], + whole_static_libs: [ + "libartbase", + ], + shared_libs: [ + "libdexfile", + ], + export_shared_lib_headers: [ + "libdexfile", + ], } art_cc_library { @@ -497,8 +485,15 @@ art_cc_library { "art_debug_defaults", "libart_defaults", ], - shared_libs: ["libdexfiled"], - export_shared_lib_headers: ["libdexfiled"], + whole_static_libs: [ + "libartbased", + ], + shared_libs: [ + "libdexfiled", + ], + export_shared_lib_headers: [ + "libdexfiled", + ], } art_cc_library { @@ -540,23 +535,9 @@ art_cc_test { "arch/x86_64/instruction_set_features_x86_64_test.cc", "barrier_test.cc", "base/arena_allocator_test.cc", - "base/bit_field_test.cc", - "base/bit_string_test.cc", - "base/bit_struct_test.cc", - "base/bit_vector_test.cc", "base/file_utils_test.cc", - "base/hex_dump_test.cc", - "base/histogram_test.cc", - "base/logging_test.cc", "base/mutex_test.cc", - "base/safe_copy_test.cc", - "base/scoped_flock_test.cc", - "base/time_utils_test.cc", "base/timing_logger_test.cc", - "base/transform_array_ref_test.cc", - "base/transform_iterator_test.cc", - "base/variant_map_test.cc", - "base/unix_file/fd_file_test.cc", "cha_test.cc", "class_linker_test.cc", "class_loader_context_test.cc", @@ -615,7 +596,6 @@ art_cc_test { "thread_pool_test.cc", "transaction_test.cc", "type_lookup_table_test.cc", - "utils_test.cc", "vdex_file_test.cc", "verifier/method_verifier_test.cc", "verifier/reg_type_test.cc", diff --git a/runtime/arch/arm/quick_entrypoints_cc_arm.cc b/runtime/arch/arm/quick_entrypoints_cc_arm.cc index 232ec3140e..987b4590b7 100644 --- a/runtime/arch/arm/quick_entrypoints_cc_arm.cc +++ b/runtime/arch/arm/quick_entrypoints_cc_arm.cc @@ -15,7 +15,7 @@ */ #include "art_method.h" -#include "utils.h" // For RoundUp(). +#include "base/utils.h" // For RoundUp(). namespace art { diff --git a/runtime/arch/instruction_set_features.cc b/runtime/arch/instruction_set_features.cc index b6b24c24fb..0c45bc9197 100644 --- a/runtime/arch/instruction_set_features.cc +++ b/runtime/arch/instruction_set_features.cc @@ -19,7 +19,7 @@ #include "android-base/strings.h" #include "base/casts.h" -#include "utils.h" +#include "base/utils.h" #include "arm/instruction_set_features_arm.h" #include "arm64/instruction_set_features_arm64.h" diff --git a/runtime/arch/mips/entrypoints_init_mips.cc b/runtime/arch/mips/entrypoints_init_mips.cc index badee59568..9418caf98c 100644 --- a/runtime/arch/mips/entrypoints_init_mips.cc +++ b/runtime/arch/mips/entrypoints_init_mips.cc @@ -17,8 +17,9 @@ #include <string.h> #include "arch/mips/asm_support_mips.h" -#include "atomic.h" +#include "base/atomic.h" #include "base/logging.h" +#include "base/quasi_atomic.h" #include "entrypoints/entrypoint_utils.h" #include "entrypoints/jni/jni_entrypoints.h" #include "entrypoints/math_entrypoints.h" diff --git a/runtime/arch/mips64/entrypoints_init_mips64.cc b/runtime/arch/mips64/entrypoints_init_mips64.cc index bdfb9421df..2acfe147f8 100644 --- a/runtime/arch/mips64/entrypoints_init_mips64.cc +++ b/runtime/arch/mips64/entrypoints_init_mips64.cc @@ -18,7 +18,8 @@ #include <string.h> #include "arch/mips64/asm_support_mips64.h" -#include "atomic.h" +#include "base/atomic.h" +#include "base/quasi_atomic.h" #include "entrypoints/entrypoint_utils.h" #include "entrypoints/jni/jni_entrypoints.h" #include "entrypoints/math_entrypoints.h" diff --git a/runtime/art_field.cc b/runtime/art_field.cc index 3f70958cff..b867621f02 100644 --- a/runtime/art_field.cc +++ b/runtime/art_field.cc @@ -17,6 +17,7 @@ #include "art_field.h" #include "art_field-inl.h" +#include "base/utils.h" #include "class_linker-inl.h" #include "dex/descriptors_names.h" #include "gc/accounting/card_table-inl.h" @@ -26,7 +27,6 @@ #include "mirror/object_array-inl.h" #include "runtime.h" #include "scoped_thread_state_change-inl.h" -#include "utils.h" #include "well_known_classes.h" namespace art { diff --git a/runtime/art_method-inl.h b/runtime/art_method-inl.h index 92769942c0..8bf91d9da1 100644 --- a/runtime/art_method-inl.h +++ b/runtime/art_method-inl.h @@ -21,6 +21,7 @@ #include "art_field.h" #include "base/callee_save_type.h" +#include "base/utils.h" #include "class_linker-inl.h" #include "common_throws.h" #include "dex/code_item_accessors-inl.h" @@ -44,7 +45,6 @@ #include "runtime-inl.h" #include "scoped_thread_state_change-inl.h" #include "thread-current-inl.h" -#include "utils.h" namespace art { diff --git a/runtime/barrier_test.cc b/runtime/barrier_test.cc index ecdabba8a5..04bb6bab1e 100644 --- a/runtime/barrier_test.cc +++ b/runtime/barrier_test.cc @@ -18,7 +18,7 @@ #include <string> -#include "atomic.h" +#include "base/atomic.h" #include "common_runtime_test.h" #include "mirror/object_array-inl.h" #include "thread-current-inl.h" diff --git a/runtime/base/arena_allocator.cc b/runtime/base/arena_allocator.cc index e87f631c2e..292bde0272 100644 --- a/runtime/base/arena_allocator.cc +++ b/runtime/base/arena_allocator.cc @@ -25,9 +25,9 @@ #include <android-base/logging.h> +#include "base/systrace.h" #include "mem_map.h" #include "mutex.h" -#include "systrace.h" #include "thread-current-inl.h" namespace art { diff --git a/runtime/base/arena_allocator.h b/runtime/base/arena_allocator.h index 060b6fac2e..c3011091e8 100644 --- a/runtime/base/arena_allocator.h +++ b/runtime/base/arena_allocator.h @@ -21,10 +21,10 @@ #include <stdint.h> #include "base/bit_utils.h" +#include "base/debug_stack.h" +#include "base/dchecked_vector.h" #include "base/macros.h" #include "base/memory_tool.h" -#include "dchecked_vector.h" -#include "debug_stack.h" #include "mutex.h" namespace art { diff --git a/runtime/base/file_utils.cc b/runtime/base/file_utils.cc index dd3f8d5b3c..f9d0d12d88 100644 --- a/runtime/base/file_utils.cc +++ b/runtime/base/file_utils.cc @@ -17,10 +17,7 @@ #include "file_utils.h" #include <inttypes.h> -#include <pthread.h> -#include <sys/mman.h> // For madvise #include <sys/stat.h> -#include <sys/syscall.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> @@ -47,10 +44,10 @@ #include "base/bit_utils.h" #include "base/stl_util.h" +#include "base/os.h" #include "base/unix_file/fd_file.h" #include "dex/dex_file_loader.h" #include "globals.h" -#include "os.h" #if defined(__APPLE__) #include <crt_externs.h> @@ -308,19 +305,6 @@ std::string GetSystemImageFilename(const char* location, const InstructionSet is return filename; } -bool FileExists(const std::string& filename) { - struct stat buffer; - return stat(filename.c_str(), &buffer) == 0; -} - -bool FileExistsAndNotEmpty(const std::string& filename) { - struct stat buffer; - if (stat(filename.c_str(), &buffer) != 0) { - return false; - } - return buffer.st_size > 0; -} - std::string ReplaceFileExtension(const std::string& filename, const std::string& new_extension) { const size_t last_ext = filename.find_last_of('.'); if (last_ext == std::string::npos) { @@ -330,26 +314,6 @@ std::string ReplaceFileExtension(const std::string& filename, const std::string& } } -int64_t GetFileSizeBytes(const std::string& filename) { - struct stat stat_buf; - int rc = stat(filename.c_str(), &stat_buf); - return rc == 0 ? stat_buf.st_size : -1; -} - -int MadviseLargestPageAlignedRegion(const uint8_t* begin, const uint8_t* end, int advice) { - DCHECK_LE(begin, end); - begin = AlignUp(begin, kPageSize); - end = AlignDown(end, kPageSize); - if (begin < end) { - int result = madvise(const_cast<uint8_t*>(begin), end - begin, advice); - if (result != 0) { - PLOG(WARNING) << "madvise failed " << result; - } - return result; - } - return 0; -} - bool LocationIsOnSystem(const char* location) { UniqueCPtr<const char[]> path(realpath(location, nullptr)); return path != nullptr && android::base::StartsWith(path.get(), GetAndroidRoot().c_str()); diff --git a/runtime/base/file_utils.h b/runtime/base/file_utils.h index cac0950d9c..7f691d546b 100644 --- a/runtime/base/file_utils.h +++ b/runtime/base/file_utils.h @@ -65,10 +65,6 @@ std::string GetSystemImageFilename(const char* location, InstructionSet isa); // Returns the vdex filename for the given oat filename. std::string GetVdexFilename(const std::string& oat_filename); -// Returns true if the file exists. -bool FileExists(const std::string& filename); -bool FileExistsAndNotEmpty(const std::string& filename); - // Returns `filename` with the text after the last occurrence of '.' replaced with // `extension`. If `filename` does not contain a period, returns a string containing `filename`, // a period, and `new_extension`. @@ -76,12 +72,6 @@ bool FileExistsAndNotEmpty(const std::string& filename); // ReplaceFileExtension("foo", "abc") == "foo.abc" std::string ReplaceFileExtension(const std::string& filename, const std::string& new_extension); -// Return the file size in bytes or -1 if the file does not exists. -int64_t GetFileSizeBytes(const std::string& filename); - -// Madvise the largest page aligned region within begin and end. -int MadviseLargestPageAlignedRegion(const uint8_t* begin, const uint8_t* end, int advice); - // Return whether the location is on system (i.e. android root). bool LocationIsOnSystem(const char* location); diff --git a/runtime/base/mutex-inl.h b/runtime/base/mutex-inl.h index 01adbf17e2..d6dbab4606 100644 --- a/runtime/base/mutex-inl.h +++ b/runtime/base/mutex-inl.h @@ -21,9 +21,9 @@ #include "mutex.h" +#include "base/utils.h" #include "base/value_object.h" #include "thread.h" -#include "utils.h" #if ART_USE_FUTEXES #include "linux/futex.h" diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc index 3d2226c1dc..a1f30b6794 100644 --- a/runtime/base/mutex.cc +++ b/runtime/base/mutex.cc @@ -21,7 +21,7 @@ #include "android-base/stringprintf.h" -#include "atomic.h" +#include "base/atomic.h" #include "base/logging.h" #include "base/systrace.h" #include "base/time_utils.h" diff --git a/runtime/base/mutex.h b/runtime/base/mutex.h index 4f7001a101..437661798f 100644 --- a/runtime/base/mutex.h +++ b/runtime/base/mutex.h @@ -26,10 +26,10 @@ #include <android-base/logging.h> -#include "atomic.h" #include "base/aborting.h" +#include "base/atomic.h" +#include "base/globals.h" #include "base/macros.h" -#include "globals.h" #if defined(__APPLE__) #define ART_USE_FUTEXES 0 @@ -50,6 +50,7 @@ class SHARED_LOCKABLE ReaderWriterMutex; class SHARED_LOCKABLE MutatorMutex; class ScopedContentionRecorder; class Thread; +class Mutex; // LockLevel is used to impose a lock hierarchy [1] where acquisition of a Mutex at a higher or // equal level to a lock a thread holds is invalid. The lock hierarchy achieves a cycle free diff --git a/runtime/atomic.cc b/runtime/base/quasi_atomic.cc index 07aceb7cfc..1a82812981 100644 --- a/runtime/atomic.cc +++ b/runtime/base/quasi_atomic.cc @@ -14,7 +14,8 @@ * limitations under the License. */ -#include "atomic.h" +#include "base/quasi_atomic.h" + #include "base/mutex.h" #include "base/stl_util.h" #include "thread-current-inl.h" diff --git a/runtime/base/quasi_atomic.h b/runtime/base/quasi_atomic.h new file mode 100644 index 0000000000..067d01db01 --- /dev/null +++ b/runtime/base/quasi_atomic.h @@ -0,0 +1,190 @@ +/* + * Copyright (C) 2008 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_BASE_QUASI_ATOMIC_H_ +#define ART_RUNTIME_BASE_QUASI_ATOMIC_H_ + +#include <stdint.h> +#include <atomic> +#include <limits> +#include <vector> + +#include <android-base/logging.h> + +#include "arch/instruction_set.h" +#include "base/macros.h" + +namespace art { + +class Mutex; + +// QuasiAtomic encapsulates two separate facilities that we are +// trying to move away from: "quasiatomic" 64 bit operations +// and custom memory fences. For the time being, they remain +// exposed. Clients should be converted to use either class Atomic +// below whenever possible, and should eventually use C++11 atomics. +// The two facilities that do not have a good C++11 analog are +// ThreadFenceForConstructor and Atomic::*JavaData. +// +// NOTE: Two "quasiatomic" operations on the exact same memory address +// are guaranteed to operate atomically with respect to each other, +// but no guarantees are made about quasiatomic operations mixed with +// non-quasiatomic operations on the same address, nor about +// quasiatomic operations that are performed on partially-overlapping +// memory. +class QuasiAtomic { + static constexpr bool NeedSwapMutexes(InstructionSet isa) { + // TODO - mips64 still need this for Cas64 ??? + return (isa == InstructionSet::kMips) || (isa == InstructionSet::kMips64); + } + + public: + static void Startup(); + + static void Shutdown(); + + // Reads the 64-bit value at "addr" without tearing. + static int64_t Read64(volatile const int64_t* addr) { + if (!NeedSwapMutexes(kRuntimeISA)) { + int64_t value; +#if defined(__LP64__) + value = *addr; +#else +#if defined(__arm__) +#if defined(__ARM_FEATURE_LPAE) + // With LPAE support (such as Cortex-A15) then ldrd is defined not to tear. + __asm__ __volatile__("@ QuasiAtomic::Read64\n" + "ldrd %0, %H0, %1" + : "=r" (value) + : "m" (*addr)); +#else + // Exclusive loads are defined not to tear, clearing the exclusive state isn't necessary. + __asm__ __volatile__("@ QuasiAtomic::Read64\n" + "ldrexd %0, %H0, %1" + : "=r" (value) + : "Q" (*addr)); +#endif +#elif defined(__i386__) + __asm__ __volatile__( + "movq %1, %0\n" + : "=x" (value) + : "m" (*addr)); +#else + LOG(FATAL) << "Unsupported architecture"; +#endif +#endif // defined(__LP64__) + return value; + } else { + return SwapMutexRead64(addr); + } + } + + // Writes to the 64-bit value at "addr" without tearing. + static void Write64(volatile int64_t* addr, int64_t value) { + if (!NeedSwapMutexes(kRuntimeISA)) { +#if defined(__LP64__) + *addr = value; +#else +#if defined(__arm__) +#if defined(__ARM_FEATURE_LPAE) + // If we know that ARM architecture has LPAE (such as Cortex-A15) strd is defined not to tear. + __asm__ __volatile__("@ QuasiAtomic::Write64\n" + "strd %1, %H1, %0" + : "=m"(*addr) + : "r" (value)); +#else + // The write is done as a swap so that the cache-line is in the exclusive state for the store. + int64_t prev; + int status; + do { + __asm__ __volatile__("@ QuasiAtomic::Write64\n" + "ldrexd %0, %H0, %2\n" + "strexd %1, %3, %H3, %2" + : "=&r" (prev), "=&r" (status), "+Q"(*addr) + : "r" (value) + : "cc"); + } while (UNLIKELY(status != 0)); +#endif +#elif defined(__i386__) + __asm__ __volatile__( + "movq %1, %0" + : "=m" (*addr) + : "x" (value)); +#else + LOG(FATAL) << "Unsupported architecture"; +#endif +#endif // defined(__LP64__) + } else { + SwapMutexWrite64(addr, value); + } + } + + // Atomically compare the value at "addr" to "old_value", if equal replace it with "new_value" + // and return true. Otherwise, don't swap, and return false. + // This is fully ordered, i.e. it has C++11 memory_order_seq_cst + // semantics (assuming all other accesses use a mutex if this one does). + // This has "strong" semantics; if it fails then it is guaranteed that + // at some point during the execution of Cas64, *addr was not equal to + // old_value. + static bool Cas64(int64_t old_value, int64_t new_value, volatile int64_t* addr) { + if (!NeedSwapMutexes(kRuntimeISA)) { + return __sync_bool_compare_and_swap(addr, old_value, new_value); + } else { + return SwapMutexCas64(old_value, new_value, addr); + } + } + + // Does the architecture provide reasonable atomic long operations or do we fall back on mutexes? + static bool LongAtomicsUseMutexes(InstructionSet isa) { + return NeedSwapMutexes(isa); + } + + static void ThreadFenceAcquire() { + std::atomic_thread_fence(std::memory_order_acquire); + } + + static void ThreadFenceRelease() { + std::atomic_thread_fence(std::memory_order_release); + } + + static void ThreadFenceForConstructor() { + #if defined(__aarch64__) + __asm__ __volatile__("dmb ishst" : : : "memory"); + #else + std::atomic_thread_fence(std::memory_order_release); + #endif + } + + static void ThreadFenceSequentiallyConsistent() { + std::atomic_thread_fence(std::memory_order_seq_cst); + } + + private: + static Mutex* GetSwapMutex(const volatile int64_t* addr); + static int64_t SwapMutexRead64(volatile const int64_t* addr); + static void SwapMutexWrite64(volatile int64_t* addr, int64_t val); + static bool SwapMutexCas64(int64_t old_value, int64_t new_value, volatile int64_t* addr); + + // We stripe across a bunch of different mutexes to reduce contention. + static constexpr size_t kSwapMutexCount = 32; + static std::vector<Mutex*>* gSwapMutexes; + + DISALLOW_COPY_AND_ASSIGN(QuasiAtomic); +}; + +} // namespace art + +#endif // ART_RUNTIME_BASE_QUASI_ATOMIC_H_ diff --git a/runtime/base/scoped_arena_allocator.h b/runtime/base/scoped_arena_allocator.h index 202902e5aa..a253e2f535 100644 --- a/runtime/base/scoped_arena_allocator.h +++ b/runtime/base/scoped_arena_allocator.h @@ -20,9 +20,9 @@ #include <android-base/logging.h> #include "arena_allocator.h" +#include "base/debug_stack.h" +#include "base/globals.h" #include "base/macros.h" -#include "debug_stack.h" -#include "globals.h" namespace art { diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index c667fe2f30..ded9f96206 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -38,12 +38,15 @@ #include "base/casts.h" #include "base/leb128.h" #include "base/logging.h" +#include "base/os.h" +#include "base/quasi_atomic.h" #include "base/scoped_arena_containers.h" #include "base/scoped_flock.h" #include "base/stl_util.h" #include "base/systrace.h" #include "base/time_utils.h" #include "base/unix_file/fd_file.h" +#include "base/utils.h" #include "base/value_object.h" #include "cha.h" #include "class_linker-inl.h" @@ -111,14 +114,12 @@ #include "oat_file_assistant.h" #include "oat_file_manager.h" #include "object_lock.h" -#include "os.h" #include "runtime.h" #include "runtime_callbacks.h" #include "scoped_thread_state_change-inl.h" #include "thread-inl.h" #include "thread_list.h" #include "trace.h" -#include "utils.h" #include "utils/dex_cache_arrays_layout-inl.h" #include "verifier/method_verifier.h" #include "well_known_classes.h" diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc index 80ef6544e8..8cd0604ac3 100644 --- a/runtime/class_linker_test.cc +++ b/runtime/class_linker_test.cc @@ -1596,6 +1596,63 @@ TEST_F(ClassLinkerTest, CreateWellKnownClassLoader) { LoadDexInDelegateLastClassLoader("Interfaces", class_loader_c); } +TEST_F(ClassLinkerTest, PrettyClass) { + ScopedObjectAccess soa(Thread::Current()); + EXPECT_EQ("null", mirror::Class::PrettyClass(nullptr)); + mirror::Class* c = class_linker_->FindSystemClass(soa.Self(), "[Ljava/lang/String;"); + ASSERT_TRUE(c != nullptr); + mirror::Object* o = mirror::ObjectArray<mirror::String>::Alloc(soa.Self(), c, 0); + EXPECT_EQ("java.lang.Class<java.lang.String[]>", mirror::Class::PrettyClass(o->GetClass())); +} + +TEST_F(ClassLinkerTest, PrettyClassAndClassLoader) { + ScopedObjectAccess soa(Thread::Current()); + EXPECT_EQ("null", mirror::Class::PrettyClassAndClassLoader(nullptr)); + mirror::Class* c = class_linker_->FindSystemClass(soa.Self(), "[Ljava/lang/String;"); + ASSERT_TRUE(c != nullptr); + mirror::Object* o = mirror::ObjectArray<mirror::String>::Alloc(soa.Self(), c, 0); + EXPECT_EQ("java.lang.Class<java.lang.String[],null>", + mirror::Class::PrettyClassAndClassLoader(o->GetClass())); +} + +TEST_F(ClassLinkerTest, PrettyField) { + ScopedObjectAccess soa(Thread::Current()); + EXPECT_EQ("null", ArtField::PrettyField(nullptr)); + + mirror::Class* java_lang_String = class_linker_->FindSystemClass(soa.Self(), + "Ljava/lang/String;"); + + ArtField* f; + f = java_lang_String->FindDeclaredInstanceField("count", "I"); + EXPECT_EQ("int java.lang.String.count", f->PrettyField()); + EXPECT_EQ("java.lang.String.count", f->PrettyField(false)); +} + +TEST_F(ClassLinkerTest, JniShortName_JniLongName) { + ScopedObjectAccess soa(Thread::Current()); + mirror::Class* c = class_linker_->FindSystemClass(soa.Self(), "Ljava/lang/String;"); + ASSERT_TRUE(c != nullptr); + ArtMethod* m; + + m = c->FindClassMethod("charAt", "(I)C", kRuntimePointerSize); + ASSERT_TRUE(m != nullptr); + ASSERT_FALSE(m->IsDirect()); + EXPECT_EQ("Java_java_lang_String_charAt", m->JniShortName()); + EXPECT_EQ("Java_java_lang_String_charAt__I", m->JniLongName()); + + m = c->FindClassMethod("indexOf", "(Ljava/lang/String;I)I", kRuntimePointerSize); + ASSERT_TRUE(m != nullptr); + ASSERT_FALSE(m->IsDirect()); + EXPECT_EQ("Java_java_lang_String_indexOf", m->JniShortName()); + EXPECT_EQ("Java_java_lang_String_indexOf__Ljava_lang_String_2I", m->JniLongName()); + + m = c->FindClassMethod("copyValueOf", "([CII)Ljava/lang/String;", kRuntimePointerSize); + ASSERT_TRUE(m != nullptr); + ASSERT_TRUE(m->IsStatic()); + EXPECT_EQ("Java_java_lang_String_copyValueOf", m->JniShortName()); + EXPECT_EQ("Java_java_lang_String_copyValueOf___3CII", m->JniLongName()); +} + class ClassLinkerClassLoaderTest : public ClassLinkerTest { protected: // Verifies that the class identified by the given descriptor is loaded with diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc index e4fbc86020..add300bdf3 100644 --- a/runtime/common_runtime_test.cc +++ b/runtime/common_runtime_test.cc @@ -30,6 +30,8 @@ #include "base/file_utils.h" #include "base/logging.h" #include "base/macros.h" +#include "base/mutex.h" +#include "base/os.h" #include "base/runtime_debug.h" #include "base/stl_util.h" #include "base/unix_file/fd_file.h" @@ -51,7 +53,6 @@ #include "mirror/class_loader.h" #include "native/dalvik_system_DexFile.h" #include "noop_compiler_callbacks.h" -#include "os.h" #include "runtime-inl.h" #include "scoped_thread_state_change-inl.h" #include "thread.h" @@ -63,6 +64,7 @@ int main(int argc, char **argv) { // everything else. In case you want to see all messages, comment out the line. setenv("ANDROID_LOG_TAGS", "*:e", 1); + art::Locks::Init(); art::InitLogging(argv, art::Runtime::Abort); LOG(INFO) << "Running main() from common_runtime_test.cc..."; testing::InitGoogleTest(&argc, argv); diff --git a/runtime/common_runtime_test.h b/runtime/common_runtime_test.h index 85b0dbb43c..7fc70e294f 100644 --- a/runtime/common_runtime_test.h +++ b/runtime/common_runtime_test.h @@ -26,13 +26,13 @@ #include "arch/instruction_set.h" #include "base/mutex.h" +#include "base/os.h" #include "base/unix_file/fd_file.h" #include "dex/art_dex_file_loader.h" #include "dex/compact_dex_level.h" #include "globals.h" // TODO: Add inl file and avoid including inl. #include "obj_ptr-inl.h" -#include "os.h" #include "scoped_thread_state_change-inl.h" namespace art { diff --git a/runtime/compiler_filter.cc b/runtime/compiler_filter.cc index 7b2dd05156..bda64ebf25 100644 --- a/runtime/compiler_filter.cc +++ b/runtime/compiler_filter.cc @@ -16,7 +16,7 @@ #include "compiler_filter.h" -#include "utils.h" +#include "base/utils.h" namespace art { diff --git a/runtime/dex/art_dex_file_loader_test.cc b/runtime/dex/art_dex_file_loader_test.cc index 25d4dd0875..6e2cfec381 100644 --- a/runtime/dex/art_dex_file_loader_test.cc +++ b/runtime/dex/art_dex_file_loader_test.cc @@ -19,6 +19,7 @@ #include <memory> #include "art_dex_file_loader.h" +#include "base/os.h" #include "base/stl_util.h" #include "base/unix_file/fd_file.h" #include "common_runtime_test.h" @@ -29,7 +30,6 @@ #include "dex/dex_file-inl.h" #include "dex/dex_file_loader.h" #include "mem_map.h" -#include "os.h" #include "scoped_thread_state_change-inl.h" #include "thread-current-inl.h" diff --git a/runtime/dex2oat_environment_test.h b/runtime/dex2oat_environment_test.h index 75642fc889..00a95cc7bd 100644 --- a/runtime/dex2oat_environment_test.h +++ b/runtime/dex2oat_environment_test.h @@ -24,7 +24,9 @@ #include <gtest/gtest.h> #include "base/file_utils.h" +#include "base/os.h" #include "base/stl_util.h" +#include "base/utils.h" #include "common_runtime_test.h" #include "compiler_callbacks.h" #include "dex/art_dex_file_loader.h" @@ -33,9 +35,7 @@ #include "gc/heap.h" #include "gc/space/image_space.h" #include "oat_file_assistant.h" -#include "os.h" #include "runtime.h" -#include "utils.h" namespace art { diff --git a/runtime/elf_file.cc b/runtime/elf_file.cc index b4661819ef..719b4af293 100644 --- a/runtime/elf_file.cc +++ b/runtime/elf_file.cc @@ -28,9 +28,9 @@ #include "base/leb128.h" #include "base/stl_util.h" #include "base/unix_file/fd_file.h" +#include "base/utils.h" #include "elf_file_impl.h" #include "elf_utils.h" -#include "utils.h" namespace art { diff --git a/runtime/elf_file.h b/runtime/elf_file.h index b1c9395fb5..ab9e6fa2ec 100644 --- a/runtime/elf_file.h +++ b/runtime/elf_file.h @@ -21,9 +21,9 @@ #include <string> #include "base/macros.h" +#include "base/os.h" // Explicitly include our own elf.h to avoid Linux and other dependencies. #include "./elf.h" -#include "os.h" namespace art { template <typename ElfTypes> diff --git a/runtime/entrypoints/quick/quick_alloc_entrypoints.cc b/runtime/entrypoints/quick/quick_alloc_entrypoints.cc index 1ab67ec2b9..ed5885f224 100644 --- a/runtime/entrypoints/quick/quick_alloc_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_alloc_entrypoints.cc @@ -18,6 +18,7 @@ #include "art_method-inl.h" #include "base/enums.h" +#include "base/quasi_atomic.h" #include "callee_save_frame.h" #include "dex/dex_file_types.h" #include "entrypoints/entrypoint_utils-inl.h" diff --git a/runtime/gc/accounting/atomic_stack.h b/runtime/gc/accounting/atomic_stack.h index f8d8271335..6b103bfe1b 100644 --- a/runtime/gc/accounting/atomic_stack.h +++ b/runtime/gc/accounting/atomic_stack.h @@ -25,7 +25,7 @@ #include <android-base/logging.h> -#include "atomic.h" +#include "base/atomic.h" #include "base/macros.h" #include "mem_map.h" #include "stack_reference.h" diff --git a/runtime/gc/accounting/bitmap-inl.h b/runtime/gc/accounting/bitmap-inl.h index bf153f56d8..a71b212af3 100644 --- a/runtime/gc/accounting/bitmap-inl.h +++ b/runtime/gc/accounting/bitmap-inl.h @@ -23,7 +23,7 @@ #include <android-base/logging.h> -#include "atomic.h" +#include "base/atomic.h" #include "base/bit_utils.h" namespace art { diff --git a/runtime/gc/accounting/card_table-inl.h b/runtime/gc/accounting/card_table-inl.h index adca5c835e..14f5d0e1c6 100644 --- a/runtime/gc/accounting/card_table-inl.h +++ b/runtime/gc/accounting/card_table-inl.h @@ -21,7 +21,7 @@ #include <android-base/logging.h> -#include "atomic.h" +#include "base/atomic.h" #include "base/bit_utils.h" #include "mem_map.h" #include "space_bitmap.h" diff --git a/runtime/gc/accounting/card_table.cc b/runtime/gc/accounting/card_table.cc index 934e57a61b..4eea607c39 100644 --- a/runtime/gc/accounting/card_table.cc +++ b/runtime/gc/accounting/card_table.cc @@ -19,13 +19,13 @@ #include <sys/mman.h> #include "base/systrace.h" +#include "base/utils.h" #include "card_table-inl.h" #include "gc/heap.h" #include "gc/space/space.h" #include "heap_bitmap.h" #include "mem_map.h" #include "runtime.h" -#include "utils.h" namespace art { namespace gc { diff --git a/runtime/gc/accounting/card_table_test.cc b/runtime/gc/accounting/card_table_test.cc index cb2479ffad..87965eddb8 100644 --- a/runtime/gc/accounting/card_table_test.cc +++ b/runtime/gc/accounting/card_table_test.cc @@ -18,14 +18,14 @@ #include <string> -#include "atomic.h" +#include "base/atomic.h" +#include "base/utils.h" #include "common_runtime_test.h" #include "handle_scope-inl.h" #include "mirror/class-inl.h" #include "mirror/string-inl.h" // Strings are easiest to allocate #include "scoped_thread_state_change-inl.h" #include "thread_pool.h" -#include "utils.h" namespace art { diff --git a/runtime/gc/accounting/remembered_set.h b/runtime/gc/accounting/remembered_set.h index e9376a90ef..b96f0d318c 100644 --- a/runtime/gc/accounting/remembered_set.h +++ b/runtime/gc/accounting/remembered_set.h @@ -18,8 +18,9 @@ #define ART_RUNTIME_GC_ACCOUNTING_REMEMBERED_SET_H_ #include "base/allocator.h" +#include "base/globals.h" +#include "base/mutex.h" #include "base/safe_map.h" -#include "globals.h" #include <set> #include <vector> diff --git a/runtime/gc/accounting/space_bitmap-inl.h b/runtime/gc/accounting/space_bitmap-inl.h index 354b9e1dbd..384e3c2f4c 100644 --- a/runtime/gc/accounting/space_bitmap-inl.h +++ b/runtime/gc/accounting/space_bitmap-inl.h @@ -23,7 +23,7 @@ #include <android-base/logging.h> -#include "atomic.h" +#include "base/atomic.h" #include "base/bit_utils.h" namespace art { diff --git a/runtime/gc/allocator/dlmalloc.cc b/runtime/gc/allocator/dlmalloc.cc index 4570e9c1b8..e508d5fddf 100644 --- a/runtime/gc/allocator/dlmalloc.cc +++ b/runtime/gc/allocator/dlmalloc.cc @@ -59,8 +59,8 @@ static void art_heap_usage_error(const char* function, void* p) { #include <sys/mman.h> -#include "globals.h" -#include "utils.h" +#include "base/globals.h" +#include "base/utils.h" extern "C" void DlmallocMadviseCallback(void* start, void* end, size_t used_bytes, void* arg) { // Is this chunk in use? diff --git a/runtime/gc/collector/concurrent_copying.cc b/runtime/gc/collector/concurrent_copying.cc index a78813bf7c..b10c504dd5 100644 --- a/runtime/gc/collector/concurrent_copying.cc +++ b/runtime/gc/collector/concurrent_copying.cc @@ -20,6 +20,7 @@ #include "base/enums.h" #include "base/file_utils.h" #include "base/histogram-inl.h" +#include "base/quasi_atomic.h" #include "base/stl_util.h" #include "base/systrace.h" #include "debugger.h" diff --git a/runtime/gc/collector/garbage_collector.cc b/runtime/gc/collector/garbage_collector.cc index fa34270d95..5e3692ea9a 100644 --- a/runtime/gc/collector/garbage_collector.cc +++ b/runtime/gc/collector/garbage_collector.cc @@ -26,6 +26,7 @@ #include "base/mutex-inl.h" #include "base/systrace.h" #include "base/time_utils.h" +#include "base/utils.h" #include "gc/accounting/heap_bitmap.h" #include "gc/gc_pause_listener.h" #include "gc/heap.h" @@ -34,7 +35,6 @@ #include "runtime.h" #include "thread-current-inl.h" #include "thread_list.h" -#include "utils.h" namespace art { namespace gc { diff --git a/runtime/gc/collector/mark_compact.h b/runtime/gc/collector/mark_compact.h index 41228099d3..e7749597cd 100644 --- a/runtime/gc/collector/mark_compact.h +++ b/runtime/gc/collector/mark_compact.h @@ -20,7 +20,7 @@ #include <deque> #include <memory> // For unique_ptr. -#include "atomic.h" +#include "base/atomic.h" #include "base/macros.h" #include "base/mutex.h" #include "garbage_collector.h" diff --git a/runtime/gc/collector/mark_sweep.h b/runtime/gc/collector/mark_sweep.h index 53b899e09e..5e0fe0607f 100644 --- a/runtime/gc/collector/mark_sweep.h +++ b/runtime/gc/collector/mark_sweep.h @@ -19,7 +19,7 @@ #include <memory> -#include "atomic.h" +#include "base/atomic.h" #include "barrier.h" #include "base/macros.h" #include "base/mutex.h" diff --git a/runtime/gc/collector/semi_space.h b/runtime/gc/collector/semi_space.h index fc77c17497..d1d45c8df6 100644 --- a/runtime/gc/collector/semi_space.h +++ b/runtime/gc/collector/semi_space.h @@ -19,7 +19,7 @@ #include <memory> -#include "atomic.h" +#include "base/atomic.h" #include "base/macros.h" #include "base/mutex.h" #include "garbage_collector.h" diff --git a/runtime/gc/heap-inl.h b/runtime/gc/heap-inl.h index 6735961591..41ee18350d 100644 --- a/runtime/gc/heap-inl.h +++ b/runtime/gc/heap-inl.h @@ -20,7 +20,9 @@ #include "heap.h" #include "allocation_listener.h" +#include "base/quasi_atomic.h" #include "base/time_utils.h" +#include "base/utils.h" #include "gc/accounting/atomic_stack.h" #include "gc/accounting/card_table-inl.h" #include "gc/allocation_record.h" @@ -34,7 +36,6 @@ #include "obj_ptr-inl.h" #include "runtime.h" #include "thread-inl.h" -#include "utils.h" #include "verify_object.h" namespace art { diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index 19b4acd836..3dc2cb572e 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -32,6 +32,7 @@ #include "base/histogram-inl.h" #include "base/logging.h" // For VLOG. #include "base/memory_tool.h" +#include "base/os.h" #include "base/stl_util.h" #include "base/systrace.h" #include "base/time_utils.h" @@ -81,7 +82,6 @@ #include "mirror/reference-inl.h" #include "nativehelper/scoped_local_ref.h" #include "obj_ptr-inl.h" -#include "os.h" #include "reflection.h" #include "runtime.h" #include "scoped_thread_state_change-inl.h" diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h index 592172f9fe..4de03318a0 100644 --- a/runtime/gc/heap.h +++ b/runtime/gc/heap.h @@ -26,7 +26,7 @@ #include "allocator_type.h" #include "arch/instruction_set.h" -#include "atomic.h" +#include "base/atomic.h" #include "base/macros.h" #include "base/mutex.h" #include "base/runtime_debug.h" diff --git a/runtime/gc/reference_processor.cc b/runtime/gc/reference_processor.cc index c59642fe4e..356f3ecaa8 100644 --- a/runtime/gc/reference_processor.cc +++ b/runtime/gc/reference_processor.cc @@ -17,6 +17,7 @@ #include "reference_processor.h" #include "base/time_utils.h" +#include "base/utils.h" #include "collector/garbage_collector.h" #include "java_vm_ext.h" #include "mirror/class-inl.h" @@ -28,7 +29,6 @@ #include "reflection.h" #include "scoped_thread_state_change-inl.h" #include "task_processor.h" -#include "utils.h" #include "well_known_classes.h" namespace art { diff --git a/runtime/gc/reference_queue.h b/runtime/gc/reference_queue.h index c48d48c530..af7788130b 100644 --- a/runtime/gc/reference_queue.h +++ b/runtime/gc/reference_queue.h @@ -21,7 +21,7 @@ #include <string> #include <vector> -#include "atomic.h" +#include "base/atomic.h" #include "base/mutex.h" #include "base/timing_logger.h" #include "globals.h" diff --git a/runtime/gc/space/dlmalloc_space.cc b/runtime/gc/space/dlmalloc_space.cc index a3eef90e3a..025c3f0ead 100644 --- a/runtime/gc/space/dlmalloc_space.cc +++ b/runtime/gc/space/dlmalloc_space.cc @@ -18,6 +18,7 @@ #include "base/logging.h" // For VLOG. #include "base/time_utils.h" +#include "base/utils.h" #include "gc/accounting/card_table.h" #include "gc/accounting/space_bitmap-inl.h" #include "gc/heap.h" @@ -30,7 +31,6 @@ #include "scoped_thread_state_change-inl.h" #include "thread.h" #include "thread_list.h" -#include "utils.h" namespace art { namespace gc { diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc index 366eb535f4..c100bc0c75 100644 --- a/runtime/gc/space/image_space.cc +++ b/runtime/gc/space/image_space.cc @@ -32,10 +32,12 @@ #include "base/enums.h" #include "base/file_utils.h" #include "base/macros.h" +#include "base/os.h" #include "base/scoped_flock.h" #include "base/stl_util.h" #include "base/systrace.h" #include "base/time_utils.h" +#include "base/utils.h" #include "dex/art_dex_file_loader.h" #include "dex/dex_file_loader.h" #include "exec_utils.h" @@ -46,10 +48,8 @@ #include "mirror/object-inl.h" #include "mirror/object-refvisitor-inl.h" #include "oat_file.h" -#include "os.h" #include "runtime.h" #include "space-inl.h" -#include "utils.h" namespace art { namespace gc { diff --git a/runtime/gc/space/image_space_fs.h b/runtime/gc/space/image_space_fs.h index 6ce81e9209..14deb6f001 100644 --- a/runtime/gc/space/image_space_fs.h +++ b/runtime/gc/space/image_space_fs.h @@ -23,13 +23,13 @@ #include "android-base/stringprintf.h" #include "base/file_utils.h" +#include "base/globals.h" #include "base/logging.h" // For VLOG. #include "base/macros.h" +#include "base/os.h" #include "base/unix_file/fd_file.h" -#include "globals.h" -#include "os.h" +#include "base/utils.h" #include "runtime.h" -#include "utils.h" namespace art { namespace gc { diff --git a/runtime/gc/space/large_object_space.cc b/runtime/gc/space/large_object_space.cc index d2efb102e9..512cde484d 100644 --- a/runtime/gc/space/large_object_space.cc +++ b/runtime/gc/space/large_object_space.cc @@ -25,12 +25,12 @@ #include "base/macros.h" #include "base/memory_tool.h" #include "base/mutex-inl.h" +#include "base/os.h" #include "base/stl_util.h" #include "gc/accounting/heap_bitmap-inl.h" #include "gc/accounting/space_bitmap-inl.h" #include "gc/heap.h" #include "image.h" -#include "os.h" #include "scoped_thread_state_change-inl.h" #include "space-inl.h" #include "thread-current-inl.h" diff --git a/runtime/gc/space/malloc_space.cc b/runtime/gc/space/malloc_space.cc index 17274b508d..0965560e2c 100644 --- a/runtime/gc/space/malloc_space.cc +++ b/runtime/gc/space/malloc_space.cc @@ -19,6 +19,7 @@ #include "android-base/stringprintf.h" #include "base/logging.h" // For VLOG +#include "base/utils.h" #include "gc/accounting/card_table-inl.h" #include "gc/accounting/space_bitmap-inl.h" #include "gc/heap.h" @@ -30,7 +31,6 @@ #include "runtime.h" #include "thread.h" #include "thread_list.h" -#include "utils.h" namespace art { namespace gc { diff --git a/runtime/gc/space/rosalloc_space.cc b/runtime/gc/space/rosalloc_space.cc index 3a685cb82d..e7865363a1 100644 --- a/runtime/gc/space/rosalloc_space.cc +++ b/runtime/gc/space/rosalloc_space.cc @@ -19,6 +19,7 @@ #include "base/logging.h" // For VLOG. #include "base/time_utils.h" +#include "base/utils.h" #include "gc/accounting/card_table.h" #include "gc/accounting/space_bitmap-inl.h" #include "gc/heap.h" @@ -29,7 +30,6 @@ #include "scoped_thread_state_change-inl.h" #include "thread.h" #include "thread_list.h" -#include "utils.h" namespace art { namespace gc { diff --git a/runtime/gc/space/space.h b/runtime/gc/space/space.h index 12bccb35e7..7af19fae61 100644 --- a/runtime/gc/space/space.h +++ b/runtime/gc/space/space.h @@ -20,7 +20,7 @@ #include <memory> #include <string> -#include "atomic.h" +#include "base/atomic.h" #include "base/macros.h" #include "base/mutex.h" #include "gc/accounting/space_bitmap.h" diff --git a/runtime/gc/space/zygote_space.cc b/runtime/gc/space/zygote_space.cc index fddb3f2dd2..cde155fb22 100644 --- a/runtime/gc/space/zygote_space.cc +++ b/runtime/gc/space/zygote_space.cc @@ -17,12 +17,12 @@ #include "zygote_space.h" #include "base/mutex-inl.h" +#include "base/utils.h" #include "gc/accounting/card_table-inl.h" #include "gc/accounting/space_bitmap-inl.h" #include "gc/heap.h" #include "runtime.h" #include "thread-current-inl.h" -#include "utils.h" namespace art { namespace gc { diff --git a/runtime/hprof/hprof.cc b/runtime/hprof/hprof.cc index 52ee5169fb..aa716f12ac 100644 --- a/runtime/hprof/hprof.cc +++ b/runtime/hprof/hprof.cc @@ -44,6 +44,7 @@ #include "base/array_ref.h" #include "base/macros.h" #include "base/mutex.h" +#include "base/os.h" #include "base/safe_map.h" #include "base/time_utils.h" #include "base/unix_file/fd_file.h" @@ -64,7 +65,6 @@ #include "mirror/class-inl.h" #include "mirror/class.h" #include "mirror/object-refvisitor-inl.h" -#include "os.h" #include "scoped_thread_state_change-inl.h" #include "thread_list.h" diff --git a/runtime/image.cc b/runtime/image.cc index 99406229a5..0955c3a3ca 100644 --- a/runtime/image.cc +++ b/runtime/image.cc @@ -18,10 +18,10 @@ #include "base/bit_utils.h" #include "base/length_prefixed_array.h" +#include "base/utils.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object_array.h" -#include "utils.h" namespace art { diff --git a/runtime/indirect_reference_table.cc b/runtime/indirect_reference_table.cc index 51878312d9..3b9cc0f946 100644 --- a/runtime/indirect_reference_table.cc +++ b/runtime/indirect_reference_table.cc @@ -18,6 +18,7 @@ #include "base/dumpable-inl.h" #include "base/systrace.h" +#include "base/utils.h" #include "java_vm_ext.h" #include "jni_internal.h" #include "nth_caller_visitor.h" @@ -25,7 +26,6 @@ #include "runtime.h" #include "scoped_thread_state_change-inl.h" #include "thread.h" -#include "utils.h" #include <cstdlib> diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc index b6055cb6c8..7ddd17329c 100644 --- a/runtime/instrumentation.cc +++ b/runtime/instrumentation.cc @@ -21,7 +21,7 @@ #include "arch/context.h" #include "art_field-inl.h" #include "art_method-inl.h" -#include "atomic.h" +#include "base/atomic.h" #include "base/callee_save_type.h" #include "class_linker.h" #include "debugger.h" diff --git a/runtime/intern_table.h b/runtime/intern_table.h index 05f2794b38..cb976917e6 100644 --- a/runtime/intern_table.h +++ b/runtime/intern_table.h @@ -19,7 +19,7 @@ #include <unordered_set> -#include "atomic.h" +#include "base/atomic.h" #include "base/allocator.h" #include "base/hash_set.h" #include "base/mutex.h" diff --git a/runtime/interpreter/interpreter_switch_impl.cc b/runtime/interpreter/interpreter_switch_impl.cc index d8f858e95b..e35d80f724 100644 --- a/runtime/interpreter/interpreter_switch_impl.cc +++ b/runtime/interpreter/interpreter_switch_impl.cc @@ -17,6 +17,7 @@ #include "interpreter_switch_impl.h" #include "base/enums.h" +#include "base/quasi_atomic.h" #include "dex/dex_file_types.h" #include "experimental_flags.h" #include "interpreter_common.h" diff --git a/runtime/interpreter/mterp/mterp.cc b/runtime/interpreter/mterp/mterp.cc index 9c7645af9e..2a9ef2ce98 100644 --- a/runtime/interpreter/mterp/mterp.cc +++ b/runtime/interpreter/mterp/mterp.cc @@ -18,6 +18,8 @@ * Mterp entry point and support functions. */ #include "mterp.h" + +#include "base/quasi_atomic.h" #include "debugger.h" #include "entrypoints/entrypoint_utils-inl.h" #include "interpreter/interpreter_common.h" diff --git a/runtime/interpreter/unstarted_runtime.cc b/runtime/interpreter/unstarted_runtime.cc index a0b58ef29e..600561b85c 100644 --- a/runtime/interpreter/unstarted_runtime.cc +++ b/runtime/interpreter/unstarted_runtime.cc @@ -33,6 +33,7 @@ #include "base/casts.h" #include "base/enums.h" #include "base/macros.h" +#include "base/quasi_atomic.h" #include "class_linker.h" #include "common_throws.h" #include "dex/descriptors_names.h" diff --git a/runtime/jdwp/jdwp.h b/runtime/jdwp/jdwp.h index b491c3ee5c..bf1d665e9d 100644 --- a/runtime/jdwp/jdwp.h +++ b/runtime/jdwp/jdwp.h @@ -17,7 +17,7 @@ #ifndef ART_RUNTIME_JDWP_JDWP_H_ #define ART_RUNTIME_JDWP_JDWP_H_ -#include "atomic.h" +#include "base/atomic.h" #include "base/logging.h" // For VLOG. #include "base/mutex.h" #include "jdwp/jdwp_bits.h" diff --git a/runtime/jdwp/jdwp_handler.cc b/runtime/jdwp/jdwp_handler.cc index 90cac853ff..291a983e75 100644 --- a/runtime/jdwp/jdwp_handler.cc +++ b/runtime/jdwp/jdwp_handler.cc @@ -22,7 +22,7 @@ #include "android-base/stringprintf.h" -#include "atomic.h" +#include "base/atomic.h" #include "base/hex_dump.h" #include "base/logging.h" // For VLOG. #include "base/macros.h" diff --git a/runtime/jdwp/jdwp_main.cc b/runtime/jdwp/jdwp_main.cc index 63f5dc8b69..557b032154 100644 --- a/runtime/jdwp/jdwp_main.cc +++ b/runtime/jdwp/jdwp_main.cc @@ -22,7 +22,7 @@ #include "android-base/stringprintf.h" -#include "atomic.h" +#include "base/atomic.h" #include "base/logging.h" // For VLOG. #include "base/time_utils.h" #include "debugger.h" diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc index 6d99ad0046..a757960e3e 100644 --- a/runtime/jit/jit.cc +++ b/runtime/jit/jit.cc @@ -23,6 +23,7 @@ #include "base/logging.h" // For VLOG. #include "base/memory_tool.h" #include "base/runtime_debug.h" +#include "base/utils.h" #include "debugger.h" #include "entrypoints/runtime_asm_entrypoints.h" #include "interpreter/interpreter.h" @@ -38,7 +39,6 @@ #include "stack_map.h" #include "thread-inl.h" #include "thread_list.h" -#include "utils.h" namespace art { namespace jit { diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc index 68a3647974..51a63ddf8a 100644 --- a/runtime/jit/jit_code_cache.cc +++ b/runtime/jit/jit_code_cache.cc @@ -22,6 +22,7 @@ #include "art_method-inl.h" #include "base/enums.h" #include "base/logging.h" // For VLOG. +#include "base/quasi_atomic.h" #include "base/stl_util.h" #include "base/systrace.h" #include "base/time_utils.h" diff --git a/runtime/jit/jit_code_cache.h b/runtime/jit/jit_code_cache.h index 0d1311fe34..16335c6911 100644 --- a/runtime/jit/jit_code_cache.h +++ b/runtime/jit/jit_code_cache.h @@ -19,8 +19,8 @@ #include "instrumentation.h" -#include "atomic.h" #include "base/arena_containers.h" +#include "base/atomic.h" #include "base/histogram-inl.h" #include "base/macros.h" #include "base/mutex.h" diff --git a/runtime/jit/profile_compilation_info.cc b/runtime/jit/profile_compilation_info.cc index 7be29c9414..1bbce4f414 100644 --- a/runtime/jit/profile_compilation_info.cc +++ b/runtime/jit/profile_compilation_info.cc @@ -37,16 +37,16 @@ #include "base/file_utils.h" #include "base/logging.h" // For VLOG. #include "base/mutex.h" +#include "base/os.h" #include "base/safe_map.h" #include "base/scoped_flock.h" #include "base/stl_util.h" #include "base/systrace.h" #include "base/time_utils.h" #include "base/unix_file/fd_file.h" +#include "base/utils.h" #include "dex/dex_file_loader.h" #include "jit/profiling_info.h" -#include "os.h" -#include "utils.h" #include "zip_archive.h" namespace art { @@ -278,7 +278,7 @@ bool ProfileCompilationInfo::Save(const std::string& filename, uint64_t* bytes_w // access and fail immediately if we can't. bool result = Save(fd); if (result) { - int64_t size = GetFileSizeBytes(filename); + int64_t size = OS::GetFileSizeBytes(filename.c_str()); if (size != -1) { VLOG(profiler) << "Successfully saved profile info to " << filename << " Size: " diff --git a/runtime/jit/profile_compilation_info.h b/runtime/jit/profile_compilation_info.h index 7e09b6b833..a0f6bf8dd6 100644 --- a/runtime/jit/profile_compilation_info.h +++ b/runtime/jit/profile_compilation_info.h @@ -20,9 +20,9 @@ #include <set> #include <vector> -#include "atomic.h" #include "base/arena_containers.h" #include "base/arena_object.h" +#include "base/atomic.h" #include "base/safe_map.h" #include "bit_memory_region.h" #include "dex/dex_cache_resolved_classes.h" diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc index 4c73d872f2..b78fcacc08 100644 --- a/runtime/jni_internal.cc +++ b/runtime/jni_internal.cc @@ -25,8 +25,8 @@ #include "art_field-inl.h" #include "art_method-inl.h" -#include "atomic.h" #include "base/allocator.h" +#include "base/atomic.h" #include "base/enums.h" #include "base/logging.h" // For VLOG. #include "base/mutex.h" diff --git a/runtime/mem_map.cc b/runtime/mem_map.cc index 26acef06d6..b9d51c1125 100644 --- a/runtime/mem_map.cc +++ b/runtime/mem_map.cc @@ -35,10 +35,10 @@ #include "base/allocator.h" #include "base/bit_utils.h" #include "base/file_utils.h" +#include "base/globals.h" #include "base/logging.h" // For VLOG_IS_ON. #include "base/memory_tool.h" -#include "globals.h" -#include "utils.h" +#include "base/utils.h" #ifndef MAP_ANONYMOUS #define MAP_ANONYMOUS MAP_ANON diff --git a/runtime/mirror/array.cc b/runtime/mirror/array.cc index 25283bc310..ea202e766f 100644 --- a/runtime/mirror/array.cc +++ b/runtime/mirror/array.cc @@ -16,6 +16,7 @@ #include "array-inl.h" +#include "base/utils.h" #include "class-inl.h" #include "class.h" #include "class_linker-inl.h" @@ -26,7 +27,6 @@ #include "object-inl.h" #include "object_array-inl.h" #include "thread.h" -#include "utils.h" namespace art { namespace mirror { diff --git a/runtime/mirror/call_site.h b/runtime/mirror/call_site.h index db244a5442..93f274808c 100644 --- a/runtime/mirror/call_site.h +++ b/runtime/mirror/call_site.h @@ -17,8 +17,8 @@ #ifndef ART_RUNTIME_MIRROR_CALL_SITE_H_ #define ART_RUNTIME_MIRROR_CALL_SITE_H_ +#include "base/utils.h" #include "mirror/method_handle_impl.h" -#include "utils.h" namespace art { diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h index 86d538ec80..ee7d217e8d 100644 --- a/runtime/mirror/class-inl.h +++ b/runtime/mirror/class-inl.h @@ -23,6 +23,7 @@ #include "art_method.h" #include "base/array_slice.h" #include "base/length_prefixed_array.h" +#include "base/utils.h" #include "class_linker.h" #include "class_loader.h" #include "common_throws.h" @@ -39,7 +40,6 @@ #include "reference-inl.h" #include "runtime.h" #include "string.h" -#include "utils.h" namespace art { namespace mirror { diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc index 7a09391056..3f4e841f86 100644 --- a/runtime/mirror/class.cc +++ b/runtime/mirror/class.cc @@ -21,6 +21,7 @@ #include "art_field-inl.h" #include "art_method-inl.h" #include "base/logging.h" // For VLOG. +#include "base/utils.h" #include "class-inl.h" #include "class_ext.h" #include "class_linker-inl.h" @@ -40,7 +41,6 @@ #include "runtime.h" #include "thread.h" #include "throwable.h" -#include "utils.h" #include "well_known_classes.h" namespace art { diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h index 6000317c85..ea065676a0 100644 --- a/runtime/mirror/class.h +++ b/runtime/mirror/class.h @@ -21,6 +21,8 @@ #include "base/casts.h" #include "base/enums.h" #include "base/iteration_range.h" +#include "base/stride_iterator.h" +#include "base/utils.h" #include "class_flags.h" #include "class_status.h" #include "dex/dex_file.h" @@ -33,9 +35,7 @@ #include "object.h" #include "object_array.h" #include "read_barrier_option.h" -#include "stride_iterator.h" #include "thread.h" -#include "utils.h" namespace art { diff --git a/runtime/mirror/class_ext.cc b/runtime/mirror/class_ext.cc index c18b219f19..081957964c 100644 --- a/runtime/mirror/class_ext.cc +++ b/runtime/mirror/class_ext.cc @@ -19,13 +19,13 @@ #include "art_method-inl.h" #include "base/casts.h" #include "base/enums.h" +#include "base/utils.h" #include "class-inl.h" #include "dex/dex_file-inl.h" #include "gc/accounting/card_table-inl.h" #include "object-inl.h" #include "object_array.h" #include "stack_trace_element.h" -#include "utils.h" #include "well_known_classes.h" namespace art { diff --git a/runtime/mirror/emulated_stack_frame.h b/runtime/mirror/emulated_stack_frame.h index 9bfa4d6098..23626f46e0 100644 --- a/runtime/mirror/emulated_stack_frame.h +++ b/runtime/mirror/emulated_stack_frame.h @@ -17,12 +17,12 @@ #ifndef ART_RUNTIME_MIRROR_EMULATED_STACK_FRAME_H_ #define ART_RUNTIME_MIRROR_EMULATED_STACK_FRAME_H_ +#include "base/utils.h" #include "dex/dex_instruction.h" #include "method_type.h" #include "object.h" #include "stack.h" #include "string.h" -#include "utils.h" namespace art { diff --git a/runtime/mirror/method_handles_lookup.h b/runtime/mirror/method_handles_lookup.h index dd8d45e66f..fefcb2ed29 100644 --- a/runtime/mirror/method_handles_lookup.h +++ b/runtime/mirror/method_handles_lookup.h @@ -17,11 +17,11 @@ #ifndef ART_RUNTIME_MIRROR_METHOD_HANDLES_LOOKUP_H_ #define ART_RUNTIME_MIRROR_METHOD_HANDLES_LOOKUP_H_ +#include "base/utils.h" #include "gc_root.h" #include "handle.h" #include "obj_ptr.h" #include "object.h" -#include "utils.h" namespace art { diff --git a/runtime/mirror/method_type.h b/runtime/mirror/method_type.h index edd991092a..3627214d90 100644 --- a/runtime/mirror/method_type.h +++ b/runtime/mirror/method_type.h @@ -17,10 +17,10 @@ #ifndef ART_RUNTIME_MIRROR_METHOD_TYPE_H_ #define ART_RUNTIME_MIRROR_METHOD_TYPE_H_ +#include "base/utils.h" #include "object_array.h" #include "object.h" #include "string.h" -#include "utils.h" namespace art { diff --git a/runtime/mirror/object-inl.h b/runtime/mirror/object-inl.h index 7fdaa32751..55dd51427c 100644 --- a/runtime/mirror/object-inl.h +++ b/runtime/mirror/object-inl.h @@ -22,7 +22,7 @@ #include "array-inl.h" #include "art_field.h" #include "art_method.h" -#include "atomic.h" +#include "base/atomic.h" #include "class-inl.h" #include "class_flags.h" #include "class_linker.h" diff --git a/runtime/mirror/object-readbarrier-inl.h b/runtime/mirror/object-readbarrier-inl.h index 126cb04cf1..aeaa850abe 100644 --- a/runtime/mirror/object-readbarrier-inl.h +++ b/runtime/mirror/object-readbarrier-inl.h @@ -19,7 +19,7 @@ #include "object.h" -#include "atomic.h" +#include "base/atomic.h" #include "heap_poisoning.h" #include "lock_word-inl.h" #include "object_reference-inl.h" diff --git a/runtime/mirror/object.h b/runtime/mirror/object.h index 816ac69b29..95f82cb147 100644 --- a/runtime/mirror/object.h +++ b/runtime/mirror/object.h @@ -17,7 +17,7 @@ #ifndef ART_RUNTIME_MIRROR_OBJECT_H_ #define ART_RUNTIME_MIRROR_OBJECT_H_ -#include "atomic.h" +#include "base/atomic.h" #include "base/casts.h" #include "base/enums.h" #include "globals.h" diff --git a/runtime/mirror/object_array-inl.h b/runtime/mirror/object_array-inl.h index 5cfc987e44..086d2f4672 100644 --- a/runtime/mirror/object_array-inl.h +++ b/runtime/mirror/object_array-inl.h @@ -24,6 +24,7 @@ #include "android-base/stringprintf.h" #include "array-inl.h" +#include "base/utils.h" #include "class.h" #include "gc/heap.h" #include "handle_scope-inl.h" @@ -31,7 +32,6 @@ #include "object-inl.h" #include "runtime.h" #include "thread.h" -#include "utils.h" namespace art { namespace mirror { diff --git a/runtime/mirror/object_reference.h b/runtime/mirror/object_reference.h index 7fd9c71b24..cf1f85d236 100644 --- a/runtime/mirror/object_reference.h +++ b/runtime/mirror/object_reference.h @@ -17,7 +17,7 @@ #ifndef ART_RUNTIME_MIRROR_OBJECT_REFERENCE_H_ #define ART_RUNTIME_MIRROR_OBJECT_REFERENCE_H_ -#include "atomic.h" +#include "base/atomic.h" #include "base/mutex.h" // For Locks::mutator_lock_. #include "globals.h" #include "heap_poisoning.h" diff --git a/runtime/mirror/object_test.cc b/runtime/mirror/object_test.cc index 32a99eb753..5306eac7f6 100644 --- a/runtime/mirror/object_test.cc +++ b/runtime/mirror/object_test.cc @@ -787,5 +787,23 @@ TEST_F(ObjectTest, ObjectPointer) { } } +TEST_F(ObjectTest, PrettyTypeOf) { + ScopedObjectAccess soa(Thread::Current()); + EXPECT_EQ("null", mirror::Object::PrettyTypeOf(nullptr)); + + StackHandleScope<2> hs(soa.Self()); + Handle<mirror::String> s(hs.NewHandle(mirror::String::AllocFromModifiedUtf8(soa.Self(), ""))); + EXPECT_EQ("java.lang.String", mirror::Object::PrettyTypeOf(s.Get())); + + Handle<mirror::ShortArray> a(hs.NewHandle(mirror::ShortArray::Alloc(soa.Self(), 2))); + EXPECT_EQ("short[]", mirror::Object::PrettyTypeOf(a.Get())); + + mirror::Class* c = class_linker_->FindSystemClass(soa.Self(), "[Ljava/lang/String;"); + ASSERT_TRUE(c != nullptr); + mirror::Object* o = mirror::ObjectArray<mirror::String>::Alloc(soa.Self(), c, 0); + EXPECT_EQ("java.lang.String[]", mirror::Object::PrettyTypeOf(o)); + EXPECT_EQ("java.lang.Class<java.lang.String[]>", mirror::Object::PrettyTypeOf(o->GetClass())); +} + } // namespace mirror } // namespace art diff --git a/runtime/mirror/string-inl.h b/runtime/mirror/string-inl.h index 8c2a49c5f6..a60861cc28 100644 --- a/runtime/mirror/string-inl.h +++ b/runtime/mirror/string-inl.h @@ -22,14 +22,14 @@ #include "array.h" #include "base/bit_utils.h" +#include "base/globals.h" +#include "base/utils.h" #include "class.h" #include "common_throws.h" #include "dex/utf.h" #include "gc/heap-inl.h" -#include "globals.h" #include "runtime.h" #include "thread.h" -#include "utils.h" namespace art { namespace mirror { diff --git a/runtime/mirror/throwable.cc b/runtime/mirror/throwable.cc index a7a6d087e1..b6173d422b 100644 --- a/runtime/mirror/throwable.cc +++ b/runtime/mirror/throwable.cc @@ -20,6 +20,7 @@ #include "art_method-inl.h" #include "base/enums.h" +#include "base/utils.h" #include "class-inl.h" #include "dex/dex_file-inl.h" #include "gc/accounting/card_table-inl.h" @@ -28,7 +29,6 @@ #include "object_array.h" #include "stack_trace_element.h" #include "string.h" -#include "utils.h" #include "well_known_classes.h" namespace art { diff --git a/runtime/monitor.cc b/runtime/monitor.cc index 0c9c65a401..2a938da15b 100644 --- a/runtime/monitor.cc +++ b/runtime/monitor.cc @@ -23,6 +23,7 @@ #include "art_method-inl.h" #include "base/logging.h" // For VLOG. #include "base/mutex.h" +#include "base/quasi_atomic.h" #include "base/stl_util.h" #include "base/systrace.h" #include "base/time_utils.h" diff --git a/runtime/monitor.h b/runtime/monitor.h index f150a8c091..384ebbedaa 100644 --- a/runtime/monitor.h +++ b/runtime/monitor.h @@ -25,8 +25,8 @@ #include <list> #include <vector> -#include "atomic.h" #include "base/allocator.h" +#include "base/atomic.h" #include "base/mutex.h" #include "gc_root.h" #include "lock_word.h" diff --git a/runtime/monitor_pool.h b/runtime/monitor_pool.h index 80bae7ff69..c6b0b0b86e 100644 --- a/runtime/monitor_pool.h +++ b/runtime/monitor_pool.h @@ -22,7 +22,7 @@ #include "base/allocator.h" #ifdef __LP64__ #include <stdint.h> -#include "atomic.h" +#include "base/atomic.h" #include "runtime.h" #else #include "base/stl_util.h" // STLDeleteElements diff --git a/runtime/monitor_test.cc b/runtime/monitor_test.cc index 7d89652ddf..bff8d7678c 100644 --- a/runtime/monitor_test.cc +++ b/runtime/monitor_test.cc @@ -18,7 +18,7 @@ #include <string> -#include "atomic.h" +#include "base/atomic.h" #include "barrier.h" #include "base/time_utils.h" #include "class_linker-inl.h" diff --git a/runtime/native/dalvik_system_DexFile.cc b/runtime/native/dalvik_system_DexFile.cc index 5d18b6e757..13319c4c57 100644 --- a/runtime/native/dalvik_system_DexFile.cc +++ b/runtime/native/dalvik_system_DexFile.cc @@ -22,7 +22,9 @@ #include "base/file_utils.h" #include "base/logging.h" +#include "base/os.h" #include "base/stl_util.h" +#include "base/utils.h" #include "class_linker.h" #include <class_loader_context.h> #include "common_throws.h" @@ -43,10 +45,8 @@ #include "oat_file.h" #include "oat_file_assistant.h" #include "oat_file_manager.h" -#include "os.h" #include "runtime.h" #include "scoped_thread_state_change-inl.h" -#include "utils.h" #include "well_known_classes.h" #include "zip_archive.h" diff --git a/runtime/native/java_lang_reflect_Field.cc b/runtime/native/java_lang_reflect_Field.cc index 688ae1977e..13275d92e4 100644 --- a/runtime/native/java_lang_reflect_Field.cc +++ b/runtime/native/java_lang_reflect_Field.cc @@ -20,6 +20,7 @@ #include "nativehelper/jni_macros.h" #include "art_field-inl.h" +#include "base/utils.h" #include "class_linker-inl.h" #include "class_linker.h" #include "common_throws.h" @@ -31,7 +32,6 @@ #include "native_util.h" #include "reflection-inl.h" #include "scoped_fast_native_object_access-inl.h" -#include "utils.h" #include "well_known_classes.h" namespace art { diff --git a/runtime/native/java_lang_reflect_Parameter.cc b/runtime/native/java_lang_reflect_Parameter.cc index 1ab91098d7..b80b20cd8d 100644 --- a/runtime/native/java_lang_reflect_Parameter.cc +++ b/runtime/native/java_lang_reflect_Parameter.cc @@ -20,13 +20,13 @@ #include "nativehelper/jni_macros.h" #include "art_method-inl.h" +#include "base/utils.h" #include "common_throws.h" #include "dex/dex_file-inl.h" #include "dex/dex_file_annotations.h" #include "jni_internal.h" #include "native_util.h" #include "scoped_fast_native_object_access-inl.h" -#include "utils.h" namespace art { diff --git a/runtime/native/java_util_concurrent_atomic_AtomicLong.cc b/runtime/native/java_util_concurrent_atomic_AtomicLong.cc index bd4b0fec70..c0032975ce 100644 --- a/runtime/native/java_util_concurrent_atomic_AtomicLong.cc +++ b/runtime/native/java_util_concurrent_atomic_AtomicLong.cc @@ -19,7 +19,8 @@ #include "nativehelper/jni_macros.h" #include "arch/instruction_set.h" -#include "atomic.h" +#include "base/atomic.h" +#include "base/quasi_atomic.h" #include "jni_internal.h" #include "native_util.h" diff --git a/runtime/native/sun_misc_Unsafe.cc b/runtime/native/sun_misc_Unsafe.cc index 1af65a371b..25f984f6be 100644 --- a/runtime/native/sun_misc_Unsafe.cc +++ b/runtime/native/sun_misc_Unsafe.cc @@ -24,6 +24,7 @@ #include "nativehelper/jni_macros.h" +#include "base/quasi_atomic.h" #include "common_throws.h" #include "gc/accounting/card_table-inl.h" #include "jni_internal.h" diff --git a/runtime/native_stack_dump.cc b/runtime/native_stack_dump.cc index 4d4bab764c..396b09abcf 100644 --- a/runtime/native_stack_dump.cc +++ b/runtime/native_stack_dump.cc @@ -44,11 +44,11 @@ #include "base/file_utils.h" #include "base/memory_tool.h" #include "base/mutex.h" +#include "base/os.h" #include "base/unix_file/fd_file.h" +#include "base/utils.h" #include "oat_quick_method_header.h" -#include "os.h" #include "thread-current-inl.h" -#include "utils.h" #endif diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc index 3576683fee..b0e1de2b81 100644 --- a/runtime/oat_file.cc +++ b/runtime/oat_file.cc @@ -40,9 +40,11 @@ #include "base/enums.h" #include "base/file_utils.h" #include "base/logging.h" // For VLOG_IS_ON. +#include "base/os.h" #include "base/stl_util.h" #include "base/systrace.h" #include "base/unix_file/fd_file.h" +#include "base/utils.h" #include "dex/art_dex_file_loader.h" #include "dex/dex_file_loader.h" #include "dex/dex_file_types.h" @@ -58,10 +60,8 @@ #include "oat.h" #include "oat_file-inl.h" #include "oat_file_manager.h" -#include "os.h" #include "runtime.h" #include "type_lookup_table.h" -#include "utils.h" #include "vdex_file.h" namespace art { @@ -1812,9 +1812,9 @@ void OatDexFile::MadviseDexFile(const DexFile& dex_file, MadviseState state) { // Default every dex file to MADV_RANDOM when its loaded by default for low ram devices. // Other devices have enough page cache to get performance benefits from loading more pages // into the page cache. - MadviseLargestPageAlignedRegion(dex_file.Begin(), - dex_file.Begin() + dex_file.Size(), - MADV_RANDOM); + DexLayoutSection::MadviseLargestPageAlignedRegion(dex_file.Begin(), + dex_file.Begin() + dex_file.Size(), + MADV_RANDOM); } const OatFile::OatDexFile* oat_dex_file = dex_file.GetOatDexFile(); if (oat_dex_file != nullptr) { diff --git a/runtime/oat_file.h b/runtime/oat_file.h index 255a31bba9..3c2cd00c8d 100644 --- a/runtime/oat_file.h +++ b/runtime/oat_file.h @@ -23,9 +23,11 @@ #include "base/array_ref.h" #include "base/mutex.h" +#include "base/os.h" #include "base/safe_map.h" #include "base/stringpiece.h" #include "base/tracking_safe_map.h" +#include "base/utils.h" #include "class_status.h" #include "compiler_filter.h" #include "dex/dex_file.h" @@ -34,9 +36,7 @@ #include "index_bss_mapping.h" #include "mirror/object.h" #include "oat.h" -#include "os.h" #include "type_lookup_table.h" -#include "utils.h" namespace art { diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc index 6bf05b77a8..6f079ca8c4 100644 --- a/runtime/oat_file_assistant.cc +++ b/runtime/oat_file_assistant.cc @@ -25,7 +25,9 @@ #include "base/file_utils.h" #include "base/logging.h" // For VLOG. +#include "base/os.h" #include "base/stl_util.h" +#include "base/utils.h" #include "class_linker.h" #include "compiler_filter.h" #include "dex/art_dex_file_loader.h" @@ -35,10 +37,8 @@ #include "gc/space/image_space.h" #include "image.h" #include "oat.h" -#include "os.h" #include "runtime.h" #include "scoped_thread_state_change-inl.h" -#include "utils.h" #include "vdex_file.h" #include "class_loader_context.h" diff --git a/runtime/oat_file_assistant.h b/runtime/oat_file_assistant.h index 6da49a9c29..8d6ec0014a 100644 --- a/runtime/oat_file_assistant.h +++ b/runtime/oat_file_assistant.h @@ -23,12 +23,12 @@ #include <string> #include "arch/instruction_set.h" +#include "base/os.h" #include "base/scoped_flock.h" #include "base/unix_file/fd_file.h" #include "compiler_filter.h" #include "class_loader_context.h" #include "oat_file.h" -#include "os.h" namespace art { diff --git a/runtime/oat_file_assistant_test.cc b/runtime/oat_file_assistant_test.cc index 72f7d02892..676071b247 100644 --- a/runtime/oat_file_assistant_test.cc +++ b/runtime/oat_file_assistant_test.cc @@ -27,16 +27,16 @@ #include "android-base/strings.h" #include "art_field-inl.h" +#include "base/os.h" +#include "base/utils.h" #include "class_linker-inl.h" #include "class_loader_context.h" #include "common_runtime_test.h" #include "dexopt_test.h" #include "oat_file.h" #include "oat_file_manager.h" -#include "os.h" #include "scoped_thread_state_change-inl.h" #include "thread-current-inl.h" -#include "utils.h" namespace art { diff --git a/runtime/oat_quick_method_header.h b/runtime/oat_quick_method_header.h index 4443255f64..f0966b7bfa 100644 --- a/runtime/oat_quick_method_header.h +++ b/runtime/oat_quick_method_header.h @@ -19,10 +19,10 @@ #include "arch/instruction_set.h" #include "base/macros.h" +#include "base/utils.h" #include "method_info.h" #include "quick/quick_method_frame_info.h" #include "stack_map.h" -#include "utils.h" namespace art { diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc index c61ecc880b..5518eb2c49 100644 --- a/runtime/parsed_options.cc +++ b/runtime/parsed_options.cc @@ -23,13 +23,13 @@ #include "base/file_utils.h" #include "base/macros.h" #include "base/stringpiece.h" +#include "base/utils.h" #include "debugger.h" #include "gc/heap.h" #include "monitor.h" #include "runtime.h" #include "ti/agent.h" #include "trace.h" -#include "utils.h" #include "cmdline_parser.h" #include "runtime_options.h" diff --git a/runtime/read_barrier-inl.h b/runtime/read_barrier-inl.h index a77d100b92..58f6c04c3e 100644 --- a/runtime/read_barrier-inl.h +++ b/runtime/read_barrier-inl.h @@ -19,6 +19,7 @@ #include "read_barrier.h" +#include "base/utils.h" #include "gc/accounting/read_barrier_table.h" #include "gc/collector/concurrent_copying-inl.h" #include "gc/heap.h" @@ -26,7 +27,6 @@ #include "mirror/object_reference.h" #include "mirror/reference.h" #include "runtime.h" -#include "utils.h" namespace art { diff --git a/runtime/reference_table.cc b/runtime/reference_table.cc index a6df27b236..d62cbdb11a 100644 --- a/runtime/reference_table.cc +++ b/runtime/reference_table.cc @@ -19,6 +19,7 @@ #include "android-base/stringprintf.h" #include "base/mutex.h" +#include "base/utils.h" #include "gc/allocation_record.h" #include "gc/heap.h" #include "indirect_reference_table.h" @@ -30,7 +31,6 @@ #include "mirror/string-inl.h" #include "runtime-inl.h" #include "thread.h" -#include "utils.h" namespace art { diff --git a/runtime/reflection-inl.h b/runtime/reflection-inl.h index 87432ab77b..26fb021903 100644 --- a/runtime/reflection-inl.h +++ b/runtime/reflection-inl.h @@ -21,13 +21,13 @@ #include "android-base/stringprintf.h" +#include "base/utils.h" #include "common_throws.h" #include "dex/descriptors_names.h" #include "dex/primitive.h" #include "jvalue-inl.h" #include "mirror/object-inl.h" #include "obj_ptr-inl.h" -#include "utils.h" namespace art { diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 4442fc6a54..8672482a8f 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -56,16 +56,20 @@ #include "art_method-inl.h" #include "asm_support.h" #include "asm_support_check.h" -#include "atomic.h" #include "base/aborting.h" #include "base/arena_allocator.h" +#include "base/atomic.h" #include "base/dumpable.h" #include "base/enums.h" #include "base/file_utils.h" #include "base/memory_tool.h" +#include "base/mutex.h" +#include "base/os.h" +#include "base/quasi_atomic.h" #include "base/stl_util.h" #include "base/systrace.h" #include "base/unix_file/fd_file.h" +#include "base/utils.h" #include "class_linker-inl.h" #include "compiler_callbacks.h" #include "debugger.h" @@ -141,7 +145,6 @@ #include "oat_file.h" #include "oat_file_manager.h" #include "object_callbacks.h" -#include "os.h" #include "parsed_options.h" #include "quick/quick_method_frame_info.h" #include "reflection.h" @@ -157,7 +160,6 @@ #include "ti/agent.h" #include "trace.h" #include "transaction.h" -#include "utils.h" #include "vdex_file.h" #include "verifier/method_verifier.h" #include "well_known_classes.h" @@ -621,6 +623,7 @@ void Runtime::SweepSystemWeaks(IsMarkedVisitor* visitor) { bool Runtime::ParseOptions(const RuntimeOptions& raw_options, bool ignore_unrecognized, RuntimeArgumentMap* runtime_options) { + Locks::Init(); InitLogging(/* argv */ nullptr, Abort); // Calls Locks::Init() as a side effect. bool parsed = ParsedOptions::Parse(raw_options, ignore_unrecognized, runtime_options); if (!parsed) { @@ -2215,7 +2218,7 @@ void Runtime::RegisterAppInfo(const std::vector<std::string>& code_paths, LOG(WARNING) << "JIT profile information will not be recorded: profile filename is empty."; return; } - if (!FileExists(profile_output_filename)) { + if (!OS::FileExists(profile_output_filename.c_str(), false /*check_file_type*/)) { LOG(WARNING) << "JIT profile information will not be recorded: profile file does not exits."; return; } diff --git a/runtime/runtime_common.h b/runtime/runtime_common.h index 06d66270af..3fba441b55 100644 --- a/runtime/runtime_common.h +++ b/runtime/runtime_common.h @@ -31,8 +31,8 @@ #include <iomanip> #include "base/dumpable.h" +#include "base/utils.h" #include "native_stack_dump.h" -#include "utils.h" namespace art { diff --git a/runtime/runtime_options.cc b/runtime/runtime_options.cc index bce0d81cfb..f8c680db44 100644 --- a/runtime/runtime_options.cc +++ b/runtime/runtime_options.cc @@ -18,13 +18,13 @@ #include <memory> +#include "base/utils.h" #include "debugger.h" #include "gc/heap.h" #include "monitor.h" #include "runtime.h" #include "thread_list.h" #include "trace.h" -#include "utils.h" namespace art { diff --git a/runtime/signal_catcher.cc b/runtime/signal_catcher.cc index 9c3afbb133..d590ad5cc6 100644 --- a/runtime/signal_catcher.cc +++ b/runtime/signal_catcher.cc @@ -36,18 +36,18 @@ #include "arch/instruction_set.h" #include "base/file_utils.h" #include "base/logging.h" // For GetCmdLine. +#include "base/os.h" #include "base/time_utils.h" #include "base/unix_file/fd_file.h" +#include "base/utils.h" #include "class_linker.h" #include "gc/heap.h" #include "jit/profile_saver.h" -#include "os.h" #include "runtime.h" #include "scoped_thread_state_change-inl.h" #include "signal_set.h" #include "thread.h" #include "thread_list.h" -#include "utils.h" namespace art { diff --git a/runtime/thread.cc b/runtime/thread.cc index 4cdf015478..5b03c2d884 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -45,6 +45,7 @@ #include "base/systrace.h" #include "base/timing_logger.h" #include "base/to_str.h" +#include "base/utils.h" #include "class_linker-inl.h" #include "debugger.h" #include "dex/descriptors_names.h" @@ -90,7 +91,6 @@ #include "stack_map.h" #include "thread-inl.h" #include "thread_list.h" -#include "utils.h" #include "verifier/method_verifier.h" #include "verify_object.h" #include "well_known_classes.h" diff --git a/runtime/thread.h b/runtime/thread.h index 295685e799..6549fc1a1f 100644 --- a/runtime/thread.h +++ b/runtime/thread.h @@ -28,7 +28,7 @@ #include "arch/context.h" #include "arch/instruction_set.h" -#include "atomic.h" +#include "base/atomic.h" #include "base/enums.h" #include "base/macros.h" #include "base/mutex.h" diff --git a/runtime/thread_linux.cc b/runtime/thread_linux.cc index 9673eee795..d05fecf0a9 100644 --- a/runtime/thread_linux.cc +++ b/runtime/thread_linux.cc @@ -19,7 +19,7 @@ #include <signal.h> #include "base/logging.h" // For VLOG. -#include "utils.h" +#include "base/utils.h" namespace art { diff --git a/runtime/thread_pool.cc b/runtime/thread_pool.cc index 386cdf006a..bec1150807 100644 --- a/runtime/thread_pool.cc +++ b/runtime/thread_pool.cc @@ -29,9 +29,9 @@ #include "base/casts.h" #include "base/stl_util.h" #include "base/time_utils.h" +#include "base/utils.h" #include "runtime.h" #include "thread-current-inl.h" -#include "utils.h" namespace art { diff --git a/runtime/thread_pool_test.cc b/runtime/thread_pool_test.cc index 28aa21f7a2..895a108af0 100644 --- a/runtime/thread_pool_test.cc +++ b/runtime/thread_pool_test.cc @@ -18,7 +18,7 @@ #include <string> -#include "atomic.h" +#include "base/atomic.h" #include "common_runtime_test.h" #include "scoped_thread_state_change-inl.h" #include "thread-inl.h" diff --git a/runtime/trace.cc b/runtime/trace.cc index d97dcb5a3d..0f321b6591 100644 --- a/runtime/trace.cc +++ b/runtime/trace.cc @@ -24,10 +24,12 @@ #include "art_method-inl.h" #include "base/casts.h" #include "base/enums.h" +#include "base/os.h" #include "base/stl_util.h" #include "base/systrace.h" #include "base/time_utils.h" #include "base/unix_file/fd_file.h" +#include "base/utils.h" #include "class_linker.h" #include "common_throws.h" #include "debugger.h" @@ -41,12 +43,10 @@ #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "nativehelper/scoped_local_ref.h" -#include "os.h" #include "scoped_thread_state_change-inl.h" #include "stack.h" #include "thread.h" #include "thread_list.h" -#include "utils.h" namespace art { diff --git a/runtime/trace.h b/runtime/trace.h index 7ce12dace0..86b8d00d51 100644 --- a/runtime/trace.h +++ b/runtime/trace.h @@ -26,12 +26,12 @@ #include <unordered_map> #include <vector> -#include "atomic.h" +#include "base/atomic.h" #include "base/macros.h" +#include "base/os.h" #include "base/safe_map.h" #include "globals.h" #include "instrumentation.h" -#include "os.h" namespace art { diff --git a/runtime/type_lookup_table.cc b/runtime/type_lookup_table.cc index 925a9089cb..7e204fc03a 100644 --- a/runtime/type_lookup_table.cc +++ b/runtime/type_lookup_table.cc @@ -20,9 +20,9 @@ #include <memory> #include "base/bit_utils.h" +#include "base/utils.h" #include "dex/dex_file-inl.h" #include "dex/utf-inl.h" -#include "utils.h" namespace art { diff --git a/runtime/utils_test.cc b/runtime/utils_test.cc deleted file mode 100644 index e67e93f9c5..0000000000 --- a/runtime/utils_test.cc +++ /dev/null @@ -1,221 +0,0 @@ -/* - * 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. - */ - -#include "utils.h" - -#include <libgen.h> -#include <stdlib.h> - -#include "base/enums.h" -#include "base/file_utils.h" -#include "base/stl_util.h" -#include "class_linker-inl.h" -#include "common_runtime_test.h" -#include "exec_utils.h" -#include "handle_scope-inl.h" -#include "mirror/array-inl.h" -#include "mirror/array.h" -#include "mirror/object-inl.h" -#include "mirror/object_array-inl.h" -#include "mirror/string.h" -#include "scoped_thread_state_change-inl.h" - -#include "base/memory_tool.h" - -namespace art { - -class UtilsTest : public CommonRuntimeTest {}; - -TEST_F(UtilsTest, PrettyTypeOf) { - ScopedObjectAccess soa(Thread::Current()); - EXPECT_EQ("null", mirror::Object::PrettyTypeOf(nullptr)); - - StackHandleScope<2> hs(soa.Self()); - Handle<mirror::String> s(hs.NewHandle(mirror::String::AllocFromModifiedUtf8(soa.Self(), ""))); - EXPECT_EQ("java.lang.String", mirror::Object::PrettyTypeOf(s.Get())); - - Handle<mirror::ShortArray> a(hs.NewHandle(mirror::ShortArray::Alloc(soa.Self(), 2))); - EXPECT_EQ("short[]", mirror::Object::PrettyTypeOf(a.Get())); - - mirror::Class* c = class_linker_->FindSystemClass(soa.Self(), "[Ljava/lang/String;"); - ASSERT_TRUE(c != nullptr); - mirror::Object* o = mirror::ObjectArray<mirror::String>::Alloc(soa.Self(), c, 0); - EXPECT_EQ("java.lang.String[]", mirror::Object::PrettyTypeOf(o)); - EXPECT_EQ("java.lang.Class<java.lang.String[]>", mirror::Object::PrettyTypeOf(o->GetClass())); -} - -TEST_F(UtilsTest, PrettyClass) { - ScopedObjectAccess soa(Thread::Current()); - EXPECT_EQ("null", mirror::Class::PrettyClass(nullptr)); - mirror::Class* c = class_linker_->FindSystemClass(soa.Self(), "[Ljava/lang/String;"); - ASSERT_TRUE(c != nullptr); - mirror::Object* o = mirror::ObjectArray<mirror::String>::Alloc(soa.Self(), c, 0); - EXPECT_EQ("java.lang.Class<java.lang.String[]>", mirror::Class::PrettyClass(o->GetClass())); -} - -TEST_F(UtilsTest, PrettyClassAndClassLoader) { - ScopedObjectAccess soa(Thread::Current()); - EXPECT_EQ("null", mirror::Class::PrettyClassAndClassLoader(nullptr)); - mirror::Class* c = class_linker_->FindSystemClass(soa.Self(), "[Ljava/lang/String;"); - ASSERT_TRUE(c != nullptr); - mirror::Object* o = mirror::ObjectArray<mirror::String>::Alloc(soa.Self(), c, 0); - EXPECT_EQ("java.lang.Class<java.lang.String[],null>", - mirror::Class::PrettyClassAndClassLoader(o->GetClass())); -} - -TEST_F(UtilsTest, PrettyField) { - ScopedObjectAccess soa(Thread::Current()); - EXPECT_EQ("null", ArtField::PrettyField(nullptr)); - - mirror::Class* java_lang_String = class_linker_->FindSystemClass(soa.Self(), - "Ljava/lang/String;"); - - ArtField* f; - f = java_lang_String->FindDeclaredInstanceField("count", "I"); - EXPECT_EQ("int java.lang.String.count", f->PrettyField()); - EXPECT_EQ("java.lang.String.count", f->PrettyField(false)); -} - -TEST_F(UtilsTest, PrettySize) { - EXPECT_EQ("1GB", PrettySize(1 * GB)); - EXPECT_EQ("2GB", PrettySize(2 * GB)); - if (sizeof(size_t) > sizeof(uint32_t)) { - EXPECT_EQ("100GB", PrettySize(100 * GB)); - } - EXPECT_EQ("1024KB", PrettySize(1 * MB)); - EXPECT_EQ("10MB", PrettySize(10 * MB)); - EXPECT_EQ("100MB", PrettySize(100 * MB)); - EXPECT_EQ("1024B", PrettySize(1 * KB)); - EXPECT_EQ("10KB", PrettySize(10 * KB)); - EXPECT_EQ("100KB", PrettySize(100 * KB)); - EXPECT_EQ("0B", PrettySize(0)); - EXPECT_EQ("1B", PrettySize(1)); - EXPECT_EQ("10B", PrettySize(10)); - EXPECT_EQ("100B", PrettySize(100)); - EXPECT_EQ("512B", PrettySize(512)); -} - -TEST_F(UtilsTest, JniShortName_JniLongName) { - ScopedObjectAccess soa(Thread::Current()); - mirror::Class* c = class_linker_->FindSystemClass(soa.Self(), "Ljava/lang/String;"); - ASSERT_TRUE(c != nullptr); - ArtMethod* m; - - m = c->FindClassMethod("charAt", "(I)C", kRuntimePointerSize); - ASSERT_TRUE(m != nullptr); - ASSERT_FALSE(m->IsDirect()); - EXPECT_EQ("Java_java_lang_String_charAt", m->JniShortName()); - EXPECT_EQ("Java_java_lang_String_charAt__I", m->JniLongName()); - - m = c->FindClassMethod("indexOf", "(Ljava/lang/String;I)I", kRuntimePointerSize); - ASSERT_TRUE(m != nullptr); - ASSERT_FALSE(m->IsDirect()); - EXPECT_EQ("Java_java_lang_String_indexOf", m->JniShortName()); - EXPECT_EQ("Java_java_lang_String_indexOf__Ljava_lang_String_2I", m->JniLongName()); - - m = c->FindClassMethod("copyValueOf", "([CII)Ljava/lang/String;", kRuntimePointerSize); - ASSERT_TRUE(m != nullptr); - ASSERT_TRUE(m->IsStatic()); - EXPECT_EQ("Java_java_lang_String_copyValueOf", m->JniShortName()); - EXPECT_EQ("Java_java_lang_String_copyValueOf___3CII", m->JniLongName()); -} - -TEST_F(UtilsTest, Split) { - std::vector<std::string> actual; - std::vector<std::string> expected; - - expected.clear(); - - actual.clear(); - Split("", ':', &actual); - EXPECT_EQ(expected, actual); - - actual.clear(); - Split(":", ':', &actual); - EXPECT_EQ(expected, actual); - - expected.clear(); - expected.push_back("foo"); - - actual.clear(); - Split(":foo", ':', &actual); - EXPECT_EQ(expected, actual); - - actual.clear(); - Split("foo:", ':', &actual); - EXPECT_EQ(expected, actual); - - actual.clear(); - Split(":foo:", ':', &actual); - EXPECT_EQ(expected, actual); - - expected.push_back("bar"); - - actual.clear(); - Split("foo:bar", ':', &actual); - EXPECT_EQ(expected, actual); - - actual.clear(); - Split(":foo:bar", ':', &actual); - EXPECT_EQ(expected, actual); - - actual.clear(); - Split("foo:bar:", ':', &actual); - EXPECT_EQ(expected, actual); - - actual.clear(); - Split(":foo:bar:", ':', &actual); - EXPECT_EQ(expected, actual); - - expected.push_back("baz"); - - actual.clear(); - Split("foo:bar:baz", ':', &actual); - EXPECT_EQ(expected, actual); - - actual.clear(); - Split(":foo:bar:baz", ':', &actual); - EXPECT_EQ(expected, actual); - - actual.clear(); - Split("foo:bar:baz:", ':', &actual); - EXPECT_EQ(expected, actual); - - actual.clear(); - Split(":foo:bar:baz:", ':', &actual); - EXPECT_EQ(expected, actual); -} - -TEST_F(UtilsTest, ArrayCount) { - int i[64]; - EXPECT_EQ(ArrayCount(i), 64u); - char c[7]; - EXPECT_EQ(ArrayCount(c), 7u); -} - -TEST_F(UtilsTest, BoundsCheckedCast) { - char buffer[64]; - const char* buffer_end = buffer + ArrayCount(buffer); - EXPECT_EQ(BoundsCheckedCast<const uint64_t*>(nullptr, buffer, buffer_end), nullptr); - EXPECT_EQ(BoundsCheckedCast<const uint64_t*>(buffer, buffer, buffer_end), - reinterpret_cast<const uint64_t*>(buffer)); - EXPECT_EQ(BoundsCheckedCast<const uint64_t*>(buffer + 56, buffer, buffer_end), - reinterpret_cast<const uint64_t*>(buffer + 56)); - EXPECT_EQ(BoundsCheckedCast<const uint64_t*>(buffer - 1, buffer, buffer_end), nullptr); - EXPECT_EQ(BoundsCheckedCast<const uint64_t*>(buffer + 57, buffer, buffer_end), nullptr); -} - -} // namespace art diff --git a/runtime/vdex_file.h b/runtime/vdex_file.h index d27f431cdc..72f03f266a 100644 --- a/runtime/vdex_file.h +++ b/runtime/vdex_file.h @@ -22,9 +22,9 @@ #include "base/array_ref.h" #include "base/macros.h" +#include "base/os.h" #include "dex/compact_offset_table.h" #include "mem_map.h" -#include "os.h" #include "quicken_info.h" namespace art { diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index 52bd7362ef..74c2244cfe 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -30,6 +30,7 @@ #include "base/stl_util.h" #include "base/systrace.h" #include "base/time_utils.h" +#include "base/utils.h" #include "class_linker.h" #include "compiler_callbacks.h" #include "dex/descriptors_names.h" @@ -55,7 +56,6 @@ #include "runtime.h" #include "scoped_thread_state_change-inl.h" #include "stack.h" -#include "utils.h" #include "verifier_compiler_binding.h" #include "verifier_deps.h" diff --git a/runtime/verifier/method_verifier_test.cc b/runtime/verifier/method_verifier_test.cc index 97c1b62abe..db3f093905 100644 --- a/runtime/verifier/method_verifier_test.cc +++ b/runtime/verifier/method_verifier_test.cc @@ -21,11 +21,11 @@ #include "android-base/strings.h" +#include "base/utils.h" #include "class_linker-inl.h" #include "common_runtime_test.h" #include "dex/dex_file-inl.h" #include "scoped_thread_state_change-inl.h" -#include "utils.h" #include "verifier_enums.h" namespace art { diff --git a/runtime/zip_archive.h b/runtime/zip_archive.h index 7b45690462..aa54018574 100644 --- a/runtime/zip_archive.h +++ b/runtime/zip_archive.h @@ -23,11 +23,11 @@ #include <android-base/logging.h> +#include "base/os.h" #include "base/safe_map.h" #include "base/unix_file/random_access_file.h" #include "globals.h" #include "mem_map.h" -#include "os.h" // system/core/zip_archive definitions. struct ZipEntry; diff --git a/runtime/zip_archive_test.cc b/runtime/zip_archive_test.cc index 4fc7ee2e20..48ee94ce8c 100644 --- a/runtime/zip_archive_test.cc +++ b/runtime/zip_archive_test.cc @@ -22,9 +22,9 @@ #include <zlib.h> #include <memory> +#include "base/os.h" #include "base/unix_file/fd_file.h" #include "common_runtime_test.h" -#include "os.h" namespace art { diff --git a/test/137-cfi/cfi.cc b/test/137-cfi/cfi.cc index 83234f0382..b91d983e75 100644 --- a/test/137-cfi/cfi.cc +++ b/test/137-cfi/cfi.cc @@ -31,11 +31,11 @@ #include "base/file_utils.h" #include "base/macros.h" +#include "base/utils.h" #include "gc/heap.h" #include "gc/space/image_space.h" #include "oat_file.h" #include "runtime.h" -#include "utils.h" namespace art { diff --git a/test/ti-stress/stress.cc b/test/ti-stress/stress.cc index d2da244397..bbe74656dd 100644 --- a/test/ti-stress/stress.cc +++ b/test/ti-stress/stress.cc @@ -24,9 +24,9 @@ #include <jni.h> +#include "base/utils.h" #include "exec_utils.h" #include "jvmti.h" -#include "utils.h" #pragma clang diagnostic push diff --git a/tools/hiddenapi/hiddenapi.cc b/tools/hiddenapi/hiddenapi.cc index d986cf82d6..d22998ae1b 100644 --- a/tools/hiddenapi/hiddenapi.cc +++ b/tools/hiddenapi/hiddenapi.cc @@ -21,12 +21,12 @@ #include "android-base/stringprintf.h" #include "android-base/strings.h" +#include "base/os.h" #include "base/unix_file/fd_file.h" #include "dex/art_dex_file_loader.h" #include "dex/dex_file-inl.h" #include "dex/hidden_api_access_flags.h" #include "mem_map.h" -#include "os.h" namespace art { |