Merge "Ensure when NotifyMethodRedefined is called the ArtMethod is valid"
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/loop_optimization.cc b/compiler/optimizing/loop_optimization.cc
index 8994963..5a483e2 100644
--- a/compiler/optimizing/loop_optimization.cc
+++ b/compiler/optimizing/loop_optimization.cc
@@ -1297,40 +1297,35 @@
return true;
}
}
+ } else if (instruction->IsAbs()) {
+ // Deal with vector restrictions.
+ HInstruction* opa = instruction->InputAt(0);
+ HInstruction* r = opa;
+ bool is_unsigned = false;
+ if (HasVectorRestrictions(restrictions, kNoAbs)) {
+ return false;
+ } else if (HasVectorRestrictions(restrictions, kNoHiBits) &&
+ (!IsNarrowerOperand(opa, type, &r, &is_unsigned) || is_unsigned)) {
+ return false; // reject, unless operand is sign-extension narrower
+ }
+ // Accept ABS(x) for vectorizable operand.
+ DCHECK(r != nullptr);
+ if (generate_code && vector_mode_ != kVector) { // de-idiom
+ r = opa;
+ }
+ if (VectorizeUse(node, r, generate_code, type, restrictions)) {
+ if (generate_code) {
+ GenerateVecOp(instruction,
+ vector_map_->Get(r),
+ nullptr,
+ HVecOperation::ToProperType(type, is_unsigned));
+ }
+ return true;
+ }
} else if (instruction->IsInvokeStaticOrDirect()) {
// Accept particular intrinsics.
HInvokeStaticOrDirect* invoke = instruction->AsInvokeStaticOrDirect();
switch (invoke->GetIntrinsic()) {
- case Intrinsics::kMathAbsInt:
- case Intrinsics::kMathAbsLong:
- case Intrinsics::kMathAbsFloat:
- case Intrinsics::kMathAbsDouble: {
- // Deal with vector restrictions.
- HInstruction* opa = instruction->InputAt(0);
- HInstruction* r = opa;
- bool is_unsigned = false;
- if (HasVectorRestrictions(restrictions, kNoAbs)) {
- return false;
- } else if (HasVectorRestrictions(restrictions, kNoHiBits) &&
- (!IsNarrowerOperand(opa, type, &r, &is_unsigned) || is_unsigned)) {
- return false; // reject, unless operand is sign-extension narrower
- }
- // Accept ABS(x) for vectorizable operand.
- DCHECK(r != nullptr);
- if (generate_code && vector_mode_ != kVector) { // de-idiom
- r = opa;
- }
- if (VectorizeUse(node, r, generate_code, type, restrictions)) {
- if (generate_code) {
- GenerateVecOp(instruction,
- vector_map_->Get(r),
- nullptr,
- HVecOperation::ToProperType(type, is_unsigned));
- }
- return true;
- }
- return false;
- }
case Intrinsics::kMathMinIntInt:
case Intrinsics::kMathMinLongLong:
case Intrinsics::kMathMinFloatFloat:
@@ -1811,18 +1806,15 @@
GENERATE_VEC(
new (global_allocator_) HVecUShr(global_allocator_, opa, opb, type, vector_length_, dex_pc),
new (global_allocator_) HUShr(org_type, opa, opb, dex_pc));
+ case HInstruction::kAbs:
+ DCHECK(opb == nullptr);
+ GENERATE_VEC(
+ new (global_allocator_) HVecAbs(global_allocator_, opa, type, vector_length_, dex_pc),
+ new (global_allocator_) HAbs(org_type, opa, dex_pc));
case HInstruction::kInvokeStaticOrDirect: {
HInvokeStaticOrDirect* invoke = org->AsInvokeStaticOrDirect();
if (vector_mode_ == kVector) {
switch (invoke->GetIntrinsic()) {
- case Intrinsics::kMathAbsInt:
- case Intrinsics::kMathAbsLong:
- case Intrinsics::kMathAbsFloat:
- case Intrinsics::kMathAbsDouble:
- DCHECK(opb == nullptr);
- vector = new (global_allocator_)
- HVecAbs(global_allocator_, opa, type, vector_length_, dex_pc);
- break;
case Intrinsics::kMathMinIntInt:
case Intrinsics::kMathMinLongLong:
case Intrinsics::kMathMinFloatFloat:
@@ -1998,9 +1990,7 @@
HInstruction* v = instruction->InputAt(1);
HInstruction* a = nullptr;
HInstruction* b = nullptr;
- if (v->IsInvokeStaticOrDirect() &&
- (v->AsInvokeStaticOrDirect()->GetIntrinsic() == Intrinsics::kMathAbsInt ||
- v->AsInvokeStaticOrDirect()->GetIntrinsic() == Intrinsics::kMathAbsLong)) {
+ if (v->GetType() == reduction_type && v->IsAbs()) {
HInstruction* x = v->InputAt(0);
if (x->GetType() == reduction_type) {
int64_t c = 0;
@@ -2054,14 +2044,13 @@
VectorizeUse(node, r, generate_code, sub_type, restrictions) &&
VectorizeUse(node, s, generate_code, sub_type, restrictions)) {
if (generate_code) {
- reduction_type = HVecOperation::ToProperType(reduction_type, is_unsigned);
if (vector_mode_ == kVector) {
vector_map_->Put(instruction, new (global_allocator_) HVecSADAccumulate(
global_allocator_,
vector_map_->Get(q),
vector_map_->Get(r),
vector_map_->Get(s),
- reduction_type,
+ HVecOperation::ToProperType(reduction_type, is_unsigned),
GetOtherVL(reduction_type, sub_type, vector_length_),
kNoDexPc));
MaybeRecordStat(stats_, MethodCompilationStat::kLoopVectorizedIdiom);
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..1d7bde60 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 2ce0aefe..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/fixed_up_dex_file.cc b/openjdkjvmti/fixed_up_dex_file.cc
index 16bbee4..ee83c4a 100644
--- a/openjdkjvmti/fixed_up_dex_file.cc
+++ b/openjdkjvmti/fixed_up_dex_file.cc
@@ -115,6 +115,9 @@
// this before unquickening.
art::Options options;
options.compact_dex_level_ = art::CompactDexLevel::kCompactDexLevelNone;
+ // Never verify the output since hidden API flags may cause the dex file verifier to fail.
+ // See b/74063493
+ options.verify_output_ = false;
// Add a filter to only include the class that has the matching descriptor.
static constexpr bool kFilterByDescriptor = true;
if (kFilterByDescriptor) {
diff --git a/openjdkjvmti/ti_class.cc b/openjdkjvmti/ti_class.cc
index 7a94326..261fe3e 100644
--- a/openjdkjvmti/ti_class.cc
+++ b/openjdkjvmti/ti_class.cc
@@ -39,7 +39,9 @@
#include "art_jvmti.h"
#include "base/array_ref.h"
#include "base/macros.h"
+#include "base/utils.h"
#include "class_linker.h"
+#include "class_loader_utils.h"
#include "class_table-inl.h"
#include "common_throws.h"
#include "dex/art_dex_file_loader.h"
@@ -72,7 +74,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 {
@@ -942,23 +943,12 @@
art::Handle<art::mirror::ClassLoader> class_loader(
hs.NewHandle(soa.Decode<art::mirror::ClassLoader>(loader)));
std::vector<const art::DexFile*> dex_files;
- ClassLoaderHelper::VisitDexFileObjects(
- self,
+ art::VisitClassLoaderDexFiles(
+ soa,
class_loader,
- [&] (art::ObjPtr<art::mirror::Object> dex_file) REQUIRES_SHARED(art::Locks::mutator_lock_) {
- art::StackHandleScope<2> hs(self);
- art::Handle<art::mirror::Object> h_dex_file(hs.NewHandle(dex_file));
- art::Handle<art::mirror::LongArray> cookie(
- hs.NewHandle(ClassLoaderHelper::GetDexFileCookie(h_dex_file)));
- size_t num_elements = cookie->GetLength();
- // We need to skip over the oat_file that's the first element. The other elements are all
- // dex files.
- for (size_t i = 1; i < num_elements; i++) {
- dex_files.push_back(
- reinterpret_cast<const art::DexFile*>(static_cast<uintptr_t>(cookie->Get(i))));
- }
- // Iterate over all dex files.
- return true;
+ [&](const art::DexFile* dex_file) {
+ dex_files.push_back(dex_file);
+ return true; // Continue with other dex files.
});
// We hold the loader so the dex files won't go away until after this call at worst.
return CopyClassDescriptors(env, dex_files, count_ptr, classes);
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 145eb67..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 {
@@ -295,6 +295,11 @@
return GetDexFile()->GetClassDef(GetClassDefIndex());
}
+inline size_t ArtMethod::GetNumberOfParameters() {
+ constexpr size_t return_type_count = 1u;
+ return strlen(GetShorty()) - return_type_count;
+}
+
inline const char* ArtMethod::GetReturnTypeDescriptor() {
DCHECK(!IsProxyMethod());
const DexFile* dex_file = GetDexFile();
diff --git a/runtime/art_method.h b/runtime/art_method.h
index 013856f..5d9b729 100644
--- a/runtime/art_method.h
+++ b/runtime/art_method.h
@@ -602,6 +602,8 @@
const DexFile::ClassDef& GetClassDef() REQUIRES_SHARED(Locks::mutator_lock_);
+ ALWAYS_INLINE size_t GetNumberOfParameters() REQUIRES_SHARED(Locks::mutator_lock_);
+
const char* GetReturnTypeDescriptor() REQUIRES_SHARED(Locks::mutator_lock_);
ALWAYS_INLINE Primitive::Type GetReturnTypePrimitive() REQUIRES_SHARED(Locks::mutator_lock_);
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..1d72875 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"
@@ -1122,12 +1123,8 @@
DCHECK(out_dex_file_names != nullptr);
DCHECK(error_msg != nullptr);
ScopedObjectAccessUnchecked soa(Thread::Current());
- ArtField* const dex_path_list_field =
- jni::DecodeArtField(WellKnownClasses::dalvik_system_BaseDexClassLoader_pathList);
- ArtField* const dex_elements_field =
- jni::DecodeArtField(WellKnownClasses::dalvik_system_DexPathList_dexElements);
- CHECK(dex_path_list_field != nullptr);
- CHECK(dex_elements_field != nullptr);
+ StackHandleScope<1> hs(soa.Self());
+ Handle<mirror::ClassLoader> handle(hs.NewHandle(class_loader));
while (!ClassLinker::IsBootClassLoader(soa, class_loader)) {
if (soa.Decode<mirror::Class>(WellKnownClasses::dalvik_system_PathClassLoader) !=
class_loader->GetClass()) {
@@ -1136,32 +1133,29 @@
// Unsupported class loader.
return false;
}
- ObjPtr<mirror::Object> dex_path_list = dex_path_list_field->GetObject(class_loader);
- if (dex_path_list != nullptr) {
- // DexPathList has an array dexElements of Elements[] which each contain a dex file.
- ObjPtr<mirror::Object> dex_elements_obj = dex_elements_field->GetObject(dex_path_list);
- // Loop through each dalvik.system.DexPathList$Element's dalvik.system.DexFile and look
- // at the mCookie which is a DexFile vector.
- if (dex_elements_obj != nullptr) {
- ObjPtr<mirror::ObjectArray<mirror::Object>> dex_elements =
- dex_elements_obj->AsObjectArray<mirror::Object>();
- // Reverse order since we insert the parent at the front.
- for (int32_t i = dex_elements->GetLength() - 1; i >= 0; --i) {
- ObjPtr<mirror::Object> element = dex_elements->GetWithoutChecks(i);
- if (element == nullptr) {
- *error_msg = StringPrintf("Null dex element at index %d", i);
- return false;
- }
- ObjPtr<mirror::String> name;
- if (!GetDexPathListElementName(element, &name)) {
- *error_msg = StringPrintf("Invalid dex path list element at index %d", i);
- return false;
- }
- if (name != nullptr) {
- out_dex_file_names->push_front(name.Ptr());
- }
- }
+ // Get element names. Sets error to true on failure.
+ auto add_element_names = [&](ObjPtr<mirror::Object> element, bool* error)
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ if (element == nullptr) {
+ *error_msg = "Null dex element";
+ *error = true; // Null element is a critical error.
+ return false; // Had an error, stop the visit.
}
+ ObjPtr<mirror::String> name;
+ if (!GetDexPathListElementName(element, &name)) {
+ *error_msg = "Invalid dex path list element";
+ *error = false; // Invalid element is not a critical error.
+ return false; // Stop the visit.
+ }
+ if (name != nullptr) {
+ out_dex_file_names->push_front(name.Ptr());
+ }
+ return true; // Continue with the next Element.
+ };
+ bool error = VisitClassLoaderDexElements(soa, handle, add_element_names, /* error */ false);
+ if (error) {
+ // An error occurred during DexPathList Element visiting.
+ return false;
}
class_loader = class_loader->GetParent();
}
@@ -2444,71 +2438,33 @@
const char* descriptor,
size_t hash,
Handle<mirror::ClassLoader> class_loader) {
- CHECK(IsPathOrDexClassLoader(soa, class_loader) || IsDelegateLastClassLoader(soa, class_loader))
+ DCHECK(IsPathOrDexClassLoader(soa, class_loader) || IsDelegateLastClassLoader(soa, class_loader))
<< "Unexpected class loader for descriptor " << descriptor;
- Thread* self = soa.Self();
- ArtField* const cookie_field =
- jni::DecodeArtField(WellKnownClasses::dalvik_system_DexFile_cookie);
- ArtField* const dex_file_field =
- jni::DecodeArtField(WellKnownClasses::dalvik_system_DexPathList__Element_dexFile);
- ObjPtr<mirror::Object> dex_path_list =
- jni::DecodeArtField(WellKnownClasses::dalvik_system_BaseDexClassLoader_pathList)->
- GetObject(class_loader.Get());
- if (dex_path_list != nullptr && dex_file_field != nullptr && cookie_field != nullptr) {
- // DexPathList has an array dexElements of Elements[] which each contain a dex file.
- ObjPtr<mirror::Object> dex_elements_obj =
- jni::DecodeArtField(WellKnownClasses::dalvik_system_DexPathList_dexElements)->
- GetObject(dex_path_list);
- // Loop through each dalvik.system.DexPathList$Element's dalvik.system.DexFile and look
- // at the mCookie which is a DexFile vector.
- if (dex_elements_obj != nullptr) {
- StackHandleScope<1> hs(self);
- Handle<mirror::ObjectArray<mirror::Object>> dex_elements =
- hs.NewHandle(dex_elements_obj->AsObjectArray<mirror::Object>());
- for (int32_t i = 0; i < dex_elements->GetLength(); ++i) {
- ObjPtr<mirror::Object> element = dex_elements->GetWithoutChecks(i);
- if (element == nullptr) {
- // Should never happen, fall back to java code to throw a NPE.
- break;
- }
- ObjPtr<mirror::Object> dex_file = dex_file_field->GetObject(element);
- if (dex_file != nullptr) {
- ObjPtr<mirror::LongArray> long_array = cookie_field->GetObject(dex_file)->AsLongArray();
- if (long_array == nullptr) {
- // This should never happen so log a warning.
- LOG(WARNING) << "Null DexFile::mCookie for " << descriptor;
- break;
- }
- int32_t long_array_size = long_array->GetLength();
- // First element is the oat file.
- for (int32_t j = kDexFileIndexStart; j < long_array_size; ++j) {
- const DexFile* cp_dex_file = reinterpret_cast<const DexFile*>(static_cast<uintptr_t>(
- long_array->GetWithoutChecks(j)));
- const DexFile::ClassDef* dex_class_def =
- OatDexFile::FindClassDef(*cp_dex_file, descriptor, hash);
- if (dex_class_def != nullptr) {
- ObjPtr<mirror::Class> klass = DefineClass(self,
- descriptor,
- hash,
- class_loader,
- *cp_dex_file,
- *dex_class_def);
- if (klass == nullptr) {
- CHECK(self->IsExceptionPending()) << descriptor;
- self->ClearException();
- // TODO: Is it really right to break here, and not check the other dex files?
- return nullptr;
- }
- return klass;
- }
- }
- }
+ ObjPtr<mirror::Class> ret;
+ auto define_class = [&](const DexFile* cp_dex_file) REQUIRES_SHARED(Locks::mutator_lock_) {
+ const DexFile::ClassDef* dex_class_def =
+ OatDexFile::FindClassDef(*cp_dex_file, descriptor, hash);
+ if (dex_class_def != nullptr) {
+ ObjPtr<mirror::Class> klass = DefineClass(soa.Self(),
+ descriptor,
+ hash,
+ class_loader,
+ *cp_dex_file,
+ *dex_class_def);
+ if (klass == nullptr) {
+ CHECK(soa.Self()->IsExceptionPending()) << descriptor;
+ soa.Self()->ClearException();
+ // TODO: Is it really right to break here, and not check the other dex files?
}
+ ret = klass;
+ return false; // Found a Class (or error == nullptr), stop visit.
}
- self->AssertNoPendingException();
- }
- return nullptr;
+ return true; // Continue with the next DexFile.
+ };
+
+ VisitClassLoaderDexFiles(soa, class_loader, define_class);
+ return ret;
}
mirror::Class* ClassLinker::FindClass(Thread* self,
@@ -4977,8 +4933,14 @@
// interface since we can still avoid the traversal. This is purely a performance optimization.
if (result) {
// TODO This should be done in a better way
- ObjectLock<mirror::Class> lock(self, iface);
- iface->SetRecursivelyInitialized();
+ // Note: Use a try-lock to avoid blocking when someone else is holding the lock on this
+ // interface. It is bad (Java) style, but not impossible. Marking the recursive
+ // initialization is a performance optimization (to avoid another idempotent visit
+ // for other implementing classes/interfaces), and can be revisited later.
+ ObjectTryLock<mirror::Class> lock(self, iface);
+ if (lock.Acquired()) {
+ iface->SetRecursivelyInitialized();
+ }
}
return result;
}
@@ -7901,42 +7863,19 @@
if (loader->GetClass() == path_class_loader ||
loader->GetClass() == dex_class_loader ||
loader->GetClass() == delegate_last_class_loader) {
- ArtField* const cookie_field =
- jni::DecodeArtField(WellKnownClasses::dalvik_system_DexFile_cookie);
- ArtField* const dex_file_field =
- jni::DecodeArtField(WellKnownClasses::dalvik_system_DexPathList__Element_dexFile);
- ObjPtr<mirror::Object> dex_path_list =
- jni::DecodeArtField(WellKnownClasses::dalvik_system_BaseDexClassLoader_pathList)->
- GetObject(loader);
- if (dex_path_list != nullptr && dex_file_field != nullptr && cookie_field != nullptr) {
- ObjPtr<mirror::Object> dex_elements_obj =
- jni::DecodeArtField(WellKnownClasses::dalvik_system_DexPathList_dexElements)->
- GetObject(dex_path_list);
- if (dex_elements_obj != nullptr) {
- ObjPtr<mirror::ObjectArray<mirror::Object>> dex_elements =
- dex_elements_obj->AsObjectArray<mirror::Object>();
- oss << "(";
- const char* path_separator = "";
- for (int32_t i = 0; i != dex_elements->GetLength(); ++i) {
- ObjPtr<mirror::Object> element = dex_elements->GetWithoutChecks(i);
- ObjPtr<mirror::Object> dex_file =
- (element != nullptr) ? dex_file_field->GetObject(element) : nullptr;
- ObjPtr<mirror::LongArray> long_array =
- (dex_file != nullptr) ? cookie_field->GetObject(dex_file)->AsLongArray() : nullptr;
- if (long_array != nullptr) {
- int32_t long_array_size = long_array->GetLength();
- // First element is the oat file.
- for (int32_t j = kDexFileIndexStart; j < long_array_size; ++j) {
- const DexFile* cp_dex_file = reinterpret_cast<const DexFile*>(
- static_cast<uintptr_t>(long_array->GetWithoutChecks(j)));
- oss << path_separator << cp_dex_file->GetLocation();
- path_separator = ":";
- }
- }
- }
- oss << ")";
- }
- }
+ oss << "(";
+ ScopedObjectAccessUnchecked soa(Thread::Current());
+ StackHandleScope<1> hs(soa.Self());
+ Handle<mirror::ClassLoader> handle(hs.NewHandle(loader));
+ const char* path_separator = "";
+ VisitClassLoaderDexFiles(soa,
+ handle,
+ [&](const DexFile* dex_file) {
+ oss << path_separator << dex_file->GetLocation();
+ path_separator = ":";
+ return true; // Continue with the next DexFile.
+ });
+ oss << ")";
}
}
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/class_loader_utils.h b/runtime/class_loader_utils.h
index d160a51..1439f11 100644
--- a/runtime/class_loader_utils.h
+++ b/runtime/class_loader_utils.h
@@ -17,8 +17,12 @@
#ifndef ART_RUNTIME_CLASS_LOADER_UTILS_H_
#define ART_RUNTIME_CLASS_LOADER_UTILS_H_
+#include "art_field-inl.h"
+#include "base/mutex.h"
#include "handle_scope.h"
+#include "jni_internal.h"
#include "mirror/class_loader.h"
+#include "native/dalvik_system_DexFile.h"
#include "scoped_thread_state_change-inl.h"
#include "well_known_classes.h"
@@ -26,7 +30,7 @@
// Returns true if the given class loader is either a PathClassLoader or a DexClassLoader.
// (they both have the same behaviour with respect to class lockup order)
-static bool IsPathOrDexClassLoader(ScopedObjectAccessAlreadyRunnable& soa,
+inline bool IsPathOrDexClassLoader(ScopedObjectAccessAlreadyRunnable& soa,
Handle<mirror::ClassLoader> class_loader)
REQUIRES_SHARED(Locks::mutator_lock_) {
mirror::Class* class_loader_class = class_loader->GetClass();
@@ -37,7 +41,7 @@
soa.Decode<mirror::Class>(WellKnownClasses::dalvik_system_DexClassLoader));
}
-static bool IsDelegateLastClassLoader(ScopedObjectAccessAlreadyRunnable& soa,
+inline bool IsDelegateLastClassLoader(ScopedObjectAccessAlreadyRunnable& soa,
Handle<mirror::ClassLoader> class_loader)
REQUIRES_SHARED(Locks::mutator_lock_) {
mirror::Class* class_loader_class = class_loader->GetClass();
@@ -45,6 +49,114 @@
soa.Decode<mirror::Class>(WellKnownClasses::dalvik_system_DelegateLastClassLoader);
}
+// Visit the DexPathList$Element instances in the given classloader with the given visitor.
+// Constraints on the visitor:
+// * The visitor should return true to continue visiting more Elements.
+// * The last argument of the visitor is an out argument of RetType. It will be returned
+// when the visitor ends the visit (by returning false).
+// This function assumes that the given classloader is a subclass of BaseDexClassLoader!
+template <typename Visitor, typename RetType>
+inline RetType VisitClassLoaderDexElements(ScopedObjectAccessAlreadyRunnable& soa,
+ Handle<mirror::ClassLoader> class_loader,
+ Visitor fn,
+ RetType defaultReturn)
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ Thread* self = soa.Self();
+ ObjPtr<mirror::Object> dex_path_list =
+ jni::DecodeArtField(WellKnownClasses::dalvik_system_BaseDexClassLoader_pathList)->
+ GetObject(class_loader.Get());
+ if (dex_path_list != nullptr) {
+ // DexPathList has an array dexElements of Elements[] which each contain a dex file.
+ ObjPtr<mirror::Object> dex_elements_obj =
+ jni::DecodeArtField(WellKnownClasses::dalvik_system_DexPathList_dexElements)->
+ GetObject(dex_path_list);
+ // Loop through each dalvik.system.DexPathList$Element's dalvik.system.DexFile and look
+ // at the mCookie which is a DexFile vector.
+ if (dex_elements_obj != nullptr) {
+ StackHandleScope<1> hs(self);
+ Handle<mirror::ObjectArray<mirror::Object>> dex_elements =
+ hs.NewHandle(dex_elements_obj->AsObjectArray<mirror::Object>());
+ for (int32_t i = 0; i < dex_elements->GetLength(); ++i) {
+ ObjPtr<mirror::Object> element = dex_elements->GetWithoutChecks(i);
+ if (element == nullptr) {
+ // Should never happen, fail.
+ break;
+ }
+ RetType ret_value;
+ if (!fn(element, &ret_value)) {
+ return ret_value;
+ }
+ }
+ }
+ self->AssertNoPendingException();
+ }
+ return defaultReturn;
+}
+
+// Visit the DexFiles in the given classloader with the given visitor.
+// Constraints on the visitor:
+// * The visitor should return true to continue visiting more DexFiles.
+// * The last argument of the visitor is an out argument of RetType. It will be returned
+// when the visitor ends the visit (by returning false).
+// This function assumes that the given classloader is a subclass of BaseDexClassLoader!
+template <typename Visitor, typename RetType>
+inline RetType VisitClassLoaderDexFiles(ScopedObjectAccessAlreadyRunnable& soa,
+ Handle<mirror::ClassLoader> class_loader,
+ Visitor fn,
+ RetType defaultReturn)
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ ArtField* const cookie_field =
+ jni::DecodeArtField(WellKnownClasses::dalvik_system_DexFile_cookie);
+ ArtField* const dex_file_field =
+ jni::DecodeArtField(WellKnownClasses::dalvik_system_DexPathList__Element_dexFile);
+ if (dex_file_field == nullptr || cookie_field == nullptr) {
+ return defaultReturn;
+ }
+ auto visit_dex_files = [&](ObjPtr<mirror::Object> element, RetType* ret)
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ ObjPtr<mirror::Object> dex_file = dex_file_field->GetObject(element);
+ if (dex_file != nullptr) {
+ ObjPtr<mirror::LongArray> long_array = cookie_field->GetObject(dex_file)->AsLongArray();
+ if (long_array == nullptr) {
+ // This should never happen so log a warning.
+ LOG(WARNING) << "Null DexFile::mCookie";
+ *ret = defaultReturn;
+ return true;
+ }
+ int32_t long_array_size = long_array->GetLength();
+ // First element is the oat file.
+ for (int32_t j = kDexFileIndexStart; j < long_array_size; ++j) {
+ const DexFile* cp_dex_file = reinterpret_cast<const DexFile*>(static_cast<uintptr_t>(
+ long_array->GetWithoutChecks(j)));
+ RetType ret_value;
+ if (!fn(cp_dex_file, /* out */ &ret_value)) {
+ *ret = ret_value;
+ return false;
+ }
+ }
+ }
+ return true;
+ };
+
+ return VisitClassLoaderDexElements(soa, class_loader, visit_dex_files, defaultReturn);
+}
+
+// Simplified version of the above, w/o out argument.
+template <typename Visitor>
+inline void VisitClassLoaderDexFiles(ScopedObjectAccessAlreadyRunnable& soa,
+ Handle<mirror::ClassLoader> class_loader,
+ Visitor fn)
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ auto helper = [&fn](const art::DexFile* dex_file, void** ATTRIBUTE_UNUSED)
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ return fn(dex_file);
+ };
+ VisitClassLoaderDexFiles<decltype(helper), void*>(soa,
+ class_loader,
+ helper,
+ /* default */ nullptr);
+}
+
} // namespace art
#endif // ART_RUNTIME_CLASS_LOADER_UTILS_H_
diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc
index e4fbc86..05159e2 100644
--- a/runtime/common_runtime_test.cc
+++ b/runtime/common_runtime_test.cc
@@ -30,10 +30,13 @@
#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"
#include "class_linker.h"
+#include "class_loader_utils.h"
#include "compiler_callbacks.h"
#include "dex/art_dex_file_loader.h"
#include "dex/dex_file-inl.h"
@@ -51,7 +54,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 +65,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);
@@ -541,58 +544,23 @@
std::vector<const DexFile*> CommonRuntimeTestImpl::GetDexFiles(
ScopedObjectAccess& soa,
Handle<mirror::ClassLoader> class_loader) {
- std::vector<const DexFile*> ret;
-
DCHECK(
(class_loader->GetClass() ==
soa.Decode<mirror::Class>(WellKnownClasses::dalvik_system_PathClassLoader)) ||
(class_loader->GetClass() ==
soa.Decode<mirror::Class>(WellKnownClasses::dalvik_system_DelegateLastClassLoader)));
- // The class loader is a PathClassLoader which inherits from BaseDexClassLoader.
- // We need to get the DexPathList and loop through it.
- ArtField* cookie_field = jni::DecodeArtField(WellKnownClasses::dalvik_system_DexFile_cookie);
- ArtField* dex_file_field =
- jni::DecodeArtField(WellKnownClasses::dalvik_system_DexPathList__Element_dexFile);
- ObjPtr<mirror::Object> dex_path_list =
- jni::DecodeArtField(WellKnownClasses::dalvik_system_BaseDexClassLoader_pathList)->
- GetObject(class_loader.Get());
- if (dex_path_list != nullptr && dex_file_field!= nullptr && cookie_field != nullptr) {
- // DexPathList has an array dexElements of Elements[] which each contain a dex file.
- ObjPtr<mirror::Object> dex_elements_obj =
- jni::DecodeArtField(WellKnownClasses::dalvik_system_DexPathList_dexElements)->
- GetObject(dex_path_list);
- // Loop through each dalvik.system.DexPathList$Element's dalvik.system.DexFile and look
- // at the mCookie which is a DexFile vector.
- if (dex_elements_obj != nullptr) {
- StackHandleScope<1> hs(soa.Self());
- Handle<mirror::ObjectArray<mirror::Object>> dex_elements =
- hs.NewHandle(dex_elements_obj->AsObjectArray<mirror::Object>());
- for (int32_t i = 0; i < dex_elements->GetLength(); ++i) {
- ObjPtr<mirror::Object> element = dex_elements->GetWithoutChecks(i);
- if (element == nullptr) {
- // Should never happen, fall back to java code to throw a NPE.
- break;
- }
- ObjPtr<mirror::Object> dex_file = dex_file_field->GetObject(element);
- if (dex_file != nullptr) {
- ObjPtr<mirror::LongArray> long_array = cookie_field->GetObject(dex_file)->AsLongArray();
- DCHECK(long_array != nullptr);
- int32_t long_array_size = long_array->GetLength();
- for (int32_t j = kDexFileIndexStart; j < long_array_size; ++j) {
- const DexFile* cp_dex_file = reinterpret_cast<const DexFile*>(static_cast<uintptr_t>(
- long_array->GetWithoutChecks(j)));
- if (cp_dex_file == nullptr) {
- LOG(WARNING) << "Null DexFile";
- continue;
- }
- ret.push_back(cp_dex_file);
- }
- }
- }
- }
- }
-
+ std::vector<const DexFile*> ret;
+ VisitClassLoaderDexFiles(soa,
+ class_loader,
+ [&](const DexFile* cp_dex_file) {
+ if (cp_dex_file == nullptr) {
+ LOG(WARNING) << "Null DexFile";
+ } else {
+ ret.push_back(cp_dex_file);
+ }
+ return true;
+ });
return ret;
}
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/dex/dex_file_annotations.cc b/runtime/dex/dex_file_annotations.cc
index 3431bb7..6f3354b 100644
--- a/runtime/dex/dex_file_annotations.cc
+++ b/runtime/dex/dex_file_annotations.cc
@@ -1121,6 +1121,21 @@
return ProcessAnnotationSetRefList(ClassData(method), set_ref_list, size);
}
+uint32_t GetNumberOfAnnotatedMethodParameters(ArtMethod* method) {
+ const DexFile* dex_file = method->GetDexFile();
+ const DexFile::ParameterAnnotationsItem* parameter_annotations =
+ FindAnnotationsItemForMethod(method);
+ if (parameter_annotations == nullptr) {
+ return 0u;
+ }
+ const DexFile::AnnotationSetRefList* set_ref_list =
+ dex_file->GetParameterAnnotationSetRefList(parameter_annotations);
+ if (set_ref_list == nullptr) {
+ return 0u;
+ }
+ return set_ref_list->size_;
+}
+
mirror::Object* GetAnnotationForMethodParameter(ArtMethod* method,
uint32_t parameter_idx,
Handle<mirror::Class> annotation_class) {
@@ -1141,7 +1156,9 @@
const DexFile::AnnotationSetRefItem* annotation_set_ref = &set_ref_list->list_[parameter_idx];
const DexFile::AnnotationSetItem* annotation_set =
dex_file->GetSetRefItemItem(annotation_set_ref);
-
+ if (annotation_set == nullptr) {
+ return nullptr;
+ }
return GetAnnotationObjectFromAnnotationSet(ClassData(method),
annotation_set,
DexFile::kDexVisibilityRuntime,
diff --git a/runtime/dex/dex_file_annotations.h b/runtime/dex/dex_file_annotations.h
index d7ebf84..4bb0d75 100644
--- a/runtime/dex/dex_file_annotations.h
+++ b/runtime/dex/dex_file_annotations.h
@@ -55,6 +55,8 @@
REQUIRES_SHARED(Locks::mutator_lock_);
mirror::ObjectArray<mirror::Object>* GetParameterAnnotations(ArtMethod* method)
REQUIRES_SHARED(Locks::mutator_lock_);
+uint32_t GetNumberOfAnnotatedMethodParameters(ArtMethod* method)
+ REQUIRES_SHARED(Locks::mutator_lock_);
mirror::Object* GetAnnotationForMethodParameter(ArtMethod* method,
uint32_t parameter_idx,
Handle<mirror::Class> annotation_class)
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 a1d0ff7..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 {
@@ -186,6 +186,11 @@
void SetAccessFlags(uint32_t new_access_flags) REQUIRES_SHARED(Locks::mutator_lock_);
+ // Returns true if the class is an enum.
+ ALWAYS_INLINE bool IsEnum() REQUIRES_SHARED(Locks::mutator_lock_) {
+ return (GetAccessFlags() & kAccEnum) != 0;
+ }
+
// Returns true if the class is an interface.
ALWAYS_INLINE bool IsInterface() REQUIRES_SHARED(Locks::mutator_lock_) {
return (GetAccessFlags() & kAccInterface) != 0;
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_Executable.cc b/runtime/native/java_lang_reflect_Executable.cc
index a5e70af..b129c66 100644
--- a/runtime/native/java_lang_reflect_Executable.cc
+++ b/runtime/native/java_lang_reflect_Executable.cc
@@ -70,7 +70,6 @@
if (method->GetDeclaringClass()->IsProxyClass()) {
return nullptr;
}
- StackHandleScope<1> hs(soa.Self());
return soa.AddLocalReference<jobjectArray>(annotations::GetSignatureAnnotationForMethod(method));
}
@@ -80,9 +79,76 @@
ArtMethod* method = ArtMethod::FromReflectedMethod(soa, javaMethod);
if (method->IsProxyMethod()) {
return nullptr;
- } else {
- return soa.AddLocalReference<jobjectArray>(annotations::GetParameterAnnotations(method));
}
+
+ StackHandleScope<4> hs(soa.Self());
+ Handle<mirror::ObjectArray<mirror::Object>> annotations =
+ hs.NewHandle(annotations::GetParameterAnnotations(method));
+ if (annotations.IsNull()) {
+ return nullptr;
+ }
+
+ // If the method is not a constructor, or has parameter annotations
+ // for each parameter, then we can return those annotations
+ // unmodified. Otherwise, we need to look at whether the
+ // constructor has implicit parameters as these may need padding
+ // with empty parameter annotations.
+ if (!method->IsConstructor() ||
+ annotations->GetLength() == static_cast<int>(method->GetNumberOfParameters())) {
+ return soa.AddLocalReference<jobjectArray>(annotations.Get());
+ }
+
+ // If declaring class is a local or an enum, do not pad parameter
+ // annotations, as the implicit constructor parameters are an implementation
+ // detail rather than required by JLS.
+ Handle<mirror::Class> declaring_class = hs.NewHandle(method->GetDeclaringClass());
+ if (annotations::GetEnclosingMethod(declaring_class) != nullptr ||
+ declaring_class->IsEnum()) {
+ return soa.AddLocalReference<jobjectArray>(annotations.Get());
+ }
+
+ // Prepare to resize the annotations so there is 1:1 correspondence
+ // with the constructor parameters.
+ Handle<mirror::ObjectArray<mirror::Object>> resized_annotations = hs.NewHandle(
+ mirror::ObjectArray<mirror::Object>::Alloc(
+ soa.Self(),
+ annotations->GetClass(),
+ static_cast<int>(method->GetNumberOfParameters())));
+ if (resized_annotations.IsNull()) {
+ DCHECK(soa.Self()->IsExceptionPending());
+ return nullptr;
+ }
+
+ static constexpr bool kTransactionActive = false;
+ const int32_t offset = resized_annotations->GetLength() - annotations->GetLength();
+ if (offset > 0) {
+ // Workaround for dexers (d8/dx) that do not insert annotations
+ // for implicit parameters (b/68033708).
+ ObjPtr<mirror::Class> annotation_array_class =
+ soa.Decode<mirror::Class>(WellKnownClasses::java_lang_annotation_Annotation__array);
+ Handle<mirror::ObjectArray<mirror::Object>> empty_annotations = hs.NewHandle(
+ mirror::ObjectArray<mirror::Object>::Alloc(soa.Self(), annotation_array_class, 0));
+ if (empty_annotations.IsNull()) {
+ DCHECK(soa.Self()->IsExceptionPending());
+ return nullptr;
+ }
+ for (int i = 0; i < offset; ++i) {
+ resized_annotations->SetWithoutChecks<kTransactionActive>(i, empty_annotations.Get());
+ }
+ for (int i = 0; i < annotations->GetLength(); ++i) {
+ ObjPtr<mirror::Object> annotation = annotations->GetWithoutChecks(i);
+ resized_annotations->SetWithoutChecks<kTransactionActive>(i + offset, annotation);
+ }
+ } else {
+ // Workaround for Jack (defunct) erroneously inserting annotations
+ // for local classes (b/68033708).
+ DCHECK_LT(offset, 0);
+ for (int i = 0; i < resized_annotations->GetLength(); ++i) {
+ ObjPtr<mirror::Object> annotation = annotations->GetWithoutChecks(i - offset);
+ resized_annotations->SetWithoutChecks<kTransactionActive>(i, annotation);
+ }
+ }
+ return soa.AddLocalReference<jobjectArray>(resized_annotations.Get());
}
static jobjectArray Executable_getParameters0(JNIEnv* env, jobject javaMethod) {
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 0b3015b..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 {
@@ -58,6 +58,40 @@
return nullptr;
}
+ uint32_t annotated_parameter_count = annotations::GetNumberOfAnnotatedMethodParameters(method);
+ if (annotated_parameter_count == 0u) {
+ return nullptr;
+ }
+
+ // For constructors with implicit arguments, we may need to adjust
+ // annotation positions based on whether the implicit parameters are
+ // expected to known and not just a compiler implementation detail.
+ if (method->IsConstructor()) {
+ StackHandleScope<1> hs(soa.Self());
+ // If declaring class is a local or an enum, do not pad parameter
+ // annotations, as the implicit constructor parameters are an
+ // implementation detail rather than required by JLS.
+ Handle<mirror::Class> declaring_class = hs.NewHandle(method->GetDeclaringClass());
+ if (annotations::GetEnclosingMethod(declaring_class) == nullptr && !declaring_class->IsEnum()) {
+ // Adjust the parameter index if the number of annotations does
+ // not match the number of parameters.
+ if (annotated_parameter_count <= parameter_count) {
+ // Workaround for dexer not inserting annotation state for implicit parameters (b/68033708).
+ uint32_t skip_count = parameter_count - annotated_parameter_count;
+ DCHECK_GE(2u, skip_count);
+ if (parameterIndex < static_cast<jint>(skip_count)) {
+ return nullptr;
+ }
+ parameterIndex -= skip_count;
+ } else {
+ // Workaround for Jack erroneously inserting implicit parameter for local classes
+ // (b/68033708).
+ DCHECK_EQ(1u, annotated_parameter_count - parameter_count);
+ parameterIndex += static_cast<jint>(annotated_parameter_count - parameter_count);
+ }
+ }
+ }
+
StackHandleScope<1> hs(soa.Self());
Handle<mirror::Class> klass(hs.NewHandle(soa.Decode<mirror::Class>(annotationType)));
return soa.AddLocalReference<jobject>(
@@ -65,9 +99,10 @@
}
static JNINativeMethod gMethods[] = {
- FAST_NATIVE_METHOD(Parameter,
- getAnnotationNative,
- "(Ljava/lang/reflect/Executable;ILjava/lang/Class;)Ljava/lang/annotation/Annotation;"),
+ FAST_NATIVE_METHOD(
+ Parameter,
+ getAnnotationNative,
+ "(Ljava/lang/reflect/Executable;ILjava/lang/Class;)Ljava/lang/annotation/Annotation;"),
};
void register_java_lang_reflect_Parameter(JNIEnv* env) {
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..1d091e9 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"
@@ -1261,18 +1261,33 @@
return ReleaseFile();
}
- if (Status() == kOatRelocationOutOfDate) {
- // We are loading an oat file for runtime use that needs relocation.
- // Reload the file non-executable to ensure that we interpret out of the
- // dex code in the oat file rather than trying to execute the unrelocated
- // compiled code.
- oat_file_assistant_->load_executable_ = false;
- Reset();
- if (IsUseable()) {
- CHECK(!IsExecutable());
- return ReleaseFile();
- }
+ switch (Status()) {
+ case kOatBootImageOutOfDate:
+ if (oat_file_assistant_->HasOriginalDexFiles()) {
+ // If there are original dex files, it is better to use them.
+ break;
+ }
+ FALLTHROUGH_INTENDED;
+
+ case kOatRelocationOutOfDate:
+ // We are loading an oat file for runtime use that needs relocation.
+ // Reload the file non-executable to ensure that we interpret out of the
+ // dex code in the oat file rather than trying to execute the unrelocated
+ // compiled code.
+ oat_file_assistant_->load_executable_ = false;
+ Reset();
+ if (IsUseable()) {
+ CHECK(!IsExecutable());
+ return ReleaseFile();
+ }
+ break;
+
+ case kOatUpToDate:
+ case kOatCannotOpen:
+ case kOatDexOutOfDate:
+ break;
}
+
return std::unique_ptr<OatFile>();
}
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_file_manager.cc b/runtime/oat_file_manager.cc
index e419444..f6fb9de 100644
--- a/runtime/oat_file_manager.cc
+++ b/runtime/oat_file_manager.cc
@@ -469,6 +469,9 @@
// Get the oat file on disk.
std::unique_ptr<const OatFile> oat_file(oat_file_assistant.GetBestOatFile().release());
+ VLOG(oat) << "OatFileAssistant(" << dex_location << ").GetBestOatFile()="
+ << reinterpret_cast<uintptr_t>(oat_file.get())
+ << " (executable=" << (oat_file != nullptr ? oat_file->IsExecutable() : false) << ")";
if ((class_loader != nullptr || dex_elements != nullptr) && oat_file != nullptr) {
// Prevent oat files from being loaded if no class_loader or dex_elements are provided.
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..470287b 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"
@@ -161,10 +161,6 @@
.Define({"-XX:EnableHSpaceCompactForOOM", "-XX:DisableHSpaceCompactForOOM"})
.WithValues({true, false})
.IntoKey(M::EnableHSpaceCompactForOOM)
- .Define("-XX:DumpNativeStackOnSigQuit:_")
- .WithType<bool>()
- .WithValueMap({{"false", false}, {"true", true}})
- .IntoKey(M::DumpNativeStackOnSigQuit)
.Define("-XX:MadviseRandomAccess:_")
.WithType<bool>()
.WithValueMap({{"false", false}, {"true", true}})
@@ -735,7 +731,6 @@
UsageMessage(stream, " -XX:BackgroundGC=none\n");
UsageMessage(stream, " -XX:LargeObjectSpace={disabled,map,freelist}\n");
UsageMessage(stream, " -XX:LargeObjectThreshold=N\n");
- UsageMessage(stream, " -XX:DumpNativeStackOnSigQuit=booleanvalue\n");
UsageMessage(stream, " -XX:MadviseRandomAccess:booleanvalue\n");
UsageMessage(stream, " -XX:SlowDebug={false,true}\n");
UsageMessage(stream, " -Xmethod-trace\n");
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..0ca646c 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"
@@ -269,7 +271,6 @@
pending_hidden_api_warning_(false),
dedupe_hidden_api_warnings_(true),
always_set_hidden_api_warning_flag_(false),
- dump_native_stack_on_sig_quit_(true),
pruned_dalvik_cache_(false),
// Initially assume we perceive jank in case the process state is never updated.
process_state_(kProcessStateJankPerceptible),
@@ -621,6 +622,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) {
@@ -1151,7 +1153,6 @@
is_explicit_gc_disabled_ = runtime_options.Exists(Opt::DisableExplicitGC);
dex2oat_enabled_ = runtime_options.GetOrDefault(Opt::Dex2Oat);
image_dex2oat_enabled_ = runtime_options.GetOrDefault(Opt::ImageDex2Oat);
- dump_native_stack_on_sig_quit_ = runtime_options.GetOrDefault(Opt::DumpNativeStackOnSigQuit);
vfprintf_ = runtime_options.GetOrDefault(Opt::HookVfprintf);
exit_ = runtime_options.GetOrDefault(Opt::HookExit);
@@ -2215,7 +2216,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.h b/runtime/runtime.h
index c7f650e..b961e7f 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -651,10 +651,6 @@
safe_mode_ = mode;
}
- bool GetDumpNativeStackOnSigQuit() const {
- return dump_native_stack_on_sig_quit_;
- }
-
bool GetPrunedDalvikCache() const {
return pruned_dalvik_cache_;
}
@@ -1005,9 +1001,6 @@
// when there is a warning. This is only used for testing.
bool always_set_hidden_api_warning_flag_;
- // Whether threads should dump their native stack on SIGQUIT.
- bool dump_native_stack_on_sig_quit_;
-
// Whether the dalvik cache was pruned when initializing the runtime.
bool pruned_dalvik_cache_;
diff --git a/runtime/runtime_common.cc b/runtime/runtime_common.cc
index 59af918..41bfb58 100644
--- a/runtime/runtime_common.cc
+++ b/runtime/runtime_common.cc
@@ -41,7 +41,6 @@
using android::base::StringPrintf;
static constexpr bool kUseSigRTTimeout = true;
-static constexpr bool kDumpNativeStackOnTimeout = true;
const char* GetSignalName(int signal_number) {
switch (signal_number) {
@@ -441,7 +440,7 @@
// Special timeout signal. Try to dump all threads.
// Note: Do not use DumpForSigQuit, as that might disable native unwind, but the native parts
// are of value here.
- runtime->GetThreadList()->Dump(std::cerr, kDumpNativeStackOnTimeout);
+ runtime->GetThreadList()->Dump(std::cerr);
std::cerr << std::endl;
}
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/runtime_options.def b/runtime/runtime_options.def
index 4121ad6..dcb1335 100644
--- a/runtime/runtime_options.def
+++ b/runtime/runtime_options.def
@@ -70,7 +70,6 @@
RUNTIME_OPTIONS_KEY (bool, UseTLAB, (kUseTlab || kUseReadBarrier))
RUNTIME_OPTIONS_KEY (bool, EnableHSpaceCompactForOOM, true)
RUNTIME_OPTIONS_KEY (bool, UseJitCompilation, false)
-RUNTIME_OPTIONS_KEY (bool, DumpNativeStackOnSigQuit, true)
RUNTIME_OPTIONS_KEY (bool, MadviseRandomAccess, false)
RUNTIME_OPTIONS_KEY (unsigned int, JITCompileThreshold)
RUNTIME_OPTIONS_KEY (unsigned int, JITWarmupThreshold)
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..f0bd9aa 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"
@@ -1161,10 +1161,9 @@
<< "]";
}
-void Thread::Dump(std::ostream& os, bool dump_native_stack, BacktraceMap* backtrace_map,
- bool force_dump_stack) const {
+void Thread::Dump(std::ostream& os, BacktraceMap* backtrace_map, bool force_dump_stack) const {
DumpState(os);
- DumpStack(os, dump_native_stack, backtrace_map, force_dump_stack);
+ DumpStack(os, backtrace_map, force_dump_stack);
}
mirror::String* Thread::GetThreadName() const {
@@ -1964,10 +1963,7 @@
}
}
-void Thread::DumpStack(std::ostream& os,
- bool dump_native_stack,
- BacktraceMap* backtrace_map,
- bool force_dump_stack) const {
+void Thread::DumpStack(std::ostream& os, BacktraceMap* backtrace_map, bool force_dump_stack) const {
// TODO: we call this code when dying but may not have suspended the thread ourself. The
// IsSuspended check is therefore racy with the use for dumping (normally we inhibit
// the race with the thread_suspend_count_lock_).
@@ -1980,7 +1976,7 @@
}
if (safe_to_dump || force_dump_stack) {
// If we're currently in native code, dump that stack before dumping the managed stack.
- if (dump_native_stack && (dump_for_abort || force_dump_stack || ShouldShowNativeStack(this))) {
+ if (dump_for_abort || force_dump_stack || ShouldShowNativeStack(this)) {
DumpKernelStack(os, GetTid(), " kernel: ", false);
ArtMethod* method =
GetCurrentMethod(nullptr,
diff --git a/runtime/thread.h b/runtime/thread.h
index 295685e..108fbc7 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"
@@ -207,7 +207,6 @@
// Dumps the detailed thread state and the thread stack (used for SIGQUIT).
void Dump(std::ostream& os,
- bool dump_native_stack = true,
BacktraceMap* backtrace_map = nullptr,
bool force_dump_stack = false) const
REQUIRES(!Locks::thread_suspend_count_lock_)
@@ -1303,7 +1302,6 @@
void DumpState(std::ostream& os) const REQUIRES_SHARED(Locks::mutator_lock_);
void DumpStack(std::ostream& os,
- bool dump_native_stack = true,
BacktraceMap* backtrace_map = nullptr,
bool force_dump_stack = false) const
REQUIRES(!Locks::thread_suspend_count_lock_)
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_list.cc b/runtime/thread_list.cc
index 8095ef5..2e41b9f 100644
--- a/runtime/thread_list.cc
+++ b/runtime/thread_list.cc
@@ -152,9 +152,8 @@
suspend_all_historam_.PrintConfidenceIntervals(os, 0.99, data); // Dump time to suspend.
}
}
- bool dump_native_stack = Runtime::Current()->GetDumpNativeStackOnSigQuit();
- Dump(os, dump_native_stack);
- DumpUnattachedThreads(os, dump_native_stack && kDumpUnattachedThreadNativeStackForSigQuit);
+ Dump(os);
+ DumpUnattachedThreads(os, kDumpUnattachedThreadNativeStackForSigQuit);
}
static void DumpUnattachedThread(std::ostream& os, pid_t tid, bool dump_native_stack)
@@ -201,11 +200,10 @@
// A closure used by Thread::Dump.
class DumpCheckpoint FINAL : public Closure {
public:
- DumpCheckpoint(std::ostream* os, bool dump_native_stack)
+ explicit DumpCheckpoint(std::ostream* os)
: os_(os),
barrier_(0),
- backtrace_map_(dump_native_stack ? BacktraceMap::Create(getpid()) : nullptr),
- dump_native_stack_(dump_native_stack) {
+ backtrace_map_(BacktraceMap::Create(getpid())) {
if (backtrace_map_ != nullptr) {
backtrace_map_->SetSuffixesToIgnore(std::vector<std::string> { "oat", "odex" });
}
@@ -219,7 +217,7 @@
std::ostringstream local_os;
{
ScopedObjectAccess soa(self);
- thread->Dump(local_os, dump_native_stack_, backtrace_map_.get());
+ thread->Dump(local_os, backtrace_map_.get());
}
{
// Use the logging lock to ensure serialization when writing to the common ostream.
@@ -247,18 +245,16 @@
Barrier barrier_;
// A backtrace map, so that all threads use a shared info and don't reacquire/parse separately.
std::unique_ptr<BacktraceMap> backtrace_map_;
- // Whether we should dump the native stack.
- const bool dump_native_stack_;
};
-void ThreadList::Dump(std::ostream& os, bool dump_native_stack) {
+void ThreadList::Dump(std::ostream& os) {
Thread* self = Thread::Current();
{
MutexLock mu(self, *Locks::thread_list_lock_);
os << "DALVIK THREADS (" << list_.size() << "):\n";
}
if (self != nullptr) {
- DumpCheckpoint checkpoint(&os, dump_native_stack);
+ DumpCheckpoint checkpoint(&os);
size_t threads_running_checkpoint;
{
// Use SOA to prevent deadlocks if multiple threads are calling Dump() at the same time.
@@ -269,7 +265,7 @@
checkpoint.WaitForThreadsToRunThroughCheckpoint(threads_running_checkpoint);
}
} else {
- DumpUnattachedThreads(os, dump_native_stack);
+ DumpUnattachedThreads(os, /* dump_native_stack */ true);
}
}
@@ -491,7 +487,6 @@
// Found a runnable thread that hasn't responded to the empty checkpoint request.
// Assume it's stuck and safe to dump its stack.
thread->Dump(LOG_STREAM(FATAL_WITHOUT_ABORT),
- /*dump_native_stack*/ true,
/*backtrace_map*/ nullptr,
/*force_dump_stack*/ true);
}
diff --git a/runtime/thread_list.h b/runtime/thread_list.h
index 895c1a4..09b10d2 100644
--- a/runtime/thread_list.h
+++ b/runtime/thread_list.h
@@ -57,7 +57,7 @@
void DumpForSigQuit(std::ostream& os)
REQUIRES(!Locks::thread_list_lock_, !Locks::mutator_lock_);
// For thread suspend timeout dumps.
- void Dump(std::ostream& os, bool dump_native_stack = true)
+ void Dump(std::ostream& os)
REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
pid_t GetLockOwner(); // For SignalCatcher.
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/001-HelloWorld/src/Main.java b/test/001-HelloWorld/src/Main.java
index 1ef6289..401e852 100644
--- a/test/001-HelloWorld/src/Main.java
+++ b/test/001-HelloWorld/src/Main.java
@@ -14,8 +14,37 @@
* limitations under the License.
*/
+import java.util.concurrent.*;
+
+interface I {
+}
+
+class A implements I {
+ static int x = (int)(10*Math.random()); // Suppress initialization.
+}
+
public class Main {
- public static void main(String[] args) {
- System.out.println("Hello, world!");
+ public static void main(String[] args) throws Exception {
+
+ final CountDownLatch first = new CountDownLatch(1);
+ final CountDownLatch second = new CountDownLatch(1);
+
+ new Thread(new Runnable() {
+ public void run() {
+ try {
+ synchronized(I.class) {
+ first.countDown();
+ second.await();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }).start();
+
+ first.await();
+ new A();
+ second.countDown();
+ System.out.println("Hello, world!");
}
}
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/170-interface-init/expected.txt b/test/170-interface-init/expected.txt
new file mode 100644
index 0000000..619c561
--- /dev/null
+++ b/test/170-interface-init/expected.txt
@@ -0,0 +1 @@
+Done.
diff --git a/test/170-interface-init/info.txt b/test/170-interface-init/info.txt
new file mode 100644
index 0000000..28401ad
--- /dev/null
+++ b/test/170-interface-init/info.txt
@@ -0,0 +1,2 @@
+Check that holding a lock on an interface class does not block initialization of an
+implementing class.
diff --git a/test/170-interface-init/src/Main.java b/test/170-interface-init/src/Main.java
new file mode 100644
index 0000000..62f6c5c
--- /dev/null
+++ b/test/170-interface-init/src/Main.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+import java.util.concurrent.CountDownLatch;
+
+interface I {
+}
+
+class A implements I {
+ static int x = (int)(10*Math.random()); // Suppress compile-time initialization.
+}
+
+public class Main {
+ public static void main(String[] args) throws Exception {
+ final CountDownLatch first = new CountDownLatch(1);
+ final CountDownLatch second = new CountDownLatch(1);
+
+ new Thread(new Runnable() {
+ public void run() {
+ try {
+ synchronized(I.class) {
+ first.countDown();
+ second.await();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }).start();
+
+ first.await();
+ new A(); // Will initialize A.
+ second.countDown();
+
+ System.out.println("Done.");
+ }
+}
diff --git a/test/562-checker-no-intermediate/src/Main.java b/test/562-checker-no-intermediate/src/Main.java
index 104ba8b..d61a9b1 100644
--- a/test/562-checker-no-intermediate/src/Main.java
+++ b/test/562-checker-no-intermediate/src/Main.java
@@ -26,7 +26,7 @@
/// CHECK-DAG: <<Array:l\d+>> NullCheck
/// CHECK-DAG: <<Index:i\d+>> BoundsCheck
/// CHECK-DAG: <<ArrayGet:i\d+>> ArrayGet [<<Array>>,<<Index>>]
- /// CHECK-DAG: <<AbsM42:i\d+>> InvokeStaticOrDirect [<<ConstM42>>] intrinsic:MathAbsInt
+ /// CHECK-DAG: <<AbsM42:i\d+>> InvokeStaticOrDirect [<<ConstM42>>{{(,[ij]\d+)?}}] method_name:Main.$noinline$abs
/// CHECK-DAG: <<Add:i\d+>> Add [<<ArrayGet>>,<<AbsM42>>]
/// CHECK-DAG: ArraySet [<<Array>>,<<Index>>,<<Add>>]
@@ -37,7 +37,7 @@
/// CHECK-DAG: <<Index:i\d+>> BoundsCheck
/// CHECK-DAG: <<Address1:i\d+>> IntermediateAddress [<<Array>>,<<DataOffset>>]
/// CHECK-DAG: <<ArrayGet:i\d+>> ArrayGet [<<Address1>>,<<Index>>]
- /// CHECK-DAG: <<AbsM42:i\d+>> InvokeStaticOrDirect [<<ConstM42>>] intrinsic:MathAbsInt
+ /// CHECK-DAG: <<AbsM42:i\d+>> InvokeStaticOrDirect [<<ConstM42>>{{(,[ij]\d+)?}}] method_name:Main.$noinline$abs
/// CHECK-DAG: <<Add:i\d+>> Add [<<ArrayGet>>,<<AbsM42>>]
/// CHECK-DAG: <<Address2:i\d+>> IntermediateAddress [<<Array>>,<<DataOffset>>]
/// CHECK-DAG: ArraySet [<<Address2>>,<<Index>>,<<Add>>]
@@ -49,7 +49,7 @@
/// CHECK-DAG: <<Index:i\d+>> BoundsCheck
/// CHECK-DAG: <<Address1:i\d+>> IntermediateAddress [<<Array>>,<<DataOffset>>]
/// CHECK-DAG: <<ArrayGet:i\d+>> ArrayGet [<<Address1>>,<<Index>>]
- /// CHECK-DAG: <<AbsM42:i\d+>> InvokeStaticOrDirect [<<ConstM42>>] intrinsic:MathAbsInt
+ /// CHECK-DAG: <<AbsM42:i\d+>> InvokeStaticOrDirect [<<ConstM42>>{{(,[ij]\d+)?}}] method_name:Main.$noinline$abs
/// CHECK-DAG: <<Add:i\d+>> Add [<<ArrayGet>>,<<AbsM42>>]
/// CHECK-DAG: <<Address2:i\d+>> IntermediateAddress [<<Array>>,<<DataOffset>>]
/// CHECK-DAG: ArraySet [<<Address2>>,<<Index>>,<<Add>>]
@@ -60,7 +60,7 @@
/// CHECK-DAG: <<Array:l\d+>> NullCheck
/// CHECK-DAG: <<Index:i\d+>> BoundsCheck
/// CHECK-DAG: <<ArrayGet:i\d+>> ArrayGet [<<Array>>,<<Index>>]
- /// CHECK-DAG: <<AbsM42:i\d+>> InvokeStaticOrDirect [<<ConstM42>>] intrinsic:MathAbsInt
+ /// CHECK-DAG: <<AbsM42:i\d+>> InvokeStaticOrDirect [<<ConstM42>>{{(,[ij]\d+)?}}] method_name:Main.$noinline$abs
/// CHECK-DAG: <<Add:i\d+>> Add [<<ArrayGet>>,<<AbsM42>>]
/// CHECK-DAG: ArraySet [<<Array>>,<<Index>>,<<Add>>]
@@ -71,7 +71,7 @@
/// CHECK-DAG: <<Index:i\d+>> BoundsCheck
/// CHECK-DAG: <<Address1:i\d+>> IntermediateAddress [<<Array>>,<<DataOffset>>]
/// CHECK-DAG: <<ArrayGet:i\d+>> ArrayGet [<<Address1>>,<<Index>>]
- /// CHECK-DAG: <<AbsM42:i\d+>> InvokeStaticOrDirect [<<ConstM42>>] intrinsic:MathAbsInt
+ /// CHECK-DAG: <<AbsM42:i\d+>> InvokeStaticOrDirect [<<ConstM42>>{{(,[ij]\d+)?}}] method_name:Main.$noinline$abs
/// CHECK-DAG: <<Add:i\d+>> Add [<<ArrayGet>>,<<AbsM42>>]
/// CHECK-DAG: <<Address2:i\d+>> IntermediateAddress [<<Array>>,<<DataOffset>>]
/// CHECK-DAG: ArraySet [<<Address2>>,<<Index>>,<<Add>>]
@@ -83,13 +83,17 @@
/// CHECK-DAG: <<Index:i\d+>> BoundsCheck
/// CHECK-DAG: <<Address1:i\d+>> IntermediateAddress [<<Array>>,<<DataOffset>>]
/// CHECK-DAG: <<ArrayGet:i\d+>> ArrayGet [<<Address1>>,<<Index>>]
- /// CHECK-DAG: <<AbsM42:i\d+>> InvokeStaticOrDirect [<<ConstM42>>] intrinsic:MathAbsInt
+ /// CHECK-DAG: <<AbsM42:i\d+>> InvokeStaticOrDirect [<<ConstM42>>{{(,[ij]\d+)?}}] method_name:Main.$noinline$abs
/// CHECK-DAG: <<Add:i\d+>> Add [<<ArrayGet>>,<<AbsM42>>]
/// CHECK-DAG: <<Address2:i\d+>> IntermediateAddress [<<Array>>,<<DataOffset>>]
/// CHECK-DAG: ArraySet [<<Address2>>,<<Index>>,<<Add>>]
public static void main(String[] args) {
- array[index] += Math.abs(-42);
+ array[index] += $noinline$abs(-42);
+ }
+
+ public static int $noinline$abs(int value) {
+ return Math.abs(value);
}
static int index = 0;
diff --git a/test/631-checker-fp-abs/src/Main.java b/test/631-checker-fp-abs/src/Main.java
index 0f85dc6..2db93b8 100644
--- a/test/631-checker-fp-abs/src/Main.java
+++ b/test/631-checker-fp-abs/src/Main.java
@@ -23,6 +23,9 @@
*/
public class Main {
+ private final static boolean isDalvik =
+ System.getProperty("java.vm.name").equals("Dalvik");
+
private static final int SPQUIET = 1 << 22;
private static final long DPQUIET = 1L << 51;
@@ -73,13 +76,16 @@
// A few NaN numbers.
int[] spnans = {
- 0x7f800001,
+ 0x7f800001, // signaling
0x7fa00000,
- 0x7fc00000,
+ 0x7fbfffff,
+ 0x7fc00000, // quiet
+ 0x7fc00001,
0x7fffffff,
- 0xff800001,
+ 0xff800001, // signaling
0xffa00000,
- 0xffc00000,
+ 0xffbfffff,
+ 0xffc00000, // quiet
0xffffffff
};
for (int i = 0; i < spnans.length; i++) {
@@ -142,6 +148,13 @@
// We allow that an expected NaN result has become quiet.
private static void expectEqualsNaN32(int expected, int result) {
if (expected != result && (expected | SPQUIET) != result) {
+ if (!isDalvik) {
+ // If not on ART, relax the expected value more towards just
+ // "spec compliance" and allow sign bit to remain set for NaN.
+ if (expected == (result & Integer.MAX_VALUE)) {
+ return;
+ }
+ }
throw new Error("Expected: 0x" + Integer.toHexString(expected)
+ ", found: 0x" + Integer.toHexString(result));
}
@@ -157,6 +170,13 @@
// We allow that an expected NaN result has become quiet.
private static void expectEqualsNaN64(long expected, long result) {
if (expected != result && (expected | DPQUIET) != result) {
+ if (!isDalvik) {
+ // If not on ART, relax the expected value more towards just
+ // "spec compliance" and allow sign bit to remain set for NaN.
+ if (expected == (result & Long.MAX_VALUE)) {
+ return;
+ }
+ }
throw new Error("Expected: 0x" + Long.toHexString(expected)
+ ", found: 0x" + Long.toHexString(result));
}
diff --git a/test/645-checker-abs-simd/src/Main.java b/test/645-checker-abs-simd/src/Main.java
index 4c69e58..870a403 100644
--- a/test/645-checker-abs-simd/src/Main.java
+++ b/test/645-checker-abs-simd/src/Main.java
@@ -19,6 +19,9 @@
*/
public class Main {
+ private final static boolean isDalvik =
+ System.getProperty("java.vm.name").equals("Dalvik");
+
private static final int SPQUIET = 1 << 22;
private static final long DPQUIET = 1L << 51;
@@ -378,6 +381,13 @@
// We allow that an expected NaN result has become quiet.
private static void expectEqualsNaN32(int expected, int result) {
if (expected != result && (expected | SPQUIET) != result) {
+ if (!isDalvik) {
+ // If not on ART, relax the expected value more towards just
+ // "spec compliance" and allow sign bit to remain set for NaN.
+ if (expected == (result & Integer.MAX_VALUE)) {
+ return;
+ }
+ }
throw new Error("Expected: 0x" + Integer.toHexString(expected)
+ ", found: 0x" + Integer.toHexString(result));
}
@@ -386,6 +396,13 @@
// We allow that an expected NaN result has become quiet.
private static void expectEqualsNaN64(long expected, long result) {
if (expected != result && (expected | DPQUIET) != result) {
+ if (!isDalvik) {
+ // If not on ART, relax the expected value more towards just
+ // "spec compliance" and allow sign bit to remain set for NaN.
+ if (expected == (result & Long.MAX_VALUE)) {
+ return;
+ }
+ }
throw new Error("Expected: 0x" + Long.toHexString(expected)
+ ", found: 0x" + Long.toHexString(result));
}
diff --git a/test/715-clinit-implicit-parameter-annotations/build b/test/715-clinit-implicit-parameter-annotations/build
new file mode 100644
index 0000000..4753c8c
--- /dev/null
+++ b/test/715-clinit-implicit-parameter-annotations/build
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# Copyright 2018 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.
+
+# Make us exit on a failure
+set -e
+
+# Always use D8 as DX does not support propagating parameter name and
+# access_flag information.
+export USE_D8=true
+
+./default-build "$@" --experimental parameter-annotations
diff --git a/test/715-clinit-implicit-parameter-annotations/expected.txt b/test/715-clinit-implicit-parameter-annotations/expected.txt
new file mode 100644
index 0000000..357eb62
--- /dev/null
+++ b/test/715-clinit-implicit-parameter-annotations/expected.txt
@@ -0,0 +1,113 @@
+Main
+ public Main()
+Main$1LocalClassStaticContext
+ Main$1LocalClassStaticContext(int)
+ Parameter [0]: Indexed : @Main$AnnotationA()
+ Array : @Main$AnnotationA()
+ Main$AnnotationA Yes
+ @Main$AnnotationA()
+ Main$AnnotationB No
+Main$1LocalClassStaticContextWithCapture
+ Main$1LocalClassStaticContextWithCapture(java.lang.String,long)
+ Parameter [0]: Indexed : @Main$AnnotationA()
+ Array : @Main$AnnotationA()
+ Main$AnnotationA Yes
+ @Main$AnnotationA()
+ Main$AnnotationB No
+Main$1LocalClassStaticContextWithCaptureAlternateOrdering
+ Main$1LocalClassStaticContextWithCaptureAlternateOrdering(java.lang.String,long)
+ Parameter [0]: Indexed : @Main$AnnotationA()
+ Array : @Main$AnnotationA()
+ Main$AnnotationA Yes
+ @Main$AnnotationA()
+ Main$AnnotationB No
+Main$1LocalClass
+ Main$1LocalClass(Main,int)
+ Parameter [0]: Indexed : @Main$AnnotationA()
+ Array : @Main$AnnotationA()
+ Main$AnnotationA Yes
+ @Main$AnnotationA()
+ Main$AnnotationB No
+Main$1LocalClassWithCapture
+ Main$1LocalClassWithCapture(Main,java.lang.String,long)
+ Parameter [0]: Indexed : @Main$AnnotationA()
+ Array : @Main$AnnotationA()
+ Main$AnnotationA Yes
+ @Main$AnnotationA()
+ Main$AnnotationB No
+Main$Inner
+ Main$Inner(Main,int,java.lang.String)
+ Parameter [0]: Main$AnnotationA No
+ Main$AnnotationB No
+ Parameter [1]: Indexed : @Main$AnnotationA()
+ Array : @Main$AnnotationA()
+ Main$AnnotationA Yes
+ @Main$AnnotationA()
+ Main$AnnotationB No
+ Parameter [2]: Main$AnnotationA No
+ Main$AnnotationB No
+ Main$Inner(Main,int,java.lang.String,boolean)
+ Parameter [0]: Main$AnnotationA No
+ Main$AnnotationB No
+ Parameter [1]: Indexed : @Main$AnnotationA()
+ Array : @Main$AnnotationA()
+ Main$AnnotationA Yes
+ @Main$AnnotationA()
+ Main$AnnotationB No
+ Parameter [2]: Main$AnnotationA No
+ Main$AnnotationB No
+ Parameter [3]: Indexed : @Main$AnnotationB(value=x)
+ Array : @Main$AnnotationB(value=x)
+ Main$AnnotationA No
+ Main$AnnotationB Yes
+ @Main$AnnotationB(value=x)
+Main$StaticInner
+ Main$StaticInner(int,java.lang.String)
+ Parameter [0]: Indexed : @Main$AnnotationA()
+ Array : @Main$AnnotationA()
+ Main$AnnotationA Yes
+ @Main$AnnotationA()
+ Main$AnnotationB No
+ Parameter [1]: Main$AnnotationA No
+ Main$AnnotationB No
+ Main$StaticInner(int,java.lang.String,boolean)
+ Parameter [0]: Indexed : @Main$AnnotationB(value=foo)
+ Array : @Main$AnnotationB(value=foo)
+ Main$AnnotationA No
+ Main$AnnotationB Yes
+ @Main$AnnotationB(value=foo)
+ Parameter [1]: Main$AnnotationA No
+ Main$AnnotationB No
+ Parameter [2]: Indexed : @Main$AnnotationA()
+ Array : @Main$AnnotationA()
+ Main$AnnotationA Yes
+ @Main$AnnotationA()
+ Main$AnnotationB No
+Main$ImportantNumber
+ private Main$ImportantNumber(java.lang.String,int,double)
+ Parameter [0]: Indexed : @Main$AnnotationA()
+ Array : @Main$AnnotationA()
+ Main$AnnotationA Yes
+ @Main$AnnotationA()
+ Main$AnnotationB No
+ private Main$ImportantNumber(java.lang.String,int,double,boolean)
+ Parameter [0]: Indexed : @Main$AnnotationB(value=x)
+ Array : @Main$AnnotationB(value=x)
+ Main$AnnotationA No
+ Main$AnnotationB Yes
+ @Main$AnnotationB(value=x)
+ Parameter [1]: Indexed : @Main$AnnotationB(value=y)
+ Array : @Main$AnnotationB(value=y)
+ Main$AnnotationA No
+ Main$AnnotationB Yes
+ @Main$AnnotationB(value=y)
+Main$BinaryNumber
+ private Main$BinaryNumber(java.lang.String,int)
+ Parameter [0]: Main$AnnotationA No
+ Main$AnnotationB No
+ Parameter [1]: Main$AnnotationA No
+ Main$AnnotationB No
+Main$1
+ Main$1(java.lang.String)
+ Parameter [0]: Main$AnnotationA No
+ Main$AnnotationB No
diff --git a/test/715-clinit-implicit-parameter-annotations/info.txt b/test/715-clinit-implicit-parameter-annotations/info.txt
new file mode 100644
index 0000000..31afd62
--- /dev/null
+++ b/test/715-clinit-implicit-parameter-annotations/info.txt
@@ -0,0 +1,5 @@
+Tests ART synthesizes parameter annotations for implicit parameters on
+constructors. Inner class and enum constructors may have implicit
+parameters. If the constructor has parameter annotations, the implicit
+parameters may not have annotations in the DEX file, but code that
+looks at these annotations will expect them to.
diff --git a/test/715-clinit-implicit-parameter-annotations/src/Main.java b/test/715-clinit-implicit-parameter-annotations/src/Main.java
new file mode 100644
index 0000000..351e3a9
--- /dev/null
+++ b/test/715-clinit-implicit-parameter-annotations/src/Main.java
@@ -0,0 +1,215 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Parameter;
+
+public class Main {
+ // A simple parameter annotation
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface AnnotationA {}
+
+ // A parameter annotation with additional state
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface AnnotationB {
+ String value() default "default-value";
+ }
+
+ // An inner class whose constructors with have an implicit
+ // argument for the enclosing instance.
+ public class Inner {
+ private final int number;
+ private final String text;
+ boolean flag;
+
+ Inner(@AnnotationA int number, String text) {
+ this.number = number;
+ this.text = text;
+ this.flag = false;
+ }
+
+ Inner(@AnnotationA int number, String text, @AnnotationB("x") boolean flag) {
+ this.number = number;
+ this.text = text;
+ this.flag = flag;
+ }
+ }
+
+ // An inner class whose constructors with have no implicit
+ // arguments for the enclosing instance.
+ public static class StaticInner {
+ private final int number;
+ private final String text;
+ boolean flag;
+
+ StaticInner(@AnnotationA int number, String text) {
+ this.number = number;
+ this.text = text;
+ this.flag = false;
+ }
+
+ StaticInner(@AnnotationB("foo") int number, String text, @AnnotationA boolean flag) {
+ this.number = number;
+ this.text = text;
+ this.flag = flag;
+ }
+ }
+
+ public enum ImportantNumber {
+ ONE(1.0),
+ TWO(2.0),
+ MANY(3.0, true);
+
+ private double doubleValue;
+ private boolean isLarge;
+
+ ImportantNumber(@AnnotationA double doubleValue) {
+ this.doubleValue = doubleValue;
+ this.isLarge = false;
+ }
+
+ ImportantNumber(@AnnotationB("x") double doubleValue, @AnnotationB("y") boolean isLarge) {
+ this.doubleValue = doubleValue;
+ this.isLarge = isLarge;
+ }
+ }
+
+ public enum BinaryNumber {
+ ZERO,
+ ONE;
+ }
+
+ private abstract static class AnonymousBase {
+ public AnonymousBase(@AnnotationA String s) {}
+ }
+
+ private static String annotationToNormalizedString(Annotation annotation) {
+ // String.replace() to accomodate different representation across VMs.
+ return annotation.toString().replace("\"", "");
+ }
+
+ private static void DumpConstructorParameterAnnotations(Class<?> cls) throws Throwable {
+ System.out.println(cls.getName());
+ for (Constructor c : cls.getDeclaredConstructors()) {
+ System.out.println(" " + c);
+ Annotation[][] annotations = c.getParameterAnnotations();
+ Parameter[] parameters = c.getParameters();
+ for (int i = 0; i < annotations.length; ++i) {
+ // Exercise java.lang.reflect.Executable.getParameterAnnotationsNative()
+ // which retrieves all annotations for the parameters.
+ System.out.print(" Parameter [" + i + "]:");
+ for (Annotation annotation : parameters[i].getAnnotations()) {
+ System.out.println(" Indexed : " + annotationToNormalizedString(annotation));
+ }
+ for (Annotation annotation : annotations[i]) {
+ System.out.println(" Array : " + annotationToNormalizedString(annotation));
+ }
+
+ // Exercise Parameter.getAnnotationNative() with
+ // retrieves a single parameter annotation according to type.
+ Object[] opaqueClasses = new Object[] {AnnotationA.class, AnnotationB.class};
+ for (Object opaqueClass : opaqueClasses) {
+ @SuppressWarnings("unchecked")
+ Class<? extends Annotation> annotationClass =
+ (Class<? extends Annotation>) opaqueClass;
+ Annotation annotation = parameters[i].getDeclaredAnnotation(annotationClass);
+ String hasAnnotation = (annotation != null ? "Yes" : "No");
+ System.out.println(" " + annotationClass.getName() + " " + hasAnnotation);
+
+ Annotation[] parameterAnnotations = parameters[i].getDeclaredAnnotationsByType(annotationClass);
+ for (Annotation parameterAnnotation : parameterAnnotations) {
+ System.out.println(" " + annotationToNormalizedString(parameterAnnotation));
+ }
+ }
+ }
+ }
+ }
+
+ private Class<?> getLocalClassWithEnclosingInstanceCapture() {
+ class LocalClass {
+ private final int integerValue;
+
+ LocalClass(@AnnotationA int integerValue) {
+ this.integerValue = integerValue;
+ }
+ }
+ return LocalClass.class;
+ }
+
+ private Class<?> getLocalClassWithEnclosingInstanceAndLocalCapture() {
+ final long CAPTURED_VALUE = System.currentTimeMillis();
+ class LocalClassWithCapture {
+ private final String value;
+ private final long capturedValue;
+
+ LocalClassWithCapture(@AnnotationA String p1) {
+ this.value = p1;
+ this.capturedValue = CAPTURED_VALUE;
+ }
+ }
+ return LocalClassWithCapture.class;
+ }
+
+ public static void main(String[] args) throws Throwable {
+ // A local class declared in a static context (0 implicit parameters).
+ class LocalClassStaticContext {
+ private final int value;
+
+ LocalClassStaticContext(@AnnotationA int p0) {
+ this.value = p0;
+ }
+ }
+
+ final long CAPTURED_VALUE = System.currentTimeMillis();
+ // A local class declared in a static context with a capture (1 implicit parameters).
+ class LocalClassStaticContextWithCapture {
+ private final long capturedValue;
+ private final String argumentValue;
+
+ LocalClassStaticContextWithCapture(@AnnotationA String p1) {
+ this.capturedValue = CAPTURED_VALUE;
+ this.argumentValue = p1;
+ }
+ }
+
+ // Another local class declared in a static context with a capture (1 implicit parameters).
+ class LocalClassStaticContextWithCaptureAlternateOrdering {
+ private final String argumentValue;
+ private final long capturedValue;
+
+ LocalClassStaticContextWithCaptureAlternateOrdering(@AnnotationA String p1) {
+ this.argumentValue = p1;
+ this.capturedValue = CAPTURED_VALUE;
+ }
+ }
+
+ DumpConstructorParameterAnnotations(Main.class);
+ DumpConstructorParameterAnnotations(LocalClassStaticContext.class);
+ DumpConstructorParameterAnnotations(LocalClassStaticContextWithCapture.class);
+ DumpConstructorParameterAnnotations(LocalClassStaticContextWithCaptureAlternateOrdering.class);
+ Main m = new Main();
+ DumpConstructorParameterAnnotations(m.getLocalClassWithEnclosingInstanceCapture());
+ DumpConstructorParameterAnnotations(m.getLocalClassWithEnclosingInstanceAndLocalCapture());
+ DumpConstructorParameterAnnotations(Inner.class);
+ DumpConstructorParameterAnnotations(StaticInner.class);
+ DumpConstructorParameterAnnotations(ImportantNumber.class);
+ DumpConstructorParameterAnnotations(BinaryNumber.class);
+ DumpConstructorParameterAnnotations(new AnonymousBase("") {}.getClass());
+ }
+}
diff --git a/test/etc/default-build b/test/etc/default-build
index 4ed2af6..3e6577c 100755
--- a/test/etc/default-build
+++ b/test/etc/default-build
@@ -137,12 +137,14 @@
JAVAC_EXPERIMENTAL_ARGS["default-methods"]="-source 1.8 -target 1.8"
JAVAC_EXPERIMENTAL_ARGS["lambdas"]="-source 1.8 -target 1.8"
JAVAC_EXPERIMENTAL_ARGS["method-handles"]="-source 1.8 -target 1.8"
+JAVAC_EXPERIMENTAL_ARGS["parameter-annotations"]="-source 1.8 -target 1.8"
JAVAC_EXPERIMENTAL_ARGS["var-handles"]="-source 1.8 -target 1.8"
JAVAC_EXPERIMENTAL_ARGS[${DEFAULT_EXPERIMENT}]="-source 1.8 -target 1.8"
JAVAC_EXPERIMENTAL_ARGS["agents"]="-source 1.8 -target 1.8"
declare -A DX_EXPERIMENTAL_ARGS
DX_EXPERIMENTAL_ARGS["method-handles"]="--min-sdk-version=26"
+DX_EXPERIMENTAL_ARGS["parameter-annotations"]="--min-sdk-version=25"
DX_EXPERIMENTAL_ARGS["var-handles"]="--min-sdk-version=26"
while true; do
diff --git a/test/etc/run-test-jar b/test/etc/run-test-jar
index b8427f4..43684f8 100755
--- a/test/etc/run-test-jar
+++ b/test/etc/run-test-jar
@@ -775,9 +775,6 @@
TMP_DIR_OPTION="-Djava.io.tmpdir=/data/local/tmp"
fi
-# We set DumpNativeStackOnSigQuit to false to avoid stressing libunwind.
-# b/27185632
-# b/24664297
dalvikvm_cmdline="$INVOKE_WITH $GDB $ANDROID_ROOT/bin/$DALVIKVM \
$GDB_ARGS \
$FLAGS \
@@ -792,7 +789,6 @@
$DEBUGGER_OPTS \
$DALVIKVM_BOOT_OPT \
$TMP_DIR_OPTION \
- -XX:DumpNativeStackOnSigQuit:false \
-cp $DEX_LOCATION/$TEST_NAME.jar$SECONDARY_DEX $MAIN $ARGS"
# Remove whitespace.
@@ -812,6 +808,25 @@
fi
RUN_TEST_ASAN_OPTIONS="${RUN_TEST_ASAN_OPTIONS}detect_leaks=0"
+# For running, we must turn off logging when dex2oat or patchoat are missing. Otherwise we use
+# the same defaults as for prebuilt: everything when --dev, otherwise errors and above only.
+if [ "$EXTERNAL_LOG_TAGS" = "n" ]; then
+ if [ "$DEV_MODE" = "y" ]; then
+ export ANDROID_LOG_TAGS='*:d'
+ elif [ "$USE_DEX2OAT_AND_PATCHOAT" = "n" ]; then
+ # All tests would log the error of failing dex2oat/patchoat. Be silent here and only
+ # log fatal events.
+ export ANDROID_LOG_TAGS='*:s'
+ elif [ "$HAVE_IMAGE" = "n" ]; then
+ # All tests would log the error of missing image. Be silent here and only log fatal
+ # events.
+ export ANDROID_LOG_TAGS='*:s'
+ else
+ # We are interested in LOG(ERROR) output.
+ export ANDROID_LOG_TAGS='*:e'
+ fi
+fi
+
if [ "$HOST" = "n" ]; then
adb root > /dev/null
adb wait-for-device
@@ -862,6 +877,7 @@
export ANDROID_ADDITIONAL_PUBLIC_LIBRARIES=$PUBLIC_LIBS && \
export DEX_LOCATION=$DEX_LOCATION && \
export ANDROID_ROOT=$ANDROID_ROOT && \
+ export ANDROID_LOG_TAGS=$ANDROID_LOG_TAGS && \
rm -rf ${DEX_LOCATION}/dalvik-cache/ && \
mkdir -p ${mkdir_locations} && \
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH && \
@@ -899,16 +915,6 @@
# Host run.
export ANDROID_PRINTF_LOG=brief
- # By default, and for prebuild dex2oat, we are interested in errors being logged. In dev mode
- # we want debug messages.
- if [ "$EXTERNAL_LOG_TAGS" = "n" ]; then
- if [ "$DEV_MODE" = "y" ]; then
- export ANDROID_LOG_TAGS='*:d'
- else
- export ANDROID_LOG_TAGS='*:e'
- fi
- fi
-
export ANDROID_DATA="$DEX_LOCATION"
export ANDROID_ROOT="${ANDROID_ROOT}"
export LD_LIBRARY_PATH="${ANDROID_ROOT}/${LIBRARY_DIRECTORY}:${ANDROID_ROOT}/${TEST_DIRECTORY}"
@@ -969,25 +975,6 @@
$strip_cmdline || { echo "Strip failed." >&2 ; exit 3; }
$sync_cmdline || { echo "Sync failed." >&2 ; exit 4; }
- # For running, we must turn off logging when dex2oat or patchoat are missing. Otherwise we use
- # the same defaults as for prebuilt: everything when --dev, otherwise errors and above only.
- if [ "$EXTERNAL_LOG_TAGS" = "n" ]; then
- if [ "$DEV_MODE" = "y" ]; then
- export ANDROID_LOG_TAGS='*:d'
- elif [ "$USE_DEX2OAT_AND_PATCHOAT" = "n" ]; then
- # All tests would log the error of failing dex2oat/patchoat. Be silent here and only
- # log fatal events.
- export ANDROID_LOG_TAGS='*:s'
- elif [ "$HAVE_IMAGE" = "n" ]; then
- # All tests would log the error of missing image. Be silent here and only log fatal
- # events.
- export ANDROID_LOG_TAGS='*:s'
- else
- # We are interested in LOG(ERROR) output.
- export ANDROID_LOG_TAGS='*:e'
- fi
- fi
-
if [ "$DRY_RUN" = "y" ]; then
exit 0
fi
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 {