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
diff --git a/cmdline/cmdline.h b/cmdline/cmdline.h
index 60dfdce..95ab123 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 @@
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 3cb9731..235a2aa 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 @@
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 e41043a..0ae1145 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 a203133..d3e3a51 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 7c7ae71..646040f 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 a17e2b5..f2ec3a9 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 5405759..9a7c604 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 1310e8d..7a8e291 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 48477ab..a26a985 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 a3bb4ec..8db892b 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 18b0913..05d8805 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 2e315b5..c90c37d 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 fc44927..d001cfe 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 28296a4..deb051f 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 ba4040a..a0fd5ff 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 71c394e..f05159b 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 acb830e..f8dc316 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 99d80d7..62550be 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 0023265..00194ff 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 1482210..778a015 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 cabd79e..fc24379 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 f4bca59..1650080 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 736a17e..788afd8 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 926575e..73afbad 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 @@
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 05592f1..49b84bb 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 @@
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 ccc85c8..cc124c1 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 6b75595..96dd319 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 7c47740..bcf2cd7 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 d2e863c..07b02f1 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 e20957c..274d18b 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 8427e7b..b2be003 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 c6ce951..319c5fb 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 856edfb..36bbb47 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 2feb14a..c72beea 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 d67e4de..0cb0ef2 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 559dc8e..63e0e3f 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 0e7d65f..eaf8518 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 df098c0..db1898b 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 c0d6f02..6cb141f 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 @@
}
// 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 9927576..068949c 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 159a4a5..ec0cbe6 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 b79a592..2bca10d 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 981f901..6719d08 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 ae44848..0b9adbd 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 6d4b3e3..febccf1 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 @@
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 8aa638a..ddb8fe1 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 80b0c26..52096f0 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 290d398..3c61944 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 @@
shared_libs: ["libbase"],
export_shared_lib_headers: ["libbase"],
}
-
diff --git a/runtime/base/aborting.h b/libartbase/base/aborting.h
similarity index 88%
rename from runtime/base/aborting.h
rename to libartbase/base/aborting.h
index 8906c96..c7089af 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 @@
} // 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
similarity index 98%
rename from runtime/base/allocator.cc
rename to libartbase/base/allocator.cc
index 2da88c3..a424145 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
similarity index 96%
rename from runtime/base/allocator.h
rename to libartbase/base/allocator.h
index 3cedb66..d92fe19 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 @@
} // 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
similarity index 97%
rename from runtime/base/array_ref.h
rename to libartbase/base/array_ref.h
index 2753c81..1d7bde6 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 @@
} // 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
similarity index 96%
rename from runtime/base/array_slice.h
rename to libartbase/base/array_slice.h
index a7bce7d..1ef2fba 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 @@
} // 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
similarity index 64%
rename from runtime/atomic.h
rename to libartbase/base/atomic.h
index 0e2f056..fd34cc6 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 @@
} // 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
similarity index 95%
rename from runtime/base/bit_field.h
rename to libartbase/base/bit_field.h
index 86007d6..9971735 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 @@
} // 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
similarity index 100%
rename from runtime/base/bit_field_test.cc
rename to libartbase/base/bit_field_test.cc
diff --git a/runtime/base/bit_string.h b/libartbase/base/bit_string.h
similarity index 98%
rename from runtime/base/bit_string.h
rename to libartbase/base/bit_string.h
index 7d9fb70..0e051f3 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 @@
} // 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
similarity index 100%
rename from runtime/base/bit_string_test.cc
rename to libartbase/base/bit_string_test.cc
diff --git a/runtime/base/bit_struct.h b/libartbase/base/bit_struct.h
similarity index 98%
rename from runtime/base/bit_struct.h
rename to libartbase/base/bit_struct.h
index 7eb63c6..386b896 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 @@
} // 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
similarity index 96%
rename from runtime/base/bit_struct_detail.h
rename to libartbase/base/bit_struct_detail.h
index 24f6c4c..facfa61 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 @@
} // 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
similarity index 100%
rename from runtime/base/bit_struct_test.cc
rename to libartbase/base/bit_struct_test.cc
diff --git a/runtime/base/bit_vector-inl.h b/libartbase/base/bit_vector-inl.h
similarity index 95%
rename from runtime/base/bit_vector-inl.h
rename to libartbase/base/bit_vector-inl.h
index e67d4e2..7a9f465 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 @@
} // 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
similarity index 100%
rename from runtime/base/bit_vector.cc
rename to libartbase/base/bit_vector.cc
diff --git a/runtime/base/bit_vector.h b/libartbase/base/bit_vector.h
similarity index 98%
rename from runtime/base/bit_vector.h
rename to libartbase/base/bit_vector.h
index 564092a..2ffa2aa 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 @@
} // 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
similarity index 100%
rename from runtime/base/bit_vector_test.cc
rename to libartbase/base/bit_vector_test.cc
diff --git a/runtime/base/bounded_fifo.h b/libartbase/base/bounded_fifo.h
similarity index 92%
rename from runtime/base/bounded_fifo.h
rename to libartbase/base/bounded_fifo.h
index 1520770..444f31a 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 @@
} // 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
similarity index 91%
rename from runtime/base/callee_save_type.h
rename to libartbase/base/callee_save_type.h
index e9cd63c..3e44a3a 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 @@
} // 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
similarity index 97%
rename from runtime/base/dchecked_vector.h
rename to libartbase/base/dchecked_vector.h
index 7236ac3..e9ce6d0 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 @@
} // 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
similarity index 96%
rename from runtime/base/debug_stack.h
rename to libartbase/base/debug_stack.h
index 1331e10..f2d93d4 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 @@
} // 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
similarity index 100%
rename from runtime/base/file_magic.cc
rename to libartbase/base/file_magic.cc
diff --git a/runtime/base/file_magic.h b/libartbase/base/file_magic.h
similarity index 87%
rename from runtime/base/file_magic.h
rename to libartbase/base/file_magic.h
index e7bd706..53f551c 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 @@
} // 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
similarity index 100%
rename from runtime/base/hex_dump.cc
rename to libartbase/base/hex_dump.cc
diff --git a/runtime/base/hex_dump.h b/libartbase/base/hex_dump.h
similarity index 91%
rename from runtime/base/hex_dump.h
rename to libartbase/base/hex_dump.h
index 2ce0aef..55f4d53 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 @@
} // 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
similarity index 100%
rename from runtime/base/hex_dump_test.cc
rename to libartbase/base/hex_dump_test.cc
diff --git a/runtime/base/histogram-inl.h b/libartbase/base/histogram-inl.h
similarity index 97%
rename from runtime/base/histogram-inl.h
rename to libartbase/base/histogram-inl.h
index 3ce0140..26d01b2 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 @@
#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
similarity index 96%
rename from runtime/base/histogram.h
rename to libartbase/base/histogram.h
index 7544a9c..39a1866 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 @@
};
} // 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
similarity index 100%
rename from runtime/base/histogram_test.cc
rename to libartbase/base/histogram_test.cc
diff --git a/runtime/base/length_prefixed_array.h b/libartbase/base/length_prefixed_array.h
similarity index 95%
rename from runtime/base/length_prefixed_array.h
rename to libartbase/base/length_prefixed_array.h
index 2df5a99..7c09bdd 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 @@
} // 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
similarity index 97%
rename from runtime/base/logging.cc
rename to libartbase/base/logging.cc
index 78d5429..37b1f82 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 @@
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
similarity index 96%
rename from runtime/base/logging.h
rename to libartbase/base/logging.h
index c562bdf..fd5fc74 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 @@
} // 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
similarity index 100%
rename from runtime/base/logging_test.cc
rename to libartbase/base/logging_test.cc
diff --git a/runtime/os.h b/libartbase/base/os.h
similarity index 84%
rename from runtime/os.h
rename to libartbase/base/os.h
index 7130fc3..4062d90 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 @@
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
similarity index 84%
rename from runtime/os_linux.cc
rename to libartbase/base/os_linux.cc
index 1b3e000..6b5a604 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 @@
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 @@
}
}
+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
similarity index 100%
rename from runtime/base/runtime_debug.cc
rename to libartbase/base/runtime_debug.cc
diff --git a/runtime/base/runtime_debug.h b/libartbase/base/runtime_debug.h
similarity index 93%
rename from runtime/base/runtime_debug.h
rename to libartbase/base/runtime_debug.h
index 89a0361..7d91166 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 @@
} // 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
similarity index 100%
rename from runtime/base/safe_copy.cc
rename to libartbase/base/safe_copy.cc
diff --git a/runtime/base/safe_copy.h b/libartbase/base/safe_copy.h
similarity index 87%
rename from runtime/base/safe_copy.h
rename to libartbase/base/safe_copy.h
index d0f497c..56cdfec 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 @@
} // 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
similarity index 100%
rename from runtime/base/safe_copy_test.cc
rename to libartbase/base/safe_copy_test.cc
diff --git a/runtime/base/scoped_flock.cc b/libartbase/base/scoped_flock.cc
similarity index 100%
rename from runtime/base/scoped_flock.cc
rename to libartbase/base/scoped_flock.cc
diff --git a/runtime/base/scoped_flock.h b/libartbase/base/scoped_flock.h
similarity index 94%
rename from runtime/base/scoped_flock.h
rename to libartbase/base/scoped_flock.h
index db6c819..476b257 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 @@
} // 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
similarity index 100%
rename from runtime/base/scoped_flock_test.cc
rename to libartbase/base/scoped_flock_test.cc
diff --git a/runtime/stride_iterator.h b/libartbase/base/stride_iterator.h
similarity index 95%
rename from runtime/stride_iterator.h
rename to libartbase/base/stride_iterator.h
index 511c2c6..67c0d38 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 @@
} // 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
similarity index 90%
rename from runtime/base/strlcpy.h
rename to libartbase/base/strlcpy.h
index de135ea..98ea34b 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 @@
#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
similarity index 93%
rename from runtime/base/systrace.h
rename to libartbase/base/systrace.h
index dc2206e..2ff33e8 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 @@
} // 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
similarity index 100%
rename from runtime/base/time_utils.cc
rename to libartbase/base/time_utils.cc
diff --git a/runtime/base/time_utils.h b/libartbase/base/time_utils.h
similarity index 95%
rename from runtime/base/time_utils.h
rename to libartbase/base/time_utils.h
index 7648a10..811af5d 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 @@
} // 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
similarity index 100%
rename from runtime/base/time_utils_test.cc
rename to libartbase/base/time_utils_test.cc
diff --git a/runtime/base/to_str.h b/libartbase/base/to_str.h
similarity index 90%
rename from runtime/base/to_str.h
rename to libartbase/base/to_str.h
index 6b1c84c..74d9584 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 @@
} // 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
similarity index 85%
rename from runtime/base/tracking_safe_map.h
rename to libartbase/base/tracking_safe_map.h
index 2f3984d..2750de1 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 @@
} // 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
similarity index 97%
rename from runtime/base/transform_array_ref.h
rename to libartbase/base/transform_array_ref.h
index a4e0bc2..de2739e 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 @@
} // 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
similarity index 100%
rename from runtime/base/transform_array_ref_test.cc
rename to libartbase/base/transform_array_ref_test.cc
diff --git a/runtime/base/transform_iterator.h b/libartbase/base/transform_iterator.h
similarity index 97%
rename from runtime/base/transform_iterator.h
rename to libartbase/base/transform_iterator.h
index 9c8f822..82d9f9e 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 @@
} // 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
similarity index 100%
rename from runtime/base/transform_iterator_test.cc
rename to libartbase/base/transform_iterator_test.cc
diff --git a/runtime/base/unix_file/README b/libartbase/base/unix_file/README
similarity index 100%
rename from runtime/base/unix_file/README
rename to libartbase/base/unix_file/README
diff --git a/runtime/base/unix_file/fd_file.cc b/libartbase/base/unix_file/fd_file.cc
similarity index 100%
rename from runtime/base/unix_file/fd_file.cc
rename to 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
similarity index 97%
rename from runtime/base/unix_file/fd_file.h
rename to libartbase/base/unix_file/fd_file.h
index 3fb70f6..fe3317f 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 @@
} // 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
similarity index 100%
rename from runtime/base/unix_file/fd_file_test.cc
rename to 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
similarity index 92%
rename from runtime/base/unix_file/random_access_file.h
rename to libartbase/base/unix_file/random_access_file.h
index 31a6dbe..d2124cc 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 @@
} // 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
similarity index 96%
rename from runtime/base/unix_file/random_access_file_test.h
rename to libartbase/base/unix_file/random_access_file_test.h
index 91858c2..1de5f7b 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 @@
} // 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
similarity index 100%
rename from runtime/base/unix_file/random_access_file_utils.cc
rename to 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
similarity index 81%
rename from runtime/base/unix_file/random_access_file_utils.h
rename to libartbase/base/unix_file/random_access_file_utils.h
index 30c81c0..47c4c2a 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 @@
} // 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
similarity index 98%
rename from runtime/utils.cc
rename to libartbase/base/utils.cc
index 7246c3d..029cffd 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
similarity index 97%
rename from runtime/utils.h
rename to libartbase/base/utils.h
index 0c3a0a2..c8c5b72 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 @@
} // 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 0000000..892d1fd
--- /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
similarity index 98%
rename from runtime/base/variant_map.h
rename to libartbase/base/variant_map.h
index c480b51..4e02c54 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 @@
} // 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
similarity index 100%
rename from runtime/base/variant_map_test.cc
rename to libartbase/base/variant_map_test.cc
diff --git a/libdexfile/Android.bp b/libdexfile/Android.bp
index 797b459..ae4ded5 100644
--- a/libdexfile/Android.bp
+++ b/libdexfile/Android.bp
@@ -24,6 +24,7 @@
"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 @@
},
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 @@
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
similarity index 82%
rename from runtime/dex/dex_file_layout.cc
rename to libdexfile/dex/dex_file_layout.cc
index d85d61d..1e36e05 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
similarity index 92%
rename from runtime/dex/dex_file_layout.h
rename to libdexfile/dex/dex_file_layout.h
index 793e3b5..183aefa 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 @@
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 @@
} // 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 85c7281..8069408 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 d4bed6b..fac0bb2 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 7a94326..e55eec4 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 0115772..3df6409 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(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 feba523..2b1210b 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 a00b1fa..b509fb4 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 6359814..9494f04 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 5551c34..d1cc563 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 @@
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 c017c5f..daab232 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -31,25 +31,14 @@
"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 @@
"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 @@
"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 @@
"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 @@
],
header_libs: [
"art_cmdlineparser_headers",
- "art_libartbase_headers",
"libnativehelper_header_only",
"jni_platform_headers",
],
@@ -440,13 +425,9 @@
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 @@
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_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 @@
"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 @@
"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 232ec31..987b459 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 b6b24c2..0c45bc9 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 badee59..9418caf 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 bdfb942..2acfe14 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 3f70958..b867621 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 9276994..8bf91d9 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 ecdabba..04bb6ba 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 e87f631..292bde0 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 060b6fa..c301109 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 dd3f8d5..f9d0d12 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 @@
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 @@
}
}
-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 cac0950..7f691d5 100644
--- a/runtime/base/file_utils.h
+++ b/runtime/base/file_utils.h
@@ -65,10 +65,6 @@
// 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 @@
// 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 01adbf1..d6dbab4 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 3d2226c..a1f30b6 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 4f7001a..4376617 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 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
similarity index 97%
rename from runtime/atomic.cc
rename to runtime/base/quasi_atomic.cc
index 07aceb7..1a82812 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 0000000..067d01d
--- /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 202902e..a253e2f 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 c667fe2..ded9f96 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 80ef654..8cd0604 100644
--- a/runtime/class_linker_test.cc
+++ b/runtime/class_linker_test.cc
@@ -1596,6 +1596,63 @@
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 e4fbc86..add300b 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 @@
// 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 85b0dbb..7fc70e2 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 7b2dd05..bda64eb 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 25d4dd0..6e2cfec 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 75642fc..00a95cc 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 b466181..719b4af 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 b1c9395..ab9e6fa 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 1ab67ec..ed5885f 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 f8d8271..6b103bf 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 bf153f5..a71b212 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 adca5c8..14f5d0e 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 934e57a..4eea607 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 cb2479f..87965ed 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 e9376a9..b96f0d3 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 354b9e1..384e3c2 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 4570e9c..e508d5f 100644
--- a/runtime/gc/allocator/dlmalloc.cc
+++ b/runtime/gc/allocator/dlmalloc.cc
@@ -59,8 +59,8 @@
#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 a78813b..b10c504 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 fa34270..5e3692e 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 4122809..e774959 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 53b899e..5e0fe06 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 fc77c17..d1d45c8 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 6735961..41ee183 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 19b4acd..3dc2cb5 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 592172f..4de0331 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 c59642f..356f3ec 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 c48d48c..af77881 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 a3eef90..025c3f0 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 366eb53..c100bc0 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 6ce81e9..14deb6f 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 d2efb10..512cde4 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 17274b5..0965560 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 3a685cb..e786536 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 12bccb3..7af19fa 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 fddb3f2..cde155f 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 52ee516..aa716f1 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 9940622..0955c3a 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 5187831..3b9cc0f 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 b6055cb..7ddd173 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 05f2794..cb97691 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 d8f858e..e35d80f 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 9c7645a..2a9ef2c 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 a0b58ef..600561b 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 b491c3e..bf1d665 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 90cac85..291a983 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 63f5dc8..557b032 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 6d99ad0..a757960 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 68a3647..51a63dd 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 0d1311f..16335c6 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 7be29c9..1bbce4f 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 @@
// 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 7e09b6b..a0f6bf8 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 4c73d87..b78fcac 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 26acef0..b9d51c1 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 25283bc..ea202e7 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 db244a5..93f2748 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 86d538e..ee7d217 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 7a09391..3f4e841 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 6000317..ea06567 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 c18b219..0819579 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 9bfa4d6..23626f4 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 dd8d45e..fefcb2e 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 edd9910..3627214 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 7fdaa32..55dd514 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 126cb04..aeaa850 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 816ac69..95f82cb 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 5cfc987..086d2f4 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 7fd9c71..cf1f85d 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 32a99eb..5306eac 100644
--- a/runtime/mirror/object_test.cc
+++ b/runtime/mirror/object_test.cc
@@ -787,5 +787,23 @@
}
}
+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 8c2a49c..a60861c 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 a7a6d08..b6173d4 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 0c9c65a..2a938da 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 f150a8c..384ebbe 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 80bae7f..c6b0b0b 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 7d89652..bff8d76 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 5d18b6e..13319c4 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 688ae19..13275d9 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 1ab9109..b80b20c 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 bd4b0fe..c003297 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 1af65a3..25f984f 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 4d4bab7..396b09a 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 3576683..b0e1de2 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 @@
// 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 255a31b..3c2cd00 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 6bf05b7..6f079ca 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 6da49a9..8d6ec00 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 72f7d02..676071b 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 4443255..f0966b7 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 c61ecc8..5518eb2 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 a77d100..58f6c04 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 a6df27b..d62cbdb 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 87432ab..26fb021 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 4442fc6..8672482 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 @@
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 @@
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 06d6627..3fba441 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 bce0d81..f8c680d 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 9c3afbb..d590ad5 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 4cdf015..5b03c2d 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 295685e..6549fc1 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 9673eee..d05fecf 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 386cdf0..bec1150 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 28aa21f..895a108 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 d97dcb5..0f321b6 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 7ce12da..86b8d00 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 925a908..7e204fc 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 e67e93f..0000000
--- 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 d27f431..72f03f2 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 52bd736..74c2244 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 97c1b62..db3f093 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 7b45690..aa54018 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 4fc7ee2..48ee94c 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 83234f0..b91d983 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 d2da244..bbe7465 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 d986cf8..d22998a 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 {