summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Android.mk1
-rw-r--r--build/Android.gtest.mk2
-rw-r--r--compiler/optimizing/intrinsics_arm64.cc8
-rw-r--r--compiler/optimizing/intrinsics_arm_vixl.cc8
-rw-r--r--compiler/optimizing/intrinsics_mips.cc8
-rw-r--r--compiler/optimizing/intrinsics_mips64.cc8
-rw-r--r--compiler/optimizing/intrinsics_x86.cc7
-rw-r--r--compiler/optimizing/intrinsics_x86_64.cc8
-rw-r--r--compiler/utils/atomic_dex_ref_map-inl.h3
-rw-r--r--libdexfile/dex/dex_file.cc3
-rw-r--r--libdexfile/dex/dex_file.h11
-rw-r--r--libdexfile/dex/hidden_api_access_flags.h1
-rw-r--r--openjdkjvmti/fixed_up_dex_file.cc12
-rw-r--r--openjdkjvmti/ti_stack.cc4
-rw-r--r--runtime/Android.bp2
-rw-r--r--runtime/base/file_utils.cc17
-rw-r--r--runtime/base/file_utils.h3
-rw-r--r--runtime/base/quasi_atomic.h12
-rw-r--r--runtime/class_linker.cc15
-rw-r--r--runtime/debugger.cc15
-rw-r--r--runtime/dex/art_dex_file_loader.cc36
-rw-r--r--runtime/dex/art_dex_file_loader.h13
-rw-r--r--runtime/dex/art_dex_file_loader_test.cc90
-rw-r--r--runtime/gc/collector/concurrent_copying.cc15
-rw-r--r--runtime/gc/heap.cc22
-rw-r--r--runtime/gc/heap.h2
-rw-r--r--runtime/hidden_api.cc172
-rw-r--r--runtime/hidden_api.h152
-rw-r--r--runtime/hidden_api_test.cc275
-rw-r--r--runtime/image.cc2
-rw-r--r--runtime/interpreter/interpreter_intrinsics.cc13
-rw-r--r--runtime/interpreter/unstarted_runtime.cc3
-rw-r--r--runtime/intrinsics_list.h1
-rw-r--r--runtime/jit/jit_code_cache.cc2
-rw-r--r--runtime/jni_internal.cc9
-rw-r--r--runtime/mirror/class-inl.h1
-rw-r--r--runtime/monitor.cc2
-rw-r--r--runtime/native/dalvik_system_VMRuntime.cc16
-rw-r--r--runtime/native/dalvik_system_ZygoteHooks.cc1
-rw-r--r--runtime/native/java_lang_Class.cc10
-rw-r--r--runtime/native/sun_misc_Unsafe.cc6
-rw-r--r--runtime/native_stack_dump.cc3
-rw-r--r--runtime/runtime.cc1
-rw-r--r--runtime/runtime.h11
-rw-r--r--runtime/thread.cc11
-rw-r--r--test/036-finalizer/src/Main.java2
-rw-r--r--test/072-reachability-fence/expected.txt5
-rw-r--r--test/072-reachability-fence/info.txt4
-rw-r--r--test/072-reachability-fence/src/Main.java61
-rw-r--r--test/166-bad-interface-super/build20
-rw-r--r--test/171-init-aste/expected.txt (renamed from test/651-checker-byte-simd-minmax/expected.txt)0
-rw-r--r--test/171-init-aste/info.txt1
-rw-r--r--test/171-init-aste/src-art/Main.java37
-rw-r--r--test/171-init-aste/src/Main.java24
-rwxr-xr-xtest/1940-ddms-ext/check21
-rw-r--r--test/1940-ddms-ext/expected_error.txt4
-rwxr-xr-xtest/1940-ddms-ext/remove_error.py38
-rw-r--r--test/411-optimizing-arith-mul/info.txt1
-rw-r--r--test/411-optimizing-arith/expected.txt (renamed from test/411-optimizing-arith-mul/expected.txt)0
-rw-r--r--test/411-optimizing-arith/info.txt7
-rw-r--r--test/411-optimizing-arith/src/DivTest.java (renamed from test/417-optimizing-arith-div/src/Main.java)8
-rw-r--r--test/411-optimizing-arith/src/Main.java26
-rw-r--r--test/411-optimizing-arith/src/MulTest.java (renamed from test/411-optimizing-arith-mul/src/Main.java)17
-rw-r--r--test/411-optimizing-arith/src/NegTest.java (renamed from test/415-optimizing-arith-neg/src/Main.java)30
-rw-r--r--test/411-optimizing-arith/src/RemTest.java (renamed from test/428-optimizing-arith-rem/src/Main.java)4
-rw-r--r--test/411-optimizing-arith/src/ShiftsTest.java (renamed from test/431-optimizing-arith-shifts/src/Main.java)4
-rw-r--r--test/411-optimizing-arith/src/SubTest.java (renamed from test/414-optimizing-arith-sub/src/Main.java)4
-rw-r--r--test/414-optimizing-arith-sub/expected.txt0
-rw-r--r--test/414-optimizing-arith-sub/info.txt1
-rw-r--r--test/415-optimizing-arith-neg/expected.txt0
-rw-r--r--test/415-optimizing-arith-neg/info.txt1
-rw-r--r--test/417-optimizing-arith-div/expected.txt0
-rw-r--r--test/417-optimizing-arith-div/info.txt1
-rw-r--r--test/428-optimizing-arith-rem/expected.txt0
-rw-r--r--test/428-optimizing-arith-rem/info.txt1
-rw-r--r--test/431-optimizing-arith-shifts/expected.txt0
-rw-r--r--test/431-optimizing-arith-shifts/info.txt1
-rw-r--r--test/646-checker-hadd-alt-char/build20
-rw-r--r--test/646-checker-hadd-alt-short/build20
-rw-r--r--test/646-checker-hadd-char/build20
-rw-r--r--test/646-checker-hadd-short/build20
-rw-r--r--test/651-checker-char-simd-minmax/expected.txt1
-rw-r--r--test/651-checker-char-simd-minmax/info.txt1
-rw-r--r--test/651-checker-double-simd-minmax/expected.txt1
-rw-r--r--test/651-checker-double-simd-minmax/info.txt1
-rw-r--r--test/651-checker-float-simd-minmax/expected.txt1
-rw-r--r--test/651-checker-float-simd-minmax/info.txt1
-rw-r--r--test/651-checker-int-simd-minmax/expected.txt1
-rw-r--r--test/651-checker-int-simd-minmax/info.txt1
-rw-r--r--test/651-checker-long-simd-minmax/expected.txt1
-rw-r--r--test/651-checker-long-simd-minmax/info.txt1
-rw-r--r--test/651-checker-short-simd-minmax/build20
-rw-r--r--test/651-checker-short-simd-minmax/expected.txt1
-rw-r--r--test/651-checker-short-simd-minmax/info.txt1
-rw-r--r--test/651-checker-simd-minmax/expected.txt7
-rw-r--r--test/651-checker-simd-minmax/info.txt (renamed from test/651-checker-byte-simd-minmax/info.txt)0
-rw-r--r--test/651-checker-simd-minmax/src/ByteSimdMinMax.java (renamed from test/651-checker-byte-simd-minmax/src/Main.java)30
-rw-r--r--test/651-checker-simd-minmax/src/CharSimdMinMax.java (renamed from test/651-checker-char-simd-minmax/src/Main.java)18
-rw-r--r--test/651-checker-simd-minmax/src/DoubleSimdMinMax.java (renamed from test/651-checker-double-simd-minmax/src/Main.java)14
-rw-r--r--test/651-checker-simd-minmax/src/FloatSimdMinMax.java (renamed from test/651-checker-float-simd-minmax/src/Main.java)14
-rw-r--r--test/651-checker-simd-minmax/src/IntSimdMinMax.java (renamed from test/651-checker-int-simd-minmax/src/Main.java)14
-rw-r--r--test/651-checker-simd-minmax/src/LongSimdMinMax.java (renamed from test/651-checker-long-simd-minmax/src/Main.java)18
-rw-r--r--test/651-checker-simd-minmax/src/Main.java27
-rw-r--r--test/651-checker-simd-minmax/src/ShortSimdMinMax.java (renamed from test/651-checker-short-simd-minmax/src/Main.java)30
-rw-r--r--test/660-checker-simd-sad-byte/build20
-rw-r--r--test/660-checker-simd-sad-char/build20
-rw-r--r--test/660-checker-simd-sad-int/build20
-rw-r--r--test/660-checker-simd-sad-short/build20
-rw-r--r--test/660-checker-simd-sad-short2/build20
-rw-r--r--test/660-checker-simd-sad-short3/build20
-rw-r--r--test/661-checker-simd-reduc/build20
-rw-r--r--test/672-checker-throw-method/build20
-rw-r--r--test/673-checker-throw-vmethod/build20
-rw-r--r--test/678-checker-simd-saturation/build20
-rw-r--r--test/680-checker-deopt-dex-pc-0/src/Main.java16
-rwxr-xr-xtest/712-varhandle-invocations/build3
-rw-r--r--test/Android.run-test.mk7
-rw-r--r--test/HiddenApiSignatures/Class1.java35
-rw-r--r--test/HiddenApiSignatures/Class12.java24
-rw-r--r--test/HiddenApiSignatures/Class2.java27
-rw-r--r--test/HiddenApiSignatures/Class3.java27
-rwxr-xr-xtest/etc/default-build2
-rwxr-xr-xtest/run-test5
-rw-r--r--test/testrunner/env.py3
-rwxr-xr-xtest/testrunner/testrunner.py80
-rw-r--r--tools/build/var_list1
-rw-r--r--tools/veridex/Android.bp3
-rw-r--r--tools/veridex/Android.mk35
-rw-r--r--tools/veridex/README.md14
-rwxr-xr-xtools/veridex/appcompat.sh51
-rw-r--r--tools/veridex/hidden_api.cc11
-rw-r--r--tools/veridex/hidden_api.h28
-rw-r--r--tools/veridex/hidden_api_finder.cc266
-rw-r--r--tools/veridex/hidden_api_finder.h59
-rw-r--r--tools/veridex/resolver.cc12
-rw-r--r--tools/veridex/resolver.h10
-rw-r--r--tools/veridex/veridex.cc8
137 files changed, 1781 insertions, 770 deletions
diff --git a/Android.mk b/Android.mk
index 558986e562..e4f4e74cb2 100644
--- a/Android.mk
+++ b/Android.mk
@@ -67,6 +67,7 @@ include $(art_path)/tools/Android.mk
include $(art_path)/tools/ahat/Android.mk
include $(art_path)/tools/amm/Android.mk
include $(art_path)/tools/dexfuzz/Android.mk
+include $(art_path)/tools/veridex/Android.mk
include $(art_path)/libart_fake/Android.mk
ART_HOST_DEPENDENCIES := \
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk
index 8681642c0e..b342abe17c 100644
--- a/build/Android.gtest.mk
+++ b/build/Android.gtest.mk
@@ -37,6 +37,7 @@ GTEST_DEX_DIRECTORIES := \
ExceptionHandle \
GetMethodSignature \
HiddenApi \
+ HiddenApiSignatures \
ImageLayoutA \
ImageLayoutB \
IMTA \
@@ -160,6 +161,7 @@ ART_GTEST_dex2oat_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEP
ART_GTEST_dex2oat_image_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS) Statics VerifierDeps
ART_GTEST_exception_test_DEX_DEPS := ExceptionHandle
ART_GTEST_hiddenapi_test_DEX_DEPS := HiddenApi
+ART_GTEST_hidden_api_test_DEX_DEPS := HiddenApiSignatures
ART_GTEST_image_test_DEX_DEPS := ImageLayoutA ImageLayoutB DefaultMethods
ART_GTEST_imtable_test_DEX_DEPS := IMTA IMTB
ART_GTEST_instrumentation_test_DEX_DEPS := Instrumentation
diff --git a/compiler/optimizing/intrinsics_arm64.cc b/compiler/optimizing/intrinsics_arm64.cc
index 81c0b50932..c3d643a7d1 100644
--- a/compiler/optimizing/intrinsics_arm64.cc
+++ b/compiler/optimizing/intrinsics_arm64.cc
@@ -2875,6 +2875,14 @@ void IntrinsicCodeGeneratorARM64::VisitThreadInterrupted(HInvoke* invoke) {
__ Bind(&done);
}
+void IntrinsicLocationsBuilderARM64::VisitReachabilityFence(HInvoke* invoke) {
+ LocationSummary* locations =
+ new (allocator_) LocationSummary(invoke, LocationSummary::kNoCall, kIntrinsified);
+ locations->SetInAt(0, Location::Any());
+}
+
+void IntrinsicCodeGeneratorARM64::VisitReachabilityFence(HInvoke* invoke ATTRIBUTE_UNUSED) { }
+
UNIMPLEMENTED_INTRINSIC(ARM64, ReferenceGetReferent)
UNIMPLEMENTED_INTRINSIC(ARM64, StringStringIndexOf);
diff --git a/compiler/optimizing/intrinsics_arm_vixl.cc b/compiler/optimizing/intrinsics_arm_vixl.cc
index e61a0b0809..29aecbc097 100644
--- a/compiler/optimizing/intrinsics_arm_vixl.cc
+++ b/compiler/optimizing/intrinsics_arm_vixl.cc
@@ -3028,6 +3028,14 @@ void IntrinsicCodeGeneratorARMVIXL::VisitThreadInterrupted(HInvoke* invoke) {
}
}
+void IntrinsicLocationsBuilderARMVIXL::VisitReachabilityFence(HInvoke* invoke) {
+ LocationSummary* locations =
+ new (allocator_) LocationSummary(invoke, LocationSummary::kNoCall, kIntrinsified);
+ locations->SetInAt(0, Location::Any());
+}
+
+void IntrinsicCodeGeneratorARMVIXL::VisitReachabilityFence(HInvoke* invoke ATTRIBUTE_UNUSED) { }
+
UNIMPLEMENTED_INTRINSIC(ARMVIXL, MathRoundDouble) // Could be done by changing rounding mode, maybe?
UNIMPLEMENTED_INTRINSIC(ARMVIXL, UnsafeCASLong) // High register pressure.
UNIMPLEMENTED_INTRINSIC(ARMVIXL, SystemArrayCopyChar)
diff --git a/compiler/optimizing/intrinsics_mips.cc b/compiler/optimizing/intrinsics_mips.cc
index bc1292b2b7..ae248a3e5c 100644
--- a/compiler/optimizing/intrinsics_mips.cc
+++ b/compiler/optimizing/intrinsics_mips.cc
@@ -2693,6 +2693,14 @@ void IntrinsicCodeGeneratorMIPS::VisitThreadInterrupted(HInvoke* invoke) {
__ Bind(&done);
}
+void IntrinsicLocationsBuilderMIPS::VisitReachabilityFence(HInvoke* invoke) {
+ LocationSummary* locations =
+ new (allocator_) LocationSummary(invoke, LocationSummary::kNoCall, kIntrinsified);
+ locations->SetInAt(0, Location::Any());
+}
+
+void IntrinsicCodeGeneratorMIPS::VisitReachabilityFence(HInvoke* invoke ATTRIBUTE_UNUSED) { }
+
// Unimplemented intrinsics.
UNIMPLEMENTED_INTRINSIC(MIPS, MathCeil)
diff --git a/compiler/optimizing/intrinsics_mips64.cc b/compiler/optimizing/intrinsics_mips64.cc
index f429afde2c..9a9ae714bc 100644
--- a/compiler/optimizing/intrinsics_mips64.cc
+++ b/compiler/optimizing/intrinsics_mips64.cc
@@ -2354,6 +2354,14 @@ void IntrinsicCodeGeneratorMIPS64::VisitThreadInterrupted(HInvoke* invoke) {
__ Bind(&done);
}
+void IntrinsicLocationsBuilderMIPS64::VisitReachabilityFence(HInvoke* invoke) {
+ LocationSummary* locations =
+ new (allocator_) LocationSummary(invoke, LocationSummary::kNoCall, kIntrinsified);
+ locations->SetInAt(0, Location::Any());
+}
+
+void IntrinsicCodeGeneratorMIPS64::VisitReachabilityFence(HInvoke* invoke ATTRIBUTE_UNUSED) { }
+
UNIMPLEMENTED_INTRINSIC(MIPS64, ReferenceGetReferent)
UNIMPLEMENTED_INTRINSIC(MIPS64, SystemArrayCopy)
diff --git a/compiler/optimizing/intrinsics_x86.cc b/compiler/optimizing/intrinsics_x86.cc
index c4f322bf0c..f84a33bb8e 100644
--- a/compiler/optimizing/intrinsics_x86.cc
+++ b/compiler/optimizing/intrinsics_x86.cc
@@ -2928,6 +2928,13 @@ void IntrinsicCodeGeneratorX86::VisitThreadInterrupted(HInvoke* invoke) {
__ Bind(&done);
}
+void IntrinsicLocationsBuilderX86::VisitReachabilityFence(HInvoke* invoke) {
+ LocationSummary* locations =
+ new (allocator_) LocationSummary(invoke, LocationSummary::kNoCall, kIntrinsified);
+ locations->SetInAt(0, Location::Any());
+}
+
+void IntrinsicCodeGeneratorX86::VisitReachabilityFence(HInvoke* invoke ATTRIBUTE_UNUSED) { }
UNIMPLEMENTED_INTRINSIC(X86, MathRoundDouble)
UNIMPLEMENTED_INTRINSIC(X86, ReferenceGetReferent)
diff --git a/compiler/optimizing/intrinsics_x86_64.cc b/compiler/optimizing/intrinsics_x86_64.cc
index 437bc3dd3c..7627dc9490 100644
--- a/compiler/optimizing/intrinsics_x86_64.cc
+++ b/compiler/optimizing/intrinsics_x86_64.cc
@@ -2737,6 +2737,14 @@ void IntrinsicCodeGeneratorX86_64::VisitThreadInterrupted(HInvoke* invoke) {
__ Bind(&done);
}
+void IntrinsicLocationsBuilderX86_64::VisitReachabilityFence(HInvoke* invoke) {
+ LocationSummary* locations =
+ new (allocator_) LocationSummary(invoke, LocationSummary::kNoCall, kIntrinsified);
+ locations->SetInAt(0, Location::Any());
+}
+
+void IntrinsicCodeGeneratorX86_64::VisitReachabilityFence(HInvoke* invoke ATTRIBUTE_UNUSED) { }
+
UNIMPLEMENTED_INTRINSIC(X86_64, ReferenceGetReferent)
UNIMPLEMENTED_INTRINSIC(X86_64, FloatIsInfinite)
UNIMPLEMENTED_INTRINSIC(X86_64, DoubleIsInfinite)
diff --git a/compiler/utils/atomic_dex_ref_map-inl.h b/compiler/utils/atomic_dex_ref_map-inl.h
index 4bd323dadb..9915498acc 100644
--- a/compiler/utils/atomic_dex_ref_map-inl.h
+++ b/compiler/utils/atomic_dex_ref_map-inl.h
@@ -81,8 +81,7 @@ inline bool AtomicDexRefMap<DexFileReferenceType, Value>::Remove(const DexFileRe
if (array == nullptr) {
return false;
}
- *out = (*array)[ref.index].load(std::memory_order_relaxed);
- (*array)[ref.index].store(nullptr, std::memory_order_seq_cst);
+ *out = (*array)[ref.index].exchange(nullptr, std::memory_order_seq_cst);
return true;
}
diff --git a/libdexfile/dex/dex_file.cc b/libdexfile/dex/dex_file.cc
index 4613b40457..1f471106df 100644
--- a/libdexfile/dex/dex_file.cc
+++ b/libdexfile/dex/dex_file.cc
@@ -121,7 +121,8 @@ DexFile::DexFile(const uint8_t* base,
num_call_site_ids_(0),
oat_dex_file_(oat_dex_file),
container_(std::move(container)),
- is_compact_dex_(is_compact_dex) {
+ is_compact_dex_(is_compact_dex),
+ is_platform_dex_(false) {
CHECK(begin_ != nullptr) << GetLocation();
CHECK_GT(size_, 0U) << GetLocation();
// Check base (=header) alignment.
diff --git a/libdexfile/dex/dex_file.h b/libdexfile/dex/dex_file.h
index aeb49d2c25..683a8243ed 100644
--- a/libdexfile/dex/dex_file.h
+++ b/libdexfile/dex/dex_file.h
@@ -992,6 +992,14 @@ class DexFile {
ALWAYS_INLINE const StandardDexFile* AsStandardDexFile() const;
ALWAYS_INLINE const CompactDexFile* AsCompactDexFile() const;
+ ALWAYS_INLINE bool IsPlatformDexFile() const {
+ return is_platform_dex_;
+ }
+
+ ALWAYS_INLINE void SetIsPlatformDexFile() {
+ is_platform_dex_ = true;
+ }
+
bool IsInMainSection(const void* addr) const {
return Begin() <= addr && addr < Begin() + Size();
}
@@ -1094,6 +1102,9 @@ class DexFile {
// If the dex file is a compact dex file. If false then the dex file is a standard dex file.
const bool is_compact_dex_;
+ // If the dex file is located in /system/framework/.
+ bool is_platform_dex_;
+
friend class DexFileLoader;
friend class DexFileVerifierTest;
friend class OatWriter;
diff --git a/libdexfile/dex/hidden_api_access_flags.h b/libdexfile/dex/hidden_api_access_flags.h
index 441b3c14b5..b62d044c6a 100644
--- a/libdexfile/dex/hidden_api_access_flags.h
+++ b/libdexfile/dex/hidden_api_access_flags.h
@@ -18,6 +18,7 @@
#define ART_LIBDEXFILE_DEX_HIDDEN_API_ACCESS_FLAGS_H_
#include "base/bit_utils.h"
+#include "base/macros.h"
#include "dex/modifiers.h"
namespace art {
diff --git a/openjdkjvmti/fixed_up_dex_file.cc b/openjdkjvmti/fixed_up_dex_file.cc
index ee83c4a4e8..fcbafe7e71 100644
--- a/openjdkjvmti/fixed_up_dex_file.cc
+++ b/openjdkjvmti/fixed_up_dex_file.cc
@@ -31,7 +31,6 @@
#include "base/leb128.h"
#include "fixed_up_dex_file.h"
-#include "dex/art_dex_file_loader.h"
#include "dex/dex_file-inl.h"
#include "dex/dex_file_loader.h"
#include "dex/dex_file_verifier.h"
@@ -108,7 +107,12 @@ std::unique_ptr<FixedUpDexFile> FixedUpDexFile::Create(const art::DexFile& origi
std::vector<unsigned char> data;
std::unique_ptr<const art::DexFile> new_dex_file;
std::string error;
- const art::ArtDexFileLoader dex_file_loader;
+
+ // Do not use ArtDexFileLoader here. This code runs in a signal handler and
+ // its stack is too small to invoke the required LocationIsOnSystemFramework
+ // (b/76429651). Instead, we use DexFileLoader and copy the IsPlatformDexFile
+ // property from `original` to `new_dex_file`.
+ const art::DexFileLoader dex_file_loader;
if (original.IsCompactDexFile()) {
// Since we are supposed to return a standard dex, convert back using dexlayout. It's OK to do
@@ -159,6 +163,10 @@ std::unique_ptr<FixedUpDexFile> FixedUpDexFile::Create(const art::DexFile& origi
return nullptr;
}
+ if (original.IsPlatformDexFile()) {
+ const_cast<art::DexFile*>(new_dex_file.get())->SetIsPlatformDexFile();
+ }
+
DoDexUnquicken(*new_dex_file, original);
RecomputeDexChecksum(const_cast<art::DexFile*>(new_dex_file.get()));
diff --git a/openjdkjvmti/ti_stack.cc b/openjdkjvmti/ti_stack.cc
index 41a649b5e3..4526be4cbe 100644
--- a/openjdkjvmti/ti_stack.cc
+++ b/openjdkjvmti/ti_stack.cc
@@ -925,7 +925,9 @@ static jvmtiError GetOwnedMonitorInfoCommon(const art::ScopedObjectAccessAlready
if (target != self) {
called_method = true;
// RequestSynchronousCheckpoint releases the thread_list_lock_ as a part of its execution.
- if (!target->RequestSynchronousCheckpoint(&closure)) {
+ // Since this deals with object references we need to avoid going to sleep.
+ art::ScopedAssertNoThreadSuspension sants("Getting owned monitor usage");
+ if (!target->RequestSynchronousCheckpoint(&closure, art::ThreadState::kRunnable)) {
return ERR(THREAD_NOT_ALIVE);
}
} else {
diff --git a/runtime/Android.bp b/runtime/Android.bp
index 51fbb2ef30..c0f1c366b8 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -87,6 +87,7 @@ cc_defaults {
"gc/space/zygote_space.cc",
"gc/task_processor.cc",
"gc/verification.cc",
+ "hidden_api.cc",
"hprof/hprof.cc",
"image.cc",
"index_bss_mapping.cc",
@@ -572,6 +573,7 @@ art_cc_test {
"gc/task_processor_test.cc",
"gtest_test.cc",
"handle_scope_test.cc",
+ "hidden_api_test.cc",
"imtable_test.cc",
"indenter_test.cc",
"indirect_reference_table_test.cc",
diff --git a/runtime/base/file_utils.cc b/runtime/base/file_utils.cc
index 1cb3b9c380..2b3e360650 100644
--- a/runtime/base/file_utils.cc
+++ b/runtime/base/file_utils.cc
@@ -319,4 +319,21 @@ bool LocationIsOnSystem(const char* location) {
return path != nullptr && android::base::StartsWith(path.get(), GetAndroidRoot().c_str());
}
+bool LocationIsOnSystemFramework(const char* location) {
+ std::string error_msg;
+ std::string root_path = GetAndroidRootSafe(&error_msg);
+ if (root_path.empty()) {
+ // Could not find Android root.
+ // TODO(dbrazdil): change to stricter GetAndroidRoot() once b/76452688 is resolved.
+ return false;
+ }
+ std::string framework_path = root_path + "/framework/";
+
+ // Warning: Bionic implementation of realpath() allocates > 12KB on the stack.
+ // Do not run this code on a small stack, e.g. in signal handler.
+ UniqueCPtr<const char[]> path(realpath(location, nullptr));
+ return path != nullptr &&
+ android::base::StartsWith(path.get(), framework_path.c_str());
+}
+
} // namespace art
diff --git a/runtime/base/file_utils.h b/runtime/base/file_utils.h
index 7f691d546b..8adb4f7bf8 100644
--- a/runtime/base/file_utils.h
+++ b/runtime/base/file_utils.h
@@ -75,6 +75,9 @@ std::string ReplaceFileExtension(const std::string& filename, const std::string&
// Return whether the location is on system (i.e. android root).
bool LocationIsOnSystem(const char* location);
+// Return whether the location is on system/framework (i.e. android_root/framework).
+bool LocationIsOnSystemFramework(const char* location);
+
} // namespace art
#endif // ART_RUNTIME_BASE_FILE_UTILS_H_
diff --git a/runtime/base/quasi_atomic.h b/runtime/base/quasi_atomic.h
index 067d01db01..0012f6482b 100644
--- a/runtime/base/quasi_atomic.h
+++ b/runtime/base/quasi_atomic.h
@@ -152,14 +152,6 @@ class QuasiAtomic {
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");
@@ -168,10 +160,6 @@ class QuasiAtomic {
#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);
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 8b64b8def0..3025818ab7 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -72,6 +72,7 @@
#include "gc/space/space-inl.h"
#include "gc_root-inl.h"
#include "handle_scope-inl.h"
+#include "hidden_api.h"
#include "image-inl.h"
#include "imt_conflict_table.h"
#include "imtable-inl.h"
@@ -6178,7 +6179,7 @@ ArtMethod* ClassLinker::AddMethodToConflictTable(ObjPtr<mirror::Class> klass,
// Note that there is a race in the presence of multiple threads and we may leak
// memory from the LinearAlloc, but that's a tradeoff compared to using
// atomic operations.
- QuasiAtomic::ThreadFenceRelease();
+ std::atomic_thread_fence(std::memory_order_release);
new_conflict_method->SetImtConflictTable(new_table, image_pointer_size_);
return new_conflict_method;
}
@@ -7935,7 +7936,8 @@ ArtMethod* ClassLinker::FindResolvedMethod(ObjPtr<mirror::Class> klass,
}
DCHECK(resolved == nullptr || resolved->GetDeclaringClassUnchecked() != nullptr);
if (resolved != nullptr &&
- hiddenapi::ShouldBlockAccessToMember(resolved, class_loader, hiddenapi::kLinking)) {
+ hiddenapi::ShouldBlockAccessToMember(
+ resolved, class_loader, dex_cache, hiddenapi::kLinking)) {
resolved = nullptr;
}
if (resolved != nullptr) {
@@ -8077,7 +8079,8 @@ ArtMethod* ClassLinker::ResolveMethodWithoutInvokeType(uint32_t method_idx,
resolved = klass->FindClassMethod(dex_cache.Get(), method_idx, image_pointer_size_);
}
if (resolved != nullptr &&
- hiddenapi::ShouldBlockAccessToMember(resolved, class_loader.Get(), hiddenapi::kLinking)) {
+ hiddenapi::ShouldBlockAccessToMember(
+ resolved, class_loader.Get(), dex_cache.Get(), hiddenapi::kLinking)) {
resolved = nullptr;
}
return resolved;
@@ -8156,7 +8159,8 @@ ArtField* ClassLinker::ResolveField(uint32_t field_idx,
}
if (resolved == nullptr ||
- hiddenapi::ShouldBlockAccessToMember(resolved, class_loader.Get(), hiddenapi::kLinking)) {
+ hiddenapi::ShouldBlockAccessToMember(
+ resolved, class_loader.Get(), dex_cache.Get(), hiddenapi::kLinking)) {
const char* name = dex_file.GetFieldName(field_id);
const char* type = dex_file.GetFieldTypeDescriptor(field_id);
ThrowNoSuchFieldError(is_static ? "static " : "instance ", klass, type, name);
@@ -8189,7 +8193,8 @@ ArtField* ClassLinker::ResolveFieldJLS(uint32_t field_idx,
StringPiece type(dex_file.GetFieldTypeDescriptor(field_id));
resolved = mirror::Class::FindField(self, klass, name, type);
if (resolved != nullptr &&
- hiddenapi::ShouldBlockAccessToMember(resolved, class_loader.Get(), hiddenapi::kLinking)) {
+ hiddenapi::ShouldBlockAccessToMember(
+ resolved, class_loader.Get(), dex_cache.Get(), hiddenapi::kLinking)) {
resolved = nullptr;
}
if (resolved != nullptr) {
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index 99a4c77979..4a9449640b 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -4354,9 +4354,11 @@ bool Dbg::DdmHandleChunk(JNIEnv* env,
WellKnownClasses::org_apache_harmony_dalvik_ddmc_DdmServer_dispatch,
type, dataArray.get(), 0, data.size()));
if (env->ExceptionCheck()) {
- LOG(INFO) << StringPrintf("Exception thrown by dispatcher for 0x%08x", type);
- env->ExceptionDescribe();
- env->ExceptionClear();
+ Thread* self = Thread::Current();
+ ScopedObjectAccess soa(self);
+ LOG(INFO) << StringPrintf("Exception thrown by dispatcher for 0x%08x", type) << std::endl
+ << self->GetException()->Dump();
+ self->ClearException();
return false;
}
@@ -4400,10 +4402,11 @@ bool Dbg::DdmHandleChunk(JNIEnv* env,
reinterpret_cast<jbyte*>(out_data->data()));
if (env->ExceptionCheck()) {
+ Thread* self = Thread::Current();
+ ScopedObjectAccess soa(self);
LOG(INFO) << StringPrintf("Exception thrown when reading response data from dispatcher 0x%08x",
- type);
- env->ExceptionDescribe();
- env->ExceptionClear();
+ type) << std::endl << self->GetException()->Dump();
+ self->ClearException();
return false;
}
diff --git a/runtime/dex/art_dex_file_loader.cc b/runtime/dex/art_dex_file_loader.cc
index 9802c6904b..f3e6a69279 100644
--- a/runtime/dex/art_dex_file_loader.cc
+++ b/runtime/dex/art_dex_file_loader.cc
@@ -22,6 +22,7 @@
#include "android-base/stringprintf.h"
#include "base/file_magic.h"
+#include "base/file_utils.h"
#include "base/stl_util.h"
#include "base/systrace.h"
#include "base/unix_file/fd_file.h"
@@ -505,4 +506,39 @@ bool ArtDexFileLoader::OpenAllDexFilesFromZip(
}
}
+std::unique_ptr<DexFile> ArtDexFileLoader::OpenCommon(const uint8_t* base,
+ size_t size,
+ const uint8_t* data_base,
+ size_t data_size,
+ const std::string& location,
+ uint32_t location_checksum,
+ const OatDexFile* oat_dex_file,
+ bool verify,
+ bool verify_checksum,
+ std::string* error_msg,
+ std::unique_ptr<DexFileContainer> container,
+ VerifyResult* verify_result) {
+ std::unique_ptr<DexFile> dex_file = DexFileLoader::OpenCommon(base,
+ size,
+ data_base,
+ data_size,
+ location,
+ location_checksum,
+ oat_dex_file,
+ verify,
+ verify_checksum,
+ error_msg,
+ std::move(container),
+ verify_result);
+
+ // Check if this dex file is located in the framework directory.
+ // If it is, set a flag on the dex file. This is used by hidden API
+ // policy decision logic.
+ if (dex_file != nullptr && LocationIsOnSystemFramework(location.c_str())) {
+ dex_file->SetIsPlatformDexFile();
+ }
+
+ return dex_file;
+}
+
} // namespace art
diff --git a/runtime/dex/art_dex_file_loader.h b/runtime/dex/art_dex_file_loader.h
index 7c7a59b37f..7577945632 100644
--- a/runtime/dex/art_dex_file_loader.h
+++ b/runtime/dex/art_dex_file_loader.h
@@ -120,6 +120,19 @@ class ArtDexFileLoader : public DexFileLoader {
bool verify_checksum,
std::string* error_msg,
ZipOpenErrorCode* error_code) const;
+
+ static std::unique_ptr<DexFile> OpenCommon(const uint8_t* base,
+ size_t size,
+ const uint8_t* data_base,
+ size_t data_size,
+ const std::string& location,
+ uint32_t location_checksum,
+ const OatDexFile* oat_dex_file,
+ bool verify,
+ bool verify_checksum,
+ std::string* error_msg,
+ std::unique_ptr<DexFileContainer> container,
+ VerifyResult* verify_result);
};
} // namespace art
diff --git a/runtime/dex/art_dex_file_loader_test.cc b/runtime/dex/art_dex_file_loader_test.cc
index 6e2cfec381..3e0d6662c7 100644
--- a/runtime/dex/art_dex_file_loader_test.cc
+++ b/runtime/dex/art_dex_file_loader_test.cc
@@ -16,9 +16,11 @@
#include <sys/mman.h>
+#include <fstream>
#include <memory>
#include "art_dex_file_loader.h"
+#include "base/file_utils.h"
#include "base/os.h"
#include "base/stl_util.h"
#include "base/unix_file/fd_file.h"
@@ -35,7 +37,40 @@
namespace art {
-class ArtDexFileLoaderTest : public CommonRuntimeTest {};
+static void Copy(const std::string& src, const std::string& dst) {
+ std::ifstream src_stream(src, std::ios::binary);
+ std::ofstream dst_stream(dst, std::ios::binary);
+ dst_stream << src_stream.rdbuf();
+}
+
+class ArtDexFileLoaderTest : public CommonRuntimeTest {
+ public:
+ virtual void SetUp() {
+ CommonRuntimeTest::SetUp();
+
+ std::string dex_location = GetTestDexFileName("Main");
+
+ data_location_path_ = android_data_ + "/foo.jar";
+ system_location_path_ = GetAndroidRoot() + "/foo.jar";
+ system_framework_location_path_ = GetAndroidRoot() + "/framework/foo.jar";
+
+ Copy(dex_location, data_location_path_);
+ Copy(dex_location, system_location_path_);
+ Copy(dex_location, system_framework_location_path_);
+ }
+
+ virtual void TearDown() {
+ remove(data_location_path_.c_str());
+ remove(system_location_path_.c_str());
+ remove(system_framework_location_path_.c_str());
+ CommonRuntimeTest::TearDown();
+ }
+
+ protected:
+ std::string data_location_path_;
+ std::string system_location_path_;
+ std::string system_framework_location_path_;
+};
// TODO: Port OpenTestDexFile(s) need to be ported to use non-ART utilities, and
// the tests that depend upon them should be moved to dex_file_loader_test.cc
@@ -304,4 +339,57 @@ TEST_F(ArtDexFileLoaderTest, GetDexCanonicalLocation) {
ASSERT_EQ(0, unlink(dex_location_sym.c_str()));
}
+TEST_F(ArtDexFileLoaderTest, IsPlatformDexFile) {
+ ArtDexFileLoader loader;
+ bool success;
+ std::string error_msg;
+ std::vector<std::unique_ptr<const DexFile>> dex_files;
+
+ // Load file from a non-system directory and check that it is not flagged as framework.
+ ASSERT_FALSE(LocationIsOnSystemFramework(data_location_path_.c_str()));
+ success = loader.Open(data_location_path_.c_str(),
+ data_location_path_,
+ /* verify */ false,
+ /* verify_checksum */ false,
+ &error_msg,
+ &dex_files);
+ ASSERT_TRUE(success);
+ ASSERT_GE(dex_files.size(), 1u);
+ for (std::unique_ptr<const DexFile>& dex_file : dex_files) {
+ ASSERT_FALSE(dex_file->IsPlatformDexFile());
+ }
+
+ dex_files.clear();
+
+ // Load file from a system, non-framework directory and check that it is not flagged as framework.
+ ASSERT_FALSE(LocationIsOnSystemFramework(system_location_path_.c_str()));
+ success = loader.Open(system_location_path_.c_str(),
+ system_location_path_,
+ /* verify */ false,
+ /* verify_checksum */ false,
+ &error_msg,
+ &dex_files);
+ ASSERT_TRUE(success);
+ ASSERT_GE(dex_files.size(), 1u);
+ for (std::unique_ptr<const DexFile>& dex_file : dex_files) {
+ ASSERT_FALSE(dex_file->IsPlatformDexFile());
+ }
+
+ dex_files.clear();
+
+ // Load file from a system/framework directory and check that it is flagged as a framework dex.
+ ASSERT_TRUE(LocationIsOnSystemFramework(system_framework_location_path_.c_str()));
+ success = loader.Open(system_framework_location_path_.c_str(),
+ system_framework_location_path_,
+ /* verify */ false,
+ /* verify_checksum */ false,
+ &error_msg,
+ &dex_files);
+ ASSERT_TRUE(success);
+ ASSERT_GE(dex_files.size(), 1u);
+ for (std::unique_ptr<const DexFile>& dex_file : dex_files) {
+ ASSERT_TRUE(dex_file->IsPlatformDexFile());
+ }
+}
+
} // namespace art
diff --git a/runtime/gc/collector/concurrent_copying.cc b/runtime/gc/collector/concurrent_copying.cc
index bb5167f15d..0747c3c77b 100644
--- a/runtime/gc/collector/concurrent_copying.cc
+++ b/runtime/gc/collector/concurrent_copying.cc
@@ -2357,14 +2357,13 @@ mirror::Object* ConcurrentCopying::Copy(mirror::Object* from_ref,
size_t non_moving_space_bytes_allocated = 0U;
size_t bytes_allocated = 0U;
size_t dummy;
+ bool fall_back_to_non_moving = false;
mirror::Object* to_ref = region_space_->AllocNonvirtual</*kForEvac*/ true>(
region_space_alloc_size, &region_space_bytes_allocated, nullptr, &dummy);
bytes_allocated = region_space_bytes_allocated;
- if (to_ref != nullptr) {
+ if (LIKELY(to_ref != nullptr)) {
DCHECK_EQ(region_space_alloc_size, region_space_bytes_allocated);
- }
- bool fall_back_to_non_moving = false;
- if (UNLIKELY(to_ref == nullptr)) {
+ } else {
// Failed to allocate in the region space. Try the skipped blocks.
to_ref = AllocateInSkippedBlock(region_space_alloc_size);
if (to_ref != nullptr) {
@@ -2374,6 +2373,9 @@ mirror::Object* ConcurrentCopying::Copy(mirror::Object* from_ref,
region_space_->RecordAlloc(to_ref);
}
bytes_allocated = region_space_alloc_size;
+ heap_->num_bytes_allocated_.fetch_sub(bytes_allocated, std::memory_order_seq_cst);
+ to_space_bytes_skipped_.fetch_sub(bytes_allocated, std::memory_order_seq_cst);
+ to_space_objects_skipped_.fetch_sub(1, std::memory_order_seq_cst);
} else {
// Fall back to the non-moving space.
fall_back_to_non_moving = true;
@@ -2383,7 +2385,6 @@ mirror::Object* ConcurrentCopying::Copy(mirror::Object* from_ref,
<< " skipped_objects="
<< to_space_objects_skipped_.load(std::memory_order_seq_cst);
}
- fall_back_to_non_moving = true;
to_ref = heap_->non_moving_space_->Alloc(Thread::Current(), obj_size,
&non_moving_space_bytes_allocated, nullptr, &dummy);
if (UNLIKELY(to_ref == nullptr)) {
@@ -2471,7 +2472,7 @@ mirror::Object* ConcurrentCopying::Copy(mirror::Object* from_ref,
// Do a fence to prevent the field CAS in ConcurrentCopying::Process from possibly reordering
// before the object copy.
- QuasiAtomic::ThreadFenceRelease();
+ std::atomic_thread_fence(std::memory_order_release);
LockWord new_lock_word = LockWord::FromForwardingAddress(reinterpret_cast<size_t>(to_ref));
@@ -2566,7 +2567,7 @@ mirror::Object* ConcurrentCopying::IsMarked(mirror::Object* from_ref) {
bool ConcurrentCopying::IsOnAllocStack(mirror::Object* ref) {
// TODO: Explain why this is here. What release operation does it pair with?
- QuasiAtomic::ThreadFenceAcquire();
+ std::atomic_thread_fence(std::memory_order_acquire);
accounting::ObjectStack* alloc_stack = GetAllocationStack();
return alloc_stack->Contains(ref);
}
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 247e25c4da..f16138c058 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -3730,13 +3730,21 @@ void Heap::RequestTrim(Thread* self) {
task_processor_->AddTask(self, added_task);
}
+void Heap::IncrementNumberOfBytesFreedRevoke(size_t freed_bytes_revoke) {
+ size_t previous_num_bytes_freed_revoke =
+ num_bytes_freed_revoke_.fetch_add(freed_bytes_revoke, std::memory_order_seq_cst);
+ // Check the updated value is less than the number of bytes allocated. There is a risk of
+ // execution being suspended between the increment above and the CHECK below, leading to
+ // the use of previous_num_bytes_freed_revoke in the comparison.
+ CHECK_GE(num_bytes_allocated_.load(std::memory_order_relaxed),
+ previous_num_bytes_freed_revoke + freed_bytes_revoke);
+}
+
void Heap::RevokeThreadLocalBuffers(Thread* thread) {
if (rosalloc_space_ != nullptr) {
size_t freed_bytes_revoke = rosalloc_space_->RevokeThreadLocalBuffers(thread);
if (freed_bytes_revoke > 0U) {
- num_bytes_freed_revoke_.fetch_add(freed_bytes_revoke, std::memory_order_seq_cst);
- CHECK_GE(num_bytes_allocated_.load(std::memory_order_relaxed),
- num_bytes_freed_revoke_.load(std::memory_order_relaxed));
+ IncrementNumberOfBytesFreedRevoke(freed_bytes_revoke);
}
}
if (bump_pointer_space_ != nullptr) {
@@ -3751,9 +3759,7 @@ void Heap::RevokeRosAllocThreadLocalBuffers(Thread* thread) {
if (rosalloc_space_ != nullptr) {
size_t freed_bytes_revoke = rosalloc_space_->RevokeThreadLocalBuffers(thread);
if (freed_bytes_revoke > 0U) {
- num_bytes_freed_revoke_.fetch_add(freed_bytes_revoke, std::memory_order_seq_cst);
- CHECK_GE(num_bytes_allocated_.load(std::memory_order_relaxed),
- num_bytes_freed_revoke_.load(std::memory_order_relaxed));
+ IncrementNumberOfBytesFreedRevoke(freed_bytes_revoke);
}
}
}
@@ -3762,9 +3768,7 @@ void Heap::RevokeAllThreadLocalBuffers() {
if (rosalloc_space_ != nullptr) {
size_t freed_bytes_revoke = rosalloc_space_->RevokeAllThreadLocalBuffers();
if (freed_bytes_revoke > 0U) {
- num_bytes_freed_revoke_.fetch_add(freed_bytes_revoke, std::memory_order_seq_cst);
- CHECK_GE(num_bytes_allocated_.load(std::memory_order_relaxed),
- num_bytes_freed_revoke_.load(std::memory_order_relaxed));
+ IncrementNumberOfBytesFreedRevoke(freed_bytes_revoke);
}
}
if (bump_pointer_space_ != nullptr) {
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h
index 9af57d17e5..ef1c0887bb 100644
--- a/runtime/gc/heap.h
+++ b/runtime/gc/heap.h
@@ -1091,6 +1091,8 @@ class Heap {
return max_free_;
}
+ ALWAYS_INLINE void IncrementNumberOfBytesFreedRevoke(size_t freed_bytes_revoke);
+
void TraceHeapSize(size_t heap_size);
// Remove a vlog code from heap-inl.h which is transitively included in half the world.
diff --git a/runtime/hidden_api.cc b/runtime/hidden_api.cc
new file mode 100644
index 0000000000..f0b36a090a
--- /dev/null
+++ b/runtime/hidden_api.cc
@@ -0,0 +1,172 @@
+/*
+ * 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.
+ */
+
+#include "hidden_api.h"
+
+#include "base/dumpable.h"
+
+namespace art {
+namespace hiddenapi {
+
+static inline std::ostream& operator<<(std::ostream& os, AccessMethod value) {
+ switch (value) {
+ case kReflection:
+ os << "reflection";
+ break;
+ case kJNI:
+ os << "JNI";
+ break;
+ case kLinking:
+ os << "linking";
+ break;
+ }
+ return os;
+}
+
+static constexpr bool EnumsEqual(EnforcementPolicy policy, HiddenApiAccessFlags::ApiList apiList) {
+ return static_cast<int>(policy) == static_cast<int>(apiList);
+}
+
+// GetMemberAction-related static_asserts.
+static_assert(
+ EnumsEqual(EnforcementPolicy::kAllLists, HiddenApiAccessFlags::kLightGreylist) &&
+ EnumsEqual(EnforcementPolicy::kDarkGreyAndBlackList, HiddenApiAccessFlags::kDarkGreylist) &&
+ EnumsEqual(EnforcementPolicy::kBlacklistOnly, HiddenApiAccessFlags::kBlacklist),
+ "Mismatch between EnforcementPolicy and ApiList enums");
+static_assert(
+ EnforcementPolicy::kAllLists < EnforcementPolicy::kDarkGreyAndBlackList &&
+ EnforcementPolicy::kDarkGreyAndBlackList < EnforcementPolicy::kBlacklistOnly,
+ "EnforcementPolicy values ordering not correct");
+
+namespace detail {
+
+MemberSignature::MemberSignature(ArtField* field) {
+ member_type_ = "field";
+ signature_parts_ = {
+ field->GetDeclaringClass()->GetDescriptor(&tmp_),
+ "->",
+ field->GetName(),
+ ":",
+ field->GetTypeDescriptor()
+ };
+}
+
+MemberSignature::MemberSignature(ArtMethod* method) {
+ member_type_ = "method";
+ signature_parts_ = {
+ method->GetDeclaringClass()->GetDescriptor(&tmp_),
+ "->",
+ method->GetName(),
+ method->GetSignature().ToString()
+ };
+}
+
+bool MemberSignature::DoesPrefixMatch(const std::string& prefix) const {
+ size_t pos = 0;
+ for (const std::string& part : signature_parts_) {
+ size_t count = std::min(prefix.length() - pos, part.length());
+ if (prefix.compare(pos, count, part, 0, count) == 0) {
+ pos += count;
+ } else {
+ return false;
+ }
+ }
+ // We have a complete match if all parts match (we exit the loop without
+ // returning) AND we've matched the whole prefix.
+ return pos == prefix.length();
+}
+
+bool MemberSignature::IsExempted(const std::vector<std::string>& exemptions) {
+ for (const std::string& exemption : exemptions) {
+ if (DoesPrefixMatch(exemption)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+void MemberSignature::Dump(std::ostream& os) const {
+ for (std::string part : signature_parts_) {
+ os << part;
+ }
+}
+
+void MemberSignature::WarnAboutAccess(AccessMethod access_method,
+ HiddenApiAccessFlags::ApiList list) {
+ LOG(WARNING) << "Accessing hidden " << member_type_ << " " << Dumpable<MemberSignature>(*this)
+ << " (" << list << ", " << access_method << ")";
+}
+
+template<typename T>
+bool ShouldBlockAccessToMemberImpl(T* member, Action action, AccessMethod access_method) {
+ // Get the signature, we need it later.
+ MemberSignature member_signature(member);
+
+ Runtime* runtime = Runtime::Current();
+
+ if (action == kDeny) {
+ // If we were about to deny, check for an exemption first.
+ // Exempted APIs are treated as light grey list.
+ if (member_signature.IsExempted(runtime->GetHiddenApiExemptions())) {
+ action = kAllowButWarn;
+ // Avoid re-examining the exemption list next time.
+ // Note this results in the warning below showing "light greylist", which
+ // seems like what one would expect. Exemptions effectively add new members to
+ // the light greylist.
+ member->SetAccessFlags(HiddenApiAccessFlags::EncodeForRuntime(
+ member->GetAccessFlags(), HiddenApiAccessFlags::kLightGreylist));
+ }
+ }
+
+ // Print a log message with information about this class member access.
+ // We do this regardless of whether we block the access or not.
+ member_signature.WarnAboutAccess(access_method,
+ HiddenApiAccessFlags::DecodeFromRuntime(member->GetAccessFlags()));
+
+ if (action == kDeny) {
+ // Block access
+ return true;
+ }
+
+ // Allow access to this member but print a warning.
+ DCHECK(action == kAllowButWarn || action == kAllowButWarnAndToast);
+
+ // Depending on a runtime flag, we might move the member into whitelist and
+ // skip the warning the next time the member is accessed.
+ if (runtime->ShouldDedupeHiddenApiWarnings()) {
+ member->SetAccessFlags(HiddenApiAccessFlags::EncodeForRuntime(
+ member->GetAccessFlags(), HiddenApiAccessFlags::kWhitelist));
+ }
+
+ // If this action requires a UI warning, set the appropriate flag.
+ if (action == kAllowButWarnAndToast || runtime->ShouldAlwaysSetHiddenApiWarningFlag()) {
+ runtime->SetPendingHiddenApiWarning(true);
+ }
+
+ return false;
+}
+
+// Need to instantiate this.
+template bool ShouldBlockAccessToMemberImpl<ArtField>(ArtField* member,
+ Action action,
+ AccessMethod access_method);
+template bool ShouldBlockAccessToMemberImpl<ArtMethod>(ArtMethod* member,
+ Action action,
+ AccessMethod access_method);
+
+} // namespace detail
+} // namespace hiddenapi
+} // namespace art
diff --git a/runtime/hidden_api.h b/runtime/hidden_api.h
index 5c6b4b56bc..cc6c146f00 100644
--- a/runtime/hidden_api.h
+++ b/runtime/hidden_api.h
@@ -19,6 +19,7 @@
#include "art_field-inl.h"
#include "art_method-inl.h"
+#include "base/mutex.h"
#include "dex/hidden_api_access_flags.h"
#include "mirror/class-inl.h"
#include "reflection.h"
@@ -57,25 +58,6 @@ enum AccessMethod {
kLinking,
};
-inline std::ostream& operator<<(std::ostream& os, AccessMethod value) {
- switch (value) {
- case kReflection:
- os << "reflection";
- break;
- case kJNI:
- os << "JNI";
- break;
- case kLinking:
- os << "linking";
- break;
- }
- return os;
-}
-
-static constexpr bool EnumsEqual(EnforcementPolicy policy, HiddenApiAccessFlags::ApiList apiList) {
- return static_cast<int>(policy) == static_cast<int>(apiList);
-}
-
inline Action GetMemberAction(uint32_t access_flags) {
EnforcementPolicy policy = Runtime::Current()->GetHiddenApiEnforcementPolicy();
if (policy == EnforcementPolicy::kNoChecks) {
@@ -88,16 +70,7 @@ inline Action GetMemberAction(uint32_t access_flags) {
return kAllow;
}
// The logic below relies on equality of values in the enums EnforcementPolicy and
- // HiddenApiAccessFlags::ApiList, and their ordering. Assert that this is as expected.
- static_assert(
- EnumsEqual(EnforcementPolicy::kAllLists, HiddenApiAccessFlags::kLightGreylist) &&
- EnumsEqual(EnforcementPolicy::kDarkGreyAndBlackList, HiddenApiAccessFlags::kDarkGreylist) &&
- EnumsEqual(EnforcementPolicy::kBlacklistOnly, HiddenApiAccessFlags::kBlacklist),
- "Mismatch between EnforcementPolicy and ApiList enums");
- static_assert(
- EnforcementPolicy::kAllLists < EnforcementPolicy::kDarkGreyAndBlackList &&
- EnforcementPolicy::kDarkGreyAndBlackList < EnforcementPolicy::kBlacklistOnly,
- "EnforcementPolicy values ordering not correct");
+ // HiddenApiAccessFlags::ApiList, and their ordering. Assertions are in hidden_api.cc.
if (static_cast<int>(policy) > static_cast<int>(api_list)) {
return api_list == HiddenApiAccessFlags::kDarkGreylist
? kAllowButWarnAndToast
@@ -107,38 +80,67 @@ inline Action GetMemberAction(uint32_t access_flags) {
}
}
-// Issue a warning about field access.
-inline void WarnAboutMemberAccess(ArtField* field, AccessMethod access_method)
- REQUIRES_SHARED(Locks::mutator_lock_) {
- std::string tmp;
- LOG(WARNING) << "Accessing hidden field "
- << field->GetDeclaringClass()->GetDescriptor(&tmp) << "->"
- << field->GetName() << ":" << field->GetTypeDescriptor()
- << " (" << HiddenApiAccessFlags::DecodeFromRuntime(field->GetAccessFlags())
- << ", " << access_method << ")";
-}
+// Implementation details. DO NOT ACCESS DIRECTLY.
+namespace detail {
+
+// Class to encapsulate the signature of a member (ArtField or ArtMethod). This
+// is used as a helper when matching prefixes, and when logging the signature.
+class MemberSignature {
+ private:
+ std::string member_type_;
+ std::vector<std::string> signature_parts_;
+ std::string tmp_;
-// Issue a warning about method access.
-inline void WarnAboutMemberAccess(ArtMethod* method, AccessMethod access_method)
+ public:
+ explicit MemberSignature(ArtField* field) REQUIRES_SHARED(Locks::mutator_lock_);
+ explicit MemberSignature(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_);
+
+ void Dump(std::ostream& os) const;
+
+ // Performs prefix match on this member. Since the full member signature is
+ // composed of several parts, we match each part in turn (rather than
+ // building the entire thing in memory and performing a simple prefix match)
+ bool DoesPrefixMatch(const std::string& prefix) const;
+
+ bool IsExempted(const std::vector<std::string>& exemptions);
+
+ void WarnAboutAccess(AccessMethod access_method, HiddenApiAccessFlags::ApiList list);
+};
+
+template<typename T>
+bool ShouldBlockAccessToMemberImpl(T* member,
+ Action action,
+ AccessMethod access_method)
+ REQUIRES_SHARED(Locks::mutator_lock_);
+
+// Returns true if the caller is either loaded by the boot strap class loader or comes from
+// a dex file located in ${ANDROID_ROOT}/framework/.
+ALWAYS_INLINE
+inline bool IsCallerInPlatformDex(ObjPtr<mirror::ClassLoader> caller_class_loader,
+ ObjPtr<mirror::DexCache> caller_dex_cache)
REQUIRES_SHARED(Locks::mutator_lock_) {
- std::string tmp;
- LOG(WARNING) << "Accessing hidden method "
- << method->GetDeclaringClass()->GetDescriptor(&tmp) << "->"
- << method->GetName() << method->GetSignature().ToString()
- << " (" << HiddenApiAccessFlags::DecodeFromRuntime(method->GetAccessFlags())
- << ", " << access_method << ")";
+ if (caller_class_loader.IsNull()) {
+ return true;
+ } else if (caller_dex_cache.IsNull()) {
+ return false;
+ } else {
+ const DexFile* caller_dex_file = caller_dex_cache->GetDexFile();
+ return caller_dex_file != nullptr && caller_dex_file->IsPlatformDexFile();
+ }
}
+} // namespace detail
+
// Returns true if access to `member` should be denied to the caller of the
-// reflective query. The decision is based on whether the caller is in boot
-// class path or not. Because different users of this function determine this
-// in a different way, `fn_caller_in_boot(self)` is called and should return
-// true if the caller is in boot class path.
+// reflective query. The decision is based on whether the caller is in the
+// platform or not. Because different users of this function determine this
+// in a different way, `fn_caller_in_platform(self)` is called and should
+// return true if the caller is located in the platform.
// This function might print warnings into the log if the member is hidden.
template<typename T>
inline bool ShouldBlockAccessToMember(T* member,
Thread* self,
- std::function<bool(Thread*)> fn_caller_in_boot,
+ std::function<bool(Thread*)> fn_caller_in_platform,
AccessMethod access_method)
REQUIRES_SHARED(Locks::mutator_lock_) {
DCHECK(member != nullptr);
@@ -149,42 +151,21 @@ inline bool ShouldBlockAccessToMember(T* member,
return false;
}
- // Member is hidden. Walk the stack to find the caller.
+ // Member is hidden. Invoke `fn_caller_in_platform` and find the origin of the access.
// This can be *very* expensive. Save it for last.
- if (fn_caller_in_boot(self)) {
- // Caller in boot class path. Exit.
+ if (fn_caller_in_platform(self)) {
+ // Caller in the platform. Exit.
return false;
}
- // Member is hidden and we are not in the boot class path.
-
- // Print a log message with information about this class member access.
- // We do this regardless of whether we block the access or not.
- WarnAboutMemberAccess(member, access_method);
-
- if (action == kDeny) {
- // Block access
- return true;
- }
-
- // Allow access to this member but print a warning.
- DCHECK(action == kAllowButWarn || action == kAllowButWarnAndToast);
-
- Runtime* runtime = Runtime::Current();
-
- // Depending on a runtime flag, we might move the member into whitelist and
- // skip the warning the next time the member is accessed.
- if (runtime->ShouldDedupeHiddenApiWarnings()) {
- member->SetAccessFlags(HiddenApiAccessFlags::EncodeForRuntime(
- member->GetAccessFlags(), HiddenApiAccessFlags::kWhitelist));
- }
-
- // If this action requires a UI warning, set the appropriate flag.
- if (action == kAllowButWarnAndToast || runtime->ShouldAlwaysSetHiddenApiWarningFlag()) {
- runtime->SetPendingHiddenApiWarning(true);
- }
+ // Member is hidden and caller is not in the platform.
+ return detail::ShouldBlockAccessToMemberImpl(member, action, access_method);
+}
- return false;
+inline bool IsCallerInPlatformDex(ObjPtr<mirror::Class> caller)
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ return !caller.IsNull() &&
+ detail::IsCallerInPlatformDex(caller->GetClassLoader(), caller->GetDexCache());
}
// Returns true if access to `member` should be denied to a caller loaded with
@@ -193,12 +174,13 @@ inline bool ShouldBlockAccessToMember(T* member,
template<typename T>
inline bool ShouldBlockAccessToMember(T* member,
ObjPtr<mirror::ClassLoader> caller_class_loader,
+ ObjPtr<mirror::DexCache> caller_dex_cache,
AccessMethod access_method)
REQUIRES_SHARED(Locks::mutator_lock_) {
- bool caller_in_boot = (caller_class_loader.IsNull());
+ bool caller_in_platform = detail::IsCallerInPlatformDex(caller_class_loader, caller_dex_cache);
return ShouldBlockAccessToMember(member,
/* thread */ nullptr,
- [caller_in_boot] (Thread*) { return caller_in_boot; },
+ [caller_in_platform] (Thread*) { return caller_in_platform; },
access_method);
}
diff --git a/runtime/hidden_api_test.cc b/runtime/hidden_api_test.cc
new file mode 100644
index 0000000000..5a31dd4972
--- /dev/null
+++ b/runtime/hidden_api_test.cc
@@ -0,0 +1,275 @@
+/*
+ * 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.
+ */
+
+#include "hidden_api.h"
+
+#include "common_runtime_test.h"
+#include "jni_internal.h"
+
+namespace art {
+
+using hiddenapi::detail::MemberSignature;
+
+class HiddenApiTest : public CommonRuntimeTest {
+ protected:
+ void SetUp() OVERRIDE {
+ // Do the normal setup.
+ CommonRuntimeTest::SetUp();
+ self_ = Thread::Current();
+ self_->TransitionFromSuspendedToRunnable();
+ LoadDex("HiddenApiSignatures");
+ bool started = runtime_->Start();
+ CHECK(started);
+
+ class1_field1_ = getArtField("mypackage/packagea/Class1", "field1", "I");
+ class1_field12_ = getArtField("mypackage/packagea/Class1", "field12", "I");
+ class1_init_ = getArtMethod("mypackage/packagea/Class1", "<init>", "()V");
+ class1_method1_ = getArtMethod("mypackage/packagea/Class1", "method1", "()V");
+ class1_method1_i_ = getArtMethod("mypackage/packagea/Class1", "method1", "(I)V");
+ class1_method12_ = getArtMethod("mypackage/packagea/Class1", "method12", "()V");
+ class12_field1_ = getArtField("mypackage/packagea/Class12", "field1", "I");
+ class12_method1_ = getArtMethod("mypackage/packagea/Class12", "method1", "()V");
+ class2_field1_ = getArtField("mypackage/packagea/Class2", "field1", "I");
+ class2_method1_ = getArtMethod("mypackage/packagea/Class2", "method1", "()V");
+ class2_method1_i_ = getArtMethod("mypackage/packagea/Class2", "method1", "(I)V");
+ class3_field1_ = getArtField("mypackage/packageb/Class3", "field1", "I");
+ class3_method1_ = getArtMethod("mypackage/packageb/Class3", "method1", "()V");
+ class3_method1_i_ = getArtMethod("mypackage/packageb/Class3", "method1", "(I)V");
+ }
+
+ ArtMethod* getArtMethod(const char* class_name, const char* name, const char* signature) {
+ JNIEnv* env = Thread::Current()->GetJniEnv();
+ jclass klass = env->FindClass(class_name);
+ jmethodID method_id = env->GetMethodID(klass, name, signature);
+ ArtMethod* art_method = jni::DecodeArtMethod(method_id);
+ return art_method;
+ }
+
+ ArtField* getArtField(const char* class_name, const char* name, const char* signature) {
+ JNIEnv* env = Thread::Current()->GetJniEnv();
+ jclass klass = env->FindClass(class_name);
+ jfieldID field_id = env->GetFieldID(klass, name, signature);
+ ArtField* art_field = jni::DecodeArtField(field_id);
+ return art_field;
+ }
+
+ protected:
+ Thread* self_;
+ ArtField* class1_field1_;
+ ArtField* class1_field12_;
+ ArtMethod* class1_init_;
+ ArtMethod* class1_method1_;
+ ArtMethod* class1_method1_i_;
+ ArtMethod* class1_method12_;
+ ArtField* class12_field1_;
+ ArtMethod* class12_method1_;
+ ArtField* class2_field1_;
+ ArtMethod* class2_method1_;
+ ArtMethod* class2_method1_i_;
+ ArtField* class3_field1_;
+ ArtMethod* class3_method1_;
+ ArtMethod* class3_method1_i_;
+};
+
+TEST_F(HiddenApiTest, CheckMembersRead) {
+ ASSERT_NE(nullptr, class1_field1_);
+ ASSERT_NE(nullptr, class1_field12_);
+ ASSERT_NE(nullptr, class1_init_);
+ ASSERT_NE(nullptr, class1_method1_);
+ ASSERT_NE(nullptr, class1_method1_i_);
+ ASSERT_NE(nullptr, class1_method12_);
+ ASSERT_NE(nullptr, class12_field1_);
+ ASSERT_NE(nullptr, class12_method1_);
+ ASSERT_NE(nullptr, class2_field1_);
+ ASSERT_NE(nullptr, class2_method1_);
+ ASSERT_NE(nullptr, class2_method1_i_);
+ ASSERT_NE(nullptr, class3_field1_);
+ ASSERT_NE(nullptr, class3_method1_);
+ ASSERT_NE(nullptr, class3_method1_i_);
+}
+
+TEST_F(HiddenApiTest, CheckEverythingMatchesL) {
+ ScopedObjectAccess soa(self_);
+ std::string prefix("L");
+ ASSERT_TRUE(MemberSignature(class1_field1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_field12_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_init_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_method1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_method1_i_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class12_field1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class12_method1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_method12_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class2_field1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class2_method1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class2_method1_i_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class3_field1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class3_method1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class3_method1_i_).DoesPrefixMatch(prefix));
+}
+
+TEST_F(HiddenApiTest, CheckPackageMatch) {
+ ScopedObjectAccess soa(self_);
+ std::string prefix("Lmypackage/packagea/");
+ ASSERT_TRUE(MemberSignature(class1_field1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_field12_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_init_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_method1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_method1_i_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_method12_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class12_field1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class12_method1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class2_field1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class2_method1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class2_method1_i_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class3_field1_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class3_method1_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class3_method1_i_).DoesPrefixMatch(prefix));
+}
+
+TEST_F(HiddenApiTest, CheckClassMatch) {
+ ScopedObjectAccess soa(self_);
+ std::string prefix("Lmypackage/packagea/Class1");
+ ASSERT_TRUE(MemberSignature(class1_field1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_field12_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_init_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_method1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_method1_i_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_method12_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class12_field1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class12_method1_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class2_field1_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class2_method1_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class2_method1_i_).DoesPrefixMatch(prefix));
+}
+
+TEST_F(HiddenApiTest, CheckClassExactMatch) {
+ ScopedObjectAccess soa(self_);
+ std::string prefix("Lmypackage/packagea/Class1;");
+ ASSERT_TRUE(MemberSignature(class1_field1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_field12_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_init_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_method1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_method1_i_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class12_field1_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class12_method1_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class2_field1_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class2_method1_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class2_method1_i_).DoesPrefixMatch(prefix));
+}
+
+TEST_F(HiddenApiTest, CheckMethodMatch) {
+ ScopedObjectAccess soa(self_);
+ std::string prefix("Lmypackage/packagea/Class1;->method1");
+ ASSERT_FALSE(MemberSignature(class1_field1_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class1_field12_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class1_init_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_method1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_method1_i_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_method12_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class12_field1_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class12_method1_).DoesPrefixMatch(prefix));
+}
+
+TEST_F(HiddenApiTest, CheckMethodExactMatch) {
+ ScopedObjectAccess soa(self_);
+ std::string prefix("Lmypackage/packagea/Class1;->method1(");
+ ASSERT_FALSE(MemberSignature(class1_field1_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class1_field12_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class1_init_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_method1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_method1_i_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class1_method12_).DoesPrefixMatch(prefix));
+}
+
+TEST_F(HiddenApiTest, CheckMethodSignatureMatch) {
+ ScopedObjectAccess soa(self_);
+ std::string prefix("Lmypackage/packagea/Class1;->method1(I)");
+ ASSERT_FALSE(MemberSignature(class1_field1_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class1_field12_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class1_method1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_method1_i_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class1_method12_).DoesPrefixMatch(prefix));
+}
+
+TEST_F(HiddenApiTest, CheckMethodSignatureAndReturnMatch) {
+ ScopedObjectAccess soa(self_);
+ std::string prefix("Lmypackage/packagea/Class1;->method1()V");
+ ASSERT_FALSE(MemberSignature(class1_field1_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class1_field12_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_method1_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class1_method1_i_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class1_method12_).DoesPrefixMatch(prefix));
+}
+
+TEST_F(HiddenApiTest, CheckFieldMatch) {
+ ScopedObjectAccess soa(self_);
+ std::string prefix("Lmypackage/packagea/Class1;->field1");
+ ASSERT_TRUE(MemberSignature(class1_field1_).DoesPrefixMatch(prefix));
+ ASSERT_TRUE(MemberSignature(class1_field12_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class1_method1_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class1_method1_i_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class1_method12_).DoesPrefixMatch(prefix));
+}
+
+TEST_F(HiddenApiTest, CheckFieldExactMatch) {
+ ScopedObjectAccess soa(self_);
+ std::string prefix("Lmypackage/packagea/Class1;->field1:");
+ ASSERT_TRUE(MemberSignature(class1_field1_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class1_field12_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class1_method1_).DoesPrefixMatch(prefix));
+}
+
+TEST_F(HiddenApiTest, CheckFieldTypeMatch) {
+ ScopedObjectAccess soa(self_);
+ std::string prefix("Lmypackage/packagea/Class1;->field1:I");
+ ASSERT_TRUE(MemberSignature(class1_field1_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class1_field12_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class1_method1_).DoesPrefixMatch(prefix));
+}
+
+TEST_F(HiddenApiTest, CheckConstructorMatch) {
+ ScopedObjectAccess soa(self_);
+ std::string prefix("Lmypackage/packagea/Class1;-><init>");
+ ASSERT_TRUE(MemberSignature(class1_init_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class1_method1_).DoesPrefixMatch(prefix));
+}
+
+TEST_F(HiddenApiTest, CheckConstructorExactMatch) {
+ ScopedObjectAccess soa(self_);
+ std::string prefix("Lmypackage/packagea/Class1;-><init>()V");
+ ASSERT_TRUE(MemberSignature(class1_init_).DoesPrefixMatch(prefix));
+ ASSERT_FALSE(MemberSignature(class1_method1_).DoesPrefixMatch(prefix));
+}
+
+TEST_F(HiddenApiTest, CheckMethodSignatureTrailingCharsNoMatch) {
+ ScopedObjectAccess soa(self_);
+ std::string prefix("Lmypackage/packagea/Class1;->method1()Vfoo");
+ ASSERT_FALSE(MemberSignature(class1_method1_).DoesPrefixMatch(prefix));
+}
+
+TEST_F(HiddenApiTest, CheckConstructorTrailingCharsNoMatch) {
+ ScopedObjectAccess soa(self_);
+ std::string prefix("Lmypackage/packagea/Class1;-><init>()Vfoo");
+ ASSERT_FALSE(MemberSignature(class1_init_).DoesPrefixMatch(prefix));
+}
+
+TEST_F(HiddenApiTest, CheckFieldTrailingCharsNoMatch) {
+ ScopedObjectAccess soa(self_);
+ std::string prefix("Lmypackage/packagea/Class1;->field1:Ifoo");
+ ASSERT_FALSE(MemberSignature(class1_field1_).DoesPrefixMatch(prefix));
+}
+
+} // namespace art
diff --git a/runtime/image.cc b/runtime/image.cc
index f14707874b..316f7a5c63 100644
--- a/runtime/image.cc
+++ b/runtime/image.cc
@@ -26,7 +26,7 @@
namespace art {
const uint8_t ImageHeader::kImageMagic[] = { 'a', 'r', 't', '\n' };
-const uint8_t ImageHeader::kImageVersion[] = { '0', '5', '8', '\0' }; // R^3 Bitstring type check.
+const uint8_t ImageHeader::kImageVersion[] = { '0', '5', '9', '\0' }; // ReachabilityFence.
ImageHeader::ImageHeader(uint32_t image_begin,
uint32_t image_size,
diff --git a/runtime/interpreter/interpreter_intrinsics.cc b/runtime/interpreter/interpreter_intrinsics.cc
index 681a582b5d..69dae31b37 100644
--- a/runtime/interpreter/interpreter_intrinsics.cc
+++ b/runtime/interpreter/interpreter_intrinsics.cc
@@ -91,7 +91,7 @@ BINARY_II_INTRINSIC(MterpIntegerRotateLeft, (Rot<int32_t, true>), SetI);
// java.lang.Integer.signum(I)I
UNARY_INTRINSIC(MterpIntegerSignum, Signum, GetVReg, SetI);
-// java.lang.Long.reverse(I)I
+// java.lang.Long.reverse(J)J
UNARY_INTRINSIC(MterpLongReverse, ReverseBits64, GetVRegLong, SetJ);
// java.lang.Long.reverseBytes(J)J
@@ -399,6 +399,16 @@ VAR_HANDLE_ACCESSOR_INTRINSIC(VarHandleWeakCompareAndSetAcquire)
VAR_HANDLE_ACCESSOR_INTRINSIC(VarHandleWeakCompareAndSetPlain)
VAR_HANDLE_ACCESSOR_INTRINSIC(VarHandleWeakCompareAndSetRelease)
+static ALWAYS_INLINE bool MterpReachabilityFence(ShadowFrame* shadow_frame ATTRIBUTE_UNUSED,
+ const Instruction* inst ATTRIBUTE_UNUSED,
+ uint16_t inst_data ATTRIBUTE_UNUSED,
+ JValue* result_register ATTRIBUTE_UNUSED)
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ // Do nothing; Its only purpose is to keep the argument reference live
+ // at preceding suspend points. That's automatic in the interpreter.
+ return true;
+}
+
// Macro to help keep track of what's left to implement.
#define UNIMPLEMENTED_CASE(name) \
case Intrinsics::k##name: \
@@ -499,6 +509,7 @@ bool MterpHandleIntrinsic(ShadowFrame* shadow_frame,
UNIMPLEMENTED_CASE(MemoryPokeIntNative /* (JI)V */)
UNIMPLEMENTED_CASE(MemoryPokeLongNative /* (JJ)V */)
UNIMPLEMENTED_CASE(MemoryPokeShortNative /* (JS)V */)
+ INTRINSIC_CASE(ReachabilityFence /* (Ljava/lang/Object;)V */)
INTRINSIC_CASE(StringCharAt)
INTRINSIC_CASE(StringCompareTo)
INTRINSIC_CASE(StringEquals)
diff --git a/runtime/interpreter/unstarted_runtime.cc b/runtime/interpreter/unstarted_runtime.cc
index 76df65f730..4c7a97dfa8 100644
--- a/runtime/interpreter/unstarted_runtime.cc
+++ b/runtime/interpreter/unstarted_runtime.cc
@@ -184,6 +184,7 @@ static ALWAYS_INLINE bool ShouldBlockAccessToMember(T* member, ShadowFrame* fram
return hiddenapi::ShouldBlockAccessToMember(
member,
frame->GetMethod()->GetDeclaringClass()->GetClassLoader(),
+ frame->GetMethod()->GetDeclaringClass()->GetDexCache(),
hiddenapi::kReflection); // all uses in this file are from reflection
}
@@ -1537,7 +1538,7 @@ void UnstartedRuntime::UnstartedUnsafePutOrderedObject(
}
int64_t offset = shadow_frame->GetVRegLong(arg_offset + 2);
mirror::Object* newValue = shadow_frame->GetVRegReference(arg_offset + 4);
- QuasiAtomic::ThreadFenceRelease();
+ std::atomic_thread_fence(std::memory_order_release);
if (Runtime::Current()->IsActiveTransaction()) {
obj->SetFieldObject<true>(MemberOffset(offset), newValue);
} else {
diff --git a/runtime/intrinsics_list.h b/runtime/intrinsics_list.h
index da08793f59..2f91f5dfe0 100644
--- a/runtime/intrinsics_list.h
+++ b/runtime/intrinsics_list.h
@@ -218,6 +218,7 @@
V(VarHandleReleaseFence, kStatic, kNeedsEnvironmentOrCache, kWriteSideEffects, kNoThrow, "Ljava/lang/invoke/VarHandle;", "releaseFence", "()V") \
V(VarHandleLoadLoadFence, kStatic, kNeedsEnvironmentOrCache, kWriteSideEffects, kNoThrow, "Ljava/lang/invoke/VarHandle;", "loadLoadFence", "()V") \
V(VarHandleStoreStoreFence, kStatic, kNeedsEnvironmentOrCache, kReadSideEffects, kNoThrow, "Ljava/lang/invoke/VarHandle;", "storeStoreFence", "()V") \
+ V(ReachabilityFence, kStatic, kNeedsEnvironmentOrCache, kWriteSideEffects, kNoThrow, "Ljava/lang/ref/Reference;", "reachabilityFence", "(Ljava/lang/Object;)V") \
SIGNATURE_POLYMORPHIC_INTRINSICS_LIST(V)
#endif // ART_RUNTIME_INTRINSICS_LIST_H_
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 5618b6ebf9..de64fdd2c9 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -1539,7 +1539,7 @@ ProfilingInfo* JitCodeCache::AddProfilingInfoInternal(Thread* self ATTRIBUTE_UNU
// Make sure other threads see the data in the profiling info object before the
// store in the ArtMethod's ProfilingInfo pointer.
- QuasiAtomic::ThreadFenceRelease();
+ std::atomic_thread_fence(std::memory_order_release);
method->SetProfilingInfo(info);
profiling_infos_.push_back(info);
diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc
index b78fcacc08..f309581735 100644
--- a/runtime/jni_internal.cc
+++ b/runtime/jni_internal.cc
@@ -80,18 +80,15 @@ namespace art {
// things not rendering correctly. E.g. b/16858794
static constexpr bool kWarnJniAbort = false;
-static bool IsCallerInBootClassPath(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_) {
- ObjPtr<mirror::Class> klass = GetCallingClass(self, /* num_frames */ 1);
- // If `klass` is null, it is an unattached native thread. Assume this is
- // *not* boot class path.
- return klass != nullptr && klass->IsBootStrapClassLoaded();
+static bool IsCallerInPlatformDex(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_) {
+ return hiddenapi::IsCallerInPlatformDex(GetCallingClass(self, /* num_frames */ 1));
}
template<typename T>
ALWAYS_INLINE static bool ShouldBlockAccessToMember(T* member, Thread* self)
REQUIRES_SHARED(Locks::mutator_lock_) {
return hiddenapi::ShouldBlockAccessToMember(
- member, self, IsCallerInBootClassPath, hiddenapi::kJNI);
+ member, self, IsCallerInPlatformDex, hiddenapi::kJNI);
}
// Helpers to call instrumentation functions for fields. These take jobjects so we don't need to set
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h
index f0898f49d3..72b31790f0 100644
--- a/runtime/mirror/class-inl.h
+++ b/runtime/mirror/class-inl.h
@@ -31,7 +31,6 @@
#include "dex/invoke_type.h"
#include "dex_cache.h"
#include "gc/heap-inl.h"
-#include "hidden_api.h"
#include "iftable.h"
#include "subtype_check.h"
#include "object-inl.h"
diff --git a/runtime/monitor.cc b/runtime/monitor.cc
index e110763300..f246d8b1c0 100644
--- a/runtime/monitor.cc
+++ b/runtime/monitor.cc
@@ -1101,7 +1101,7 @@ mirror::Object* Monitor::MonitorEnter(Thread* self, mirror::Object* obj, bool tr
case LockWord::kFatLocked: {
// We should have done an acquire read of the lockword initially, to ensure
// visibility of the monitor data structure. Use an explicit fence instead.
- QuasiAtomic::ThreadFenceAcquire();
+ std::atomic_thread_fence(std::memory_order_acquire);
Monitor* mon = lock_word.FatLockMonitor();
if (trylock) {
return mon->TryLock(self) ? h_obj.Get() : nullptr;
diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc
index 505b745200..a5ade6f30f 100644
--- a/runtime/native/dalvik_system_VMRuntime.cc
+++ b/runtime/native/dalvik_system_VMRuntime.cc
@@ -78,6 +78,21 @@ static jboolean VMRuntime_hasUsedHiddenApi(JNIEnv*, jobject) {
return Runtime::Current()->HasPendingHiddenApiWarning() ? JNI_TRUE : JNI_FALSE;
}
+static void VMRuntime_setHiddenApiExemptions(JNIEnv* env,
+ jclass,
+ jobjectArray exemptions) {
+ std::vector<std::string> exemptions_vec;
+ int exemptions_length = env->GetArrayLength(exemptions);
+ for (int i = 0; i < exemptions_length; i++) {
+ jstring exemption = reinterpret_cast<jstring>(env->GetObjectArrayElement(exemptions, i));
+ const char* raw_exemption = env->GetStringUTFChars(exemption, nullptr);
+ exemptions_vec.push_back(raw_exemption);
+ env->ReleaseStringUTFChars(exemption, raw_exemption);
+ }
+
+ Runtime::Current()->SetHiddenApiExemptions(exemptions_vec);
+}
+
static jobject VMRuntime_newNonMovableArray(JNIEnv* env, jobject, jclass javaElementClass,
jint length) {
ScopedFastNativeObjectAccess soa(env);
@@ -672,6 +687,7 @@ static JNINativeMethod gMethods[] = {
NATIVE_METHOD(VMRuntime, concurrentGC, "()V"),
NATIVE_METHOD(VMRuntime, disableJitCompilation, "()V"),
NATIVE_METHOD(VMRuntime, hasUsedHiddenApi, "()Z"),
+ NATIVE_METHOD(VMRuntime, setHiddenApiExemptions, "([Ljava/lang/String;)V"),
NATIVE_METHOD(VMRuntime, getTargetHeapUtilization, "()F"),
FAST_NATIVE_METHOD(VMRuntime, isDebuggerActive, "()Z"),
FAST_NATIVE_METHOD(VMRuntime, isNativeDebuggable, "()Z"),
diff --git a/runtime/native/dalvik_system_ZygoteHooks.cc b/runtime/native/dalvik_system_ZygoteHooks.cc
index d9a5096331..cf0a72a477 100644
--- a/runtime/native/dalvik_system_ZygoteHooks.cc
+++ b/runtime/native/dalvik_system_ZygoteHooks.cc
@@ -27,6 +27,7 @@
#include "base/mutex.h"
#include "base/runtime_debug.h"
#include "debugger.h"
+#include "hidden_api.h"
#include "java_vm_ext.h"
#include "jit/jit.h"
#include "jni_internal.h"
diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc
index fc61c9597e..ad05856eaf 100644
--- a/runtime/native/java_lang_Class.cc
+++ b/runtime/native/java_lang_Class.cc
@@ -49,8 +49,8 @@
namespace art {
-// Returns true if the first non-ClassClass caller up the stack is in boot class path.
-static bool IsCallerInBootClassPath(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_) {
+// Returns true if the first non-ClassClass caller up the stack is in a platform dex file.
+static bool IsCallerInPlatformDex(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_) {
// Walk the stack and find the first frame not from java.lang.Class.
// This is very expensive. Save this till the last.
struct FirstNonClassClassCallerVisitor : public StackVisitor {
@@ -82,7 +82,7 @@ static bool IsCallerInBootClassPath(Thread* self) REQUIRES_SHARED(Locks::mutator
FirstNonClassClassCallerVisitor visitor(self);
visitor.WalkStack();
return visitor.caller != nullptr &&
- visitor.caller->GetDeclaringClass()->IsBootStrapClassLoaded();
+ hiddenapi::IsCallerInPlatformDex(visitor.caller->GetDeclaringClass());
}
// Returns true if the first non-ClassClass caller up the stack is not allowed to
@@ -90,7 +90,7 @@ static bool IsCallerInBootClassPath(Thread* self) REQUIRES_SHARED(Locks::mutator
ALWAYS_INLINE static bool ShouldEnforceHiddenApi(Thread* self)
REQUIRES_SHARED(Locks::mutator_lock_) {
hiddenapi::EnforcementPolicy policy = Runtime::Current()->GetHiddenApiEnforcementPolicy();
- return policy != hiddenapi::EnforcementPolicy::kNoChecks && !IsCallerInBootClassPath(self);
+ return policy != hiddenapi::EnforcementPolicy::kNoChecks && !IsCallerInPlatformDex(self);
}
// Returns true if the first non-ClassClass caller up the stack should not be
@@ -99,7 +99,7 @@ template<typename T>
ALWAYS_INLINE static bool ShouldBlockAccessToMember(T* member, Thread* self)
REQUIRES_SHARED(Locks::mutator_lock_) {
return hiddenapi::ShouldBlockAccessToMember(
- member, self, IsCallerInBootClassPath, hiddenapi::kReflection);
+ member, self, IsCallerInPlatformDex, hiddenapi::kReflection);
}
// Returns true if a class member should be discoverable with reflection given
diff --git a/runtime/native/sun_misc_Unsafe.cc b/runtime/native/sun_misc_Unsafe.cc
index 25f984f6be..fb00ae3967 100644
--- a/runtime/native/sun_misc_Unsafe.cc
+++ b/runtime/native/sun_misc_Unsafe.cc
@@ -116,7 +116,7 @@ static void Unsafe_putOrderedInt(JNIEnv* env, jobject, jobject javaObj, jlong of
ScopedFastNativeObjectAccess soa(env);
ObjPtr<mirror::Object> obj = soa.Decode<mirror::Object>(javaObj);
// TODO: A release store is likely to be faster on future processors.
- QuasiAtomic::ThreadFenceRelease();
+ std::atomic_thread_fence(std::memory_order_release);
// JNI must use non transactional mode.
obj->SetField32<false>(MemberOffset(offset), newValue);
}
@@ -152,7 +152,7 @@ static void Unsafe_putOrderedLong(JNIEnv* env, jobject, jobject javaObj, jlong o
jlong newValue) {
ScopedFastNativeObjectAccess soa(env);
ObjPtr<mirror::Object> obj = soa.Decode<mirror::Object>(javaObj);
- QuasiAtomic::ThreadFenceRelease();
+ std::atomic_thread_fence(std::memory_order_release);
// JNI must use non transactional mode.
obj->SetField64<false>(MemberOffset(offset), newValue);
}
@@ -194,7 +194,7 @@ static void Unsafe_putOrderedObject(JNIEnv* env, jobject, jobject javaObj, jlong
ScopedFastNativeObjectAccess soa(env);
ObjPtr<mirror::Object> obj = soa.Decode<mirror::Object>(javaObj);
ObjPtr<mirror::Object> newValue = soa.Decode<mirror::Object>(javaNewValue);
- QuasiAtomic::ThreadFenceRelease();
+ std::atomic_thread_fence(std::memory_order_release);
// JNI must use non transactional mode.
obj->SetFieldObject<false>(MemberOffset(offset), newValue);
}
diff --git a/runtime/native_stack_dump.cc b/runtime/native_stack_dump.cc
index 0db1770eea..14f3f45f9e 100644
--- a/runtime/native_stack_dump.cc
+++ b/runtime/native_stack_dump.cc
@@ -429,7 +429,8 @@ void DumpNativeStack(std::ostream& os ATTRIBUTE_UNUSED,
BacktraceMap* existing_map ATTRIBUTE_UNUSED,
const char* prefix ATTRIBUTE_UNUSED,
ArtMethod* current_method ATTRIBUTE_UNUSED,
- void* ucontext_ptr ATTRIBUTE_UNUSED) {
+ void* ucontext_ptr ATTRIBUTE_UNUSED,
+ bool skip_frames ATTRIBUTE_UNUSED) {
}
void DumpKernelStack(std::ostream& os ATTRIBUTE_UNUSED,
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 9a626bab00..b80ce7de46 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -86,6 +86,7 @@
#include "gc/space/space-inl.h"
#include "gc/system_weak.h"
#include "handle_scope-inl.h"
+#include "hidden_api.h"
#include "image-inl.h"
#include "instrumentation.h"
#include "intern_table.h"
diff --git a/runtime/runtime.h b/runtime/runtime.h
index dba31b2939..03f17bc04a 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -536,6 +536,14 @@ class Runtime {
pending_hidden_api_warning_ = value;
}
+ void SetHiddenApiExemptions(const std::vector<std::string>& exemptions) {
+ hidden_api_exemptions_ = exemptions;
+ }
+
+ const std::vector<std::string>& GetHiddenApiExemptions() {
+ return hidden_api_exemptions_;
+ }
+
bool HasPendingHiddenApiWarning() const {
return pending_hidden_api_warning_;
}
@@ -996,6 +1004,9 @@ class Runtime {
// Whether access checks on hidden API should be performed.
hiddenapi::EnforcementPolicy hidden_api_policy_;
+ // List of signature prefixes of methods that have been removed from the blacklist
+ std::vector<std::string> hidden_api_exemptions_;
+
// Whether the application has used an API which is not restricted but we
// should issue a warning about it.
bool pending_hidden_api_warning_;
diff --git a/runtime/thread.cc b/runtime/thread.cc
index b13d8ec42a..d17f409a7d 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -2881,6 +2881,17 @@ jobjectArray Thread::CreateAnnotatedStackTrace(const ScopedObjectAccessAlreadyRu
Handle<mirror::Class> h_aste_class(hs.NewHandle<mirror::Class>(
h_aste_array_class->GetComponentType()));
+
+ // Make sure the AnnotatedStackTraceElement.class is initialized, b/76208924 .
+ class_linker->EnsureInitialized(soa.Self(),
+ h_aste_class,
+ /* can_init_fields */ true,
+ /* can_init_parents */ true);
+ if (soa.Self()->IsExceptionPending()) {
+ // This should not fail in a healthy runtime.
+ return nullptr;
+ }
+
ArtField* stack_trace_element_field = h_aste_class->FindField(
soa.Self(), h_aste_class.Get(), "stackTraceElement", "Ljava/lang/StackTraceElement;");
DCHECK(stack_trace_element_field != nullptr);
diff --git a/test/036-finalizer/src/Main.java b/test/036-finalizer/src/Main.java
index 51d4a81150..be7ae4a8c2 100644
--- a/test/036-finalizer/src/Main.java
+++ b/test/036-finalizer/src/Main.java
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
@@ -80,6 +81,7 @@ public class Main {
// the test fail (even when keeping the `null` assignment). b/76454261
FinalizerTest keepLive = wimp.get();
System.out.println("wimp: " + wimpString(wimp));
+ Reference.reachabilityFence(keepLive);
keepLive = null; // Clear the reference.
/* this will try to collect and finalize ft */
diff --git a/test/072-reachability-fence/expected.txt b/test/072-reachability-fence/expected.txt
new file mode 100644
index 0000000000..fdd0d7bd59
--- /dev/null
+++ b/test/072-reachability-fence/expected.txt
@@ -0,0 +1,5 @@
+Starting
+Reference 0 was live.
+Reference 3 was live.
+Reference 4 was live.
+Finished
diff --git a/test/072-reachability-fence/info.txt b/test/072-reachability-fence/info.txt
new file mode 100644
index 0000000000..21b6d6a39f
--- /dev/null
+++ b/test/072-reachability-fence/info.txt
@@ -0,0 +1,4 @@
+Check that reachabilityFence() prevents garbage collection of objects only referred to by a dead
+reference.
+
+This is not very convincing, since we currently usually keep such objects around anyway.
diff --git a/test/072-reachability-fence/src/Main.java b/test/072-reachability-fence/src/Main.java
new file mode 100644
index 0000000000..ac1e131d99
--- /dev/null
+++ b/test/072-reachability-fence/src/Main.java
@@ -0,0 +1,61 @@
+/*
+ * 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.ref.Reference;
+import java.lang.ref.WeakReference;
+
+public class Main {
+ public static void main(String[] args) {
+ System.out.println("Starting");
+ WeakReference wrefs[] = new WeakReference[5];
+ String str0 = generateString("String", 0);
+ String str1 = generateString("String", 1);
+ String str2 = generateString("String", 2);
+ String str3 = generateString("String", 3);
+ String str4 = generateString("String", 4);
+ wrefs[0] = new WeakReference(str0);
+ wrefs[1] = new WeakReference(str1);
+ wrefs[2] = new WeakReference(str2);
+ wrefs[3] = new WeakReference(str3);
+ wrefs[4] = new WeakReference(str4);
+ // Clear a couple as a sanity check.
+ str1 = null;
+ str2 = null;
+ // str<n> dead here; in the future we will possibly reuse the registers.
+ // Give the compiler something to fill the registers with.
+ String str5 = generateString("String", 5);
+ String str6 = generateString("String", 6);
+ String str7 = generateString("String", 7);
+ String str8 = generateString("String", 8);
+ String str9 = generateString("String", 9);
+ Runtime.getRuntime().gc();
+ for (int i = 0; i < 5; ++i) {
+ if (wrefs[i].get() != null) {
+ System.out.println("Reference " + i + " was live.");
+ }
+ }
+ Reference.reachabilityFence(str0);
+ Reference.reachabilityFence(str1);
+ Reference.reachabilityFence(str2);
+ Reference.reachabilityFence(str3);
+ Reference.reachabilityFence(str4);
+ System.out.println("Finished");
+ }
+
+ private static String generateString(String base, int num) {
+ return base + num;
+ }
+}
diff --git a/test/166-bad-interface-super/build b/test/166-bad-interface-super/build
deleted file mode 100644
index d85147f17b..0000000000
--- a/test/166-bad-interface-super/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/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.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/651-checker-byte-simd-minmax/expected.txt b/test/171-init-aste/expected.txt
index b0aad4deb5..b0aad4deb5 100644
--- a/test/651-checker-byte-simd-minmax/expected.txt
+++ b/test/171-init-aste/expected.txt
diff --git a/test/171-init-aste/info.txt b/test/171-init-aste/info.txt
new file mode 100644
index 0000000000..201e8ada57
--- /dev/null
+++ b/test/171-init-aste/info.txt
@@ -0,0 +1 @@
+Regression test for failure to initialize dalvik.system.AnnotatedStackTraceElement.
diff --git a/test/171-init-aste/src-art/Main.java b/test/171-init-aste/src-art/Main.java
new file mode 100644
index 0000000000..9d3661022e
--- /dev/null
+++ b/test/171-init-aste/src-art/Main.java
@@ -0,0 +1,37 @@
+/*
+ * 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.reflect.Method;
+import dalvik.system.AnnotatedStackTraceElement;
+
+public class Main {
+ public static void main(String args[]) throws Exception {
+ Class<?> vmStack = Class.forName("dalvik.system.VMStack");
+ Method getAnnotatedThreadStackTrace =
+ vmStack.getDeclaredMethod("getAnnotatedThreadStackTrace", Thread.class);
+ Object[] annotatedStackTrace =
+ (Object[]) getAnnotatedThreadStackTrace.invoke(null, Thread.currentThread());
+ AnnotatedStackTraceElement annotatedElement =
+ (AnnotatedStackTraceElement) annotatedStackTrace[0];
+ // This used to fail an assertion that the AnnotatedStackTraceElement.class
+ // is at least initializing (i.e. initializing, initialized or resolved-erroneous).
+ // Note: We cannot use reflection for this test because getDeclaredMethod() would
+ // initialize the class and hide the failure.
+ annotatedElement.getStackTraceElement();
+
+ System.out.println("passed");
+ }
+}
diff --git a/test/171-init-aste/src/Main.java b/test/171-init-aste/src/Main.java
new file mode 100644
index 0000000000..4479cb4373
--- /dev/null
+++ b/test/171-init-aste/src/Main.java
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+public class Main {
+ // Note: This file is used for the RI which does not support
+ // dalvik.system.AnnotatedStackTraceElement (see src-art/Main.java),
+ // so that we do not need an exclusion in known failures.
+ public static void main(String args[]) throws Exception {
+ System.out.println("passed");
+ }
+}
diff --git a/test/1940-ddms-ext/check b/test/1940-ddms-ext/check
deleted file mode 100755
index 91966b41a0..0000000000
--- a/test/1940-ddms-ext/check
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2017 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.
-
-# Need to pull out the describeException ouput since that won't be there on
-# device.
-./remove_error.py "$2" "./expected_error.txt" > "$2.tmp"
-
-./default-check "$1" "$2.tmp"
diff --git a/test/1940-ddms-ext/expected_error.txt b/test/1940-ddms-ext/expected_error.txt
deleted file mode 100644
index 73883b46e2..0000000000
--- a/test/1940-ddms-ext/expected_error.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-java.lang.ArrayIndexOutOfBoundsException: byte[] offset=12 length=55 src.length=1
- at art.Test1940.processChunk(Native Method)
- at art.Test1940.run(Test1940.java:156)
- at Main.main(Main.java:19)
diff --git a/test/1940-ddms-ext/remove_error.py b/test/1940-ddms-ext/remove_error.py
deleted file mode 100755
index 638c479a31..0000000000
--- a/test/1940-ddms-ext/remove_error.py
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/usr/bin/env python3
-#
-# 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 argparse
-
-def main():
- parser = argparse.ArgumentParser()
- parser.add_argument('input_data', type=open)
- parser.add_argument('expected_error', type=str)
- args = parser.parse_args()
-
- for line in map(str.rstrip, args.input_data.readlines()):
- print_full = True
- with open(args.expected_error) as err_file:
- for err_line in map(str.rstrip, err_file):
- if line.startswith(err_line):
- print_full = False
- if line != err_line:
- print(line[len(err_line):])
- break
- if print_full and line != '':
- print(line)
-
-if __name__ == '__main__':
- main()
diff --git a/test/411-optimizing-arith-mul/info.txt b/test/411-optimizing-arith-mul/info.txt
deleted file mode 100644
index 10155512f0..0000000000
--- a/test/411-optimizing-arith-mul/info.txt
+++ /dev/null
@@ -1 +0,0 @@
-Tests for basic arithmethic operations.
diff --git a/test/411-optimizing-arith-mul/expected.txt b/test/411-optimizing-arith/expected.txt
index e69de29bb2..e69de29bb2 100644
--- a/test/411-optimizing-arith-mul/expected.txt
+++ b/test/411-optimizing-arith/expected.txt
diff --git a/test/411-optimizing-arith/info.txt b/test/411-optimizing-arith/info.txt
new file mode 100644
index 0000000000..42be5d564f
--- /dev/null
+++ b/test/411-optimizing-arith/info.txt
@@ -0,0 +1,7 @@
+Tests for basic arithmethic operations:
+ - multiply,
+ - subtract,
+ - negate,
+ - division,
+ - modulo (rem),
+ - shifts.
diff --git a/test/417-optimizing-arith-div/src/Main.java b/test/411-optimizing-arith/src/DivTest.java
index 68e89b3eb2..7696d0a806 100644
--- a/test/417-optimizing-arith-div/src/Main.java
+++ b/test/411-optimizing-arith/src/DivTest.java
@@ -16,7 +16,7 @@
// Note that $opt$ is a marker for the optimizing compiler to test
// it does compile the method.
-public class Main {
+public class DivTest {
public static void expectEquals(int expected, int result) {
if (expected != result) {
@@ -98,11 +98,7 @@ public class Main {
}
}
- public static void main(String[] args) {
- div();
- }
-
- public static void div() {
+ public static void main() {
divInt();
divLong();
divFloat();
diff --git a/test/411-optimizing-arith/src/Main.java b/test/411-optimizing-arith/src/Main.java
new file mode 100644
index 0000000000..e1a43d3b57
--- /dev/null
+++ b/test/411-optimizing-arith/src/Main.java
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+public class Main {
+ public static void main(String args[]) {
+ MulTest.main();
+ SubTest.main();
+ NegTest.main();
+ DivTest.main();
+ RemTest.main();
+ ShiftsTest.main();
+ }
+}
diff --git a/test/411-optimizing-arith-mul/src/Main.java b/test/411-optimizing-arith/src/MulTest.java
index 60e418e1e5..b9bffca0d1 100644
--- a/test/411-optimizing-arith-mul/src/Main.java
+++ b/test/411-optimizing-arith/src/MulTest.java
@@ -16,7 +16,7 @@
// Note that $opt$ is a marker for the optimizing compiler to test
// it does compile the method.
-public class Main {
+public class MulTest {
public static void expectEquals(int expected, int result) {
if (expected != result) {
@@ -72,11 +72,7 @@ public class Main {
}
}
- public static void main(String[] args) {
- mul();
- }
-
- public static void mul() {
+ public static void main() {
mulInt();
mulLong();
mulFloat();
@@ -129,9 +125,12 @@ public class Main {
expectEquals(Float.NEGATIVE_INFINITY, $opt$Mul(-2F, 3.40282346638528860e+38F));
expectEquals(Float.NEGATIVE_INFINITY, $opt$Mul(2F, Float.NEGATIVE_INFINITY));
expectEquals(Float.POSITIVE_INFINITY, $opt$Mul(-2F, Float.NEGATIVE_INFINITY));
- expectEquals(Float.NEGATIVE_INFINITY, $opt$Mul(Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY));
- expectEquals(Float.POSITIVE_INFINITY, $opt$Mul(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY));
- expectEquals(Float.POSITIVE_INFINITY, $opt$Mul(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY));
+ expectEquals(Float.NEGATIVE_INFINITY,
+ $opt$Mul(Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY));
+ expectEquals(Float.POSITIVE_INFINITY,
+ $opt$Mul(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY));
+ expectEquals(Float.POSITIVE_INFINITY,
+ $opt$Mul(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY));
}
private static void mulDouble() {
diff --git a/test/415-optimizing-arith-neg/src/Main.java b/test/411-optimizing-arith/src/NegTest.java
index c53b639d40..83047269bb 100644
--- a/test/415-optimizing-arith-neg/src/Main.java
+++ b/test/411-optimizing-arith/src/NegTest.java
@@ -17,7 +17,7 @@
// Note that $opt$ is a marker for the optimizing compiler to test
// it does compile the method, and that $noinline$ is a marker to
// test that it does not inline it.
-public class Main {
+public class NegTest {
public static void assertEquals(int expected, int result) {
if (expected != result) {
@@ -67,7 +67,7 @@ public class Main {
}
}
- public static void main(String[] args) {
+ public static void main() {
negInt();
$opt$noinline$InplaceNegOneInt(1);
@@ -169,55 +169,29 @@ public class Main {
}
- static boolean doThrow = false;
-
private static void $opt$noinline$InplaceNegOneInt(int a) {
- if (doThrow) {
- // Try defeating inlining.
- throw new Error();
- }
a = -a;
assertEquals(-1, a);
}
private static void $opt$noinline$InplaceNegOneLong(long a) {
- if (doThrow) {
- // Try defeating inlining.
- throw new Error();
- }
a = -a;
assertEquals(-1L, a);
}
private static int $opt$noinline$NegInt(int a){
- if (doThrow) {
- // Try defeating inlining.
- throw new Error();
- }
return -a;
}
private static long $opt$noinline$NegLong(long a){
- if (doThrow) {
- // Try defeating inlining.
- throw new Error();
- }
return -a;
}
private static float $opt$noinline$NegFloat(float a){
- if (doThrow) {
- // Try defeating inlining.
- throw new Error();
- }
return -a;
}
private static double $opt$noinline$NegDouble(double a){
- if (doThrow) {
- // Try defeating inlining.
- throw new Error();
- }
return -a;
}
}
diff --git a/test/428-optimizing-arith-rem/src/Main.java b/test/411-optimizing-arith/src/RemTest.java
index 3f77318e6c..1b31f63569 100644
--- a/test/428-optimizing-arith-rem/src/Main.java
+++ b/test/411-optimizing-arith/src/RemTest.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-public class Main {
+public class RemTest {
- public static void main(String[] args) {
+ public static void main() {
remInt();
remLong();
}
diff --git a/test/431-optimizing-arith-shifts/src/Main.java b/test/411-optimizing-arith/src/ShiftsTest.java
index b7a112f6a3..139ff70bf0 100644
--- a/test/431-optimizing-arith-shifts/src/Main.java
+++ b/test/411-optimizing-arith/src/ShiftsTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-public class Main {
+public class ShiftsTest {
public static void expectEquals(int expected, int result) {
if (expected != result) {
@@ -28,7 +28,7 @@ public class Main {
}
}
- public static void main(String[] args) {
+ public static void main() {
testShlInt();
testShlLong();
testShrInt();
diff --git a/test/414-optimizing-arith-sub/src/Main.java b/test/411-optimizing-arith/src/SubTest.java
index b4531cdfd4..9c9ea92f20 100644
--- a/test/414-optimizing-arith-sub/src/Main.java
+++ b/test/411-optimizing-arith/src/SubTest.java
@@ -16,7 +16,7 @@
// Note that $opt$ is a marker for the optimizing compiler to test
// it does compile the method.
-public class Main {
+public class SubTest {
public static void expectEquals(int expected, int result) {
if (expected != result) {
@@ -70,7 +70,7 @@ public class Main {
}
}
- public static void main(String[] args) {
+ public static void main() {
subInt();
subLong();
subFloat();
diff --git a/test/414-optimizing-arith-sub/expected.txt b/test/414-optimizing-arith-sub/expected.txt
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/414-optimizing-arith-sub/expected.txt
+++ /dev/null
diff --git a/test/414-optimizing-arith-sub/info.txt b/test/414-optimizing-arith-sub/info.txt
deleted file mode 100644
index 1eaa14887b..0000000000
--- a/test/414-optimizing-arith-sub/info.txt
+++ /dev/null
@@ -1 +0,0 @@
-Subtraction tests.
diff --git a/test/415-optimizing-arith-neg/expected.txt b/test/415-optimizing-arith-neg/expected.txt
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/415-optimizing-arith-neg/expected.txt
+++ /dev/null
diff --git a/test/415-optimizing-arith-neg/info.txt b/test/415-optimizing-arith-neg/info.txt
deleted file mode 100644
index 8494aad938..0000000000
--- a/test/415-optimizing-arith-neg/info.txt
+++ /dev/null
@@ -1 +0,0 @@
-Tests for arithmetic negation operations.
diff --git a/test/417-optimizing-arith-div/expected.txt b/test/417-optimizing-arith-div/expected.txt
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/417-optimizing-arith-div/expected.txt
+++ /dev/null
diff --git a/test/417-optimizing-arith-div/info.txt b/test/417-optimizing-arith-div/info.txt
deleted file mode 100644
index 1374b0ffb3..0000000000
--- a/test/417-optimizing-arith-div/info.txt
+++ /dev/null
@@ -1 +0,0 @@
-Tests for division operation.
diff --git a/test/428-optimizing-arith-rem/expected.txt b/test/428-optimizing-arith-rem/expected.txt
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/428-optimizing-arith-rem/expected.txt
+++ /dev/null
diff --git a/test/428-optimizing-arith-rem/info.txt b/test/428-optimizing-arith-rem/info.txt
deleted file mode 100644
index 3e37ffeee8..0000000000
--- a/test/428-optimizing-arith-rem/info.txt
+++ /dev/null
@@ -1 +0,0 @@
-Tests for modulo (rem) operation.
diff --git a/test/431-optimizing-arith-shifts/expected.txt b/test/431-optimizing-arith-shifts/expected.txt
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/431-optimizing-arith-shifts/expected.txt
+++ /dev/null
diff --git a/test/431-optimizing-arith-shifts/info.txt b/test/431-optimizing-arith-shifts/info.txt
deleted file mode 100644
index 14ff264662..0000000000
--- a/test/431-optimizing-arith-shifts/info.txt
+++ /dev/null
@@ -1 +0,0 @@
-Tests for shift operations.
diff --git a/test/646-checker-hadd-alt-char/build b/test/646-checker-hadd-alt-char/build
deleted file mode 100644
index d85147f17b..0000000000
--- a/test/646-checker-hadd-alt-char/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/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.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/646-checker-hadd-alt-short/build b/test/646-checker-hadd-alt-short/build
deleted file mode 100644
index d85147f17b..0000000000
--- a/test/646-checker-hadd-alt-short/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/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.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/646-checker-hadd-char/build b/test/646-checker-hadd-char/build
deleted file mode 100644
index d85147f17b..0000000000
--- a/test/646-checker-hadd-char/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/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.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/646-checker-hadd-short/build b/test/646-checker-hadd-short/build
deleted file mode 100644
index d85147f17b..0000000000
--- a/test/646-checker-hadd-short/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/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.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/651-checker-char-simd-minmax/expected.txt b/test/651-checker-char-simd-minmax/expected.txt
deleted file mode 100644
index b0aad4deb5..0000000000
--- a/test/651-checker-char-simd-minmax/expected.txt
+++ /dev/null
@@ -1 +0,0 @@
-passed
diff --git a/test/651-checker-char-simd-minmax/info.txt b/test/651-checker-char-simd-minmax/info.txt
deleted file mode 100644
index 73af1242c0..0000000000
--- a/test/651-checker-char-simd-minmax/info.txt
+++ /dev/null
@@ -1 +0,0 @@
-Functional tests on min/max SIMD vectorization.
diff --git a/test/651-checker-double-simd-minmax/expected.txt b/test/651-checker-double-simd-minmax/expected.txt
deleted file mode 100644
index b0aad4deb5..0000000000
--- a/test/651-checker-double-simd-minmax/expected.txt
+++ /dev/null
@@ -1 +0,0 @@
-passed
diff --git a/test/651-checker-double-simd-minmax/info.txt b/test/651-checker-double-simd-minmax/info.txt
deleted file mode 100644
index 73af1242c0..0000000000
--- a/test/651-checker-double-simd-minmax/info.txt
+++ /dev/null
@@ -1 +0,0 @@
-Functional tests on min/max SIMD vectorization.
diff --git a/test/651-checker-float-simd-minmax/expected.txt b/test/651-checker-float-simd-minmax/expected.txt
deleted file mode 100644
index b0aad4deb5..0000000000
--- a/test/651-checker-float-simd-minmax/expected.txt
+++ /dev/null
@@ -1 +0,0 @@
-passed
diff --git a/test/651-checker-float-simd-minmax/info.txt b/test/651-checker-float-simd-minmax/info.txt
deleted file mode 100644
index 73af1242c0..0000000000
--- a/test/651-checker-float-simd-minmax/info.txt
+++ /dev/null
@@ -1 +0,0 @@
-Functional tests on min/max SIMD vectorization.
diff --git a/test/651-checker-int-simd-minmax/expected.txt b/test/651-checker-int-simd-minmax/expected.txt
deleted file mode 100644
index b0aad4deb5..0000000000
--- a/test/651-checker-int-simd-minmax/expected.txt
+++ /dev/null
@@ -1 +0,0 @@
-passed
diff --git a/test/651-checker-int-simd-minmax/info.txt b/test/651-checker-int-simd-minmax/info.txt
deleted file mode 100644
index 73af1242c0..0000000000
--- a/test/651-checker-int-simd-minmax/info.txt
+++ /dev/null
@@ -1 +0,0 @@
-Functional tests on min/max SIMD vectorization.
diff --git a/test/651-checker-long-simd-minmax/expected.txt b/test/651-checker-long-simd-minmax/expected.txt
deleted file mode 100644
index b0aad4deb5..0000000000
--- a/test/651-checker-long-simd-minmax/expected.txt
+++ /dev/null
@@ -1 +0,0 @@
-passed
diff --git a/test/651-checker-long-simd-minmax/info.txt b/test/651-checker-long-simd-minmax/info.txt
deleted file mode 100644
index 73af1242c0..0000000000
--- a/test/651-checker-long-simd-minmax/info.txt
+++ /dev/null
@@ -1 +0,0 @@
-Functional tests on min/max SIMD vectorization.
diff --git a/test/651-checker-short-simd-minmax/build b/test/651-checker-short-simd-minmax/build
deleted file mode 100644
index d85147f17b..0000000000
--- a/test/651-checker-short-simd-minmax/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/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.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/651-checker-short-simd-minmax/expected.txt b/test/651-checker-short-simd-minmax/expected.txt
deleted file mode 100644
index b0aad4deb5..0000000000
--- a/test/651-checker-short-simd-minmax/expected.txt
+++ /dev/null
@@ -1 +0,0 @@
-passed
diff --git a/test/651-checker-short-simd-minmax/info.txt b/test/651-checker-short-simd-minmax/info.txt
deleted file mode 100644
index 73af1242c0..0000000000
--- a/test/651-checker-short-simd-minmax/info.txt
+++ /dev/null
@@ -1 +0,0 @@
-Functional tests on min/max SIMD vectorization.
diff --git a/test/651-checker-simd-minmax/expected.txt b/test/651-checker-simd-minmax/expected.txt
new file mode 100644
index 0000000000..f362c45b77
--- /dev/null
+++ b/test/651-checker-simd-minmax/expected.txt
@@ -0,0 +1,7 @@
+ByteSimdMinMax passed
+CharSimdMinMax passed
+ShortSimdMinMax passed
+IntSimdMinMax passed
+LongSimdMinMax passed
+DoubleSimdMinMax passed
+FloatSimdMinMax passed
diff --git a/test/651-checker-byte-simd-minmax/info.txt b/test/651-checker-simd-minmax/info.txt
index 73af1242c0..73af1242c0 100644
--- a/test/651-checker-byte-simd-minmax/info.txt
+++ b/test/651-checker-simd-minmax/info.txt
diff --git a/test/651-checker-byte-simd-minmax/src/Main.java b/test/651-checker-simd-minmax/src/ByteSimdMinMax.java
index 4e667bbc6f..b9954947f7 100644
--- a/test/651-checker-byte-simd-minmax/src/Main.java
+++ b/test/651-checker-simd-minmax/src/ByteSimdMinMax.java
@@ -17,9 +17,9 @@
/**
* Tests for MIN/MAX vectorization.
*/
-public class Main {
+public class ByteSimdMinMax {
- /// CHECK-START: void Main.doitMin(byte[], byte[], byte[]) loop_optimization (before)
+ /// CHECK-START: void ByteSimdMinMax.doitMin(byte[], byte[], byte[]) loop_optimization (before)
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:b\d+>> ArrayGet loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Get2:b\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -27,7 +27,7 @@ public class Main {
/// CHECK-DAG: <<Cnv:b\d+>> TypeConversion [<<Min>>] loop:<<Loop>> outer_loop:none
/// CHECK-DAG: ArraySet [{{l\d+}},<<Phi>>,<<Cnv>>] loop:<<Loop>> outer_loop:none
//
- /// CHECK-START-{ARM,ARM64,MIPS64}: void Main.doitMin(byte[], byte[], byte[]) loop_optimization (after)
+ /// CHECK-START-{ARM,ARM64,MIPS64}: void ByteSimdMinMax.doitMin(byte[], byte[], byte[]) loop_optimization (after)
/// CHECK-DAG: <<Get1:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get2:d\d+>> VecLoad loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Min:d\d+>> VecMin [<<Get1>>,<<Get2>>] packed_type:Int8 loop:<<Loop>> outer_loop:none
@@ -39,7 +39,7 @@ public class Main {
}
}
- /// CHECK-START: void Main.doitMinUnsigned(byte[], byte[], byte[]) instruction_simplifier (before)
+ /// CHECK-START: void ByteSimdMinMax.doitMinUnsigned(byte[], byte[], byte[]) instruction_simplifier (before)
/// CHECK-DAG: <<I255:i\d+>> IntConstant 255 loop:none
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:b\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -50,7 +50,7 @@ public class Main {
/// CHECK-DAG: <<Cnv:b\d+>> TypeConversion [<<Min>>] loop:<<Loop>> outer_loop:none
/// CHECK-DAG: ArraySet [{{l\d+}},{{i\d+}},<<Cnv>>] loop:<<Loop>> outer_loop:none
//
- /// CHECK-START: void Main.doitMinUnsigned(byte[], byte[], byte[]) loop_optimization (before)
+ /// CHECK-START: void ByteSimdMinMax.doitMinUnsigned(byte[], byte[], byte[]) loop_optimization (before)
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:a\d+>> ArrayGet loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Get2:a\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -58,7 +58,7 @@ public class Main {
/// CHECK-DAG: <<Cnv:b\d+>> TypeConversion [<<Min>>] loop:<<Loop>> outer_loop:none
/// CHECK-DAG: ArraySet [{{l\d+}},<<Phi>>,<<Cnv>>] loop:<<Loop>> outer_loop:none
//
- /// CHECK-START-{ARM,ARM64,MIPS64}: void Main.doitMinUnsigned(byte[], byte[], byte[]) loop_optimization (after)
+ /// CHECK-START-{ARM,ARM64,MIPS64}: void ByteSimdMinMax.doitMinUnsigned(byte[], byte[], byte[]) loop_optimization (after)
/// CHECK-DAG: <<Get1:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get2:d\d+>> VecLoad loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Min:d\d+>> VecMin [<<Get1>>,<<Get2>>] packed_type:Uint8 loop:<<Loop>> outer_loop:none
@@ -70,7 +70,7 @@ public class Main {
}
}
- /// CHECK-START: void Main.doitMax(byte[], byte[], byte[]) loop_optimization (before)
+ /// CHECK-START: void ByteSimdMinMax.doitMax(byte[], byte[], byte[]) loop_optimization (before)
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:b\d+>> ArrayGet loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Get2:b\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -78,7 +78,7 @@ public class Main {
/// CHECK-DAG: <<Cnv:b\d+>> TypeConversion [<<Max>>] loop:<<Loop>> outer_loop:none
/// CHECK-DAG: ArraySet [{{l\d+}},<<Phi>>,<<Cnv>>] loop:<<Loop>> outer_loop:none
//
- /// CHECK-START-{ARM,ARM64,MIPS64}: void Main.doitMax(byte[], byte[], byte[]) loop_optimization (after)
+ /// CHECK-START-{ARM,ARM64,MIPS64}: void ByteSimdMinMax.doitMax(byte[], byte[], byte[]) loop_optimization (after)
/// CHECK-DAG: <<Get1:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get2:d\d+>> VecLoad loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Max:d\d+>> VecMax [<<Get1>>,<<Get2>>] packed_type:Int8 loop:<<Loop>> outer_loop:none
@@ -90,7 +90,7 @@ public class Main {
}
}
- /// CHECK-START: void Main.doitMaxUnsigned(byte[], byte[], byte[]) instruction_simplifier (before)
+ /// CHECK-START: void ByteSimdMinMax.doitMaxUnsigned(byte[], byte[], byte[]) instruction_simplifier (before)
/// CHECK-DAG: <<I255:i\d+>> IntConstant 255 loop:none
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:b\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -101,7 +101,7 @@ public class Main {
/// CHECK-DAG: <<Cnv:b\d+>> TypeConversion [<<Max>>] loop:<<Loop>> outer_loop:none
/// CHECK-DAG: ArraySet [{{l\d+}},{{i\d+}},<<Cnv>>] loop:<<Loop>> outer_loop:none
//
- /// CHECK-START: void Main.doitMaxUnsigned(byte[], byte[], byte[]) loop_optimization (before)
+ /// CHECK-START: void ByteSimdMinMax.doitMaxUnsigned(byte[], byte[], byte[]) loop_optimization (before)
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:a\d+>> ArrayGet loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Get2:a\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -109,7 +109,7 @@ public class Main {
/// CHECK-DAG: <<Cnv:b\d+>> TypeConversion [<<Max>>] loop:<<Loop>> outer_loop:none
/// CHECK-DAG: ArraySet [{{l\d+}},<<Phi>>,<<Cnv>>] loop:<<Loop>> outer_loop:none
//
- /// CHECK-START-{ARM,ARM64,MIPS64}: void Main.doitMaxUnsigned(byte[], byte[], byte[]) loop_optimization (after)
+ /// CHECK-START-{ARM,ARM64,MIPS64}: void ByteSimdMinMax.doitMaxUnsigned(byte[], byte[], byte[]) loop_optimization (after)
/// CHECK-DAG: <<Get1:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get2:d\d+>> VecLoad loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Max:d\d+>> VecMax [<<Get1>>,<<Get2>>] packed_type:Uint8 loop:<<Loop>> outer_loop:none
@@ -121,7 +121,7 @@ public class Main {
}
}
- /// CHECK-START: void Main.doitMin100(byte[], byte[]) loop_optimization (before)
+ /// CHECK-START: void ByteSimdMinMax.doitMin100(byte[], byte[]) loop_optimization (before)
/// CHECK-DAG: <<I100:i\d+>> IntConstant 100 loop:none
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get:b\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -129,7 +129,7 @@ public class Main {
/// CHECK-DAG: <<Cnv:b\d+>> TypeConversion [<<Min>>] loop:<<Loop>> outer_loop:none
/// CHECK-DAG: ArraySet [{{l\d+}},<<Phi>>,<<Cnv>>] loop:<<Loop>> outer_loop:none
//
- /// CHECK-START-{ARM64,MIPS64}: void Main.doitMin100(byte[], byte[]) loop_optimization (after)
+ /// CHECK-START-{ARM64,MIPS64}: void ByteSimdMinMax.doitMin100(byte[], byte[]) loop_optimization (after)
/// CHECK-DAG: <<I100:i\d+>> IntConstant 100 loop:none
/// CHECK-DAG: <<Repl:d\d+>> VecReplicateScalar [<<I100>>] loop:none
/// CHECK-DAG: <<Get:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
@@ -142,7 +142,7 @@ public class Main {
}
}
- public static void main(String[] args) {
+ public static void main() {
// Initialize cross-values for all possible values.
int total = 256 * 256;
byte[] x = new byte[total];
@@ -185,7 +185,7 @@ public class Main {
expectEquals(expected, x[i]);
}
- System.out.println("passed");
+ System.out.println("ByteSimdMinMax passed");
}
private static void expectEquals(byte expected, byte result) {
diff --git a/test/651-checker-char-simd-minmax/src/Main.java b/test/651-checker-simd-minmax/src/CharSimdMinMax.java
index 520e10b6c1..30169c4591 100644
--- a/test/651-checker-char-simd-minmax/src/Main.java
+++ b/test/651-checker-simd-minmax/src/CharSimdMinMax.java
@@ -17,9 +17,9 @@
/**
* Tests for MIN/MAX vectorization.
*/
-public class Main {
+public class CharSimdMinMax {
- /// CHECK-START: void Main.doitMin(char[], char[], char[]) loop_optimization (before)
+ /// CHECK-START: void CharSimdMinMax.doitMin(char[], char[], char[]) loop_optimization (before)
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:c\d+>> ArrayGet loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Get2:c\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -27,7 +27,7 @@ public class Main {
/// CHECK-DAG: <<Cnv:c\d+>> TypeConversion [<<Min>>] loop:<<Loop>> outer_loop:none
/// CHECK-DAG: ArraySet [{{l\d+}},<<Phi>>,<<Cnv>>] loop:<<Loop>> outer_loop:none
//
- /// CHECK-START-{ARM,ARM64,MIPS64}: void Main.doitMin(char[], char[], char[]) loop_optimization (after)
+ /// CHECK-START-{ARM,ARM64,MIPS64}: void CharSimdMinMax.doitMin(char[], char[], char[]) loop_optimization (after)
/// CHECK-DAG: <<Get1:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get2:d\d+>> VecLoad loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Min:d\d+>> VecMin [<<Get1>>,<<Get2>>] packed_type:Uint16 loop:<<Loop>> outer_loop:none
@@ -39,7 +39,7 @@ public class Main {
}
}
- /// CHECK-START: void Main.doitMax(char[], char[], char[]) loop_optimization (before)
+ /// CHECK-START: void CharSimdMinMax.doitMax(char[], char[], char[]) loop_optimization (before)
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:c\d+>> ArrayGet loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Get2:c\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -47,7 +47,7 @@ public class Main {
/// CHECK-DAG: <<Cnv:c\d+>> TypeConversion [<<Max>>] loop:<<Loop>> outer_loop:none
/// CHECK-DAG: ArraySet [{{l\d+}},<<Phi>>,<<Cnv>>] loop:<<Loop>> outer_loop:none
//
- /// CHECK-START-{ARM,ARM64,MIPS64}: void Main.doitMax(char[], char[], char[]) loop_optimization (after)
+ /// CHECK-START-{ARM,ARM64,MIPS64}: void CharSimdMinMax.doitMax(char[], char[], char[]) loop_optimization (after)
/// CHECK-DAG: <<Get1:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get2:d\d+>> VecLoad loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Max:d\d+>> VecMax [<<Get1>>,<<Get2>>] packed_type:Uint16 loop:<<Loop>> outer_loop:none
@@ -59,7 +59,7 @@ public class Main {
}
}
- /// CHECK-START: void Main.doitMin100(char[], char[]) loop_optimization (before)
+ /// CHECK-START: void CharSimdMinMax.doitMin100(char[], char[]) loop_optimization (before)
/// CHECK-DAG: <<I100:i\d+>> IntConstant 100 loop:none
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get:c\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -67,7 +67,7 @@ public class Main {
/// CHECK-DAG: <<Cnv:c\d+>> TypeConversion [<<Min>>] loop:<<Loop>> outer_loop:none
/// CHECK-DAG: ArraySet [{{l\d+}},<<Phi>>,<<Cnv>>] loop:<<Loop>> outer_loop:none
//
- /// CHECK-START-{ARM64,MIPS64}: void Main.doitMin100(char[], char[]) loop_optimization (after)
+ /// CHECK-START-{ARM64,MIPS64}: void CharSimdMinMax.doitMin100(char[], char[]) loop_optimization (after)
/// CHECK-DAG: <<I100:i\d+>> IntConstant 100 loop:none
/// CHECK-DAG: <<Repl:d\d+>> VecReplicateScalar [<<I100>>] loop:none
/// CHECK-DAG: <<Get:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
@@ -80,7 +80,7 @@ public class Main {
}
}
- public static void main(String[] args) {
+ public static void main() {
char[] interesting = {
0x0000, 0x0001, 0x007f, 0x0080, 0x0081, 0x00ff,
0x0100, 0x0101, 0x017f, 0x0180, 0x0181, 0x01ff,
@@ -121,7 +121,7 @@ public class Main {
expectEquals(expected, x[i]);
}
- System.out.println("passed");
+ System.out.println("CharSimdMinMax passed");
}
private static void expectEquals(char expected, char result) {
diff --git a/test/651-checker-double-simd-minmax/src/Main.java b/test/651-checker-simd-minmax/src/DoubleSimdMinMax.java
index 2eaf907167..da20594db8 100644
--- a/test/651-checker-double-simd-minmax/src/Main.java
+++ b/test/651-checker-simd-minmax/src/DoubleSimdMinMax.java
@@ -17,9 +17,9 @@
/**
* Tests for MIN/MAX vectorization.
*/
-public class Main {
+public class DoubleSimdMinMax {
- /// CHECK-START: void Main.doitMin(double[], double[], double[]) loop_optimization (before)
+ /// CHECK-START: void DoubleSimdMinMax.doitMin(double[], double[], double[]) loop_optimization (before)
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:d\d+>> ArrayGet loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Get2:d\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -29,7 +29,7 @@ public class Main {
// TODO x86: 0.0 vs -0.0?
// TODO MIPS64: min(x, NaN)?
//
- /// CHECK-START-ARM64: void Main.doitMin(double[], double[], double[]) loop_optimization (after)
+ /// CHECK-START-ARM64: void DoubleSimdMinMax.doitMin(double[], double[], double[]) loop_optimization (after)
/// CHECK-DAG: <<Get1:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get2:d\d+>> VecLoad loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Min:d\d+>> VecMin [<<Get1>>,<<Get2>>] loop:<<Loop>> outer_loop:none
@@ -41,7 +41,7 @@ public class Main {
}
}
- /// CHECK-START: void Main.doitMax(double[], double[], double[]) loop_optimization (before)
+ /// CHECK-START: void DoubleSimdMinMax.doitMax(double[], double[], double[]) loop_optimization (before)
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:d\d+>> ArrayGet loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Get2:d\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -51,7 +51,7 @@ public class Main {
// TODO x86: 0.0 vs -0.0?
// TODO MIPS64: max(x, NaN)?
//
- /// CHECK-START-ARM64: void Main.doitMax(double[], double[], double[]) loop_optimization (after)
+ /// CHECK-START-ARM64: void DoubleSimdMinMax.doitMax(double[], double[], double[]) loop_optimization (after)
/// CHECK-DAG: <<Get1:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get2:d\d+>> VecLoad loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Max:d\d+>> VecMax [<<Get1>>,<<Get2>>] loop:<<Loop>> outer_loop:none
@@ -63,7 +63,7 @@ public class Main {
}
}
- public static void main(String[] args) {
+ public static void main() {
double[] interesting = {
-0.0f,
+0.0f,
@@ -109,7 +109,7 @@ public class Main {
expectEquals(expected, x[i]);
}
- System.out.println("passed");
+ System.out.println("DoubleSimdMinMax passed");
}
private static void expectEquals(double expected, double result) {
diff --git a/test/651-checker-float-simd-minmax/src/Main.java b/test/651-checker-simd-minmax/src/FloatSimdMinMax.java
index dc09dfc7cc..645081248a 100644
--- a/test/651-checker-float-simd-minmax/src/Main.java
+++ b/test/651-checker-simd-minmax/src/FloatSimdMinMax.java
@@ -17,9 +17,9 @@
/**
* Tests for MIN/MAX vectorization.
*/
-public class Main {
+public class FloatSimdMinMax {
- /// CHECK-START: void Main.doitMin(float[], float[], float[]) loop_optimization (before)
+ /// CHECK-START: void FloatSimdMinMax.doitMin(float[], float[], float[]) loop_optimization (before)
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:f\d+>> ArrayGet loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Get2:f\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -29,7 +29,7 @@ public class Main {
// TODO x86: 0.0 vs -0.0?
// TODO MIPS64: min(x, NaN)?
//
- /// CHECK-START-ARM64: void Main.doitMin(float[], float[], float[]) loop_optimization (after)
+ /// CHECK-START-ARM64: void FloatSimdMinMax.doitMin(float[], float[], float[]) loop_optimization (after)
/// CHECK-DAG: <<Get1:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get2:d\d+>> VecLoad loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Min:d\d+>> VecMin [<<Get1>>,<<Get2>>] loop:<<Loop>> outer_loop:none
@@ -41,7 +41,7 @@ public class Main {
}
}
- /// CHECK-START: void Main.doitMax(float[], float[], float[]) loop_optimization (before)
+ /// CHECK-START: void FloatSimdMinMax.doitMax(float[], float[], float[]) loop_optimization (before)
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:f\d+>> ArrayGet loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Get2:f\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -51,7 +51,7 @@ public class Main {
// TODO x86: 0.0 vs -0.0?
// TODO MIPS64: max(x, NaN)?
//
- /// CHECK-START-ARM64: void Main.doitMax(float[], float[], float[]) loop_optimization (after)
+ /// CHECK-START-ARM64: void FloatSimdMinMax.doitMax(float[], float[], float[]) loop_optimization (after)
/// CHECK-DAG: <<Get1:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get2:d\d+>> VecLoad loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Max:d\d+>> VecMax [<<Get1>>,<<Get2>>] loop:<<Loop>> outer_loop:none
@@ -63,7 +63,7 @@ public class Main {
}
}
- public static void main(String[] args) {
+ public static void main() {
float[] interesting = {
-0.0f,
+0.0f,
@@ -109,7 +109,7 @@ public class Main {
expectEquals(expected, x[i]);
}
- System.out.println("passed");
+ System.out.println("FloatSimdMinMax passed");
}
private static void expectEquals(float expected, float result) {
diff --git a/test/651-checker-int-simd-minmax/src/Main.java b/test/651-checker-simd-minmax/src/IntSimdMinMax.java
index 82fad84d08..6373ae10eb 100644
--- a/test/651-checker-int-simd-minmax/src/Main.java
+++ b/test/651-checker-simd-minmax/src/IntSimdMinMax.java
@@ -17,16 +17,16 @@
/**
* Tests for MIN/MAX vectorization.
*/
-public class Main {
+public class IntSimdMinMax {
- /// CHECK-START: void Main.doitMin(int[], int[], int[]) loop_optimization (before)
+ /// CHECK-START: void IntSimdMinMax.doitMin(int[], int[], int[]) loop_optimization (before)
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:i\d+>> ArrayGet loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Get2:i\d+>> ArrayGet loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Min:i\d+>> Min [<<Get1>>,<<Get2>>] loop:<<Loop>> outer_loop:none
/// CHECK-DAG: ArraySet [{{l\d+}},<<Phi>>,<<Min>>] loop:<<Loop>> outer_loop:none
//
- /// CHECK-START-{ARM,ARM64,MIPS64}: void Main.doitMin(int[], int[], int[]) loop_optimization (after)
+ /// CHECK-START-{ARM,ARM64,MIPS64}: void IntSimdMinMax.doitMin(int[], int[], int[]) loop_optimization (after)
/// CHECK-DAG: <<Get1:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get2:d\d+>> VecLoad loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Min:d\d+>> VecMin [<<Get1>>,<<Get2>>] packed_type:Int32 loop:<<Loop>> outer_loop:none
@@ -38,14 +38,14 @@ public class Main {
}
}
- /// CHECK-START: void Main.doitMax(int[], int[], int[]) loop_optimization (before)
+ /// CHECK-START: void IntSimdMinMax.doitMax(int[], int[], int[]) loop_optimization (before)
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:i\d+>> ArrayGet loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Get2:i\d+>> ArrayGet loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Max:i\d+>> Max [<<Get1>>,<<Get2>>] loop:<<Loop>> outer_loop:none
/// CHECK-DAG: ArraySet [{{l\d+}},<<Phi>>,<<Max>>] loop:<<Loop>> outer_loop:none
//
- /// CHECK-START-{ARM,ARM64,MIPS64}: void Main.doitMax(int[], int[], int[]) loop_optimization (after)
+ /// CHECK-START-{ARM,ARM64,MIPS64}: void IntSimdMinMax.doitMax(int[], int[], int[]) loop_optimization (after)
/// CHECK-DAG: <<Get1:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get2:d\d+>> VecLoad loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Max:d\d+>> VecMax [<<Get1>>,<<Get2>>] packed_type:Int32 loop:<<Loop>> outer_loop:none
@@ -57,7 +57,7 @@ public class Main {
}
}
- public static void main(String[] args) {
+ public static void main() {
int[] interesting = {
0x00000000, 0x00000001, 0x00007fff, 0x00008000, 0x00008001, 0x0000ffff,
0x00010000, 0x00010001, 0x00017fff, 0x00018000, 0x00018001, 0x0001ffff,
@@ -93,7 +93,7 @@ public class Main {
expectEquals(expected, x[i]);
}
- System.out.println("passed");
+ System.out.println("IntSimdMinMax passed");
}
private static void expectEquals(int expected, int result) {
diff --git a/test/651-checker-long-simd-minmax/src/Main.java b/test/651-checker-simd-minmax/src/LongSimdMinMax.java
index f52686e54c..bb0c6047ed 100644
--- a/test/651-checker-long-simd-minmax/src/Main.java
+++ b/test/651-checker-simd-minmax/src/LongSimdMinMax.java
@@ -17,9 +17,9 @@
/**
* Tests for MIN/MAX vectorization.
*/
-public class Main {
+public class LongSimdMinMax {
- /// CHECK-START: void Main.doitMin(long[], long[], long[]) loop_optimization (before)
+ /// CHECK-START: void LongSimdMinMax.doitMin(long[], long[], long[]) loop_optimization (before)
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:j\d+>> ArrayGet loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Get2:j\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -28,10 +28,10 @@ public class Main {
//
// Not directly supported for longs.
//
- /// CHECK-START-ARM64: void Main.doitMin(long[], long[], long[]) loop_optimization (after)
+ /// CHECK-START-ARM64: void LongSimdMinMax.doitMin(long[], long[], long[]) loop_optimization (after)
/// CHECK-NOT: VecMin
//
- /// CHECK-START-MIPS64: void Main.doitMin(long[], long[], long[]) loop_optimization (after)
+ /// CHECK-START-MIPS64: void LongSimdMinMax.doitMin(long[], long[], long[]) loop_optimization (after)
/// CHECK-DAG: <<Get1:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get2:d\d+>> VecLoad loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Min:d\d+>> VecMin [<<Get1>>,<<Get2>>] loop:<<Loop>> outer_loop:none
@@ -44,7 +44,7 @@ public class Main {
}
}
- /// CHECK-START: void Main.doitMax(long[], long[], long[]) loop_optimization (before)
+ /// CHECK-START: void LongSimdMinMax.doitMax(long[], long[], long[]) loop_optimization (before)
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:j\d+>> ArrayGet loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Get2:j\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -53,10 +53,10 @@ public class Main {
//
// Not directly supported for longs.
//
- /// CHECK-START-ARM64: void Main.doitMax(long[], long[], long[]) loop_optimization (after)
+ /// CHECK-START-ARM64: void LongSimdMinMax.doitMax(long[], long[], long[]) loop_optimization (after)
/// CHECK-NOT: VecMax
//
- /// CHECK-START-MIPS64: void Main.doitMax(long[], long[], long[]) loop_optimization (after)
+ /// CHECK-START-MIPS64: void LongSimdMinMax.doitMax(long[], long[], long[]) loop_optimization (after)
/// CHECK-DAG: <<Get1:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get2:d\d+>> VecLoad loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Max:d\d+>> VecMax [<<Get1>>,<<Get2>>] loop:<<Loop>> outer_loop:none
@@ -68,7 +68,7 @@ public class Main {
}
}
- public static void main(String[] args) {
+ public static void main() {
long[] interesting = {
0x0000000000000000L, 0x0000000000000001L, 0x000000007fffffffL,
0x0000000080000000L, 0x0000000080000001L, 0x00000000ffffffffL,
@@ -110,7 +110,7 @@ public class Main {
expectEquals(expected, x[i]);
}
- System.out.println("passed");
+ System.out.println("LongSimdMinMax passed");
}
private static void expectEquals(long expected, long result) {
diff --git a/test/651-checker-simd-minmax/src/Main.java b/test/651-checker-simd-minmax/src/Main.java
new file mode 100644
index 0000000000..9134dd1edd
--- /dev/null
+++ b/test/651-checker-simd-minmax/src/Main.java
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+public class Main {
+ public static void main(String[] args) {
+ ByteSimdMinMax.main();
+ CharSimdMinMax.main();
+ ShortSimdMinMax.main();
+ IntSimdMinMax.main();
+ LongSimdMinMax.main();
+ DoubleSimdMinMax.main();
+ FloatSimdMinMax.main();
+ }
+}
diff --git a/test/651-checker-short-simd-minmax/src/Main.java b/test/651-checker-simd-minmax/src/ShortSimdMinMax.java
index 4300ca2951..aae78914d8 100644
--- a/test/651-checker-short-simd-minmax/src/Main.java
+++ b/test/651-checker-simd-minmax/src/ShortSimdMinMax.java
@@ -17,9 +17,9 @@
/**
* Tests for MIN/MAX vectorization.
*/
-public class Main {
+public class ShortSimdMinMax {
- /// CHECK-START: void Main.doitMin(short[], short[], short[]) loop_optimization (before)
+ /// CHECK-START: void ShortSimdMinMax.doitMin(short[], short[], short[]) loop_optimization (before)
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:s\d+>> ArrayGet loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Get2:s\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -27,7 +27,7 @@ public class Main {
/// CHECK-DAG: <<Cnv:s\d+>> TypeConversion [<<Min>>] loop:<<Loop>> outer_loop:none
/// CHECK-DAG: ArraySet [{{l\d+}},<<Phi>>,<<Cnv>>] loop:<<Loop>> outer_loop:none
//
- /// CHECK-START-{ARM,ARM64,MIPS64}: void Main.doitMin(short[], short[], short[]) loop_optimization (after)
+ /// CHECK-START-{ARM,ARM64,MIPS64}: void ShortSimdMinMax.doitMin(short[], short[], short[]) loop_optimization (after)
/// CHECK-DAG: <<Get1:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get2:d\d+>> VecLoad loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Min:d\d+>> VecMin [<<Get1>>,<<Get2>>] packed_type:Int16 loop:<<Loop>> outer_loop:none
@@ -39,7 +39,7 @@ public class Main {
}
}
- /// CHECK-START: void Main.doitMinUnsigned(short[], short[], short[]) instruction_simplifier (before)
+ /// CHECK-START: void ShortSimdMinMax.doitMinUnsigned(short[], short[], short[]) instruction_simplifier (before)
/// CHECK-DAG: <<IMAX:i\d+>> IntConstant 65535 loop:none
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:s\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -50,7 +50,7 @@ public class Main {
/// CHECK-DAG: <<Cnv:s\d+>> TypeConversion [<<Min>>] loop:<<Loop>> outer_loop:none
/// CHECK-DAG: ArraySet [{{l\d+}},{{i\d+}},<<Cnv>>] loop:<<Loop>> outer_loop:none
//
- /// CHECK-START: void Main.doitMinUnsigned(short[], short[], short[]) loop_optimization (before)
+ /// CHECK-START: void ShortSimdMinMax.doitMinUnsigned(short[], short[], short[]) loop_optimization (before)
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:c\d+>> ArrayGet loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Get2:c\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -58,7 +58,7 @@ public class Main {
/// CHECK-DAG: <<Cnv:s\d+>> TypeConversion [<<Min>>] loop:<<Loop>> outer_loop:none
/// CHECK-DAG: ArraySet [{{l\d+}},<<Phi>>,<<Cnv>>] loop:<<Loop>> outer_loop:none
//
- /// CHECK-START-{ARM,ARM64,MIPS64}: void Main.doitMinUnsigned(short[], short[], short[]) loop_optimization (after)
+ /// CHECK-START-{ARM,ARM64,MIPS64}: void ShortSimdMinMax.doitMinUnsigned(short[], short[], short[]) loop_optimization (after)
/// CHECK-DAG: <<Get1:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get2:d\d+>> VecLoad loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Min:d\d+>> VecMin [<<Get1>>,<<Get2>>] packed_type:Uint16 loop:<<Loop>> outer_loop:none
@@ -70,7 +70,7 @@ public class Main {
}
}
- /// CHECK-START: void Main.doitMax(short[], short[], short[]) loop_optimization (before)
+ /// CHECK-START: void ShortSimdMinMax.doitMax(short[], short[], short[]) loop_optimization (before)
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:s\d+>> ArrayGet loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Get2:s\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -78,7 +78,7 @@ public class Main {
/// CHECK-DAG: <<Cnv:s\d+>> TypeConversion [<<Max>>] loop:<<Loop>> outer_loop:none
/// CHECK-DAG: ArraySet [{{l\d+}},<<Phi>>,<<Cnv>>] loop:<<Loop>> outer_loop:none
//
- /// CHECK-START-{ARM,ARM64,MIPS64}: void Main.doitMax(short[], short[], short[]) loop_optimization (after)
+ /// CHECK-START-{ARM,ARM64,MIPS64}: void ShortSimdMinMax.doitMax(short[], short[], short[]) loop_optimization (after)
/// CHECK-DAG: <<Get1:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get2:d\d+>> VecLoad loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Max:d\d+>> VecMax [<<Get1>>,<<Get2>>] packed_type:Int16 loop:<<Loop>> outer_loop:none
@@ -90,7 +90,7 @@ public class Main {
}
}
- /// CHECK-START: void Main.doitMaxUnsigned(short[], short[], short[]) instruction_simplifier (before)
+ /// CHECK-START: void ShortSimdMinMax.doitMaxUnsigned(short[], short[], short[]) instruction_simplifier (before)
/// CHECK-DAG: <<IMAX:i\d+>> IntConstant 65535 loop:none
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:s\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -101,7 +101,7 @@ public class Main {
/// CHECK-DAG: <<Cnv:s\d+>> TypeConversion [<<Max>>] loop:<<Loop>> outer_loop:none
/// CHECK-DAG: ArraySet [{{l\d+}},{{i\d+}},<<Cnv>>] loop:<<Loop>> outer_loop:none
//
- /// CHECK-START: void Main.doitMaxUnsigned(short[], short[], short[]) loop_optimization (before)
+ /// CHECK-START: void ShortSimdMinMax.doitMaxUnsigned(short[], short[], short[]) loop_optimization (before)
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get1:c\d+>> ArrayGet loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Get2:c\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -109,7 +109,7 @@ public class Main {
/// CHECK-DAG: <<Cnv:s\d+>> TypeConversion [<<Max>>] loop:<<Loop>> outer_loop:none
/// CHECK-DAG: ArraySet [{{l\d+}},<<Phi>>,<<Cnv>>] loop:<<Loop>> outer_loop:none
//
- /// CHECK-START-{ARM,ARM64,MIPS64}: void Main.doitMaxUnsigned(short[], short[], short[]) loop_optimization (after)
+ /// CHECK-START-{ARM,ARM64,MIPS64}: void ShortSimdMinMax.doitMaxUnsigned(short[], short[], short[]) loop_optimization (after)
/// CHECK-DAG: <<Get1:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get2:d\d+>> VecLoad loop:<<Loop>> outer_loop:none
/// CHECK-DAG: <<Max:d\d+>> VecMax [<<Get1>>,<<Get2>>] packed_type:Uint16 loop:<<Loop>> outer_loop:none
@@ -121,7 +121,7 @@ public class Main {
}
}
- /// CHECK-START: void Main.doitMin100(short[], short[]) loop_optimization (before)
+ /// CHECK-START: void ShortSimdMinMax.doitMin100(short[], short[]) loop_optimization (before)
/// CHECK-DAG: <<I100:i\d+>> IntConstant 100 loop:none
/// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
/// CHECK-DAG: <<Get:s\d+>> ArrayGet loop:<<Loop>> outer_loop:none
@@ -129,7 +129,7 @@ public class Main {
/// CHECK-DAG: <<Cnv:s\d+>> TypeConversion [<<Min>>] loop:<<Loop>> outer_loop:none
/// CHECK-DAG: ArraySet [{{l\d+}},<<Phi>>,<<Cnv>>] loop:<<Loop>> outer_loop:none
//
- /// CHECK-START-{ARM64,MIPS64}: void Main.doitMin100(short[], short[]) loop_optimization (after)
+ /// CHECK-START-{ARM64,MIPS64}: void ShortSimdMinMax.doitMin100(short[], short[]) loop_optimization (after)
/// CHECK-DAG: <<I100:i\d+>> IntConstant 100 loop:none
/// CHECK-DAG: <<Repl:d\d+>> VecReplicateScalar [<<I100>>] loop:none
/// CHECK-DAG: <<Get:d\d+>> VecLoad loop:<<Loop:B\d+>> outer_loop:none
@@ -142,7 +142,7 @@ public class Main {
}
}
- public static void main(String[] args) {
+ public static void main() {
short[] interesting = {
(short) 0x0000, (short) 0x0001, (short) 0x007f,
(short) 0x0080, (short) 0x0081, (short) 0x00ff,
@@ -199,7 +199,7 @@ public class Main {
expectEquals(expected, x[i]);
}
- System.out.println("passed");
+ System.out.println("ShortSimdMinMax passed");
}
private static void expectEquals(short expected, short result) {
diff --git a/test/660-checker-simd-sad-byte/build b/test/660-checker-simd-sad-byte/build
deleted file mode 100644
index d85147f17b..0000000000
--- a/test/660-checker-simd-sad-byte/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/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.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/660-checker-simd-sad-char/build b/test/660-checker-simd-sad-char/build
deleted file mode 100644
index d85147f17b..0000000000
--- a/test/660-checker-simd-sad-char/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/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.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/660-checker-simd-sad-int/build b/test/660-checker-simd-sad-int/build
deleted file mode 100644
index d85147f17b..0000000000
--- a/test/660-checker-simd-sad-int/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/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.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/660-checker-simd-sad-short/build b/test/660-checker-simd-sad-short/build
deleted file mode 100644
index d85147f17b..0000000000
--- a/test/660-checker-simd-sad-short/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/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.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/660-checker-simd-sad-short2/build b/test/660-checker-simd-sad-short2/build
deleted file mode 100644
index d85147f17b..0000000000
--- a/test/660-checker-simd-sad-short2/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/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.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/660-checker-simd-sad-short3/build b/test/660-checker-simd-sad-short3/build
deleted file mode 100644
index d85147f17b..0000000000
--- a/test/660-checker-simd-sad-short3/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/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.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/661-checker-simd-reduc/build b/test/661-checker-simd-reduc/build
deleted file mode 100644
index d85147f17b..0000000000
--- a/test/661-checker-simd-reduc/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/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.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/672-checker-throw-method/build b/test/672-checker-throw-method/build
deleted file mode 100644
index d85147f17b..0000000000
--- a/test/672-checker-throw-method/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/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.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/673-checker-throw-vmethod/build b/test/673-checker-throw-vmethod/build
deleted file mode 100644
index d85147f17b..0000000000
--- a/test/673-checker-throw-vmethod/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/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.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/678-checker-simd-saturation/build b/test/678-checker-simd-saturation/build
deleted file mode 100644
index d85147f17b..0000000000
--- a/test/678-checker-simd-saturation/build
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/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.
-
-# See b/65168732
-export USE_D8=false
-
-./default-build "$@"
diff --git a/test/680-checker-deopt-dex-pc-0/src/Main.java b/test/680-checker-deopt-dex-pc-0/src/Main.java
index d5a6a9015c..64a3cb3da7 100644
--- a/test/680-checker-deopt-dex-pc-0/src/Main.java
+++ b/test/680-checker-deopt-dex-pc-0/src/Main.java
@@ -31,15 +31,12 @@ public class Main {
System.loadLibrary(args[0]);
if (hasJit()) {
byte[] array = { 0, 1, 2, 3 };
- while (!hasJitCompiledEntrypoint(Main.class, "$noinline$getInt")) {
- for (int i = 0; i < 10000; ++i) {
- if ($noinline$getInt(array, 0) != 0x03020100) {
- throw new Error();
- }
- }
- try {
- Thread.sleep(200);
- } catch (InterruptedException ignored) {}
+ ensureJitCompiled(Main.class, "$noinline$getInt");
+ if (!hasJitCompiledEntrypoint(Main.class, "$noinline$getInt")) {
+ throw new Error("Unexpected entrypoint!");
+ }
+ if ($noinline$getInt(array, 0) != 0x03020100) {
+ throw new Error();
}
try {
// The HDeoptimize at dex pc 0 was previously handled poorly as the dex pc 0
@@ -56,4 +53,5 @@ public class Main {
public static native boolean hasJit();
public native static boolean hasJitCompiledEntrypoint(Class<?> cls, String methodName);
+ public native static void ensureJitCompiled(Class<?> cls, String methodName);
}
diff --git a/test/712-varhandle-invocations/build b/test/712-varhandle-invocations/build
index 6d4429f0ef..253765be91 100755
--- a/test/712-varhandle-invocations/build
+++ b/test/712-varhandle-invocations/build
@@ -35,8 +35,5 @@ python3 ./util-src/generate_java.py "${GENERATED_SRC}" ${MANUAL_TESTS}
# Desugar is not happy with our Java 9 byte code, it shouldn't be necessary here anyway.
export USE_DESUGAR=false
-# See b/65168732
-export USE_D8=false
-
# Invoke default build with increased heap size for dx
./default-build "$@" --experimental var-handles --dx-vm-option -JXmx384m
diff --git a/test/Android.run-test.mk b/test/Android.run-test.mk
index f8bebdd35f..6633958140 100644
--- a/test/Android.run-test.mk
+++ b/test/Android.run-test.mk
@@ -21,12 +21,17 @@ include art/build/Android.common_test.mk
TEST_ART_RUN_TEST_DEPENDENCIES := \
$(HOST_OUT_EXECUTABLES)/dx \
$(HOST_OUT_EXECUTABLES)/d8 \
- $(HOST_OUT_EXECUTABLES)/d8-compat-dx \
$(HOST_OUT_EXECUTABLES)/hiddenapi \
$(HOST_OUT_EXECUTABLES)/jasmin \
$(HOST_OUT_EXECUTABLES)/smali \
$(HOST_OUT_JAVA_LIBRARIES)/desugar.jar
+# Add d8 dependency, if enabled.
+ifeq ($(USE_D8),true)
+TEST_ART_RUN_TEST_DEPENDENCIES += \
+ $(HOST_OUT_EXECUTABLES)/d8-compat-dx
+endif
+
# We need dex2oat and dalvikvm on the target as well as the core images (all images as we sync
# only once).
TEST_ART_TARGET_SYNC_DEPS += $(ART_TARGET_EXECUTABLES) $(TARGET_CORE_IMG_OUTS)
diff --git a/test/HiddenApiSignatures/Class1.java b/test/HiddenApiSignatures/Class1.java
new file mode 100644
index 0000000000..a9004dcd99
--- /dev/null
+++ b/test/HiddenApiSignatures/Class1.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package mypackage.packagea;
+
+public class Class1 {
+ public int field1;
+ public int field12;
+
+ public Class1() {
+ }
+
+ public void method1() {
+ }
+
+ public void method1(int i) {
+ }
+
+ public void method12() {
+ }
+
+} \ No newline at end of file
diff --git a/test/HiddenApiSignatures/Class12.java b/test/HiddenApiSignatures/Class12.java
new file mode 100644
index 0000000000..82b22e365f
--- /dev/null
+++ b/test/HiddenApiSignatures/Class12.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package mypackage.packagea;
+
+public class Class12 {
+ public int field1;
+
+ public void method1() {
+ }
+} \ No newline at end of file
diff --git a/test/HiddenApiSignatures/Class2.java b/test/HiddenApiSignatures/Class2.java
new file mode 100644
index 0000000000..dc92b9cfd8
--- /dev/null
+++ b/test/HiddenApiSignatures/Class2.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package mypackage.packagea;
+
+public class Class2 {
+ public int field1;
+
+ public void method1() {
+ }
+
+ public void method1(int i) {
+ }
+} \ No newline at end of file
diff --git a/test/HiddenApiSignatures/Class3.java b/test/HiddenApiSignatures/Class3.java
new file mode 100644
index 0000000000..fbf04071a4
--- /dev/null
+++ b/test/HiddenApiSignatures/Class3.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package mypackage.packageb;
+
+public class Class3 {
+ public int field1;
+
+ public void method1() {
+ }
+
+ public void method1(int i) {
+ }
+} \ No newline at end of file
diff --git a/test/etc/default-build b/test/etc/default-build
index dd5560213a..9de7294a59 100755
--- a/test/etc/default-build
+++ b/test/etc/default-build
@@ -317,7 +317,7 @@ function make_dex() {
fi
local dexer="${DX}"
- if [[ "${USE_D8}" != "false" ]]; then
+ if [ ${USE_D8} = "true" ]; then
dexer="${ANDROID_HOST_OUT}/bin/d8-compat-dx"
fi
diff --git a/test/run-test b/test/run-test
index 5f85b0875b..5b43b52b41 100755
--- a/test/run-test
+++ b/test/run-test
@@ -45,7 +45,7 @@ export JAVAC="javac -g -Xlint:-options"
export RUN="${progdir}/etc/run-test-jar"
export DEX_LOCATION=/data/run-test/${test_dir}
export NEED_DEX="true"
-export USE_D8="true"
+export USE_D8="false"
export USE_JACK="false"
export USE_DESUGAR="true"
export SMALI_ARGS=""
@@ -365,6 +365,9 @@ while true; do
elif [ "x$1" = "x--build-only" ]; then
build_only="yes"
shift
+ elif [ "x$1" = "x--build-with-d8" ]; then
+ USE_D8="true"
+ shift
elif [ "x$1" = "x--build-with-javac-dx" ]; then
USE_JACK="false"
shift
diff --git a/test/testrunner/env.py b/test/testrunner/env.py
index 7564f5a6b4..539499173c 100644
--- a/test/testrunner/env.py
+++ b/test/testrunner/env.py
@@ -71,6 +71,9 @@ ANDROID_BUILD_TOP = _get_android_build_top()
# Compiling with jack? Possible values in (True, False, 'default')
ANDROID_COMPILE_WITH_JACK = _get_build_var_boolean('ANDROID_COMPILE_WITH_JACK', 'default')
+# Follow the build system's D8 usage.
+USE_D8_BY_DEFAULT = _get_build_var_boolean('USE_D8_BY_DEFAULT', False)
+
# Directory used for temporary test files on the host.
ART_HOST_TEST_DIR = tempfile.mkdtemp(prefix = 'test-art-')
diff --git a/test/testrunner/testrunner.py b/test/testrunner/testrunner.py
index 99bab097ab..0cfb661019 100755
--- a/test/testrunner/testrunner.py
+++ b/test/testrunner/testrunner.py
@@ -174,56 +174,37 @@ def setup_test_env():
global _user_input_variants
global run_all_configs
+ # These are the default variant-options we will use if nothing in the group is specified.
+ default_variants = {
+ 'target': {'host', 'target'},
+ 'pictest': {'npictest'},
+ 'prebuild': {'prebuild'},
+ 'cdex_level': {'cdex-fast'},
+ 'jvmti': { 'no-jvmti'},
+ 'compiler': {'optimizing',
+ 'jit',
+ 'interpreter',
+ 'interp-ac',
+ 'speed-profile'},
+ 'relocate': {'no-relocate'},
+ 'trace': {'ntrace'},
+ 'gc': {'cms'},
+ 'jni': {'checkjni'},
+ 'image': {'picimage'},
+ 'pictest': {'pictest'},
+ 'debuggable': {'ndebuggable'},
+ 'run': {'debug'},
+ # address_sizes_target depends on the target so it is dealt with below.
+ }
+ # We want to pull these early since the full VARIANT_TYPE_DICT has a few additional ones we don't
+ # want to pick up if we pass --all.
+ default_variants_keys = default_variants.keys()
if run_all_configs:
- target_types = _user_input_variants['target']
- _user_input_variants = VARIANT_TYPE_DICT
- _user_input_variants['target'] = target_types
-
- if not _user_input_variants['target']:
- _user_input_variants['target'].add('host')
- _user_input_variants['target'].add('target')
-
- if not _user_input_variants['prebuild']: # Default
- _user_input_variants['prebuild'].add('prebuild')
-
- if not _user_input_variants['cdex_level']: # Default
- _user_input_variants['cdex_level'].add('cdex-fast')
-
- # By default only run without jvmti
- if not _user_input_variants['jvmti']:
- _user_input_variants['jvmti'].add('no-jvmti')
-
- # By default we run all 'compiler' variants.
- if not _user_input_variants['compiler'] and _user_input_variants['target'] != 'jvm':
- _user_input_variants['compiler'].add('optimizing')
- _user_input_variants['compiler'].add('jit')
- _user_input_variants['compiler'].add('interpreter')
- _user_input_variants['compiler'].add('interp-ac')
- _user_input_variants['compiler'].add('speed-profile')
-
- if not _user_input_variants['relocate']: # Default
- _user_input_variants['relocate'].add('no-relocate')
+ default_variants = VARIANT_TYPE_DICT
- if not _user_input_variants['trace']: # Default
- _user_input_variants['trace'].add('ntrace')
-
- if not _user_input_variants['gc']: # Default
- _user_input_variants['gc'].add('cms')
-
- if not _user_input_variants['jni']: # Default
- _user_input_variants['jni'].add('checkjni')
-
- if not _user_input_variants['image']: # Default
- _user_input_variants['image'].add('picimage')
-
- if not _user_input_variants['pictest']: # Default
- _user_input_variants['pictest'].add('npictest')
-
- if not _user_input_variants['debuggable']: # Default
- _user_input_variants['debuggable'].add('ndebuggable')
-
- if not _user_input_variants['run']: # Default
- _user_input_variants['run'].add('debug')
+ for key in default_variants_keys:
+ if not _user_input_variants[key]:
+ _user_input_variants[key] = default_variants[key]
_user_input_variants['address_sizes_target'] = collections.defaultdict(set)
if not _user_input_variants['address_sizes']:
@@ -504,6 +485,9 @@ def run_tests(tests):
elif env.ANDROID_COMPILE_WITH_JACK == False:
options_test += ' --build-with-javac-dx'
+ if env.USE_D8_BY_DEFAULT == True:
+ options_test += ' --build-with-d8'
+
# TODO(http://36039166): This is a temporary solution to
# fix build breakages.
options_test = (' --output-path %s') % (
diff --git a/tools/build/var_list b/tools/build/var_list
index adcb066f7c..3727741dac 100644
--- a/tools/build/var_list
+++ b/tools/build/var_list
@@ -34,4 +34,5 @@ HOST_PREFER_32_BIT
HOST_OUT_EXECUTABLES
ANDROID_JAVA_TOOLCHAIN
ANDROID_COMPILE_WITH_JACK
+USE_D8_BY_DEFAULT
diff --git a/tools/veridex/Android.bp b/tools/veridex/Android.bp
index ff181c89a7..cbf62d9e9c 100644
--- a/tools/veridex/Android.bp
+++ b/tools/veridex/Android.bp
@@ -12,11 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-art_cc_binary {
+cc_binary {
name: "veridex",
host_supported: true,
srcs: [
"hidden_api.cc",
+ "hidden_api_finder.cc",
"resolver.cc",
"veridex.cc",
],
diff --git a/tools/veridex/Android.mk b/tools/veridex/Android.mk
new file mode 100644
index 0000000000..4183054193
--- /dev/null
+++ b/tools/veridex/Android.mk
@@ -0,0 +1,35 @@
+#
+# 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+system_stub_dex := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/core_dex_intermediates/classes.dex
+$(system_stub_dex): PRIVATE_MIN_SDK_VERSION := 1000
+$(system_stub_dex): $(TOPDIR)prebuilts/sdk/system_current/android.jar | $(ZIP2ZIP) $(DX)
+ $(transform-classes-d8.jar-to-dex)
+
+
+oahl_stub_dex := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/oahl_dex_intermediates/classes.dex
+$(oahl_stub_dex): PRIVATE_MIN_SDK_VERSION := 1000
+$(oahl_stub_dex): $(TOPDIR)prebuilts/sdk/org.apache.http.legacy/org.apache.http.legacy.jar | $(ZIP2ZIP) $(DX)
+ $(transform-classes-d8.jar-to-dex)
+
+.PHONY: appcompat
+
+appcompat: $(system_stub_dex) $(oahl_stub_dex) $(HOST_OUT_EXECUTABLES)/veridex \
+ ${TARGET_OUT_COMMON_INTERMEDIATES}/PACKAGING/hiddenapi-light-greylist.txt \
+ ${TARGET_OUT_COMMON_INTERMEDIATES}/PACKAGING/hiddenapi-dark-greylist.txt \
+ ${TARGET_OUT_COMMON_INTERMEDIATES}/PACKAGING/hiddenapi-blacklist.txt
diff --git a/tools/veridex/README.md b/tools/veridex/README.md
new file mode 100644
index 0000000000..0f91b08771
--- /dev/null
+++ b/tools/veridex/README.md
@@ -0,0 +1,14 @@
+appcompat.sh
+============
+
+Given an APK, finds API uses that fall into the blacklist/greylists APIs.
+
+NOTE: appcompat.sh is still under development. It can report
+API uses that do not execute at runtime, and reflection uses
+that do not exist. It can also miss on reflection uses.
+
+To build it:
+> make appcompat
+
+To run it:
+> ./art/tools/veridex/appcompat.sh test.apk
diff --git a/tools/veridex/appcompat.sh b/tools/veridex/appcompat.sh
new file mode 100755
index 0000000000..f75aa4f0d0
--- /dev/null
+++ b/tools/veridex/appcompat.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# 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.
+
+# We want to be at the root for simplifying the "out" detection
+# logic.
+if [ ! -d art ]; then
+ echo "Script needs to be run at the root of the android tree."
+ exit 1
+fi
+
+# Logic for setting out_dir from build/make/core/envsetup.mk:
+if [[ -z $OUT_DIR ]]; then
+ if [[ -z $OUT_DIR_COMMON_BASE ]]; then
+ OUT=out
+ else
+ OUT=${OUT_DIR_COMMON_BASE}/${PWD##*/}
+ fi
+else
+ OUT=${OUT_DIR}
+fi
+
+PACKAGING=${OUT}/target/common/obj/PACKAGING
+
+if [ -z "$ANDROID_HOST_OUT" ] ; then
+ ANDROID_HOST_OUT=${OUT}/host/linux-x86
+fi
+
+echo "NOTE: appcompat.sh is still under development. It can report"
+echo "API uses that do not execute at runtime, and reflection uses"
+echo "that do not exist. It can also miss on reflection uses."
+
+
+${ANDROID_HOST_OUT}/bin/veridex \
+ --core-stubs=${PACKAGING}/core_dex_intermediates/classes.dex:${PACKAGING}/oahl_dex_intermediates/classes.dex \
+ --blacklist=${PACKAGING}/hiddenapi-blacklist.txt \
+ --light-greylist=${PACKAGING}/hiddenapi-light-greylist.txt \
+ --dark-greylist=${PACKAGING}/hiddenapi-dark-greylist.txt \
+ --dex-file=$1
diff --git a/tools/veridex/hidden_api.cc b/tools/veridex/hidden_api.cc
index 33e499bfc3..93f921a25f 100644
--- a/tools/veridex/hidden_api.cc
+++ b/tools/veridex/hidden_api.cc
@@ -44,17 +44,6 @@ std::string HiddenApi::GetApiFieldName(const DexFile& dex_file, uint32_t field_i
return ss.str();
}
-bool HiddenApi::LogIfIn(const std::string& name,
- const std::set<std::string>& list,
- const std::string& log,
- const std::string& access_kind) {
- if (list.find(name) != list.end()) {
- LOG(WARNING) << std::string(log) << " usage found " << name << " (" << access_kind << ")";
- return true;
- }
- return false;
-}
-
void HiddenApi::FillList(const char* filename, std::set<std::string>& entries) {
if (filename == nullptr) {
return;
diff --git a/tools/veridex/hidden_api.h b/tools/veridex/hidden_api.h
index 282e7cf8e8..5893b8ae33 100644
--- a/tools/veridex/hidden_api.h
+++ b/tools/veridex/hidden_api.h
@@ -17,6 +17,9 @@
#ifndef ART_TOOLS_VERIDEX_HIDDEN_API_H_
#define ART_TOOLS_VERIDEX_HIDDEN_API_H_
+#include "dex/hidden_api_access_flags.h"
+
+#include <ostream>
#include <set>
#include <string>
@@ -35,10 +38,20 @@ class HiddenApi {
FillList(blacklist, blacklist_);
}
- bool LogIfInList(const std::string& name, const char* access_kind) const {
- return LogIfIn(name, blacklist_, "Blacklist", access_kind) ||
- LogIfIn(name, dark_greylist_, "Dark greylist", access_kind) ||
- LogIfIn(name, light_greylist_, "Light greylist", access_kind);
+ HiddenApiAccessFlags::ApiList GetApiList(const std::string& name) const {
+ if (IsInList(name, blacklist_)) {
+ return HiddenApiAccessFlags::kBlacklist;
+ } else if (IsInList(name, dark_greylist_)) {
+ return HiddenApiAccessFlags::kDarkGreylist;
+ } else if (IsInList(name, light_greylist_)) {
+ return HiddenApiAccessFlags::kLightGreylist;
+ } else {
+ return HiddenApiAccessFlags::kWhitelist;
+ }
+ }
+
+ bool IsInRestrictionList(const std::string& name) const {
+ return GetApiList(name) != HiddenApiAccessFlags::kWhitelist;
}
static std::string GetApiMethodName(const DexFile& dex_file, uint32_t method_index);
@@ -46,10 +59,9 @@ class HiddenApi {
static std::string GetApiFieldName(const DexFile& dex_file, uint32_t field_index);
private:
- static bool LogIfIn(const std::string& name,
- const std::set<std::string>& list,
- const std::string& log,
- const std::string& access_kind);
+ static bool IsInList(const std::string& name, const std::set<std::string>& list) {
+ return list.find(name) != list.end();
+ }
static void FillList(const char* filename, std::set<std::string>& entries);
diff --git a/tools/veridex/hidden_api_finder.cc b/tools/veridex/hidden_api_finder.cc
new file mode 100644
index 0000000000..d611f78eed
--- /dev/null
+++ b/tools/veridex/hidden_api_finder.cc
@@ -0,0 +1,266 @@
+/*
+ * 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.
+ */
+
+#include "hidden_api_finder.h"
+
+#include "dex/code_item_accessors-inl.h"
+#include "dex/dex_instruction-inl.h"
+#include "dex/dex_file.h"
+#include "dex/method_reference.h"
+#include "hidden_api.h"
+#include "resolver.h"
+#include "veridex.h"
+
+#include <iostream>
+
+namespace art {
+
+void HiddenApiFinder::CheckMethod(uint32_t method_id,
+ VeridexResolver* resolver,
+ MethodReference ref) {
+ // Cheap check that the method is resolved. If it is, we know it's not in
+ // a restricted list.
+ if (resolver->GetMethod(method_id) != nullptr) {
+ return;
+ }
+ std::string name = HiddenApi::GetApiMethodName(resolver->GetDexFile(), method_id);
+ if (hidden_api_.IsInRestrictionList(name)) {
+ method_locations_[name].push_back(ref);
+ }
+}
+
+void HiddenApiFinder::CheckField(uint32_t field_id,
+ VeridexResolver* resolver,
+ MethodReference ref) {
+ // Cheap check that the field is resolved. If it is, we know it's not in
+ // a restricted list.
+ if (resolver->GetField(field_id) != nullptr) {
+ return;
+ }
+ std::string name = HiddenApi::GetApiFieldName(resolver->GetDexFile(), field_id);
+ if (hidden_api_.IsInRestrictionList(name)) {
+ field_locations_[name].push_back(ref);
+ }
+}
+
+void HiddenApiFinder::CollectAccesses(VeridexResolver* resolver) {
+ const DexFile& dex_file = resolver->GetDexFile();
+ size_t class_def_count = dex_file.NumClassDefs();
+ for (size_t class_def_index = 0; class_def_index < class_def_count; ++class_def_index) {
+ const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
+ const uint8_t* class_data = dex_file.GetClassData(class_def);
+ if (class_data == nullptr) {
+ // Empty class.
+ continue;
+ }
+ ClassDataItemIterator it(dex_file, class_data);
+ it.SkipAllFields();
+ for (; it.HasNextMethod(); it.Next()) {
+ const DexFile::CodeItem* code_item = it.GetMethodCodeItem();
+ if (code_item == nullptr) {
+ continue;
+ }
+ CodeItemDataAccessor code_item_accessor(dex_file, code_item);
+ for (const DexInstructionPcPair& inst : code_item_accessor) {
+ switch (inst->Opcode()) {
+ case Instruction::CONST_CLASS: {
+ dex::TypeIndex type_index(inst->VRegB_21c());
+ std::string name = dex_file.StringByTypeIdx(type_index);
+ // Only keep classes that are in a restriction list.
+ if (hidden_api_.IsInRestrictionList(name)) {
+ classes_.insert(name);
+ }
+ break;
+ }
+ case Instruction::CONST_STRING: {
+ dex::StringIndex string_index(inst->VRegB_21c());
+ std::string name = std::string(dex_file.StringDataByIdx(string_index));
+ // Cheap filtering on the string literal. We know it cannot be a field/method/class
+ // if it contains a space.
+ if (name.find(' ') == std::string::npos) {
+ // Class names at the Java level are of the form x.y.z, but the list encodes
+ // them of the form Lx/y/z;. Inner classes have '$' for both Java level class
+ // names in strings, and hidden API lists.
+ std::string str = name;
+ std::replace(str.begin(), str.end(), '.', '/');
+ str = "L" + str + ";";
+ // Note: we can query the lists directly, as HiddenApi added classes that own
+ // private methods and fields in them.
+ // We don't add class names to the `strings_` set as we know method/field names
+ // don't have '.' or '/'. All hidden API class names have a '/'.
+ if (hidden_api_.IsInRestrictionList(str)) {
+ classes_.insert(str);
+ } else if (hidden_api_.IsInRestrictionList(name)) {
+ // Could be something passed to JNI.
+ classes_.insert(name);
+ } else {
+ // We only keep track of the location for strings, as these will be the
+ // field/method names the user is interested in.
+ strings_.insert(name);
+ reflection_locations_[name].push_back(
+ MethodReference(&dex_file, it.GetMemberIndex()));
+ }
+ }
+ break;
+ }
+ case Instruction::INVOKE_DIRECT:
+ case Instruction::INVOKE_INTERFACE:
+ case Instruction::INVOKE_STATIC:
+ case Instruction::INVOKE_SUPER:
+ case Instruction::INVOKE_VIRTUAL: {
+ CheckMethod(
+ inst->VRegB_35c(), resolver, MethodReference(&dex_file, it.GetMemberIndex()));
+ break;
+ }
+
+ case Instruction::INVOKE_DIRECT_RANGE:
+ case Instruction::INVOKE_INTERFACE_RANGE:
+ case Instruction::INVOKE_STATIC_RANGE:
+ case Instruction::INVOKE_SUPER_RANGE:
+ case Instruction::INVOKE_VIRTUAL_RANGE: {
+ CheckMethod(
+ inst->VRegB_3rc(), resolver, MethodReference(&dex_file, it.GetMemberIndex()));
+ break;
+ }
+
+ case Instruction::IGET:
+ case Instruction::IGET_WIDE:
+ case Instruction::IGET_OBJECT:
+ case Instruction::IGET_BOOLEAN:
+ case Instruction::IGET_BYTE:
+ case Instruction::IGET_CHAR:
+ case Instruction::IGET_SHORT: {
+ CheckField(
+ inst->VRegC_22c(), resolver, MethodReference(&dex_file, it.GetMemberIndex()));
+ break;
+ }
+
+ case Instruction::IPUT:
+ case Instruction::IPUT_WIDE:
+ case Instruction::IPUT_OBJECT:
+ case Instruction::IPUT_BOOLEAN:
+ case Instruction::IPUT_BYTE:
+ case Instruction::IPUT_CHAR:
+ case Instruction::IPUT_SHORT: {
+ CheckField(
+ inst->VRegC_22c(), resolver, MethodReference(&dex_file, it.GetMemberIndex()));
+ break;
+ }
+
+ case Instruction::SGET:
+ case Instruction::SGET_WIDE:
+ case Instruction::SGET_OBJECT:
+ case Instruction::SGET_BOOLEAN:
+ case Instruction::SGET_BYTE:
+ case Instruction::SGET_CHAR:
+ case Instruction::SGET_SHORT: {
+ CheckField(
+ inst->VRegB_21c(), resolver, MethodReference(&dex_file, it.GetMemberIndex()));
+ break;
+ }
+
+ case Instruction::SPUT:
+ case Instruction::SPUT_WIDE:
+ case Instruction::SPUT_OBJECT:
+ case Instruction::SPUT_BOOLEAN:
+ case Instruction::SPUT_BYTE:
+ case Instruction::SPUT_CHAR:
+ case Instruction::SPUT_SHORT: {
+ CheckField(
+ inst->VRegB_21c(), resolver, MethodReference(&dex_file, it.GetMemberIndex()));
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+ }
+ }
+}
+
+static std::string GetApiMethodName(MethodReference ref) {
+ return HiddenApi::GetApiMethodName(*ref.dex_file, ref.index);
+}
+
+void HiddenApiFinder::Run(const std::vector<std::unique_ptr<VeridexResolver>>& resolvers) {
+ for (const std::unique_ptr<VeridexResolver>& resolver : resolvers) {
+ CollectAccesses(resolver.get());
+ }
+
+ Dump(std::cout);
+}
+
+void HiddenApiFinder::Dump(std::ostream& os) {
+ static const char* kPrefix = " ";
+ uint32_t count = 0;
+ uint32_t linking_count = method_locations_.size() + field_locations_.size();
+ uint32_t api_counts[4] = {0, 0, 0, 0};
+
+ // Dump methods from hidden APIs linked against.
+ for (const std::pair<std::string, std::vector<MethodReference>>& pair : method_locations_) {
+ HiddenApiAccessFlags::ApiList api_list = hidden_api_.GetApiList(pair.first);
+ api_counts[api_list]++;
+ os << "#" << ++count << ": Linking " << api_list << " " << pair.first << " use(s):";
+ os << std::endl;
+ for (const MethodReference& ref : pair.second) {
+ os << kPrefix << GetApiMethodName(ref) << std::endl;
+ }
+ os << std::endl;
+ }
+
+ // Dump fields from hidden APIs linked against.
+ for (const std::pair<std::string, std::vector<MethodReference>>& pair : field_locations_) {
+ HiddenApiAccessFlags::ApiList api_list = hidden_api_.GetApiList(pair.first);
+ api_counts[api_list]++;
+ os << "#" << ++count << ": Linking " << api_list << " " << pair.first << " use(s):";
+ os << std::endl;
+ for (const MethodReference& ref : pair.second) {
+ os << kPrefix << GetApiMethodName(ref) << std::endl;
+ }
+ os << std::endl;
+ }
+
+ // Dump potential reflection uses.
+ for (const std::string& cls : classes_) {
+ for (const std::string& name : strings_) {
+ std::string full_name = cls + "->" + name;
+ HiddenApiAccessFlags::ApiList api_list = hidden_api_.GetApiList(full_name);
+ api_counts[api_list]++;
+ if (api_list != HiddenApiAccessFlags::kWhitelist) {
+ os << "#" << ++count << ": Reflection " << api_list << " " << full_name
+ << " potential use(s):";
+ os << std::endl;
+ for (const MethodReference& ref : reflection_locations_[name]) {
+ os << kPrefix << GetApiMethodName(ref) << std::endl;
+ }
+ os << std::endl;
+ }
+ }
+ }
+
+ os << count << " hidden API(s) used: "
+ << linking_count << " linked against, "
+ << count - linking_count << " potentially through reflection" << std::endl;
+ os << kPrefix << api_counts[HiddenApiAccessFlags::kBlacklist]
+ << " in blacklist" << std::endl;
+ os << kPrefix << api_counts[HiddenApiAccessFlags::kDarkGreylist]
+ << " in dark greylist" << std::endl;
+ os << kPrefix << api_counts[HiddenApiAccessFlags::kLightGreylist]
+ << " in light greylist" << std::endl;
+}
+
+} // namespace art
diff --git a/tools/veridex/hidden_api_finder.h b/tools/veridex/hidden_api_finder.h
new file mode 100644
index 0000000000..243079c187
--- /dev/null
+++ b/tools/veridex/hidden_api_finder.h
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+#ifndef ART_TOOLS_VERIDEX_HIDDEN_API_FINDER_H_
+#define ART_TOOLS_VERIDEX_HIDDEN_API_FINDER_H_
+
+#include "dex/method_reference.h"
+
+#include <iostream>
+#include <map>
+#include <set>
+#include <string>
+
+namespace art {
+
+class HiddenApi;
+class VeridexResolver;
+
+/**
+ * Reports potential uses of hidden APIs from static linking and reflection.
+ */
+class HiddenApiFinder {
+ public:
+ explicit HiddenApiFinder(const HiddenApi& hidden_api) : hidden_api_(hidden_api) {}
+
+ // Iterate over the dex files associated with the passed resolvers to report
+ // hidden API uses.
+ void Run(const std::vector<std::unique_ptr<VeridexResolver>>& app_resolvers);
+
+ private:
+ void CollectAccesses(VeridexResolver* resolver);
+ void CheckMethod(uint32_t method_idx, VeridexResolver* resolver, MethodReference ref);
+ void CheckField(uint32_t field_idx, VeridexResolver* resolver, MethodReference ref);
+ void Dump(std::ostream& os);
+
+ const HiddenApi& hidden_api_;
+ std::set<std::string> classes_;
+ std::set<std::string> strings_;
+ std::map<std::string, std::vector<MethodReference>> reflection_locations_;
+ std::map<std::string, std::vector<MethodReference>> method_locations_;
+ std::map<std::string, std::vector<MethodReference>> field_locations_;
+};
+
+} // namespace art
+
+#endif // ART_TOOLS_VERIDEX_HIDDEN_API_FINDER_H_
diff --git a/tools/veridex/resolver.cc b/tools/veridex/resolver.cc
index 6ab872ed6f..13dda5c199 100644
--- a/tools/veridex/resolver.cc
+++ b/tools/veridex/resolver.cc
@@ -277,10 +277,8 @@ VeriField VeridexResolver::GetField(uint32_t field_index) {
return field_info;
}
-void VeridexResolver::ResolveAll(const HiddenApi& hidden_api) {
+void VeridexResolver::ResolveAll() {
for (uint32_t i = 0; i < dex_file_.NumTypeIds(); ++i) {
- // Note: we don't look at HiddenApi for types, as the lists don't contain
- // classes.
if (GetVeriClass(dex::TypeIndex(i)) == nullptr) {
LOG(WARNING) << "Unresolved " << dex_file_.PrettyType(dex::TypeIndex(i));
}
@@ -288,17 +286,13 @@ void VeridexResolver::ResolveAll(const HiddenApi& hidden_api) {
for (uint32_t i = 0; i < dex_file_.NumMethodIds(); ++i) {
if (GetMethod(i) == nullptr) {
- if (!hidden_api.LogIfInList(HiddenApi::GetApiMethodName(dex_file_, i), "Linking")) {
- LOG(WARNING) << "Unresolved: " << dex_file_.PrettyMethod(i);
- }
+ LOG(WARNING) << "Unresolved: " << dex_file_.PrettyMethod(i);
}
}
for (uint32_t i = 0; i < dex_file_.NumFieldIds(); ++i) {
if (GetField(i) == nullptr) {
- if (!hidden_api.LogIfInList(HiddenApi::GetApiFieldName(dex_file_, i), "Linking")) {
- LOG(WARNING) << "Unresolved: " << dex_file_.PrettyField(i);
- }
+ LOG(WARNING) << "Unresolved: " << dex_file_.PrettyField(i);
}
}
}
diff --git a/tools/veridex/resolver.h b/tools/veridex/resolver.h
index 82f6aaeddd..06c8aa70c5 100644
--- a/tools/veridex/resolver.h
+++ b/tools/veridex/resolver.h
@@ -66,9 +66,13 @@ class VeridexResolver {
const char* field_name,
const char* field_type);
- // Resolve all type_id/method_id/field_id. Log for unresolved
- // entities, or entities part of a hidden API list.
- void ResolveAll(const HiddenApi& hidden_api);
+ // Resolve all type_id/method_id/field_id.
+ void ResolveAll();
+
+ // The dex file this resolver is associated to.
+ const DexFile& GetDexFile() const {
+ return dex_file_;
+ }
private:
// Return the resolver where `kls` is from.
diff --git a/tools/veridex/veridex.cc b/tools/veridex/veridex.cc
index c5203fea66..16e9f0e55b 100644
--- a/tools/veridex/veridex.cc
+++ b/tools/veridex/veridex.cc
@@ -21,6 +21,7 @@
#include "dex/dex_file.h"
#include "dex/dex_file_loader.h"
#include "hidden_api.h"
+#include "hidden_api_finder.h"
#include "resolver.h"
#include <sstream>
@@ -162,11 +163,10 @@ class Veridex {
std::vector<std::unique_ptr<VeridexResolver>> app_resolvers;
Resolve(app_dex_files, resolver_map, type_map, &app_resolvers);
- // Resolve all type_id/method_id/field_id of app dex files.
+ // Find and log uses of hidden APIs.
HiddenApi hidden_api(options.blacklist, options.dark_greylist, options.light_greylist);
- for (const std::unique_ptr<VeridexResolver>& resolver : app_resolvers) {
- resolver->ResolveAll(hidden_api);
- }
+ HiddenApiFinder api_finder(hidden_api);
+ api_finder.Run(app_resolvers);
return 0;
}