Merge "ART: Make dex2oat watchdog configurable"
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk
index e525808..d376f29 100644
--- a/build/Android.gtest.mk
+++ b/build/Android.gtest.mk
@@ -92,8 +92,8 @@
ART_GTEST_class_table_test_DEX_DEPS := XandY
ART_GTEST_compiler_driver_test_DEX_DEPS := AbstractMethod StaticLeafMethods ProfileTestMultiDex
ART_GTEST_dex_cache_test_DEX_DEPS := Main Packages MethodTypes
-ART_GTEST_dex_file_test_DEX_DEPS := GetMethodSignature Main Nested
-ART_GTEST_dex2oat_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS) Statics
+ART_GTEST_dex_file_test_DEX_DEPS := GetMethodSignature Main Nested MultiDex
+ART_GTEST_dex2oat_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS) Statics VerifierDeps
ART_GTEST_exception_test_DEX_DEPS := ExceptionHandle
ART_GTEST_image_test_DEX_DEPS := ImageLayoutA ImageLayoutB
ART_GTEST_imtable_test_DEX_DEPS := IMTA IMTB
@@ -102,6 +102,7 @@
ART_GTEST_jni_internal_test_DEX_DEPS := AllFields StaticLeafMethods
ART_GTEST_oat_file_assistant_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS)
ART_GTEST_dexoptanalyzer_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS)
+ART_GTEST_image_space_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS)
ART_GTEST_oat_file_test_DEX_DEPS := Main MultiDex
ART_GTEST_oat_test_DEX_DEPS := Main
ART_GTEST_object_test_DEX_DEPS := ProtoCompare ProtoCompare2 StaticsFromCode XandY
@@ -146,6 +147,11 @@
$(ART_GTEST_dex2oat_environment_tests_TARGET_DEPS) \
dexoptanalyzerd
+ART_GTEST_image_space_test_HOST_DEPS := \
+ $(ART_GTEST_dex2oat_environment_tests_HOST_DEPS)
+ART_GTEST_image_space_test_TARGET_DEPS := \
+ $(ART_GTEST_dex2oat_environment_tests_TARGET_DEPS)
+
ART_GTEST_dex2oat_test_HOST_DEPS := \
$(ART_GTEST_dex2oat_environment_tests_HOST_DEPS)
ART_GTEST_dex2oat_test_TARGET_DEPS := \
@@ -627,6 +633,9 @@
ART_GTEST_dexoptanalyzer_test_DEX_DEPS :=
ART_GTEST_dexoptanalyzer_test_HOST_DEPS :=
ART_GTEST_dexoptanalyzer_test_TARGET_DEPS :=
+ART_GTEST_image_space_test_DEX_DEPS :=
+ART_GTEST_image_space_test_HOST_DEPS :=
+ART_GTEST_image_space_test_TARGET_DEPS :=
ART_GTEST_dex2oat_test_DEX_DEPS :=
ART_GTEST_dex2oat_test_HOST_DEPS :=
ART_GTEST_dex2oat_test_TARGET_DEPS :=
diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc
index c72edb1..70ff327 100644
--- a/compiler/image_writer.cc
+++ b/compiler/image_writer.cc
@@ -2254,6 +2254,14 @@
orig_dex_cache->FixupResolvedMethodTypes(NativeCopyLocation(orig_method_types, orig_dex_cache),
ImageAddressVisitor(this));
}
+ GcRoot<mirror::CallSite>* orig_call_sites = orig_dex_cache->GetResolvedCallSites();
+ if (orig_call_sites != nullptr) {
+ copy_dex_cache->SetFieldPtrWithSize<false>(mirror::DexCache::ResolvedCallSitesOffset(),
+ NativeLocationInImage(orig_call_sites),
+ PointerSize::k64);
+ orig_dex_cache->FixupResolvedCallSites(NativeCopyLocation(orig_call_sites, orig_dex_cache),
+ ImageAddressVisitor(this));
+ }
// Remove the DexFile pointers. They will be fixed up when the runtime loads the oat file. Leaving
// compiler pointers in here will make the output non-deterministic.
diff --git a/compiler/optimizing/intrinsics_arm64.cc b/compiler/optimizing/intrinsics_arm64.cc
index 1047d3b..86e5429 100644
--- a/compiler/optimizing/intrinsics_arm64.cc
+++ b/compiler/optimizing/intrinsics_arm64.cc
@@ -23,7 +23,7 @@
#include "entrypoints/quick/quick_entrypoints.h"
#include "intrinsics.h"
#include "mirror/array-inl.h"
-#include "mirror/string.h"
+#include "mirror/string-inl.h"
#include "thread.h"
#include "utils/arm64/assembler_arm64.h"
@@ -1450,16 +1450,47 @@
}
}
+// The cut off for unrolling the loop in String.equals() intrinsic for const strings.
+// The normal loop plus the pre-header is 9 instructions without string compression and 12
+// instructions with string compression. We can compare up to 8 bytes in 4 instructions
+// (LDR+LDR+CMP+BNE) and up to 16 bytes in 5 instructions (LDP+LDP+CMP+CCMP+BNE). Allow up
+// to 10 instructions for the unrolled loop.
+constexpr size_t kShortConstStringEqualsCutoffInBytes = 32;
+
+static const char* GetConstString(HInstruction* candidate, uint32_t* utf16_length) {
+ if (candidate->IsLoadString()) {
+ HLoadString* load_string = candidate->AsLoadString();
+ const DexFile& dex_file = load_string->GetDexFile();
+ return dex_file.StringDataAndUtf16LengthByIdx(load_string->GetStringIndex(), utf16_length);
+ }
+ return nullptr;
+}
+
void IntrinsicLocationsBuilderARM64::VisitStringEquals(HInvoke* invoke) {
LocationSummary* locations = new (arena_) LocationSummary(invoke,
LocationSummary::kNoCall,
kIntrinsified);
locations->SetInAt(0, Location::RequiresRegister());
locations->SetInAt(1, Location::RequiresRegister());
- // Temporary registers to store lengths of strings and for calculations.
- locations->AddTemp(Location::RequiresRegister());
- locations->AddTemp(Location::RequiresRegister());
+ // For the generic implementation and for long const strings we need a temporary.
+ // We do not need it for short const strings, up to 8 bytes, see code generation below.
+ uint32_t const_string_length = 0u;
+ const char* const_string = GetConstString(invoke->InputAt(0), &const_string_length);
+ if (const_string == nullptr) {
+ const_string = GetConstString(invoke->InputAt(1), &const_string_length);
+ }
+ bool is_compressed =
+ mirror::kUseStringCompression &&
+ const_string != nullptr &&
+ mirror::String::DexFileStringAllASCII(const_string, const_string_length);
+ if (const_string == nullptr || const_string_length > (is_compressed ? 8u : 4u)) {
+ locations->AddTemp(Location::RequiresRegister());
+ }
+
+ // TODO: If the String.equals() is used only for an immediately following HIf, we can
+ // mark it as emitted-at-use-site and emit branches directly to the appropriate blocks.
+ // Then we shall need an extra temporary register instead of the output register.
locations->SetOut(Location::RequiresRegister(), Location::kOutputOverlap);
}
@@ -1473,8 +1504,7 @@
UseScratchRegisterScope scratch_scope(masm);
Register temp = scratch_scope.AcquireW();
- Register temp1 = WRegisterFrom(locations->GetTemp(0));
- Register temp2 = WRegisterFrom(locations->GetTemp(1));
+ Register temp1 = scratch_scope.AcquireW();
vixl::aarch64::Label loop;
vixl::aarch64::Label end;
@@ -1510,47 +1540,99 @@
__ B(&return_false, ne);
}
- // Load `count` fields of this and argument strings.
- __ Ldr(temp, MemOperand(str.X(), count_offset));
- __ Ldr(temp1, MemOperand(arg.X(), count_offset));
- // Check if `count` fields are equal, return false if they're not.
- // Also compares the compression style, if differs return false.
- __ Cmp(temp, temp1);
- __ B(&return_false, ne);
- // Return true if both strings are empty. Even with string compression `count == 0` means empty.
- static_assert(static_cast<uint32_t>(mirror::StringCompressionFlag::kCompressed) == 0u,
- "Expecting 0=compressed, 1=uncompressed");
- __ Cbz(temp, &return_true);
+ // Check if one of the inputs is a const string. Do not special-case both strings
+ // being const, such cases should be handled by constant folding if needed.
+ uint32_t const_string_length = 0u;
+ const char* const_string = GetConstString(invoke->InputAt(0), &const_string_length);
+ if (const_string == nullptr) {
+ const_string = GetConstString(invoke->InputAt(1), &const_string_length);
+ if (const_string != nullptr) {
+ std::swap(str, arg); // Make sure the const string is in `str`.
+ }
+ }
+ bool is_compressed =
+ mirror::kUseStringCompression &&
+ const_string != nullptr &&
+ mirror::String::DexFileStringAllASCII(const_string, const_string_length);
+
+ if (const_string != nullptr) {
+ // Load `count` field of the argument string and check if it matches the const string.
+ // Also compares the compression style, if differs return false.
+ __ Ldr(temp, MemOperand(arg.X(), count_offset));
+ __ Cmp(temp, Operand(mirror::String::GetFlaggedCount(const_string_length, is_compressed)));
+ __ B(&return_false, ne);
+ } else {
+ // Load `count` fields of this and argument strings.
+ __ Ldr(temp, MemOperand(str.X(), count_offset));
+ __ Ldr(temp1, MemOperand(arg.X(), count_offset));
+ // Check if `count` fields are equal, return false if they're not.
+ // Also compares the compression style, if differs return false.
+ __ Cmp(temp, temp1);
+ __ B(&return_false, ne);
+ }
// Assertions that must hold in order to compare strings 8 bytes at a time.
DCHECK_ALIGNED(value_offset, 8);
static_assert(IsAligned<8>(kObjectAlignment), "String of odd length is not zero padded");
- if (mirror::kUseStringCompression) {
- // For string compression, calculate the number of bytes to compare (not chars).
- // This could in theory exceed INT32_MAX, so treat temp as unsigned.
- __ Lsr(temp, temp, 1u); // Extract length.
- __ And(temp1, temp1, Operand(1)); // Extract compression flag.
- __ Lsl(temp, temp, temp1); // Calculate number of bytes to compare.
+ if (const_string != nullptr &&
+ const_string_length < (is_compressed ? kShortConstStringEqualsCutoffInBytes
+ : kShortConstStringEqualsCutoffInBytes / 2u)) {
+ // Load and compare the contents. Though we know the contents of the short const string
+ // at compile time, materializing constants may be more code than loading from memory.
+ int32_t offset = value_offset;
+ size_t remaining_bytes =
+ RoundUp(is_compressed ? const_string_length : const_string_length * 2u, 8u);
+ temp = temp.X();
+ temp1 = temp1.X();
+ while (remaining_bytes > 8u) {
+ Register temp2 = XRegisterFrom(locations->GetTemp(0));
+ __ Ldp(temp, temp1, MemOperand(str.X(), offset));
+ __ Ldp(temp2, out, MemOperand(arg.X(), offset));
+ __ Cmp(temp, temp2);
+ __ Ccmp(temp1, out, NoFlag, eq);
+ __ B(&return_false, ne);
+ offset += 2u * sizeof(uint64_t);
+ remaining_bytes -= 2u * sizeof(uint64_t);
+ }
+ if (remaining_bytes != 0u) {
+ __ Ldr(temp, MemOperand(str.X(), offset));
+ __ Ldr(temp1, MemOperand(arg.X(), offset));
+ __ Cmp(temp, temp1);
+ __ B(&return_false, ne);
+ }
+ } else {
+ // Return true if both strings are empty. Even with string compression `count == 0` means empty.
+ static_assert(static_cast<uint32_t>(mirror::StringCompressionFlag::kCompressed) == 0u,
+ "Expecting 0=compressed, 1=uncompressed");
+ __ Cbz(temp, &return_true);
+
+ if (mirror::kUseStringCompression) {
+ // For string compression, calculate the number of bytes to compare (not chars).
+ // This could in theory exceed INT32_MAX, so treat temp as unsigned.
+ __ And(temp1, temp, Operand(1)); // Extract compression flag.
+ __ Lsr(temp, temp, 1u); // Extract length.
+ __ Lsl(temp, temp, temp1); // Calculate number of bytes to compare.
+ }
+
+ // Store offset of string value in preparation for comparison loop
+ __ Mov(temp1, value_offset);
+
+ temp1 = temp1.X();
+ Register temp2 = XRegisterFrom(locations->GetTemp(0));
+ // Loop to compare strings 8 bytes at a time starting at the front of the string.
+ // Ok to do this because strings are zero-padded to kObjectAlignment.
+ __ Bind(&loop);
+ __ Ldr(out, MemOperand(str.X(), temp1));
+ __ Ldr(temp2, MemOperand(arg.X(), temp1));
+ __ Add(temp1, temp1, Operand(sizeof(uint64_t)));
+ __ Cmp(out, temp2);
+ __ B(&return_false, ne);
+ // With string compression, we have compared 8 bytes, otherwise 4 chars.
+ __ Sub(temp, temp, Operand(mirror::kUseStringCompression ? 8 : 4), SetFlags);
+ __ B(&loop, hi);
}
- // Store offset of string value in preparation for comparison loop
- __ Mov(temp1, value_offset);
-
- temp1 = temp1.X();
- temp2 = temp2.X();
- // Loop to compare strings 8 bytes at a time starting at the front of the string.
- // Ok to do this because strings are zero-padded to kObjectAlignment.
- __ Bind(&loop);
- __ Ldr(out, MemOperand(str.X(), temp1));
- __ Ldr(temp2, MemOperand(arg.X(), temp1));
- __ Add(temp1, temp1, Operand(sizeof(uint64_t)));
- __ Cmp(out, temp2);
- __ B(&return_false, ne);
- // With string compression, we have compared 8 bytes, otherwise 4 chars.
- __ Sub(temp, temp, Operand(mirror::kUseStringCompression ? 8 : 4), SetFlags);
- __ B(&loop, hi);
-
// Return true and exit the function.
// If loop does not result in returning false, we return true.
__ Bind(&return_true);
diff --git a/compiler/optimizing/stack_map_stream.cc b/compiler/optimizing/stack_map_stream.cc
index f8e01b7..1bcc8e1 100644
--- a/compiler/optimizing/stack_map_stream.cc
+++ b/compiler/optimizing/stack_map_stream.cc
@@ -38,19 +38,14 @@
current_entry_.native_pc_code_offset = CodeOffset::FromOffset(native_pc_offset, instruction_set_);
current_entry_.register_mask = register_mask;
current_entry_.sp_mask = sp_mask;
- current_entry_.num_dex_registers = num_dex_registers;
current_entry_.inlining_depth = inlining_depth;
- current_entry_.dex_register_locations_start_index = dex_register_locations_.size();
current_entry_.inline_infos_start_index = inline_infos_.size();
- current_entry_.dex_register_map_hash = 0;
- current_entry_.same_dex_register_map_as_ = kNoSameDexMapFound;
current_entry_.stack_mask_index = 0;
- if (num_dex_registers != 0) {
- current_entry_.live_dex_registers_mask =
- ArenaBitVector::Create(allocator_, num_dex_registers, true, kArenaAllocStackMapStream);
- } else {
- current_entry_.live_dex_registers_mask = nullptr;
- }
+ current_entry_.dex_register_entry.num_dex_registers = num_dex_registers;
+ current_entry_.dex_register_entry.locations_start_index = dex_register_locations_.size();
+ current_entry_.dex_register_entry.live_dex_registers_mask = (num_dex_registers != 0)
+ ? ArenaBitVector::Create(allocator_, num_dex_registers, true, kArenaAllocStackMapStream)
+ : nullptr;
if (sp_mask != nullptr) {
stack_mask_max_ = std::max(stack_mask_max_, sp_mask->GetHighestBitSet());
@@ -65,7 +60,7 @@
}
void StackMapStream::EndStackMapEntry() {
- current_entry_.same_dex_register_map_as_ = FindEntryWithTheSameDexMap();
+ current_entry_.dex_register_map_index = AddDexRegisterMapEntry(current_entry_.dex_register_entry);
stack_maps_.push_back(current_entry_);
current_entry_ = StackMapEntry();
}
@@ -91,19 +86,15 @@
dex_register_locations_.push_back(index);
location_catalog_entries_indices_.Insert(std::make_pair(location, index));
}
-
- if (in_inline_frame_) {
- // TODO: Support sharing DexRegisterMap across InlineInfo.
- DCHECK_LT(current_dex_register_, current_inline_info_.num_dex_registers);
- current_inline_info_.live_dex_registers_mask->SetBit(current_dex_register_);
- } else {
- DCHECK_LT(current_dex_register_, current_entry_.num_dex_registers);
- current_entry_.live_dex_registers_mask->SetBit(current_dex_register_);
- current_entry_.dex_register_map_hash += (1 <<
- (current_dex_register_ % (sizeof(current_entry_.dex_register_map_hash) * kBitsPerByte)));
- current_entry_.dex_register_map_hash += static_cast<uint32_t>(value);
- current_entry_.dex_register_map_hash += static_cast<uint32_t>(kind);
- }
+ DexRegisterMapEntry* const entry = in_inline_frame_
+ ? ¤t_inline_info_.dex_register_entry
+ : ¤t_entry_.dex_register_entry;
+ DCHECK_LT(current_dex_register_, entry->num_dex_registers);
+ entry->live_dex_registers_mask->SetBit(current_dex_register_);
+ entry->hash += (1 <<
+ (current_dex_register_ % (sizeof(DexRegisterMapEntry::hash) * kBitsPerByte)));
+ entry->hash += static_cast<uint32_t>(value);
+ entry->hash += static_cast<uint32_t>(kind);
}
current_dex_register_++;
}
@@ -124,20 +115,19 @@
current_inline_info_.method_index = method->GetDexMethodIndexUnchecked();
}
current_inline_info_.dex_pc = dex_pc;
- current_inline_info_.num_dex_registers = num_dex_registers;
- current_inline_info_.dex_register_locations_start_index = dex_register_locations_.size();
- if (num_dex_registers != 0) {
- current_inline_info_.live_dex_registers_mask =
- ArenaBitVector::Create(allocator_, num_dex_registers, true, kArenaAllocStackMapStream);
- } else {
- current_inline_info_.live_dex_registers_mask = nullptr;
- }
+ current_inline_info_.dex_register_entry.num_dex_registers = num_dex_registers;
+ current_inline_info_.dex_register_entry.locations_start_index = dex_register_locations_.size();
+ current_inline_info_.dex_register_entry.live_dex_registers_mask = (num_dex_registers != 0)
+ ? ArenaBitVector::Create(allocator_, num_dex_registers, true, kArenaAllocStackMapStream)
+ : nullptr;
current_dex_register_ = 0;
}
void StackMapStream::EndInlineInfoEntry() {
+ current_inline_info_.dex_register_map_index =
+ AddDexRegisterMapEntry(current_inline_info_.dex_register_entry);
DCHECK(in_inline_frame_);
- DCHECK_EQ(current_dex_register_, current_inline_info_.num_dex_registers)
+ DCHECK_EQ(current_dex_register_, current_inline_info_.dex_register_entry.num_dex_registers)
<< "Inline information contains less registers than expected";
in_inline_frame_ = false;
inline_infos_.push_back(current_inline_info_);
@@ -193,8 +183,7 @@
return size;
}
-size_t StackMapStream::ComputeDexRegisterMapSize(uint32_t num_dex_registers,
- const BitVector* live_dex_registers_mask) const {
+size_t StackMapStream::DexRegisterMapEntry::ComputeSize(size_t catalog_size) const {
// For num_dex_registers == 0u live_dex_registers_mask may be null.
if (num_dex_registers == 0u) {
return 0u; // No register map will be emitted.
@@ -208,8 +197,7 @@
// Compute the size of the set of live Dex register entries.
size_t number_of_live_dex_registers = live_dex_registers_mask->NumSetBits();
size_t map_entries_size_in_bits =
- DexRegisterMap::SingleEntrySizeInBits(location_catalog_entries_.size())
- * number_of_live_dex_registers;
+ DexRegisterMap::SingleEntrySizeInBits(catalog_size) * number_of_live_dex_registers;
size_t map_entries_size_in_bytes =
RoundUp(map_entries_size_in_bits, kBitsPerByte) / kBitsPerByte;
size += map_entries_size_in_bytes;
@@ -218,18 +206,8 @@
size_t StackMapStream::ComputeDexRegisterMapsSize() const {
size_t size = 0;
- size_t inline_info_index = 0;
- for (const StackMapEntry& entry : stack_maps_) {
- if (entry.same_dex_register_map_as_ == kNoSameDexMapFound) {
- size += ComputeDexRegisterMapSize(entry.num_dex_registers, entry.live_dex_registers_mask);
- } else {
- // Entries with the same dex map will have the same offset.
- }
- for (size_t j = 0; j < entry.inlining_depth; ++j) {
- InlineInfoEntry inline_entry = inline_infos_[inline_info_index++];
- size += ComputeDexRegisterMapSize(inline_entry.num_dex_registers,
- inline_entry.live_dex_registers_mask);
- }
+ for (const DexRegisterMapEntry& entry : dex_register_entries_) {
+ size += entry.ComputeSize(location_catalog_entries_.size());
}
return size;
}
@@ -264,6 +242,30 @@
encoding->SetFromSizes(method_index_max, dex_pc_max, extra_data_max, dex_register_maps_bytes);
}
+size_t StackMapStream::MaybeCopyDexRegisterMap(DexRegisterMapEntry& entry,
+ size_t* current_offset,
+ MemoryRegion dex_register_locations_region) {
+ DCHECK(current_offset != nullptr);
+ if ((entry.num_dex_registers == 0) || (entry.live_dex_registers_mask->NumSetBits() == 0)) {
+ // No dex register map needed.
+ return StackMap::kNoDexRegisterMap;
+ }
+ if (entry.offset == DexRegisterMapEntry::kOffsetUnassigned) {
+ // Not already copied, need to copy and and assign an offset.
+ entry.offset = *current_offset;
+ const size_t entry_size = entry.ComputeSize(location_catalog_entries_.size());
+ DexRegisterMap dex_register_map(
+ dex_register_locations_region.Subregion(entry.offset, entry_size));
+ *current_offset += entry_size;
+ // Fill in the map since it was just added.
+ FillInDexRegisterMap(dex_register_map,
+ entry.num_dex_registers,
+ *entry.live_dex_registers_mask,
+ entry.locations_start_index);
+ }
+ return entry.offset;
+}
+
void StackMapStream::FillIn(MemoryRegion region) {
DCHECK_EQ(0u, current_entry_.dex_pc) << "EndStackMapEntry not called after BeginStackMapEntry";
DCHECK_NE(0u, needed_size_) << "PrepareForFillIn not called before FillIn";
@@ -311,35 +313,10 @@
stack_map.SetRegisterMaskIndex(encoding.stack_map.encoding, entry.register_mask_index);
stack_map.SetStackMaskIndex(encoding.stack_map.encoding, entry.stack_mask_index);
- if (entry.num_dex_registers == 0 || (entry.live_dex_registers_mask->NumSetBits() == 0)) {
- // No dex map available.
- stack_map.SetDexRegisterMapOffset(encoding.stack_map.encoding, StackMap::kNoDexRegisterMap);
- } else {
- // Search for an entry with the same dex map.
- if (entry.same_dex_register_map_as_ != kNoSameDexMapFound) {
- // If we have a hit reuse the offset.
- stack_map.SetDexRegisterMapOffset(
- encoding.stack_map.encoding,
- code_info.GetStackMapAt(entry.same_dex_register_map_as_, encoding)
- .GetDexRegisterMapOffset(encoding.stack_map.encoding));
- } else {
- // New dex registers maps should be added to the stack map.
- MemoryRegion register_region = dex_register_locations_region.Subregion(
- next_dex_register_map_offset,
- ComputeDexRegisterMapSize(entry.num_dex_registers, entry.live_dex_registers_mask));
- next_dex_register_map_offset += register_region.size();
- DexRegisterMap dex_register_map(register_region);
- stack_map.SetDexRegisterMapOffset(
- encoding.stack_map.encoding,
- register_region.begin() - dex_register_locations_region.begin());
-
- // Set the dex register location.
- FillInDexRegisterMap(dex_register_map,
- entry.num_dex_registers,
- *entry.live_dex_registers_mask,
- entry.dex_register_locations_start_index);
- }
- }
+ size_t offset = MaybeCopyDexRegisterMap(dex_register_entries_[entry.dex_register_map_index],
+ &next_dex_register_map_offset,
+ dex_register_locations_region);
+ stack_map.SetDexRegisterMapOffset(encoding.stack_map.encoding, offset);
// Set the inlining info.
if (entry.inlining_depth != 0) {
@@ -371,29 +348,13 @@
inline_info.SetExtraDataAtDepth(encoding.inline_info.encoding, depth, 1);
}
inline_info.SetDexPcAtDepth(encoding.inline_info.encoding, depth, inline_entry.dex_pc);
- if (inline_entry.num_dex_registers == 0) {
- // No dex map available.
- inline_info.SetDexRegisterMapOffsetAtDepth(encoding.inline_info.encoding,
- depth,
- StackMap::kNoDexRegisterMap);
- DCHECK(inline_entry.live_dex_registers_mask == nullptr);
- } else {
- MemoryRegion register_region = dex_register_locations_region.Subregion(
- next_dex_register_map_offset,
- ComputeDexRegisterMapSize(inline_entry.num_dex_registers,
- inline_entry.live_dex_registers_mask));
- next_dex_register_map_offset += register_region.size();
- DexRegisterMap dex_register_map(register_region);
- inline_info.SetDexRegisterMapOffsetAtDepth(
- encoding.inline_info.encoding,
- depth,
- register_region.begin() - dex_register_locations_region.begin());
-
- FillInDexRegisterMap(dex_register_map,
- inline_entry.num_dex_registers,
- *inline_entry.live_dex_registers_mask,
- inline_entry.dex_register_locations_start_index);
- }
+ size_t dex_register_map_offset = MaybeCopyDexRegisterMap(
+ dex_register_entries_[inline_entry.dex_register_map_index],
+ &next_dex_register_map_offset,
+ dex_register_locations_region);
+ inline_info.SetDexRegisterMapOffsetAtDepth(encoding.inline_info.encoding,
+ depth,
+ dex_register_map_offset);
}
} else if (encoding.stack_map.encoding.GetInlineInfoEncoding().BitSize() > 0) {
stack_map.SetInlineInfoIndex(encoding.stack_map.encoding, StackMap::kNoInlineInfo);
@@ -448,34 +409,31 @@
}
}
-size_t StackMapStream::FindEntryWithTheSameDexMap() {
- size_t current_entry_index = stack_maps_.size();
- auto entries_it = dex_map_hash_to_stack_map_indices_.find(current_entry_.dex_register_map_hash);
+size_t StackMapStream::AddDexRegisterMapEntry(const DexRegisterMapEntry& entry) {
+ const size_t current_entry_index = dex_register_entries_.size();
+ auto entries_it = dex_map_hash_to_stack_map_indices_.find(entry.hash);
if (entries_it == dex_map_hash_to_stack_map_indices_.end()) {
// We don't have a perfect hash functions so we need a list to collect all stack maps
// which might have the same dex register map.
ArenaVector<uint32_t> stack_map_indices(allocator_->Adapter(kArenaAllocStackMapStream));
stack_map_indices.push_back(current_entry_index);
- dex_map_hash_to_stack_map_indices_.Put(current_entry_.dex_register_map_hash,
- std::move(stack_map_indices));
- return kNoSameDexMapFound;
- }
-
- // We might have collisions, so we need to check whether or not we really have a match.
- for (uint32_t test_entry_index : entries_it->second) {
- if (HaveTheSameDexMaps(GetStackMap(test_entry_index), current_entry_)) {
- return test_entry_index;
+ dex_map_hash_to_stack_map_indices_.Put(entry.hash, std::move(stack_map_indices));
+ } else {
+ // We might have collisions, so we need to check whether or not we really have a match.
+ for (uint32_t test_entry_index : entries_it->second) {
+ if (DexRegisterMapEntryEquals(dex_register_entries_[test_entry_index], entry)) {
+ return test_entry_index;
+ }
}
+ entries_it->second.push_back(current_entry_index);
}
- entries_it->second.push_back(current_entry_index);
- return kNoSameDexMapFound;
+ dex_register_entries_.push_back(entry);
+ return current_entry_index;
}
-bool StackMapStream::HaveTheSameDexMaps(const StackMapEntry& a, const StackMapEntry& b) const {
- if (a.live_dex_registers_mask == nullptr && b.live_dex_registers_mask == nullptr) {
- return true;
- }
- if (a.live_dex_registers_mask == nullptr || b.live_dex_registers_mask == nullptr) {
+bool StackMapStream::DexRegisterMapEntryEquals(const DexRegisterMapEntry& a,
+ const DexRegisterMapEntry& b) const {
+ if ((a.live_dex_registers_mask == nullptr) != (b.live_dex_registers_mask == nullptr)) {
return false;
}
if (a.num_dex_registers != b.num_dex_registers) {
@@ -489,12 +447,12 @@
}
size_t number_of_live_dex_registers = a.live_dex_registers_mask->NumSetBits();
DCHECK_LE(number_of_live_dex_registers, dex_register_locations_.size());
- DCHECK_LE(a.dex_register_locations_start_index,
+ DCHECK_LE(a.locations_start_index,
dex_register_locations_.size() - number_of_live_dex_registers);
- DCHECK_LE(b.dex_register_locations_start_index,
+ DCHECK_LE(b.locations_start_index,
dex_register_locations_.size() - number_of_live_dex_registers);
- auto a_begin = dex_register_locations_.begin() + a.dex_register_locations_start_index;
- auto b_begin = dex_register_locations_.begin() + b.dex_register_locations_start_index;
+ auto a_begin = dex_register_locations_.begin() + a.locations_start_index;
+ auto b_begin = dex_register_locations_.begin() + b.locations_start_index;
if (!std::equal(a_begin, a_begin + number_of_live_dex_registers, b_begin)) {
return false;
}
@@ -597,10 +555,10 @@
CheckDexRegisterMap(code_info,
code_info.GetDexRegisterMapOf(
- stack_map, encoding, entry.num_dex_registers),
- entry.num_dex_registers,
- entry.live_dex_registers_mask,
- entry.dex_register_locations_start_index);
+ stack_map, encoding, entry.dex_register_entry.num_dex_registers),
+ entry.dex_register_entry.num_dex_registers,
+ entry.dex_register_entry.live_dex_registers_mask,
+ entry.dex_register_entry.locations_start_index);
// Check inline info.
DCHECK_EQ(stack_map.HasInlineInfo(stack_map_encoding), (entry.inlining_depth != 0));
@@ -623,10 +581,13 @@
CheckDexRegisterMap(code_info,
code_info.GetDexRegisterMapAtDepth(
- d, inline_info, encoding, inline_entry.num_dex_registers),
- inline_entry.num_dex_registers,
- inline_entry.live_dex_registers_mask,
- inline_entry.dex_register_locations_start_index);
+ d,
+ inline_info,
+ encoding,
+ inline_entry.dex_register_entry.num_dex_registers),
+ inline_entry.dex_register_entry.num_dex_registers,
+ inline_entry.dex_register_entry.live_dex_registers_mask,
+ inline_entry.dex_register_entry.locations_start_index);
}
}
}
diff --git a/compiler/optimizing/stack_map_stream.h b/compiler/optimizing/stack_map_stream.h
index 08c1d3e..bba3d51 100644
--- a/compiler/optimizing/stack_map_stream.h
+++ b/compiler/optimizing/stack_map_stream.h
@@ -70,6 +70,7 @@
inline_infos_(allocator->Adapter(kArenaAllocStackMapStream)),
stack_masks_(allocator->Adapter(kArenaAllocStackMapStream)),
register_masks_(allocator->Adapter(kArenaAllocStackMapStream)),
+ dex_register_entries_(allocator->Adapter(kArenaAllocStackMapStream)),
stack_mask_max_(-1),
dex_pc_max_(0),
register_mask_max_(0),
@@ -89,30 +90,42 @@
code_info_encoding_.reserve(16);
}
+ // A dex register map entry for a single stack map entry, contains what registers are live as
+ // well as indices into the location catalog.
+ class DexRegisterMapEntry {
+ public:
+ static const size_t kOffsetUnassigned = -1;
+
+ BitVector* live_dex_registers_mask;
+ uint32_t num_dex_registers;
+ size_t locations_start_index;
+ // Computed fields
+ size_t hash = 0;
+ size_t offset = kOffsetUnassigned;
+
+ size_t ComputeSize(size_t catalog_size) const;
+ };
+
// See runtime/stack_map.h to know what these fields contain.
struct StackMapEntry {
uint32_t dex_pc;
CodeOffset native_pc_code_offset;
uint32_t register_mask;
BitVector* sp_mask;
- uint32_t num_dex_registers;
uint8_t inlining_depth;
- size_t dex_register_locations_start_index;
size_t inline_infos_start_index;
- BitVector* live_dex_registers_mask;
- uint32_t dex_register_map_hash;
- size_t same_dex_register_map_as_;
uint32_t stack_mask_index;
uint32_t register_mask_index;
+ DexRegisterMapEntry dex_register_entry;
+ size_t dex_register_map_index;
};
struct InlineInfoEntry {
uint32_t dex_pc; // DexFile::kDexNoIndex for intrinsified native methods.
ArtMethod* method;
uint32_t method_index;
- uint32_t num_dex_registers;
- BitVector* live_dex_registers_mask;
- size_t dex_register_locations_start_index;
+ DexRegisterMapEntry dex_register_entry;
+ size_t dex_register_map_index;
};
void BeginStackMapEntry(uint32_t dex_pc,
@@ -140,7 +153,8 @@
}
void SetStackMapNativePcOffset(size_t i, uint32_t native_pc_offset) {
- stack_maps_[i].native_pc_code_offset = CodeOffset::FromOffset(native_pc_offset, instruction_set_);
+ stack_maps_[i].native_pc_code_offset =
+ CodeOffset::FromOffset(native_pc_offset, instruction_set_);
}
// Prepares the stream to fill in a memory region. Must be called before FillIn.
@@ -150,8 +164,6 @@
private:
size_t ComputeDexRegisterLocationCatalogSize() const;
- size_t ComputeDexRegisterMapSize(uint32_t num_dex_registers,
- const BitVector* live_dex_registers_mask) const;
size_t ComputeDexRegisterMapsSize() const;
void ComputeInlineInfoEncoding(InlineInfoEncoding* encoding,
size_t dex_register_maps_bytes);
@@ -164,15 +176,24 @@
// Returns the number of unique register masks.
size_t PrepareRegisterMasks();
- // Returns the index of an entry with the same dex register map as the current_entry,
- // or kNoSameDexMapFound if no such entry exists.
- size_t FindEntryWithTheSameDexMap();
- bool HaveTheSameDexMaps(const StackMapEntry& a, const StackMapEntry& b) const;
+ // Deduplicate entry if possible and return the corresponding index into dex_register_entries_
+ // array. If entry is not a duplicate, a new entry is added to dex_register_entries_.
+ size_t AddDexRegisterMapEntry(const DexRegisterMapEntry& entry);
+
+ // Return true if the two dex register map entries are equal.
+ bool DexRegisterMapEntryEquals(const DexRegisterMapEntry& a, const DexRegisterMapEntry& b) const;
+
+ // Fill in the corresponding entries of a register map.
void FillInDexRegisterMap(DexRegisterMap dex_register_map,
uint32_t num_dex_registers,
const BitVector& live_dex_registers_mask,
uint32_t start_index_in_dex_register_locations) const;
+ // Returns the offset for the dex register inside of the dex register location region. See FillIn.
+ // Only copies the dex register map if the offset for the entry is not already assigned.
+ size_t MaybeCopyDexRegisterMap(DexRegisterMapEntry& entry,
+ size_t* current_offset,
+ MemoryRegion dex_register_locations_region);
void CheckDexRegisterMap(const CodeInfo& code_info,
const DexRegisterMap& dex_register_map,
size_t num_dex_registers,
@@ -199,6 +220,7 @@
ArenaVector<InlineInfoEntry> inline_infos_;
ArenaVector<uint8_t> stack_masks_;
ArenaVector<uint32_t> register_masks_;
+ ArenaVector<DexRegisterMapEntry> dex_register_entries_;
int stack_mask_max_;
uint32_t dex_pc_max_;
uint32_t register_mask_max_;
diff --git a/compiler/optimizing/stack_map_test.cc b/compiler/optimizing/stack_map_test.cc
index bd0aa6d..0416951 100644
--- a/compiler/optimizing/stack_map_test.cc
+++ b/compiler/optimizing/stack_map_test.cc
@@ -410,6 +410,100 @@
}
}
+TEST(StackMapTest, TestDeduplicateInlineInfoDexRegisterMap) {
+ ArenaPool pool;
+ ArenaAllocator arena(&pool);
+ StackMapStream stream(&arena, kRuntimeISA);
+ ArtMethod art_method;
+
+ ArenaBitVector sp_mask1(&arena, 0, true);
+ sp_mask1.SetBit(2);
+ sp_mask1.SetBit(4);
+ const size_t number_of_dex_registers = 2;
+ const size_t number_of_dex_registers_in_inline_info = 2;
+ stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask1, number_of_dex_registers, 1);
+ stream.AddDexRegisterEntry(Kind::kInStack, 0); // Short location.
+ stream.AddDexRegisterEntry(Kind::kConstant, -2); // Large location.
+ stream.BeginInlineInfoEntry(&art_method, 3, number_of_dex_registers_in_inline_info);
+ stream.AddDexRegisterEntry(Kind::kInStack, 0); // Short location.
+ stream.AddDexRegisterEntry(Kind::kConstant, -2); // Large location.
+ stream.EndInlineInfoEntry();
+ stream.EndStackMapEntry();
+
+ size_t size = stream.PrepareForFillIn();
+ void* memory = arena.Alloc(size, kArenaAllocMisc);
+ MemoryRegion region(memory, size);
+ stream.FillIn(region);
+
+ CodeInfo code_info(region);
+ CodeInfoEncoding encoding = code_info.ExtractEncoding();
+ ASSERT_EQ(1u, code_info.GetNumberOfStackMaps(encoding));
+
+ uint32_t number_of_catalog_entries = code_info.GetNumberOfLocationCatalogEntries(encoding);
+ ASSERT_EQ(2u, number_of_catalog_entries);
+ DexRegisterLocationCatalog location_catalog = code_info.GetDexRegisterLocationCatalog(encoding);
+ // The Dex register location catalog contains:
+ // - one 1-byte short Dex register locations, and
+ // - one 5-byte large Dex register location.
+ const size_t expected_location_catalog_size = 1u + 5u;
+ ASSERT_EQ(expected_location_catalog_size, location_catalog.Size());
+
+ // First stack map.
+ {
+ StackMap stack_map = code_info.GetStackMapAt(0, encoding);
+ ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForDexPc(0, encoding)));
+ ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(64, encoding)));
+ ASSERT_EQ(0u, stack_map.GetDexPc(encoding.stack_map.encoding));
+ ASSERT_EQ(64u, stack_map.GetNativePcOffset(encoding.stack_map.encoding, kRuntimeISA));
+ ASSERT_EQ(0x3u, code_info.GetRegisterMaskOf(encoding, stack_map));
+
+ ASSERT_TRUE(CheckStackMask(code_info, encoding, stack_map, sp_mask1));
+
+ ASSERT_TRUE(stack_map.HasDexRegisterMap(encoding.stack_map.encoding));
+ DexRegisterMap map(code_info.GetDexRegisterMapOf(stack_map, encoding, number_of_dex_registers));
+ ASSERT_TRUE(map.IsDexRegisterLive(0));
+ ASSERT_TRUE(map.IsDexRegisterLive(1));
+ ASSERT_EQ(2u, map.GetNumberOfLiveDexRegisters(number_of_dex_registers));
+ // The Dex register map contains:
+ // - one 1-byte live bit mask, and
+ // - one 1-byte set of location catalog entry indices composed of two 2-bit values.
+ size_t expected_map_size = 1u + 1u;
+ ASSERT_EQ(expected_map_size, map.Size());
+
+ ASSERT_EQ(Kind::kInStack, map.GetLocationKind(0, number_of_dex_registers, code_info, encoding));
+ ASSERT_EQ(Kind::kConstant,
+ map.GetLocationKind(1, number_of_dex_registers, code_info, encoding));
+ ASSERT_EQ(Kind::kInStack,
+ map.GetLocationInternalKind(0, number_of_dex_registers, code_info, encoding));
+ ASSERT_EQ(Kind::kConstantLargeValue,
+ map.GetLocationInternalKind(1, number_of_dex_registers, code_info, encoding));
+ ASSERT_EQ(0, map.GetStackOffsetInBytes(0, number_of_dex_registers, code_info, encoding));
+ ASSERT_EQ(-2, map.GetConstant(1, number_of_dex_registers, code_info, encoding));
+
+ const size_t index0 =
+ map.GetLocationCatalogEntryIndex(0, number_of_dex_registers, number_of_catalog_entries);
+ const size_t index1 =
+ map.GetLocationCatalogEntryIndex(1, number_of_dex_registers, number_of_catalog_entries);
+ ASSERT_EQ(0u, index0);
+ ASSERT_EQ(1u, index1);
+ DexRegisterLocation location0 = location_catalog.GetDexRegisterLocation(index0);
+ DexRegisterLocation location1 = location_catalog.GetDexRegisterLocation(index1);
+ ASSERT_EQ(Kind::kInStack, location0.GetKind());
+ ASSERT_EQ(Kind::kConstant, location1.GetKind());
+ ASSERT_EQ(Kind::kInStack, location0.GetInternalKind());
+ ASSERT_EQ(Kind::kConstantLargeValue, location1.GetInternalKind());
+ ASSERT_EQ(0, location0.GetValue());
+ ASSERT_EQ(-2, location1.GetValue());
+
+ // Test that the inline info dex register map deduplicated to the same offset as the stack map
+ // one.
+ ASSERT_TRUE(stack_map.HasInlineInfo(encoding.stack_map.encoding));
+ InlineInfo inline_info = code_info.GetInlineInfoOf(stack_map, encoding);
+ EXPECT_EQ(inline_info.GetDexRegisterMapOffsetAtDepth(encoding.inline_info.encoding, 0),
+ stack_map.GetDexRegisterMapOffset(encoding.stack_map.encoding));
+ }
+}
+
TEST(StackMapTest, TestNonLiveDexRegisters) {
ArenaPool pool;
ArenaAllocator arena(&pool);
diff --git a/compiler/utils/x86/assembler_x86.cc b/compiler/utils/x86/assembler_x86.cc
index a24d49e..5a466e1 100644
--- a/compiler/utils/x86/assembler_x86.cc
+++ b/compiler/utils/x86/assembler_x86.cc
@@ -783,6 +783,79 @@
}
+void X86Assembler::movdqa(XmmRegister dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitUint8(0x0F);
+ EmitUint8(0x6F);
+ EmitXmmRegisterOperand(dst, src);
+}
+
+
+void X86Assembler::movdqa(XmmRegister dst, const Address& src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitUint8(0x0F);
+ EmitUint8(0x6F);
+ EmitOperand(dst, src);
+}
+
+
+void X86Assembler::movdqu(XmmRegister dst, const Address& src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0xF3);
+ EmitUint8(0x0F);
+ EmitUint8(0x6F);
+ EmitOperand(dst, src);
+}
+
+
+void X86Assembler::movdqa(const Address& dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitUint8(0x0F);
+ EmitUint8(0x7F);
+ EmitOperand(src, dst);
+}
+
+
+void X86Assembler::movdqu(const Address& dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0xF3);
+ EmitUint8(0x0F);
+ EmitUint8(0x7F);
+ EmitOperand(src, dst);
+}
+
+
+void X86Assembler::paddd(XmmRegister dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitUint8(0x0F);
+ EmitUint8(0xFE);
+ EmitXmmRegisterOperand(dst, src);
+}
+
+
+void X86Assembler::psubd(XmmRegister dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitUint8(0x0F);
+ EmitUint8(0xFA);
+ EmitXmmRegisterOperand(dst, src);
+}
+
+
+void X86Assembler::pmulld(XmmRegister dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitUint8(0x0F);
+ EmitUint8(0x38);
+ EmitUint8(0x40);
+ EmitXmmRegisterOperand(dst, src);
+}
+
+
void X86Assembler::cvtsi2ss(XmmRegister dst, Register src) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
EmitUint8(0xF3);
@@ -990,10 +1063,27 @@
}
-void X86Assembler::andps(XmmRegister dst, XmmRegister src) {
+void X86Assembler::xorps(XmmRegister dst, const Address& src) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
EmitUint8(0x0F);
- EmitUint8(0x54);
+ EmitUint8(0x57);
+ EmitOperand(dst, src);
+}
+
+
+void X86Assembler::xorps(XmmRegister dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x0F);
+ EmitUint8(0x57);
+ EmitXmmRegisterOperand(dst, src);
+}
+
+
+void X86Assembler::pxor(XmmRegister dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitUint8(0x0F);
+ EmitUint8(0xEF);
EmitXmmRegisterOperand(dst, src);
}
@@ -1007,35 +1097,19 @@
}
-void X86Assembler::orpd(XmmRegister dst, XmmRegister src) {
+void X86Assembler::andpd(XmmRegister dst, const Address& src) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
EmitUint8(0x66);
EmitUint8(0x0F);
- EmitUint8(0x56);
- EmitXmmRegisterOperand(dst, src);
-}
-
-
-void X86Assembler::xorps(XmmRegister dst, const Address& src) {
- AssemblerBuffer::EnsureCapacity ensured(&buffer_);
- EmitUint8(0x0F);
- EmitUint8(0x57);
+ EmitUint8(0x54);
EmitOperand(dst, src);
}
-void X86Assembler::orps(XmmRegister dst, XmmRegister src) {
+void X86Assembler::andps(XmmRegister dst, XmmRegister src) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
EmitUint8(0x0F);
- EmitUint8(0x56);
- EmitXmmRegisterOperand(dst, src);
-}
-
-
-void X86Assembler::xorps(XmmRegister dst, XmmRegister src) {
- AssemblerBuffer::EnsureCapacity ensured(&buffer_);
- EmitUint8(0x0F);
- EmitUint8(0x57);
+ EmitUint8(0x54);
EmitXmmRegisterOperand(dst, src);
}
@@ -1048,12 +1122,38 @@
}
-void X86Assembler::andpd(XmmRegister dst, const Address& src) {
+void X86Assembler::pand(XmmRegister dst, XmmRegister src) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
EmitUint8(0x66);
EmitUint8(0x0F);
- EmitUint8(0x54);
- EmitOperand(dst, src);
+ EmitUint8(0xDB);
+ EmitXmmRegisterOperand(dst, src);
+}
+
+
+void X86Assembler::orpd(XmmRegister dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitUint8(0x0F);
+ EmitUint8(0x56);
+ EmitXmmRegisterOperand(dst, src);
+}
+
+
+void X86Assembler::orps(XmmRegister dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x0F);
+ EmitUint8(0x56);
+ EmitXmmRegisterOperand(dst, src);
+}
+
+
+void X86Assembler::por(XmmRegister dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitUint8(0x0F);
+ EmitUint8(0xEB);
+ EmitXmmRegisterOperand(dst, src);
}
@@ -1076,6 +1176,16 @@
}
+void X86Assembler::pshufd(XmmRegister dst, XmmRegister src, const Immediate& imm) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitUint8(0x0F);
+ EmitUint8(0x70);
+ EmitXmmRegisterOperand(dst, src);
+ EmitUint8(imm.value());
+}
+
+
void X86Assembler::fldl(const Address& src) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
EmitUint8(0xDD);
diff --git a/compiler/utils/x86/assembler_x86.h b/compiler/utils/x86/assembler_x86.h
index 4056ca6..4343e2e 100644
--- a/compiler/utils/x86/assembler_x86.h
+++ b/compiler/utils/x86/assembler_x86.h
@@ -430,6 +430,16 @@
void mulpd(XmmRegister dst, XmmRegister src);
void divpd(XmmRegister dst, XmmRegister src);
+ void movdqa(XmmRegister dst, XmmRegister src); // move
+ void movdqa(XmmRegister dst, const Address& src); // load aligned
+ void movdqu(XmmRegister dst, const Address& src); // load unaligned
+ void movdqa(const Address& dst, XmmRegister src); // store aligned
+ void movdqu(const Address& dst, XmmRegister src); // store unaligned
+
+ void paddd(XmmRegister dst, XmmRegister src); // no addr variant (for now)
+ void psubd(XmmRegister dst, XmmRegister src);
+ void pmulld(XmmRegister dst, XmmRegister src);
+
void cvtsi2ss(XmmRegister dst, Register src);
void cvtsi2sd(XmmRegister dst, Register src);
@@ -463,17 +473,21 @@
void xorpd(XmmRegister dst, XmmRegister src);
void xorps(XmmRegister dst, const Address& src);
void xorps(XmmRegister dst, XmmRegister src);
+ void pxor(XmmRegister dst, XmmRegister src); // no addr variant (for now)
void andpd(XmmRegister dst, XmmRegister src);
void andpd(XmmRegister dst, const Address& src);
void andps(XmmRegister dst, XmmRegister src);
void andps(XmmRegister dst, const Address& src);
+ void pand(XmmRegister dst, XmmRegister src); // no addr variant (for now)
- void orpd(XmmRegister dst, XmmRegister src);
+ void orpd(XmmRegister dst, XmmRegister src); // no addr variant (for now)
void orps(XmmRegister dst, XmmRegister src);
+ void por(XmmRegister dst, XmmRegister src);
void shufpd(XmmRegister dst, XmmRegister src, const Immediate& imm);
void shufps(XmmRegister dst, XmmRegister src, const Immediate& imm);
+ void pshufd(XmmRegister dst, XmmRegister src, const Immediate& imm);
void flds(const Address& src);
void fstps(const Address& dst);
diff --git a/compiler/utils/x86/assembler_x86_test.cc b/compiler/utils/x86/assembler_x86_test.cc
index 1768d8b..c6ab893 100644
--- a/compiler/utils/x86/assembler_x86_test.cc
+++ b/compiler/utils/x86/assembler_x86_test.cc
@@ -467,6 +467,28 @@
DriverStr(expected, "movupd_address");
}
+TEST_F(AssemblerX86Test, Movdqa) {
+ DriverStr(RepeatFF(&x86::X86Assembler::movdqa, "movdqa %{reg2}, %{reg1}"), "movdqa");
+}
+
+TEST_F(AssemblerX86Test, MovdqaAddr) {
+ GetAssembler()->movdqa(x86::XmmRegister(x86::XMM0), x86::Address(x86::Register(x86::ESP), 4));
+ GetAssembler()->movdqa(x86::Address(x86::Register(x86::ESP), 2), x86::XmmRegister(x86::XMM1));
+ const char* expected =
+ "movdqa 0x4(%ESP), %xmm0\n"
+ "movdqa %xmm1, 0x2(%ESP)\n";
+ DriverStr(expected, "movdqa_address");
+}
+
+TEST_F(AssemblerX86Test, MovdquAddr) {
+ GetAssembler()->movdqu(x86::XmmRegister(x86::XMM0), x86::Address(x86::Register(x86::ESP), 4));
+ GetAssembler()->movdqu(x86::Address(x86::Register(x86::ESP), 2), x86::XmmRegister(x86::XMM1));
+ const char* expected =
+ "movdqu 0x4(%ESP), %xmm0\n"
+ "movdqu %xmm1, 0x2(%ESP)\n";
+ DriverStr(expected, "movdqu_address");
+}
+
TEST_F(AssemblerX86Test, AddPS) {
DriverStr(RepeatFF(&x86::X86Assembler::addps, "addps %{reg2}, %{reg1}"), "addps");
}
@@ -499,6 +521,54 @@
DriverStr(RepeatFF(&x86::X86Assembler::divpd, "divpd %{reg2}, %{reg1}"), "divpd");
}
+TEST_F(AssemblerX86Test, PAddD) {
+ DriverStr(RepeatFF(&x86::X86Assembler::paddd, "paddd %{reg2}, %{reg1}"), "paddd");
+}
+
+TEST_F(AssemblerX86Test, PSubD) {
+ DriverStr(RepeatFF(&x86::X86Assembler::psubd, "psubd %{reg2}, %{reg1}"), "psubd");
+}
+
+TEST_F(AssemblerX86Test, PMullD) {
+ DriverStr(RepeatFF(&x86::X86Assembler::pmulld, "pmulld %{reg2}, %{reg1}"), "pmulld");
+}
+
+TEST_F(AssemblerX86Test, XorPD) {
+ DriverStr(RepeatFF(&x86::X86Assembler::xorpd, "xorpd %{reg2}, %{reg1}"), "xorpd");
+}
+
+TEST_F(AssemblerX86Test, XorPS) {
+ DriverStr(RepeatFF(&x86::X86Assembler::xorps, "xorps %{reg2}, %{reg1}"), "xorps");
+}
+
+TEST_F(AssemblerX86Test, PXor) {
+ DriverStr(RepeatFF(&x86::X86Assembler::pxor, "pxor %{reg2}, %{reg1}"), "pxor");
+}
+
+TEST_F(AssemblerX86Test, AndPD) {
+ DriverStr(RepeatFF(&x86::X86Assembler::andpd, "andpd %{reg2}, %{reg1}"), "andpd");
+}
+
+TEST_F(AssemblerX86Test, AndPS) {
+ DriverStr(RepeatFF(&x86::X86Assembler::andps, "andps %{reg2}, %{reg1}"), "andps");
+}
+
+TEST_F(AssemblerX86Test, PAnd) {
+ DriverStr(RepeatFF(&x86::X86Assembler::pand, "pand %{reg2}, %{reg1}"), "pand");
+}
+
+TEST_F(AssemblerX86Test, OrPD) {
+ DriverStr(RepeatFF(&x86::X86Assembler::orpd, "orpd %{reg2}, %{reg1}"), "orpd");
+}
+
+TEST_F(AssemblerX86Test, OrPS) {
+ DriverStr(RepeatFF(&x86::X86Assembler::orps, "orps %{reg2}, %{reg1}"), "orps");
+}
+
+TEST_F(AssemblerX86Test, POr) {
+ DriverStr(RepeatFF(&x86::X86Assembler::por, "por %{reg2}, %{reg1}"), "por");
+}
+
TEST_F(AssemblerX86Test, ShufPS) {
DriverStr(RepeatFFI(&x86::X86Assembler::shufps, 1, "shufps ${imm}, %{reg2}, %{reg1}"), "shufps");
}
@@ -507,6 +577,10 @@
DriverStr(RepeatFFI(&x86::X86Assembler::shufpd, 1, "shufpd ${imm}, %{reg2}, %{reg1}"), "shufpd");
}
+TEST_F(AssemblerX86Test, PShufD) {
+ DriverStr(RepeatFFI(&x86::X86Assembler::pshufd, 1, "pshufd ${imm}, %{reg2}, %{reg1}"), "pshufd");
+}
+
/////////////////
// Near labels //
/////////////////
diff --git a/compiler/utils/x86_64/assembler_x86_64.cc b/compiler/utils/x86_64/assembler_x86_64.cc
index c2c44ab..b41be80 100644
--- a/compiler/utils/x86_64/assembler_x86_64.cc
+++ b/compiler/utils/x86_64/assembler_x86_64.cc
@@ -832,6 +832,87 @@
}
+void X86_64Assembler::movdqa(XmmRegister dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitOptionalRex32(dst, src);
+ EmitUint8(0x0F);
+ EmitUint8(0x6F);
+ EmitXmmRegisterOperand(dst.LowBits(), src);
+}
+
+
+void X86_64Assembler::movdqa(XmmRegister dst, const Address& src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitOptionalRex32(dst, src);
+ EmitUint8(0x0F);
+ EmitUint8(0x6F);
+ EmitOperand(dst.LowBits(), src);
+}
+
+
+void X86_64Assembler::movdqu(XmmRegister dst, const Address& src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0xF3);
+ EmitOptionalRex32(dst, src);
+ EmitUint8(0x0F);
+ EmitUint8(0x6F);
+ EmitOperand(dst.LowBits(), src);
+}
+
+
+void X86_64Assembler::movdqa(const Address& dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitOptionalRex32(src, dst);
+ EmitUint8(0x0F);
+ EmitUint8(0x7F);
+ EmitOperand(src.LowBits(), dst);
+}
+
+
+void X86_64Assembler::movdqu(const Address& dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0xF3);
+ EmitOptionalRex32(src, dst);
+ EmitUint8(0x0F);
+ EmitUint8(0x7F);
+ EmitOperand(src.LowBits(), dst);
+}
+
+
+void X86_64Assembler::paddd(XmmRegister dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitOptionalRex32(dst, src);
+ EmitUint8(0x0F);
+ EmitUint8(0xFE);
+ EmitXmmRegisterOperand(dst.LowBits(), src);
+}
+
+
+void X86_64Assembler::psubd(XmmRegister dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitOptionalRex32(dst, src);
+ EmitUint8(0x0F);
+ EmitUint8(0xFA);
+ EmitXmmRegisterOperand(dst.LowBits(), src);
+}
+
+
+void X86_64Assembler::pmulld(XmmRegister dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitOptionalRex32(dst, src);
+ EmitUint8(0x0F);
+ EmitUint8(0x38);
+ EmitUint8(0x40);
+ EmitXmmRegisterOperand(dst.LowBits(), src);
+}
+
+
void X86_64Assembler::cvtsi2ss(XmmRegister dst, CpuRegister src) {
cvtsi2ss(dst, src, false);
}
@@ -1170,6 +1251,16 @@
}
+void X86_64Assembler::pxor(XmmRegister dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitOptionalRex32(dst, src);
+ EmitUint8(0x0F);
+ EmitUint8(0xEF);
+ EmitXmmRegisterOperand(dst.LowBits(), src);
+}
+
+
void X86_64Assembler::andpd(XmmRegister dst, const Address& src) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
EmitUint8(0x66);
@@ -1196,6 +1287,15 @@
EmitXmmRegisterOperand(dst.LowBits(), src);
}
+void X86_64Assembler::pand(XmmRegister dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitOptionalRex32(dst, src);
+ EmitUint8(0x0F);
+ EmitUint8(0xDB);
+ EmitXmmRegisterOperand(dst.LowBits(), src);
+}
+
void X86_64Assembler::orpd(XmmRegister dst, XmmRegister src) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
EmitUint8(0x66);
@@ -1213,6 +1313,14 @@
EmitXmmRegisterOperand(dst.LowBits(), src);
}
+void X86_64Assembler::por(XmmRegister dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitOptionalRex32(dst, src);
+ EmitUint8(0x0F);
+ EmitUint8(0xEB);
+ EmitXmmRegisterOperand(dst.LowBits(), src);
+}
void X86_64Assembler::shufpd(XmmRegister dst, XmmRegister src, const Immediate& imm) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
@@ -1235,6 +1343,17 @@
}
+void X86_64Assembler::pshufd(XmmRegister dst, XmmRegister src, const Immediate& imm) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
+ EmitOptionalRex32(dst, src);
+ EmitUint8(0x0F);
+ EmitUint8(0x70);
+ EmitXmmRegisterOperand(dst.LowBits(), src);
+ EmitUint8(imm.value());
+}
+
+
void X86_64Assembler::fldl(const Address& src) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
EmitUint8(0xDD);
diff --git a/compiler/utils/x86_64/assembler_x86_64.h b/compiler/utils/x86_64/assembler_x86_64.h
index e140b45..43ea12a 100644
--- a/compiler/utils/x86_64/assembler_x86_64.h
+++ b/compiler/utils/x86_64/assembler_x86_64.h
@@ -446,6 +446,16 @@
void mulpd(XmmRegister dst, XmmRegister src);
void divpd(XmmRegister dst, XmmRegister src);
+ void movdqa(XmmRegister dst, XmmRegister src); // move
+ void movdqa(XmmRegister dst, const Address& src); // load aligned
+ void movdqu(XmmRegister dst, const Address& src); // load unaligned
+ void movdqa(const Address& dst, XmmRegister src); // store aligned
+ void movdqu(const Address& dst, XmmRegister src); // store unaligned
+
+ void paddd(XmmRegister dst, XmmRegister src); // no addr variant (for now)
+ void psubd(XmmRegister dst, XmmRegister src);
+ void pmulld(XmmRegister dst, XmmRegister src);
+
void cvtsi2ss(XmmRegister dst, CpuRegister src); // Note: this is the r/m32 version.
void cvtsi2ss(XmmRegister dst, CpuRegister src, bool is64bit);
void cvtsi2ss(XmmRegister dst, const Address& src, bool is64bit);
@@ -487,16 +497,20 @@
void xorpd(XmmRegister dst, XmmRegister src);
void xorps(XmmRegister dst, const Address& src);
void xorps(XmmRegister dst, XmmRegister src);
+ void pxor(XmmRegister dst, XmmRegister src); // no addr variant (for now)
void andpd(XmmRegister dst, const Address& src);
void andpd(XmmRegister dst, XmmRegister src);
- void andps(XmmRegister dst, XmmRegister src);
+ void andps(XmmRegister dst, XmmRegister src); // no addr variant (for now)
+ void pand(XmmRegister dst, XmmRegister src);
- void orpd(XmmRegister dst, XmmRegister src);
+ void orpd(XmmRegister dst, XmmRegister src); // no addr variant (for now)
void orps(XmmRegister dst, XmmRegister src);
+ void por(XmmRegister dst, XmmRegister src);
void shufpd(XmmRegister dst, XmmRegister src, const Immediate& imm);
void shufps(XmmRegister dst, XmmRegister src, const Immediate& imm);
+ void pshufd(XmmRegister dst, XmmRegister src, const Immediate& imm);
void flds(const Address& src);
void fstps(const Address& dst);
diff --git a/compiler/utils/x86_64/assembler_x86_64_test.cc b/compiler/utils/x86_64/assembler_x86_64_test.cc
index efa5cc9..aeb1911 100644
--- a/compiler/utils/x86_64/assembler_x86_64_test.cc
+++ b/compiler/utils/x86_64/assembler_x86_64_test.cc
@@ -1034,6 +1034,28 @@
DriverStr(RepeatFF(&x86_64::X86_64Assembler::movsd, "movsd %{reg2}, %{reg1}"), "movsd");
}
+TEST_F(AssemblerX86_64Test, Movdqa) {
+ DriverStr(RepeatFF(&x86_64::X86_64Assembler::movdqa, "movdqa %{reg2}, %{reg1}"), "movapd");
+}
+
+TEST_F(AssemblerX86_64Test, MovdqaAddr) {
+ GetAssembler()->movdqa(x86_64::XmmRegister(x86_64::XMM0), x86_64::Address(x86_64::CpuRegister(x86_64::RSP), 4));
+ GetAssembler()->movdqa(x86_64::Address(x86_64::CpuRegister(x86_64::RSP), 2), x86_64::XmmRegister(x86_64::XMM1));
+ const char* expected =
+ "movdqa 0x4(%RSP), %xmm0\n"
+ "movdqa %xmm1, 0x2(%RSP)\n";
+ DriverStr(expected, "movdqa_address");
+}
+
+TEST_F(AssemblerX86_64Test, MovdquAddr) {
+ GetAssembler()->movdqu(x86_64::XmmRegister(x86_64::XMM0), x86_64::Address(x86_64::CpuRegister(x86_64::RSP), 4));
+ GetAssembler()->movdqu(x86_64::Address(x86_64::CpuRegister(x86_64::RSP), 2), x86_64::XmmRegister(x86_64::XMM1));
+ const char* expected =
+ "movdqu 0x4(%RSP), %xmm0\n"
+ "movdqu %xmm1, 0x2(%RSP)\n";
+ DriverStr(expected, "movdqu_address");
+}
+
TEST_F(AssemblerX86_64Test, Movd1) {
DriverStr(RepeatFR(&x86_64::X86_64Assembler::movd, "movd %{reg2}, %{reg1}"), "movd.1");
}
@@ -1106,6 +1128,18 @@
DriverStr(RepeatFF(&x86_64::X86_64Assembler::divpd, "divpd %{reg2}, %{reg1}"), "divpd");
}
+TEST_F(AssemblerX86_64Test, Paddd) {
+ DriverStr(RepeatFF(&x86_64::X86_64Assembler::paddd, "paddd %{reg2}, %{reg1}"), "paddd");
+}
+
+TEST_F(AssemblerX86_64Test, Psubd) {
+ DriverStr(RepeatFF(&x86_64::X86_64Assembler::psubd, "psubd %{reg2}, %{reg1}"), "psubd");
+}
+
+TEST_F(AssemblerX86_64Test, Pmulld) {
+ DriverStr(RepeatFF(&x86_64::X86_64Assembler::pmulld, "pmulld %{reg2}, %{reg1}"), "pmulld");
+}
+
TEST_F(AssemblerX86_64Test, Cvtsi2ss) {
DriverStr(RepeatFr(&x86_64::X86_64Assembler::cvtsi2ss, "cvtsi2ss %{reg2}, %{reg1}"), "cvtsi2ss");
}
@@ -1187,6 +1221,10 @@
DriverStr(RepeatFF(&x86_64::X86_64Assembler::xorpd, "xorpd %{reg2}, %{reg1}"), "xorpd");
}
+TEST_F(AssemblerX86_64Test, Pxor) {
+ DriverStr(RepeatFF(&x86_64::X86_64Assembler::pxor, "pxor %{reg2}, %{reg1}"), "pxor");
+}
+
TEST_F(AssemblerX86_64Test, Andps) {
DriverStr(RepeatFF(&x86_64::X86_64Assembler::andps, "andps %{reg2}, %{reg1}"), "andps");
}
@@ -1195,6 +1233,10 @@
DriverStr(RepeatFF(&x86_64::X86_64Assembler::andpd, "andpd %{reg2}, %{reg1}"), "andpd");
}
+TEST_F(AssemblerX86_64Test, Pand) {
+ DriverStr(RepeatFF(&x86_64::X86_64Assembler::pand, "pand %{reg2}, %{reg1}"), "pand");
+}
+
TEST_F(AssemblerX86_64Test, Orps) {
DriverStr(RepeatFF(&x86_64::X86_64Assembler::orps, "orps %{reg2}, %{reg1}"), "orps");
}
@@ -1203,6 +1245,10 @@
DriverStr(RepeatFF(&x86_64::X86_64Assembler::orpd, "orpd %{reg2}, %{reg1}"), "orpd");
}
+TEST_F(AssemblerX86_64Test, Por) {
+ DriverStr(RepeatFF(&x86_64::X86_64Assembler::por, "por %{reg2}, %{reg1}"), "por");
+}
+
TEST_F(AssemblerX86_64Test, Shufps) {
DriverStr(RepeatFFI(&x86_64::X86_64Assembler::shufps, 1, "shufps ${imm}, %{reg2}, %{reg1}"), "shufps");
}
@@ -1211,6 +1257,10 @@
DriverStr(RepeatFFI(&x86_64::X86_64Assembler::shufpd, 1, "shufpd ${imm}, %{reg2}, %{reg1}"), "shufpd");
}
+TEST_F(AssemblerX86_64Test, PShufd) {
+ DriverStr(RepeatFFI(&x86_64::X86_64Assembler::pshufd, 1, "pshufd ${imm}, %{reg2}, %{reg1}"), "pshufd");
+}
+
TEST_F(AssemblerX86_64Test, UcomissAddress) {
GetAssembler()->ucomiss(x86_64::XmmRegister(x86_64::XMM0), x86_64::Address(
x86_64::CpuRegister(x86_64::RDI), x86_64::CpuRegister(x86_64::RBX), x86_64::TIMES_4, 12));
diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index 05cf0fc..5dcdd9e 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -231,7 +231,7 @@
}
virtual std::string GetTestDexFileName() {
- return GetDexSrc1();
+ return Dex2oatEnvironmentTest::GetTestDexFileName("VerifierDeps");
}
virtual void CheckResult(bool expect_use) {
diff --git a/dexdump/dexdump.cc b/dexdump/dexdump.cc
index d5776fa..5656ddd 100644
--- a/dexdump/dexdump.cc
+++ b/dexdump/dexdump.cc
@@ -881,26 +881,30 @@
outSize = snprintf(buf.get(), bufSize, "[obj+%0*x]", width, index);
break;
case Instruction::kIndexMethodAndProtoRef: {
- std::string method("<method?>");
- std::string proto("<proto?>");
- if (index < pDexFile->GetHeader().method_ids_size_) {
- const DexFile::MethodId& pMethodId = pDexFile->GetMethodId(index);
- const char* name = pDexFile->StringDataByIdx(pMethodId.name_idx_);
- const Signature signature = pDexFile->GetMethodSignature(pMethodId);
- const char* backDescriptor = pDexFile->StringByTypeIdx(pMethodId.class_idx_);
- method = android::base::StringPrintf("%s.%s:%s",
- backDescriptor,
- name,
- signature.ToString().c_str());
- }
- if (secondary_index < pDexFile->GetHeader().proto_ids_size_) {
- const DexFile::ProtoId& protoId = pDexFile->GetProtoId(secondary_index);
- const Signature signature = pDexFile->GetProtoSignature(protoId);
- proto = signature.ToString();
- }
- outSize = snprintf(buf.get(), bufSize, "%s, %s // method@%0*x, proto@%0*x",
- method.c_str(), proto.c_str(), width, index, width, secondary_index);
+ std::string method("<method?>");
+ std::string proto("<proto?>");
+ if (index < pDexFile->GetHeader().method_ids_size_) {
+ const DexFile::MethodId& pMethodId = pDexFile->GetMethodId(index);
+ const char* name = pDexFile->StringDataByIdx(pMethodId.name_idx_);
+ const Signature signature = pDexFile->GetMethodSignature(pMethodId);
+ const char* backDescriptor = pDexFile->StringByTypeIdx(pMethodId.class_idx_);
+ method = android::base::StringPrintf("%s.%s:%s",
+ backDescriptor,
+ name,
+ signature.ToString().c_str());
}
+ if (secondary_index < pDexFile->GetHeader().proto_ids_size_) {
+ const DexFile::ProtoId& protoId = pDexFile->GetProtoId(secondary_index);
+ const Signature signature = pDexFile->GetProtoSignature(protoId);
+ proto = signature.ToString();
+ }
+ outSize = snprintf(buf.get(), bufSize, "%s, %s // method@%0*x, proto@%0*x",
+ method.c_str(), proto.c_str(), width, index, width, secondary_index);
+ break;
+ }
+ case Instruction::kIndexCallSiteRef:
+ // Call site information is too large to detail in disassembly so just output the index.
+ outSize = snprintf(buf.get(), bufSize, "call_site@%0*x", width, index);
break;
// SOME NOT SUPPORTED:
// case Instruction::kIndexVaries:
@@ -1581,6 +1585,198 @@
free(accessStr);
}
+static void dumpMethodHandle(const DexFile* pDexFile, u4 idx) {
+ const DexFile::MethodHandleItem& mh = pDexFile->GetMethodHandle(idx);
+ bool is_invoke = false;
+ const char* type;
+ switch (static_cast<DexFile::MethodHandleType>(mh.method_handle_type_)) {
+ case DexFile::MethodHandleType::kStaticPut:
+ type = "put-static";
+ break;
+ case DexFile::MethodHandleType::kStaticGet:
+ type = "get-static";
+ break;
+ case DexFile::MethodHandleType::kInstancePut:
+ type = "put-instance";
+ break;
+ case DexFile::MethodHandleType::kInstanceGet:
+ type = "get-instance";
+ break;
+ case DexFile::MethodHandleType::kInvokeStatic:
+ type = "invoke-static";
+ is_invoke = true;
+ break;
+ case DexFile::MethodHandleType::kInvokeInstance:
+ type = "invoke-instance";
+ is_invoke = true;
+ break;
+ case DexFile::MethodHandleType::kInvokeConstructor:
+ type = "invoke-constructor";
+ is_invoke = true;
+ break;
+ }
+
+ const char* declaring_class;
+ const char* member;
+ std::string member_type;
+ if (is_invoke) {
+ const DexFile::MethodId& method_id = pDexFile->GetMethodId(mh.field_or_method_idx_);
+ declaring_class = pDexFile->GetMethodDeclaringClassDescriptor(method_id);
+ member = pDexFile->GetMethodName(method_id);
+ member_type = pDexFile->GetMethodSignature(method_id).ToString();
+ } else {
+ const DexFile::FieldId& field_id = pDexFile->GetFieldId(mh.field_or_method_idx_);
+ declaring_class = pDexFile->GetFieldDeclaringClassDescriptor(field_id);
+ member = pDexFile->GetFieldName(field_id);
+ member_type = pDexFile->GetFieldTypeDescriptor(field_id);
+ }
+
+ if (gOptions.outputFormat == OUTPUT_PLAIN) {
+ fprintf(gOutFile, "Method handle #%u:\n", idx);
+ fprintf(gOutFile, " type : %s\n", type);
+ fprintf(gOutFile, " target : %s %s\n", declaring_class, member);
+ fprintf(gOutFile, " target_type : %s\n", member_type.c_str());
+ } else {
+ fprintf(gOutFile, "<method_handle index=\"%u\"\n", idx);
+ fprintf(gOutFile, " type=\"%s\"\n", type);
+ fprintf(gOutFile, " target_class=\"%s\"\n", declaring_class);
+ fprintf(gOutFile, " target_member=\"%s\"\n", member);
+ fprintf(gOutFile, " target_member_type=");
+ dumpEscapedString(member_type.c_str());
+ fprintf(gOutFile, "\n>\n</method_handle>\n");
+ }
+}
+
+static void dumpCallSite(const DexFile* pDexFile, u4 idx) {
+ const DexFile::CallSiteIdItem& call_site_id = pDexFile->GetCallSiteId(idx);
+ CallSiteArrayValueIterator it(*pDexFile, call_site_id);
+ if (it.Size() < 3) {
+ fprintf(stderr, "ERROR: Call site %u has too few values.\n", idx);
+ return;
+ }
+
+ uint32_t method_handle_idx = static_cast<uint32_t>(it.GetJavaValue().i);
+ it.Next();
+ dex::StringIndex method_name_idx = static_cast<dex::StringIndex>(it.GetJavaValue().i);
+ const char* method_name = pDexFile->StringDataByIdx(method_name_idx);
+ it.Next();
+ uint32_t method_type_idx = static_cast<uint32_t>(it.GetJavaValue().i);
+ const DexFile::ProtoId& method_type_id = pDexFile->GetProtoId(method_type_idx);
+ std::string method_type = pDexFile->GetProtoSignature(method_type_id).ToString();
+ it.Next();
+
+ if (gOptions.outputFormat == OUTPUT_PLAIN) {
+ fprintf(gOutFile, "Call site #%u:\n", idx);
+ fprintf(gOutFile, " link_argument[0] : %u (MethodHandle)\n", method_handle_idx);
+ fprintf(gOutFile, " link_argument[1] : %s (String)\n", method_name);
+ fprintf(gOutFile, " link_argument[2] : %s (MethodType)\n", method_type.c_str());
+ } else {
+ fprintf(gOutFile, "<call_site index=\"%u\">\n", idx);
+ fprintf(gOutFile,
+ "<link_argument index=\"0\" type=\"MethodHandle\" value=\"%u\"/>\n",
+ method_handle_idx);
+ fprintf(gOutFile,
+ "<link_argument index=\"1\" type=\"String\" values=\"%s\"/>\n",
+ method_name);
+ fprintf(gOutFile,
+ "<link_argument index=\"2\" type=\"MethodType\" value=\"%s\"/>\n",
+ method_type.c_str());
+ }
+
+ size_t argument = 3;
+ while (it.HasNext()) {
+ const char* type;
+ std::string value;
+ switch (it.GetValueType()) {
+ case EncodedArrayValueIterator::ValueType::kByte:
+ type = "byte";
+ value = android::base::StringPrintf("%u", it.GetJavaValue().b);
+ break;
+ case EncodedArrayValueIterator::ValueType::kShort:
+ type = "short";
+ value = android::base::StringPrintf("%d", it.GetJavaValue().s);
+ break;
+ case EncodedArrayValueIterator::ValueType::kChar:
+ type = "char";
+ value = android::base::StringPrintf("%u", it.GetJavaValue().c);
+ break;
+ case EncodedArrayValueIterator::ValueType::kInt:
+ type = "int";
+ value = android::base::StringPrintf("%d", it.GetJavaValue().i);
+ break;
+ case EncodedArrayValueIterator::ValueType::kLong:
+ type = "long";
+ value = android::base::StringPrintf("%" PRId64, it.GetJavaValue().j);
+ break;
+ case EncodedArrayValueIterator::ValueType::kFloat:
+ type = "float";
+ value = android::base::StringPrintf("%g", it.GetJavaValue().f);
+ break;
+ case EncodedArrayValueIterator::ValueType::kDouble:
+ type = "double";
+ value = android::base::StringPrintf("%g", it.GetJavaValue().d);
+ break;
+ case EncodedArrayValueIterator::ValueType::kMethodType: {
+ type = "MethodType";
+ uint32_t proto_idx = static_cast<uint32_t>(it.GetJavaValue().i);
+ const DexFile::ProtoId& proto_id = pDexFile->GetProtoId(proto_idx);
+ value = pDexFile->GetProtoSignature(proto_id).ToString();
+ break;
+ }
+ case EncodedArrayValueIterator::ValueType::kMethodHandle:
+ type = "MethodHandle";
+ value = android::base::StringPrintf("%d", it.GetJavaValue().i);
+ break;
+ case EncodedArrayValueIterator::ValueType::kString: {
+ type = "String";
+ dex::StringIndex string_idx = static_cast<dex::StringIndex>(it.GetJavaValue().i);
+ value = pDexFile->StringDataByIdx(string_idx);
+ break;
+ }
+ case EncodedArrayValueIterator::ValueType::kType: {
+ type = "Class";
+ dex::TypeIndex type_idx = static_cast<dex::TypeIndex>(it.GetJavaValue().i);
+ const DexFile::ClassDef* class_def = pDexFile->FindClassDef(type_idx);
+ value = pDexFile->GetClassDescriptor(*class_def);
+ value = descriptorClassToDot(value.c_str()).get();
+ break;
+ }
+ case EncodedArrayValueIterator::ValueType::kField:
+ case EncodedArrayValueIterator::ValueType::kMethod:
+ case EncodedArrayValueIterator::ValueType::kEnum:
+ case EncodedArrayValueIterator::ValueType::kArray:
+ case EncodedArrayValueIterator::ValueType::kAnnotation:
+ // Unreachable based on current EncodedArrayValueIterator::Next().
+ UNIMPLEMENTED(FATAL) << " type " << type;
+ UNREACHABLE();
+ break;
+ case EncodedArrayValueIterator::ValueType::kNull:
+ type = "Null";
+ value = "null";
+ break;
+ case EncodedArrayValueIterator::ValueType::kBoolean:
+ type = "boolean";
+ value = it.GetJavaValue().z ? "true" : "false";
+ break;
+ }
+
+ if (gOptions.outputFormat == OUTPUT_PLAIN) {
+ fprintf(gOutFile, " link_argument[%zu] : %s (%s)\n", argument, value.c_str(), type);
+ } else {
+ fprintf(gOutFile, "<link_argument index=\"%zu\" type=\"%s\" value=", argument, type);
+ dumpEscapedString(value.c_str());
+ fprintf(gOutFile, "/>\n");
+ }
+
+ it.Next();
+ argument++;
+ }
+
+ if (gOptions.outputFormat == OUTPUT_XML) {
+ fprintf(gOutFile, "</call_site>\n");
+ }
+}
+
/*
* Dumps the requested sections of the file.
*/
@@ -1612,6 +1808,16 @@
dumpClass(pDexFile, i, &package);
} // for
+ // Iterate over all method handles.
+ for (u4 i = 0; i < pDexFile->NumMethodHandles(); ++i) {
+ dumpMethodHandle(pDexFile, i);
+ } // for
+
+ // Iterate over all call site ids.
+ for (u4 i = 0; i < pDexFile->NumCallSiteIds(); ++i) {
+ dumpCallSite(pDexFile, i);
+ } // for
+
// Free the last package allocated.
if (package != nullptr) {
fprintf(gOutFile, "</package>\n");
diff --git a/disassembler/disassembler_x86.cc b/disassembler/disassembler_x86.cc
index 9f49ec6..ff05733 100644
--- a/disassembler/disassembler_x86.cc
+++ b/disassembler/disassembler_x86.cc
@@ -859,6 +859,22 @@
has_modrm = true;
store = true;
break;
+ case 0x7F:
+ if (prefix[2] == 0x66) {
+ src_reg_file = dst_reg_file = SSE;
+ opcode1 = "movdqa";
+ prefix[2] = 0; // clear prefix now it's served its purpose as part of the opcode
+ } else if (prefix[0] == 0xF3) {
+ src_reg_file = dst_reg_file = SSE;
+ opcode1 = "movdqu";
+ prefix[0] = 0; // clear prefix now it's served its purpose as part of the opcode
+ } else {
+ dst_reg_file = MMX;
+ opcode1 = "movq";
+ }
+ store = true;
+ has_modrm = true;
+ break;
case 0x80: case 0x81: case 0x82: case 0x83: case 0x84: case 0x85: case 0x86: case 0x87:
case 0x88: case 0x89: case 0x8A: case 0x8B: case 0x8C: case 0x8D: case 0x8E: case 0x8F:
opcode1 = "j";
diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc
index 9a73830..b9be5f2 100644
--- a/patchoat/patchoat.cc
+++ b/patchoat/patchoat.cc
@@ -688,6 +688,16 @@
orig_dex_cache->FixupResolvedMethodTypes(RelocatedCopyOf(orig_method_types),
RelocatedPointerVisitor(this));
}
+
+ GcRoot<mirror::CallSite>* orig_call_sites = orig_dex_cache->GetResolvedCallSites();
+ GcRoot<mirror::CallSite>* relocated_call_sites = RelocatedAddressOfPointer(orig_call_sites);
+ copy_dex_cache->SetField64<false>(
+ mirror::DexCache::ResolvedCallSitesOffset(),
+ static_cast<int64_t>(reinterpret_cast<uintptr_t>(relocated_call_sites)));
+ if (orig_call_sites != nullptr) {
+ orig_dex_cache->FixupResolvedCallSites(RelocatedCopyOf(orig_call_sites),
+ RelocatedPointerVisitor(this));
+ }
}
}
diff --git a/runtime/Android.bp b/runtime/Android.bp
index 9585ba2..d3a81a9 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -123,6 +123,7 @@
"memory_region.cc",
"method_handles.cc",
"mirror/array.cc",
+ "mirror/call_site.cc",
"mirror/class.cc",
"mirror/class_ext.cc",
"mirror/dex_cache.cc",
@@ -131,6 +132,7 @@
"mirror/field.cc",
"mirror/method.cc",
"mirror/method_handle_impl.cc",
+ "mirror/method_handles_lookup.cc",
"mirror/method_type.cc",
"mirror/object.cc",
"mirror/reference.cc",
@@ -546,6 +548,7 @@
"gc/reference_queue_test.cc",
"gc/space/dlmalloc_space_static_test.cc",
"gc/space/dlmalloc_space_random_test.cc",
+ "gc/space/image_space_test.cc",
"gc/space/large_object_space_test.cc",
"gc/space/rosalloc_space_static_test.cc",
"gc/space/rosalloc_space_random_test.cc",
diff --git a/runtime/art_method.cc b/runtime/art_method.cc
index 6cb8544..59e6ac0 100644
--- a/runtime/art_method.cc
+++ b/runtime/art_method.cc
@@ -67,7 +67,6 @@
}
ArtMethod* ArtMethod::GetSingleImplementation(PointerSize pointer_size) {
- DCHECK(!IsNative());
if (!IsAbstract()) {
// A non-abstract's single implementation is itself.
return this;
@@ -442,12 +441,56 @@
UNREACHABLE();
}
+// We use the method's DexFile and declaring class name to find the OatMethod for an obsolete
+// method. This is extremely slow but we need it if we want to be able to have obsolete native
+// methods since we need this to find the size of its stack frames.
+//
+// NB We could (potentially) do this differently and rely on the way the transformation is applied
+// in order to use the entrypoint to find this information. However, for debugging reasons (most
+// notably making sure that new invokes of obsolete methods fail) we choose to instead get the data
+// directly from the dex file.
+static const OatFile::OatMethod FindOatMethodFromDexFileFor(ArtMethod* method, bool* found)
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ DCHECK(method->IsObsolete() && method->IsNative());
+ const DexFile* dex_file = method->GetDexFile();
+
+ // recreate the class_def_index from the descriptor.
+ std::string descriptor_storage;
+ const DexFile::TypeId* declaring_class_type_id =
+ dex_file->FindTypeId(method->GetDeclaringClass()->GetDescriptor(&descriptor_storage));
+ CHECK(declaring_class_type_id != nullptr);
+ dex::TypeIndex declaring_class_type_index = dex_file->GetIndexForTypeId(*declaring_class_type_id);
+ const DexFile::ClassDef* declaring_class_type_def =
+ dex_file->FindClassDef(declaring_class_type_index);
+ CHECK(declaring_class_type_def != nullptr);
+ uint16_t declaring_class_def_index = dex_file->GetIndexForClassDef(*declaring_class_type_def);
+
+ size_t oat_method_index = GetOatMethodIndexFromMethodIndex(*dex_file,
+ declaring_class_def_index,
+ method->GetDexMethodIndex());
+
+ OatFile::OatClass oat_class = OatFile::FindOatClass(*dex_file,
+ declaring_class_def_index,
+ found);
+ if (!(*found)) {
+ return OatFile::OatMethod::Invalid();
+ }
+ return oat_class.GetOatMethod(oat_method_index);
+}
+
static const OatFile::OatMethod FindOatMethodFor(ArtMethod* method,
PointerSize pointer_size,
bool* found)
REQUIRES_SHARED(Locks::mutator_lock_) {
- // We shouldn't be calling this with obsolete methods.
- DCHECK(!method->IsObsolete());
+ if (UNLIKELY(method->IsObsolete())) {
+ // We shouldn't be calling this with obsolete methods except for native obsolete methods for
+ // which we need to use the oat method to figure out how large the quick frame is.
+ DCHECK(method->IsNative()) << "We should only be finding the OatMethod of obsolete methods in "
+ << "order to allow stack walking. Other obsolete methods should "
+ << "never need to access this information.";
+ DCHECK_EQ(pointer_size, kRuntimePointerSize) << "Obsolete method in compiler!";
+ return FindOatMethodFromDexFileFor(method, found);
+ }
// Although we overwrite the trampoline of non-static methods, we may get here via the resolution
// method for direct methods (or virtual methods made direct).
mirror::Class* declaring_class = method->GetDeclaringClass();
diff --git a/runtime/art_method.h b/runtime/art_method.h
index 3836303..3d51fdd 100644
--- a/runtime/art_method.h
+++ b/runtime/art_method.h
@@ -432,6 +432,7 @@
}
ProfilingInfo* GetProfilingInfo(PointerSize pointer_size) {
+ DCHECK(!IsNative());
return reinterpret_cast<ProfilingInfo*>(GetDataPtrSize(pointer_size));
}
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc
index 6e102be..7bba944 100644
--- a/runtime/base/mutex.cc
+++ b/runtime/base/mutex.cc
@@ -72,6 +72,7 @@
ReaderWriterMutex* Locks::jni_globals_lock_ = nullptr;
Mutex* Locks::jni_weak_globals_lock_ = nullptr;
ReaderWriterMutex* Locks::dex_lock_ = nullptr;
+std::vector<BaseMutex*> Locks::expected_mutexes_on_weak_ref_access_;
struct AllMutexData {
// A guard for all_mutexes_ that's not a mutex (Mutexes must CAS to acquire and busy wait).
@@ -146,7 +147,10 @@
const uint64_t start_nano_time_;
};
-BaseMutex::BaseMutex(const char* name, LockLevel level) : level_(level), name_(name) {
+BaseMutex::BaseMutex(const char* name, LockLevel level)
+ : level_(level),
+ name_(name),
+ should_respond_to_empty_checkpoint_request_(false) {
if (kLogLockContentions) {
ScopedAllMutexesLock mu(this);
std::set<BaseMutex*>** all_mutexes_ptr = &gAllMutexData->all_mutexes;
@@ -377,6 +381,9 @@
// Failed to acquire, hang up.
ScopedContentionRecorder scr(this, SafeGetTid(self), GetExclusiveOwnerTid());
num_contenders_++;
+ if (UNLIKELY(should_respond_to_empty_checkpoint_request_)) {
+ self->CheckEmptyCheckpointFromMutex();
+ }
if (futex(state_.Address(), FUTEX_WAIT, 1, nullptr, nullptr, 0) != 0) {
// EAGAIN and EINTR both indicate a spurious failure, try again from the beginning.
// We don't use TEMP_FAILURE_RETRY so we can intentionally retry to acquire the lock.
@@ -519,6 +526,18 @@
return os;
}
+void Mutex::WakeupToRespondToEmptyCheckpoint() {
+#if ART_USE_FUTEXES
+ // Wake up all the waiters so they will respond to the emtpy checkpoint.
+ DCHECK(should_respond_to_empty_checkpoint_request_);
+ if (UNLIKELY(num_contenders_.LoadRelaxed() > 0)) {
+ futex(state_.Address(), FUTEX_WAKE, -1, nullptr, nullptr, 0);
+ }
+#else
+ LOG(FATAL) << "Non futex case isn't supported.";
+#endif
+}
+
ReaderWriterMutex::ReaderWriterMutex(const char* name, LockLevel level)
: BaseMutex(name, level)
#if ART_USE_FUTEXES
@@ -563,6 +582,9 @@
// Failed to acquire, hang up.
ScopedContentionRecorder scr(this, SafeGetTid(self), GetExclusiveOwnerTid());
++num_pending_writers_;
+ if (UNLIKELY(should_respond_to_empty_checkpoint_request_)) {
+ self->CheckEmptyCheckpointFromMutex();
+ }
if (futex(state_.Address(), FUTEX_WAIT, cur_state, nullptr, nullptr, 0) != 0) {
// EAGAIN and EINTR both indicate a spurious failure, try again from the beginning.
// We don't use TEMP_FAILURE_RETRY so we can intentionally retry to acquire the lock.
@@ -639,6 +661,9 @@
}
ScopedContentionRecorder scr(this, SafeGetTid(self), GetExclusiveOwnerTid());
++num_pending_writers_;
+ if (UNLIKELY(should_respond_to_empty_checkpoint_request_)) {
+ self->CheckEmptyCheckpointFromMutex();
+ }
if (futex(state_.Address(), FUTEX_WAIT, cur_state, &rel_ts, nullptr, 0) != 0) {
if (errno == ETIMEDOUT) {
--num_pending_writers_;
@@ -677,6 +702,9 @@
// Owner holds it exclusively, hang up.
ScopedContentionRecorder scr(this, GetExclusiveOwnerTid(), SafeGetTid(self));
++num_pending_readers_;
+ if (UNLIKELY(should_respond_to_empty_checkpoint_request_)) {
+ self->CheckEmptyCheckpointFromMutex();
+ }
if (futex(state_.Address(), FUTEX_WAIT, cur_state, nullptr, nullptr, 0) != 0) {
if (errno != EAGAIN && errno != EINTR) {
PLOG(FATAL) << "futex wait failed for " << name_;
@@ -749,6 +777,19 @@
return os;
}
+void ReaderWriterMutex::WakeupToRespondToEmptyCheckpoint() {
+#if ART_USE_FUTEXES
+ // Wake up all the waiters so they will respond to the emtpy checkpoint.
+ DCHECK(should_respond_to_empty_checkpoint_request_);
+ if (UNLIKELY(num_pending_readers_.LoadRelaxed() > 0 ||
+ num_pending_writers_.LoadRelaxed() > 0)) {
+ futex(state_.Address(), FUTEX_WAKE, -1, nullptr, nullptr, 0);
+ }
+#else
+ LOG(FATAL) << "Non futex case isn't supported.";
+#endif
+}
+
ConditionVariable::ConditionVariable(const char* name, Mutex& guard)
: name_(name), guard_(guard) {
#if ART_USE_FUTEXES
@@ -1121,6 +1162,12 @@
#undef UPDATE_CURRENT_LOCK_LEVEL
+ // List of mutexes that we may hold when accessing a weak ref.
+ dex_lock_->SetShouldRespondToEmptyCheckpointRequest(true);
+ expected_mutexes_on_weak_ref_access_.push_back(dex_lock_);
+ classlinker_classes_lock_->SetShouldRespondToEmptyCheckpointRequest(true);
+ expected_mutexes_on_weak_ref_access_.push_back(classlinker_classes_lock_);
+
InitConditions();
}
}
diff --git a/runtime/base/mutex.h b/runtime/base/mutex.h
index ffe18c6..9b6938f 100644
--- a/runtime/base/mutex.h
+++ b/runtime/base/mutex.h
@@ -152,6 +152,16 @@
static void DumpAll(std::ostream& os);
+ bool ShouldRespondToEmptyCheckpointRequest() const {
+ return should_respond_to_empty_checkpoint_request_;
+ }
+
+ void SetShouldRespondToEmptyCheckpointRequest(bool value) {
+ should_respond_to_empty_checkpoint_request_ = value;
+ }
+
+ virtual void WakeupToRespondToEmptyCheckpoint() = 0;
+
protected:
friend class ConditionVariable;
@@ -168,6 +178,7 @@
const LockLevel level_; // Support for lock hierarchy.
const char* const name_;
+ bool should_respond_to_empty_checkpoint_request_;
// A log entry that records contention but makes no guarantee that either tid will be held live.
struct ContentionLogEntry {
@@ -266,6 +277,8 @@
// For negative capabilities in clang annotations.
const Mutex& operator!() const { return *this; }
+ void WakeupToRespondToEmptyCheckpoint() OVERRIDE;
+
private:
#if ART_USE_FUTEXES
// 0 is unheld, 1 is held.
@@ -386,6 +399,8 @@
// For negative capabilities in clang annotations.
const ReaderWriterMutex& operator!() const { return *this; }
+ void WakeupToRespondToEmptyCheckpoint() OVERRIDE;
+
private:
#if ART_USE_FUTEXES
// Out-of-inline path for handling contention for a SharedLock.
@@ -713,6 +728,12 @@
// Have an exclusive logging thread.
static Mutex* logging_lock_ ACQUIRED_AFTER(unexpected_signal_lock_);
+
+ // List of mutexes that we expect a thread may hold when accessing weak refs. This is used to
+ // avoid a deadlock in the empty checkpoint while weak ref access is disabled (b/34964016). If we
+ // encounter an unexpected mutex on accessing weak refs,
+ // Thread::CheckEmptyCheckpointFromWeakRefAccess will detect it.
+ static std::vector<BaseMutex*> expected_mutexes_on_weak_ref_access_;
};
class Roles {
diff --git a/runtime/cha.cc b/runtime/cha.cc
index d11b12f..eaba01b 100644
--- a/runtime/cha.cc
+++ b/runtime/cha.cc
@@ -200,7 +200,8 @@
if (verify_method != excluded_method) {
DCHECK(!verify_method->HasSingleImplementation())
<< "class: " << verify_class->PrettyClass()
- << " verify_method: " << verify_method->PrettyMethod(true);
+ << " verify_method: " << verify_method->PrettyMethod(true)
+ << " excluded_method: " << excluded_method->PrettyMethod(true);
if (verify_method->IsAbstract()) {
DCHECK(verify_method->GetSingleImplementation(image_pointer_size) == nullptr);
}
@@ -257,9 +258,6 @@
return;
}
- // Native methods don't have single-implementation flag set.
- DCHECK(!method_in_super->IsNative());
-
uint16_t method_index = method_in_super->GetMethodIndex();
if (method_in_super->IsAbstract()) {
if (kIsDebugBuild) {
@@ -374,12 +372,12 @@
// used for static methods or methods of final classes.
return;
}
- if (method->IsNative()) {
- // Native method's invocation overhead is already high and it
- // cannot be inlined. It's not worthwhile to devirtualize the
- // call which can add a deoptimization point.
- DCHECK(!method->HasSingleImplementation());
- } else if (method->IsAbstract()) {
+ if (method->IsAbstract()) {
+ // single-implementation of abstract method shares the same field
+ // that's used for JNI function of native method. It's fine since a method
+ // cannot be both abstract and native.
+ DCHECK(!method->IsNative()) << "Abstract method cannot be native";
+
if (method->GetDeclaringClass()->IsInstantiable()) {
// Rare case, but we do accept it (such as 800-smali/smali/b_26143249.smali).
// Do not attempt to devirtualize it.
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 7db8368..110241b 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -70,6 +70,7 @@
#include "jni_internal.h"
#include "leb128.h"
#include "linear_alloc.h"
+#include "mirror/call_site.h"
#include "mirror/class.h"
#include "mirror/class-inl.h"
#include "mirror/class_ext.h"
@@ -82,6 +83,7 @@
#include "mirror/method.h"
#include "mirror/method_type.h"
#include "mirror/method_handle_impl.h"
+#include "mirror/method_handles_lookup.h"
#include "mirror/object-inl.h"
#include "mirror/object_array-inl.h"
#include "mirror/proxy.h"
@@ -695,6 +697,18 @@
SetClassRoot(kJavaLangInvokeMethodHandleImpl, class_root);
mirror::MethodHandleImpl::SetClass(class_root);
+ // Create java.lang.invoke.MethodHandles.Lookup.class root
+ class_root = FindSystemClass(self, "Ljava/lang/invoke/MethodHandles$Lookup;");
+ CHECK(class_root != nullptr);
+ SetClassRoot(kJavaLangInvokeMethodHandlesLookup, class_root);
+ mirror::MethodHandlesLookup::SetClass(class_root);
+
+ // Create java.lang.invoke.CallSite.class root
+ class_root = FindSystemClass(self, "Ljava/lang/invoke/CallSite;");
+ CHECK(class_root != nullptr);
+ SetClassRoot(kJavaLangInvokeCallSite, class_root);
+ mirror::CallSite::SetClass(class_root);
+
class_root = FindSystemClass(self, "Ldalvik/system/EmulatedStackFrame;");
CHECK(class_root != nullptr);
SetClassRoot(kDalvikSystemEmulatedStackFrame, class_root);
@@ -981,6 +995,8 @@
mirror::Method::SetArrayClass(GetClassRoot(kJavaLangReflectMethodArrayClass));
mirror::MethodType::SetClass(GetClassRoot(kJavaLangInvokeMethodType));
mirror::MethodHandleImpl::SetClass(GetClassRoot(kJavaLangInvokeMethodHandleImpl));
+ mirror::MethodHandlesLookup::SetClass(GetClassRoot(kJavaLangInvokeMethodHandlesLookup));
+ mirror::CallSite::SetClass(GetClassRoot(kJavaLangInvokeCallSite));
mirror::Reference::SetClass(GetClassRoot(kJavaLangRefReference));
mirror::BooleanArray::SetArrayClass(GetClassRoot(kBooleanArrayClass));
mirror::ByteArray::SetArrayClass(GetClassRoot(kByteArrayClass));
@@ -1231,12 +1247,13 @@
if (dex_file->NumProtoIds() < num_method_types) {
num_method_types = dex_file->NumProtoIds();
}
-
+ const size_t num_call_sites = dex_file->NumCallSiteIds();
CHECK_EQ(num_strings, dex_cache->NumStrings());
CHECK_EQ(num_types, dex_cache->NumResolvedTypes());
CHECK_EQ(num_methods, dex_cache->NumResolvedMethods());
CHECK_EQ(num_fields, dex_cache->NumResolvedFields());
CHECK_EQ(num_method_types, dex_cache->NumResolvedMethodTypes());
+ CHECK_EQ(num_call_sites, dex_cache->NumResolvedCallSites());
DexCacheArraysLayout layout(image_pointer_size_, dex_file);
uint8_t* const raw_arrays = oat_dex_file->GetDexCacheArrays();
if (num_strings != 0u) {
@@ -1316,6 +1333,22 @@
mirror::MethodTypeDexCachePair::Initialize(method_types);
dex_cache->SetResolvedMethodTypes(method_types);
}
+ if (num_call_sites != 0u) {
+ GcRoot<mirror::CallSite>* const image_resolved_call_sites =
+ dex_cache->GetResolvedCallSites();
+ GcRoot<mirror::CallSite>* const call_sites =
+ reinterpret_cast<GcRoot<mirror::CallSite>*>(raw_arrays + layout.CallSitesOffset());
+ for (size_t j = 0; kIsDebugBuild && j < num_call_sites; ++j) {
+ DCHECK(call_sites[j].IsNull());
+ }
+ CopyNonNull(image_resolved_call_sites,
+ num_call_sites,
+ call_sites,
+ [](const GcRoot<mirror::CallSite>& elem) {
+ return elem.IsNull();
+ });
+ dex_cache->SetResolvedCallSites(call_sites);
+ }
}
{
WriterMutexLock mu2(self, *Locks::dex_lock_);
@@ -2115,6 +2148,8 @@
mirror::ShortArray::ResetArrayClass();
mirror::MethodType::ResetClass();
mirror::MethodHandleImpl::ResetClass();
+ mirror::MethodHandlesLookup::ResetClass();
+ mirror::CallSite::ResetClass();
mirror::EmulatedStackFrame::ResetClass();
Thread* const self = Thread::Current();
for (const ClassLoaderData& data : class_loaders_) {
@@ -3112,6 +3147,7 @@
last_field_idx = field_idx;
}
}
+
// Load instance fields.
LengthPrefixedArray<ArtField>* ifields = AllocArtFieldArray(self,
allocator,
@@ -3128,6 +3164,7 @@
last_field_idx = field_idx;
}
}
+
if (UNLIKELY(num_sfields != it.NumStaticFields()) ||
UNLIKELY(num_ifields != it.NumInstanceFields())) {
LOG(WARNING) << "Duplicate fields in class " << klass->PrettyDescriptor()
@@ -8189,6 +8226,148 @@
return type.Get();
}
+mirror::MethodHandle* ClassLinker::ResolveMethodHandle(uint32_t method_handle_idx,
+ ArtMethod* referrer)
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ Thread* const self = Thread::Current();
+ const DexFile* const dex_file = referrer->GetDexFile();
+ const DexFile::MethodHandleItem& mh = dex_file->GetMethodHandle(method_handle_idx);
+
+ union {
+ ArtField* field;
+ ArtMethod* method;
+ uintptr_t field_or_method;
+ } target;
+ uint32_t num_params;
+ mirror::MethodHandle::Kind kind;
+ DexFile::MethodHandleType handle_type =
+ static_cast<DexFile::MethodHandleType>(mh.method_handle_type_);
+ switch (handle_type) {
+ case DexFile::MethodHandleType::kStaticPut: {
+ kind = mirror::MethodHandle::Kind::kStaticPut;
+ target.field = ResolveField(mh.field_or_method_idx_, referrer, true /* is_static */);
+ num_params = 1;
+ break;
+ }
+ case DexFile::MethodHandleType::kStaticGet: {
+ kind = mirror::MethodHandle::Kind::kStaticGet;
+ target.field = ResolveField(mh.field_or_method_idx_, referrer, true /* is_static */);
+ num_params = 0;
+ break;
+ }
+ case DexFile::MethodHandleType::kInstancePut: {
+ kind = mirror::MethodHandle::Kind::kInstancePut;
+ target.field = ResolveField(mh.field_or_method_idx_, referrer, false /* is_static */);
+ num_params = 2;
+ break;
+ }
+ case DexFile::MethodHandleType::kInstanceGet: {
+ kind = mirror::MethodHandle::Kind::kInstanceGet;
+ target.field = ResolveField(mh.field_or_method_idx_, referrer, false /* is_static */);
+ num_params = 1;
+ break;
+ }
+ case DexFile::MethodHandleType::kInvokeStatic: {
+ kind = mirror::MethodHandle::Kind::kInvokeStatic;
+ target.method = ResolveMethod<kNoICCECheckForCache>(self,
+ mh.field_or_method_idx_,
+ referrer,
+ InvokeType::kStatic);
+ uint32_t shorty_length;
+ target.method->GetShorty(&shorty_length);
+ num_params = shorty_length - 1; // Remove 1 for return value.
+ break;
+ }
+ case DexFile::MethodHandleType::kInvokeInstance: {
+ kind = mirror::MethodHandle::Kind::kInvokeVirtual;
+ target.method = ResolveMethod<kNoICCECheckForCache>(self,
+ mh.field_or_method_idx_,
+ referrer,
+ InvokeType::kVirtual);
+ uint32_t shorty_length;
+ target.method->GetShorty(&shorty_length);
+ num_params = shorty_length - 1; // Remove 1 for return value.
+ break;
+ }
+ case DexFile::MethodHandleType::kInvokeConstructor: {
+ UNIMPLEMENTED(FATAL) << "Invoke constructor is implemented as a transform.";
+ num_params = 0;
+ }
+ }
+
+ StackHandleScope<5> hs(self);
+ ObjPtr<mirror::Class> class_type = mirror::Class::GetJavaLangClass();
+ ObjPtr<mirror::Class> array_of_class = FindArrayClass(self, &class_type);
+ Handle<mirror::ObjectArray<mirror::Class>> method_params(hs.NewHandle(
+ mirror::ObjectArray<mirror::Class>::Alloc(self, array_of_class, num_params)));
+ if (method_params.Get() == nullptr) {
+ DCHECK(self->IsExceptionPending());
+ return nullptr;
+ }
+
+ Handle<mirror::Class> return_type;
+ switch (handle_type) {
+ case DexFile::MethodHandleType::kStaticPut: {
+ method_params->Set(0, target.field->GetType<true>());
+ return_type = hs.NewHandle(FindPrimitiveClass('V'));
+ break;
+ }
+ case DexFile::MethodHandleType::kStaticGet: {
+ return_type = hs.NewHandle(target.field->GetType<true>());
+ break;
+ }
+ case DexFile::MethodHandleType::kInstancePut: {
+ method_params->Set(0, target.field->GetDeclaringClass());
+ method_params->Set(1, target.field->GetType<true>());
+ return_type = hs.NewHandle(FindPrimitiveClass('V'));
+ break;
+ }
+ case DexFile::MethodHandleType::kInstanceGet: {
+ method_params->Set(0, target.field->GetDeclaringClass());
+ return_type = hs.NewHandle(target.field->GetType<true>());
+ break;
+ }
+ case DexFile::MethodHandleType::kInvokeStatic:
+ case DexFile::MethodHandleType::kInvokeInstance: {
+ // TODO(oth): This will not work for varargs methods as this
+ // requires instantiating a Transformer. This resolution step
+ // would be best done in managed code rather than in the run
+ // time (b/35235705)
+ Handle<mirror::DexCache> dex_cache(hs.NewHandle(referrer->GetDexCache()));
+ Handle<mirror::ClassLoader> class_loader(hs.NewHandle(referrer->GetClassLoader()));
+ DexFileParameterIterator it(*dex_file, target.method->GetPrototype());
+ for (int32_t i = 0; it.HasNext(); i++, it.Next()) {
+ const dex::TypeIndex type_idx = it.GetTypeIdx();
+ mirror::Class* klass = ResolveType(*dex_file, type_idx, dex_cache, class_loader);
+ if (nullptr == klass) {
+ DCHECK(self->IsExceptionPending());
+ return nullptr;
+ }
+ method_params->Set(i, klass);
+ }
+ return_type = hs.NewHandle(target.method->GetReturnType(true));
+ break;
+ }
+ case DexFile::MethodHandleType::kInvokeConstructor: {
+ // TODO(oth): b/35235705
+ UNIMPLEMENTED(FATAL) << "Invoke constructor is implemented as a transform.";
+ }
+ }
+
+ if (return_type.IsNull()) {
+ DCHECK(self->IsExceptionPending());
+ return nullptr;
+ }
+
+ Handle<mirror::MethodType>
+ mt(hs.NewHandle(mirror::MethodType::Create(self, return_type, method_params)));
+ if (mt.IsNull()) {
+ DCHECK(self->IsExceptionPending());
+ return nullptr;
+ }
+ return mirror::MethodHandleImpl::Create(self, target.field_or_method, kind, mt);
+}
+
bool ClassLinker::IsQuickResolutionStub(const void* entry_point) const {
return (entry_point == GetQuickResolutionStub()) ||
(quick_resolution_trampoline_ == entry_point);
@@ -8304,7 +8483,9 @@
"[Ljava/lang/reflect/Constructor;",
"[Ljava/lang/reflect/Field;",
"[Ljava/lang/reflect/Method;",
+ "Ljava/lang/invoke/CallSite;",
"Ljava/lang/invoke/MethodHandleImpl;",
+ "Ljava/lang/invoke/MethodHandles$Lookup;",
"Ljava/lang/invoke/MethodType;",
"Ljava/lang/ClassLoader;",
"Ljava/lang/Throwable;",
diff --git a/runtime/class_linker.h b/runtime/class_linker.h
index 62d3c29..e27a53d 100644
--- a/runtime/class_linker.h
+++ b/runtime/class_linker.h
@@ -55,6 +55,8 @@
class DexCacheMethodHandlesTest_Open_Test;
class DexCacheTest_Open_Test;
class IfTable;
+ class MethodHandle;
+ class MethodHandlesLookup;
class MethodType;
template<class T> class ObjectArray;
class StackTraceElement;
@@ -106,7 +108,9 @@
kJavaLangReflectConstructorArrayClass,
kJavaLangReflectFieldArrayClass,
kJavaLangReflectMethodArrayClass,
+ kJavaLangInvokeCallSite,
kJavaLangInvokeMethodHandleImpl,
+ kJavaLangInvokeMethodHandlesLookup,
kJavaLangInvokeMethodType,
kJavaLangClassLoader,
kJavaLangThrowable,
@@ -366,6 +370,12 @@
REQUIRES_SHARED(Locks::mutator_lock_)
REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
+ // Resolve a method handle with a given ID from the DexFile. The
+ // result is not cached in the DexCache as the instance will only be
+ // used once in most circumstances.
+ mirror::MethodHandle* ResolveMethodHandle(uint32_t method_handle_idx, ArtMethod* referrer)
+ REQUIRES_SHARED(Locks::mutator_lock_);
+
// Returns true on success, false if there's an exception pending.
// can_run_clinit=false allows the compiler to attempt to init a class,
// given the restriction that no <clinit> execution is possible.
diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc
index 03105cb..ee8aed7 100644
--- a/runtime/class_linker_test.cc
+++ b/runtime/class_linker_test.cc
@@ -32,6 +32,7 @@
#include "entrypoints/entrypoint_utils-inl.h"
#include "gc/heap.h"
#include "mirror/accessible_object.h"
+#include "mirror/call_site.h"
#include "mirror/class-inl.h"
#include "mirror/class_ext.h"
#include "mirror/dex_cache.h"
@@ -40,6 +41,7 @@
#include "mirror/field.h"
#include "mirror/method_type.h"
#include "mirror/method_handle_impl.h"
+#include "mirror/method_handles_lookup.h"
#include "mirror/object-inl.h"
#include "mirror/object_array-inl.h"
#include "mirror/proxy.h"
@@ -669,11 +671,13 @@
addOffset(OFFSETOF_MEMBER(mirror::DexCache, dex_), "dex");
addOffset(OFFSETOF_MEMBER(mirror::DexCache, dex_file_), "dexFile");
addOffset(OFFSETOF_MEMBER(mirror::DexCache, location_), "location");
+ addOffset(OFFSETOF_MEMBER(mirror::DexCache, num_resolved_call_sites_), "numResolvedCallSites");
addOffset(OFFSETOF_MEMBER(mirror::DexCache, num_resolved_fields_), "numResolvedFields");
addOffset(OFFSETOF_MEMBER(mirror::DexCache, num_resolved_method_types_), "numResolvedMethodTypes");
addOffset(OFFSETOF_MEMBER(mirror::DexCache, num_resolved_methods_), "numResolvedMethods");
addOffset(OFFSETOF_MEMBER(mirror::DexCache, num_resolved_types_), "numResolvedTypes");
addOffset(OFFSETOF_MEMBER(mirror::DexCache, num_strings_), "numStrings");
+ addOffset(OFFSETOF_MEMBER(mirror::DexCache, resolved_call_sites_), "resolvedCallSites");
addOffset(OFFSETOF_MEMBER(mirror::DexCache, resolved_fields_), "resolvedFields");
addOffset(OFFSETOF_MEMBER(mirror::DexCache, resolved_method_types_), "resolvedMethodTypes");
addOffset(OFFSETOF_MEMBER(mirror::DexCache, resolved_methods_), "resolvedMethods");
@@ -762,6 +766,14 @@
}
};
+struct MethodHandlesLookupOffsets : public CheckOffsets<mirror::MethodHandlesLookup> {
+ MethodHandlesLookupOffsets() : CheckOffsets<mirror::MethodHandlesLookup>(
+ false, "Ljava/lang/invoke/MethodHandles$Lookup;") {
+ addOffset(OFFSETOF_MEMBER(mirror::MethodHandlesLookup, allowed_modes_), "allowedModes");
+ addOffset(OFFSETOF_MEMBER(mirror::MethodHandlesLookup, lookup_class_), "lookupClass");
+ }
+};
+
struct EmulatedStackFrameOffsets : public CheckOffsets<mirror::EmulatedStackFrame> {
EmulatedStackFrameOffsets() : CheckOffsets<mirror::EmulatedStackFrame>(
false, "Ldalvik/system/EmulatedStackFrame;") {
@@ -772,6 +784,13 @@
}
};
+struct CallSiteOffsets : public CheckOffsets<mirror::CallSite> {
+ CallSiteOffsets() : CheckOffsets<mirror::CallSite>(
+ false, "Ljava/lang/invoke/CallSite;") {
+ addOffset(OFFSETOF_MEMBER(mirror::CallSite, target_), "target");
+ }
+};
+
// C++ fields must exactly match the fields in the Java classes. If this fails,
// reorder the fields in the C++ class. Managed class fields are ordered by
// ClassLinker::LinkFields.
@@ -794,7 +813,9 @@
EXPECT_TRUE(MethodTypeOffsets().Check());
EXPECT_TRUE(MethodHandleOffsets().Check());
EXPECT_TRUE(MethodHandleImplOffsets().Check());
+ EXPECT_TRUE(MethodHandlesLookupOffsets().Check());
EXPECT_TRUE(EmulatedStackFrameOffsets().Check());
+ EXPECT_TRUE(CallSiteOffsets().Check());
}
TEST_F(ClassLinkerTest, FindClassNonexistent) {
diff --git a/runtime/common_throws.cc b/runtime/common_throws.cc
index a44f79e..4f4bed0 100644
--- a/runtime/common_throws.cc
+++ b/runtime/common_throws.cc
@@ -126,6 +126,22 @@
mirror::Class::PrettyDescriptor(array_class).c_str()).c_str());
}
+// BootstrapMethodError
+
+void ThrowBootstrapMethodError(const char* fmt, ...) {
+ va_list args;
+ va_start(args, fmt);
+ ThrowException("Ljava/lang/BootstrapMethodError;", nullptr, fmt, &args);
+ va_end(args);
+}
+
+void ThrowWrappedBootstrapMethodError(const char* fmt, ...) {
+ va_list args;
+ va_start(args, fmt);
+ ThrowWrappedException("Ljava/lang/BootstrapMethodError;", nullptr, fmt, &args);
+ va_end(args);
+}
+
// ClassCastException
void ThrowClassCastException(ObjPtr<mirror::Class> dest_type, ObjPtr<mirror::Class> src_type) {
diff --git a/runtime/common_throws.h b/runtime/common_throws.h
index 76ea2ae..55a8938 100644
--- a/runtime/common_throws.h
+++ b/runtime/common_throws.h
@@ -56,6 +56,14 @@
ObjPtr<mirror::Class> array_class)
REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
+// BootstrapMethodError
+
+void ThrowBootstrapMethodError(const char* fmt, ...)
+ REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
+
+void ThrowWrappedBootstrapMethodError(const char* fmt, ...)
+ REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
+
// ClassCircularityError
void ThrowClassCircularityError(ObjPtr<mirror::Class> c)
@@ -236,7 +244,7 @@
__attribute__((__format__(__printf__, 2, 3)))
REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
-// WrontMethodTypeException
+// WrongMethodTypeException
void ThrowWrongMethodTypeException(mirror::MethodType* callee_type,
mirror::MethodType* callsite_type)
REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
diff --git a/runtime/dex2oat_environment_test.h b/runtime/dex2oat_environment_test.h
index 8b0c51c..e58c6f5 100644
--- a/runtime/dex2oat_environment_test.h
+++ b/runtime/dex2oat_environment_test.h
@@ -53,7 +53,7 @@
ASSERT_EQ(0, mkdir(odex_dir_.c_str(), 0700));
// Verify the environment is as we expect
- uint32_t checksum;
+ std::vector<uint32_t> checksums;
std::string error_msg;
ASSERT_TRUE(OS::FileExists(GetSystemImageFile().c_str()))
<< "Expected pre-compiled boot image to be at: " << GetSystemImageFile();
@@ -61,7 +61,7 @@
<< "Expected dex file to be at: " << GetDexSrc1();
ASSERT_TRUE(OS::FileExists(GetStrippedDexSrc1().c_str()))
<< "Expected stripped dex file to be at: " << GetStrippedDexSrc1();
- ASSERT_FALSE(DexFile::GetChecksum(GetStrippedDexSrc1().c_str(), &checksum, &error_msg))
+ ASSERT_FALSE(DexFile::GetMultiDexChecksums(GetStrippedDexSrc1().c_str(), &checksums, &error_msg))
<< "Expected stripped dex file to be stripped: " << GetStrippedDexSrc1();
ASSERT_TRUE(OS::FileExists(GetDexSrc2().c_str()))
<< "Expected dex file to be at: " << GetDexSrc2();
diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc
index f59420d..9ad4063 100644
--- a/runtime/dex_file.cc
+++ b/runtime/dex_file.cc
@@ -72,23 +72,13 @@
uint8_t type_;
};
-bool DexFile::GetChecksum(const char* filename, uint32_t* checksum, std::string* error_msg) {
- CHECK(checksum != nullptr);
+bool DexFile::GetMultiDexChecksums(const char* filename,
+ std::vector<uint32_t>* checksums,
+ std::string* error_msg) {
+ CHECK(checksums != nullptr);
uint32_t magic;
- // Strip ":...", which is the location
- const char* zip_entry_name = kClassesDex;
- const char* file_part = filename;
- std::string file_part_storage;
-
- if (DexFile::IsMultiDexLocation(filename)) {
- file_part_storage = GetBaseLocation(filename);
- file_part = file_part_storage.c_str();
- zip_entry_name = filename + file_part_storage.size() + 1;
- DCHECK_EQ(zip_entry_name[-1], kMultiDexSeparator);
- }
-
- File fd = OpenAndReadMagic(file_part, &magic, error_msg);
+ File fd = OpenAndReadMagic(filename, &magic, error_msg);
if (fd.Fd() == -1) {
DCHECK(!error_msg->empty());
return false;
@@ -97,17 +87,25 @@
std::unique_ptr<ZipArchive> zip_archive(
ZipArchive::OpenFromFd(fd.Release(), filename, error_msg));
if (zip_archive.get() == nullptr) {
- *error_msg = StringPrintf("Failed to open zip archive '%s' (error msg: %s)", file_part,
+ *error_msg = StringPrintf("Failed to open zip archive '%s' (error msg: %s)", filename,
error_msg->c_str());
return false;
}
- std::unique_ptr<ZipEntry> zip_entry(zip_archive->Find(zip_entry_name, error_msg));
+
+ uint32_t i = 0;
+ std::string zip_entry_name = GetMultiDexClassesDexName(i++);
+ std::unique_ptr<ZipEntry> zip_entry(zip_archive->Find(zip_entry_name.c_str(), error_msg));
if (zip_entry.get() == nullptr) {
- *error_msg = StringPrintf("Zip archive '%s' doesn't contain %s (error msg: %s)", file_part,
- zip_entry_name, error_msg->c_str());
+ *error_msg = StringPrintf("Zip archive '%s' doesn't contain %s (error msg: %s)", filename,
+ zip_entry_name.c_str(), error_msg->c_str());
return false;
}
- *checksum = zip_entry->GetCrc32();
+
+ do {
+ checksums->push_back(zip_entry->GetCrc32());
+ zip_entry_name = DexFile::GetMultiDexClassesDexName(i++);
+ zip_entry.reset(zip_archive->Find(zip_entry_name.c_str(), error_msg));
+ } while (zip_entry.get() != nullptr);
return true;
}
if (IsDexMagic(magic)) {
@@ -116,7 +114,7 @@
if (dex_file.get() == nullptr) {
return false;
}
- *checksum = dex_file->GetHeader().checksum_;
+ checksums->push_back(dex_file->GetHeader().checksum_);
return true;
}
*error_msg = StringPrintf("Expected valid zip or dex file: '%s'", filename);
@@ -497,9 +495,14 @@
method_ids_(reinterpret_cast<const MethodId*>(base + header_->method_ids_off_)),
proto_ids_(reinterpret_cast<const ProtoId*>(base + header_->proto_ids_off_)),
class_defs_(reinterpret_cast<const ClassDef*>(base + header_->class_defs_off_)),
+ method_handles_(nullptr),
+ num_method_handles_(0),
+ call_site_ids_(nullptr),
+ num_call_site_ids_(0),
oat_dex_file_(oat_dex_file) {
CHECK(begin_ != nullptr) << GetLocation();
CHECK_GT(size_, 0U) << GetLocation();
+ InitializeSectionsFromMapList();
}
DexFile::~DexFile() {
@@ -540,6 +543,29 @@
return true;
}
+void DexFile::InitializeSectionsFromMapList() {
+ const MapList* map_list = reinterpret_cast<const MapList*>(begin_ + header_->map_off_);
+ const size_t count = map_list->size_;
+
+ size_t map_limit = header_->map_off_ + count * sizeof(MapItem);
+ if (header_->map_off_ >= map_limit || map_limit > size_) {
+ // Overflow or out out of bounds. The dex file verifier runs after
+ // this method and will reject the file as it is malformed.
+ return;
+ }
+
+ for (size_t i = 0; i < count; ++i) {
+ const MapItem& map_item = map_list->list_[i];
+ if (map_item.type_ == kDexTypeMethodHandleItem) {
+ method_handles_ = reinterpret_cast<const MethodHandleItem*>(begin_ + map_item.offset_);
+ num_method_handles_ = map_item.size_;
+ } else if (map_item.type_ == kDexTypeCallSiteIdItem) {
+ call_site_ids_ = reinterpret_cast<const CallSiteIdItem*>(begin_ + map_item.offset_);
+ num_call_site_ids_ = map_item.size_;
+ }
+ }
+}
+
bool DexFile::IsMagicValid(const uint8_t* magic) {
return (memcmp(magic, kDexMagic, sizeof(kDexMagic)) == 0);
}
@@ -1339,24 +1365,20 @@
}
}
-EncodedStaticFieldValueIterator::EncodedStaticFieldValueIterator(const DexFile& dex_file,
- const DexFile::ClassDef& class_def)
+EncodedArrayValueIterator::EncodedArrayValueIterator(const DexFile& dex_file,
+ const uint8_t* array_data)
: dex_file_(dex_file),
array_size_(),
pos_(-1),
+ ptr_(array_data),
type_(kByte) {
- ptr_ = dex_file_.GetEncodedStaticFieldValuesArray(class_def);
- if (ptr_ == nullptr) {
- array_size_ = 0;
- } else {
- array_size_ = DecodeUnsignedLeb128(&ptr_);
- }
+ array_size_ = (ptr_ != nullptr) ? DecodeUnsignedLeb128(&ptr_) : 0;
if (array_size_ > 0) {
Next();
}
}
-void EncodedStaticFieldValueIterator::Next() {
+void EncodedArrayValueIterator::Next() {
pos_++;
if (pos_ >= array_size_) {
return;
@@ -1396,6 +1418,8 @@
break;
case kString:
case kType:
+ case kMethodType:
+ case kMethodHandle:
jval_.i = DexFile::ReadUnsignedInt(ptr_, value_arg, false);
break;
case kField:
diff --git a/runtime/dex_file.h b/runtime/dex_file.h
index cb7f174..58b8e79 100644
--- a/runtime/dex_file.h
+++ b/runtime/dex_file.h
@@ -103,7 +103,7 @@
};
// Map item type codes.
- enum {
+ enum MapItemType : uint16_t { // private
kDexTypeHeaderItem = 0x0000,
kDexTypeStringIdItem = 0x0001,
kDexTypeTypeIdItem = 0x0002,
@@ -111,6 +111,8 @@
kDexTypeFieldIdItem = 0x0004,
kDexTypeMethodIdItem = 0x0005,
kDexTypeClassDefItem = 0x0006,
+ kDexTypeCallSiteIdItem = 0x0007,
+ kDexTypeMethodHandleItem = 0x0008,
kDexTypeMapList = 0x1000,
kDexTypeTypeList = 0x1001,
kDexTypeAnnotationSetRefList = 0x1002,
@@ -260,6 +262,37 @@
DISALLOW_COPY_AND_ASSIGN(TypeList);
};
+ // MethodHandle Types
+ enum class MethodHandleType : uint16_t { // private
+ kStaticPut = 0x0000, // a setter for a given static field.
+ kStaticGet = 0x0001, // a getter for a given static field.
+ kInstancePut = 0x0002, // a setter for a given instance field.
+ kInstanceGet = 0x0003, // a getter for a given instance field.
+ kInvokeStatic = 0x0004, // an invoker for a given static method.
+ kInvokeInstance = 0x0005, // invoke_instance : an invoker for a given instance method. This
+ // can be any non-static method on any class (or interface) except
+ // for “<init>”.
+ kInvokeConstructor = 0x0006, // an invoker for a given constructor.
+ kLast = kInvokeConstructor
+ };
+
+ // raw method_handle_item
+ struct MethodHandleItem {
+ uint16_t method_handle_type_;
+ uint16_t reserved1_; // Reserved for future use.
+ uint16_t field_or_method_idx_; // Field index for accessors, method index otherwise.
+ uint16_t reserved2_; // Reserved for future use.
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MethodHandleItem);
+ };
+
+ // raw call_site_id_item
+ struct CallSiteIdItem {
+ uint32_t data_off_; // Offset into data section pointing to encoded array items.
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CallSiteIdItem);
+ };
+
// Raw code_item.
struct CodeItem {
uint16_t registers_size_; // the number of registers used by this code
@@ -302,6 +335,8 @@
kDexAnnotationLong = 0x06,
kDexAnnotationFloat = 0x10,
kDexAnnotationDouble = 0x11,
+ kDexAnnotationMethodType = 0x15,
+ kDexAnnotationMethodHandle = 0x16,
kDexAnnotationString = 0x17,
kDexAnnotationType = 0x18,
kDexAnnotationField = 0x19,
@@ -389,11 +424,18 @@
struct AnnotationValue;
- // Returns the checksum of a file for comparison with GetLocationChecksum().
- // For .dex files, this is the header checksum.
- // For zip files, this is the classes.dex zip entry CRC32 checksum.
- // Return true if the checksum could be found, false otherwise.
- static bool GetChecksum(const char* filename, uint32_t* checksum, std::string* error_msg);
+ // Returns the checksums of a file for comparison with GetLocationChecksum().
+ // For .dex files, this is the single header checksum.
+ // For zip files, this is the zip entry CRC32 checksum for classes.dex and
+ // each additional multidex entry classes2.dex, classes3.dex, etc.
+ // Return true if the checksums could be found, false otherwise.
+ static bool GetMultiDexChecksums(const char* filename,
+ std::vector<uint32_t>* checksums,
+ std::string* error_msg);
+
+ // Check whether a location denotes a multidex dex file. This is a very simple check: returns
+ // whether the string contains the separator character.
+ static bool IsMultiDexLocation(const char* location);
// Opens .dex file, backed by existing memory
static std::unique_ptr<const DexFile> Open(const uint8_t* base,
@@ -683,6 +725,24 @@
}
}
+ uint32_t NumMethodHandles() const {
+ return num_method_handles_;
+ }
+
+ const MethodHandleItem& GetMethodHandle(uint32_t idx) const {
+ CHECK_LT(idx, NumMethodHandles());
+ return method_handles_[idx];
+ }
+
+ uint32_t NumCallSiteIds() const {
+ return num_call_site_ids_;
+ }
+
+ const CallSiteIdItem& GetCallSiteId(uint32_t idx) const {
+ CHECK_LT(idx, NumCallSiteIds());
+ return call_site_ids_[idx];
+ }
+
// Returns a pointer to the raw memory mapped class_data_item
const uint8_t* GetClassData(const ClassDef& class_def) const {
if (class_def.class_data_off_ == 0) {
@@ -761,6 +821,10 @@
}
}
+ const uint8_t* GetCallSiteEncodedValuesArray(const CallSiteIdItem& call_site_id) const {
+ return begin_ + call_site_id.data_off_;
+ }
+
static const TryItem* GetTryItems(const CodeItem& code_item, uint32_t offset);
// Get the base of the encoded data for the given DexCode.
@@ -1101,9 +1165,8 @@
// Returns true if the header magic and version numbers are of the expected values.
bool CheckMagicAndVersion(std::string* error_msg) const;
- // Check whether a location denotes a multidex dex file. This is a very simple check: returns
- // whether the string contains the separator character.
- static bool IsMultiDexLocation(const char* location);
+ // Initialize section info for sections only found in map. Returns true on success.
+ void InitializeSectionsFromMapList();
// The base address of the memory mapping.
const uint8_t* const begin_;
@@ -1143,6 +1206,18 @@
// Points to the base of the class definition list.
const ClassDef* const class_defs_;
+ // Points to the base of the method handles list.
+ const MethodHandleItem* method_handles_;
+
+ // Number of elements in the method handles list.
+ size_t num_method_handles_;
+
+ // Points to the base of the call sites id list.
+ const CallSiteIdItem* call_site_ids_;
+
+ // Number of elements in the call sites list.
+ size_t num_call_site_ids_;
+
// If this dex file was loaded from an oat file, oat_dex_file_ contains a
// pointer to the OatDexFile it was loaded from. Otherwise oat_dex_file_ is
// null.
@@ -1409,32 +1484,33 @@
DISALLOW_IMPLICIT_CONSTRUCTORS(ClassDataItemIterator);
};
-class EncodedStaticFieldValueIterator {
+class EncodedArrayValueIterator {
public:
- EncodedStaticFieldValueIterator(const DexFile& dex_file,
- const DexFile::ClassDef& class_def);
+ EncodedArrayValueIterator(const DexFile& dex_file, const uint8_t* array_data);
bool HasNext() const { return pos_ < array_size_; }
void Next();
enum ValueType {
- kByte = 0x00,
- kShort = 0x02,
- kChar = 0x03,
- kInt = 0x04,
- kLong = 0x06,
- kFloat = 0x10,
- kDouble = 0x11,
- kString = 0x17,
- kType = 0x18,
- kField = 0x19,
- kMethod = 0x1a,
- kEnum = 0x1b,
- kArray = 0x1c,
- kAnnotation = 0x1d,
- kNull = 0x1e,
- kBoolean = 0x1f
+ kByte = 0x00,
+ kShort = 0x02,
+ kChar = 0x03,
+ kInt = 0x04,
+ kLong = 0x06,
+ kFloat = 0x10,
+ kDouble = 0x11,
+ kMethodType = 0x15,
+ kMethodHandle = 0x16,
+ kString = 0x17,
+ kType = 0x18,
+ kField = 0x19,
+ kMethod = 0x1a,
+ kEnum = 0x1b,
+ kArray = 0x1c,
+ kAnnotation = 0x1d,
+ kNull = 0x1e,
+ kBoolean = 0x1f,
};
ValueType GetValueType() const { return type_; }
@@ -1452,10 +1528,38 @@
jvalue jval_; // Value of current encoded value.
private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(EncodedArrayValueIterator);
+};
+std::ostream& operator<<(std::ostream& os, const EncodedArrayValueIterator::ValueType& code);
+
+class EncodedStaticFieldValueIterator : public EncodedArrayValueIterator {
+ public:
+ EncodedStaticFieldValueIterator(const DexFile& dex_file,
+ const DexFile::ClassDef& class_def)
+ : EncodedArrayValueIterator(dex_file,
+ dex_file.GetEncodedStaticFieldValuesArray(class_def))
+ {}
+
+ private:
DISALLOW_IMPLICIT_CONSTRUCTORS(EncodedStaticFieldValueIterator);
};
std::ostream& operator<<(std::ostream& os, const EncodedStaticFieldValueIterator::ValueType& code);
+class CallSiteArrayValueIterator : public EncodedArrayValueIterator {
+ public:
+ CallSiteArrayValueIterator(const DexFile& dex_file,
+ const DexFile::CallSiteIdItem& call_site_id)
+ : EncodedArrayValueIterator(dex_file,
+ dex_file.GetCallSiteEncodedValuesArray(call_site_id))
+ {}
+
+ uint32_t Size() const { return array_size_; }
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(CallSiteArrayValueIterator);
+};
+std::ostream& operator<<(std::ostream& os, const CallSiteArrayValueIterator::ValueType& code);
+
class CatchHandlerIterator {
public:
CatchHandlerIterator(const DexFile::CodeItem& code_item, uint32_t address);
diff --git a/runtime/dex_file_test.cc b/runtime/dex_file_test.cc
index 9dca4c0..9131715 100644
--- a/runtime/dex_file_test.cc
+++ b/runtime/dex_file_test.cc
@@ -326,12 +326,32 @@
}
TEST_F(DexFileTest, GetChecksum) {
- uint32_t checksum;
+ std::vector<uint32_t> checksums;
ScopedObjectAccess soa(Thread::Current());
std::string error_msg;
- EXPECT_TRUE(DexFile::GetChecksum(GetLibCoreDexFileNames()[0].c_str(), &checksum, &error_msg))
+ EXPECT_TRUE(DexFile::GetMultiDexChecksums(GetLibCoreDexFileNames()[0].c_str(), &checksums, &error_msg))
<< error_msg;
- EXPECT_EQ(java_lang_dex_file_->GetLocationChecksum(), checksum);
+ ASSERT_EQ(1U, checksums.size());
+ EXPECT_EQ(java_lang_dex_file_->GetLocationChecksum(), checksums[0]);
+}
+
+TEST_F(DexFileTest, GetMultiDexChecksums) {
+ std::string error_msg;
+ std::vector<uint32_t> checksums;
+ std::string multidex_file = GetTestDexFileName("MultiDex");
+ EXPECT_TRUE(DexFile::GetMultiDexChecksums(multidex_file.c_str(),
+ &checksums,
+ &error_msg)) << error_msg;
+
+ std::vector<std::unique_ptr<const DexFile>> dexes = OpenTestDexFiles("MultiDex");
+ ASSERT_EQ(2U, dexes.size());
+ ASSERT_EQ(2U, checksums.size());
+
+ EXPECT_EQ(dexes[0]->GetLocation(), DexFile::GetMultiDexLocation(0, multidex_file.c_str()));
+ EXPECT_EQ(dexes[0]->GetLocationChecksum(), checksums[0]);
+
+ EXPECT_EQ(dexes[1]->GetLocation(), DexFile::GetMultiDexLocation(1, multidex_file.c_str()));
+ EXPECT_EQ(dexes[1]->GetLocationChecksum(), checksums[1]);
}
TEST_F(DexFileTest, ClassDefs) {
diff --git a/runtime/dex_file_verifier.cc b/runtime/dex_file_verifier.cc
index 318123e..0b3f16a 100644
--- a/runtime/dex_file_verifier.cc
+++ b/runtime/dex_file_verifier.cc
@@ -46,8 +46,8 @@
return (high == 0);
}
-static uint32_t MapTypeToBitMask(uint32_t map_type) {
- switch (map_type) {
+static uint32_t MapTypeToBitMask(DexFile::MapItemType map_item_type) {
+ switch (map_item_type) {
case DexFile::kDexTypeHeaderItem: return 1 << 0;
case DexFile::kDexTypeStringIdItem: return 1 << 1;
case DexFile::kDexTypeTypeIdItem: return 1 << 2;
@@ -55,23 +55,25 @@
case DexFile::kDexTypeFieldIdItem: return 1 << 4;
case DexFile::kDexTypeMethodIdItem: return 1 << 5;
case DexFile::kDexTypeClassDefItem: return 1 << 6;
- case DexFile::kDexTypeMapList: return 1 << 7;
- case DexFile::kDexTypeTypeList: return 1 << 8;
- case DexFile::kDexTypeAnnotationSetRefList: return 1 << 9;
- case DexFile::kDexTypeAnnotationSetItem: return 1 << 10;
- case DexFile::kDexTypeClassDataItem: return 1 << 11;
- case DexFile::kDexTypeCodeItem: return 1 << 12;
- case DexFile::kDexTypeStringDataItem: return 1 << 13;
- case DexFile::kDexTypeDebugInfoItem: return 1 << 14;
- case DexFile::kDexTypeAnnotationItem: return 1 << 15;
- case DexFile::kDexTypeEncodedArrayItem: return 1 << 16;
- case DexFile::kDexTypeAnnotationsDirectoryItem: return 1 << 17;
+ case DexFile::kDexTypeCallSiteIdItem: return 1 << 7;
+ case DexFile::kDexTypeMethodHandleItem: return 1 << 8;
+ case DexFile::kDexTypeMapList: return 1 << 9;
+ case DexFile::kDexTypeTypeList: return 1 << 10;
+ case DexFile::kDexTypeAnnotationSetRefList: return 1 << 11;
+ case DexFile::kDexTypeAnnotationSetItem: return 1 << 12;
+ case DexFile::kDexTypeClassDataItem: return 1 << 13;
+ case DexFile::kDexTypeCodeItem: return 1 << 14;
+ case DexFile::kDexTypeStringDataItem: return 1 << 15;
+ case DexFile::kDexTypeDebugInfoItem: return 1 << 16;
+ case DexFile::kDexTypeAnnotationItem: return 1 << 17;
+ case DexFile::kDexTypeEncodedArrayItem: return 1 << 18;
+ case DexFile::kDexTypeAnnotationsDirectoryItem: return 1 << 19;
}
return 0;
}
-static bool IsDataSectionType(uint32_t map_type) {
- switch (map_type) {
+static bool IsDataSectionType(DexFile::MapItemType map_item_type) {
+ switch (map_item_type) {
case DexFile::kDexTypeHeaderItem:
case DexFile::kDexTypeStringIdItem:
case DexFile::kDexTypeTypeIdItem:
@@ -80,6 +82,20 @@
case DexFile::kDexTypeMethodIdItem:
case DexFile::kDexTypeClassDefItem:
return false;
+ case DexFile::kDexTypeCallSiteIdItem:
+ case DexFile::kDexTypeMethodHandleItem:
+ case DexFile::kDexTypeMapList:
+ case DexFile::kDexTypeTypeList:
+ case DexFile::kDexTypeAnnotationSetRefList:
+ case DexFile::kDexTypeAnnotationSetItem:
+ case DexFile::kDexTypeClassDataItem:
+ case DexFile::kDexTypeCodeItem:
+ case DexFile::kDexTypeStringDataItem:
+ case DexFile::kDexTypeDebugInfoItem:
+ case DexFile::kDexTypeAnnotationItem:
+ case DexFile::kDexTypeEncodedArrayItem:
+ case DexFile::kDexTypeAnnotationsDirectoryItem:
+ return true;
}
return true;
}
@@ -455,7 +471,8 @@
return false;
}
- if (IsDataSectionType(item->type_)) {
+ DexFile::MapItemType item_type = static_cast<DexFile::MapItemType>(item->type_);
+ if (IsDataSectionType(item_type)) {
uint32_t icount = item->size_;
if (UNLIKELY(icount > data_items_left)) {
ErrorStringPrintf("Too many items in data section: %ud", data_item_count + icount);
@@ -465,7 +482,7 @@
data_item_count += icount;
}
- uint32_t bit = MapTypeToBitMask(item->type_);
+ uint32_t bit = MapTypeToBitMask(item_type);
if (UNLIKELY(bit == 0)) {
ErrorStringPrintf("Unknown map section type %x", item->type_);
@@ -837,6 +854,28 @@
return false;
}
break;
+ case DexFile::kDexAnnotationMethodType: {
+ if (UNLIKELY(value_arg > 3)) {
+ ErrorStringPrintf("Bad encoded_value method type size %x", value_arg);
+ return false;
+ }
+ uint32_t idx = ReadUnsignedLittleEndian(value_arg + 1);
+ if (!CheckIndex(idx, header_->proto_ids_size_, "method_type value")) {
+ return false;
+ }
+ break;
+ }
+ case DexFile::kDexAnnotationMethodHandle: {
+ if (UNLIKELY(value_arg > 3)) {
+ ErrorStringPrintf("Bad encoded_value method handle size %x", value_arg);
+ return false;
+ }
+ uint32_t idx = ReadUnsignedLittleEndian(value_arg + 1);
+ if (!CheckIndex(idx, dex_file_->NumMethodHandles(), "method_handle value")) {
+ return false;
+ }
+ break;
+ }
default:
ErrorStringPrintf("Bogus encoded_value value_type %x", value_type);
return false;
@@ -1455,7 +1494,7 @@
}
bool DexFileVerifier::CheckIntraSectionIterate(size_t offset, uint32_t section_count,
- uint16_t type) {
+ DexFile::MapItemType type) {
// Get the right alignment mask for the type of section.
size_t alignment_mask;
switch (type) {
@@ -1481,6 +1520,7 @@
}
// Check depending on the section type.
+ const uint8_t* start_ptr = ptr_;
switch (type) {
case DexFile::kDexTypeStringIdItem: {
if (!CheckListSize(ptr_, 1, sizeof(DexFile::StringId), "string_ids")) {
@@ -1524,6 +1564,20 @@
ptr_ += sizeof(DexFile::ClassDef);
break;
}
+ case DexFile::kDexTypeCallSiteIdItem: {
+ if (!CheckListSize(ptr_, 1, sizeof(DexFile::CallSiteIdItem), "call_site_ids")) {
+ return false;
+ }
+ ptr_ += sizeof(DexFile::CallSiteIdItem);
+ break;
+ }
+ case DexFile::kDexTypeMethodHandleItem: {
+ if (!CheckListSize(ptr_, 1, sizeof(DexFile::MethodHandleItem), "method_handles")) {
+ return false;
+ }
+ ptr_ += sizeof(DexFile::MethodHandleItem);
+ break;
+ }
case DexFile::kDexTypeTypeList: {
if (!CheckList(sizeof(DexFile::TypeItem), "type_list", &ptr_)) {
return false;
@@ -1584,9 +1638,14 @@
}
break;
}
- default:
- ErrorStringPrintf("Unknown map item type %x", type);
- return false;
+ case DexFile::kDexTypeHeaderItem:
+ case DexFile::kDexTypeMapList:
+ break;
+ }
+
+ if (start_ptr == ptr_) {
+ ErrorStringPrintf("Unknown map item type %x", type);
+ return false;
}
if (IsDataSectionType(type)) {
@@ -1610,7 +1669,9 @@
return true;
}
-bool DexFileVerifier::CheckIntraIdSection(size_t offset, uint32_t count, uint16_t type) {
+bool DexFileVerifier::CheckIntraIdSection(size_t offset,
+ uint32_t count,
+ DexFile::MapItemType type) {
uint32_t expected_offset;
uint32_t expected_size;
@@ -1658,7 +1719,9 @@
return CheckIntraSectionIterate(offset, count, type);
}
-bool DexFileVerifier::CheckIntraDataSection(size_t offset, uint32_t count, uint16_t type) {
+bool DexFileVerifier::CheckIntraDataSection(size_t offset,
+ uint32_t count,
+ DexFile::MapItemType type) {
size_t data_start = header_->data_off_;
size_t data_end = data_start + header_->data_size_;
@@ -1684,16 +1747,16 @@
bool DexFileVerifier::CheckIntraSection() {
const DexFile::MapList* map = reinterpret_cast<const DexFile::MapList*>(begin_ + header_->map_off_);
const DexFile::MapItem* item = map->list_;
-
- uint32_t count = map->size_;
size_t offset = 0;
+ uint32_t count = map->size_;
ptr_ = begin_;
// Check the items listed in the map.
while (count--) {
+ const size_t current_offset = offset;
uint32_t section_offset = item->offset_;
uint32_t section_count = item->size_;
- uint16_t type = item->type_;
+ DexFile::MapItemType type = static_cast<DexFile::MapItemType>(item->type_);
// Check for padding and overlap between items.
if (!CheckPadding(offset, section_offset)) {
@@ -1741,6 +1804,11 @@
ptr_ += sizeof(uint32_t) + (map->size_ * sizeof(DexFile::MapItem));
offset = section_offset + sizeof(uint32_t) + (map->size_ * sizeof(DexFile::MapItem));
break;
+ case DexFile::kDexTypeMethodHandleItem:
+ case DexFile::kDexTypeCallSiteIdItem:
+ CheckIntraSectionIterate(section_offset, section_count, type);
+ offset = ptr_ - begin_;
+ break;
case DexFile::kDexTypeTypeList:
case DexFile::kDexTypeAnnotationSetRefList:
case DexFile::kDexTypeAnnotationSetItem:
@@ -1756,7 +1824,9 @@
}
offset = ptr_ - begin_;
break;
- default:
+ }
+
+ if (offset == current_offset) {
ErrorStringPrintf("Unknown map item type %x", type);
return false;
}
@@ -2237,6 +2307,92 @@
return true;
}
+bool DexFileVerifier::CheckInterCallSiteIdItem() {
+ const DexFile::CallSiteIdItem* item = reinterpret_cast<const DexFile::CallSiteIdItem*>(ptr_);
+
+ // Check call site referenced by item is in encoded array section.
+ if (!CheckOffsetToTypeMap(item->data_off_, DexFile::kDexTypeEncodedArrayItem)) {
+ ErrorStringPrintf("Invalid offset in CallSideIdItem");
+ return false;
+ }
+
+ CallSiteArrayValueIterator it(*dex_file_, *item);
+
+ // Check Method Handle
+ if (!it.HasNext() || it.GetValueType() != EncodedArrayValueIterator::ValueType::kMethodHandle) {
+ ErrorStringPrintf("CallSiteArray missing method handle");
+ return false;
+ }
+
+ uint32_t handle_index = static_cast<uint32_t>(it.GetJavaValue().i);
+ if (handle_index >= dex_file_->NumMethodHandles()) {
+ ErrorStringPrintf("CallSite has bad method handle id: %x", handle_index);
+ return false;
+ }
+
+ // Check target method name.
+ it.Next();
+ if (!it.HasNext() ||
+ it.GetValueType() != EncodedArrayValueIterator::ValueType::kString) {
+ ErrorStringPrintf("CallSiteArray missing target method name");
+ return false;
+ }
+
+ uint32_t name_index = static_cast<uint32_t>(it.GetJavaValue().i);
+ if (name_index >= dex_file_->NumStringIds()) {
+ ErrorStringPrintf("CallSite has bad method name id: %x", name_index);
+ return false;
+ }
+
+ // Check method type.
+ it.Next();
+ if (!it.HasNext() ||
+ it.GetValueType() != EncodedArrayValueIterator::ValueType::kMethodType) {
+ ErrorStringPrintf("CallSiteArray missing method type");
+ return false;
+ }
+
+ uint32_t proto_index = static_cast<uint32_t>(it.GetJavaValue().i);
+ if (proto_index >= dex_file_->NumProtoIds()) {
+ ErrorStringPrintf("CallSite has bad method type: %x", proto_index);
+ return false;
+ }
+
+ ptr_ += sizeof(DexFile::CallSiteIdItem);
+ return true;
+}
+
+bool DexFileVerifier::CheckInterMethodHandleItem() {
+ const DexFile::MethodHandleItem* item = reinterpret_cast<const DexFile::MethodHandleItem*>(ptr_);
+
+ DexFile::MethodHandleType method_handle_type =
+ static_cast<DexFile::MethodHandleType>(item->method_handle_type_);
+ if (method_handle_type > DexFile::MethodHandleType::kLast) {
+ ErrorStringPrintf("Bad method handle type %x", item->method_handle_type_);
+ return false;
+ }
+
+ uint32_t index = item->field_or_method_idx_;
+ switch (method_handle_type) {
+ case DexFile::MethodHandleType::kStaticPut:
+ case DexFile::MethodHandleType::kStaticGet:
+ case DexFile::MethodHandleType::kInstancePut:
+ case DexFile::MethodHandleType::kInstanceGet: {
+ LOAD_FIELD(field, index, "method_handle_item field_idx", return false);
+ break;
+ }
+ case DexFile::MethodHandleType::kInvokeStatic:
+ case DexFile::MethodHandleType::kInvokeInstance:
+ case DexFile::MethodHandleType::kInvokeConstructor: {
+ LOAD_METHOD(method, index, "method_handle_item method_idx", return false);
+ break;
+ }
+ }
+
+ ptr_ += sizeof(DexFile::MethodHandleItem);
+ return true;
+}
+
bool DexFileVerifier::CheckInterAnnotationSetRefList() {
const DexFile::AnnotationSetRefList* list =
reinterpret_cast<const DexFile::AnnotationSetRefList*>(ptr_);
@@ -2386,7 +2542,9 @@
return true;
}
-bool DexFileVerifier::CheckInterSectionIterate(size_t offset, uint32_t count, uint16_t type) {
+bool DexFileVerifier::CheckInterSectionIterate(size_t offset,
+ uint32_t count,
+ DexFile::MapItemType type) {
// Get the right alignment mask for the type of section.
size_t alignment_mask;
switch (type) {
@@ -2405,8 +2563,22 @@
ptr_ = begin_ + new_offset;
const uint8_t* prev_ptr = ptr_;
+ if (MapTypeToBitMask(type) == 0) {
+ ErrorStringPrintf("Unknown map item type %x", type);
+ return false;
+ }
+
// Check depending on the section type.
switch (type) {
+ case DexFile::kDexTypeHeaderItem:
+ case DexFile::kDexTypeMapList:
+ case DexFile::kDexTypeTypeList:
+ case DexFile::kDexTypeCodeItem:
+ case DexFile::kDexTypeStringDataItem:
+ case DexFile::kDexTypeDebugInfoItem:
+ case DexFile::kDexTypeAnnotationItem:
+ case DexFile::kDexTypeEncodedArrayItem:
+ break;
case DexFile::kDexTypeStringIdItem: {
if (!CheckInterStringIdItem()) {
return false;
@@ -2451,6 +2623,18 @@
}
break;
}
+ case DexFile::kDexTypeCallSiteIdItem: {
+ if (!CheckInterCallSiteIdItem()) {
+ return false;
+ }
+ break;
+ }
+ case DexFile::kDexTypeMethodHandleItem: {
+ if (!CheckInterMethodHandleItem()) {
+ return false;
+ }
+ break;
+ }
case DexFile::kDexTypeAnnotationSetRefList: {
if (!CheckInterAnnotationSetRefList()) {
return false;
@@ -2483,9 +2667,6 @@
}
break;
}
- default:
- ErrorStringPrintf("Unknown map item type %x", type);
- return false;
}
previous_item_ = prev_ptr;
@@ -2504,7 +2685,8 @@
while (count--) {
uint32_t section_offset = item->offset_;
uint32_t section_count = item->size_;
- uint16_t type = item->type_;
+ DexFile::MapItemType type = static_cast<DexFile::MapItemType>(item->type_);
+ bool found = false;
switch (type) {
case DexFile::kDexTypeHeaderItem:
@@ -2515,6 +2697,7 @@
case DexFile::kDexTypeDebugInfoItem:
case DexFile::kDexTypeAnnotationItem:
case DexFile::kDexTypeEncodedArrayItem:
+ found = true;
break;
case DexFile::kDexTypeStringIdItem:
case DexFile::kDexTypeTypeIdItem:
@@ -2522,6 +2705,8 @@
case DexFile::kDexTypeFieldIdItem:
case DexFile::kDexTypeMethodIdItem:
case DexFile::kDexTypeClassDefItem:
+ case DexFile::kDexTypeCallSiteIdItem:
+ case DexFile::kDexTypeMethodHandleItem:
case DexFile::kDexTypeAnnotationSetRefList:
case DexFile::kDexTypeAnnotationSetItem:
case DexFile::kDexTypeClassDataItem:
@@ -2529,11 +2714,14 @@
if (!CheckInterSectionIterate(section_offset, section_count, type)) {
return false;
}
+ found = true;
break;
}
- default:
- ErrorStringPrintf("Unknown map item type %x", type);
- return false;
+ }
+
+ if (!found) {
+ ErrorStringPrintf("Unknown map item type %x", item->type_);
+ return false;
}
item++;
diff --git a/runtime/dex_file_verifier.h b/runtime/dex_file_verifier.h
index ae20613..71b316c 100644
--- a/runtime/dex_file_verifier.h
+++ b/runtime/dex_file_verifier.h
@@ -122,9 +122,9 @@
bool CheckIntraAnnotationItem();
bool CheckIntraAnnotationsDirectoryItem();
- bool CheckIntraSectionIterate(size_t offset, uint32_t count, uint16_t type);
- bool CheckIntraIdSection(size_t offset, uint32_t count, uint16_t type);
- bool CheckIntraDataSection(size_t offset, uint32_t count, uint16_t type);
+ bool CheckIntraSectionIterate(size_t offset, uint32_t count, DexFile::MapItemType type);
+ bool CheckIntraIdSection(size_t offset, uint32_t count, DexFile::MapItemType type);
+ bool CheckIntraDataSection(size_t offset, uint32_t count, DexFile::MapItemType type);
bool CheckIntraSection();
bool CheckOffsetToTypeMap(size_t offset, uint16_t type);
@@ -140,12 +140,14 @@
bool CheckInterFieldIdItem();
bool CheckInterMethodIdItem();
bool CheckInterClassDefItem();
+ bool CheckInterCallSiteIdItem();
+ bool CheckInterMethodHandleItem();
bool CheckInterAnnotationSetRefList();
bool CheckInterAnnotationSetItem();
bool CheckInterClassDataItem();
bool CheckInterAnnotationsDirectoryItem();
- bool CheckInterSectionIterate(size_t offset, uint32_t count, uint16_t type);
+ bool CheckInterSectionIterate(size_t offset, uint32_t count, DexFile::MapItemType type);
bool CheckInterSection();
// Load a string by (type) index. Checks whether the index is in bounds, printing the error if
diff --git a/runtime/dex_file_verifier_test.cc b/runtime/dex_file_verifier_test.cc
index c56b200..7736f3d 100644
--- a/runtime/dex_file_verifier_test.cc
+++ b/runtime/dex_file_verifier_test.cc
@@ -1885,4 +1885,209 @@
&error_msg));
}
+static const char* kInvokeCustomDexFiles[] = {
+ // TODO(oth): Revisit this test when we have smali / dx support.
+ // https://cs.corp.google.com/android/toolchain/jack/jack-tests/tests/com/android/jack/java7/invokecustom/test001/Tests.java
+ "ZGV4CjAzOAAEj12s/acmmdGuDL92SWSBh6iLBjxgomWkCAAAcAAAAHhWNBIAAAAAAAAAALwHAAAx"
+ "AAAAcAAAABYAAAA0AQAACQAAAIwBAAADAAAA+AEAAAsAAAAQAgAAAQAAAHACAAAMBgAAmAIAAMID"
+ "AADKAwAAzQMAANIDAADhAwAA5AMAAOoDAAAfBAAAUgQAAIMEAAC4BAAA1AQAAOsEAAD+BAAAEgUA"
+ "ACYFAAA6BQAAUQUAAG4FAACTBQAAtAUAAN0FAAD/BQAAHgYAADgGAABKBgAAVgYAAFkGAABdBgAA"
+ "YgYAAGYGAAB7BgAAgAYAAI8GAACdBgAAtAYAAMMGAADSBgAA3gYAAPIGAAD4BgAABgcAAA4HAAAU"
+ "BwAAGgcAAB8HAAAoBwAANAcAADoHAAABAAAABgAAAAcAAAAIAAAACQAAAAoAAAALAAAADAAAAA0A"
+ "AAAOAAAADwAAABAAAAARAAAAEgAAABMAAAAUAAAAFQAAABYAAAAXAAAAGAAAABoAAAAeAAAAAgAA"
+ "AAAAAACMAwAABQAAAAwAAACUAwAABQAAAA4AAACgAwAABAAAAA8AAAAAAAAAGgAAABQAAAAAAAAA"
+ "GwAAABQAAACsAwAAHAAAABQAAACMAwAAHQAAABQAAAC0AwAAHQ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AAAAIAAAAWAAAANAEAAAMAAAAJAAAAjAEAAAQAAAADAAAA+AEAAAUAAAALAAAA"
+ "EAIAAAcAAAACAAAAaAIAAAYAAAABAAAAcAIAAAgAAAABAAAAkAIAAAMQAAADAAAAmAIAAAEgAAAF"
+ "AAAAtAIAAAYgAAABAAAAZAMAAAEQAAAGAAAAjAMAAAIgAAAxAAAAwgMAAAMgAAAFAAAAQQcAAAQg"
+ "AAADAAAAYwcAAAUgAAABAAAAlgcAAAAgAAABAAAAnQcAAAAQAAABAAAAvAcAAA==",
+ // https://cs.corp.google.com/android/toolchain/jack/jack-tests/tests/com/android/jack/java7/invokecustom/test002/Tests.java
+ "ZGV4CjAzOAAzq3aGAwKhT4QQj4lqNfZJAO8Tm24uTyNICQAAcAAAAHhWNBIAAAAAAAAAAGAIAAA2"
+ "AAAAcAAAABgAAABIAQAACQAAAKgBAAAEAAAAFAIAAA0AAAA0AgAAAQAAAKQCAAB8BgAAzAIAACYE"
+ "AAAwBAAAOAQAAEQEAABHBAAATAQAAE8EAABVBAAAigQAALwEAADtBAAAIgUAAD4FAABVBQAAaAUA"
+ "AH0FAACRBQAApQUAALkFAADQBQAA7QUAABIGAAAzBgAAXAYAAH4GAACdBgAAtwYAAMkGAADPBgAA"
+ "2wYAAN4GAADiBgAA5wYAAOsGAAD/BgAAFAcAABkHAAAoBwAANgcAAE0HAABcBwAAawcAAH4HAACK"
+ "BwAAkAcAAJgHAACeBwAAqgcAALAHAAC1BwAAxgcAAM8HAADbBwAA4QcAAAMAAAAHAAAACAAAAAkA"
+ "AAAKAAAACwAAAAwAAAANAAAADgAAAA8AAAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAA"
+ "ABgAAAAZAAAAGgAAAB0AAAAhAAAAIgAAAAQAAAAAAAAA8AMAAAYAAAAPAAAA+AMAAAUAAAAQAAAA"
+ "AAAAAAYAAAASAAAABAQAAB0AAAAVAAAAAAAAAB4AAAAVAAAAEAQAAB8AAAAVAAAA8AMA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Jh4AIQAHDgA2AgAABw4APwEA"
+ "Bw60ADsABw6lAAABBCQcAhgAGAApHAEdAgMnGAQrGwAvFygvFyMzGAACBQE1HAEYDAEUAAMWABcj"
+ "FQABAAQBAQkAiIAE4AUBgYAE0AYBCugGAQmABwQBqAcAAAATAAAAAAAAAAEAAAAAAAAAAQAAADYA"
+ "AABwAAAAAgAAABgAAABIAQAAAwAAAAkAAACoAQAABAAAAAQAAAAUAgAABQAAAA0AAAA0AgAABwAA"
+ "AAIAAACcAgAABgAAAAEAAACkAgAACAAAAAEAAADEAgAAAxAAAAIAAADMAgAAASAAAAUAAADgAgAA"
+ "BiAAAAEAAADQAwAAARAAAAYAAADwAwAAAiAAADYAAAAmBAAAAyAAAAUAAADoBwAABCAAAAMAAAAO"
+ "CAAABSAAAAEAAAA4CAAAACAAAAEAAAA/CAAAABAAAAEAAABgCAAA",
+ // https://cs.corp.google.com/android/toolchain/jack/jack-tests/tests/com/android/jack/java7/invokecustom/test003/Tests.java
+ "ZGV4CjAzOABjnhkFatj30/7cHTCJsfr7vAjz9/p+Y+TcCAAAcAAAAHhWNBIAAAAAAAAAAPQHAAAx"
+ "AAAAcAAAABYAAAA0AQAACQAAAIwBAAADAAAA+AEAAAsAAAAQAgAAAQAAAHACAABEBgAAmAIAAOoD"
+ "AADyAwAA9QMAAP4DAAANBAAAEAQAABYEAABLBAAAfgQAAK8EAADkBAAAAAUAABcFAAAqBQAAPgUA"
+ "AFIFAABmBQAAfQUAAJoFAAC/BQAA4AUAAAkGAAArBgAASgYAAGQGAAB2BgAAggYAAIUGAACJBgAA"
+ "jgYAAJIGAACnBgAArAYAALsGAADJBgAA4AYAAO8GAAD+BgAACgcAAB4HAAAkBwAAMgcAADoHAABA"
+ "BwAARgcAAEsHAABUBwAAYAcAAGYHAAABAAAABgAAAAcAAAAIAAAACQAAAAoAAAALAAAADAAAAA0A"
+ "AAAOAAAADwAAABAAAAARAAAAEgAAABMAAAAUAAAAFQAAABYAAAAXAAAAGAAAAB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AABw4ANQMAAAAHDqUAPwEABw7wADsABw7w"
+ "AAABBCAcBhgAGAAYABgAGAAYACYcAR0CBCAcAxgPGAkYESMYBCcbACsXKCsXHy4YAAIFATAcARgL"
+ "ARMAAxYAFx8VAAEABAEBCQCBgAS0BQEKzAUBCuwFAQmcBgQBzAYAAAATAAAAAAAAAAEAAAAAAAAA"
+ "AQAAADEAAABwAAAAAgAAABYAAAA0AQAAAwAAAAkAAACMAQAABAAAAAMAAAD4AQAABQAAAAsAAAAQ"
+ "AgAABwAAAAIAAABoAgAABgAAAAEAAABwAgAACAAAAAEAAACQAgAAAxAAAAMAAACYAgAAASAAAAUA"
+ "AAC0AgAABiAAAAEAAAB8AwAAARAAAAcAAACkAwAAAiAAADEAAADqAwAAAyAAAAUAAABtBwAABCAA"
+ "AAMAAACTBwAABSAAAAEAAADOBwAAACAAAAEAAADVBwAAABAAAAEAAAD0BwAA",
+ // https://cs.corp.google.com/android/toolchain/jack/jack-tests/tests/com/android/jack/java7/invokecustom/test004/Tests.java
+ "ZGV4CjAzOABvUVfbV74qWbSOEsgKP+EzahlNQLW2/8TMDAAAcAAAAHhWNBIAAAAAAAAAAOQLAABS"
+ "AAAAcAAAAB8AAAC4AQAAEAAAADQCAAADAAAA9AIAABIAAAAMAwAAAQAAAKQDAAAACQAAzAMAANYF"
+ "AADZBQAA4QUAAOkFAADsBQAA7wUAAPIFAAD1BQAA/AUAAP8FAAAEBgAAEwYAABYGAAAZBgAAHwYA"
+ "AC8GAABkBgAAjQYAAMAGAADxBgAAJgcAAEUHAABhBwAAeAcAAIoHAACdBwAAsQcAAMUHAADZBwAA"
+ "8AcAAA0IAAAyCAAAUwgAAHwIAACeCAAAvQgAANcIAADpCAAA7AgAAPgIAAD7CAAAAAkAAAYJAAAM"
+ "CQAAEAkAABUJAAAaCQAAHgkAACMJAAAnCQAAKgkAADMJAABICQAATQkAAFwJAABqCQAAdgkAAIQJ"
+ "AACPCQAAmgkAAKYJAACzCQAAygkAANkJAADoCQA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dXJuVHlwZQAKc2hvcnRWYWx1ZQALc3RyaW5nVmFsdWUABHRlc3QABXZhbHVlACMABw4ANwIA"
+ "AAcOAD4NAAAAAAAAAAAAAAAAAAcOPEtaWmmWw4d4h6UAUgEABw60AE4ABw6lAAAGBTUcAhgEGARD"
+ "HAEdCAQ1HA0YFhgQGBgYHRgAGAEYGxgEGAMYAhgQGA4YBT4YCkQbAEoXRUkcCh0HATgcAT8dBwE5"
+ "HAEAAR0HATocAQNhHQcBThwBIgAEHQcBQhwBBAEdBwFBHAFwmpkxQR0HATwcAfGamZmZmZkBQB0H"
+ "AU8cARcHHQcBOxwBGAodBwFGHAFmFc1bB0oXNE0YBAILAVEcCRcAFyAXGhciFzIXGhcXFwEXHQIM"
+ "AVEcARgSARoADRYAFzQVAAQBBAEEYSQABAQBcJqZMUHxmpmZmZmZAUAXBxgKZhXNWwcBAAQBAQkA"
+ "gYAE7AcBCoQIAQqcCAEJ1AkEAfwJAAATAAAAAAAAAAEAAAAAAAAAAQAAAFIAAABwAAAAAgAAAB8A"
+ "AAC4AQAAAwAAABAAAAA0AgAABAAAAAMAAAD0AgAABQAAABIAAAAMAwAABwAAAAIAAACcAwAABgAA"
+ "AAEAAACkAwAACAAAAAEAAADEAwAAAxAAAAMAAADMAwAAASAAAAUAAADsAwAABiAAAAEAAAAkBQAA"
+ "ARAAAA0AAABMBQAAAiAAAFIAAADWBQAAAyAAAAUAAACoCgAABCAAAAQAAADeCgAABSAAAAEAAACd"
+ "CwAAACAAAAEAAADGCwAAABAAAAEAAADkCwAA"
+};
+
+TEST_F(DexFileVerifierTest, InvokeCustomDexSamples) {
+ for (size_t i = 0; i < arraysize(kInvokeCustomDexFiles); ++i) {
+ size_t length;
+ std::unique_ptr<uint8_t[]> dex_bytes(DecodeBase64(kInvokeCustomDexFiles[i], &length));
+ CHECK(dex_bytes != nullptr);
+ // Note: `dex_file` will be destroyed before `dex_bytes`.
+ std::unique_ptr<DexFile> dex_file(GetDexFile(dex_bytes.get(), length));
+ std::string error_msg;
+ EXPECT_TRUE(DexFileVerifier::Verify(dex_file.get(),
+ dex_file->Begin(),
+ dex_file->Size(),
+ "good checksum, verify",
+ /*verify_checksum*/ true,
+ &error_msg));
+ // TODO(oth): Test corruptions (b/35308502)
+ }
+}
+
} // namespace art
diff --git a/runtime/dex_instruction.cc b/runtime/dex_instruction.cc
index 37f3ac9..091085a 100644
--- a/runtime/dex_instruction.cc
+++ b/runtime/dex_instruction.cc
@@ -407,6 +407,20 @@
break;
}
FALLTHROUGH_INTENDED;
+ case INVOKE_CUSTOM:
+ if (file != nullptr) {
+ os << opcode << " {";
+ uint32_t call_site_idx = VRegB_35c();
+ for (size_t i = 0; i < VRegA_35c(); ++i) {
+ if (i != 0) {
+ os << ", ";
+ }
+ os << "v" << arg[i];
+ }
+ os << "}, // call_site@" << call_site_idx;
+ break;
+ }
+ FALLTHROUGH_INTENDED;
default:
os << opcode << " {v" << arg[0] << ", v" << arg[1] << ", v" << arg[2]
<< ", v" << arg[3] << ", v" << arg[4] << "}, thing@" << VRegB_35c();
@@ -415,6 +429,8 @@
break;
}
case k3rc: {
+ uint16_t first_reg = VRegC_3rc();
+ uint16_t last_reg = VRegC_3rc() + VRegA_3rc() - 1;
switch (Opcode()) {
case INVOKE_VIRTUAL_RANGE:
case INVOKE_SUPER_RANGE:
@@ -423,7 +439,7 @@
case INVOKE_INTERFACE_RANGE:
if (file != nullptr) {
uint32_t method_idx = VRegB_3rc();
- os << StringPrintf("%s, {v%d .. v%d}, ", opcode, VRegC_3rc(), (VRegC_3rc() + VRegA_3rc() - 1))
+ os << StringPrintf("%s, {v%d .. v%d}, ", opcode, first_reg, last_reg)
<< file->PrettyMethod(method_idx) << " // method@" << method_idx;
break;
}
@@ -431,14 +447,22 @@
case INVOKE_VIRTUAL_RANGE_QUICK:
if (file != nullptr) {
uint32_t method_idx = VRegB_3rc();
- os << StringPrintf("%s, {v%d .. v%d}, ", opcode, VRegC_3rc(), (VRegC_3rc() + VRegA_3rc() - 1))
+ os << StringPrintf("%s, {v%d .. v%d}, ", opcode, first_reg, last_reg)
<< "// vtable@" << method_idx;
break;
}
FALLTHROUGH_INTENDED;
+ case INVOKE_CUSTOM_RANGE:
+ if (file != nullptr) {
+ uint32_t call_site_idx = VRegB_3rc();
+ os << StringPrintf("%s, {v%d .. v%d}, ", opcode, first_reg, last_reg)
+ << "// call_site@" << call_site_idx;
+ break;
+ }
+ FALLTHROUGH_INTENDED;
default:
- os << StringPrintf("%s, {v%d .. v%d}, thing@%d", opcode, VRegC_3rc(),
- (VRegC_3rc() + VRegA_3rc() - 1), VRegB_3rc());
+ os << StringPrintf("%s, {v%d .. v%d}, ", opcode, first_reg, last_reg)
+ << "thing@" << VRegB_3rc();
break;
}
break;
diff --git a/runtime/dex_instruction.h b/runtime/dex_instruction.h
index 578550c..d269110 100644
--- a/runtime/dex_instruction.h
+++ b/runtime/dex_instruction.h
@@ -126,14 +126,15 @@
enum IndexType {
kIndexUnknown = 0,
- kIndexNone, // has no index
- kIndexTypeRef, // type reference index
- kIndexStringRef, // string reference index
- kIndexMethodRef, // method reference index
- kIndexFieldRef, // field reference index
- kIndexFieldOffset, // field offset (for static linked fields)
- kIndexVtableOffset, // vtable offset (for static linked methods)
- kIndexMethodAndProtoRef // method and a proto reference index (for invoke-polymorphic)
+ kIndexNone, // has no index
+ kIndexTypeRef, // type reference index
+ kIndexStringRef, // string reference index
+ kIndexMethodRef, // method reference index
+ kIndexFieldRef, // field reference index
+ kIndexFieldOffset, // field offset (for static linked fields)
+ kIndexVtableOffset, // vtable offset (for static linked methods)
+ kIndexMethodAndProtoRef, // method and a proto reference index (for invoke-polymorphic)
+ kIndexCallSiteRef, // call site reference index
};
enum Flags {
@@ -165,31 +166,32 @@
};
enum VerifyFlag {
- kVerifyNone = 0x000000,
- kVerifyRegA = 0x000001,
- kVerifyRegAWide = 0x000002,
- kVerifyRegB = 0x000004,
- kVerifyRegBField = 0x000008,
- kVerifyRegBMethod = 0x000010,
- kVerifyRegBNewInstance = 0x000020,
- kVerifyRegBString = 0x000040,
- kVerifyRegBType = 0x000080,
- kVerifyRegBWide = 0x000100,
- kVerifyRegC = 0x000200,
- kVerifyRegCField = 0x000400,
- kVerifyRegCNewArray = 0x000800,
- kVerifyRegCType = 0x001000,
- kVerifyRegCWide = 0x002000,
- kVerifyArrayData = 0x004000,
- kVerifyBranchTarget = 0x008000,
- kVerifySwitchTargets = 0x010000,
- kVerifyVarArg = 0x020000,
- kVerifyVarArgNonZero = 0x040000,
- kVerifyVarArgRange = 0x080000,
- kVerifyVarArgRangeNonZero = 0x100000,
- kVerifyRuntimeOnly = 0x200000,
- kVerifyError = 0x400000,
- kVerifyRegHPrototype = 0x800000
+ kVerifyNone = 0x0000000,
+ kVerifyRegA = 0x0000001,
+ kVerifyRegAWide = 0x0000002,
+ kVerifyRegB = 0x0000004,
+ kVerifyRegBField = 0x0000008,
+ kVerifyRegBMethod = 0x0000010,
+ kVerifyRegBNewInstance = 0x0000020,
+ kVerifyRegBString = 0x0000040,
+ kVerifyRegBType = 0x0000080,
+ kVerifyRegBWide = 0x0000100,
+ kVerifyRegC = 0x0000200,
+ kVerifyRegCField = 0x0000400,
+ kVerifyRegCNewArray = 0x0000800,
+ kVerifyRegCType = 0x0001000,
+ kVerifyRegCWide = 0x0002000,
+ kVerifyArrayData = 0x0004000,
+ kVerifyBranchTarget = 0x0008000,
+ kVerifySwitchTargets = 0x0010000,
+ kVerifyVarArg = 0x0020000,
+ kVerifyVarArgNonZero = 0x0040000,
+ kVerifyVarArgRange = 0x0080000,
+ kVerifyVarArgRangeNonZero = 0x0100000,
+ kVerifyRuntimeOnly = 0x0200000,
+ kVerifyError = 0x0400000,
+ kVerifyRegHPrototype = 0x0800000,
+ kVerifyRegBCallSite = 0x1000000
};
static constexpr uint32_t kMaxVarArgRegs = 5;
diff --git a/runtime/dex_instruction_list.h b/runtime/dex_instruction_list.h
index ca2ce1d..a5ce3c2 100644
--- a/runtime/dex_instruction_list.h
+++ b/runtime/dex_instruction_list.h
@@ -271,8 +271,8 @@
V(0xF9, UNUSED_F9, "unused-f9", k10x, kIndexUnknown, 0, kVerifyError) \
V(0xFA, INVOKE_POLYMORPHIC, "invoke-polymorphic", k45cc, kIndexMethodAndProtoRef, kContinue | kThrow | kInvoke, kVerifyRegBMethod | kVerifyVarArgNonZero | kVerifyRegHPrototype) \
V(0xFB, INVOKE_POLYMORPHIC_RANGE, "invoke-polymorphic/range", k4rcc, kIndexMethodAndProtoRef, kContinue | kThrow | kInvoke, kVerifyRegBMethod | kVerifyVarArgRangeNonZero | kVerifyRegHPrototype) \
- V(0xFC, UNUSED_FC, "unused-fc", k10x, kIndexUnknown, 0, kVerifyError) \
- V(0xFD, UNUSED_FD, "unused-fd", k10x, kIndexUnknown, 0, kVerifyError) \
+ V(0xFC, INVOKE_CUSTOM, "invoke-custom", k35c, kIndexCallSiteRef, kContinue | kThrow, kVerifyRegBCallSite) \
+ V(0xFD, INVOKE_CUSTOM_RANGE, "invoke-custom/range", k3rc, kIndexCallSiteRef, kContinue | kThrow, kVerifyRegBCallSite) \
V(0xFE, UNUSED_FE, "unused-fe", k10x, kIndexUnknown, 0, kVerifyError) \
V(0xFF, UNUSED_FF, "unused-ff", k10x, kIndexUnknown, 0, kVerifyError)
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index 3ef47c4..c2bca53 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -2435,8 +2435,8 @@
// Wrap raw_method_handle in a Handle for safety.
StackHandleScope<5> hs(self);
- Handle<mirror::MethodHandleImpl> method_handle(
- hs.NewHandle(ObjPtr<mirror::MethodHandleImpl>::DownCast(MakeObjPtr(raw_method_handle))));
+ Handle<mirror::MethodHandle> method_handle(
+ hs.NewHandle(ObjPtr<mirror::MethodHandle>::DownCast(MakeObjPtr(raw_method_handle))));
raw_method_handle = nullptr;
self->EndAssertNoThreadSuspension(old_cause);
@@ -2497,15 +2497,14 @@
// consecutive order.
uint32_t unused_args[Instruction::kMaxVarArgRegs] = {};
uint32_t first_callee_arg = first_arg + 1;
- const bool do_assignability_check = false;
- if (!DoInvokePolymorphic<true /* is_range */, do_assignability_check>(self,
- resolved_method,
- *shadow_frame,
- method_handle,
- method_type,
- unused_args,
- first_callee_arg,
- result)) {
+ if (!DoInvokePolymorphic<true /* is_range */>(self,
+ resolved_method,
+ *shadow_frame,
+ method_handle,
+ method_type,
+ unused_args,
+ first_callee_arg,
+ result)) {
DCHECK(self->IsExceptionPending());
}
diff --git a/runtime/gc/allocation_record.cc b/runtime/gc/allocation_record.cc
index e18a955..122f779 100644
--- a/runtime/gc/allocation_record.cc
+++ b/runtime/gc/allocation_record.cc
@@ -292,7 +292,7 @@
(kUseReadBarrier && !self->GetWeakRefAccessEnabled()))) {
// Check and run the empty checkpoint before blocking so the empty checkpoint will work in the
// presence of threads blocking for weak ref access.
- self->CheckEmptyCheckpoint();
+ self->CheckEmptyCheckpointFromWeakRefAccess(Locks::alloc_tracker_lock_);
new_record_condition_.WaitHoldingLocks(self);
}
diff --git a/runtime/gc/collector/concurrent_copying.cc b/runtime/gc/collector/concurrent_copying.cc
index f12ad80..f18ffb4 100644
--- a/runtime/gc/collector/concurrent_copying.cc
+++ b/runtime/gc/collector/concurrent_copying.cc
@@ -835,65 +835,9 @@
void ConcurrentCopying::IssueEmptyCheckpoint() {
Thread* self = Thread::Current();
ThreadList* thread_list = Runtime::Current()->GetThreadList();
- Barrier* barrier = thread_list->EmptyCheckpointBarrier();
- barrier->Init(self, 0);
- std::vector<uint32_t> runnable_thread_ids; // Used in debug build only
- size_t barrier_count = thread_list->RunEmptyCheckpoint(runnable_thread_ids);
- // If there are no threads to wait which implys that all the checkpoint functions are finished,
- // then no need to release the mutator lock.
- if (barrier_count == 0) {
- return;
- }
// Release locks then wait for all mutator threads to pass the barrier.
Locks::mutator_lock_->SharedUnlock(self);
- {
- ScopedThreadStateChange tsc(self, kWaitingForCheckPointsToRun);
- if (kIsDebugBuild) {
- static constexpr uint64_t kEmptyCheckpointTimeoutMs = 600 * 1000; // 10 minutes.
- bool timed_out = barrier->Increment(self, barrier_count, kEmptyCheckpointTimeoutMs);
- if (timed_out) {
- std::ostringstream ss;
- ss << "Empty checkpoint timeout\n";
- ss << "Barrier count " << barrier->GetCount(self) << "\n";
- ss << "Runnable thread IDs";
- for (uint32_t tid : runnable_thread_ids) {
- ss << " " << tid;
- }
- ss << "\n";
- Locks::mutator_lock_->Dump(ss);
- ss << "\n";
- LOG(FATAL_WITHOUT_ABORT) << ss.str();
- // Some threads in 'runnable_thread_ids' are probably stuck. Try to dump their stacks.
- // Avoid using ThreadList::Dump() initially because it is likely to get stuck as well.
- {
- ScopedObjectAccess soa(self);
- MutexLock mu1(self, *Locks::thread_list_lock_);
- for (Thread* thread : thread_list->GetList()) {
- uint32_t tid = thread->GetThreadId();
- bool is_in_runnable_thread_ids =
- std::find(runnable_thread_ids.begin(), runnable_thread_ids.end(), tid) !=
- runnable_thread_ids.end();
- if (is_in_runnable_thread_ids &&
- thread->ReadFlag(kEmptyCheckpointRequest)) {
- // Found a runnable thread that hasn't responded to the empty checkpoint request.
- // Assume it's stuck and safe to dump its stack.
- thread->Dump(LOG_STREAM(FATAL_WITHOUT_ABORT),
- /*dump_native_stack*/ true,
- /*backtrace_map*/ nullptr,
- /*force_dump_stack*/ true);
- }
- }
- }
- LOG(FATAL_WITHOUT_ABORT)
- << "Dumped runnable threads that haven't responded to empty checkpoint.";
- // Now use ThreadList::Dump() to dump more threads, noting it may get stuck.
- thread_list->Dump(LOG_STREAM(FATAL_WITHOUT_ABORT));
- LOG(FATAL) << "Dumped all threads.";
- }
- } else {
- barrier->Increment(self, barrier_count);
- }
- }
+ thread_list->RunEmptyCheckpoint();
Locks::mutator_lock_->SharedLock(self);
}
diff --git a/runtime/gc/reference_processor.cc b/runtime/gc/reference_processor.cc
index c154836..86b1522 100644
--- a/runtime/gc/reference_processor.cc
+++ b/runtime/gc/reference_processor.cc
@@ -104,7 +104,7 @@
}
// Check and run the empty checkpoint before blocking so the empty checkpoint will work in the
// presence of threads blocking for weak ref access.
- self->CheckEmptyCheckpoint();
+ self->CheckEmptyCheckpointFromWeakRefAccess(Locks::reference_processor_lock_);
condition_.WaitHoldingLocks(self);
}
return reference->GetReferent();
@@ -292,7 +292,7 @@
(kUseReadBarrier && !self->GetWeakRefAccessEnabled())) {
// Check and run the empty checkpoint before blocking so the empty checkpoint will work in the
// presence of threads blocking for weak ref access.
- self->CheckEmptyCheckpoint();
+ self->CheckEmptyCheckpointFromWeakRefAccess(Locks::reference_processor_lock_);
condition_.WaitHoldingLocks(self);
}
}
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index 442a42e..2163a20 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -692,7 +692,7 @@
if (validate_oat_file) {
TimingLogger::ScopedTiming timing("ValidateOatFile", &logger);
CHECK(space->oat_file_ != nullptr);
- if (!ValidateOatFile(*space, *space->oat_file_, error_msg)) {
+ if (!ImageSpace::ValidateOatFile(*space->oat_file_, error_msg)) {
DCHECK(!error_msg->empty());
return nullptr;
}
@@ -1283,6 +1283,14 @@
}
dex_cache->FixupResolvedMethodTypes<kWithoutReadBarrier>(new_method_types, fixup_adapter);
}
+ GcRoot<mirror::CallSite>* call_sites = dex_cache->GetResolvedCallSites();
+ if (call_sites != nullptr) {
+ GcRoot<mirror::CallSite>* new_call_sites = fixup_adapter.ForwardObject(call_sites);
+ if (call_sites != new_call_sites) {
+ dex_cache->SetResolvedCallSites(new_call_sites);
+ }
+ dex_cache->FixupResolvedCallSites<kWithoutReadBarrier>(new_call_sites, fixup_adapter);
+ }
}
}
{
@@ -1379,33 +1387,6 @@
return oat_file;
}
-
- static bool ValidateOatFile(const ImageSpace& space,
- const OatFile& oat_file,
- std::string* error_msg) {
- for (const OatFile::OatDexFile* oat_dex_file : oat_file.GetOatDexFiles()) {
- const std::string& dex_file_location = oat_dex_file->GetDexFileLocation();
- uint32_t dex_file_location_checksum;
- if (!DexFile::GetChecksum(dex_file_location.c_str(), &dex_file_location_checksum, error_msg)) {
- *error_msg = StringPrintf("Failed to get checksum of dex file '%s' referenced by image %s: "
- "%s",
- dex_file_location.c_str(),
- space.GetName(),
- error_msg->c_str());
- return false;
- }
- if (dex_file_location_checksum != oat_dex_file->GetDexFileLocationChecksum()) {
- *error_msg = StringPrintf("ValidateOatFile found checksum mismatch between oat file '%s' and "
- "dex file '%s' (0x%x != 0x%x)",
- oat_file.GetLocation().c_str(),
- dex_file_location.c_str(),
- oat_dex_file->GetDexFileLocationChecksum(),
- dex_file_location_checksum);
- return false;
- }
- }
- return true;
- }
};
static constexpr uint64_t kLowSpaceValue = 50 * MB;
@@ -1782,6 +1763,63 @@
return bootcp_oss.str();
}
+bool ImageSpace::ValidateOatFile(const OatFile& oat_file, std::string* error_msg) {
+ for (const OatFile::OatDexFile* oat_dex_file : oat_file.GetOatDexFiles()) {
+ const std::string& dex_file_location = oat_dex_file->GetDexFileLocation();
+
+ // Skip multidex locations - These will be checked when we visit their
+ // corresponding primary non-multidex location.
+ if (DexFile::IsMultiDexLocation(dex_file_location.c_str())) {
+ continue;
+ }
+
+ std::vector<uint32_t> checksums;
+ if (!DexFile::GetMultiDexChecksums(dex_file_location.c_str(), &checksums, error_msg)) {
+ *error_msg = StringPrintf("ValidateOatFile failed to get checksums of dex file '%s' "
+ "referenced by oat file %s: %s",
+ dex_file_location.c_str(),
+ oat_file.GetLocation().c_str(),
+ error_msg->c_str());
+ return false;
+ }
+ CHECK(!checksums.empty());
+ if (checksums[0] != oat_dex_file->GetDexFileLocationChecksum()) {
+ *error_msg = StringPrintf("ValidateOatFile found checksum mismatch between oat file "
+ "'%s' and dex file '%s' (0x%x != 0x%x)",
+ oat_file.GetLocation().c_str(),
+ dex_file_location.c_str(),
+ oat_dex_file->GetDexFileLocationChecksum(),
+ checksums[0]);
+ return false;
+ }
+
+ // Verify checksums for any related multidex entries.
+ for (size_t i = 1; i < checksums.size(); i++) {
+ std::string multi_dex_location = DexFile::GetMultiDexLocation(i, dex_file_location.c_str());
+ const OatFile::OatDexFile* multi_dex = oat_file.GetOatDexFile(multi_dex_location.c_str(),
+ nullptr,
+ error_msg);
+ if (multi_dex == nullptr) {
+ *error_msg = StringPrintf("ValidateOatFile oat file '%s' is missing entry '%s'",
+ oat_file.GetLocation().c_str(),
+ multi_dex_location.c_str());
+ return false;
+ }
+
+ if (checksums[i] != multi_dex->GetDexFileLocationChecksum()) {
+ *error_msg = StringPrintf("ValidateOatFile found checksum mismatch between oat file "
+ "'%s' and dex file '%s' (0x%x != 0x%x)",
+ oat_file.GetLocation().c_str(),
+ multi_dex_location.c_str(),
+ multi_dex->GetDexFileLocationChecksum(),
+ checksums[i]);
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
void ImageSpace::ExtractMultiImageLocations(const std::string& input_image_file_name,
const std::string& boot_classpath,
std::vector<std::string>* image_file_names) {
diff --git a/runtime/gc/space/image_space.h b/runtime/gc/space/image_space.h
index 489a289..199bbdd 100644
--- a/runtime/gc/space/image_space.h
+++ b/runtime/gc/space/image_space.h
@@ -131,6 +131,17 @@
const std::vector<const char*>& oat_filenames,
const std::vector<const char*>& image_filenames);
+ // Returns true if the dex checksums in the given oat file match the
+ // checksums of the original dex files on disk. This is intended to be used
+ // to validate the boot image oat file, which may contain dex entries from
+ // multiple different (possibly multidex) dex files on disk. Prefer the
+ // OatFileAssistant for validating regular app oat files because the
+ // OatFileAssistant caches dex checksums that are reused to check both the
+ // oat and odex file.
+ //
+ // This function is exposed for testing purposes.
+ static bool ValidateOatFile(const OatFile& oat_file, std::string* error_msg);
+
// Return the end of the image which includes non-heap objects such as ArtMethods and ArtFields.
uint8_t* GetImageEnd() const {
return Begin() + GetImageHeader().GetImageSize();
diff --git a/runtime/gc/space/image_space_test.cc b/runtime/gc/space/image_space_test.cc
new file mode 100644
index 0000000..7a38074
--- /dev/null
+++ b/runtime/gc/space/image_space_test.cc
@@ -0,0 +1,111 @@
+/*
+ * 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.
+ */
+
+#include <gtest/gtest.h>
+
+#include "dexopt_test.h"
+
+namespace art {
+namespace gc {
+namespace space {
+
+TEST_F(DexoptTest, ValidateOatFile) {
+ std::string dex1 = GetScratchDir() + "/Dex1.jar";
+ std::string multidex1 = GetScratchDir() + "/MultiDex1.jar";
+ std::string dex2 = GetScratchDir() + "/Dex2.jar";
+ std::string oat_location = GetScratchDir() + "/Oat.oat";
+
+ Copy(GetDexSrc1(), dex1);
+ Copy(GetMultiDexSrc1(), multidex1);
+ Copy(GetDexSrc2(), dex2);
+
+ std::string error_msg;
+ std::vector<std::string> args;
+ args.push_back("--dex-file=" + dex1);
+ args.push_back("--dex-file=" + multidex1);
+ args.push_back("--dex-file=" + dex2);
+ args.push_back("--oat-file=" + oat_location);
+ ASSERT_TRUE(OatFileAssistant::Dex2Oat(args, &error_msg)) << error_msg;
+
+ std::unique_ptr<OatFile> oat(OatFile::Open(oat_location.c_str(),
+ oat_location.c_str(),
+ nullptr,
+ nullptr,
+ false,
+ /*low_4gb*/false,
+ nullptr,
+ &error_msg));
+ ASSERT_TRUE(oat != nullptr) << error_msg;
+
+ // Originally all the dex checksums should be up to date.
+ EXPECT_TRUE(ImageSpace::ValidateOatFile(*oat, &error_msg)) << error_msg;
+
+ // Invalidate the dex1 checksum.
+ Copy(GetDexSrc2(), dex1);
+ EXPECT_FALSE(ImageSpace::ValidateOatFile(*oat, &error_msg));
+
+ // Restore the dex1 checksum.
+ Copy(GetDexSrc1(), dex1);
+ EXPECT_TRUE(ImageSpace::ValidateOatFile(*oat, &error_msg)) << error_msg;
+
+ // Invalidate the non-main multidex checksum.
+ Copy(GetMultiDexSrc2(), multidex1);
+ EXPECT_FALSE(ImageSpace::ValidateOatFile(*oat, &error_msg));
+
+ // Restore the multidex checksum.
+ Copy(GetMultiDexSrc1(), multidex1);
+ EXPECT_TRUE(ImageSpace::ValidateOatFile(*oat, &error_msg)) << error_msg;
+
+ // Invalidate the dex2 checksum.
+ Copy(GetDexSrc1(), dex2);
+ EXPECT_FALSE(ImageSpace::ValidateOatFile(*oat, &error_msg));
+
+ // restore the dex2 checksum.
+ Copy(GetDexSrc2(), dex2);
+ EXPECT_TRUE(ImageSpace::ValidateOatFile(*oat, &error_msg)) << error_msg;
+
+ // Replace the multidex file with a non-multidex file.
+ Copy(GetDexSrc1(), multidex1);
+ EXPECT_FALSE(ImageSpace::ValidateOatFile(*oat, &error_msg));
+
+ // Restore the multidex file
+ Copy(GetMultiDexSrc1(), multidex1);
+ EXPECT_TRUE(ImageSpace::ValidateOatFile(*oat, &error_msg)) << error_msg;
+
+ // Replace dex1 with a multidex file.
+ Copy(GetMultiDexSrc1(), dex1);
+ EXPECT_FALSE(ImageSpace::ValidateOatFile(*oat, &error_msg));
+
+ // Restore the dex1 file.
+ Copy(GetDexSrc1(), dex1);
+ EXPECT_TRUE(ImageSpace::ValidateOatFile(*oat, &error_msg)) << error_msg;
+
+ // Remove the dex2 file.
+ EXPECT_EQ(0, unlink(dex2.c_str()));
+ EXPECT_FALSE(ImageSpace::ValidateOatFile(*oat, &error_msg));
+
+ // Restore the dex2 file.
+ Copy(GetDexSrc2(), dex2);
+ EXPECT_TRUE(ImageSpace::ValidateOatFile(*oat, &error_msg)) << error_msg;
+
+ // Remove the multidex file.
+ EXPECT_EQ(0, unlink(multidex1.c_str()));
+ EXPECT_FALSE(ImageSpace::ValidateOatFile(*oat, &error_msg));
+}
+
+} // namespace space
+} // namespace gc
+} // namespace art
diff --git a/runtime/gc/system_weak.h b/runtime/gc/system_weak.h
index e5cddfc..60105f4 100644
--- a/runtime/gc/system_weak.h
+++ b/runtime/gc/system_weak.h
@@ -82,7 +82,7 @@
(kUseReadBarrier && !self->GetWeakRefAccessEnabled()))) {
// Check and run the empty checkpoint before blocking so the empty checkpoint will work in the
// presence of threads blocking for weak ref access.
- self->CheckEmptyCheckpoint();
+ self->CheckEmptyCheckpointFromWeakRefAccess(&allow_disallow_lock_);
new_weak_condition_.WaitHoldingLocks(self);
}
}
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc
index 28bcb97..3d4a2d1 100644
--- a/runtime/interpreter/interpreter_common.cc
+++ b/runtime/interpreter/interpreter_common.cc
@@ -519,7 +519,7 @@
}
}
-template<bool is_range, bool do_access_check>
+template<bool is_range>
bool DoInvokePolymorphic(Thread* self,
ShadowFrame& shadow_frame,
const Instruction* inst,
@@ -539,8 +539,8 @@
// was symbolically invoked in bytecode (say MethodHandle.invoke or MethodHandle.invokeExact)
// and not the method that we'll dispatch to in the end.
StackHandleScope<5> hs(self);
- Handle<mirror::MethodHandleImpl> method_handle(hs.NewHandle(
- ObjPtr<mirror::MethodHandleImpl>::DownCast(
+ Handle<mirror::MethodHandle> method_handle(hs.NewHandle(
+ ObjPtr<mirror::MethodHandle>::DownCast(
MakeObjPtr(shadow_frame.GetVRegReference(vRegC)))));
if (UNLIKELY(method_handle.Get() == nullptr)) {
// Note that the invoke type is kVirtual here because a call to a signature
@@ -584,31 +584,300 @@
// VRegC is the register holding the method handle. Arguments passed
// to the method handle's target do not include the method handle.
uint32_t first_arg = inst->VRegC_4rcc() + 1;
- return DoInvokePolymorphic<is_range, do_access_check>(self,
- invoke_method,
- shadow_frame,
- method_handle,
- callsite_type,
- args /* unused */,
- first_arg,
- result);
+ return DoInvokePolymorphic<is_range>(self,
+ invoke_method,
+ shadow_frame,
+ method_handle,
+ callsite_type,
+ args /* unused */,
+ first_arg,
+ result);
} else {
// Get the register arguments for the invoke.
inst->GetVarArgs(args, inst_data);
// Drop the first register which is the method handle performing the invoke.
memmove(args, args + 1, sizeof(args[0]) * (Instruction::kMaxVarArgRegs - 1));
args[Instruction::kMaxVarArgRegs - 1] = 0;
- return DoInvokePolymorphic<is_range, do_access_check>(self,
- invoke_method,
- shadow_frame,
- method_handle,
- callsite_type,
- args,
- args[0],
- result);
+ return DoInvokePolymorphic<is_range>(self,
+ invoke_method,
+ shadow_frame,
+ method_handle,
+ callsite_type,
+ args,
+ args[0],
+ result);
}
}
+static ObjPtr<mirror::CallSite> InvokeBootstrapMethod(Thread* self,
+ ShadowFrame& shadow_frame,
+ uint32_t call_site_idx)
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ ArtMethod* referrer = shadow_frame.GetMethod();
+ const DexFile* dex_file = referrer->GetDexFile();
+ const DexFile::CallSiteIdItem& csi = dex_file->GetCallSiteId(call_site_idx);
+
+ StackHandleScope<9> hs(self);
+ Handle<mirror::ClassLoader> class_loader(hs.NewHandle(referrer->GetClassLoader()));
+ Handle<mirror::DexCache> dex_cache(hs.NewHandle(referrer->GetDexCache()));
+
+ CallSiteArrayValueIterator it(*dex_file, csi);
+ uint32_t method_handle_idx = static_cast<uint32_t>(it.GetJavaValue().i);
+ ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
+ Handle<mirror::MethodHandle>
+ bootstrap(hs.NewHandle(class_linker->ResolveMethodHandle(method_handle_idx, referrer)));
+ if (bootstrap.IsNull()) {
+ DCHECK(self->IsExceptionPending());
+ return nullptr;
+ }
+ Handle<mirror::MethodType> bootstrap_method_type = hs.NewHandle(bootstrap->GetMethodType());
+ it.Next();
+
+ DCHECK_EQ(static_cast<size_t>(bootstrap->GetMethodType()->GetPTypes()->GetLength()), it.Size());
+ const size_t num_bootstrap_vregs = bootstrap->GetMethodType()->NumberOfVRegs();
+
+ // Set-up a shadow frame for invoking the bootstrap method handle.
+ ShadowFrameAllocaUniquePtr bootstrap_frame =
+ CREATE_SHADOW_FRAME(num_bootstrap_vregs, nullptr, referrer, shadow_frame.GetDexPC());
+ ScopedStackedShadowFramePusher pusher(
+ self, bootstrap_frame.get(), StackedShadowFrameType::kShadowFrameUnderConstruction);
+ size_t vreg = 0;
+
+ // The first parameter is a MethodHandles lookup instance.
+ {
+ Handle<mirror::Class> lookup_class(hs.NewHandle(bootstrap->GetTargetClass()));
+ ObjPtr<mirror::MethodHandlesLookup> lookup =
+ mirror::MethodHandlesLookup::Create(self, lookup_class);
+ if (lookup.IsNull()) {
+ DCHECK(self->IsExceptionPending());
+ return nullptr;
+ }
+ bootstrap_frame->SetVRegReference(vreg++, lookup.Ptr());
+ }
+
+ // The second parameter is the name to lookup.
+ {
+ dex::StringIndex name_idx(static_cast<uint32_t>(it.GetJavaValue().i));
+ ObjPtr<mirror::String> name = class_linker->ResolveString(*dex_file, name_idx, dex_cache);
+ if (name.IsNull()) {
+ DCHECK(self->IsExceptionPending());
+ return nullptr;
+ }
+ bootstrap_frame->SetVRegReference(vreg++, name.Ptr());
+ }
+ it.Next();
+
+ // The third parameter is the method type associated with the name.
+ uint32_t method_type_idx = static_cast<uint32_t>(it.GetJavaValue().i);
+ Handle<mirror::MethodType>
+ method_type(hs.NewHandle(class_linker->ResolveMethodType(*dex_file,
+ method_type_idx,
+ dex_cache,
+ class_loader)));
+ if (method_type.IsNull()) {
+ DCHECK(self->IsExceptionPending());
+ return nullptr;
+ }
+ bootstrap_frame->SetVRegReference(vreg++, method_type.Get());
+ it.Next();
+
+ // Append remaining arguments (if any).
+ while (it.HasNext()) {
+ const jvalue& jvalue = it.GetJavaValue();
+ switch (it.GetValueType()) {
+ case EncodedArrayValueIterator::ValueType::kBoolean:
+ case EncodedArrayValueIterator::ValueType::kByte:
+ case EncodedArrayValueIterator::ValueType::kChar:
+ case EncodedArrayValueIterator::ValueType::kShort:
+ case EncodedArrayValueIterator::ValueType::kInt:
+ bootstrap_frame->SetVReg(vreg, jvalue.i);
+ vreg += 1;
+ break;
+ case EncodedArrayValueIterator::ValueType::kLong:
+ bootstrap_frame->SetVRegLong(vreg, jvalue.j);
+ vreg += 2;
+ break;
+ case EncodedArrayValueIterator::ValueType::kFloat:
+ bootstrap_frame->SetVRegFloat(vreg, jvalue.f);
+ vreg += 1;
+ break;
+ case EncodedArrayValueIterator::ValueType::kDouble:
+ bootstrap_frame->SetVRegDouble(vreg, jvalue.d);
+ vreg += 2;
+ break;
+ case EncodedArrayValueIterator::ValueType::kMethodType: {
+ uint32_t idx = static_cast<uint32_t>(jvalue.i);
+ ObjPtr<mirror::MethodType> ref =
+ class_linker->ResolveMethodType(*dex_file, idx, dex_cache, class_loader);
+ if (ref.IsNull()) {
+ DCHECK(self->IsExceptionPending());
+ return nullptr;
+ }
+ bootstrap_frame->SetVRegReference(vreg, ref.Ptr());
+ vreg += 1;
+ break;
+ }
+ case EncodedArrayValueIterator::ValueType::kMethodHandle: {
+ uint32_t idx = static_cast<uint32_t>(jvalue.i);
+ ObjPtr<mirror::MethodHandle> ref =
+ class_linker->ResolveMethodHandle(idx, referrer);
+ if (ref.IsNull()) {
+ DCHECK(self->IsExceptionPending());
+ return nullptr;
+ }
+ bootstrap_frame->SetVRegReference(vreg, ref.Ptr());
+ vreg += 1;
+ break;
+ }
+ case EncodedArrayValueIterator::ValueType::kString: {
+ dex::StringIndex idx(static_cast<uint32_t>(jvalue.i));
+ ObjPtr<mirror::String> ref = class_linker->ResolveString(*dex_file, idx, dex_cache);
+ if (ref.IsNull()) {
+ DCHECK(self->IsExceptionPending());
+ return nullptr;
+ }
+ bootstrap_frame->SetVRegReference(vreg, ref.Ptr());
+ vreg += 1;
+ break;
+ }
+ case EncodedArrayValueIterator::ValueType::kType: {
+ dex::TypeIndex idx(static_cast<uint32_t>(jvalue.i));
+ ObjPtr<mirror::Class> ref =
+ class_linker->ResolveType(*dex_file, idx, dex_cache, class_loader);
+ if (ref.IsNull()) {
+ DCHECK(self->IsExceptionPending());
+ return nullptr;
+ }
+ bootstrap_frame->SetVRegReference(vreg, ref.Ptr());
+ vreg += 1;
+ break;
+ }
+ case EncodedArrayValueIterator::ValueType::kNull:
+ bootstrap_frame->SetVRegReference(vreg, nullptr);
+ vreg += 1;
+ break;
+ case EncodedArrayValueIterator::ValueType::kField:
+ case EncodedArrayValueIterator::ValueType::kMethod:
+ case EncodedArrayValueIterator::ValueType::kEnum:
+ case EncodedArrayValueIterator::ValueType::kArray:
+ case EncodedArrayValueIterator::ValueType::kAnnotation:
+ // Unreachable based on current EncodedArrayValueIterator::Next().
+ UNREACHABLE();
+ }
+
+ it.Next();
+ }
+
+ // Invoke the bootstrap method handle.
+ JValue result;
+
+ // This array of arguments is unused. DoInvokePolymorphic() operates on either a
+ // an argument array or a range, but always takes an array argument.
+ uint32_t args_unused[Instruction::kMaxVarArgRegs];
+ ArtMethod* invoke_exact =
+ jni::DecodeArtMethod(WellKnownClasses::java_lang_invoke_MethodHandle_invokeExact);
+ bool invoke_success = DoInvokePolymorphic<true /* is_range */>(self,
+ invoke_exact,
+ *bootstrap_frame,
+ bootstrap,
+ bootstrap_method_type,
+ args_unused,
+ 0,
+ &result);
+ if (!invoke_success) {
+ DCHECK(self->IsExceptionPending());
+ return nullptr;
+ }
+
+ Handle<mirror::Object> object(hs.NewHandle(result.GetL()));
+
+ // Check the result is not null.
+ if (UNLIKELY(object.IsNull())) {
+ ThrowNullPointerException("CallSite == null");
+ return nullptr;
+ }
+
+ // Check the result type is a subclass of CallSite.
+ if (UNLIKELY(!object->InstanceOf(mirror::CallSite::StaticClass()))) {
+ ThrowClassCastException(object->GetClass(), mirror::CallSite::StaticClass());
+ return nullptr;
+ }
+
+ Handle<mirror::CallSite> call_site =
+ hs.NewHandle(ObjPtr<mirror::CallSite>::DownCast(ObjPtr<mirror::Object>(result.GetL())));
+
+ // Check the call site target is not null as we're going to invoke it.
+ Handle<mirror::MethodHandle> target = hs.NewHandle(call_site->GetTarget());
+ if (UNLIKELY(target.IsNull())) {
+ ThrowNullPointerException("CallSite target == null");
+ return nullptr;
+ }
+
+ // Check the target method type matches the method type requested.
+ if (UNLIKELY(!target->GetMethodType()->IsExactMatch(method_type.Get()))) {
+ ThrowWrongMethodTypeException(target->GetMethodType(), method_type.Get());
+ return nullptr;
+ }
+
+ return call_site.Get();
+}
+
+template<bool is_range>
+bool DoInvokeCustom(Thread* self,
+ ShadowFrame& shadow_frame,
+ const Instruction* inst,
+ uint16_t inst_data,
+ JValue* result)
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ // invoke-custom is not supported in transactions. In transactions
+ // there is a limited set of types supported. invoke-custom allows
+ // running arbitrary code and instantiating arbitrary types.
+ CHECK(!Runtime::Current()->IsActiveTransaction());
+ StackHandleScope<4> hs(self);
+ Handle<mirror::DexCache> dex_cache(hs.NewHandle(shadow_frame.GetMethod()->GetDexCache()));
+ const uint32_t call_site_idx = is_range ? inst->VRegB_3rc() : inst->VRegB_35c();
+ MutableHandle<mirror::CallSite>
+ call_site(hs.NewHandle(dex_cache->GetResolvedCallSite(call_site_idx)));
+ if (call_site.IsNull()) {
+ call_site.Assign(InvokeBootstrapMethod(self, shadow_frame, call_site_idx));
+ if (UNLIKELY(call_site.IsNull())) {
+ CHECK(self->IsExceptionPending());
+ ThrowWrappedBootstrapMethodError("Exception from call site #%u bootstrap method",
+ call_site_idx);
+ result->SetJ(0);
+ return false;
+ }
+ mirror::CallSite* winning_call_site =
+ dex_cache->SetResolvedCallSite(call_site_idx, call_site.Get());
+ call_site.Assign(winning_call_site);
+ }
+
+ // CallSite.java checks the re-assignment of the call site target
+ // when mutating call site targets. We only check the target is
+ // non-null and has the right type during bootstrap method execution.
+ Handle<mirror::MethodHandle> target = hs.NewHandle(call_site->GetTarget());
+ Handle<mirror::MethodType> target_method_type = hs.NewHandle(target->GetMethodType());
+ DCHECK_EQ(static_cast<size_t>(inst->VRegA()), target_method_type->NumberOfVRegs());
+
+ uint32_t args[Instruction::kMaxVarArgRegs];
+ if (is_range) {
+ args[0] = inst->VRegC_3rc();
+ } else {
+ inst->GetVarArgs(args, inst_data);
+ }
+
+ ArtMethod* invoke_exact =
+ jni::DecodeArtMethod(WellKnownClasses::java_lang_invoke_MethodHandle_invokeExact);
+ return DoInvokePolymorphic<is_range>(self,
+ invoke_exact,
+ shadow_frame,
+ target,
+ target_method_type,
+ args,
+ args[0],
+ result);
+}
+
template <bool is_range>
inline void CopyRegisters(ShadowFrame& caller_frame,
ShadowFrame* callee_frame,
@@ -975,17 +1244,24 @@
EXPLICIT_DO_CALL_TEMPLATE_DECL(true, true);
#undef EXPLICIT_DO_CALL_TEMPLATE_DECL
-// Explicit DoInvokePolymorphic template function declarations.
-#define EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(_is_range, _do_assignability_check) \
- template REQUIRES_SHARED(Locks::mutator_lock_) \
- bool DoInvokePolymorphic<_is_range, _do_assignability_check>( \
- Thread* self, ShadowFrame& shadow_frame, const Instruction* inst, \
+// Explicit DoInvokeCustom template function declarations.
+#define EXPLICIT_DO_INVOKE_CUSTOM_TEMPLATE_DECL(_is_range) \
+ template REQUIRES_SHARED(Locks::mutator_lock_) \
+ bool DoInvokeCustom<_is_range>( \
+ Thread* self, ShadowFrame& shadow_frame, const Instruction* inst, \
uint16_t inst_data, JValue* result)
+EXPLICIT_DO_INVOKE_CUSTOM_TEMPLATE_DECL(false);
+EXPLICIT_DO_INVOKE_CUSTOM_TEMPLATE_DECL(true);
+#undef EXPLICIT_DO_INVOKE_CUSTOM_TEMPLATE_DECL
-EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(false, false);
-EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(false, true);
-EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(true, false);
-EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(true, true);
+// Explicit DoInvokePolymorphic template function declarations.
+#define EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(_is_range) \
+ template REQUIRES_SHARED(Locks::mutator_lock_) \
+ bool DoInvokePolymorphic<_is_range>( \
+ Thread* self, ShadowFrame& shadow_frame, const Instruction* inst, \
+ uint16_t inst_data, JValue* result)
+EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(false);
+EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(true);
#undef EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL
// Explicit DoFilledNewArray template function declarations.
diff --git a/runtime/interpreter/interpreter_common.h b/runtime/interpreter/interpreter_common.h
index 7ef3508..6b22af9 100644
--- a/runtime/interpreter/interpreter_common.h
+++ b/runtime/interpreter/interpreter_common.h
@@ -40,9 +40,11 @@
#include "entrypoints/entrypoint_utils-inl.h"
#include "handle_scope-inl.h"
#include "jit/jit.h"
+#include "mirror/call_site.h"
#include "mirror/class-inl.h"
#include "mirror/dex_cache.h"
#include "mirror/method.h"
+#include "mirror/method_handles_lookup.h"
#include "mirror/object-inl.h"
#include "mirror/object_array-inl.h"
#include "mirror/string-inl.h"
@@ -154,13 +156,21 @@
}
// Performs a signature polymorphic invoke (invoke-polymorphic/invoke-polymorphic-range).
-template<bool is_range, bool do_access_check>
+template<bool is_range>
bool DoInvokePolymorphic(Thread* self,
ShadowFrame& shadow_frame,
const Instruction* inst,
uint16_t inst_data,
JValue* result);
+// Performs a custom invoke (invoke-custom/invoke-custom-range).
+template<bool is_range>
+bool DoInvokeCustom(Thread* self,
+ ShadowFrame& shadow_frame,
+ const Instruction* inst,
+ uint16_t inst_data,
+ JValue* result);
+
// Handles invoke-virtual-quick and invoke-virtual-quick-range instructions.
// Returns true on success, otherwise throws an exception and returns false.
template<bool is_range>
diff --git a/runtime/interpreter/interpreter_switch_impl.cc b/runtime/interpreter/interpreter_switch_impl.cc
index a77a3fc..b191dd7 100644
--- a/runtime/interpreter/interpreter_switch_impl.cc
+++ b/runtime/interpreter/interpreter_switch_impl.cc
@@ -1524,7 +1524,7 @@
case Instruction::INVOKE_POLYMORPHIC: {
PREAMBLE();
DCHECK(Runtime::Current()->IsMethodHandlesEnabled());
- bool success = DoInvokePolymorphic<false, do_access_check>(
+ bool success = DoInvokePolymorphic<false /* is_range */>(
self, shadow_frame, inst, inst_data, &result_register);
POSSIBLY_HANDLE_PENDING_EXCEPTION(!success, Next_4xx);
break;
@@ -1532,11 +1532,27 @@
case Instruction::INVOKE_POLYMORPHIC_RANGE: {
PREAMBLE();
DCHECK(Runtime::Current()->IsMethodHandlesEnabled());
- bool success = DoInvokePolymorphic<true, do_access_check>(
+ bool success = DoInvokePolymorphic<true /* is_range */>(
self, shadow_frame, inst, inst_data, &result_register);
POSSIBLY_HANDLE_PENDING_EXCEPTION(!success, Next_4xx);
break;
}
+ case Instruction::INVOKE_CUSTOM: {
+ PREAMBLE();
+ DCHECK(Runtime::Current()->IsMethodHandlesEnabled());
+ bool success = DoInvokeCustom<false /* is_range */>(
+ self, shadow_frame, inst, inst_data, &result_register);
+ POSSIBLY_HANDLE_PENDING_EXCEPTION(!success, Next_3xx);
+ break;
+ }
+ case Instruction::INVOKE_CUSTOM_RANGE: {
+ PREAMBLE();
+ DCHECK(Runtime::Current()->IsMethodHandlesEnabled());
+ bool success = DoInvokeCustom<true /* is_range */>(
+ self, shadow_frame, inst, inst_data, &result_register);
+ POSSIBLY_HANDLE_PENDING_EXCEPTION(!success, Next_3xx);
+ break;
+ }
case Instruction::NEG_INT:
PREAMBLE();
shadow_frame.SetVReg(
@@ -2315,7 +2331,7 @@
break;
case Instruction::UNUSED_3E ... Instruction::UNUSED_43:
case Instruction::UNUSED_F3 ... Instruction::UNUSED_F9:
- case Instruction::UNUSED_FC ... Instruction::UNUSED_FF:
+ case Instruction::UNUSED_FE ... Instruction::UNUSED_FF:
case Instruction::UNUSED_79:
case Instruction::UNUSED_7A:
UnexpectedOpcode(inst, shadow_frame);
diff --git a/runtime/java_vm_ext.cc b/runtime/java_vm_ext.cc
index e0f28ad..a341cdb 100644
--- a/runtime/java_vm_ext.cc
+++ b/runtime/java_vm_ext.cc
@@ -572,7 +572,7 @@
while (!kUseReadBarrier && UNLIKELY(!MayAccessWeakGlobals(self))) {
// Check and run the empty checkpoint before blocking so the empty checkpoint will work in the
// presence of threads blocking for weak ref access.
- self->CheckEmptyCheckpoint();
+ self->CheckEmptyCheckpointFromWeakRefAccess(Locks::jni_weak_globals_lock_);
weak_globals_add_condition_.WaitHoldingLocks(self);
}
IndirectRef ref = weak_globals_.Add(kIRTFirstSegment, obj);
@@ -706,7 +706,7 @@
while (UNLIKELY(!MayAccessWeakGlobals(self))) {
// Check and run the empty checkpoint before blocking so the empty checkpoint will work in the
// presence of threads blocking for weak ref access.
- self->CheckEmptyCheckpoint();
+ self->CheckEmptyCheckpointFromWeakRefAccess(Locks::jni_weak_globals_lock_);
weak_globals_add_condition_.WaitHoldingLocks(self);
}
return weak_globals_.Get(ref);
@@ -731,7 +731,7 @@
while (UNLIKELY(!MayAccessWeakGlobals(self))) {
// Check and run the empty checkpoint before blocking so the empty checkpoint will work in the
// presence of threads blocking for weak ref access.
- self->CheckEmptyCheckpoint();
+ self->CheckEmptyCheckpointFromWeakRefAccess(Locks::jni_weak_globals_lock_);
weak_globals_add_condition_.WaitHoldingLocks(self);
}
// When just checking a weak ref has been cleared, avoid triggering the read barrier in decode
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index f5151b5..60ab275 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -556,12 +556,13 @@
// Flush data cache, as compiled code references literals in it.
FlushDataCache(reinterpret_cast<char*>(roots_data),
reinterpret_cast<char*>(roots_data + data_size));
- // Flush caches before we remove write permission because on some ARMv8 hardware,
- // flushing caches require write permissions.
+ // Flush caches before we remove write permission because some ARMv8 Qualcomm kernels may
+ // trigger a segfault if a page fault occurs when requesting a cache maintenance operation.
+ // This is a kernel bug that we need to work around until affected devices (e.g. Nexus 5X and
+ // 6P) stop being supported or their kernels are fixed.
//
- // For reference, here are kernel patches discussing about this issue:
- // https://android.googlesource.com/kernel/msm/%2B/0e7f7bcc3fc87489cda5aa6aff8ce40eed912279
- // https://patchwork.kernel.org/patch/9047921/
+ // For reference, this behavior is caused by this commit:
+ // https://android.googlesource.com/kernel/msm/+/3fbe6bc28a6b9939d0650f2f17eb5216c719950c
FlushInstructionCache(reinterpret_cast<char*>(code_ptr),
reinterpret_cast<char*>(code_ptr + code_size));
DCHECK(!Runtime::Current()->IsAotCompiler());
@@ -685,6 +686,10 @@
// shouldn't be used since it is no longer logically in the jit code cache.
// TODO We should add DCHECKS that validate that the JIT is paused when this method is entered.
void JitCodeCache::MoveObsoleteMethod(ArtMethod* old_method, ArtMethod* new_method) {
+ // Native methods have no profiling info and need no special handling from the JIT code cache.
+ if (old_method->IsNative()) {
+ return;
+ }
MutexLock mu(Thread::Current(), lock_);
// Update ProfilingInfo to the new one and remove it from the old_method.
if (old_method->GetProfilingInfo(kRuntimePointerSize) != nullptr) {
diff --git a/runtime/method_handles.cc b/runtime/method_handles.cc
index 99886e5..9825ad6 100644
--- a/runtime/method_handles.cc
+++ b/runtime/method_handles.cc
@@ -555,7 +555,7 @@
Handle<mirror::MethodType> callee_type,
Thread* self,
ShadowFrame& shadow_frame,
- Handle<mirror::MethodHandleImpl> receiver,
+ Handle<mirror::MethodHandle> receiver,
const uint32_t (&args)[Instruction::kMaxVarArgRegs],
uint32_t first_arg,
JValue* result)
@@ -645,7 +645,7 @@
template <bool is_range>
bool DoInvokePolymorphicUnchecked(Thread* self,
ShadowFrame& shadow_frame,
- Handle<mirror::MethodHandleImpl> method_handle,
+ Handle<mirror::MethodHandle> method_handle,
Handle<mirror::MethodType> callsite_type,
const uint32_t (&args)[Instruction::kMaxVarArgRegs],
uint32_t first_arg,
@@ -780,7 +780,6 @@
}
// Helper for setters in invoke-polymorphic.
-template <bool do_assignability_check>
inline bool DoFieldPutForInvokePolymorphic(Thread* self,
ShadowFrame& shadow_frame,
ObjPtr<mirror::Object>& obj,
@@ -788,30 +787,33 @@
Primitive::Type field_type,
const JValue& value)
REQUIRES_SHARED(Locks::mutator_lock_) {
- static const bool kTransaction = false;
+ DCHECK(!Runtime::Current()->IsActiveTransaction());
+ static const bool kTransaction = false; // Not in a transaction.
+ static const bool kAssignabilityCheck = false; // No access check.
switch (field_type) {
case Primitive::kPrimBoolean:
- return DoFieldPutCommon<Primitive::kPrimBoolean, do_assignability_check, kTransaction>(
- self, shadow_frame, obj, field, value);
+ return
+ DoFieldPutCommon<Primitive::kPrimBoolean, kAssignabilityCheck, kTransaction>(
+ self, shadow_frame, obj, field, value);
case Primitive::kPrimByte:
- return DoFieldPutCommon<Primitive::kPrimByte, do_assignability_check, kTransaction>(
+ return DoFieldPutCommon<Primitive::kPrimByte, kAssignabilityCheck, kTransaction>(
self, shadow_frame, obj, field, value);
case Primitive::kPrimChar:
- return DoFieldPutCommon<Primitive::kPrimChar, do_assignability_check, kTransaction>(
+ return DoFieldPutCommon<Primitive::kPrimChar, kAssignabilityCheck, kTransaction>(
self, shadow_frame, obj, field, value);
case Primitive::kPrimShort:
- return DoFieldPutCommon<Primitive::kPrimShort, do_assignability_check, kTransaction>(
+ return DoFieldPutCommon<Primitive::kPrimShort, kAssignabilityCheck, kTransaction>(
self, shadow_frame, obj, field, value);
case Primitive::kPrimInt:
case Primitive::kPrimFloat:
- return DoFieldPutCommon<Primitive::kPrimInt, do_assignability_check, kTransaction>(
+ return DoFieldPutCommon<Primitive::kPrimInt, kAssignabilityCheck, kTransaction>(
self, shadow_frame, obj, field, value);
case Primitive::kPrimLong:
case Primitive::kPrimDouble:
- return DoFieldPutCommon<Primitive::kPrimLong, do_assignability_check, kTransaction>(
+ return DoFieldPutCommon<Primitive::kPrimLong, kAssignabilityCheck, kTransaction>(
self, shadow_frame, obj, field, value);
case Primitive::kPrimNot:
- return DoFieldPutCommon<Primitive::kPrimNot, do_assignability_check, kTransaction>(
+ return DoFieldPutCommon<Primitive::kPrimNot, kAssignabilityCheck, kTransaction>(
self, shadow_frame, obj, field, value);
case Primitive::kPrimVoid:
LOG(FATAL) << "Unreachable: " << field_type;
@@ -855,10 +857,10 @@
return field_value;
}
-template <bool is_range, bool do_conversions, bool do_assignability_check>
+template <bool is_range, bool do_conversions>
bool DoInvokePolymorphicFieldAccess(Thread* self,
ShadowFrame& shadow_frame,
- Handle<mirror::MethodHandleImpl> method_handle,
+ Handle<mirror::MethodHandle> method_handle,
Handle<mirror::MethodType> callsite_type,
const uint32_t (&args)[Instruction::kMaxVarArgRegs],
uint32_t first_arg,
@@ -903,12 +905,7 @@
return false;
}
ObjPtr<mirror::Object> obj = shadow_frame.GetVRegReference(obj_reg);
- return DoFieldPutForInvokePolymorphic<do_assignability_check>(self,
- shadow_frame,
- obj,
- field,
- field_type,
- value);
+ return DoFieldPutForInvokePolymorphic(self, shadow_frame, obj, field, field_type, value);
}
case mirror::MethodHandle::kStaticPut: {
ObjPtr<mirror::Object> obj = GetAndInitializeDeclaringClass(self, field);
@@ -922,12 +919,7 @@
DCHECK(self->IsExceptionPending());
return false;
}
- return DoFieldPutForInvokePolymorphic<do_assignability_check>(self,
- shadow_frame,
- obj,
- field,
- field_type,
- value);
+ return DoFieldPutForInvokePolymorphic(self, shadow_frame, obj, field, field_type, value);
}
default:
LOG(FATAL) << "Unreachable: " << handle_kind;
@@ -935,10 +927,10 @@
}
}
-template <bool is_range, bool do_assignability_check>
+template <bool is_range>
static inline bool DoInvokePolymorphicNonExact(Thread* self,
ShadowFrame& shadow_frame,
- Handle<mirror::MethodHandleImpl> method_handle,
+ Handle<mirror::MethodHandle> method_handle,
Handle<mirror::MethodType> callsite_type,
const uint32_t (&args)[Instruction::kMaxVarArgRegs],
uint32_t first_arg,
@@ -959,7 +951,7 @@
if (IsFieldAccess(handle_kind)) {
if (UNLIKELY(callsite_type->IsExactMatch(handle_type.Ptr()))) {
const bool do_convert = false;
- return DoInvokePolymorphicFieldAccess<is_range, do_convert, do_assignability_check>(
+ return DoInvokePolymorphicFieldAccess<is_range, do_convert>(
self,
shadow_frame,
method_handle,
@@ -969,7 +961,7 @@
result);
} else {
const bool do_convert = true;
- return DoInvokePolymorphicFieldAccess<is_range, do_convert, do_assignability_check>(
+ return DoInvokePolymorphicFieldAccess<is_range, do_convert>(
self,
shadow_frame,
method_handle,
@@ -999,10 +991,10 @@
}
}
-template <bool is_range, bool do_assignability_check>
+template <bool is_range>
bool DoInvokePolymorphicExact(Thread* self,
ShadowFrame& shadow_frame,
- Handle<mirror::MethodHandleImpl> method_handle,
+ Handle<mirror::MethodHandle> method_handle,
Handle<mirror::MethodType> callsite_type,
const uint32_t (&args)[Instruction::kMaxVarArgRegs],
uint32_t first_arg,
@@ -1018,13 +1010,13 @@
ThrowWrongMethodTypeException(nominal_type.Ptr(), callsite_type.Get());
return false;
}
- return DoInvokePolymorphicNonExact<is_range, do_assignability_check>(self,
- shadow_frame,
- method_handle,
- callsite_type,
- args,
- first_arg,
- result);
+ return DoInvokePolymorphicNonExact<is_range>(self,
+ shadow_frame,
+ method_handle,
+ callsite_type,
+ args,
+ first_arg,
+ result);
}
ObjPtr<mirror::MethodType> handle_type(method_handle->GetMethodType());
@@ -1036,7 +1028,7 @@
const mirror::MethodHandle::Kind handle_kind = method_handle->GetHandleKind();
if (IsFieldAccess(handle_kind)) {
const bool do_convert = false;
- return DoInvokePolymorphicFieldAccess<is_range, do_convert, do_assignability_check>(
+ return DoInvokePolymorphicFieldAccess<is_range, do_convert>(
self,
shadow_frame,
method_handle,
@@ -1057,51 +1049,49 @@
} // namespace
-template <bool is_range, bool do_assignability_check>
+template <bool is_range>
bool DoInvokePolymorphic(Thread* self,
ArtMethod* invoke_method,
ShadowFrame& shadow_frame,
- Handle<mirror::MethodHandleImpl> method_handle,
+ Handle<mirror::MethodHandle> method_handle,
Handle<mirror::MethodType> callsite_type,
const uint32_t (&args)[Instruction::kMaxVarArgRegs],
uint32_t first_arg,
JValue* result)
REQUIRES_SHARED(Locks::mutator_lock_) {
if (IsMethodHandleInvokeExact(invoke_method)) {
- return DoInvokePolymorphicExact<is_range, do_assignability_check>(self,
- shadow_frame,
- method_handle,
- callsite_type,
- args,
- first_arg,
- result);
+ return DoInvokePolymorphicExact<is_range>(self,
+ shadow_frame,
+ method_handle,
+ callsite_type,
+ args,
+ first_arg,
+ result);
} else {
- return DoInvokePolymorphicNonExact<is_range, do_assignability_check>(self,
- shadow_frame,
- method_handle,
- callsite_type,
- args,
- first_arg,
- result);
+ return DoInvokePolymorphicNonExact<is_range>(self,
+ shadow_frame,
+ method_handle,
+ callsite_type,
+ args,
+ first_arg,
+ result);
}
}
-#define EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(_is_range, _do_assignability_check) \
-template REQUIRES_SHARED(Locks::mutator_lock_) \
-bool DoInvokePolymorphic<_is_range, _do_assignability_check>( \
- Thread* self, \
- ArtMethod* invoke_method, \
- ShadowFrame& shadow_frame, \
- Handle<mirror::MethodHandleImpl> method_handle, \
- Handle<mirror::MethodType> callsite_type, \
- const uint32_t (&args)[Instruction::kMaxVarArgRegs], \
- uint32_t first_arg, \
- JValue* result)
+#define EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(_is_range) \
+ template REQUIRES_SHARED(Locks::mutator_lock_) \
+ bool DoInvokePolymorphic<_is_range>( \
+ Thread* self, \
+ ArtMethod* invoke_method, \
+ ShadowFrame& shadow_frame, \
+ Handle<mirror::MethodHandle> method_handle, \
+ Handle<mirror::MethodType> callsite_type, \
+ const uint32_t (&args)[Instruction::kMaxVarArgRegs], \
+ uint32_t first_arg, \
+ JValue* result)
-EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(true, true);
-EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(true, false);
-EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(false, true);
-EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(false, false);
+EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(true);
+EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(false);
#undef EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL
} // namespace art
diff --git a/runtime/method_handles.h b/runtime/method_handles.h
index 734d7c7..5bea0ab 100644
--- a/runtime/method_handles.h
+++ b/runtime/method_handles.h
@@ -27,7 +27,7 @@
namespace art {
namespace mirror {
- class MethodHandleImpl;
+ class MethodHandle;
class MethodType;
} // mirror
@@ -202,11 +202,11 @@
size_t arg_index_;
};
-template <bool is_range, bool do_assignability_check>
+template <bool is_range>
bool DoInvokePolymorphic(Thread* self,
ArtMethod* invoke_method,
ShadowFrame& shadow_frame,
- Handle<mirror::MethodHandleImpl> method_handle,
+ Handle<mirror::MethodHandle> method_handle,
Handle<mirror::MethodType> callsite_type,
const uint32_t (&args)[Instruction::kMaxVarArgRegs],
uint32_t first_arg,
diff --git a/runtime/mirror/call_site.cc b/runtime/mirror/call_site.cc
new file mode 100644
index 0000000..eb613df
--- /dev/null
+++ b/runtime/mirror/call_site.cc
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+#include "call_site.h"
+
+#include "class-inl.h"
+#include "gc_root-inl.h"
+
+namespace art {
+namespace mirror {
+
+GcRoot<mirror::Class> CallSite::static_class_;
+
+mirror::CallSite* CallSite::Create(Thread* const self, Handle<MethodHandle> target) {
+ StackHandleScope<1> hs(self);
+ Handle<mirror::CallSite> cs(
+ hs.NewHandle(ObjPtr<CallSite>::DownCast(StaticClass()->AllocObject(self))));
+ CHECK(!Runtime::Current()->IsActiveTransaction());
+ cs->SetFieldObject<false>(TargetOffset(), target.Get());
+ return cs.Get();
+}
+
+void CallSite::SetClass(Class* klass) {
+ CHECK(static_class_.IsNull()) << static_class_.Read() << " " << klass;
+ CHECK(klass != nullptr);
+ static_class_ = GcRoot<Class>(klass);
+}
+
+void CallSite::ResetClass() {
+ CHECK(!static_class_.IsNull());
+ static_class_ = GcRoot<Class>(nullptr);
+}
+
+void CallSite::VisitRoots(RootVisitor* visitor) {
+ static_class_.VisitRootIfNonNull(visitor, RootInfo(kRootStickyClass));
+}
+
+} // namespace mirror
+} // namespace art
diff --git a/runtime/mirror/call_site.h b/runtime/mirror/call_site.h
new file mode 100644
index 0000000..db244a5
--- /dev/null
+++ b/runtime/mirror/call_site.h
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+
+#ifndef ART_RUNTIME_MIRROR_CALL_SITE_H_
+#define ART_RUNTIME_MIRROR_CALL_SITE_H_
+
+#include "mirror/method_handle_impl.h"
+#include "utils.h"
+
+namespace art {
+
+struct CallSiteOffsets;
+
+namespace mirror {
+
+// C++ mirror of java.lang.invoke.CallSite
+class MANAGED CallSite : public Object {
+ public:
+ static mirror::CallSite* Create(Thread* const self,
+ Handle<MethodHandle> method_handle)
+ REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
+
+ static mirror::Class* StaticClass() REQUIRES_SHARED(Locks::mutator_lock_) {
+ return static_class_.Read();
+ }
+
+ MethodHandle* GetTarget() REQUIRES_SHARED(Locks::mutator_lock_) {
+ return GetFieldObject<MethodHandle>(TargetOffset());
+ }
+
+ static void SetClass(Class* klass) REQUIRES_SHARED(Locks::mutator_lock_);
+ static void ResetClass() REQUIRES_SHARED(Locks::mutator_lock_);
+ static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
+
+ private:
+ static inline MemberOffset TargetOffset() {
+ return MemberOffset(OFFSETOF_MEMBER(CallSite, target_));
+ }
+
+ HeapReference<mirror::MethodHandle> target_;
+
+ static GcRoot<mirror::Class> static_class_; // java.lang.invoke.CallSite.class
+
+ friend struct art::CallSiteOffsets; // for verifying offset information
+ DISALLOW_IMPLICIT_CONSTRUCTORS(CallSite);
+};
+
+} // namespace mirror
+} // namespace art
+
+#endif // ART_RUNTIME_MIRROR_CALL_SITE_H_
diff --git a/runtime/mirror/dex_cache-inl.h b/runtime/mirror/dex_cache-inl.h
index a59bb7b..973c8ed 100644
--- a/runtime/mirror/dex_cache-inl.h
+++ b/runtime/mirror/dex_cache-inl.h
@@ -26,6 +26,7 @@
#include "base/logging.h"
#include "gc_root.h"
#include "mirror/class.h"
+#include "mirror/call_site.h"
#include "mirror/method_type.h"
#include "runtime.h"
#include "obj_ptr.h"
@@ -106,6 +107,35 @@
Runtime::Current()->GetHeap()->WriteBarrierEveryFieldOf(this);
}
+inline CallSite* DexCache::GetResolvedCallSite(uint32_t call_site_idx) {
+ DCHECK(Runtime::Current()->IsMethodHandlesEnabled());
+ DCHECK_LT(call_site_idx, GetDexFile()->NumCallSiteIds());
+ GcRoot<mirror::CallSite>& target = GetResolvedCallSites()[call_site_idx];
+ Atomic<GcRoot<mirror::CallSite>>& ref =
+ reinterpret_cast<Atomic<GcRoot<mirror::CallSite>>&>(target);
+ return ref.LoadSequentiallyConsistent().Read();
+}
+
+inline CallSite* DexCache::SetResolvedCallSite(uint32_t call_site_idx, CallSite* call_site) {
+ DCHECK(Runtime::Current()->IsMethodHandlesEnabled());
+ DCHECK_LT(call_site_idx, GetDexFile()->NumCallSiteIds());
+
+ GcRoot<mirror::CallSite> null_call_site(nullptr);
+ GcRoot<mirror::CallSite> candidate(call_site);
+ GcRoot<mirror::CallSite>& target = GetResolvedCallSites()[call_site_idx];
+
+ // The first assignment for a given call site wins.
+ Atomic<GcRoot<mirror::CallSite>>& ref =
+ reinterpret_cast<Atomic<GcRoot<mirror::CallSite>>&>(target);
+ if (ref.CompareExchangeStrongSequentiallyConsistent(null_call_site, candidate)) {
+ // TODO: Fine-grained marking, so that we don't need to go through all arrays in full.
+ Runtime::Current()->GetHeap()->WriteBarrierEveryFieldOf(this);
+ return call_site;
+ } else {
+ return target.Read();
+ }
+}
+
inline ArtField* DexCache::GetResolvedField(uint32_t field_idx, PointerSize ptr_size) {
DCHECK_EQ(Runtime::Current()->GetClassLinker()->GetImagePointerSize(), ptr_size);
DCHECK_LT(field_idx, NumResolvedFields()); // NOTE: Unchecked, i.e. not throwing AIOOB.
@@ -208,6 +238,11 @@
VisitDexCachePairs<mirror::MethodType, kReadBarrierOption, Visitor>(
GetResolvedMethodTypes(), NumResolvedMethodTypes(), visitor);
+
+ GcRoot<mirror::CallSite>* resolved_call_sites = GetResolvedCallSites();
+ for (size_t i = 0, num_call_sites = NumResolvedCallSites(); i != num_call_sites; ++i) {
+ visitor.VisitRootIfNonNull(resolved_call_sites[i].AddressWithoutBarrier());
+ }
}
}
@@ -246,6 +281,17 @@
}
}
+template <ReadBarrierOption kReadBarrierOption, typename Visitor>
+inline void DexCache::FixupResolvedCallSites(GcRoot<mirror::CallSite>* dest,
+ const Visitor& visitor) {
+ GcRoot<mirror::CallSite>* src = GetResolvedCallSites();
+ for (size_t i = 0, count = NumResolvedCallSites(); i < count; ++i) {
+ mirror::CallSite* source = src[i].Read<kReadBarrierOption>();
+ mirror::CallSite* new_source = visitor(source);
+ dest[i] = GcRoot<mirror::CallSite>(new_source);
+ }
+}
+
} // namespace mirror
} // namespace art
diff --git a/runtime/mirror/dex_cache.cc b/runtime/mirror/dex_cache.cc
index 741cf3b..0f6acab 100644
--- a/runtime/mirror/dex_cache.cc
+++ b/runtime/mirror/dex_cache.cc
@@ -90,6 +90,10 @@
raw_arrays + layout.MethodTypesOffset());
}
+ GcRoot<mirror::CallSite>* call_sites = (dex_file->NumCallSiteIds() == 0)
+ ? nullptr
+ : reinterpret_cast<GcRoot<mirror::CallSite>*>(raw_arrays + layout.CallSitesOffset());
+
DCHECK_ALIGNED(raw_arrays, alignof(mirror::StringDexCacheType)) <<
"Expected raw_arrays to align to StringDexCacheType.";
DCHECK_ALIGNED(layout.StringsOffset(), alignof(mirror::StringDexCacheType)) <<
@@ -117,6 +121,9 @@
CHECK_EQ(method_types[i].load(std::memory_order_relaxed).index, 0u);
CHECK(method_types[i].load(std::memory_order_relaxed).object.IsNull());
}
+ for (size_t i = 0; i < dex_file->NumCallSiteIds(); ++i) {
+ CHECK(call_sites[i].IsNull());
+ }
}
if (strings != nullptr) {
mirror::StringDexCachePair::Initialize(strings);
@@ -136,6 +143,8 @@
dex_file->NumFieldIds(),
method_types,
num_method_types,
+ call_sites,
+ dex_file->NumCallSiteIds(),
image_pointer_size);
}
@@ -151,6 +160,8 @@
uint32_t num_resolved_fields,
MethodTypeDexCacheType* resolved_method_types,
uint32_t num_resolved_method_types,
+ GcRoot<CallSite>* resolved_call_sites,
+ uint32_t num_resolved_call_sites,
PointerSize pointer_size) {
CHECK(dex_file != nullptr);
CHECK(location != nullptr);
@@ -159,6 +170,7 @@
CHECK_EQ(num_resolved_methods != 0u, resolved_methods != nullptr);
CHECK_EQ(num_resolved_fields != 0u, resolved_fields != nullptr);
CHECK_EQ(num_resolved_method_types != 0u, resolved_method_types != nullptr);
+ CHECK_EQ(num_resolved_call_sites != 0u, resolved_call_sites != nullptr);
SetDexFile(dex_file);
SetLocation(location);
@@ -167,11 +179,13 @@
SetResolvedMethods(resolved_methods);
SetResolvedFields(resolved_fields);
SetResolvedMethodTypes(resolved_method_types);
+ SetResolvedCallSites(resolved_call_sites);
SetField32<false>(NumStringsOffset(), num_strings);
SetField32<false>(NumResolvedTypesOffset(), num_resolved_types);
SetField32<false>(NumResolvedMethodsOffset(), num_resolved_methods);
SetField32<false>(NumResolvedFieldsOffset(), num_resolved_fields);
SetField32<false>(NumResolvedMethodTypesOffset(), num_resolved_method_types);
+ SetField32<false>(NumResolvedCallSitesOffset(), num_resolved_call_sites);
Runtime* const runtime = Runtime::Current();
if (runtime->HasResolutionMethod()) {
diff --git a/runtime/mirror/dex_cache.h b/runtime/mirror/dex_cache.h
index 6f88cc5..10bb5aa 100644
--- a/runtime/mirror/dex_cache.h
+++ b/runtime/mirror/dex_cache.h
@@ -36,6 +36,7 @@
namespace mirror {
+class CallSite;
class MethodType;
class String;
@@ -163,6 +164,10 @@
void FixupResolvedMethodTypes(MethodTypeDexCacheType* dest, const Visitor& visitor)
REQUIRES_SHARED(Locks::mutator_lock_);
+ template <ReadBarrierOption kReadBarrierOption = kWithReadBarrier, typename Visitor>
+ void FixupResolvedCallSites(GcRoot<mirror::CallSite>* dest, const Visitor& visitor)
+ REQUIRES_SHARED(Locks::mutator_lock_);
+
String* GetLocation() REQUIRES_SHARED(Locks::mutator_lock_) {
return GetFieldObject<String>(OFFSET_OF_OBJECT_MEMBER(DexCache, location_));
}
@@ -191,6 +196,10 @@
return OFFSET_OF_OBJECT_MEMBER(DexCache, resolved_method_types_);
}
+ static MemberOffset ResolvedCallSitesOffset() {
+ return OFFSET_OF_OBJECT_MEMBER(DexCache, resolved_call_sites_);
+ }
+
static MemberOffset NumStringsOffset() {
return OFFSET_OF_OBJECT_MEMBER(DexCache, num_strings_);
}
@@ -211,6 +220,10 @@
return OFFSET_OF_OBJECT_MEMBER(DexCache, num_resolved_method_types_);
}
+ static MemberOffset NumResolvedCallSitesOffset() {
+ return OFFSET_OF_OBJECT_MEMBER(DexCache, num_resolved_call_sites_);
+ }
+
mirror::String* GetResolvedString(dex::StringIndex string_idx) ALWAYS_INLINE
REQUIRES_SHARED(Locks::mutator_lock_);
@@ -244,7 +257,18 @@
MethodType* GetResolvedMethodType(uint32_t proto_idx) REQUIRES_SHARED(Locks::mutator_lock_);
- void SetResolvedMethodType(uint32_t proto_idx, MethodType* resolved) REQUIRES_SHARED(Locks::mutator_lock_);
+ void SetResolvedMethodType(uint32_t proto_idx, MethodType* resolved)
+ REQUIRES_SHARED(Locks::mutator_lock_);
+
+ CallSite* GetResolvedCallSite(uint32_t call_site_idx) REQUIRES_SHARED(Locks::mutator_lock_);
+
+ // Attempts to bind |call_site_idx| to the call site |resolved|. The
+ // caller must use the return value in place of |resolved|. This is
+ // because multiple threads can invoke the bootstrap method each
+ // producing a call site, but the method handle invocation on the
+ // call site must be on a common agreed value.
+ CallSite* SetResolvedCallSite(uint32_t call_site_idx, CallSite* resolved) WARN_UNUSED
+ REQUIRES_SHARED(Locks::mutator_lock_);
StringDexCacheType* GetStrings() ALWAYS_INLINE REQUIRES_SHARED(Locks::mutator_lock_) {
return GetFieldPtr64<StringDexCacheType*>(StringsOffset());
@@ -295,6 +319,18 @@
SetFieldPtr<false>(ResolvedMethodTypesOffset(), resolved_method_types);
}
+ GcRoot<CallSite>* GetResolvedCallSites()
+ ALWAYS_INLINE
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ return GetFieldPtr<GcRoot<CallSite>*>(ResolvedCallSitesOffset());
+ }
+
+ void SetResolvedCallSites(GcRoot<CallSite>* resolved_call_sites)
+ ALWAYS_INLINE
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ SetFieldPtr<false>(ResolvedCallSitesOffset(), resolved_call_sites);
+ }
+
size_t NumStrings() REQUIRES_SHARED(Locks::mutator_lock_) {
return GetField32(NumStringsOffset());
}
@@ -315,6 +351,10 @@
return GetField32(NumResolvedMethodTypesOffset());
}
+ size_t NumResolvedCallSites() REQUIRES_SHARED(Locks::mutator_lock_) {
+ return GetField32(NumResolvedCallSitesOffset());
+ }
+
const DexFile* GetDexFile() ALWAYS_INLINE REQUIRES_SHARED(Locks::mutator_lock_) {
return GetFieldPtr<const DexFile*>(OFFSET_OF_OBJECT_MEMBER(DexCache, dex_file_));
}
@@ -346,8 +386,10 @@
uint32_t num_resolved_methods,
ArtField** resolved_fields,
uint32_t num_resolved_fields,
- MethodTypeDexCacheType* resolved_methodtypes,
- uint32_t num_resolved_methodtypes,
+ MethodTypeDexCacheType* resolved_method_types,
+ uint32_t num_resolved_method_types,
+ GcRoot<CallSite>* resolved_call_sites,
+ uint32_t num_resolved_call_sites,
PointerSize pointer_size)
REQUIRES_SHARED(Locks::mutator_lock_);
@@ -362,6 +404,8 @@
HeapReference<Object> dex_;
HeapReference<String> location_;
uint64_t dex_file_; // const DexFile*
+ uint64_t resolved_call_sites_; // GcRoot<CallSite>* array with num_resolved_call_sites_
+ // elements.
uint64_t resolved_fields_; // ArtField*, array with num_resolved_fields_ elements.
uint64_t resolved_method_types_; // std::atomic<MethodTypeDexCachePair>* array with
// num_resolved_method_types_ elements.
@@ -370,6 +414,7 @@
uint64_t strings_; // std::atomic<StringDexCachePair>*, array with num_strings_
// elements.
+ uint32_t num_resolved_call_sites_; // Number of elements in the call_sites_ array.
uint32_t num_resolved_fields_; // Number of elements in the resolved_fields_ array.
uint32_t num_resolved_method_types_; // Number of elements in the resolved_method_types_ array.
uint32_t num_resolved_methods_; // Number of elements in the resolved_methods_ array.
diff --git a/runtime/mirror/method_handle_impl.cc b/runtime/mirror/method_handle_impl.cc
index 4f1c448..fa4d25a 100644
--- a/runtime/mirror/method_handle_impl.cc
+++ b/runtime/mirror/method_handle_impl.cc
@@ -28,6 +28,18 @@
return klass;
}
+void MethodHandle::Initialize(uintptr_t art_field_or_method,
+ Kind kind,
+ Handle<MethodType> method_type)
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ CHECK(!Runtime::Current()->IsActiveTransaction());
+ SetFieldObject<false>(CachedSpreadInvokerOffset(), nullptr);
+ SetFieldObject<false>(NominalTypeOffset(), nullptr);
+ SetFieldObject<false>(MethodTypeOffset(), method_type.Get());
+ SetField32<false>(HandleKindOffset(), static_cast<uint32_t>(kind));
+ SetField64<false>(ArtFieldOrMethodOffset(), art_field_or_method);
+}
+
GcRoot<mirror::Class> MethodHandleImpl::static_class_;
void MethodHandleImpl::SetClass(Class* klass) {
@@ -45,5 +57,17 @@
static_class_.VisitRootIfNonNull(visitor, RootInfo(kRootStickyClass));
}
+mirror::MethodHandleImpl* MethodHandleImpl::Create(Thread* const self,
+ uintptr_t art_field_or_method,
+ MethodHandle::Kind kind,
+ Handle<MethodType> method_type)
+ REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_) {
+ StackHandleScope<1> hs(self);
+ Handle<mirror::MethodHandleImpl> mh(
+ hs.NewHandle(ObjPtr<MethodHandleImpl>::DownCast(StaticClass()->AllocObject(self))));
+ mh->Initialize(art_field_or_method, kind, method_type);
+ return mh.Get();
+}
+
} // namespace mirror
} // namespace art
diff --git a/runtime/mirror/method_handle_impl.h b/runtime/mirror/method_handle_impl.h
index 53d267b..9938af8 100644
--- a/runtime/mirror/method_handle_impl.h
+++ b/runtime/mirror/method_handle_impl.h
@@ -17,10 +17,11 @@
#ifndef ART_RUNTIME_MIRROR_METHOD_HANDLE_IMPL_H_
#define ART_RUNTIME_MIRROR_METHOD_HANDLE_IMPL_H_
+#include "art_field.h"
+#include "art_method.h"
#include "class.h"
#include "gc_root.h"
#include "object-inl.h"
-#include "method_handles.h"
#include "method_type.h"
namespace art {
@@ -82,10 +83,19 @@
GetField64(OFFSET_OF_OBJECT_MEMBER(MethodHandle, art_field_or_method_)));
}
+ ObjPtr<mirror::Class> GetTargetClass() REQUIRES_SHARED(Locks::mutator_lock_) {
+ Kind kind = GetHandleKind();
+ return (kind <= kLastValidKind) ?
+ GetTargetMethod()->GetDeclaringClass() : GetTargetField()->GetDeclaringClass();
+ }
+
static mirror::Class* StaticClass() REQUIRES_SHARED(Locks::mutator_lock_);
+ protected:
+ void Initialize(uintptr_t art_field_or_method, Kind kind, Handle<MethodType> method_type)
+ REQUIRES_SHARED(Locks::mutator_lock_);
+
private:
- // NOTE: cached_spread_invoker_ isn't used by the runtime.
HeapReference<mirror::MethodHandle> cached_spread_invoker_;
HeapReference<mirror::MethodType> nominal_type_;
HeapReference<mirror::MethodType> method_type_;
@@ -93,6 +103,9 @@
uint64_t art_field_or_method_;
private:
+ static MemberOffset CachedSpreadInvokerOffset() {
+ return MemberOffset(OFFSETOF_MEMBER(MethodHandle, cached_spread_invoker_));
+ }
static MemberOffset NominalTypeOffset() {
return MemberOffset(OFFSETOF_MEMBER(MethodHandle, nominal_type_));
}
@@ -113,6 +126,12 @@
// C++ mirror of java.lang.invoke.MethodHandleImpl
class MANAGED MethodHandleImpl : public MethodHandle {
public:
+ static mirror::MethodHandleImpl* Create(Thread* const self,
+ uintptr_t art_field_or_method,
+ MethodHandle::Kind kind,
+ Handle<MethodType> method_type)
+ REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
+
static mirror::Class* StaticClass() REQUIRES_SHARED(Locks::mutator_lock_) {
return static_class_.Read();
}
diff --git a/runtime/mirror/method_handles_lookup.cc b/runtime/mirror/method_handles_lookup.cc
new file mode 100644
index 0000000..c758e54
--- /dev/null
+++ b/runtime/mirror/method_handles_lookup.cc
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+#include "method_handles_lookup.h"
+
+#include "class.h"
+#include "gc_root-inl.h"
+#include "object-inl.h"
+#include "handle_scope.h"
+#include "modifiers.h"
+
+namespace art {
+namespace mirror {
+
+GcRoot<mirror::Class> MethodHandlesLookup::static_class_;
+
+void MethodHandlesLookup::SetClass(Class* klass) {
+ CHECK(static_class_.IsNull()) << static_class_.Read() << " " << klass;
+ CHECK(klass != nullptr);
+ static_class_ = GcRoot<Class>(klass);
+}
+
+void MethodHandlesLookup::ResetClass() {
+ CHECK(!static_class_.IsNull());
+ static_class_ = GcRoot<Class>(nullptr);
+}
+
+void MethodHandlesLookup::VisitRoots(RootVisitor* visitor) {
+ static_class_.VisitRootIfNonNull(visitor, RootInfo(kRootStickyClass));
+}
+
+MethodHandlesLookup* MethodHandlesLookup::Create(Thread* const self, Handle<Class> lookup_class)
+ REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_) {
+ static constexpr uint32_t kAllModes = kAccPublic | kAccPrivate | kAccProtected | kAccStatic;
+
+ StackHandleScope<1> hs(self);
+ Handle<MethodHandlesLookup> mhl(
+ hs.NewHandle(ObjPtr<MethodHandlesLookup>::DownCast(StaticClass()->AllocObject(self))));
+ mhl->SetFieldObject<false>(LookupClassOffset(), lookup_class.Get());
+ mhl->SetField32<false>(AllowedModesOffset(), kAllModes);
+ return mhl.Get();
+}
+
+} // namespace mirror
+} // namespace art
diff --git a/runtime/mirror/method_handles_lookup.h b/runtime/mirror/method_handles_lookup.h
new file mode 100644
index 0000000..63eb428
--- /dev/null
+++ b/runtime/mirror/method_handles_lookup.h
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+#ifndef ART_RUNTIME_MIRROR_METHOD_HANDLES_LOOKUP_H_
+#define ART_RUNTIME_MIRROR_METHOD_HANDLES_LOOKUP_H_
+
+#include "obj_ptr.h"
+#include "gc_root.h"
+#include "object.h"
+#include "handle.h"
+#include "utils.h"
+
+namespace art {
+
+struct MethodHandlesLookupOffsets;
+class RootVisitor;
+
+namespace mirror {
+
+// C++ mirror of java.lang.invoke.MethodHandles.Lookup
+class MANAGED MethodHandlesLookup : public Object {
+ public:
+ static mirror::MethodHandlesLookup* Create(Thread* const self,
+ Handle<Class> lookup_class)
+ REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
+
+ static mirror::Class* StaticClass() REQUIRES_SHARED(Locks::mutator_lock_) {
+ return static_class_.Read();
+ }
+
+ static void SetClass(Class* klass) REQUIRES_SHARED(Locks::mutator_lock_);
+ static void ResetClass() REQUIRES_SHARED(Locks::mutator_lock_);
+ static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
+
+ private:
+ static MemberOffset AllowedModesOffset() {
+ return MemberOffset(OFFSETOF_MEMBER(MethodHandlesLookup, allowed_modes_));
+ }
+
+ static MemberOffset LookupClassOffset() {
+ return MemberOffset(OFFSETOF_MEMBER(MethodHandlesLookup, lookup_class_));
+ }
+
+ HeapReference<mirror::Class> lookup_class_;
+
+ int32_t allowed_modes_;
+
+ static GcRoot<mirror::Class> static_class_; // java.lang.invoke.MethodHandles.Lookup.class
+
+ friend struct art::MethodHandlesLookupOffsets; // for verifying offset information
+ DISALLOW_IMPLICIT_CONSTRUCTORS(MethodHandlesLookup);
+};
+
+} // namespace mirror
+} // namespace art
+
+#endif // ART_RUNTIME_MIRROR_METHOD_HANDLES_LOOKUP_H_
diff --git a/runtime/mirror/method_type.cc b/runtime/mirror/method_type.cc
index 5d77a16..4b8dfac 100644
--- a/runtime/mirror/method_type.cc
+++ b/runtime/mirror/method_type.cc
@@ -44,6 +44,22 @@
return mt.Get();
}
+size_t MethodType::NumberOfVRegs() REQUIRES_SHARED(Locks::mutator_lock_) {
+ mirror::ObjectArray<Class>* const p_types = GetPTypes();
+ const int32_t p_types_length = p_types->GetLength();
+
+ // Initialize |num_vregs| with number of parameters and only increment it for
+ // types requiring a second vreg.
+ size_t num_vregs = static_cast<size_t>(p_types_length);
+ for (int32_t i = 0; i < p_types_length; ++i) {
+ mirror::Class* klass = p_types->GetWithoutChecks(i);
+ if (klass->IsPrimitiveLong() || klass->IsPrimitiveDouble()) {
+ ++num_vregs;
+ }
+ }
+ return num_vregs;
+}
+
bool MethodType::IsExactMatch(mirror::MethodType* target) REQUIRES_SHARED(Locks::mutator_lock_) {
mirror::ObjectArray<Class>* const p_types = GetPTypes();
const int32_t params_length = p_types->GetLength();
diff --git a/runtime/mirror/method_type.h b/runtime/mirror/method_type.h
index 9a98143..374bbe5 100644
--- a/runtime/mirror/method_type.h
+++ b/runtime/mirror/method_type.h
@@ -44,6 +44,10 @@
return GetFieldObject<ObjectArray<Class>>(OFFSET_OF_OBJECT_MEMBER(MethodType, p_types_));
}
+ // Number of virtual registers required to hold the parameters for
+ // this method type.
+ size_t NumberOfVRegs() REQUIRES_SHARED(Locks::mutator_lock_);
+
Class* GetRType() REQUIRES_SHARED(Locks::mutator_lock_) {
return GetFieldObject<Class>(OFFSET_OF_OBJECT_MEMBER(MethodType, r_type_));
}
diff --git a/runtime/mirror/string-inl.h b/runtime/mirror/string-inl.h
index 9b8445d..c2407d7 100644
--- a/runtime/mirror/string-inl.h
+++ b/runtime/mirror/string-inl.h
@@ -308,7 +308,7 @@
}
template<typename MemoryType>
-bool String::AllASCII(const MemoryType* const chars, const int length) {
+inline bool String::AllASCII(const MemoryType* chars, const int length) {
static_assert(std::is_unsigned<MemoryType>::value, "Expecting unsigned MemoryType");
for (int i = 0; i < length; ++i) {
// Valid ASCII characters are in range 1..0x7f. Zero is not considered ASCII
@@ -320,6 +320,13 @@
return true;
}
+inline bool String::DexFileStringAllASCII(const char* chars, const int length) {
+ // For strings from the dex file we just need to check that
+ // the terminating character is at the right position.
+ DCHECK_EQ(AllASCII(reinterpret_cast<const uint8_t*>(chars), length), chars[length] == 0);
+ return chars[length] == 0;
+}
+
} // namespace mirror
} // namespace art
diff --git a/runtime/mirror/string.h b/runtime/mirror/string.h
index 409c6c2..38f6dd4 100644
--- a/runtime/mirror/string.h
+++ b/runtime/mirror/string.h
@@ -184,7 +184,9 @@
bool IsValueNull() REQUIRES_SHARED(Locks::mutator_lock_);
template<typename MemoryType>
- static bool AllASCII(const MemoryType* const chars, const int length);
+ static bool AllASCII(const MemoryType* chars, const int length);
+
+ static bool DexFileStringAllASCII(const char* chars, const int length);
ALWAYS_INLINE static bool IsCompressed(int32_t count) {
return GetCompressionFlagFromCount(count) == StringCompressionFlag::kCompressed;
diff --git a/runtime/monitor.cc b/runtime/monitor.cc
index a32003e..f3cb0df 100644
--- a/runtime/monitor.cc
+++ b/runtime/monitor.cc
@@ -1380,7 +1380,7 @@
while (!kUseReadBarrier && UNLIKELY(!allow_new_monitors_)) {
// Check and run the empty checkpoint before blocking so the empty checkpoint will work in the
// presence of threads blocking for weak ref access.
- self->CheckEmptyCheckpoint();
+ self->CheckEmptyCheckpointFromWeakRefAccess(&monitor_list_lock_);
monitor_add_condition_.WaitHoldingLocks(self);
}
list_.push_front(m);
diff --git a/runtime/oat.h b/runtime/oat.h
index e7e8328..0f6657b 100644
--- a/runtime/oat.h
+++ b/runtime/oat.h
@@ -32,7 +32,7 @@
class PACKED(4) OatHeader {
public:
static constexpr uint8_t kOatMagic[] = { 'o', 'a', 't', '\n' };
- static constexpr uint8_t kOatVersion[] = { '1', '1', '0', '\0' }; // Clean up code info change.
+ static constexpr uint8_t kOatVersion[] = { '1', '1', '2', '\0' }; // Manual bump (Revert^3 hash-based DexCache types; stack maps).
static constexpr const char* kImageLocationKey = "image-location";
static constexpr const char* kDex2OatCmdLineKey = "dex2oat-cmdline";
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index 31eb1cc..493da27 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -273,6 +273,36 @@
return true;
}
+static bool FindDexFileMapItem(const uint8_t* dex_begin,
+ const uint8_t* dex_end,
+ DexFile::MapItemType map_item_type,
+ const DexFile::MapItem** result_item) {
+ *result_item = nullptr;
+
+ const DexFile::Header* header =
+ BoundsCheckedCast<const DexFile::Header*>(dex_begin, dex_begin, dex_end);
+ if (nullptr == header) return false;
+
+ if (!DexFile::IsMagicValid(header->magic_)) return true; // Not a dex file, not an error.
+
+ const DexFile::MapList* map_list =
+ BoundsCheckedCast<const DexFile::MapList*>(dex_begin + header->map_off_, dex_begin, dex_end);
+ if (nullptr == map_list) return false;
+
+ const DexFile::MapItem* map_item = map_list->list_;
+ size_t count = map_list->size_;
+ while (count--) {
+ if (map_item->type_ == static_cast<uint16_t>(map_item_type)) {
+ *result_item = map_item;
+ break;
+ }
+ map_item = BoundsCheckedCast<const DexFile::MapItem*>(map_item + 1, dex_begin, dex_end);
+ if (nullptr == map_item) return false;
+ }
+
+ return true;
+}
+
bool OatFileBase::Setup(const char* abs_dex_location, std::string* error_msg) {
if (!GetOatHeader().IsValid()) {
std::string cause = GetOatHeader().GetValidationErrorMessage();
@@ -501,7 +531,19 @@
uint8_t* current_dex_cache_arrays = nullptr;
if (dex_cache_arrays != nullptr) {
- DexCacheArraysLayout layout(pointer_size, *header);
+ // All DexCache types except for CallSite have their instance counts in the
+ // DexFile header. For CallSites, we need to read the info from the MapList.
+ const DexFile::MapItem* call_sites_item = nullptr;
+ if (!FindDexFileMapItem(DexBegin(),
+ DexEnd(),
+ DexFile::MapItemType::kDexTypeCallSiteIdItem,
+ &call_sites_item)) {
+ *error_msg = StringPrintf("In oat file '%s' could not read data from truncated DexFile map",
+ GetLocation().c_str());
+ return false;
+ }
+ size_t num_call_sites = call_sites_item == nullptr ? 0 : call_sites_item->size_;
+ DexCacheArraysLayout layout(pointer_size, *header, num_call_sites);
if (layout.Size() != 0u) {
if (static_cast<size_t>(dex_cache_arrays_end - dex_cache_arrays) < layout.Size()) {
*error_msg = StringPrintf("In oat file '%s' found OatDexFile #%zu for '%s' with "
@@ -1468,77 +1510,6 @@
return out.str();
}
-bool OatFile::CheckStaticDexFileDependencies(const char* dex_dependencies, std::string* msg) {
- if (dex_dependencies == nullptr || dex_dependencies[0] == 0) {
- // No dependencies.
- return true;
- }
-
- // Assumption: this is not performance-critical. So it's OK to do this with a std::string and
- // Split() instead of manual parsing of the combined char*.
- std::vector<std::string> split;
- Split(dex_dependencies, kDexClassPathEncodingSeparator, &split);
- if (split.size() % 2 != 0) {
- // Expected pairs of location and checksum.
- *msg = StringPrintf("Odd number of elements in dependency list %s", dex_dependencies);
- return false;
- }
-
- for (auto it = split.begin(), end = split.end(); it != end; it += 2) {
- std::string& location = *it;
- std::string& checksum = *(it + 1);
- int64_t converted = strtoll(checksum.c_str(), nullptr, 10);
- if (converted == 0) {
- // Conversion error.
- *msg = StringPrintf("Conversion error for %s", checksum.c_str());
- return false;
- }
-
- uint32_t dex_checksum;
- std::string error_msg;
- if (DexFile::GetChecksum(DexFile::GetDexCanonicalLocation(location.c_str()).c_str(),
- &dex_checksum,
- &error_msg)) {
- if (converted != dex_checksum) {
- *msg = StringPrintf("Checksums don't match for %s: %" PRId64 " vs %u",
- location.c_str(), converted, dex_checksum);
- return false;
- }
- } else {
- // Problem retrieving checksum.
- // TODO: odex files?
- *msg = StringPrintf("Could not retrieve checksum for %s: %s", location.c_str(),
- error_msg.c_str());
- return false;
- }
- }
-
- return true;
-}
-
-bool OatFile::GetDexLocationsFromDependencies(const char* dex_dependencies,
- std::vector<std::string>* locations) {
- DCHECK(locations != nullptr);
- if (dex_dependencies == nullptr || dex_dependencies[0] == 0) {
- return true;
- }
-
- // Assumption: this is not performance-critical. So it's OK to do this with a std::string and
- // Split() instead of manual parsing of the combined char*.
- std::vector<std::string> split;
- Split(dex_dependencies, kDexClassPathEncodingSeparator, &split);
- if (split.size() % 2 != 0) {
- // Expected pairs of location and checksum.
- return false;
- }
-
- for (auto it = split.begin(), end = split.end(); it != end; it += 2) {
- locations->push_back(*it);
- }
-
- return true;
-}
-
OatFile::OatClass OatFile::FindOatClass(const DexFile& dex_file,
uint16_t class_def_idx,
bool* found) {
diff --git a/runtime/oat_file.h b/runtime/oat_file.h
index 111755e..d24283a 100644
--- a/runtime/oat_file.h
+++ b/runtime/oat_file.h
@@ -290,15 +290,6 @@
// Create a dependency list (dex locations and checksums) for the given dex files.
static std::string EncodeDexFileDependencies(const std::vector<const DexFile*>& dex_files);
- // Check the given dependency list against their dex files - thus the name "Static," this does
- // not check the class-loader environment, only whether there have been file updates.
- static bool CheckStaticDexFileDependencies(const char* dex_dependencies, std::string* msg);
-
- // Get the dex locations of a dependency list. Note: this is *not* cleaned for synthetic
- // locations of multidex files.
- static bool GetDexLocationsFromDependencies(const char* dex_dependencies,
- std::vector<std::string>* locations);
-
// Finds the associated oat class for a dex_file and descriptor. Returns an invalid OatClass on
// error and sets found to false.
static OatClass FindOatClass(const DexFile& dex_file, uint16_t class_def_idx, bool* found);
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index 77cdd28..5ae2fc5 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -38,6 +38,8 @@
namespace art {
+using android::base::StringPrintf;
+
std::ostream& operator << (std::ostream& stream, const OatFileAssistant::OatStatus status) {
switch (status) {
case OatFileAssistant::kOatCannotOpen:
@@ -264,7 +266,7 @@
const OatFile& oat_file, const char* dex_location) {
std::vector<std::unique_ptr<const DexFile>> dex_files;
- // Load the primary dex file.
+ // Load the main dex file.
std::string error_msg;
const OatFile::OatDexFile* oat_dex_file = oat_file.GetOatDexFile(
dex_location, nullptr, &error_msg);
@@ -280,12 +282,12 @@
}
dex_files.push_back(std::move(dex_file));
- // Load secondary multidex files
+ // Load the rest of the multidex entries
for (size_t i = 1; ; i++) {
- std::string secondary_dex_location = DexFile::GetMultiDexLocation(i, dex_location);
- oat_dex_file = oat_file.GetOatDexFile(secondary_dex_location.c_str(), nullptr);
+ std::string multidex_dex_location = DexFile::GetMultiDexLocation(i, dex_location);
+ oat_dex_file = oat_file.GetOatDexFile(multidex_dex_location.c_str(), nullptr);
if (oat_dex_file == nullptr) {
- // There are no more secondary dex files to load.
+ // There are no more multidex entries to load.
break;
}
@@ -300,10 +302,10 @@
}
bool OatFileAssistant::HasOriginalDexFiles() {
- // Ensure GetRequiredDexChecksum has been run so that
+ // Ensure GetRequiredDexChecksums has been run so that
// has_original_dex_files_ is initialized. We don't care about the result of
- // GetRequiredDexChecksum.
- GetRequiredDexChecksum();
+ // GetRequiredDexChecksums.
+ GetRequiredDexChecksums();
return has_original_dex_files_;
}
@@ -316,88 +318,66 @@
}
bool OatFileAssistant::DexChecksumUpToDate(const VdexFile& file, std::string* error_msg) {
- if (file.GetHeader().GetNumberOfDexFiles() <= 0) {
- VLOG(oat) << "Vdex does not contain any dex files";
+ const std::vector<uint32_t>* required_dex_checksums = GetRequiredDexChecksums();
+ if (required_dex_checksums == nullptr) {
+ LOG(WARNING) << "Required dex checksums not found. Assuming dex checksums are up to date.";
+ return true;
+ }
+
+ uint32_t number_of_dex_files = file.GetHeader().GetNumberOfDexFiles();
+ if (required_dex_checksums->size() != number_of_dex_files) {
+ *error_msg = StringPrintf("expected %zu dex files but found %u",
+ required_dex_checksums->size(),
+ number_of_dex_files);
return false;
}
- // TODO: Use GetRequiredDexChecksum to get secondary checksums as well, not
- // just the primary. Because otherwise we may fail to see a secondary
- // checksum failure in the case when the original (multidex) files are
- // stripped but we have a newer odex file.
- const uint32_t* dex_checksum_pointer = GetRequiredDexChecksum();
- if (dex_checksum_pointer != nullptr) {
- uint32_t actual_checksum = file.GetLocationChecksum(0);
- if (*dex_checksum_pointer != actual_checksum) {
- VLOG(oat) << "Dex checksum does not match for primary dex: " << dex_location_
- << ". Expected: " << *dex_checksum_pointer
- << ", Actual: " << actual_checksum;
+ for (uint32_t i = 0; i < number_of_dex_files; i++) {
+ uint32_t expected_checksum = (*required_dex_checksums)[i];
+ uint32_t actual_checksum = file.GetLocationChecksum(i);
+ if (expected_checksum != actual_checksum) {
+ std::string dex = DexFile::GetMultiDexLocation(i, dex_location_.c_str());
+ *error_msg = StringPrintf("Dex checksum does not match for dex: %s."
+ "Expected: %u, actual: %u",
+ dex.c_str(),
+ expected_checksum,
+ actual_checksum);
return false;
}
}
- // Verify the dex checksums for any secondary multidex files
- for (uint32_t i = 1; i < file.GetHeader().GetNumberOfDexFiles(); i++) {
- std::string secondary_dex_location = DexFile::GetMultiDexLocation(i, dex_location_.c_str());
- uint32_t expected_secondary_checksum = 0;
- if (DexFile::GetChecksum(secondary_dex_location.c_str(),
- &expected_secondary_checksum,
- error_msg)) {
- uint32_t actual_secondary_checksum = file.GetLocationChecksum(i);
- if (expected_secondary_checksum != actual_secondary_checksum) {
- VLOG(oat) << "Dex checksum does not match for secondary dex: "
- << secondary_dex_location
- << ". Expected: " << expected_secondary_checksum
- << ", Actual: " << actual_secondary_checksum;
- return false;
- }
- } else {
- // If we can't get the checksum for the secondary location, we assume
- // the dex checksum is up to date for this and all other secondary dex
- // files.
- break;
- }
- }
return true;
}
bool OatFileAssistant::DexChecksumUpToDate(const OatFile& file, std::string* error_msg) {
- // Note: GetOatDexFile will return null if the dex checksum doesn't match
- // what we provide, which verifies the primary dex checksum for us.
- const uint32_t* dex_checksum_pointer = GetRequiredDexChecksum();
- const OatFile::OatDexFile* oat_dex_file = file.GetOatDexFile(
- dex_location_.c_str(), dex_checksum_pointer, error_msg);
- if (oat_dex_file == nullptr) {
+ const std::vector<uint32_t>* required_dex_checksums = GetRequiredDexChecksums();
+ if (required_dex_checksums == nullptr) {
+ LOG(WARNING) << "Required dex checksums not found. Assuming dex checksums are up to date.";
+ return true;
+ }
+
+ uint32_t number_of_dex_files = file.GetOatHeader().GetDexFileCount();
+ if (required_dex_checksums->size() != number_of_dex_files) {
+ *error_msg = StringPrintf("expected %zu dex files but found %u",
+ required_dex_checksums->size(),
+ number_of_dex_files);
return false;
}
- // Verify the dex checksums for any secondary multidex files
- for (size_t i = 1; ; i++) {
- std::string secondary_dex_location = DexFile::GetMultiDexLocation(i, dex_location_.c_str());
- const OatFile::OatDexFile* secondary_oat_dex_file
- = file.GetOatDexFile(secondary_dex_location.c_str(), nullptr);
- if (secondary_oat_dex_file == nullptr) {
- // There are no more secondary dex files to check.
- break;
+ for (uint32_t i = 0; i < number_of_dex_files; i++) {
+ std::string dex = DexFile::GetMultiDexLocation(i, dex_location_.c_str());
+ uint32_t expected_checksum = (*required_dex_checksums)[i];
+ const OatFile::OatDexFile* oat_dex_file = file.GetOatDexFile(dex.c_str(), nullptr);
+ if (oat_dex_file == nullptr) {
+ *error_msg = StringPrintf("failed to find %s in %s", dex.c_str(), file.GetLocation().c_str());
+ return false;
}
-
- uint32_t expected_secondary_checksum = 0;
- if (DexFile::GetChecksum(secondary_dex_location.c_str(),
- &expected_secondary_checksum, error_msg)) {
- uint32_t actual_secondary_checksum
- = secondary_oat_dex_file->GetDexFileLocationChecksum();
- if (expected_secondary_checksum != actual_secondary_checksum) {
- VLOG(oat) << "Dex checksum does not match for secondary dex: "
- << secondary_dex_location
- << ". Expected: " << expected_secondary_checksum
- << ", Actual: " << actual_secondary_checksum;
- return false;
- }
- } else {
- // If we can't get the checksum for the secondary location, we assume
- // the dex checksum is up to date for this and all other secondary dex
- // files.
- break;
+ uint32_t actual_checksum = oat_dex_file->GetDexFileLocationChecksum();
+ if (expected_checksum != actual_checksum) {
+ VLOG(oat) << "Dex checksum does not match for dex: " << dex
+ << ". Expected: " << expected_checksum
+ << ", Actual: " << actual_checksum;
+ return false;
}
}
return true;
@@ -710,13 +690,16 @@
return image_spaces[0]->GetImageLocation();
}
-const uint32_t* OatFileAssistant::GetRequiredDexChecksum() {
- if (!required_dex_checksum_attempted_) {
- required_dex_checksum_attempted_ = true;
- required_dex_checksum_found_ = false;
+const std::vector<uint32_t>* OatFileAssistant::GetRequiredDexChecksums() {
+ if (!required_dex_checksums_attempted_) {
+ required_dex_checksums_attempted_ = true;
+ required_dex_checksums_found_ = false;
+ cached_required_dex_checksums_.clear();
std::string error_msg;
- if (DexFile::GetChecksum(dex_location_.c_str(), &cached_required_dex_checksum_, &error_msg)) {
- required_dex_checksum_found_ = true;
+ if (DexFile::GetMultiDexChecksums(dex_location_.c_str(),
+ &cached_required_dex_checksums_,
+ &error_msg)) {
+ required_dex_checksums_found_ = true;
has_original_dex_files_ = true;
} else {
// This can happen if the original dex file has been stripped from the
@@ -724,19 +707,23 @@
VLOG(oat) << "OatFileAssistant: " << error_msg;
has_original_dex_files_ = false;
- // Get the checksum from the odex if we can.
+ // Get the checksums from the odex if we can.
const OatFile* odex_file = odex_.GetFile();
if (odex_file != nullptr) {
- const OatFile::OatDexFile* odex_dex_file
- = odex_file->GetOatDexFile(dex_location_.c_str(), nullptr);
- if (odex_dex_file != nullptr) {
- cached_required_dex_checksum_ = odex_dex_file->GetDexFileLocationChecksum();
- required_dex_checksum_found_ = true;
+ required_dex_checksums_found_ = true;
+ for (size_t i = 0; i < odex_file->GetOatHeader().GetDexFileCount(); i++) {
+ std::string dex = DexFile::GetMultiDexLocation(i, dex_location_.c_str());
+ const OatFile::OatDexFile* odex_dex_file = odex_file->GetOatDexFile(dex.c_str(), nullptr);
+ if (odex_dex_file == nullptr) {
+ required_dex_checksums_found_ = false;
+ break;
+ }
+ cached_required_dex_checksums_.push_back(odex_dex_file->GetDexFileLocationChecksum());
}
}
}
}
- return required_dex_checksum_found_ ? &cached_required_dex_checksum_ : nullptr;
+ return required_dex_checksums_found_ ? &cached_required_dex_checksums_ : nullptr;
}
const OatFileAssistant::ImageInfo* OatFileAssistant::GetImageInfo() {
diff --git a/runtime/oat_file_assistant.h b/runtime/oat_file_assistant.h
index 6d47ad2..3ede29f 100644
--- a/runtime/oat_file_assistant.h
+++ b/runtime/oat_file_assistant.h
@@ -400,13 +400,13 @@
// the oat file assistant.
static std::string ImageLocation();
- // Gets the dex checksum required for an up-to-date oat file.
- // Returns dex_checksum if a required checksum was located. Returns
- // null if the required checksum was not found.
- // The caller shouldn't clean up or free the returned pointer.
- // This sets the has_original_dex_files_ field to true if a checksum was
- // found for the dex_location_ dex file.
- const uint32_t* GetRequiredDexChecksum();
+ // Gets the dex checksums required for an up-to-date oat file.
+ // Returns cached_required_dex_checksums if the required checksums were
+ // located. Returns null if the required checksums were not found. The
+ // caller shouldn't clean up or free the returned pointer. This sets the
+ // has_original_dex_files_ field to true if the checksums were found for the
+ // dex_location_ dex file.
+ const std::vector<uint32_t>* GetRequiredDexChecksums();
// Returns the loaded image info.
// Loads the image info if needed. Returns null if the image info failed
@@ -430,11 +430,11 @@
// Whether we will attempt to load oat files executable.
bool load_executable_ = false;
- // Cached value of the required dex checksum.
- // This should be accessed only by the GetRequiredDexChecksum() method.
- uint32_t cached_required_dex_checksum_;
- bool required_dex_checksum_attempted_ = false;
- bool required_dex_checksum_found_;
+ // Cached value of the required dex checksums.
+ // This should be accessed only by the GetRequiredDexChecksums() method.
+ std::vector<uint32_t> cached_required_dex_checksums_;
+ bool required_dex_checksums_attempted_ = false;
+ bool required_dex_checksums_found_;
bool has_original_dex_files_;
OatFileInfo odex_;
diff --git a/runtime/oat_file_assistant_test.cc b/runtime/oat_file_assistant_test.cc
index f777340..6cfe3d1 100644
--- a/runtime/oat_file_assistant_test.cc
+++ b/runtime/oat_file_assistant_test.cc
@@ -237,16 +237,16 @@
EXPECT_EQ(2u, dex_files.size());
}
-// Case: We have a MultiDEX file where the secondary dex file is out of date.
+// Case: We have a MultiDEX file where the non-main multdex entry is out of date.
// Expect: The status is kDex2OatNeeded.
-TEST_F(OatFileAssistantTest, MultiDexSecondaryOutOfDate) {
- std::string dex_location = GetScratchDir() + "/MultiDexSecondaryOutOfDate.jar";
+TEST_F(OatFileAssistantTest, MultiDexNonMainOutOfDate) {
+ std::string dex_location = GetScratchDir() + "/MultiDexNonMainOutOfDate.jar";
// Compile code for GetMultiDexSrc1.
Copy(GetMultiDexSrc1(), dex_location);
GenerateOatForTest(dex_location.c_str(), CompilerFilter::kSpeed);
- // Now overwrite the dex file with GetMultiDexSrc2 so the secondary checksum
+ // Now overwrite the dex file with GetMultiDexSrc2 so the non-main checksum
// is out of date.
Copy(GetMultiDexSrc2(), dex_location);
@@ -256,6 +256,37 @@
EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
}
+// Case: We have a stripped MultiDEX file where the non-main multidex entry is
+// out of date with respect to the odex file.
+TEST_F(OatFileAssistantTest, StrippedMultiDexNonMainOutOfDate) {
+ std::string dex_location = GetScratchDir() + "/StrippedMultiDexNonMainOutOfDate.jar";
+ std::string odex_location = GetOdexDir() + "/StrippedMultiDexNonMainOutOfDate.odex";
+
+ // Compile the oat from GetMultiDexSrc1.
+ Copy(GetMultiDexSrc1(), dex_location);
+ GenerateOatForTest(dex_location.c_str(), CompilerFilter::kSpeed);
+
+ // Compile the odex from GetMultiDexSrc2, which has a different non-main
+ // dex checksum.
+ Copy(GetMultiDexSrc2(), dex_location);
+ GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kInterpretOnly);
+
+ // Strip the dex file.
+ Copy(GetStrippedDexSrc1(), dex_location);
+
+ OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, /*load_executable*/false);
+
+ // Because the dex file is stripped, the odex file is considered the source
+ // of truth for the dex checksums. The oat file should be considered
+ // unusable.
+ std::unique_ptr<OatFile> best_file = oat_file_assistant.GetBestOatFile();
+ ASSERT_TRUE(best_file.get() != nullptr);
+ EXPECT_EQ(best_file->GetLocation(), odex_location);
+ EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
+ EXPECT_EQ(OatFileAssistant::kOatUpToDate, oat_file_assistant.OdexFileStatus());
+ EXPECT_EQ(OatFileAssistant::kOatDexOutOfDate, oat_file_assistant.OatFileStatus());
+}
+
// Case: We have a MultiDEX file and up-to-date OAT file for it with relative
// encoded dex locations.
// Expect: The oat file status is kNoDexOptNeeded.
@@ -336,16 +367,16 @@
oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
}
-// Case: We have a MultiDEX (ODEX) VDEX file where the secondary dex file is
-// out of date and there is no corresponding ODEX file.
-TEST_F(OatFileAssistantTest, VdexMultiDexSecondaryOutOfDate) {
+// Case: We have a MultiDEX (ODEX) VDEX file where the non-main multidex entry
+// is out of date and there is no corresponding ODEX file.
+TEST_F(OatFileAssistantTest, VdexMultiDexNonMainOutOfDate) {
// This test case is only meaningful if vdex is enabled.
if (!kIsVdexEnabled) {
return;
}
- std::string dex_location = GetScratchDir() + "/VdexMultiDexSecondaryOutOfDate.jar";
- std::string oat_location = GetOdexDir() + "/VdexMultiDexSecondaryOutOfDate.oat";
+ std::string dex_location = GetScratchDir() + "/VdexMultiDexNonMainOutOfDate.jar";
+ std::string oat_location = GetOdexDir() + "/VdexMultiDexNonMainOutOfDate.oat";
Copy(GetMultiDexSrc1(), dex_location);
GenerateOdexForTest(dex_location, oat_location, CompilerFilter::kSpeed);
diff --git a/runtime/oat_file_test.cc b/runtime/oat_file_test.cc
index b416b9d..d5fe1f3 100644
--- a/runtime/oat_file_test.cc
+++ b/runtime/oat_file_test.cc
@@ -62,54 +62,4 @@
"/data/app/foo/base.apk", "o/base.apk"));
}
-static std::vector<const DexFile*> ToConstDexFiles(
- const std::vector<std::unique_ptr<const DexFile>>& in) {
- std::vector<const DexFile*> ret;
- for (auto& d : in) {
- ret.push_back(d.get());
- }
- return ret;
-}
-
-TEST_F(OatFileTest, DexFileDependencies) {
- std::string error_msg;
-
- // No dependencies.
- EXPECT_TRUE(OatFile::CheckStaticDexFileDependencies(nullptr, &error_msg)) << error_msg;
- EXPECT_TRUE(OatFile::CheckStaticDexFileDependencies("", &error_msg)) << error_msg;
-
- // Ill-formed dependencies.
- EXPECT_FALSE(OatFile::CheckStaticDexFileDependencies("abc", &error_msg));
- EXPECT_FALSE(OatFile::CheckStaticDexFileDependencies("abc*123*def", &error_msg));
- EXPECT_FALSE(OatFile::CheckStaticDexFileDependencies("abc*def*", &error_msg));
-
- // Unsatisfiable dependency.
- EXPECT_FALSE(OatFile::CheckStaticDexFileDependencies("abc*123*", &error_msg));
-
- // Load some dex files to be able to do a real test.
- ScopedObjectAccess soa(Thread::Current());
-
- std::vector<std::unique_ptr<const DexFile>> dex_files1 = OpenTestDexFiles("Main");
- std::vector<const DexFile*> dex_files_const1 = ToConstDexFiles(dex_files1);
- std::string encoding1 = OatFile::EncodeDexFileDependencies(dex_files_const1);
- EXPECT_TRUE(OatFile::CheckStaticDexFileDependencies(encoding1.c_str(), &error_msg))
- << error_msg << " " << encoding1;
- std::vector<std::string> split1;
- EXPECT_TRUE(OatFile::GetDexLocationsFromDependencies(encoding1.c_str(), &split1));
- ASSERT_EQ(split1.size(), 1U);
- EXPECT_EQ(split1[0], dex_files_const1[0]->GetLocation());
-
- std::vector<std::unique_ptr<const DexFile>> dex_files2 = OpenTestDexFiles("MultiDex");
- EXPECT_GT(dex_files2.size(), 1U);
- std::vector<const DexFile*> dex_files_const2 = ToConstDexFiles(dex_files2);
- std::string encoding2 = OatFile::EncodeDexFileDependencies(dex_files_const2);
- EXPECT_TRUE(OatFile::CheckStaticDexFileDependencies(encoding2.c_str(), &error_msg))
- << error_msg << " " << encoding2;
- std::vector<std::string> split2;
- EXPECT_TRUE(OatFile::GetDexLocationsFromDependencies(encoding2.c_str(), &split2));
- ASSERT_EQ(split2.size(), 2U);
- EXPECT_EQ(split2[0], dex_files_const2[0]->GetLocation());
- EXPECT_EQ(split2[1], dex_files_const2[1]->GetLocation());
-}
-
} // namespace art
diff --git a/runtime/openjdkjvmti/ti_class.cc b/runtime/openjdkjvmti/ti_class.cc
index cf3cfa4..7ca233f 100644
--- a/runtime/openjdkjvmti/ti_class.cc
+++ b/runtime/openjdkjvmti/ti_class.cc
@@ -50,6 +50,9 @@
#include "mirror/array-inl.h"
#include "mirror/class-inl.h"
#include "mirror/class_ext.h"
+#include "mirror/object_reference.h"
+#include "mirror/object-inl.h"
+#include "mirror/reference.h"
#include "runtime.h"
#include "runtime_callbacks.h"
#include "ScopedLocalRef.h"
@@ -347,6 +350,7 @@
FixupGlobalReferenceTables(input, output);
FixupLocalReferenceTables(self, input, output);
+ FixupHeap(input, output);
}
if (heap->IsGcConcurrentAndMoving()) {
heap->DecrementDisableMovingGC(self);
@@ -385,8 +389,7 @@
art::mirror::Class* output_;
};
- void FixupGlobalReferenceTables(art::mirror::Class* input,
- art::mirror::Class* output)
+ void FixupGlobalReferenceTables(art::mirror::Class* input, art::mirror::Class* output)
REQUIRES(art::Locks::mutator_lock_) {
art::JavaVMExt* java_vm = art::Runtime::Current()->GetJavaVM();
@@ -441,6 +444,62 @@
art::Runtime::Current()->GetThreadList()->ForEach(LocalUpdate::Callback, &local_upd);
}
+ void FixupHeap(art::mirror::Class* input, art::mirror::Class* output)
+ REQUIRES(art::Locks::mutator_lock_) {
+ class HeapFixupVisitor {
+ public:
+ HeapFixupVisitor(const art::mirror::Class* root_input, art::mirror::Class* root_output)
+ : input_(root_input), output_(root_output) {}
+
+ void operator()(art::mirror::Object* src,
+ art::MemberOffset field_offset,
+ bool is_static ATTRIBUTE_UNUSED) const
+ REQUIRES_SHARED(art::Locks::mutator_lock_) {
+ art::mirror::HeapReference<art::mirror::Object>* trg =
+ src->GetFieldObjectReferenceAddr(field_offset);
+ if (trg->AsMirrorPtr() == input_) {
+ DCHECK_NE(field_offset.Uint32Value(), 0u); // This shouldn't be the class field of
+ // an object.
+ trg->Assign(output_);
+ }
+ }
+
+ void operator()(art::ObjPtr<art::mirror::Class> klass ATTRIBUTE_UNUSED,
+ art::ObjPtr<art::mirror::Reference> reference) const
+ REQUIRES_SHARED(art::Locks::mutator_lock_) {
+ art::mirror::Object* val = reference->GetReferent();
+ if (val == input_) {
+ reference->SetReferent<false>(output_);
+ }
+ }
+
+ void VisitRoot(art::mirror::CompressedReference<art::mirror::Object>* root ATTRIBUTE_UNUSED)
+ const {
+ LOG(FATAL) << "Unreachable";
+ }
+
+ void VisitRootIfNonNull(
+ art::mirror::CompressedReference<art::mirror::Object>* root ATTRIBUTE_UNUSED) const {
+ LOG(FATAL) << "Unreachable";
+ }
+
+ static void AllObjectsCallback(art::mirror::Object* obj, void* arg)
+ REQUIRES_SHARED(art::Locks::mutator_lock_) {
+ HeapFixupVisitor* hfv = reinterpret_cast<HeapFixupVisitor*>(arg);
+
+ // Visit references, not native roots.
+ obj->VisitReferences<false>(*hfv, *hfv);
+ }
+
+ private:
+ const art::mirror::Class* input_;
+ art::mirror::Class* output_;
+ };
+ HeapFixupVisitor hfv(input, output);
+ art::Runtime::Current()->GetHeap()->VisitObjectsPaused(HeapFixupVisitor::AllObjectsCallback,
+ &hfv);
+ }
+
// A set of all the temp classes we have handed out. We have to fix up references to these.
// For simplicity, we store the temp classes as JNI global references in a vector. Normally a
// Prepare event will closely follow, so the vector should be small.
diff --git a/runtime/openjdkjvmti/ti_redefine.cc b/runtime/openjdkjvmti/ti_redefine.cc
index 843fd8c..d767c33 100644
--- a/runtime/openjdkjvmti/ti_redefine.cc
+++ b/runtime/openjdkjvmti/ti_redefine.cc
@@ -68,6 +68,66 @@
using android::base::StringPrintf;
+// A helper that fills in a classes obsolete_methods_ and obsolete_dex_caches_ classExt fields as
+// they are created. This ensures that we can always call any method of an obsolete ArtMethod object
+// almost as soon as they are created since the GetObsoleteDexCache method will succeed.
+class ObsoleteMap {
+ public:
+ art::ArtMethod* FindObsoleteVersion(art::ArtMethod* original)
+ REQUIRES(art::Locks::mutator_lock_, art::Roles::uninterruptible_) {
+ auto method_pair = id_map_.find(original);
+ if (method_pair != id_map_.end()) {
+ art::ArtMethod* res = obsolete_methods_->GetElementPtrSize<art::ArtMethod*>(
+ method_pair->second, art::kRuntimePointerSize);
+ DCHECK(res != nullptr);
+ DCHECK_EQ(original, res->GetNonObsoleteMethod());
+ return res;
+ } else {
+ return nullptr;
+ }
+ }
+
+ void RecordObsolete(art::ArtMethod* original, art::ArtMethod* obsolete)
+ REQUIRES(art::Locks::mutator_lock_, art::Roles::uninterruptible_) {
+ DCHECK(original != nullptr);
+ DCHECK(obsolete != nullptr);
+ int32_t slot = next_free_slot_++;
+ DCHECK_LT(slot, obsolete_methods_->GetLength());
+ DCHECK(nullptr ==
+ obsolete_methods_->GetElementPtrSize<art::ArtMethod*>(slot, art::kRuntimePointerSize));
+ DCHECK(nullptr == obsolete_dex_caches_->Get(slot));
+ obsolete_methods_->SetElementPtrSize(slot, obsolete, art::kRuntimePointerSize);
+ obsolete_dex_caches_->Set(slot, original_dex_cache_);
+ id_map_.insert({original, slot});
+ }
+
+ ObsoleteMap(art::ObjPtr<art::mirror::PointerArray> obsolete_methods,
+ art::ObjPtr<art::mirror::ObjectArray<art::mirror::DexCache>> obsolete_dex_caches,
+ art::ObjPtr<art::mirror::DexCache> original_dex_cache)
+ : next_free_slot_(0),
+ obsolete_methods_(obsolete_methods),
+ obsolete_dex_caches_(obsolete_dex_caches),
+ original_dex_cache_(original_dex_cache) {
+ // Figure out where the first unused slot in the obsolete_methods_ array is.
+ while (obsolete_methods_->GetElementPtrSize<art::ArtMethod*>(
+ next_free_slot_, art::kRuntimePointerSize) != nullptr) {
+ DCHECK(obsolete_dex_caches_->Get(next_free_slot_) != nullptr);
+ next_free_slot_++;
+ }
+ // Sanity check that the same slot in obsolete_dex_caches_ is free.
+ DCHECK(obsolete_dex_caches_->Get(next_free_slot_) == nullptr);
+ }
+
+ private:
+ int32_t next_free_slot_;
+ std::unordered_map<art::ArtMethod*, int32_t> id_map_;
+ // Pointers to the fields in mirror::ClassExt. These can be held as ObjPtr since this is only used
+ // when we have an exclusive mutator_lock_ (i.e. all threads are suspended).
+ art::ObjPtr<art::mirror::PointerArray> obsolete_methods_;
+ art::ObjPtr<art::mirror::ObjectArray<art::mirror::DexCache>> obsolete_dex_caches_;
+ art::ObjPtr<art::mirror::DexCache> original_dex_cache_;
+};
+
// This visitor walks thread stacks and allocates and sets up the obsolete methods. It also does
// some basic sanity checks that the obsolete method is sane.
class ObsoleteMethodStackVisitor : public art::StackVisitor {
@@ -76,7 +136,7 @@
art::Thread* thread,
art::LinearAlloc* allocator,
const std::unordered_set<art::ArtMethod*>& obsoleted_methods,
- /*out*/std::unordered_map<art::ArtMethod*, art::ArtMethod*>* obsolete_maps)
+ ObsoleteMap* obsolete_maps)
: StackVisitor(thread,
/*context*/nullptr,
StackVisitor::StackWalkKind::kIncludeInlinedFrames),
@@ -94,7 +154,7 @@
art::Thread* thread,
art::LinearAlloc* allocator,
const std::unordered_set<art::ArtMethod*>& obsoleted_methods,
- /*out*/std::unordered_map<art::ArtMethod*, art::ArtMethod*>* obsolete_maps)
+ ObsoleteMap* obsolete_maps)
REQUIRES(art::Locks::mutator_lock_) {
ObsoleteMethodStackVisitor visitor(thread,
allocator,
@@ -104,6 +164,7 @@
}
bool VisitFrame() OVERRIDE REQUIRES(art::Locks::mutator_lock_) {
+ art::ScopedAssertNoThreadSuspension snts("Fixing up the stack for obsolete methods.");
art::ArtMethod* old_method = GetMethod();
if (obsoleted_methods_.find(old_method) != obsoleted_methods_.end()) {
// We cannot ensure that the right dex file is used in inlined frames so we don't support
@@ -113,9 +174,8 @@
// TODO We should really support redefining intrinsics.
// We don't support intrinsics so check for them here.
DCHECK(!old_method->IsIntrinsic());
- art::ArtMethod* new_obsolete_method = nullptr;
- auto obsolete_method_pair = obsolete_maps_->find(old_method);
- if (obsolete_method_pair == obsolete_maps_->end()) {
+ art::ArtMethod* new_obsolete_method = obsolete_maps_->FindObsoleteVersion(old_method);
+ if (new_obsolete_method == nullptr) {
// Create a new Obsolete Method and put it in the list.
art::Runtime* runtime = art::Runtime::Current();
art::ClassLinker* cl = runtime->GetClassLinker();
@@ -129,7 +189,7 @@
DCHECK_EQ(new_obsolete_method->GetDeclaringClass(), old_method->GetDeclaringClass());
new_obsolete_method->SetIsObsolete();
new_obsolete_method->SetDontCompile();
- obsolete_maps_->insert({old_method, new_obsolete_method});
+ obsolete_maps_->RecordObsolete(old_method, new_obsolete_method);
// Update JIT Data structures to point to the new method.
art::jit::Jit* jit = art::Runtime::Current()->GetJit();
if (jit != nullptr) {
@@ -137,8 +197,6 @@
// structures to keep track of the new obsolete method.
jit->GetCodeCache()->MoveObsoleteMethod(old_method, new_obsolete_method);
}
- } else {
- new_obsolete_method = obsolete_method_pair->second;
}
DCHECK(new_obsolete_method != nullptr);
SetMethod(new_obsolete_method);
@@ -152,9 +210,9 @@
// The set of all methods which could be obsoleted.
const std::unordered_set<art::ArtMethod*>& obsoleted_methods_;
// A map from the original to the newly allocated obsolete method for frames on this thread. The
- // values in this map must be added to the obsolete_methods_ (and obsolete_dex_caches_) fields of
- // the redefined classes ClassExt by the caller.
- std::unordered_map<art::ArtMethod*, art::ArtMethod*>* obsolete_maps_;
+ // values in this map are added to the obsolete_methods_ (and obsolete_dex_caches_) fields of
+ // the redefined classes ClassExt as it is filled.
+ ObsoleteMap* obsolete_maps_;
};
jvmtiError Redefiner::IsModifiableClass(jvmtiEnv* env ATTRIBUTE_UNUSED,
@@ -431,11 +489,12 @@
}
struct CallbackCtx {
+ ObsoleteMap* obsolete_map;
art::LinearAlloc* allocator;
- std::unordered_map<art::ArtMethod*, art::ArtMethod*> obsolete_map;
std::unordered_set<art::ArtMethod*> obsolete_methods;
- explicit CallbackCtx(art::LinearAlloc* alloc) : allocator(alloc) {}
+ explicit CallbackCtx(ObsoleteMap* map, art::LinearAlloc* alloc)
+ : obsolete_map(map), allocator(alloc) {}
};
void DoAllocateObsoleteMethodsCallback(art::Thread* t, void* vdata) NO_THREAD_SAFETY_ANALYSIS {
@@ -443,7 +502,7 @@
ObsoleteMethodStackVisitor::UpdateObsoleteFrames(t,
data->allocator,
data->obsolete_methods,
- &data->obsolete_map);
+ data->obsolete_map);
}
// This creates any ArtMethod* structures needed for obsolete methods and ensures that the stack is
@@ -454,9 +513,18 @@
art::mirror::ClassExt* ext = art_klass->GetExtData();
CHECK(ext->GetObsoleteMethods() != nullptr);
art::ClassLinker* linker = driver_->runtime_->GetClassLinker();
- CallbackCtx ctx(linker->GetAllocatorForClassLoader(art_klass->GetClassLoader()));
+ // This holds pointers to the obsolete methods map fields which are updated as needed.
+ ObsoleteMap map(ext->GetObsoleteMethods(), ext->GetObsoleteDexCaches(), art_klass->GetDexCache());
+ CallbackCtx ctx(&map, linker->GetAllocatorForClassLoader(art_klass->GetClassLoader()));
// Add all the declared methods to the map
for (auto& m : art_klass->GetDeclaredMethods(art::kRuntimePointerSize)) {
+ // It is possible to simply filter out some methods where they cannot really become obsolete,
+ // such as native methods and keep their original (possibly optimized) implementations. We don't
+ // do this, however, since we would need to mark these functions (still in the classes
+ // declared_methods array) as obsolete so we will find the correct dex file to get meta-data
+ // from (for example about stack-frame size). Furthermore we would be unable to get some useful
+ // error checking from the interpreter which ensure we don't try to start executing obsolete
+ // methods.
ctx.obsolete_methods.insert(&m);
// TODO Allow this or check in IsModifiableClass.
DCHECK(!m.IsIntrinsic());
@@ -466,36 +534,6 @@
art::ThreadList* list = art::Runtime::Current()->GetThreadList();
list->ForEach(DoAllocateObsoleteMethodsCallback, static_cast<void*>(&ctx));
}
- FillObsoleteMethodMap(art_klass, ctx.obsolete_map);
-}
-
-// Fills the obsolete method map in the art_klass's extData. This is so obsolete methods are able to
-// figure out their DexCaches.
-void Redefiner::ClassRedefinition::FillObsoleteMethodMap(
- art::mirror::Class* art_klass,
- const std::unordered_map<art::ArtMethod*, art::ArtMethod*>& obsoletes) {
- int32_t index = 0;
- art::mirror::ClassExt* ext_data = art_klass->GetExtData();
- art::mirror::PointerArray* obsolete_methods = ext_data->GetObsoleteMethods();
- art::mirror::ObjectArray<art::mirror::DexCache>* obsolete_dex_caches =
- ext_data->GetObsoleteDexCaches();
- int32_t num_method_slots = obsolete_methods->GetLength();
- // Find the first empty index.
- for (; index < num_method_slots; index++) {
- if (obsolete_methods->GetElementPtrSize<art::ArtMethod*>(
- index, art::kRuntimePointerSize) == nullptr) {
- break;
- }
- }
- // Make sure we have enough space.
- CHECK_GT(num_method_slots, static_cast<int32_t>(obsoletes.size() + index));
- CHECK(obsolete_dex_caches->Get(index) == nullptr);
- // Fill in the map.
- for (auto& obs : obsoletes) {
- obsolete_methods->SetElementPtrSize(index, obs.second, art::kRuntimePointerSize);
- obsolete_dex_caches->Set(index, art_klass->GetDexCache());
- index++;
- }
}
// Try and get the declared method. First try to get a virtual method then a direct method if that's
diff --git a/runtime/openjdkjvmti/ti_redefine.h b/runtime/openjdkjvmti/ti_redefine.h
index c441377..65ee291 100644
--- a/runtime/openjdkjvmti/ti_redefine.h
+++ b/runtime/openjdkjvmti/ti_redefine.h
@@ -155,12 +155,6 @@
void FindAndAllocateObsoleteMethods(art::mirror::Class* art_klass)
REQUIRES(art::Locks::mutator_lock_);
- void FillObsoleteMethodMap(
- art::mirror::Class* art_klass,
- const std::unordered_map<art::ArtMethod*, art::ArtMethod*>& obsoletes)
- REQUIRES(art::Locks::mutator_lock_);
-
-
// Checks that the dex file contains only the single expected class and that the top-level class
// data has not been modified in an incompatible manner.
bool CheckClass() REQUIRES_SHARED(art::Locks::mutator_lock_);
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 9609bee..f8f3d76 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -95,6 +95,7 @@
#include "mirror/field.h"
#include "mirror/method.h"
#include "mirror/method_handle_impl.h"
+#include "mirror/method_handles_lookup.h"
#include "mirror/method_type.h"
#include "mirror/stack_trace_element.h"
#include "mirror/throwable.h"
@@ -1715,6 +1716,7 @@
mirror::Field::VisitRoots(visitor);
mirror::MethodType::VisitRoots(visitor);
mirror::MethodHandleImpl::VisitRoots(visitor);
+ mirror::MethodHandlesLookup::VisitRoots(visitor);
mirror::EmulatedStackFrame::VisitRoots(visitor);
mirror::ClassExt::VisitRoots(visitor);
// Visit all the primitive array types classes.
diff --git a/runtime/stack.cc b/runtime/stack.cc
index d7ba1d7..51a24e4 100644
--- a/runtime/stack.cc
+++ b/runtime/stack.cc
@@ -874,9 +874,13 @@
CHECK_EQ(GetMethod(), callee) << "Expected: " << ArtMethod::PrettyMethod(callee)
<< " Found: " << ArtMethod::PrettyMethod(GetMethod());
} else {
- CHECK_EQ(instrumentation_frame.method_, GetMethod())
- << "Expected: " << ArtMethod::PrettyMethod(instrumentation_frame.method_)
- << " Found: " << ArtMethod::PrettyMethod(GetMethod());
+ // Instrumentation generally doesn't distinguish between a method's obsolete and
+ // non-obsolete version.
+ CHECK_EQ(instrumentation_frame.method_->GetNonObsoleteMethod(),
+ GetMethod()->GetNonObsoleteMethod())
+ << "Expected: "
+ << ArtMethod::PrettyMethod(instrumentation_frame.method_->GetNonObsoleteMethod())
+ << " Found: " << ArtMethod::PrettyMethod(GetMethod()->GetNonObsoleteMethod());
}
if (num_frames_ != 0) {
// Check agreement of frame Ids only if num_frames_ is computed to avoid infinite
@@ -903,7 +907,7 @@
<< " native=" << method->IsNative()
<< std::noboolalpha
<< " entrypoints=" << method->GetEntryPointFromQuickCompiledCode()
- << "," << method->GetEntryPointFromJni()
+ << "," << (method->IsNative() ? method->GetEntryPointFromJni() : nullptr)
<< " next=" << *cur_quick_frame_;
}
diff --git a/runtime/thread-inl.h b/runtime/thread-inl.h
index c92305f..8d94626 100644
--- a/runtime/thread-inl.h
+++ b/runtime/thread-inl.h
@@ -80,7 +80,34 @@
}
}
-inline void Thread::CheckEmptyCheckpoint() {
+inline void Thread::CheckEmptyCheckpointFromWeakRefAccess(BaseMutex* cond_var_mutex) {
+ Thread* self = Thread::Current();
+ DCHECK_EQ(self, this);
+ for (;;) {
+ if (ReadFlag(kEmptyCheckpointRequest)) {
+ RunEmptyCheckpoint();
+ // Check we hold only an expected mutex when accessing weak ref.
+ if (kIsDebugBuild) {
+ for (int i = kLockLevelCount - 1; i >= 0; --i) {
+ BaseMutex* held_mutex = self->GetHeldMutex(static_cast<LockLevel>(i));
+ if (held_mutex != nullptr &&
+ held_mutex != Locks::mutator_lock_ &&
+ held_mutex != cond_var_mutex) {
+ std::vector<BaseMutex*>& expected_mutexes = Locks::expected_mutexes_on_weak_ref_access_;
+ CHECK(std::find(expected_mutexes.begin(), expected_mutexes.end(), held_mutex) !=
+ expected_mutexes.end())
+ << "Holding unexpected mutex " << held_mutex->GetName()
+ << " when accessing weak ref";
+ }
+ }
+ }
+ } else {
+ break;
+ }
+ }
+}
+
+inline void Thread::CheckEmptyCheckpointFromMutex() {
DCHECK_EQ(Thread::Current(), this);
for (;;) {
if (ReadFlag(kEmptyCheckpointRequest)) {
diff --git a/runtime/thread.h b/runtime/thread.h
index 3a1b7da..a46e799 100644
--- a/runtime/thread.h
+++ b/runtime/thread.h
@@ -176,7 +176,8 @@
void CheckSuspend() REQUIRES_SHARED(Locks::mutator_lock_);
// Process a pending empty checkpoint if pending.
- void CheckEmptyCheckpoint() REQUIRES_SHARED(Locks::mutator_lock_);
+ void CheckEmptyCheckpointFromWeakRefAccess(BaseMutex* cond_var_mutex);
+ void CheckEmptyCheckpointFromMutex();
static Thread* FromManagedThread(const ScopedObjectAccessAlreadyRunnable& ts,
ObjPtr<mirror::Object> thread_peer)
diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc
index df8acc3..caed369 100644
--- a/runtime/thread_list.cc
+++ b/runtime/thread_list.cc
@@ -379,13 +379,15 @@
return count;
}
-size_t ThreadList::RunEmptyCheckpoint(std::vector<uint32_t>& runnable_thread_ids) {
+void ThreadList::RunEmptyCheckpoint() {
Thread* self = Thread::Current();
Locks::mutator_lock_->AssertNotExclusiveHeld(self);
Locks::thread_list_lock_->AssertNotHeld(self);
Locks::thread_suspend_count_lock_->AssertNotHeld(self);
-
+ std::vector<uint32_t> runnable_thread_ids;
size_t count = 0;
+ Barrier* barrier = empty_checkpoint_barrier_.get();
+ barrier->Init(self, 0);
{
MutexLock mu(self, *Locks::thread_list_lock_);
MutexLock mu2(self, *Locks::thread_suspend_count_lock_);
@@ -415,8 +417,72 @@
// checkpoint request. Otherwise we will hang as they are blocking in the kRunnable state.
Runtime::Current()->GetHeap()->GetReferenceProcessor()->BroadcastForSlowPath(self);
Runtime::Current()->BroadcastForNewSystemWeaks(/*broadcast_for_checkpoint*/true);
-
- return count;
+ {
+ ScopedThreadStateChange tsc(self, kWaitingForCheckPointsToRun);
+ uint64_t total_wait_time = 0;
+ bool first_iter = true;
+ while (true) {
+ // Wake up the runnable threads blocked on the mutexes that another thread, which is blocked
+ // on a weak ref access, holds (indirectly blocking for weak ref access through another thread
+ // and a mutex.) This needs to be done periodically because the thread may be preempted
+ // between the CheckEmptyCheckpointFromMutex call and the subsequent futex wait in
+ // Mutex::ExclusiveLock, etc. when the wakeup via WakeupToRespondToEmptyCheckpoint
+ // arrives. This could cause a *very rare* deadlock, if not repeated. Most of the cases are
+ // handled in the first iteration.
+ for (BaseMutex* mutex : Locks::expected_mutexes_on_weak_ref_access_) {
+ mutex->WakeupToRespondToEmptyCheckpoint();
+ }
+ static constexpr uint64_t kEmptyCheckpointPeriodicTimeoutMs = 100; // 100ms
+ static constexpr uint64_t kEmptyCheckpointTotalTimeoutMs = 600 * 1000; // 10 minutes.
+ size_t barrier_count = first_iter ? count : 0;
+ first_iter = false; // Don't add to the barrier count from the second iteration on.
+ bool timed_out = barrier->Increment(self, barrier_count, kEmptyCheckpointPeriodicTimeoutMs);
+ if (!timed_out) {
+ break; // Success
+ }
+ // This is a very rare case.
+ total_wait_time += kEmptyCheckpointPeriodicTimeoutMs;
+ if (kIsDebugBuild && total_wait_time > kEmptyCheckpointTotalTimeoutMs) {
+ std::ostringstream ss;
+ ss << "Empty checkpoint timeout\n";
+ ss << "Barrier count " << barrier->GetCount(self) << "\n";
+ ss << "Runnable thread IDs";
+ for (uint32_t tid : runnable_thread_ids) {
+ ss << " " << tid;
+ }
+ ss << "\n";
+ Locks::mutator_lock_->Dump(ss);
+ ss << "\n";
+ LOG(FATAL_WITHOUT_ABORT) << ss.str();
+ // Some threads in 'runnable_thread_ids' are probably stuck. Try to dump their stacks.
+ // Avoid using ThreadList::Dump() initially because it is likely to get stuck as well.
+ {
+ ScopedObjectAccess soa(self);
+ MutexLock mu1(self, *Locks::thread_list_lock_);
+ for (Thread* thread : GetList()) {
+ uint32_t tid = thread->GetThreadId();
+ bool is_in_runnable_thread_ids =
+ std::find(runnable_thread_ids.begin(), runnable_thread_ids.end(), tid) !=
+ runnable_thread_ids.end();
+ if (is_in_runnable_thread_ids &&
+ thread->ReadFlag(kEmptyCheckpointRequest)) {
+ // Found a runnable thread that hasn't responded to the empty checkpoint request.
+ // Assume it's stuck and safe to dump its stack.
+ thread->Dump(LOG_STREAM(FATAL_WITHOUT_ABORT),
+ /*dump_native_stack*/ true,
+ /*backtrace_map*/ nullptr,
+ /*force_dump_stack*/ true);
+ }
+ }
+ }
+ LOG(FATAL_WITHOUT_ABORT)
+ << "Dumped runnable threads that haven't responded to empty checkpoint.";
+ // Now use ThreadList::Dump() to dump more threads, noting it may get stuck.
+ Dump(LOG_STREAM(FATAL_WITHOUT_ABORT));
+ LOG(FATAL) << "Dumped all threads.";
+ }
+ }
+ }
}
// Request that a checkpoint function be run on all active (non-suspended)
diff --git a/runtime/thread_list.h b/runtime/thread_list.h
index b60fca1..70917eb 100644
--- a/runtime/thread_list.h
+++ b/runtime/thread_list.h
@@ -109,9 +109,7 @@
// in-flight mutator heap access (eg. a read barrier.) Runnable threads will respond by
// decrementing the empty checkpoint barrier count. This works even when the weak ref access is
// disabled. Only one concurrent use is currently supported.
- // In debug build, runnable_thread_ids will be populated with the thread IDS of the runnable
- // thread to wait for.
- size_t RunEmptyCheckpoint(std::vector<uint32_t>& runnable_thread_ids)
+ void RunEmptyCheckpoint()
REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
size_t RunCheckpointOnRunnableThreads(Closure* checkpoint_function)
diff --git a/runtime/utils.h b/runtime/utils.h
index 67438b5..96e5bfa 100644
--- a/runtime/utils.h
+++ b/runtime/utils.h
@@ -301,6 +301,30 @@
}
}
+// Returns a type cast pointer if object pointed to is within the provided bounds.
+// Otherwise returns nullptr.
+template <typename T>
+inline static T BoundsCheckedCast(const void* pointer,
+ const void* lower,
+ const void* upper) {
+ const uint8_t* bound_begin = static_cast<const uint8_t*>(lower);
+ const uint8_t* bound_end = static_cast<const uint8_t*>(upper);
+ DCHECK(bound_begin <= bound_end);
+
+ T result = reinterpret_cast<T>(pointer);
+ const uint8_t* begin = static_cast<const uint8_t*>(pointer);
+ const uint8_t* end = begin + sizeof(*result);
+ if (begin < bound_begin || end > bound_end || begin > end) {
+ return nullptr;
+ }
+ return result;
+}
+
+template <typename T, size_t size>
+constexpr size_t ArrayCount(const T (&)[size]) {
+ return size;
+}
+
} // namespace art
#endif // ART_RUNTIME_UTILS_H_
diff --git a/runtime/utils/dex_cache_arrays_layout-inl.h b/runtime/utils/dex_cache_arrays_layout-inl.h
index bd1b044..9865821 100644
--- a/runtime/utils/dex_cache_arrays_layout-inl.h
+++ b/runtime/utils/dex_cache_arrays_layout-inl.h
@@ -29,7 +29,8 @@
namespace art {
inline DexCacheArraysLayout::DexCacheArraysLayout(PointerSize pointer_size,
- const DexFile::Header& header)
+ const DexFile::Header& header,
+ uint32_t num_call_sites)
: pointer_size_(pointer_size),
/* types_offset_ is always 0u, so it's constexpr */
methods_offset_(
@@ -40,12 +41,14 @@
RoundUp(strings_offset_ + StringsSize(header.string_ids_size_), FieldsAlignment())),
method_types_offset_(
RoundUp(fields_offset_ + FieldsSize(header.field_ids_size_), MethodTypesAlignment())),
- size_(
- RoundUp(method_types_offset_ + MethodTypesSize(header.proto_ids_size_), Alignment())) {
+ call_sites_offset_(
+ RoundUp(method_types_offset_ + MethodTypesSize(header.proto_ids_size_),
+ MethodTypesAlignment())),
+ size_(RoundUp(call_sites_offset_ + CallSitesSize(num_call_sites), Alignment())) {
}
inline DexCacheArraysLayout::DexCacheArraysLayout(PointerSize pointer_size, const DexFile* dex_file)
- : DexCacheArraysLayout(pointer_size, dex_file->GetHeader()) {
+ : DexCacheArraysLayout(pointer_size, dex_file->GetHeader(), dex_file->NumCallSiteIds()) {
}
inline constexpr size_t DexCacheArraysLayout::Alignment() {
@@ -131,10 +134,18 @@
inline size_t DexCacheArraysLayout::MethodTypesAlignment() const {
static_assert(alignof(mirror::MethodTypeDexCacheType) == 8,
- "alignof(MethodTypeDexCacheType) != 8");
+ "Expecting alignof(MethodTypeDexCacheType) == 8");
return alignof(mirror::MethodTypeDexCacheType);
}
+inline size_t DexCacheArraysLayout::CallSitesSize(size_t num_elements) const {
+ return ArraySize(GcRootAsPointerSize<mirror::CallSite>(), num_elements);
+}
+
+inline size_t DexCacheArraysLayout::CallSitesAlignment() const {
+ return alignof(GcRoot<mirror::CallSite>);
+}
+
inline size_t DexCacheArraysLayout::ElementOffset(PointerSize element_size, uint32_t idx) {
return static_cast<size_t>(element_size) * idx;
}
diff --git a/runtime/utils/dex_cache_arrays_layout.h b/runtime/utils/dex_cache_arrays_layout.h
index 7d4b23a..ed677ed 100644
--- a/runtime/utils/dex_cache_arrays_layout.h
+++ b/runtime/utils/dex_cache_arrays_layout.h
@@ -37,11 +37,14 @@
strings_offset_(0u),
fields_offset_(0u),
method_types_offset_(0u),
+ call_sites_offset_(0u),
size_(0u) {
}
// Construct a layout for a particular dex file header.
- DexCacheArraysLayout(PointerSize pointer_size, const DexFile::Header& header);
+ DexCacheArraysLayout(PointerSize pointer_size,
+ const DexFile::Header& header,
+ uint32_t num_call_sites);
// Construct a layout for a particular dex file.
DexCacheArraysLayout(PointerSize pointer_size, const DexFile* dex_file);
@@ -104,6 +107,14 @@
size_t MethodTypesAlignment() const;
+ size_t CallSitesOffset() const {
+ return call_sites_offset_;
+ }
+
+ size_t CallSitesSize(size_t num_elements) const;
+
+ size_t CallSitesAlignment() const;
+
private:
static constexpr size_t types_offset_ = 0u;
const PointerSize pointer_size_; // Must be first for construction initialization order.
@@ -111,6 +122,7 @@
const size_t strings_offset_;
const size_t fields_offset_;
const size_t method_types_offset_;
+ const size_t call_sites_offset_;
const size_t size_;
static size_t Alignment(PointerSize pointer_size);
diff --git a/runtime/utils_test.cc b/runtime/utils_test.cc
index 02f1e1b..634bd47 100644
--- a/runtime/utils_test.cc
+++ b/runtime/utils_test.cc
@@ -408,4 +408,23 @@
IsValidDescriptor(reinterpret_cast<char*>(&unpaired_surrogate_with_multibyte_sequence[0])));
}
+TEST_F(UtilsTest, ArrayCount) {
+ int i[64];
+ EXPECT_EQ(ArrayCount(i), 64u);
+ char c[7];
+ EXPECT_EQ(ArrayCount(c), 7u);
+}
+
+TEST_F(UtilsTest, BoundsCheckedCast) {
+ char buffer[64];
+ const char* buffer_end = buffer + ArrayCount(buffer);
+ EXPECT_EQ(BoundsCheckedCast<const uint64_t*>(nullptr, buffer, buffer_end), nullptr);
+ EXPECT_EQ(BoundsCheckedCast<const uint64_t*>(buffer, buffer, buffer_end),
+ reinterpret_cast<const uint64_t*>(buffer));
+ EXPECT_EQ(BoundsCheckedCast<const uint64_t*>(buffer + 56, buffer, buffer_end),
+ reinterpret_cast<const uint64_t*>(buffer + 56));
+ EXPECT_EQ(BoundsCheckedCast<const uint64_t*>(buffer - 1, buffer, buffer_end), nullptr);
+ EXPECT_EQ(BoundsCheckedCast<const uint64_t*>(buffer + 57, buffer, buffer_end), nullptr);
+}
+
} // namespace art
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index 5f55f3f..16739fa 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -3114,6 +3114,44 @@
just_set_result = true;
break;
}
+ case Instruction::INVOKE_CUSTOM:
+ case Instruction::INVOKE_CUSTOM_RANGE: {
+ // Verify registers based on method_type in the call site.
+ bool is_range = (inst->Opcode() == Instruction::INVOKE_CUSTOM_RANGE);
+
+ // Step 1. Check the call site that produces the method handle for invocation
+ const uint32_t call_site_idx = is_range ? inst->VRegB_3rc() : inst->VRegB_35c();
+ if (!CheckCallSite(call_site_idx)) {
+ DCHECK(HasFailures());
+ break;
+ }
+
+ // Step 2. Check the register arguments correspond to the expected arguments for the
+ // method handle produced by step 1. The dex file verifier has checked ranges for
+ // the first three arguments and CheckCallSite has checked the method handle type.
+ CallSiteArrayValueIterator it(*dex_file_, dex_file_->GetCallSiteId(call_site_idx));
+ it.Next(); // Skip to name.
+ it.Next(); // Skip to method type of the method handle
+ const uint32_t proto_idx = static_cast<uint32_t>(it.GetJavaValue().i);
+ const DexFile::ProtoId& proto_id = dex_file_->GetProtoId(proto_idx);
+ DexFileParameterIterator param_it(*dex_file_, proto_id);
+ // Treat method as static as it has yet to be determined.
+ VerifyInvocationArgsFromIterator(¶m_it, inst, METHOD_STATIC, is_range, nullptr);
+ const char* return_descriptor = dex_file_->GetReturnTypeDescriptor(proto_id);
+
+ // Step 3. Propagate return type information
+ const RegType& return_type =
+ reg_types_.FromDescriptor(GetClassLoader(), return_descriptor, false);
+ if (!return_type.IsLowHalf()) {
+ work_line_->SetResultRegisterType(this, return_type);
+ } else {
+ work_line_->SetResultRegisterTypeWide(return_type, return_type.HighHalf(®_types_));
+ }
+ just_set_result = true;
+ // TODO: Add compiler support for invoke-custom (b/35337872).
+ Fail(VERIFY_ERROR_FORCE_INTERPRETER);
+ break;
+ }
case Instruction::NEG_INT:
case Instruction::NOT_INT:
work_line_->CheckUnaryOp(this, inst, reg_types_.Integer(), reg_types_.Integer());
@@ -3423,7 +3461,7 @@
/* These should never appear during verification. */
case Instruction::UNUSED_3E ... Instruction::UNUSED_43:
case Instruction::UNUSED_F3 ... Instruction::UNUSED_F9:
- case Instruction::UNUSED_FC ... Instruction::UNUSED_FF:
+ case Instruction::UNUSED_FE ... Instruction::UNUSED_FF:
case Instruction::UNUSED_79:
case Instruction::UNUSED_7A:
Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Unexpected opcode " << inst->DumpString(dex_file_);
@@ -4094,6 +4132,116 @@
VerifyInvocationArgsFromIterator(&it, inst, method_type, is_range, nullptr);
}
+bool MethodVerifier::CheckCallSite(uint32_t call_site_idx) {
+ CallSiteArrayValueIterator it(*dex_file_, dex_file_->GetCallSiteId(call_site_idx));
+ // Check essential arguments are provided. The dex file verifier has verified indicies of the
+ // main values (method handle, name, method_type).
+ if (it.Size() < 3) {
+ Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Call site #" << call_site_idx
+ << " has too few arguments: "
+ << it.Size() << "< 3";
+ return false;
+ }
+
+ // Get and check the first argument: the method handle.
+ uint32_t method_handle_idx = static_cast<uint32_t>(it.GetJavaValue().i);
+ it.Next();
+ const DexFile::MethodHandleItem& mh = dex_file_->GetMethodHandle(method_handle_idx);
+ if (mh.method_handle_type_ != static_cast<uint16_t>(DexFile::MethodHandleType::kInvokeStatic)) {
+ Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Call site #" << call_site_idx
+ << " argument 0 method handle type is not InvokeStatic";
+ return false;
+ }
+
+ // Skip the second argument, the name to resolve, as checked by the
+ // dex file verifier.
+ it.Next();
+
+ // Skip the third argument, the method type expected, as checked by
+ // the dex file verifier.
+ it.Next();
+
+ // Check the bootstrap method handle and remaining arguments.
+ const DexFile::MethodId& method_id = dex_file_->GetMethodId(mh.field_or_method_idx_);
+ uint32_t length;
+ const char* shorty = dex_file_->GetMethodShorty(method_id, &length);
+
+ if (it.Size() < length - 1) {
+ Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Call site #" << call_site_idx
+ << " too few arguments for bootstrap method: "
+ << it.Size() << " < " << (length - 1);
+ return false;
+ }
+
+ // Check the return type and first 3 arguments are references
+ // (CallSite, Lookup, String, MethodType). If they are not of the
+ // expected types (or subtypes), it will trigger a
+ // WrongMethodTypeException during execution.
+ if (shorty[0] != 'L') {
+ Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Call site #" << call_site_idx
+ << " bootstrap return type is not a reference";
+ return false;
+ }
+
+ for (uint32_t i = 1; i < 4; ++i) {
+ if (shorty[i] != 'L') {
+ Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Call site #" << call_site_idx
+ << " bootstrap method argument " << (i - 1)
+ << " is not a reference";
+ return false;
+ }
+ }
+
+ // Check the optional arguments.
+ for (uint32_t i = 4; i < length; ++i, it.Next()) {
+ bool match = false;
+ switch (it.GetValueType()) {
+ case EncodedArrayValueIterator::ValueType::kBoolean:
+ case EncodedArrayValueIterator::ValueType::kByte:
+ case EncodedArrayValueIterator::ValueType::kShort:
+ case EncodedArrayValueIterator::ValueType::kChar:
+ case EncodedArrayValueIterator::ValueType::kInt:
+ // These all fit within one register and encoders do not seem
+ // too exacting on the encoding type they use (ie using
+ // integer for all of these).
+ match = (strchr("ZBCSI", shorty[i]) != nullptr);
+ break;
+ case EncodedArrayValueIterator::ValueType::kLong:
+ match = ('J' == shorty[i]);
+ break;
+ case EncodedArrayValueIterator::ValueType::kFloat:
+ match = ('F' == shorty[i]);
+ break;
+ case EncodedArrayValueIterator::ValueType::kDouble:
+ match = ('D' == shorty[i]);
+ break;
+ case EncodedArrayValueIterator::ValueType::kMethodType:
+ case EncodedArrayValueIterator::ValueType::kMethodHandle:
+ case EncodedArrayValueIterator::ValueType::kString:
+ case EncodedArrayValueIterator::ValueType::kType:
+ case EncodedArrayValueIterator::ValueType::kNull:
+ match = ('L' == shorty[i]);
+ break;
+ case EncodedArrayValueIterator::ValueType::kField:
+ case EncodedArrayValueIterator::ValueType::kMethod:
+ case EncodedArrayValueIterator::ValueType::kEnum:
+ case EncodedArrayValueIterator::ValueType::kArray:
+ case EncodedArrayValueIterator::ValueType::kAnnotation:
+ // Unreachable based on current EncodedArrayValueIterator::Next().
+ UNREACHABLE();
+ }
+
+ if (!match) {
+ Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Call site #" << call_site_idx
+ << " bootstrap method argument " << (i - 1)
+ << " expected " << shorty[i]
+ << " got value type: " << it.GetValueType();
+ return false;
+ }
+ }
+ return true;
+}
+
class MethodParamListDescriptorIterator {
public:
explicit MethodParamListDescriptorIterator(ArtMethod* res_method) :
diff --git a/runtime/verifier/method_verifier.h b/runtime/verifier/method_verifier.h
index fa5a698..7b67967 100644
--- a/runtime/verifier/method_verifier.h
+++ b/runtime/verifier/method_verifier.h
@@ -697,6 +697,11 @@
REQUIRES_SHARED(Locks::mutator_lock_);
/*
+ * Verify the arguments present for a call site. Returns "true" if all is well, "false" otherwise.
+ */
+ bool CheckCallSite(uint32_t call_site_idx);
+
+ /*
* Verify that the target instruction is not "move-exception". It's important that the only way
* to execute a move-exception is as the first instruction of an exception handler.
* Returns "true" if all is well, "false" if the target instruction is move-exception.
diff --git a/test/021-string2/src/Main.java b/test/021-string2/src/Main.java
index df0a3dd..5a43a4f 100644
--- a/test/021-string2/src/Main.java
+++ b/test/021-string2/src/Main.java
@@ -117,6 +117,9 @@
" " + $noinline$equals(s0_3, s0_1) +
" " + $noinline$equals(s0_3, s0_2) +
" " + $noinline$equals(s0_3, s0_3));
+
+ testEqualsConstString();
+ testConstStringEquals();
}
public static void testCompareToAndEquals() {
@@ -539,6 +542,266 @@
}
}
+ public static void testEqualsConstString() {
+ Assert.assertTrue($noinline$equalsConstString0(""));
+ Assert.assertFalse($noinline$equalsConstString0("1"));
+
+ Assert.assertTrue($noinline$equalsConstString7("0123456"));
+ Assert.assertFalse($noinline$equalsConstString7("012345"));
+ Assert.assertFalse($noinline$equalsConstString7("01234567"));
+ Assert.assertFalse($noinline$equalsConstString7("012345x"));
+ Assert.assertFalse($noinline$equalsConstString7("012345\u0440"));
+
+ Assert.assertTrue($noinline$equalsConstString14("01234567890123"));
+ Assert.assertFalse($noinline$equalsConstString14("0123456789012"));
+ Assert.assertFalse($noinline$equalsConstString14("012345678901234"));
+ Assert.assertFalse($noinline$equalsConstString14("0123456789012x"));
+ Assert.assertFalse($noinline$equalsConstString14("0123456789012\u0440"));
+
+ Assert.assertTrue($noinline$equalsConstString24("012345678901234567890123"));
+ Assert.assertFalse($noinline$equalsConstString24("01234567890123456789012"));
+ Assert.assertFalse($noinline$equalsConstString24("0123456789012345678901234"));
+ Assert.assertFalse($noinline$equalsConstString24("01234567890123456789012x"));
+ Assert.assertFalse($noinline$equalsConstString24("01234567890123456789012\u0440"));
+
+ Assert.assertTrue($noinline$equalsConstString29("01234567890123456789012345678"));
+ Assert.assertFalse($noinline$equalsConstString29("0123456789012345678901234567"));
+ Assert.assertFalse($noinline$equalsConstString29("012345678901234567890123456789"));
+ Assert.assertFalse($noinline$equalsConstString29("0123456789012345678901234567x"));
+ Assert.assertFalse($noinline$equalsConstString29("0123456789012345678901234567\u0440"));
+
+ Assert.assertTrue($noinline$equalsConstString35("01234567890123456789012345678901234"));
+ Assert.assertFalse($noinline$equalsConstString35("0123456789012345678901234567890123"));
+ Assert.assertFalse($noinline$equalsConstString35("012345678901234567890123456789012345"));
+ Assert.assertFalse($noinline$equalsConstString35("0123456789012345678901234567890123x"));
+ Assert.assertFalse(
+ $noinline$equalsConstString35("0123456789012345678901234567890123\u0440"));
+
+ Assert.assertTrue($noinline$equalsConstNonAsciiString7("\u0440123456"));
+ Assert.assertFalse($noinline$equalsConstNonAsciiString7("\u044012345"));
+ Assert.assertFalse($noinline$equalsConstNonAsciiString7("\u04401234567"));
+ Assert.assertFalse($noinline$equalsConstNonAsciiString7("\u044012345x"));
+ Assert.assertFalse($noinline$equalsConstNonAsciiString7("0123456"));
+
+ Assert.assertTrue($noinline$equalsConstNonAsciiString14("\u04401234567890123"));
+ Assert.assertFalse($noinline$equalsConstNonAsciiString14("\u0440123456789012"));
+ Assert.assertFalse($noinline$equalsConstNonAsciiString14("\u044012345678901234"));
+ Assert.assertFalse($noinline$equalsConstNonAsciiString14("\u0440123456789012x"));
+ Assert.assertFalse($noinline$equalsConstNonAsciiString14("01234567890123"));
+
+ Assert.assertTrue($noinline$equalsConstNonAsciiString24("\u044012345678901234567890123"));
+ Assert.assertFalse($noinline$equalsConstNonAsciiString24("\u04401234567890123456789012"));
+ Assert.assertFalse($noinline$equalsConstNonAsciiString24("\u0440123456789012345678901234"));
+ Assert.assertFalse($noinline$equalsConstNonAsciiString24("\u04401234567890123456789012x"));
+ Assert.assertFalse($noinline$equalsConstNonAsciiString24("\012345678901234567890123"));
+
+ Assert.assertTrue(
+ $noinline$equalsConstNonAsciiString29("\u04401234567890123456789012345678"));
+ Assert.assertFalse(
+ $noinline$equalsConstNonAsciiString29("\u0440123456789012345678901234567"));
+ Assert.assertFalse(
+ $noinline$equalsConstNonAsciiString29("\u044012345678901234567890123456789"));
+ Assert.assertFalse(
+ $noinline$equalsConstNonAsciiString29("\u0440123456789012345678901234567x"));
+ Assert.assertFalse($noinline$equalsConstNonAsciiString29("01234567890123456789012345678"));
+
+ Assert.assertTrue(
+ $noinline$equalsConstNonAsciiString35("\u04401234567890123456789012345678901234"));
+ Assert.assertFalse(
+ $noinline$equalsConstNonAsciiString35("\u0440123456789012345678901234567890123"));
+ Assert.assertFalse(
+ $noinline$equalsConstNonAsciiString35("\u044012345678901234567890123456789012345"));
+ Assert.assertFalse(
+ $noinline$equalsConstNonAsciiString35("\u0440123456789012345678901234567890123x"));
+ Assert.assertFalse(
+ $noinline$equalsConstNonAsciiString35("01234567890123456789012345678901234"));
+ }
+
+ public static void testConstStringEquals() {
+ Assert.assertTrue($noinline$constString0Equals(""));
+ Assert.assertFalse($noinline$constString0Equals("1"));
+
+ Assert.assertTrue($noinline$constString7Equals("0123456"));
+ Assert.assertFalse($noinline$constString7Equals("012345"));
+ Assert.assertFalse($noinline$constString7Equals("01234567"));
+ Assert.assertFalse($noinline$constString7Equals("012345x"));
+ Assert.assertFalse($noinline$constString7Equals("012345\u0440"));
+
+ Assert.assertTrue($noinline$constString14Equals("01234567890123"));
+ Assert.assertFalse($noinline$constString14Equals("0123456789012"));
+ Assert.assertFalse($noinline$constString14Equals("012345678901234"));
+ Assert.assertFalse($noinline$constString14Equals("0123456789012x"));
+ Assert.assertFalse($noinline$constString14Equals("0123456789012\u0440"));
+
+ Assert.assertTrue($noinline$constString24Equals("012345678901234567890123"));
+ Assert.assertFalse($noinline$constString24Equals("01234567890123456789012"));
+ Assert.assertFalse($noinline$constString24Equals("0123456789012345678901234"));
+ Assert.assertFalse($noinline$constString24Equals("01234567890123456789012x"));
+ Assert.assertFalse($noinline$constString24Equals("01234567890123456789012\u0440"));
+
+ Assert.assertTrue($noinline$constString29Equals("01234567890123456789012345678"));
+ Assert.assertFalse($noinline$constString29Equals("0123456789012345678901234567"));
+ Assert.assertFalse($noinline$constString29Equals("012345678901234567890123456789"));
+ Assert.assertFalse($noinline$constString29Equals("0123456789012345678901234567x"));
+ Assert.assertFalse($noinline$constString29Equals("0123456789012345678901234567\u0440"));
+
+ Assert.assertTrue($noinline$constString35Equals("01234567890123456789012345678901234"));
+ Assert.assertFalse($noinline$constString35Equals("0123456789012345678901234567890123"));
+ Assert.assertFalse($noinline$constString35Equals("012345678901234567890123456789012345"));
+ Assert.assertFalse($noinline$constString35Equals("0123456789012345678901234567890123x"));
+ Assert.assertFalse(
+ $noinline$constString35Equals("0123456789012345678901234567890123\u0040"));
+
+ Assert.assertTrue($noinline$constNonAsciiString7Equals("\u0440123456"));
+ Assert.assertFalse($noinline$constNonAsciiString7Equals("\u044012345"));
+ Assert.assertFalse($noinline$constNonAsciiString7Equals("\u04401234567"));
+ Assert.assertFalse($noinline$constNonAsciiString7Equals("\u044012345x"));
+ Assert.assertFalse($noinline$constNonAsciiString7Equals("0123456"));
+
+ Assert.assertTrue($noinline$constNonAsciiString14Equals("\u04401234567890123"));
+ Assert.assertFalse($noinline$constNonAsciiString14Equals("\u0440123456789012"));
+ Assert.assertFalse($noinline$constNonAsciiString14Equals("\u044012345678901234"));
+ Assert.assertFalse($noinline$constNonAsciiString14Equals("\u0440123456789012x"));
+ Assert.assertFalse($noinline$constNonAsciiString14Equals("01234567890123"));
+
+ Assert.assertTrue($noinline$constNonAsciiString24Equals("\u044012345678901234567890123"));
+ Assert.assertFalse($noinline$constNonAsciiString24Equals("\u04401234567890123456789012"));
+ Assert.assertFalse($noinline$constNonAsciiString24Equals("\u0440123456789012345678901234"));
+ Assert.assertFalse($noinline$constNonAsciiString24Equals("\u04401234567890123456789012x"));
+ Assert.assertFalse($noinline$constNonAsciiString24Equals("\012345678901234567890123"));
+
+ Assert.assertTrue(
+ $noinline$constNonAsciiString29Equals("\u04401234567890123456789012345678"));
+ Assert.assertFalse(
+ $noinline$constNonAsciiString29Equals("\u0440123456789012345678901234567"));
+ Assert.assertFalse(
+ $noinline$constNonAsciiString29Equals("\u044012345678901234567890123456789"));
+ Assert.assertFalse(
+ $noinline$constNonAsciiString29Equals("\u0440123456789012345678901234567x"));
+ Assert.assertFalse($noinline$constNonAsciiString29Equals("01234567890123456789012345678"));
+
+ Assert.assertTrue(
+ $noinline$constNonAsciiString35Equals("\u04401234567890123456789012345678901234"));
+ Assert.assertFalse(
+ $noinline$constNonAsciiString35Equals("\u0440123456789012345678901234567890123"));
+ Assert.assertFalse(
+ $noinline$constNonAsciiString35Equals("\u044012345678901234567890123456789012345"));
+ Assert.assertFalse(
+ $noinline$constNonAsciiString35Equals("\u0440123456789012345678901234567890123x"));
+ Assert.assertFalse(
+ $noinline$constNonAsciiString35Equals("01234567890123456789012345678901234"));
+ }
+
+ public static boolean $noinline$equalsConstString0(String s) {
+ if (doThrow) { throw new Error(); }
+ return s.equals("");
+ }
+
+ public static boolean $noinline$equalsConstString7(String s) {
+ if (doThrow) { throw new Error(); }
+ return s.equals("0123456");
+ }
+
+ public static boolean $noinline$equalsConstString14(String s) {
+ if (doThrow) { throw new Error(); }
+ return s.equals("01234567890123");
+ }
+
+ public static boolean $noinline$equalsConstString24(String s) {
+ if (doThrow) { throw new Error(); }
+ return s.equals("012345678901234567890123");
+ }
+
+ public static boolean $noinline$equalsConstString29(String s) {
+ if (doThrow) { throw new Error(); }
+ return s.equals("01234567890123456789012345678");
+ }
+
+ public static boolean $noinline$equalsConstString35(String s) {
+ if (doThrow) { throw new Error(); }
+ return s.equals("01234567890123456789012345678901234");
+ }
+
+ public static boolean $noinline$equalsConstNonAsciiString7(String s) {
+ if (doThrow) { throw new Error(); }
+ return s.equals("\u0440123456");
+ }
+
+ public static boolean $noinline$equalsConstNonAsciiString14(String s) {
+ if (doThrow) { throw new Error(); }
+ return s.equals("\u04401234567890123");
+ }
+
+ public static boolean $noinline$equalsConstNonAsciiString24(String s) {
+ if (doThrow) { throw new Error(); }
+ return s.equals("\u044012345678901234567890123");
+ }
+
+ public static boolean $noinline$equalsConstNonAsciiString29(String s) {
+ if (doThrow) { throw new Error(); }
+ return s.equals("\u04401234567890123456789012345678");
+ }
+
+ public static boolean $noinline$equalsConstNonAsciiString35(String s) {
+ if (doThrow) { throw new Error(); }
+ return s.equals("\u04401234567890123456789012345678901234");
+ }
+
+ public static boolean $noinline$constString0Equals(String s) {
+ if (doThrow) { throw new Error(); }
+ return s.equals("");
+ }
+
+ public static boolean $noinline$constString7Equals(String s) {
+ if (doThrow) { throw new Error(); }
+ return "0123456".equals(s);
+ }
+
+ public static boolean $noinline$constString14Equals(String s) {
+ if (doThrow) { throw new Error(); }
+ return "01234567890123".equals(s);
+ }
+
+ public static boolean $noinline$constString24Equals(String s) {
+ if (doThrow) { throw new Error(); }
+ return "012345678901234567890123".equals(s);
+ }
+
+ public static boolean $noinline$constString29Equals(String s) {
+ if (doThrow) { throw new Error(); }
+ return "01234567890123456789012345678".equals(s);
+ }
+
+ public static boolean $noinline$constString35Equals(String s) {
+ if (doThrow) { throw new Error(); }
+ return "01234567890123456789012345678901234".equals(s);
+ }
+
+ public static boolean $noinline$constNonAsciiString7Equals(String s) {
+ if (doThrow) { throw new Error(); }
+ return "\u0440123456".equals(s);
+ }
+
+ public static boolean $noinline$constNonAsciiString14Equals(String s) {
+ if (doThrow) { throw new Error(); }
+ return "\u04401234567890123".equals(s);
+ }
+
+ public static boolean $noinline$constNonAsciiString24Equals(String s) {
+ if (doThrow) { throw new Error(); }
+ return "\u044012345678901234567890123".equals(s);
+ }
+
+ public static boolean $noinline$constNonAsciiString29Equals(String s) {
+ if (doThrow) { throw new Error(); }
+ return "\u04401234567890123456789012345678".equals(s);
+ }
+
+ public static boolean $noinline$constNonAsciiString35Equals(String s) {
+ if (doThrow) { throw new Error(); }
+ return "\u04401234567890123456789012345678901234".equals(s);
+ }
+
public static int $noinline$compareTo(String lhs, String rhs) {
if (doThrow) { throw new Error(); }
return lhs.compareTo(rhs);
diff --git a/test/536-checker-intrinsic-optimization/src/Main.java b/test/536-checker-intrinsic-optimization/src/Main.java
index ed7524c..52f3f84 100644
--- a/test/536-checker-intrinsic-optimization/src/Main.java
+++ b/test/536-checker-intrinsic-optimization/src/Main.java
@@ -329,7 +329,7 @@
/// CHECK-NOT: cbz
// Terminate the scope for the CHECK-NOT search at the reference or length comparison,
// whichever comes first.
- /// CHECK: cmp {{w.*,}} {{w.*}}
+ /// CHECK: cmp {{w.*,}} {{w.*|#.*}}
public static boolean stringArgumentNotNull(Object obj) {
obj.getClass();
return "foo".equals(obj);
@@ -380,10 +380,10 @@
// so repeat the check twice.
/// CHECK-NOT: ldr {{w\d+}}, [{{x\d+}}]
/// CHECK-NOT: ldr {{w\d+}}, [{{x\d+}}, #0]
- /// CHECK: cmp {{w\d+}}, {{w\d+}}
+ /// CHECK: cmp {{w\d+}}, {{w\d+|#.*}}
/// CHECK-NOT: ldr {{w\d+}}, [{{x\d+}}]
/// CHECK-NOT: ldr {{w\d+}}, [{{x\d+}}, #0]
- /// CHECK: cmp {{w\d+}}, {{w\d+}}
+ /// CHECK: cmp {{w\d+}}, {{w\d+|#.*}}
public static boolean stringArgumentIsString() {
return "foo".equals(myString);
}
diff --git a/test/616-cha-native/expected.txt b/test/616-cha-native/expected.txt
new file mode 100644
index 0000000..6a5618e
--- /dev/null
+++ b/test/616-cha-native/expected.txt
@@ -0,0 +1 @@
+JNI_OnLoad called
diff --git a/test/616-cha-native/info.txt b/test/616-cha-native/info.txt
new file mode 100644
index 0000000..a17bcab
--- /dev/null
+++ b/test/616-cha-native/info.txt
@@ -0,0 +1,2 @@
+Test for Class Hierarchy Analysis (CHA) single-implementation status updating
+behavior on an overridden native method.
diff --git a/test/616-cha-native/src/Main.java b/test/616-cha-native/src/Main.java
new file mode 100644
index 0000000..53a463c
--- /dev/null
+++ b/test/616-cha-native/src/Main.java
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+abstract class A {
+ public abstract void foo();
+}
+
+class B extends A {
+ public native void foo();
+}
+
+class C extends B {
+ public void foo() {}
+}
+
+public class Main {
+ public static void main(String[] args) {
+ System.loadLibrary(args[0]);
+ }
+}
diff --git a/test/616-cha/src/Main.java b/test/616-cha/src/Main.java
index b617944..beea90a 100644
--- a/test/616-cha/src/Main.java
+++ b/test/616-cha/src/Main.java
@@ -196,8 +196,6 @@
// should return true for those cases.
assertSingleImplementation(java.lang.String.class, "charAt", true);
assertSingleImplementation(java.lang.Thread.class, "join", true);
- // We don't set single-implementation modifier bit for native methods.
- assertSingleImplementation(java.lang.Thread.class, "isInterrupted", false);
if (isInterpreted()) {
sIsOptimizing = false;
diff --git a/test/912-classes/classes.cc b/test/912-classes/classes.cc
index b727453..3ccfe86 100644
--- a/test/912-classes/classes.cc
+++ b/test/912-classes/classes.cc
@@ -433,6 +433,13 @@
class ClassLoadPrepareEquality {
public:
static constexpr const char* kClassName = "LMain$ClassE;";
+ static constexpr const char* kStorageFieldName = "STATIC";
+ static constexpr const char* kStorageFieldSig = "Ljava/lang/Object;";
+ static constexpr const char* kStorageWeakFieldName = "WEAK";
+ static constexpr const char* kStorageWeakFieldSig = "Ljava/lang/ref/Reference;";
+ static constexpr const char* kWeakClassName = "java/lang/ref/WeakReference";
+ static constexpr const char* kWeakInitSig = "(Ljava/lang/Object;)V";
+ static constexpr const char* kWeakGetSig = "()Ljava/lang/Object;";
static void JNICALL ClassLoadCallback(jvmtiEnv* jenv,
JNIEnv* jni_env,
@@ -446,6 +453,8 @@
// The following is bad and relies on implementation details. But otherwise a test would be
// a lot more complicated.
local_stored_class_ = jni_env->NewLocalRef(klass);
+ // Store the value into a field in the heap.
+ SetOrCompare(jni_env, klass, true);
}
}
@@ -459,10 +468,58 @@
CHECK(jni_env->IsSameObject(stored_class_, klass));
CHECK(jni_env->IsSameObject(weakly_stored_class_, klass));
CHECK(jni_env->IsSameObject(local_stored_class_, klass));
+ // Look up the value in a field in the heap.
+ SetOrCompare(jni_env, klass, false);
compared_ = true;
}
}
+ static void SetOrCompare(JNIEnv* jni_env, jobject value, bool set) {
+ CHECK(storage_class_ != nullptr);
+
+ // Simple direct storage.
+ jfieldID field = jni_env->GetStaticFieldID(storage_class_, kStorageFieldName, kStorageFieldSig);
+ CHECK(field != nullptr);
+
+ if (set) {
+ jni_env->SetStaticObjectField(storage_class_, field, value);
+ CHECK(!jni_env->ExceptionCheck());
+ } else {
+ ScopedLocalRef<jobject> stored(jni_env, jni_env->GetStaticObjectField(storage_class_, field));
+ CHECK(jni_env->IsSameObject(value, stored.get()));
+ }
+
+ // Storage as a reference.
+ ScopedLocalRef<jclass> weak_ref_class(jni_env, jni_env->FindClass(kWeakClassName));
+ CHECK(weak_ref_class.get() != nullptr);
+ jfieldID weak_field = jni_env->GetStaticFieldID(storage_class_,
+ kStorageWeakFieldName,
+ kStorageWeakFieldSig);
+ CHECK(weak_field != nullptr);
+ if (set) {
+ // Create a WeakReference.
+ jmethodID weak_init = jni_env->GetMethodID(weak_ref_class.get(), "<init>", kWeakInitSig);
+ CHECK(weak_init != nullptr);
+ ScopedLocalRef<jobject> weak_obj(jni_env, jni_env->NewObject(weak_ref_class.get(),
+ weak_init,
+ value));
+ CHECK(weak_obj.get() != nullptr);
+ jni_env->SetStaticObjectField(storage_class_, weak_field, weak_obj.get());
+ CHECK(!jni_env->ExceptionCheck());
+ } else {
+ // Check the reference value.
+ jmethodID get_referent = jni_env->GetMethodID(weak_ref_class.get(), "get", kWeakGetSig);
+ CHECK(get_referent != nullptr);
+ ScopedLocalRef<jobject> weak_obj(jni_env, jni_env->GetStaticObjectField(storage_class_,
+ weak_field));
+ CHECK(weak_obj.get() != nullptr);
+ ScopedLocalRef<jobject> weak_referent(jni_env, jni_env->CallObjectMethod(weak_obj.get(),
+ get_referent));
+ CHECK(weak_referent.get() != nullptr);
+ CHECK(jni_env->IsSameObject(value, weak_referent.get()));
+ }
+ }
+
static void CheckFound() {
CHECK(found_);
CHECK(compared_);
@@ -477,6 +534,8 @@
}
}
+ static jclass storage_class_;
+
private:
static jobject stored_class_;
static jweak weakly_stored_class_;
@@ -484,12 +543,19 @@
static bool found_;
static bool compared_;
};
+jclass ClassLoadPrepareEquality::storage_class_ = nullptr;
jobject ClassLoadPrepareEquality::stored_class_ = nullptr;
jweak ClassLoadPrepareEquality::weakly_stored_class_ = nullptr;
jobject ClassLoadPrepareEquality::local_stored_class_ = nullptr;
bool ClassLoadPrepareEquality::found_ = false;
bool ClassLoadPrepareEquality::compared_ = false;
+extern "C" JNIEXPORT void JNICALL Java_Main_setEqualityEventStorageClass(
+ JNIEnv* env, jclass Main_klass ATTRIBUTE_UNUSED, jclass klass) {
+ ClassLoadPrepareEquality::storage_class_ =
+ reinterpret_cast<jclass>(env->NewGlobalRef(klass));
+}
+
extern "C" JNIEXPORT void JNICALL Java_Main_enableClassLoadPrepareEqualityEvents(
JNIEnv* env, jclass Main_klass ATTRIBUTE_UNUSED, jboolean b) {
EnableEvents(env,
@@ -499,6 +565,8 @@
if (b == JNI_FALSE) {
ClassLoadPrepareEquality::Free(env);
ClassLoadPrepareEquality::CheckFound();
+ env->DeleteGlobalRef(ClassLoadPrepareEquality::storage_class_);
+ ClassLoadPrepareEquality::storage_class_ = nullptr;
}
}
diff --git a/test/912-classes/src/Main.java b/test/912-classes/src/Main.java
index c1de679..005074f 100644
--- a/test/912-classes/src/Main.java
+++ b/test/912-classes/src/Main.java
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+import java.lang.ref.Reference;
import java.lang.reflect.Constructor;
import java.lang.reflect.Proxy;
import java.util.Arrays;
@@ -315,6 +316,8 @@
}
private static void testClassLoadPrepareEquality() throws Exception {
+ setEqualityEventStorageClass(ClassF.class);
+
enableClassLoadPrepareEqualityEvents(true);
Class.forName("Main$ClassE");
@@ -393,6 +396,7 @@
private static native void enableClassLoadSeenEvents(boolean b);
private static native boolean hadLoadEvent();
+ private static native void setEqualityEventStorageClass(Class<?> c);
private static native void enableClassLoadPrepareEqualityEvents(boolean b);
private static class TestForNonInit {
@@ -428,6 +432,11 @@
}
}
+ public static class ClassF {
+ public static Object STATIC = null;
+ public static Reference<Object> WEAK = null;
+ }
+
private static final String DEX1 = System.getenv("DEX_LOCATION") + "/912-classes.jar";
private static final String DEX2 = System.getenv("DEX_LOCATION") + "/912-classes-ex.jar";
diff --git a/test/945-obsolete-native/build b/test/945-obsolete-native/build
new file mode 100755
index 0000000..898e2e5
--- /dev/null
+++ b/test/945-obsolete-native/build
@@ -0,0 +1,17 @@
+#!/bin/bash
+#
+# Copyright 2016 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.
+
+./default-build "$@" --experimental agents
diff --git a/test/945-obsolete-native/expected.txt b/test/945-obsolete-native/expected.txt
new file mode 100644
index 0000000..83efda1
--- /dev/null
+++ b/test/945-obsolete-native/expected.txt
@@ -0,0 +1,9 @@
+hello
+Not doing anything here
+goodbye
+hello
+transforming calling function
+goodbye
+Hello - Transformed
+Not doing anything here
+Goodbye - Transformed
diff --git a/test/945-obsolete-native/info.txt b/test/945-obsolete-native/info.txt
new file mode 100644
index 0000000..c8b892c
--- /dev/null
+++ b/test/945-obsolete-native/info.txt
@@ -0,0 +1 @@
+Tests basic obsolete method support
diff --git a/test/945-obsolete-native/obsolete_native.cc b/test/945-obsolete-native/obsolete_native.cc
new file mode 100644
index 0000000..061e7af
--- /dev/null
+++ b/test/945-obsolete-native/obsolete_native.cc
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+#include <inttypes.h>
+#include <memory>
+#include <stdio.h>
+
+#include "android-base/stringprintf.h"
+
+#include "android-base/stringprintf.h"
+#include "base/logging.h"
+#include "base/macros.h"
+#include "jni.h"
+#include "openjdkjvmti/jvmti.h"
+#include "ScopedLocalRef.h"
+#include "ti-agent/common_helper.h"
+#include "ti-agent/common_load.h"
+
+namespace art {
+namespace Test945ObsoleteNative {
+
+extern "C" JNIEXPORT void JNICALL Java_Main_bindTest945ObsoleteNative(
+ JNIEnv* env, jclass klass ATTRIBUTE_UNUSED) {
+ BindFunctions(jvmti_env, env, "Transform");
+}
+
+extern "C" JNIEXPORT void JNICALL Java_Transform_doExecute(JNIEnv* env,
+ jclass klass ATTRIBUTE_UNUSED,
+ jobject runnable) {
+ jclass runnable_klass = env->FindClass("java/lang/Runnable");
+ DCHECK(runnable_klass != nullptr);
+ jmethodID run_method = env->GetMethodID(runnable_klass, "run", "()V");
+ env->CallVoidMethod(runnable, run_method);
+}
+
+
+} // namespace Test945ObsoleteNative
+} // namespace art
diff --git a/test/945-obsolete-native/run b/test/945-obsolete-native/run
new file mode 100755
index 0000000..c6e62ae
--- /dev/null
+++ b/test/945-obsolete-native/run
@@ -0,0 +1,17 @@
+#!/bin/bash
+#
+# Copyright 2016 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.
+
+./default-run "$@" --jvmti
diff --git a/test/945-obsolete-native/src/Main.java b/test/945-obsolete-native/src/Main.java
new file mode 100644
index 0000000..5e2154e
--- /dev/null
+++ b/test/945-obsolete-native/src/Main.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Base64;
+
+public class Main {
+ // class Transform {
+ // public void sayHi(Runnable r) {
+ // System.out.println("Hello - Transformed");
+ // doExecute(r);
+ // System.out.println("Goodbye - Transformed");
+ // }
+ //
+ // private static native void doExecute(Runnable r);
+ // }
+ private static final byte[] CLASS_BYTES = Base64.getDecoder().decode(
+ "yv66vgAAADQAIgoACAASCQATABQIABUKABYAFwoABwAYCAAZBwAaBwAbAQAGPGluaXQ+AQADKClW" +
+ "AQAEQ29kZQEAD0xpbmVOdW1iZXJUYWJsZQEABXNheUhpAQAXKExqYXZhL2xhbmcvUnVubmFibGU7" +
+ "KVYBAAlkb0V4ZWN1dGUBAApTb3VyY2VGaWxlAQAOVHJhbnNmb3JtLmphdmEMAAkACgcAHAwAHQAe" +
+ "AQATSGVsbG8gLSBUcmFuc2Zvcm1lZAcAHwwAIAAhDAAPAA4BABVHb29kYnllIC0gVHJhbnNmb3Jt" +
+ "ZWQBAAlUcmFuc2Zvcm0BABBqYXZhL2xhbmcvT2JqZWN0AQAQamF2YS9sYW5nL1N5c3RlbQEAA291" +
+ "dAEAFUxqYXZhL2lvL1ByaW50U3RyZWFtOwEAE2phdmEvaW8vUHJpbnRTdHJlYW0BAAdwcmludGxu" +
+ "AQAVKExqYXZhL2xhbmcvU3RyaW5nOylWACAABwAIAAAAAAADAAAACQAKAAEACwAAAB0AAQABAAAA" +
+ "BSq3AAGxAAAAAQAMAAAABgABAAAAEQABAA0ADgABAAsAAAA5AAIAAgAAABWyAAISA7YABCu4AAWy" +
+ "AAISBrYABLEAAAABAAwAAAASAAQAAAATAAgAFAAMABUAFAAWAQoADwAOAAAAAQAQAAAAAgAR");
+ private static final byte[] DEX_BYTES = Base64.getDecoder().decode(
+ "ZGV4CjAzNQB1fZcJR/opPuXacK8mIla5shH0LSg72qJYAwAAcAAAAHhWNBIAAAAAAAAAALgCAAAR" +
+ "AAAAcAAAAAcAAAC0AAAAAwAAANAAAAABAAAA9AAAAAUAAAD8AAAAAQAAACQBAAAUAgAARAEAAKIB" +
+ "AACqAQAAwQEAANYBAADjAQAA+gEAAA4CAAAkAgAAOAIAAEwCAABcAgAAXwIAAGMCAABuAgAAggIA" +
+ "AIcCAACQAgAAAwAAAAQAAAAFAAAABgAAAAcAAAAIAAAACgAAAAoAAAAGAAAAAAAAAAsAAAAGAAAA" +
+ "lAEAAAsAAAAGAAAAnAEAAAUAAQAOAAAAAAAAAAAAAAAAAAEADAAAAAAAAQAQAAAAAQACAA8AAAAC" +
+ "AAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAJAAAAAAAAAKUCAAAAAAAAAQABAAEAAACXAgAABAAAAHAQ" +
+ "BAAAAA4ABAACAAIAAACcAgAAFAAAAGIAAAAbAQIAAABuIAMAEABxEAEAAwBiAAAAGwEBAAAAbiAD" +
+ "ABAADgABAAAAAwAAAAEAAAAEAAY8aW5pdD4AFUdvb2RieWUgLSBUcmFuc2Zvcm1lZAATSGVsbG8g" +
+ "LSBUcmFuc2Zvcm1lZAALTFRyYW5zZm9ybTsAFUxqYXZhL2lvL1ByaW50U3RyZWFtOwASTGphdmEv" +
+ "bGFuZy9PYmplY3Q7ABRMamF2YS9sYW5nL1J1bm5hYmxlOwASTGphdmEvbGFuZy9TdHJpbmc7ABJM" +
+ "amF2YS9sYW5nL1N5c3RlbTsADlRyYW5zZm9ybS5qYXZhAAFWAAJWTAAJZG9FeGVjdXRlABJlbWl0" +
+ "dGVyOiBqYWNrLTQuMjUAA291dAAHcHJpbnRsbgAFc2F5SGkAEQAHDgATAQAHDoc8hwAAAAIBAICA" +
+ "BMQCAYoCAAIB3AIADQAAAAAAAAABAAAAAAAAAAEAAAARAAAAcAAAAAIAAAAHAAAAtAAAAAMAAAAD" +
+ "AAAA0AAAAAQAAAABAAAA9AAAAAUAAAAFAAAA/AAAAAYAAAABAAAAJAEAAAEgAAACAAAARAEAAAEQ" +
+ "AAACAAAAlAEAAAIgAAARAAAAogEAAAMgAAACAAAAlwIAAAAgAAABAAAApQIAAAAQAAABAAAAuAIA" +
+ "AA==");
+
+ public static void main(String[] args) {
+ bindTest945ObsoleteNative();
+ doTest(new Transform());
+ }
+
+ public static void doTest(Transform t) {
+ t.sayHi(() -> { System.out.println("Not doing anything here"); });
+ t.sayHi(() -> {
+ System.out.println("transforming calling function");
+ doCommonClassRedefinition(Transform.class, CLASS_BYTES, DEX_BYTES);
+ });
+ t.sayHi(() -> { System.out.println("Not doing anything here"); });
+ }
+
+ // Transforms the class
+ private static native void doCommonClassRedefinition(Class<?> target,
+ byte[] classfile,
+ byte[] dexfile);
+
+ private static native void bindTest945ObsoleteNative();
+}
diff --git a/test/945-obsolete-native/src/Transform.java b/test/945-obsolete-native/src/Transform.java
new file mode 100644
index 0000000..2b7cc1b
--- /dev/null
+++ b/test/945-obsolete-native/src/Transform.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+class Transform {
+ public void sayHi(Runnable r) {
+ System.out.println("hello");
+ doExecute(r);
+ System.out.println("goodbye");
+ }
+
+ private static native void doExecute(Runnable r);
+}
diff --git a/test/952-invoke-custom/build b/test/952-invoke-custom/build
new file mode 100644
index 0000000..a423ca6
--- /dev/null
+++ b/test/952-invoke-custom/build
@@ -0,0 +1,25 @@
+#!/bin/bash
+#
+# Copyright 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# make us exit on a failure
+set -e
+
+if [[ $@ != *"--jvm"* ]]; then
+ # Don't do anything with jvm.
+ export USE_JACK=true
+fi
+
+./default-build "$@" --experimental method-handles
diff --git a/test/952-invoke-custom/expected.txt b/test/952-invoke-custom/expected.txt
new file mode 100644
index 0000000..bb87296
--- /dev/null
+++ b/test/952-invoke-custom/expected.txt
@@ -0,0 +1,14 @@
+Caught exception from uninitialized call site
+Caught exception from uninitialized call site
+linkerMethod failure type 1
+Returning null instead of CallSite for add (int,int)int
+linkerMethod failure type 2
+Throwing InstantiationException in linkerMethod()
+linkerMethod failure type 3
+Throwing ArithmeticException in add()
+Failure Type + 0 (1013)
+Linking add (int,int)int
+100
+-9000
+9000
+Winners 1 Votes 16
diff --git a/test/952-invoke-custom/generator/TestInvokeCustomWithConcurrentThreads.java b/test/952-invoke-custom/generator/TestInvokeCustomWithConcurrentThreads.java
new file mode 100644
index 0000000..5d5cae4
--- /dev/null
+++ b/test/952-invoke-custom/generator/TestInvokeCustomWithConcurrentThreads.java
@@ -0,0 +1,227 @@
+/*
+ * Copyright (C) 2016 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 com.android.jack.annotations.CalledByInvokeCustom;
+import com.android.jack.annotations.Constant;
+import com.android.jack.annotations.LinkerMethodHandle;
+import com.android.jack.annotations.MethodHandleKind;
+
+import java.lang.invoke.CallSite;
+import java.lang.invoke.ConstantCallSite;
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+
+import java.lang.Thread;
+import java.lang.ThreadLocal;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class TestInvokeCustomWithConcurrentThreads extends Thread {
+ private static final int NUMBER_OF_THREADS = 16;
+
+ private static final AtomicInteger nextIndex = new AtomicInteger(0);
+
+ private static final ThreadLocal<Integer> threadIndex =
+ new ThreadLocal<Integer>() {
+ @Override
+ protected Integer initialValue() {
+ return nextIndex.getAndIncrement();
+ }
+ };
+
+ // Array of call sites instantiated, one per thread
+ private static CallSite[] instantiated = new CallSite[NUMBER_OF_THREADS];
+
+ // Array of counters for how many times each instantiated call site is called
+ private static AtomicInteger[] called = new AtomicInteger[NUMBER_OF_THREADS];
+
+ // Array of call site indicies of which call site a thread invoked
+ private static AtomicInteger[] targetted = new AtomicInteger[NUMBER_OF_THREADS];
+
+ private TestInvokeCustomWithConcurrentThreads() {}
+
+ private static int getThreadIndex() {
+ return threadIndex.get().intValue();
+ }
+
+ public static int notUsed(int x) {
+ return x;
+ }
+
+ @Override
+ public void run() {
+ int x = setCalled(-1 /* argument dropped */);
+ notUsed(x);
+ }
+
+ @CalledByInvokeCustom(
+ invokeMethodHandle = @LinkerMethodHandle(kind = MethodHandleKind.INVOKE_STATIC,
+ enclosingType = TestInvokeCustomWithConcurrentThreads.class,
+ name = "linkerMethod",
+ argumentTypes = {MethodHandles.Lookup.class, String.class, MethodType.class}),
+ name = "setCalled",
+ returnType = int.class,
+ argumentTypes = {int.class})
+ private static int setCalled(int index) {
+ called[index].getAndIncrement();
+ targetted[getThreadIndex()].set(index);
+ return 0;
+ }
+
+ @SuppressWarnings("unused")
+ private static CallSite linkerMethod(MethodHandles.Lookup caller,
+ String name,
+ MethodType methodType) throws Throwable {
+ int threadIndex = getThreadIndex();
+ MethodHandle mh =
+ caller.findStatic(TestInvokeCustomWithConcurrentThreads.class, name, methodType);
+ assertEquals(methodType, mh.type());
+ assertEquals(mh.type().parameterCount(), 1);
+ mh = MethodHandles.insertArguments(mh, 0, threadIndex);
+ mh = MethodHandles.dropArguments(mh, 0, int.class);
+ assertEquals(mh.type().parameterCount(), 1);
+ assertEquals(methodType, mh.type());
+
+ // Sleep to try to get concurrent executions of this
+ // method. Multiple call sites should be created, but only one
+ // invoked.
+ Thread.sleep(125);
+
+ instantiated[getThreadIndex()] = new ConstantCallSite(mh);
+ return instantiated[getThreadIndex()];
+ }
+
+ public static void test() throws Throwable {
+ // Initialize counters for which call site gets invoked
+ for (int i = 0; i < NUMBER_OF_THREADS; ++i) {
+ called[i] = new AtomicInteger(0);
+ targetted[i] = new AtomicInteger(0);
+ }
+
+ // Run threads that each invoke-custom the call site
+ Thread [] threads = new Thread[NUMBER_OF_THREADS];
+ for (int i = 0; i < NUMBER_OF_THREADS; ++i) {
+ threads[i] = new TestInvokeCustomWithConcurrentThreads();
+ threads[i].start();
+ }
+
+ // Wait for all threads to complete
+ for (int i = 0; i < NUMBER_OF_THREADS; ++i) {
+ threads[i].join();
+ }
+
+ // Check one call site instance won
+ int winners = 0;
+ int votes = 0;
+ for (int i = 0; i < NUMBER_OF_THREADS; ++i) {
+ assertNotEquals(instantiated[i], null);
+ if (called[i].get() != 0) {
+ winners++;
+ votes += called[i].get();
+ }
+ }
+
+ System.out.println("Winners " + winners + " Votes " + votes);
+
+ // We assert this below but output details when there's an error as
+ // it's non-deterministic.
+ if (winners != 1) {
+ System.out.println("Threads did not the same call-sites:");
+ for (int i = 0; i < NUMBER_OF_THREADS; ++i) {
+ System.out.format(" Thread % 2d invoked call site instance #%02d\n",
+ i, targetted[i].get());
+ }
+ }
+
+ // We assert this below but output details when there's an error as
+ // it's non-deterministic.
+ if (votes != NUMBER_OF_THREADS) {
+ System.out.println("Call-sites invocations :");
+ for (int i = 0; i < NUMBER_OF_THREADS; ++i) {
+ System.out.format(" Call site instance #%02d was invoked % 2d times\n",
+ i, called[i].get());
+ }
+ }
+
+ assertEquals(winners, 1);
+ assertEquals(votes, NUMBER_OF_THREADS);
+ }
+
+ public static void assertTrue(boolean value) {
+ if (!value) {
+ throw new AssertionError("assertTrue value: " + value);
+ }
+ }
+
+ public static void assertEquals(byte b1, byte b2) {
+ if (b1 == b2) { return; }
+ throw new AssertionError("assertEquals b1: " + b1 + ", b2: " + b2);
+ }
+
+ public static void assertEquals(char c1, char c2) {
+ if (c1 == c2) { return; }
+ throw new AssertionError("assertEquals c1: " + c1 + ", c2: " + c2);
+ }
+
+ public static void assertEquals(short s1, short s2) {
+ if (s1 == s2) { return; }
+ throw new AssertionError("assertEquals s1: " + s1 + ", s2: " + s2);
+ }
+
+ public static void assertEquals(int i1, int i2) {
+ if (i1 == i2) { return; }
+ throw new AssertionError("assertEquals i1: " + i1 + ", i2: " + i2);
+ }
+
+ public static void assertEquals(long l1, long l2) {
+ if (l1 == l2) { return; }
+ throw new AssertionError("assertEquals l1: " + l1 + ", l2: " + l2);
+ }
+
+ public static void assertEquals(float f1, float f2) {
+ if (f1 == f2) { return; }
+ throw new AssertionError("assertEquals f1: " + f1 + ", f2: " + f2);
+ }
+
+ public static void assertEquals(double d1, double d2) {
+ if (d1 == d2) { return; }
+ throw new AssertionError("assertEquals d1: " + d1 + ", d2: " + d2);
+ }
+
+ public static void assertEquals(Object o, Object p) {
+ if (o == p) { return; }
+ if (o != null && p != null && o.equals(p)) { return; }
+ throw new AssertionError("assertEquals: o1: " + o + ", o2: " + p);
+ }
+
+ public static void assertNotEquals(Object o, Object p) {
+ if (o != p) { return; }
+ if (o != null && p != null && !o.equals(p)) { return; }
+ throw new AssertionError("assertNotEquals: o1: " + o + ", o2: " + p);
+ }
+
+ public static void assertEquals(String s1, String s2) {
+ if (s1 == s2) {
+ return;
+ }
+
+ if (s1 != null && s2 != null && s1.equals(s2)) {
+ return;
+ }
+
+ throw new AssertionError("assertEquals s1: " + s1 + ", s2: " + s2);
+ }
+}
diff --git a/test/952-invoke-custom/generator/TestLinkerMethodMinimalArguments.java b/test/952-invoke-custom/generator/TestLinkerMethodMinimalArguments.java
new file mode 100644
index 0000000..93d96a9
--- /dev/null
+++ b/test/952-invoke-custom/generator/TestLinkerMethodMinimalArguments.java
@@ -0,0 +1,137 @@
+/*
+ * 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.
+ */
+
+import com.android.jack.annotations.CalledByInvokeCustom;
+import com.android.jack.annotations.Constant;
+import com.android.jack.annotations.LinkerMethodHandle;
+import com.android.jack.annotations.MethodHandleKind;
+
+import java.lang.invoke.CallSite;
+import java.lang.invoke.ConstantCallSite;
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+
+public class TestLinkerMethodMinimalArguments {
+
+ private static int forceFailureType = 0;
+
+ private static int FAILURE_TYPE_NONE = 0;
+ private static int FAILURE_TYPE_LINKER_METHOD_RETURNS_NULL = 1;
+ private static int FAILURE_TYPE_LINKER_METHOD_THROWS = 2;
+ private static int FAILURE_TYPE_TARGET_METHOD_THROWS = 3;
+
+ @CalledByInvokeCustom(
+ invokeMethodHandle = @LinkerMethodHandle(
+ kind = MethodHandleKind.INVOKE_STATIC,
+ enclosingType = TestLinkerMethodMinimalArguments.class,
+ argumentTypes = {MethodHandles.Lookup.class, String.class, MethodType.class},
+ name = "linkerMethod"),
+ name = "add",
+ returnType = int.class,
+ argumentTypes = {int.class, int.class})
+ private static int add(int a, int b) {
+ if (forceFailureType == FAILURE_TYPE_TARGET_METHOD_THROWS) {
+ System.out.println("Throwing ArithmeticException in add()");
+ throw new ArithmeticException("add");
+ }
+ return a + b;
+ }
+
+ @SuppressWarnings("unused")
+ private static CallSite linkerMethod(MethodHandles.Lookup caller, String name,
+ MethodType methodType) throws Throwable {
+ System.out.println("linkerMethod failure type " + forceFailureType);
+ MethodHandle mh_add =
+ caller.findStatic(TestLinkerMethodMinimalArguments.class, name, methodType);
+ if (forceFailureType == FAILURE_TYPE_LINKER_METHOD_RETURNS_NULL) {
+ System.out.println("Returning null instead of CallSite for " + name + " " + methodType);
+ return null;
+ } else if (forceFailureType == FAILURE_TYPE_LINKER_METHOD_THROWS) {
+ System.out.println("Throwing InstantiationException in linkerMethod()");
+ throw new InstantiationException("linkerMethod");
+ } else {
+ return new ConstantCallSite(mh_add);
+ }
+ }
+
+ public static void test(int failureType, int x, int y) throws Throwable {
+ assertTrue(failureType >= FAILURE_TYPE_NONE);
+ assertTrue(failureType <= FAILURE_TYPE_TARGET_METHOD_THROWS);
+ forceFailureType = failureType;
+ assertEquals(x + y, add(x, y));
+ System.out.println("Failure Type + " + failureType + " (" + x + y+ ")");
+ }
+
+ public static void assertTrue(boolean value) {
+ if (!value) {
+ throw new AssertionError("assertTrue value: " + value);
+ }
+ }
+
+ public static void assertEquals(byte b1, byte b2) {
+ if (b1 == b2) { return; }
+ throw new AssertionError("assertEquals b1: " + b1 + ", b2: " + b2);
+ }
+
+ public static void assertEquals(char c1, char c2) {
+ if (c1 == c2) { return; }
+ throw new AssertionError("assertEquals c1: " + c1 + ", c2: " + c2);
+ }
+
+ public static void assertEquals(short s1, short s2) {
+ if (s1 == s2) { return; }
+ throw new AssertionError("assertEquals s1: " + s1 + ", s2: " + s2);
+ }
+
+ public static void assertEquals(int i1, int i2) {
+ if (i1 == i2) { return; }
+ throw new AssertionError("assertEquals i1: " + i1 + ", i2: " + i2);
+ }
+
+ public static void assertEquals(long l1, long l2) {
+ if (l1 == l2) { return; }
+ throw new AssertionError("assertEquals l1: " + l1 + ", l2: " + l2);
+ }
+
+ public static void assertEquals(float f1, float f2) {
+ if (f1 == f2) { return; }
+ throw new AssertionError("assertEquals f1: " + f1 + ", f2: " + f2);
+ }
+
+ public static void assertEquals(double d1, double d2) {
+ if (d1 == d2) { return; }
+ throw new AssertionError("assertEquals d1: " + d1 + ", d2: " + d2);
+ }
+
+ public static void assertEquals(Object o, Object p) {
+ if (o == p) { return; }
+ if (o != null && p != null && o.equals(p)) { return; }
+ throw new AssertionError("assertEquals: o1: " + o + ", o2: " + p);
+ }
+
+ public static void assertEquals(String s1, String s2) {
+ if (s1 == s2) {
+ return;
+ }
+
+ if (s1 != null && s2 != null && s1.equals(s2)) {
+ return;
+ }
+
+ throw new AssertionError("assertEquals s1: " + s1 + ", s2: " + s2);
+ }
+}
diff --git a/test/952-invoke-custom/generator/TestLinkerMethodMultipleArgumentTypes.java b/test/952-invoke-custom/generator/TestLinkerMethodMultipleArgumentTypes.java
new file mode 100644
index 0000000..4e4d97e
--- /dev/null
+++ b/test/952-invoke-custom/generator/TestLinkerMethodMultipleArgumentTypes.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2016 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 com.android.jack.annotations.CalledByInvokeCustom;
+import com.android.jack.annotations.Constant;
+import com.android.jack.annotations.LinkerMethodHandle;
+import com.android.jack.annotations.MethodHandleKind;
+
+import java.lang.invoke.CallSite;
+import java.lang.invoke.ConstantCallSite;
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+
+public class TestLinkerMethodMultipleArgumentTypes {
+
+ private static int bootstrapRunCount = 0;
+
+ @CalledByInvokeCustom(
+ invokeMethodHandle = @LinkerMethodHandle(kind = MethodHandleKind.INVOKE_STATIC,
+ enclosingType = TestLinkerMethodMultipleArgumentTypes.class,
+ name = "linkerMethod",
+ argumentTypes = {MethodHandles.Lookup.class, String.class, MethodType.class,
+ boolean.class, byte.class, char.class, short.class, int.class,
+ float.class, double.class, String.class, Class.class, long.class}),
+ methodHandleExtraArgs = {@Constant(booleanValue = true), @Constant(byteValue = 1),
+ @Constant(charValue = 'a'), @Constant(shortValue = 1024),
+ @Constant(intValue = 1), @Constant(floatValue = 11.1f),
+ @Constant(doubleValue = 2.2), @Constant(stringValue = "Hello"),
+ @Constant(classValue = TestLinkerMethodMultipleArgumentTypes.class),
+ @Constant(longValue = 123456789L)},
+ name = "add",
+ returnType = int.class,
+ argumentTypes = {int.class, int.class})
+ private static int add(int a, int b) {
+ return a + b;
+ }
+
+ @SuppressWarnings("unused")
+ private static CallSite linkerMethod(MethodHandles.Lookup caller, String name,
+ MethodType methodType, boolean v1, byte v2, char v3,
+ short v4, int v5, float v6, double v7,
+ String v8, Class<?> v9, long v10) throws Throwable {
+ System.out.println("Linking " + name + " " + methodType);
+ assertTrue(v1);
+ assertEquals(1, v2);
+ assertEquals('a', v3);
+ assertEquals(1024, v4);
+ assertEquals(1, v5);
+ assertEquals(11.1f, v6);
+ assertEquals(2.2, v7);
+ assertEquals("Hello", v8);
+ assertEquals(TestLinkerMethodMultipleArgumentTypes.class, v9);
+ assertEquals(123456789L, v10);
+ MethodHandle mh_add =
+ caller.findStatic(TestLinkerMethodMultipleArgumentTypes.class, name, methodType);
+ return new ConstantCallSite(mh_add);
+ }
+
+ public int GetBootstrapRunCount() {
+ return bootstrapRunCount;
+ }
+
+ public static void test(int x, int y) throws Throwable {
+ assertEquals(x + y, add(x, y));
+ System.out.println(x + y);
+ }
+
+ public static void assertTrue(boolean value) {
+ if (!value) {
+ throw new AssertionError("assertTrue value: " + value);
+ }
+ }
+
+ public static void assertEquals(byte b1, byte b2) {
+ if (b1 == b2) { return; }
+ throw new AssertionError("assertEquals b1: " + b1 + ", b2: " + b2);
+ }
+
+ public static void assertEquals(char c1, char c2) {
+ if (c1 == c2) { return; }
+ throw new AssertionError("assertEquals c1: " + c1 + ", c2: " + c2);
+ }
+
+ public static void assertEquals(short s1, short s2) {
+ if (s1 == s2) { return; }
+ throw new AssertionError("assertEquals s1: " + s1 + ", s2: " + s2);
+ }
+
+ public static void assertEquals(int i1, int i2) {
+ if (i1 == i2) { return; }
+ throw new AssertionError("assertEquals i1: " + i1 + ", i2: " + i2);
+ }
+
+ public static void assertEquals(long l1, long l2) {
+ if (l1 == l2) { return; }
+ throw new AssertionError("assertEquals l1: " + l1 + ", l2: " + l2);
+ }
+
+ public static void assertEquals(float f1, float f2) {
+ if (f1 == f2) { return; }
+ throw new AssertionError("assertEquals f1: " + f1 + ", f2: " + f2);
+ }
+
+ public static void assertEquals(double d1, double d2) {
+ if (d1 == d2) { return; }
+ throw new AssertionError("assertEquals d1: " + d1 + ", d2: " + d2);
+ }
+
+ public static void assertEquals(Object o, Object p) {
+ if (o == p) { return; }
+ if (o != null && p != null && o.equals(p)) { return; }
+ throw new AssertionError("assertEquals: o1: " + o + ", o2: " + p);
+ }
+
+ public static void assertEquals(String s1, String s2) {
+ if (s1 == s2) {
+ return;
+ }
+
+ if (s1 != null && s2 != null && s1.equals(s2)) {
+ return;
+ }
+
+ throw new AssertionError("assertEquals s1: " + s1 + ", s2: " + s2);
+ }
+}
diff --git a/test/952-invoke-custom/generator/build-test.sh b/test/952-invoke-custom/generator/build-test.sh
new file mode 100755
index 0000000..90a60e6
--- /dev/null
+++ b/test/952-invoke-custom/generator/build-test.sh
@@ -0,0 +1,77 @@
+#!/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.
+
+# Set up prog to be the path of this script, including following symlinks,
+# and set up progdir to be the fully-qualified pathname of its directory.
+prog="$0"
+args="$@"
+while [ -h "${prog}" ]; do
+ newProg=`/bin/ls -ld "${prog}"`
+ newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
+ if expr "x${newProg}" : 'x/' >/dev/null; then
+ prog="${newProg}"
+ else
+ progdir=`dirname "${prog}"`
+ prog="${progdir}/${newProg}"
+ fi
+done
+oldwd=`pwd`
+progdir=`dirname "${prog}"`
+cd "${progdir}"
+progdir=`pwd`
+prog="${progdir}"/`basename "${prog}"`
+test_dir="test-$$"
+if [ -z "$TMPDIR" ]; then
+ tmp_dir="/tmp/$USER/${test_dir}"
+else
+ tmp_dir="${TMPDIR}/${test_dir}"
+fi
+
+# This is a custom drop that necessitates this complexity.
+JACK_ANNOTATIONS_LIB=$HOME/Downloads/jack-test-annotations-lib.jack
+
+# Compile test into a base64 string that can be instantiated via
+# reflection on hosts without the jack-test-annotations-lib.jack file.
+mkdir $tmp_dir
+for input_file in $progdir/*.java; do
+ i=${input_file##*/Test}
+ i=${i%%.java}
+ src_file=$progdir/Test$i.java
+ jack_file=./src.jack
+ dex_file=./classes.dex
+ base_64_file=$tmp_dir/TestData$i.base64
+ output_file=$progdir/../src/TestData$i.java
+ # Compile source file to jack file.
+ jack -g -cp $ANDROID_BUILD_TOP/out/host/linux-x86/../common/obj/JAVA_LIBRARIES/core-libart-hostdex_intermediates/classes.jack:$ANDROID_BUILD_TOP/out/host/linux-x86/../common/obj/JAVA_LIBRARIES/core-oj-hostdex_intermediates/classes.jack:$JACK_ANNOTATIONS_LIB -D sched.runner=multi-threaded -D sched.runner.thread.kind=fixed -D sched.runner.thread.fixed.count=4 -D jack.java.source.version=1.7 -D jack.android.min-api-level=o-b2 --output-jack $jack_file $src_file
+ # Compile jack file to classes.dex.
+ jack -g -cp $ANDROID_BUILD_TOP/out/host/linux-x86/../common/obj/JAVA_LIBRARIES/core-libart-hostdex_intermediates/classes.jack:$ANDROID_BUILD_TOP/out/host/linux-x86/../common/obj/JAVA_LIBRARIES/core-oj-hostdex_intermediates/classes.jack -D sched.runner=multi-threaded -D sched.runner.thread.kind=fixed -D sched.runner.thread.fixed.count=4 -D jack.java.source.version=1.7 -D jack.android.min-api-level=o-b2 --import $jack_file --output-dex .
+ # Pack the classes.dex file into a base64 string.
+ base64 -w 72 $dex_file > $base_64_file
+ # Emit a managed source file containing the base64 string. The test can be
+ # run by loading this string as a dex file and invoking it via reflection.
+cat > $output_file <<HEADER
+/* Generated by ${prog##*/} from ${src_file##*/} */
+public class TestData$i {
+ public static final String BASE64_DEX_FILE =
+HEADER
+sed -e 's/^\(.*\)$/ "\1" +/' -e '$s/ +/;/' $base_64_file >> $output_file
+cat >> $output_file <<FOOTER
+}
+FOOTER
+ rm $dex_file $jack_file
+done
+
+rm -rf $tmp_dir
diff --git a/test/952-invoke-custom/info.txt b/test/952-invoke-custom/info.txt
new file mode 100644
index 0000000..e9a9f6c
--- /dev/null
+++ b/test/952-invoke-custom/info.txt
@@ -0,0 +1,7 @@
+A test that is only available as a DEX binary.
+
+This tests execution of invoke-custom. There is no bytecode to emit
+invoke-custom directly. This test is generated using jack-test-annotations-lib.jack
+which is not a publicly supported at this time.
+
+The tests and a script to generate data from them are in the generator/ directory.
diff --git a/test/952-invoke-custom/src/Main.java b/test/952-invoke-custom/src/Main.java
new file mode 100644
index 0000000..2abc312
--- /dev/null
+++ b/test/952-invoke-custom/src/Main.java
@@ -0,0 +1,159 @@
+/*
+ * 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.
+ */
+
+import dalvik.system.InMemoryDexClassLoader;
+
+import java.lang.invoke.CallSite;
+import java.lang.invoke.MethodType;
+import java.lang.invoke.MutableCallSite;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.nio.ByteBuffer;
+import java.util.Base64;
+
+// This test is a stop-gap until we have support for generating invoke-custom
+// in the Android tree.
+
+public class Main {
+
+ private static void TestUninitializedCallSite() throws Throwable {
+ CallSite callSite = new MutableCallSite(MethodType.methodType(int.class));
+ try {
+ callSite.getTarget().invoke();
+ fail();
+ } catch (IllegalStateException e) {
+ System.out.println("Caught exception from uninitialized call site");
+ }
+
+ callSite = new MutableCallSite(MethodType.methodType(String.class, int.class, char.class));
+ try {
+ callSite.getTarget().invoke(1535, 'd');
+ fail();
+ } catch (IllegalStateException e) {
+ System.out.println("Caught exception from uninitialized call site");
+ }
+ }
+
+ private static void TestLinkerMethodMultipleArgumentTypes() throws Throwable {
+ // This is a more comprehensive test of invoke-custom, the linker
+ // method takes additional arguments of types boolean, byte, char,
+ // short, int, float, double, String, Class, and long (in this order)
+ // The test asserts the values passed to the linker method match their
+ // expected values.
+ byte[] base64Data = TestDataLinkerMethodMultipleArgumentTypes.BASE64_DEX_FILE.getBytes();
+ Base64.Decoder decoder = Base64.getDecoder();
+ ByteBuffer dexBuffer = ByteBuffer.wrap(decoder.decode(base64Data));
+
+ InMemoryDexClassLoader classLoader =
+ new InMemoryDexClassLoader(dexBuffer,
+ ClassLoader.getSystemClassLoader());
+ Class<?> testClass =
+ classLoader.loadClass("TestLinkerMethodMultipleArgumentTypes");
+ Method testMethod = testClass.getDeclaredMethod("test", int.class, int.class);
+ // First invocation should link via the bootstrap method (outputs "Linking add" ...).
+ testMethod.invoke(null, 33, 67);
+ // Subsequent invocations use the cached value of the CallSite and do not require linking.
+ testMethod.invoke(null, -10000, +1000);
+ testMethod.invoke(null, -1000, +10000);
+ }
+
+ private static void TestLinkerMethodMinimalArguments() throws Throwable {
+ // This test checks various failures when running the linker
+ // method and during invocation of the method handle.
+ byte[] base64Data = TestDataLinkerMethodMinimalArguments.BASE64_DEX_FILE.getBytes();
+ Base64.Decoder decoder = Base64.getDecoder();
+ ByteBuffer dexBuffer = ByteBuffer.wrap(decoder.decode(base64Data));
+
+ InMemoryDexClassLoader classLoader =
+ new InMemoryDexClassLoader(dexBuffer,
+ ClassLoader.getSystemClassLoader());
+ Class<?> testClass =
+ classLoader.loadClass("TestLinkerMethodMinimalArguments");
+ Method testMethod = testClass.getDeclaredMethod("test", int.class, int.class, int.class);
+
+ try {
+ testMethod.invoke(null, 1 /* linker method return null */, 10, 10);
+ } catch (InvocationTargetException e) {
+ assertEquals(e.getCause().getClass().getName(), "java.lang.BootstrapMethodError");
+ assertEquals(
+ e.getCause().getCause().getClass().getName(), "java.lang.NullPointerException");
+ }
+
+ try {
+ testMethod.invoke(null, 2 /* linker method throw InstantiationException */, 10, 11);
+ } catch (InvocationTargetException e) {
+ assertEquals(e.getCause().getClass().getName(), "java.lang.BootstrapMethodError");
+ assertEquals(
+ e.getCause().getCause().getClass().getName(), "java.lang.InstantiationException");
+ }
+ try {
+ // Creating the CallSite works here, but fail invoking the method.
+ testMethod.invoke(null, 3 /* target throw NPE */, 10, 12);
+ } catch (InvocationTargetException e) {
+ assertEquals(e.getCause().getClass().getName(), "java.lang.ArithmeticException");
+ }
+
+ // This should succeed using already resolved CallSite.
+ testMethod.invoke(null, 0 /* no error */, 10, 13);
+ }
+
+ private static void TestInvokeCustomWithConcurrentThreads() throws Throwable {
+ // This is a concurrency test that attempts to run invoke-custom on the same
+ // call site.
+ byte[] base64Data = TestDataInvokeCustomWithConcurrentThreads.BASE64_DEX_FILE.getBytes();
+ Base64.Decoder decoder = Base64.getDecoder();
+ ByteBuffer dexBuffer = ByteBuffer.wrap(decoder.decode(base64Data));
+
+ InMemoryDexClassLoader classLoader =
+ new InMemoryDexClassLoader(dexBuffer,
+ ClassLoader.getSystemClassLoader());
+ Class<?> testClass =
+ classLoader.loadClass("TestInvokeCustomWithConcurrentThreads");
+ Method testMethod = testClass.getDeclaredMethod("test");
+ testMethod.invoke(null);
+ }
+
+ public static void assertEquals(Object o, Object p) {
+ if (o == p) { return; }
+ if (o != null && p != null && o.equals(p)) { return; }
+ throw new AssertionError("assertEquals: o1: " + o + ", o2: " + p);
+ }
+
+ public static void assertEquals(String s1, String s2) {
+ if (s1 == s2) {
+ return;
+ }
+
+ if (s1 != null && s2 != null && s1.equals(s2)) {
+ return;
+ }
+
+ throw new AssertionError("assertEquals s1: " + s1 + ", s2: " + s2);
+ }
+
+ private static void fail() {
+ System.out.println("fail");
+ Thread.dumpStack();
+ }
+
+ public static void main(String[] args) throws Throwable {
+ TestUninitializedCallSite();
+ TestLinkerMethodMinimalArguments();
+ TestLinkerMethodMultipleArgumentTypes();
+ TestInvokeCustomWithConcurrentThreads();
+ }
+}
\ No newline at end of file
diff --git a/test/952-invoke-custom/src/TestDataInvokeCustomWithConcurrentThreads.java b/test/952-invoke-custom/src/TestDataInvokeCustomWithConcurrentThreads.java
new file mode 100644
index 0000000..9a77e67
--- /dev/null
+++ b/test/952-invoke-custom/src/TestDataInvokeCustomWithConcurrentThreads.java
@@ -0,0 +1,145 @@
+/* Generated by build-test.sh from TestInvokeCustomWithConcurrentThreads.java */
+public class TestDataInvokeCustomWithConcurrentThreads {
+ public static final String BASE64_DEX_FILE =
+ "ZGV4CjAzOADq+VhgIFlZEzwomlDWIN5pEqcVmb8SN2y8HQAAcAAAAHhWNBIAAAAAAAAAANQc" +
+ "AACqAAAAcAAAACoAAAAYAwAAJgAAAMADAAAJAAAAiAUAADgAAADQBQAAAgAAAJQHAADgFQAA" +
+ "3AcAAKQRAADXEQAABxIAABASAAAYEgAAIBIAACgSAAAwEgAAOBIAAEASAABIEgAAUBIAAFcS" +
+ "AABaEgAAZBIAAGwSAABwEgAAcxIAAHYSAACQEgAAkxIAAJYSAACZEgAAnRIAAKwSAACvEgAA" +
+ "shIAALYSAAC6EgAAvhIAAMISAADGEgAAyhIAANASAADVEgAA2xIAAAYTAAAvEwAAMxMAAGgT" +
+ "AACbEwAAzBMAAPATAAAQFAAAMxQAAFIUAABuFAAAhRQAAKEUAAC0FAAAyRQAAN0UAADxFAAA" +
+ "DBUAACAVAAA0FQAATBUAAGUVAAB8FQAAmRUAAL4VAADfFQAACBYAACoWAABJFgAAdhYAAIkW" +
+ "AACMFgAAkhYAAL4WAADkFgAA5xYAAOwWAADxFgAA9hYAAPsWAAD/FgAABBcAAAgXAAANFwAA" +
+ "ERcAABYXAAAbFwAAHxcAACkXAAAsFwAAMBcAAEQXAABZFwAAbhcAAIwXAAC6FwAAxxcAAM8X" +
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ABcEQAASQAAACMAAABkEQAASgAAACMAAABsEQAASwAAACMAAADcEAAATAAAACMAAAB0EQAA" +
+ "TQAAACMAAAAEEQAATgAAACMAAAB8EQAATwAAACMAAAAMEQAAUAAAACMAAACEEQAATwAAACMA" +
+ "AAAUEQAAUAAAACMAAACMEQAATwAAACMAAACUEQAAUQAAACMAAACcEQAAUgAAACMAAAAcEQAA" +
+ "VQAAACQAAAAMEQAABwAEAEEAAAAHACkAbwAAAAcAKACEAAAABwAhAI8AAAAHACkAngAAAAcA" +
+ "GQChAAAACgAKABcAAAATABIAQwAAABcAEACSAAAABgAVAA4AAAAGAAMAggAAAAYABQCCAAAA" +
+ "BwAUAAsAAAAHABUADQAAAAcAFQAOAAAABwAWAF4AAAAHABcAXgAAAAcAGABeAAAABwAZAF4A" +
+ "AAAHABsAXgAAAAcAHQBeAAAABwAfAF4AAAAHACEAXgAAAAcAIwBeAAAABwAfAGcAAAAHACQA" +
+ "aQAAAAcAAAB9AAAABwAPAIsAAAAHAAEAkAAAAAcAFQCXAAAABwABAJsAAAAHABUAnwAAABAA" +
+ "AgB6AAAAEAAgAJUAAAARAB4ADgAAABMAAACFAAAAEwAEAKYAAAAUACUAdgAAABUAJQB2AAAA" +
+ "FgAVAA4AAAAWAAcAXAAAABYACABcAAAAFgAJAFwAAAAWAAoAXAAAABYACwBcAAAAFgAMAFwA" +
+ "AAAWAA0AXAAAABYADgBcAAAAFgAGAKMAAAAYABUADgAAABgAFQCHAAAAGAAcAJwAAAAYABUA" +
+ "nQAAABkAFQAOAAAAGQAFAHsAAAAcACIADgAAAB0AEwCkAAAAHgAQAHkAAAAfABEAcwAAAB8A" +
+ "EgCDAAAAIAAAAJQAAAAhABoADgAAACEAAAB7AAAAIQAAAHwAAAAhABoAmgAAAFMcAAAGAAAA" +
+ "EAAAABkAAAAAAAAARAAAAJwQAABaHAAAAAAAAAcAAAABAAAAGAAAAAAAAABEAAAArBAAAG0c" +
+ "AABQHAAABAAAABIAAAADAAAA9BsAA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EaA4gg7BABiIAEhBEBgoAE0BEBCegRAQnIEgEJqBMBCYwUAQnwFAEJ0BUBCbQWAQmsFwEJ" +
+ "pBgBCYQZAQmAGgEKzBoBCvgaAQnMHAIK4BwBCZgdFAH4IAAAEwAAAAAAAAABAAAAAAAAAAEA" +
+ "AACqAAAAcAAAAAIAAAAqAAAAGAMAAAMAAAAmAAAAwAMAAAQAAAAJAAAAiAUAAAUAAAA4AAAA" +
+ "0AUAAAcAAAABAAAAkAcAAAYAAAACAAAAlAcAAAgAAAABAAAA1AcAAAMQAAAFAAAA3AcAAAEg" +
+ "AAAXAAAADAgAAAYgAAACAAAAnBAAAAEQAAAXAAAA3BAAAAIgAACqAAAApBEAAAMgAAAWAAAA" +
+ "1RoAAAQgAAAGAAAA9BsAAAUgAAACAAAAUBwAAAAgAAACAAAAWhwAAAAQAAABAAAA1BwAAA==";
+}
diff --git a/test/952-invoke-custom/src/TestDataLinkerMethodMinimalArguments.java b/test/952-invoke-custom/src/TestDataLinkerMethodMinimalArguments.java
new file mode 100644
index 0000000..443a7af
--- /dev/null
+++ b/test/952-invoke-custom/src/TestDataLinkerMethodMinimalArguments.java
@@ -0,0 +1,106 @@
+/* Generated by build-test.sh from TestLinkerMethodMinimalArguments.java */
+public class TestDataLinkerMethodMinimalArguments {
+ public static final String BASE64_DEX_FILE =
+ "ZGV4CjAzOADnZpVEc25JsNXLCW+vh64OuLf8RymAuINwFQAAcAAAAHhWNBIAAAAAAAAAAIgU" +
+ "AACBAAAAcAAAAB0AAAB0AgAAHAAAAOgCAAAHAAAAOAQAACIAAABwBAAAAQAAAIQFAADEDwAA" +
+ "rAUAAKAMAACjDAAApwwAAKoMAACyDAAAugwAAMIMAADKDAAA0gwAANoMAADiDAAA6gwAAPQM" +
+ "AAD8DAAA/wwAAAINAAAFDQAACA0AADENAABUDQAAZw0AAIoNAACbDQAAng0AAKMNAACyDQAA" +
+ "tQ0AALgNAAC8DQAAwA0AAMQNAADIDQAAzA0AANANAADWDQAA+g0AAP4NAAAzDgAAZg4AAJcO" +
+ "AACzDgAAyg4AAOsOAAAHDwAAGg8AAD4PAABSDwAAZg8AAIEPAACVDwAArA8AAMkPAADuDwAA" +
+ "DxAAADgQAABXEAAAgBAAAIMQAACqEAAA0RAAAAQRAAAHEQAADBEAABERAAAWEQAAGxEAACAR" +
+ "AAAmEQAAKxEAAC8RAAA0EQAAOREAAD0RAABAEQAARBEAAEcRAABMEQAAVBEAAGMRAABxEQAA" +
+ "hBEAAJcRAACqEQAAvREAANARAADjEQAA9hEAAAoSAAAWEgAAKhIAAC0SAAAxEgAANRIAADkS" +
+ "AAA9EgAARRIAAEkSAABNEgAAYRIAAHASAAB4EgAAfBIAAIASAACNEgAAmRIAAKsSAACvEgAA" +
+ "sxIAAMcSAADNEgAA0RIAANUSAADjEgAA/xIAAAsTAAATEwAAGRMAABwTAAAhEwAAJBMAAC0T" +
+ "AAA5EwAAPRMAAEETAABHEwAATRMAAFcTAABeEwAAYRMAAA0AAAAOAAAADwAAABAAAAAWAAAA" +
+ "GQAAACIAAAAkAAAAJQAAACYAAAAnAAAAKAAAACkAAAAqAAAAKwAAACwAAAAtAAAALgAAAC8A" +
+ "AAAwAAAAMQAAADIAAAAzAAAANAAAADUAAAA2AAAAOAAAADwAAABIAAAAFwAAAAQAAADsCwAA" +
+ "GgAAABEAAAAAAAAAGwAAABIAAAD0CwAAHAAAABIAAAD8CwAAHQAAABIAAAAEDAAAHgAAABIA" +
+ "AAAMDAAAHwAAABIAAAAUDAAAIAAAABIAAAAcDAAAIAAAABIAAAAkDAAAIwAAABIAAAAsDAAA" +
+ "IQAAABUAAAA0DAAAIQAAABcAAABADAAAPAAAABsAAAAAAAAAPQAAABsAAABMDAAAPgAAABsA" +
+ "AABUDAAAPwAAABsAAABcDAAAQAAAABsAAABkDAAAQQAAABsAAADsCwAAQgAAABsAAABsDAAA" +
+ "QwAAABsAAAB4DAAARAAAABsAAAAcDAAARQAAABsAAACADAAARAAAABsAAAAkDAAARQAAABsA" +
+ "AACIDAAARAAAABsAAACQDAAARgAAABsAAACYDAAARwAAABsAAAAsDAAASQAAABwAAAAcDAAA" +
+ "BgAEABEAAAAGAAQAEgAAAAYABAATAAAABgAEABQAAAAGAAQAaAAAAAkACQAYAAAAEwALAHUA" +
+ "AAAGAAwACwAAAAYADAAMAAAABgAAAEsAAAAGAA0ATgAAAAYADgBOAAAABgAPAE4AAAAGABAA" +
+ "TgAAAAYAEQBOAAAABgATAE4AAAAGABUATgAAAAYAFwBOAAAABgAZAE4AAAAGABoAVwAAAAYA" +
+ "CgBvAAAABgASAHsAAAALABYAdwAAAAwAFgAMAAAADQAUAAwAAAAPABYADAAAABAADAAMAAAA" +
+ "EAAbAGMAAAARABsAYwAAABIADAAMAAAAEgACAEwAAAASAAMATAAAABIABABMAAAAEgAFAEwA" +
+ "AAASAAYATAAAABIABwBMAAAAEgAIAEwAAAASAAkATAAAABIAAQB9AAAAFgAYAAwAAAAYAAsA" +
+ "ZwAAADIUAAAGAAAAAQAAABAAAAAAAAAAOQAAAMQLAAA5FAAAAAAAAAQAAAANAAAAAQAAAAIU" +
+ "AAABAAAAKhQAAAEAAAAAAAAAZBMAAA8AAAASAGcABABnAAIAEhBnAAAAEiBnAAEAEjBnAAMA" +
+ "DgAAAAEAAQABAAAAcBMAAAQAAABwEBMAAAAOAAQAAgACAAAAdRMAABoAAABgAAQAYAEDADMQ" +
+ "EwBiAAYAGwE6AAAAbiAPABAAIgAMABsBSwAAAHAgEAAQACcAkAACAw8ABQACAAIAAAB/EwAA" +
+ "KAAAADNDAwAOACIADQAiARIAcBAWAAEAGwJPAAAAbiAdACEADAFuIBoAMQAMARsCAwAAAG4g" +
+ "HQAhAAwBbiAaAEEADAFuEB8AAQAMAXAgEQAQACcABQACAAIAAACHEwAAKAAAADNDAwAOACIA" +
+ "DQAiARIAcBAWAAEAGwJQAAAAbiAdACEADAFuIBcAMQAMARsCBAAAAG4gHQAhAAwBbiAXAEEA" +
+ "DAFuEB8AAQAMAXA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tlTWV0aG9kSGFuZGxl" +
+ "AARraW5kAAJsMQACbDIADGxpbmtlck1ldGhvZAAabGlua2VyTWV0aG9kIGZhaWx1cmUgdHlw" +
+ "ZSAACm1ldGhvZFR5cGUABm1oX2FkZAAEbmFtZQABbwADb3V0AAFwAAdwcmludGxuAApyZXR1" +
+ "cm5UeXBlAAJzMQACczIABHRlc3QABHRoaXMACHRvU3RyaW5nAAV2YWx1ZQABeAABeQAeAAcd" +
+ "Li08PAJ5OwAcAAcOAC8CS1oHDmmHlwBWAltcBw48AFsCXV4HDjwAdAJgYQcOWgBvAmVmBw5a" +
+ "AGUCamsHDjwAagJubwcOWgB5AnV3Bw48tAB/Anp7Bw4tIKUgAGACensHDjwAUAF/Bw4tARoQ" +
+ "ADkDX3RyBw4BGxBpAwBzGGkBJA8taYeXAEgDZ4ABgQEHLId4LZYBLw8CeywtAAAHBE0cAhgE" +
+ "GARrHAEdCARNHAMYGBgRGBliGAZsGwVzF29zF0t4GAQCCgF+HAEYFAMWABdLFQAFAA8AAAoB" +
+ "CgEKAQoBCgCIgAS8CwGBgATsCwEKhAwBCcgMAQmoDQEJiA4BCewOAQnQDwEJsBABCZQRAQmM" +
+ "EgEJhBMBCeQTAQqwFAEJlBYAEwAAAAAAAAABAAAAAAAAAAEAAACBAAAAcAAAAAIAAAAdAAAA" +
+ "dAIAAAMAAAAcAAAA6AIAAAQAAAAHAAAAOAQAAAUAAAAiAAAAcAQAAAcAAAABAAAAgAUAAAYA" +
+ "AAABAAAAhAUAAAgAAAABAAAApAUAAAMQAAACAAAArAUAAAEgAAAPAAAAvAUAAAYgAAABAAAA" +
+ "xAsAAAEQAAAVAAAA7AsAAAIgAACBAAAAoAwAAAMgAAAPAAAAZBMAAAQgAAACAAAAAhQAAAUg" +
+ "AAABAAAAMhQAAAAgAAABAAAAORQAAAAQAAABAAAAiBQAAA==";
+}
diff --git a/test/952-invoke-custom/src/TestDataLinkerMethodMultipleArgumentTypes.java b/test/952-invoke-custom/src/TestDataLinkerMethodMultipleArgumentTypes.java
new file mode 100644
index 0000000..b96e184
--- /dev/null
+++ b/test/952-invoke-custom/src/TestDataLinkerMethodMultipleArgumentTypes.java
@@ -0,0 +1,108 @@
+/* Generated by build-test.sh from TestLinkerMethodMultipleArgumentTypes.java */
+public class TestDataLinkerMethodMultipleArgumentTypes {
+ public static final String BASE64_DEX_FILE =
+ "ZGV4CjAzOADmj8ccx56N3pWZ9IunuZvI0eWD+wmFmSnEFQAAcAAAAHhWNBIAAAAAAAAAANwU" +
+ "AACTAAAAcAAAAB0AAAC8AgAAHQAAADADAAADAAAAjAQAACIAAACkBAAAAQAAALgFAADkDwAA" +
+ "4AUAAEQMAABHDAAASgwAAFIMAABaDAAAYgwAAGoMAAByDAAAegwAAIIMAACKDAAAkgwAAJwM" +
+ "AACkDAAApwwAAKoMAACtDAAAsAwAAMYMAADNDAAA0AwAANUMAADkDAAA5wwAAOoMAADuDAAA" +
+ "8gwAAPYMAAD6DAAA/gwAAAINAAAIDQAAGA0AAEENAABFDQAAeg0AAKMNAADWDQAABw4AACYO" +
+ "AABCDgAATA4AAGMOAAB/DgAAkQ4AAKQOAAC6DgAAzg4AAOIOAAD9DgAAEQ8AACgPAABFDwAA" +
+ "ag8AAIsPAAC0DwAA0w8AANYPAAACEAAABRAAAAoQAAAPEAAAFBAAABkQAAAdEAAAIhAAACcQ" +
+ "AAArEAAAMBAAADUQAAA5EAAAPBAAAEUQAABJEAAATBAAAFEQAABZEAAAaBAAAHYQAACJEAAA" +
+ "nBAAAK8QAADCEAAA1RAAAOgQAAD7EAAADxEAABsRAAAvEQAAMhEAADYRAAA6EQAASBEAAFsR" +
+ "AABmEQAAahEAAG4RAAB2EQAAgREAAI0RAACREQAAlREAAKIRAAC2EQAAxREAAM0RAADREQAA" +
+ "1REAAOERAADtEQAA8REAAPURAAD/EQAAExIAABkSAAAdEgAAIRIAAC8SAAA6EgAAURIAAF0S" +
+ "AABlEgAAaxIAAG4SAABzEgAAdhIAAH8SAACLEgAAjxIAAJMSAACfEgAArBIAALISAAC4EgAA" +
+ "whIAAMYSAADLEgAAzxIAANMSAADXEgAA2xIAAN8SAADjEgAA5xIAAOsSAADyEgAA9RIAAA0A" +
+ "AAAOAAAADwAAABAAAAATAAAAFgAAACAAAAAiAAAAIwAAACQAAAAlAAAAJgAAACcAAAApAAAA" +
+ "KgAAACwAAAAuAAAALwAAADAAAAAxAAAAMgAAADMAAAA0AAAANQAAADYAAAA3AAAAOAAAADoA" +
+ "AABGAAAAEwAAAAQAAAAAAAAAFAAAAAQAAACICwAAFwAAABEAAAAAAAAAGAAAABIAAACQCwAA" +
+ "GQAAABIAAACYCwAAGgAAABIAAACgCwAAGwAAABIAAACoCwAAHAAAABIAAACwCwAAHQAAABIA" +
+ "AAC4CwAAHQAAABIAAADACwAAIQAAABIAAADICwAAHwAAABUAAADQCwAAHgAAABcAAADwCwAA" +
+ "OgAAABsAAAAAAAAAOwAAABsAAAD8CwAAPAAAABsAAAAEDAAAPQAAABsAAAAMDAAAPgAAABsA" +
+ "AAAUDAAAPwAAABsAAACoCwAAQAAAABsAAACICwAAQQAAABsAAAAcDAAAQgAAABsAAAC4CwAA" +
+ "QwAAABsAAAAkDAAAQgAAABsAAADACwAAQwAAABsAAAAsDAAAQgAAABsAAAA0DAAARAAAABsA" +
+ "AAA8DAAARQAAABsAAADICwAASAAAABwAAAC4CwAABgAEAFwAAAAKAAoAFQAAABMADQB7AAAA" +
+ "BgANAAsAAAAGAA0ADAAAAAYAAAARAAAABgABAEoAAAAGAA4ATQAAAAYADwBNAAAABgAQAE0A" +
+ "AAAGABEATQAAAAYAEwBNAAAABgAUAE0AAAAGABYATQAAAAYAGABNAAAABgAaAE0AAAAGABsA" +
+ "VgAAAAYACwB0AAAABgATAIMAAAANABIAfQAAAA0AFwB9AAAADgAVAAwAAAAQAA0ADAAAABAA" +
+ "HABoAAAAEQAcAGgAAAASAA0ADAAAABIAAwBLAAAAEgAEAEsAAAASAAUASwAAABIABgBLAAAA" +
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mQFAHQgBggEcARcSHQgBYhwBGAYdCAF1HAFmFc1b" +
+ "B3kXSn4YBAILAZABHAkXARc2Fy8XNxdHFy8XKxcKFzMCDAGQARwBGBQNFgAXShUBBAEEAQRh" +
+ "JAAEBAFwmpkxQfGamZmZmZkBQBcSGAZmFc1bBwEADwEACgCIgAT8CwGBgASUDAIKrAwBCcQM" +
+ "AQmkDQEJhA4BCegOAQnMDwEJrBABCZARAQmIEgEJgBMBCeATAQqsFAEJlBYCAcgWEwAAAAAA" +
+ "AAABAAAAAAAAAAEAAACTAAAAcAAAAAIAAAAdAAAAvAIAAAMAAAAdAAAAMAMAAAQAAAADAAAA" +
+ "jAQAAAUAAAAiAAAApAQAAAcAAAABAAAAtAUAAAYAAAABAAAAuAUAAAgAAAABAAAA2AUAAAMQ" +
+ "AAADAAAA4AUAAAEgAAAQAAAA/AUAAAYgAAABAAAAYAsAAAEQAAAUAAAAiAsAAAIgAACTAAAA" +
+ "RAwAAAMgAAAQAAAA+BIAAAQgAAADAAAAqRMAAAUgAAABAAAAaRQAAAAgAAABAAAAkhQAAAAQ" +
+ "AAABAAAA3BQAAA==";
+}
diff --git a/test/Android.bp b/test/Android.bp
index d3244a6..00c890a 100644
--- a/test/Android.bp
+++ b/test/Android.bp
@@ -274,6 +274,7 @@
"933-misc-events/misc_events.cc",
"936-search-onload/search_onload.cc",
"944-transform-classloaders/classloader.cc",
+ "945-obsolete-native/obsolete_native.cc",
],
shared_libs: [
"libbase",
diff --git a/test/dexdump/invoke-custom.dex b/test/dexdump/invoke-custom.dex
new file mode 100644
index 0000000..67261ca
--- /dev/null
+++ b/test/dexdump/invoke-custom.dex
Binary files differ
diff --git a/test/dexdump/invoke-custom.lst b/test/dexdump/invoke-custom.lst
new file mode 100644
index 0000000..3540bd1
--- /dev/null
+++ b/test/dexdump/invoke-custom.lst
@@ -0,0 +1,6 @@
+#invoke-custom.dex
+0x000003fc 8 com.android.jack.java7.invokecustom.test004.Tests <init> ()V Tests.java 35
+0x00000414 6 com.android.jack.java7.invokecustom.test004.Tests add (II)I Tests.java 55
+0x0000042c 166 com.android.jack.java7.invokecustom.test004.Tests linkerMethod (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;ZBCSIFDLjava/lang/String;Ljava/lang/Class;J)Ljava/lang/invoke/CallSite; Tests.java 62
+0x000004e4 24 com.android.jack.java7.invokecustom.test004.Tests main ([Ljava/lang/String;)V Tests.java 82
+0x0000050c 22 com.android.jack.java7.invokecustom.test004.Tests test ()V Tests.java 78
diff --git a/test/dexdump/invoke-custom.txt b/test/dexdump/invoke-custom.txt
new file mode 100644
index 0000000..e92549a
--- /dev/null
+++ b/test/dexdump/invoke-custom.txt
@@ -0,0 +1,254 @@
+Processing 'invoke-custom.dex'...
+Opened 'invoke-custom.dex', DEX version '038'
+DEX file header:
+magic : 'dex\n038\0'
+checksum : db57516f
+signature : 57be...ffc4
+file_size : 3276
+header_size : 112
+link_size : 0
+link_off : 0 (0x000000)
+string_ids_size : 82
+string_ids_off : 112 (0x000070)
+type_ids_size : 31
+type_ids_off : 440 (0x0001b8)
+proto_ids_size : 16
+proto_ids_off : 564 (0x000234)
+field_ids_size : 3
+field_ids_off : 756 (0x0002f4)
+method_ids_size : 18
+method_ids_off : 780 (0x00030c)
+class_defs_size : 1
+class_defs_off : 932 (0x0003a4)
+data_size : 2304
+data_off : 972 (0x0003cc)
+
+Class #0 header:
+class_idx : 10
+access_flags : 1 (0x0001)
+superclass_idx : 15
+interfaces_off : 0 (0x000000)
+source_file_idx : 38
+annotations_off : 1316 (0x000524)
+class_data_off : 3014 (0x000bc6)
+static_fields_size : 1
+instance_fields_size: 0
+direct_methods_size : 4
+virtual_methods_size: 1
+
+Class #0 annotations:
+Annotations on method #1 'add'
+ VISIBILITY_BUILD Lcom/android/jack/annotations/CalledByInvokeCustom; argumentTypes={ I I } invokeMethodHandle={ Lcom/android/jack/annotations/LinkerMethodHandle; argumentTypes={ Ljava/lang/invoke/MethodHandles$Lookup; Ljava/lang/String; Ljava/lang/invoke/MethodType; Z B C S I F D Ljava/lang/String; Ljava/lang/Class; J } enclosingType=Lcom/android/jack/java7/invokecustom/test004/Tests; kind=INVOKE_STATIC name="linkerMethod" } methodHandleExtraArgs={ Lcom/android/jack/annotations/Constant; booleanValue={ true } Lcom/android/jack/annotations/Constant; byteValue={ 1 } Lcom/android/jack/annotations/Constant; charValue={ 97 } Lcom/android/jack/annotations/Constant; shortValue={ 1024 } Lcom/android/jack/annotations/Constant; intValue={ 1 } Lcom/android/jack/annotations/Constant; floatValue={ 11.1 } Lcom/android/jack/annotations/Constant; doubleValue={ 2.2 } Lcom/android/jack/annotations/Constant; stringValue={ "Hello" } Lcom/android/jack/annotations/Constant; classValue={ Lcom/android/jack/java7/invokecustom/test004/Tests; } Lcom/android/jack/annotations/Constant; longValue={ 123456789 } } name="add" returnType=I
+Annotations on method #2 'linkerMethod'
+ VISIBILITY_SYSTEM Ldalvik/annotation/Signature; value={ "(" "Ljava/lang/invoke/MethodHandles$Lookup;" "Ljava/lang/String;" "Ljava/lang/invoke/MethodType;" "ZBCSIFD" "Ljava/lang/String;" "Ljava/lang/Class" "<*>;J)" "Ljava/lang/invoke/CallSite;" }
+ VISIBILITY_SYSTEM Ldalvik/annotation/Throws; value={ Ljava/lang/Throwable; }
+Annotations on method #4 'test'
+ VISIBILITY_SYSTEM Ldalvik/annotation/Throws; value={ Ljava/lang/Throwable; }
+ VISIBILITY_RUNTIME Lorg/junit/Test;
+
+Class #0 -
+ Class descriptor : 'Lcom/android/jack/java7/invokecustom/test004/Tests;'
+ Access flags : 0x0001 (PUBLIC)
+ Superclass : 'Ljava/lang/Object;'
+ Interfaces -
+ Static fields -
+ #0 : (in Lcom/android/jack/java7/invokecustom/test004/Tests;)
+ name : 'fieldCallSite'
+ type : 'Ljava/lang/invoke/CallSite;'
+ access : 0x0009 (PUBLIC STATIC)
+ Instance fields -
+ Direct methods -
+ #0 : (in Lcom/android/jack/java7/invokecustom/test004/Tests;)
+ name : '<init>'
+ type : '()V'
+ access : 0x10001 (PUBLIC CONSTRUCTOR)
+ code -
+ registers : 1
+ ins : 1
+ outs : 1
+ insns size : 4 16-bit code units
+0003ec: |[0003ec] com.android.jack.java7.invokecustom.test004.Tests.<init>:()V
+0003fc: 7010 0600 0000 |0000: invoke-direct {v0}, Ljava/lang/Object;.<init>:()V // method@0006
+000402: 0e00 |0003: return-void
+ catches : (none)
+ positions :
+ 0x0000 line=35
+ locals :
+ 0x0000 - 0x0004 reg=0 this Lcom/android/jack/java7/invokecustom/test004/Tests;
+
+ #1 : (in Lcom/android/jack/java7/invokecustom/test004/Tests;)
+ name : 'add'
+ type : '(II)I'
+ access : 0x000a (PRIVATE STATIC)
+ code -
+ registers : 3
+ ins : 2
+ outs : 0
+ insns size : 3 16-bit code units
+000404: |[000404] com.android.jack.java7.invokecustom.test004.Tests.add:(II)I
+000414: 9000 0102 |0000: add-int v0, v1, v2
+000418: 0f00 |0002: return v0
+ catches : (none)
+ positions :
+ 0x0000 line=55
+ locals :
+ 0x0000 - 0x0003 reg=1 (null) I
+ 0x0000 - 0x0003 reg=2 (null) I
+
+ #2 : (in Lcom/android/jack/java7/invokecustom/test004/Tests;)
+ name : 'linkerMethod'
+ type : '(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;ZBCSIFDLjava/lang/String;Ljava/lang/Class;J)Ljava/lang/invoke/CallSite;'
+ access : 0x000a (PRIVATE STATIC)
+ code -
+ registers : 24
+ ins : 15
+ outs : 6
+ insns size : 83 16-bit code units
+00041c: |[00041c] com.android.jack.java7.invokecustom.test004.Tests.linkerMethod:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;ZBCSIFDLjava/lang/String;Ljava/lang/Class;J)Ljava/lang/invoke/CallSite;
+00042c: 7110 1100 0c00 |0000: invoke-static {v12}, Ljunit/framework/Assert;.assertTrue:(Z)V // method@0011
+000432: 1212 |0003: const/4 v2, #int 1 // #1
+000434: 7120 0d00 d200 |0004: invoke-static {v2, v13}, Ljunit/framework/Assert;.assertEquals:(II)V // method@000d
+00043a: 1302 6100 |0007: const/16 v2, #int 97 // #61
+00043e: 7120 0a00 e200 |0009: invoke-static {v2, v14}, Ljunit/framework/Assert;.assertEquals:(CC)V // method@000a
+000444: 1302 0004 |000c: const/16 v2, #int 1024 // #400
+000448: 7120 0d00 f200 |000e: invoke-static {v2, v15}, Ljunit/framework/Assert;.assertEquals:(II)V // method@000d
+00044e: 1212 |0011: const/4 v2, #int 1 // #1
+000450: 0200 1000 |0012: move/from16 v0, v16
+000454: 7120 0d00 0200 |0014: invoke-static {v2, v0}, Ljunit/framework/Assert;.assertEquals:(II)V // method@000d
+00045a: 1202 |0017: const/4 v2, #int 0 // #0
+00045c: 1403 9a99 3141 |0018: const v3, #float 11.1 // #4131999a
+000462: 0200 1100 |001b: move/from16 v0, v17
+000466: 7130 0c00 0302 |001d: invoke-static {v3, v0, v2}, Ljunit/framework/Assert;.assertEquals:(FFF)V // method@000c
+00046c: 1606 0000 |0020: const-wide/16 v6, #int 0 // #0
+000470: 1802 9a99 9999 9999 0140 |0022: const-wide v2, #double 2.2 // #400199999999999a
+00047a: 0504 1200 |0027: move-wide/from16 v4, v18
+00047e: 7706 0b00 0200 |0029: invoke-static/range {v2, v3, v4, v5, v6, v7}, Ljunit/framework/Assert;.assertEquals:(DDD)V // method@000b
+000484: 1b02 0700 0000 |002c: const-string/jumbo v2, "Hello" // string@00000007
+00048a: 0800 1400 |002f: move-object/from16 v0, v20
+00048e: 7120 1000 0200 |0031: invoke-static {v2, v0}, Ljunit/framework/Assert;.assertEquals:(Ljava/lang/String;Ljava/lang/String;)V // method@0010
+000494: 1c02 0a00 |0034: const-class v2, Lcom/android/jack/java7/invokecustom/test004/Tests; // type@000a
+000498: 0800 1500 |0036: move-object/from16 v0, v21
+00049c: 7120 0f00 0200 |0038: invoke-static {v2, v0}, Ljunit/framework/Assert;.assertEquals:(Ljava/lang/Object;Ljava/lang/Object;)V // method@000f
+0004a2: 1702 15cd 5b07 |003b: const-wide/32 v2, #float 1.6536e-34 // #075bcd15
+0004a8: 0500 1600 |003e: move-wide/from16 v0, v22
+0004ac: 7140 0e00 3210 |0040: invoke-static {v2, v3, v0, v1}, Ljunit/framework/Assert;.assertEquals:(JJ)V // method@000e
+0004b2: 7100 0900 0000 |0043: invoke-static {}, Ljava/lang/invoke/MethodHandles;.lookup:()Ljava/lang/invoke/MethodHandles$Lookup; // method@0009
+0004b8: 0c02 |0046: move-result-object v2
+0004ba: 1c03 0a00 |0047: const-class v3, Lcom/android/jack/java7/invokecustom/test004/Tests; // type@000a
+0004be: 6e40 0800 32ba |0049: invoke-virtual {v2, v3, v10, v11}, Ljava/lang/invoke/MethodHandles$Lookup;.findStatic:(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/MethodHandle; // method@0008
+0004c4: 0c02 |004c: move-result-object v2
+0004c6: 2203 1400 |004d: new-instance v3, Ljava/lang/invoke/ConstantCallSite; // type@0014
+0004ca: 7020 0700 2300 |004f: invoke-direct {v3, v2}, Ljava/lang/invoke/ConstantCallSite;.<init>:(Ljava/lang/invoke/MethodHandle;)V // method@0007
+0004d0: 1103 |0052: return-object v3
+ catches : (none)
+ positions :
+ 0x0000 line=62
+ 0x0003 line=63
+ 0x0007 line=64
+ 0x000c line=65
+ 0x0011 line=66
+ 0x0017 line=67
+ 0x0020 line=68
+ 0x002c line=69
+ 0x0034 line=70
+ 0x003b line=71
+ 0x0043 line=72
+ 0x004d line=73
+ locals :
+ 0x0000 - 0x0053 reg=9 (null) Ljava/lang/invoke/MethodHandles$Lookup;
+ 0x0000 - 0x0053 reg=10 (null) Ljava/lang/String;
+ 0x0000 - 0x0053 reg=11 (null) Ljava/lang/invoke/MethodType;
+ 0x0000 - 0x0053 reg=12 (null) Z
+ 0x0000 - 0x0053 reg=13 (null) B
+ 0x0000 - 0x0053 reg=14 (null) C
+ 0x0000 - 0x0053 reg=15 (null) S
+ 0x0000 - 0x0053 reg=16 (null) I
+ 0x0000 - 0x0053 reg=17 (null) F
+ 0x0000 - 0x0053 reg=18 (null) D
+ 0x0000 - 0x0053 reg=20 (null) Ljava/lang/String;
+ 0x0000 - 0x0053 reg=21 (null) Ljava/lang/Class;
+ 0x0000 - 0x0053 reg=22 (null) J
+
+ #3 : (in Lcom/android/jack/java7/invokecustom/test004/Tests;)
+ name : 'main'
+ type : '([Ljava/lang/String;)V'
+ access : 0x0009 (PUBLIC STATIC)
+ code -
+ registers : 4
+ ins : 1
+ outs : 2
+ insns size : 12 16-bit code units
+0004d4: |[0004d4] com.android.jack.java7.invokecustom.test004.Tests.main:([Ljava/lang/String;)V
+0004e4: 6200 0200 |0000: sget-object v0, Ljava/lang/System;.out:Ljava/io/PrintStream; // field@0002
+0004e8: 1221 |0002: const/4 v1, #int 2 // #2
+0004ea: 1232 |0003: const/4 v2, #int 3 // #3
+0004ec: fc20 0000 2100 |0004: invoke-custom {v1, v2}, call_site@0000
+0004f2: 0a01 |0007: move-result v1
+0004f4: 6e20 0500 1000 |0008: invoke-virtual {v0, v1}, Ljava/io/PrintStream;.println:(I)V // method@0005
+0004fa: 0e00 |000b: return-void
+ catches : (none)
+ positions :
+ 0x0000 line=82
+ 0x000b line=83
+ locals :
+ 0x0000 - 0x000c reg=3 (null) [Ljava/lang/String;
+
+ Virtual methods -
+ #0 : (in Lcom/android/jack/java7/invokecustom/test004/Tests;)
+ name : 'test'
+ type : '()V'
+ access : 0x0001 (PUBLIC)
+ code -
+ registers : 3
+ ins : 1
+ outs : 2
+ insns size : 11 16-bit code units
+0004fc: |[0004fc] com.android.jack.java7.invokecustom.test004.Tests.test:()V
+00050c: 1220 |0000: const/4 v0, #int 2 // #2
+00050e: 1231 |0001: const/4 v1, #int 3 // #3
+000510: fc20 0100 1000 |0002: invoke-custom {v0, v1}, call_site@0001
+000516: 0a00 |0005: move-result v0
+000518: 1251 |0006: const/4 v1, #int 5 // #5
+00051a: 7120 0d00 0100 |0007: invoke-static {v1, v0}, Ljunit/framework/Assert;.assertEquals:(II)V // method@000d
+000520: 0e00 |000a: return-void
+ catches : (none)
+ positions :
+ 0x0000 line=78
+ 0x000a line=79
+ locals :
+ 0x0000 - 0x000b reg=2 this Lcom/android/jack/java7/invokecustom/test004/Tests;
+
+ source_file_idx : 38 (Tests.java)
+
+Method handle #0:
+ type : invoke-static
+ target : Lcom/android/jack/java7/invokecustom/test004/Tests; linkerMethod
+ target_type : (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;ZBCSIFDLjava/lang/String;Ljava/lang/Class;J)Ljava/lang/invoke/CallSite;
+Call site #0:
+ link_argument[0] : 0 (MethodHandle)
+ link_argument[1] : add (String)
+ link_argument[2] : (II)I (MethodType)
+ link_argument[3] : 1 (int)
+ link_argument[4] : 1 (int)
+ link_argument[5] : 97 (int)
+ link_argument[6] : 1024 (int)
+ link_argument[7] : 1 (int)
+ link_argument[8] : 11.1 (float)
+ link_argument[9] : 2.2 (double)
+ link_argument[10] : Hello (String)
+ link_argument[11] : Tests (Class)
+ link_argument[12] : 123456789 (long)
+Call site #1:
+ link_argument[0] : 0 (MethodHandle)
+ link_argument[1] : add (String)
+ link_argument[2] : (II)I (MethodType)
+ link_argument[3] : 1 (int)
+ link_argument[4] : 1 (int)
+ link_argument[5] : 97 (int)
+ link_argument[6] : 1024 (int)
+ link_argument[7] : 1 (int)
+ link_argument[8] : 11.1 (float)
+ link_argument[9] : 2.2 (double)
+ link_argument[10] : Hello (String)
+ link_argument[11] : Tests (Class)
+ link_argument[12] : 123456789 (long)
diff --git a/test/dexdump/invoke-custom.xml b/test/dexdump/invoke-custom.xml
new file mode 100644
index 0000000..2a29667
--- /dev/null
+++ b/test/dexdump/invoke-custom.xml
@@ -0,0 +1,89 @@
+<api>
+<package name="com.android.jack.java7.invokecustom.test004"
+>
+<class name="Tests"
+ extends="java.lang.Object"
+ interface="false"
+ abstract="false"
+ static="false"
+ final="false"
+ visibility="public"
+>
+<field name="fieldCallSite"
+ type="java.lang.invoke.CallSite"
+ transient="false"
+ volatile="false"
+ static="true"
+ final="false"
+ visibility="public"
+>
+</field>
+<constructor name="Tests"
+ type="com.android.jack.java7.invokecustom.test004.Tests"
+ static="false"
+ final="false"
+ visibility="public"
+>
+</constructor>
+<method name="main"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ visibility="public"
+>
+<parameter name="arg0" type="java.lang.String[]">
+</parameter>
+</method>
+<method name="test"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ visibility="public"
+>
+</method>
+</class>
+<method_handle index="0"
+ type="invoke-static"
+ target_class="Lcom/android/jack/java7/invokecustom/test004/Tests;"
+ target_member="linkerMethod"
+ target_member_type="(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;ZBCSIFDLjava/lang/String;Ljava/lang/Class;J)Ljava/lang/invoke/CallSite;"
+>
+</method_handle>
+<call_site index="0">
+<link_argument index="0" type="MethodHandle" value="0"/>
+<link_argument index="1" type="String" values="add"/>
+<link_argument index="2" type="MethodType" value="(II)I"/>
+<link_argument index="3" type="int" value="1"/>
+<link_argument index="4" type="int" value="1"/>
+<link_argument index="5" type="int" value="97"/>
+<link_argument index="6" type="int" value="1024"/>
+<link_argument index="7" type="int" value="1"/>
+<link_argument index="8" type="float" value="11.1"/>
+<link_argument index="9" type="double" value="2.2"/>
+<link_argument index="10" type="String" value="Hello"/>
+<link_argument index="11" type="Class" value="Tests"/>
+<link_argument index="12" type="long" value="123456789"/>
+</call_site>
+<call_site index="1">
+<link_argument index="0" type="MethodHandle" value="0"/>
+<link_argument index="1" type="String" values="add"/>
+<link_argument index="2" type="MethodType" value="(II)I"/>
+<link_argument index="3" type="int" value="1"/>
+<link_argument index="4" type="int" value="1"/>
+<link_argument index="5" type="int" value="97"/>
+<link_argument index="6" type="int" value="1024"/>
+<link_argument index="7" type="int" value="1"/>
+<link_argument index="8" type="float" value="11.1"/>
+<link_argument index="9" type="double" value="2.2"/>
+<link_argument index="10" type="String" value="Hello"/>
+<link_argument index="11" type="Class" value="Tests"/>
+<link_argument index="12" type="long" value="123456789"/>
+</call_site>
+</package>
+</api>
diff --git a/test/ti-agent/common_load.cc b/test/ti-agent/common_load.cc
index c5a9356..351857d 100644
--- a/test/ti-agent/common_load.cc
+++ b/test/ti-agent/common_load.cc
@@ -122,6 +122,7 @@
{ "942-private-recursive", common_redefine::OnLoad, nullptr },
{ "943-private-recursive-jit", common_redefine::OnLoad, nullptr },
{ "944-transform-classloaders", common_redefine::OnLoad, nullptr },
+ { "945-obsolete-native", common_redefine::OnLoad, nullptr },
};
static AgentLib* FindAgent(char* name) {