summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/driver/compiler_driver.cc20
-rw-r--r--compiler/image_writer.cc10
-rw-r--r--compiler/optimizing/code_generator.cc2
-rw-r--r--compiler/optimizing/inliner.cc2
-rw-r--r--compiler/optimizing/instruction_builder.cc20
-rw-r--r--compiler/optimizing/optimizing_compiler.cc2
-rw-r--r--compiler/optimizing/sharpening.cc6
-rw-r--r--compiler/utils/x86/assembler_x86.cc142
-rw-r--r--compiler/utils/x86/assembler_x86.h16
-rw-r--r--compiler/utils/x86/assembler_x86_test.cc74
-rw-r--r--compiler/utils/x86_64/assembler_x86_64.cc119
-rw-r--r--compiler/utils/x86_64/assembler_x86_64.h18
-rw-r--r--compiler/utils/x86_64/assembler_x86_64_test.cc50
-rw-r--r--compiler/verifier_deps_test.cc2
-rw-r--r--dex2oat/dex2oat.cc58
-rw-r--r--dex2oat/dex2oat_test.cc44
-rw-r--r--dexdump/dexdump.cc244
-rw-r--r--disassembler/disassembler_x86.cc16
-rw-r--r--oatdump/oatdump.cc4
-rw-r--r--patchoat/patchoat.cc10
-rw-r--r--runtime/Android.bp2
-rw-r--r--runtime/arch/stub_test.cc4
-rw-r--r--runtime/art_method.cc52
-rw-r--r--runtime/art_method.h1
-rw-r--r--runtime/class_linker.cc315
-rw-r--r--runtime/class_linker.h10
-rw-r--r--runtime/class_linker_test.cc35
-rw-r--r--runtime/class_table_test.cc2
-rw-r--r--runtime/common_runtime_test.h6
-rw-r--r--runtime/common_throws.cc16
-rw-r--r--runtime/common_throws.h10
-rw-r--r--runtime/debugger.cc18
-rw-r--r--runtime/dex_file.cc34
-rw-r--r--runtime/dex_file.h30
-rw-r--r--runtime/dex_file_annotations.cc28
-rw-r--r--runtime/dex_file_verifier.cc8
-rw-r--r--runtime/dex_instruction.cc32
-rw-r--r--runtime/dex_instruction.h68
-rw-r--r--runtime/dex_instruction_list.h4
-rw-r--r--runtime/entrypoints/entrypoint_utils.cc2
-rw-r--r--runtime/entrypoints/quick/quick_field_entrypoints.cc2
-rw-r--r--runtime/entrypoints/quick/quick_trampoline_entrypoints.cc21
-rw-r--r--runtime/gc/reference_queue_test.cc14
-rw-r--r--runtime/gc/space/image_space.cc8
-rw-r--r--runtime/gc/space/space_create_test.cc16
-rw-r--r--runtime/gc/space/space_test.h4
-rw-r--r--runtime/handle.h8
-rw-r--r--runtime/imtable_test.cc4
-rw-r--r--runtime/indirect_reference_table_test.cc20
-rw-r--r--runtime/intern_table_test.cc14
-rw-r--r--runtime/interpreter/interpreter_common.cc336
-rw-r--r--runtime/interpreter/interpreter_common.h12
-rw-r--r--runtime/interpreter/interpreter_switch_impl.cc22
-rw-r--r--runtime/interpreter/unstarted_runtime.cc22
-rw-r--r--runtime/interpreter/unstarted_runtime_test.cc4
-rw-r--r--runtime/jdwp/object_registry.cc4
-rw-r--r--runtime/jit/jit_code_cache.cc4
-rw-r--r--runtime/jni_internal.cc2
-rw-r--r--runtime/jobject_comparator.cc4
-rw-r--r--runtime/method_handles.cc138
-rw-r--r--runtime/method_handles.h6
-rw-r--r--runtime/mirror/array.cc6
-rw-r--r--runtime/mirror/call_site.cc52
-rw-r--r--runtime/mirror/call_site.h64
-rw-r--r--runtime/mirror/class.cc14
-rw-r--r--runtime/mirror/class_ext.cc4
-rw-r--r--runtime/mirror/dex_cache-inl.h46
-rw-r--r--runtime/mirror/dex_cache.cc14
-rw-r--r--runtime/mirror/dex_cache.h51
-rw-r--r--runtime/mirror/dex_cache_test.cc6
-rw-r--r--runtime/mirror/emulated_stack_frame.cc4
-rw-r--r--runtime/mirror/field-inl.h4
-rw-r--r--runtime/mirror/method_handle_impl.cc24
-rw-r--r--runtime/mirror/method_handle_impl.h23
-rw-r--r--runtime/mirror/method_handles_lookup.cc58
-rw-r--r--runtime/mirror/method_handles_lookup.h70
-rw-r--r--runtime/mirror/method_type.cc16
-rw-r--r--runtime/mirror/method_type.h4
-rw-r--r--runtime/mirror/method_type_test.cc2
-rw-r--r--runtime/mirror/object_test.cc10
-rw-r--r--runtime/monitor_test.cc4
-rw-r--r--runtime/native/dalvik_system_VMRuntime.cc4
-rw-r--r--runtime/native/java_lang_Class.cc22
-rw-r--r--runtime/native/java_lang_invoke_MethodHandleImpl.cc2
-rw-r--r--runtime/native/java_lang_reflect_Executable.cc6
-rw-r--r--runtime/native/libcore_util_CharsetUtils.cc4
-rw-r--r--runtime/oat_file.cc44
-rw-r--r--runtime/oat_file_assistant_test.cc2
-rw-r--r--runtime/oat_file_manager.cc8
-rw-r--r--runtime/object_lock.cc4
-rw-r--r--runtime/openjdkjvmti/ti_class_loader.cc8
-rw-r--r--runtime/openjdkjvmti/ti_redefine.cc134
-rw-r--r--runtime/openjdkjvmti/ti_redefine.h6
-rw-r--r--runtime/openjdkjvmti/ti_threadgroup.cc6
-rw-r--r--runtime/proxy_test.cc20
-rw-r--r--runtime/reference_table_test.cc4
-rw-r--r--runtime/reflection.cc10
-rw-r--r--runtime/runtime.cc2
-rw-r--r--runtime/runtime_callbacks_test.cc2
-rw-r--r--runtime/stack.cc12
-rw-r--r--runtime/stack_map.h21
-rw-r--r--runtime/thread.cc16
-rw-r--r--runtime/transaction_test.cc62
-rw-r--r--runtime/utils.h24
-rw-r--r--runtime/utils/dex_cache_arrays_layout-inl.h21
-rw-r--r--runtime/utils/dex_cache_arrays_layout.h14
-rw-r--r--runtime/utils_test.cc19
-rw-r--r--runtime/verifier/method_verifier.cc150
-rw-r--r--runtime/verifier/method_verifier.h5
-rw-r--r--runtime/verifier/verifier_deps.cc8
-rw-r--r--runtime/zip_archive.cc113
-rw-r--r--runtime/zip_archive.h18
-rwxr-xr-xtest/044-proxy/build17
-rw-r--r--test/044-proxy/expected.txt2
-rwxr-xr-xtest/071-dexfile-map-clean/build21
-rw-r--r--test/071-dexfile-map-clean/expected.txt3
-rw-r--r--test/071-dexfile-map-clean/info.txt11
-rwxr-xr-xtest/071-dexfile-map-clean/run31
-rw-r--r--test/071-dexfile-map-clean/src-ex/Another.java21
-rw-r--r--test/071-dexfile-map-clean/src/Main.java147
-rw-r--r--test/121-modifiers/build40
-rw-r--r--test/121-modifiers/info.txt17
-rw-r--r--test/121-modifiers/smali/A$B.smali42
-rw-r--r--test/121-modifiers/smali/A$C.smali30
-rw-r--r--test/121-modifiers/smali/A.smali41
-rw-r--r--test/121-modifiers/smali/Inf.smali23
-rw-r--r--test/121-modifiers/smali/NonInf.smali177
-rw-r--r--test/121-modifiers/src-java/A.java23
-rw-r--r--test/121-modifiers/src-java/Asm.java (renamed from test/121-modifiers/src/Asm.java)0
-rw-r--r--test/121-modifiers/src-java/Inf.java (renamed from test/121-modifiers/src/Inf.java)0
-rw-r--r--test/121-modifiers/src-java/NonInf.java (renamed from test/121-modifiers/src/NonInf.java)0
-rw-r--r--test/121-modifiers/src2/Main.java (renamed from test/121-modifiers/src/Main.java)8
-rw-r--r--test/626-const-class-linking/clear_dex_cache_types.cc2
-rw-r--r--test/911-get-stack-trace/expected.txt146
-rw-r--r--test/911-get-stack-trace/src/AllTraces.java6
-rw-r--r--test/911-get-stack-trace/src/Frames.java4
-rw-r--r--test/911-get-stack-trace/src/OtherThread.java4
-rw-r--r--test/911-get-stack-trace/src/ThreadListTraces.java2
-rwxr-xr-xtest/945-obsolete-native/build17
-rw-r--r--test/945-obsolete-native/expected.txt9
-rw-r--r--test/945-obsolete-native/info.txt1
-rw-r--r--test/945-obsolete-native/obsolete_native.cc51
-rwxr-xr-xtest/945-obsolete-native/run17
-rw-r--r--test/945-obsolete-native/src/Main.java77
-rw-r--r--test/945-obsolete-native/src/Transform.java25
-rw-r--r--test/952-invoke-custom/build25
-rw-r--r--test/952-invoke-custom/expected.txt14
-rw-r--r--test/952-invoke-custom/generator/TestInvokeCustomWithConcurrentThreads.java227
-rw-r--r--test/952-invoke-custom/generator/TestLinkerMethodMinimalArguments.java137
-rw-r--r--test/952-invoke-custom/generator/TestLinkerMethodMultipleArgumentTypes.java140
-rwxr-xr-xtest/952-invoke-custom/generator/build-test.sh77
-rw-r--r--test/952-invoke-custom/info.txt7
-rw-r--r--test/952-invoke-custom/src/Main.java159
-rw-r--r--test/952-invoke-custom/src/TestDataInvokeCustomWithConcurrentThreads.java145
-rw-r--r--test/952-invoke-custom/src/TestDataLinkerMethodMinimalArguments.java106
-rw-r--r--test/952-invoke-custom/src/TestDataLinkerMethodMultipleArgumentTypes.java108
-rw-r--r--test/Android.bp1
-rw-r--r--test/dexdump/invoke-custom.dexbin0 -> 3276 bytes
-rw-r--r--test/dexdump/invoke-custom.lst6
-rw-r--r--test/dexdump/invoke-custom.txt254
-rw-r--r--test/dexdump/invoke-custom.xml89
-rwxr-xr-xtest/etc/default-build42
-rwxr-xr-xtest/etc/run-test-jar19
-rwxr-xr-xtest/run-test18
-rw-r--r--test/ti-agent/common_load.cc1
165 files changed, 5274 insertions, 764 deletions
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 7af850a263..f7bea32d4c 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -960,7 +960,7 @@ static void EnsureVerifiedOrVerifyAtRuntime(jobject jclass_loader,
const DexFile::ClassDef& class_def = dex_file->GetClassDef(i);
const char* descriptor = dex_file->GetClassDescriptor(class_def);
cls.Assign(class_linker->FindClass(soa.Self(), descriptor, class_loader));
- if (cls.Get() == nullptr) {
+ if (cls == nullptr) {
soa.Self()->ClearException();
} else if (&cls->GetDexFile() == dex_file) {
DCHECK(cls->IsErroneous() || cls->IsVerified() || cls->IsCompileTimeVerified())
@@ -1155,7 +1155,7 @@ void CompilerDriver::LoadImageClasses(TimingLogger* timings) {
StackHandleScope<1> hs(self);
Handle<mirror::Class> klass(
hs.NewHandle(class_linker->FindSystemClass(self, descriptor.c_str())));
- if (klass.Get() == nullptr) {
+ if (klass == nullptr) {
VLOG(compiler) << "Failed to find class " << descriptor;
image_classes_->erase(it++);
self->ClearException();
@@ -1182,13 +1182,13 @@ void CompilerDriver::LoadImageClasses(TimingLogger* timings) {
Handle<mirror::DexCache> dex_cache(hs2.NewHandle(class_linker->RegisterDexFile(*dex_file,
nullptr)));
Handle<mirror::Class> klass(hs2.NewHandle(
- (dex_cache.Get() != nullptr)
+ (dex_cache != nullptr)
? class_linker->ResolveType(*dex_file,
exception_type_idx,
dex_cache,
ScopedNullHandle<mirror::ClassLoader>())
: nullptr));
- if (klass.Get() == nullptr) {
+ if (klass == nullptr) {
const DexFile::TypeId& type_id = dex_file->GetTypeId(exception_type_idx);
const char* descriptor = dex_file->GetTypeDescriptor(type_id);
LOG(FATAL) << "Failed to resolve class " << descriptor;
@@ -1877,7 +1877,7 @@ class ResolveTypeVisitor : public CompilationVisitor {
Handle<mirror::DexCache> dex_cache(hs.NewHandle(class_linker->RegisterDexFile(
dex_file,
class_loader.Get())));
- ObjPtr<mirror::Class> klass = (dex_cache.Get() != nullptr)
+ ObjPtr<mirror::Class> klass = (dex_cache != nullptr)
? class_linker->ResolveType(dex_file, dex::TypeIndex(type_idx), dex_cache, class_loader)
: nullptr;
@@ -1978,7 +1978,7 @@ static void LoadAndUpdateStatus(const DexFile& dex_file,
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
Handle<mirror::Class> cls(hs.NewHandle<mirror::Class>(
class_linker->FindClass(self, descriptor, class_loader)));
- if (cls.Get() != nullptr) {
+ if (cls != nullptr) {
// Check that the class is resolved with the current dex file. We might get
// a boot image class, or a class in a different dex file for multidex, and
// we should not update the status in that case.
@@ -2126,7 +2126,7 @@ class VerifyClassVisitor : public CompilationVisitor {
Handle<mirror::Class> klass(
hs.NewHandle(class_linker->FindClass(soa.Self(), descriptor, class_loader)));
verifier::MethodVerifier::FailureKind failure_kind;
- if (klass.Get() == nullptr) {
+ if (klass == nullptr) {
CHECK(soa.Self()->IsExceptionPending());
soa.Self()->ClearException();
@@ -2228,7 +2228,7 @@ class SetVerifiedClassVisitor : public CompilationVisitor {
Handle<mirror::Class> klass(
hs.NewHandle(class_linker->FindClass(soa.Self(), descriptor, class_loader)));
// Class might have failed resolution. Then don't set it to verified.
- if (klass.Get() != nullptr) {
+ if (klass != nullptr) {
// Only do this if the class is resolved. If even resolution fails, quickening will go very,
// very wrong.
if (klass->IsResolved() && !klass->IsErroneousResolved()) {
@@ -2290,7 +2290,7 @@ class InitializeClassVisitor : public CompilationVisitor {
Handle<mirror::Class> klass(
hs.NewHandle(manager_->GetClassLinker()->FindClass(soa.Self(), descriptor, class_loader)));
- if (klass.Get() != nullptr && !SkipClass(jclass_loader, dex_file, klass.Get())) {
+ if (klass != nullptr && !SkipClass(jclass_loader, dex_file, klass.Get())) {
// Only try to initialize classes that were successfully verified.
if (klass->IsVerified()) {
// Attempt to initialize the class but bail if we either need to initialize the super-class
@@ -2540,7 +2540,7 @@ class CompileClassVisitor : public CompilationVisitor {
Handle<mirror::Class> klass(
hs.NewHandle(class_linker->FindClass(soa.Self(), descriptor, class_loader)));
Handle<mirror::DexCache> dex_cache;
- if (klass.Get() == nullptr) {
+ if (klass == nullptr) {
soa.Self()->AssertPendingException();
soa.Self()->ClearException();
dex_cache = hs.NewHandle(class_linker->FindDexCache(soa.Self(), dex_file));
diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc
index c72edb18a3..d2dd30d8e6 100644
--- a/compiler/image_writer.cc
+++ b/compiler/image_writer.cc
@@ -1078,7 +1078,7 @@ ObjectArray<Object>* ImageWriter::CreateImageRoots(size_t oat_index) const {
}
Handle<ObjectArray<Object>> dex_caches(
hs.NewHandle(ObjectArray<Object>::Alloc(self, object_array_class.Get(), dex_cache_count)));
- CHECK(dex_caches.Get() != nullptr) << "Failed to allocate a dex cache array.";
+ CHECK(dex_caches != nullptr) << "Failed to allocate a dex cache array.";
{
ReaderMutexLock mu(self, *Locks::dex_lock_);
size_t non_image_dex_caches = 0;
@@ -2254,6 +2254,14 @@ void ImageWriter::FixupDexCache(mirror::DexCache* orig_dex_cache,
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/code_generator.cc b/compiler/optimizing/code_generator.cc
index d68aa51b1b..bac16cd5df 100644
--- a/compiler/optimizing/code_generator.cc
+++ b/compiler/optimizing/code_generator.cc
@@ -1419,7 +1419,7 @@ void CodeGenerator::EmitJitRoots(uint8_t* code,
QuickEntrypointEnum CodeGenerator::GetArrayAllocationEntrypoint(Handle<mirror::Class> array_klass) {
ScopedObjectAccess soa(Thread::Current());
- if (array_klass.Get() == nullptr) {
+ if (array_klass == nullptr) {
// This can only happen for non-primitive arrays, as primitive arrays can always
// be resolved.
return kQuickAllocArrayResolved32;
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index 1380355603..2dd5fefc80 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -378,7 +378,7 @@ bool HInliner::TryInline(HInvoke* invoke_instruction) {
soa.Self(),
class_linker->GetClassRoot(ClassLinker::kClassArrayClass),
InlineCache::kIndividualCacheSize));
- if (inline_cache.Get() == nullptr) {
+ if (inline_cache == nullptr) {
// We got an OOME. Just clear the exception, and don't inline.
DCHECK(soa.Self()->IsExceptionPending());
soa.Self()->ClearException();
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc
index a1c391f455..3374e42955 100644
--- a/compiler/optimizing/instruction_builder.cc
+++ b/compiler/optimizing/instruction_builder.cc
@@ -680,7 +680,7 @@ ArtMethod* HInstructionBuilder::ResolveMethod(uint16_t method_idx, InvokeType in
Handle<mirror::Class> methods_class(hs.NewHandle(class_linker->ResolveReferencedClassOfMethod(
method_idx, dex_compilation_unit_->GetDexCache(), class_loader)));
- if (UNLIKELY(methods_class.Get() == nullptr)) {
+ if (UNLIKELY(methods_class == nullptr)) {
// Clean up any exception left by type resolution.
soa.Self()->ClearException();
return nullptr;
@@ -702,7 +702,7 @@ ArtMethod* HInstructionBuilder::ResolveMethod(uint16_t method_idx, InvokeType in
// Check access. The class linker has a fast path for looking into the dex cache
// and does not check the access if it hits it.
- if (compiling_class.Get() == nullptr) {
+ if (compiling_class == nullptr) {
if (!resolved_method->IsPublic()) {
return nullptr;
}
@@ -718,7 +718,7 @@ ArtMethod* HInstructionBuilder::ResolveMethod(uint16_t method_idx, InvokeType in
// make this an invoke-unresolved to handle cross-dex invokes or abstract super methods, both of
// which require runtime handling.
if (invoke_type == kSuper) {
- if (compiling_class.Get() == nullptr) {
+ if (compiling_class == nullptr) {
// We could not determine the method's class we need to wait until runtime.
DCHECK(Runtime::Current()->IsAotCompiler());
return nullptr;
@@ -954,7 +954,7 @@ bool HInstructionBuilder::BuildNewInstance(dex::TypeIndex type_index, uint32_t d
}
// Consider classes we haven't resolved as potentially finalizable.
- bool finalizable = (klass.Get() == nullptr) || klass->IsFinalizable();
+ bool finalizable = (klass == nullptr) || klass->IsFinalizable();
AppendInstruction(new (arena_) HNewInstance(
cls,
@@ -972,7 +972,7 @@ static bool IsSubClass(mirror::Class* to_test, mirror::Class* super_class)
}
bool HInstructionBuilder::IsInitialized(Handle<mirror::Class> cls) const {
- if (cls.Get() == nullptr) {
+ if (cls == nullptr) {
return false;
}
@@ -1292,7 +1292,7 @@ bool HInstructionBuilder::IsOutermostCompilingClass(dex::TypeIndex type_index) c
// When this happens we cannot establish a direct relation between the current
// class and the outer class, so we return false.
// (Note that this is only used for optimizing invokes and field accesses)
- return (cls.Get() != nullptr) && (outer_class.Get() == cls.Get());
+ return (cls != nullptr) && (outer_class.Get() == cls.Get());
}
void HInstructionBuilder::BuildUnresolvedStaticFieldAccess(const Instruction& instruction,
@@ -1340,7 +1340,7 @@ ArtField* HInstructionBuilder::ResolveField(uint16_t field_idx, bool is_static,
}
// Check access.
- if (compiling_class.Get() == nullptr) {
+ if (compiling_class == nullptr) {
if (!resolved_field->IsPublic()) {
return nullptr;
}
@@ -1612,7 +1612,7 @@ void HInstructionBuilder::BuildFillWideArrayData(HInstruction* object,
static TypeCheckKind ComputeTypeCheckKind(Handle<mirror::Class> cls)
REQUIRES_SHARED(Locks::mutator_lock_) {
- if (cls.Get() == nullptr) {
+ if (cls == nullptr) {
return TypeCheckKind::kUnresolvedCheck;
} else if (cls->IsInterface()) {
return TypeCheckKind::kInterfaceCheck;
@@ -1643,7 +1643,7 @@ HLoadClass* HInstructionBuilder::BuildLoadClass(dex::TypeIndex type_index, uint3
soa, dex_compilation_unit_->GetDexCache(), class_loader, type_index, dex_compilation_unit_));
bool needs_access_check = true;
- if (klass.Get() != nullptr) {
+ if (klass != nullptr) {
if (klass->IsPublic()) {
needs_access_check = false;
} else {
@@ -1679,7 +1679,7 @@ HLoadClass* HInstructionBuilder::BuildLoadClass(dex::TypeIndex type_index,
type_index,
*actual_dex_file,
klass,
- klass.Get() != nullptr && (klass.Get() == GetOutermostCompilingClass()),
+ klass != nullptr && (klass.Get() == GetOutermostCompilingClass()),
dex_pc,
needs_access_check);
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index 727ca7d893..8638e346fb 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -1214,7 +1214,7 @@ bool OptimizingCompiler::JitCompile(Thread* self,
Handle<mirror::ObjectArray<mirror::Object>> roots(
hs.NewHandle(mirror::ObjectArray<mirror::Object>::Alloc(
self, class_linker->GetClassRoot(ClassLinker::kObjectArrayClass), number_of_roots)));
- if (roots.Get() == nullptr) {
+ if (roots == nullptr) {
// Out of memory, just clear the exception to avoid any Java exception uncaught problems.
DCHECK(self->IsExceptionPending());
self->ClearException();
diff --git a/compiler/optimizing/sharpening.cc b/compiler/optimizing/sharpening.cc
index f07f02a719..be400925d5 100644
--- a/compiler/optimizing/sharpening.cc
+++ b/compiler/optimizing/sharpening.cc
@@ -163,7 +163,7 @@ HLoadClass::LoadKind HSharpening::SharpenClass(HLoadClass* load_class,
if (!compiler_driver->GetSupportBootImageFixup()) {
// compiler_driver_test. Do not sharpen.
desired_load_kind = HLoadClass::LoadKind::kDexCacheViaMethod;
- } else if ((klass.Get() != nullptr) && compiler_driver->IsImageClass(
+ } else if ((klass != nullptr) && compiler_driver->IsImageClass(
dex_file.StringDataByIdx(dex_file.GetTypeId(type_index).descriptor_idx_))) {
is_in_boot_image = true;
desired_load_kind = codegen->GetCompilerOptions().GetCompilePic()
@@ -175,7 +175,7 @@ HLoadClass::LoadKind HSharpening::SharpenClass(HLoadClass* load_class,
desired_load_kind = HLoadClass::LoadKind::kBssEntry;
}
} else {
- is_in_boot_image = (klass.Get() != nullptr) &&
+ is_in_boot_image = (klass != nullptr) &&
runtime->GetHeap()->ObjectIsInBootImageSpace(klass.Get());
if (runtime->UseJitCompilation()) {
// TODO: Make sure we don't set the "compile PIC" flag for JIT as that's bogus.
@@ -183,7 +183,7 @@ HLoadClass::LoadKind HSharpening::SharpenClass(HLoadClass* load_class,
if (is_in_boot_image) {
// TODO: Use direct pointers for all non-moving spaces, not just boot image. Bug: 29530787
desired_load_kind = HLoadClass::LoadKind::kBootImageAddress;
- } else if (klass.Get() != nullptr) {
+ } else if (klass != nullptr) {
desired_load_kind = HLoadClass::LoadKind::kJitTableAddress;
} else {
// Class not loaded yet. This happens when the dex code requesting
diff --git a/compiler/utils/x86/assembler_x86.cc b/compiler/utils/x86/assembler_x86.cc
index a24d49e08d..5a466e1d5d 100644
--- a/compiler/utils/x86/assembler_x86.cc
+++ b/compiler/utils/x86/assembler_x86.cc
@@ -783,6 +783,79 @@ void X86Assembler::divpd(XmmRegister dst, XmmRegister src) {
}
+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::xorpd(XmmRegister dst, XmmRegister src) {
}
-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,53 +1097,63 @@ void X86Assembler::andpd(XmmRegister dst, XmmRegister src) {
}
-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);
+ EmitUint8(0x54);
+ EmitOperand(dst, src);
+}
+
+
+void X86Assembler::andps(XmmRegister dst, XmmRegister src) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x0F);
+ EmitUint8(0x54);
EmitXmmRegisterOperand(dst, src);
}
-void X86Assembler::xorps(XmmRegister dst, const Address& src) {
+void X86Assembler::andps(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::pand(XmmRegister dst, XmmRegister src) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
EmitUint8(0x0F);
- EmitUint8(0x56);
+ EmitUint8(0xDB);
EmitXmmRegisterOperand(dst, src);
}
-void X86Assembler::xorps(XmmRegister dst, XmmRegister src) {
+void X86Assembler::orpd(XmmRegister dst, XmmRegister src) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x66);
EmitUint8(0x0F);
- EmitUint8(0x57);
+ EmitUint8(0x56);
EmitXmmRegisterOperand(dst, src);
}
-void X86Assembler::andps(XmmRegister dst, const Address& src) {
+void X86Assembler::orps(XmmRegister dst, XmmRegister src) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
EmitUint8(0x0F);
- EmitUint8(0x54);
- EmitOperand(dst, src);
+ EmitUint8(0x56);
+ EmitXmmRegisterOperand(dst, src);
}
-void X86Assembler::andpd(XmmRegister dst, const Address& src) {
+void X86Assembler::por(XmmRegister dst, XmmRegister src) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
EmitUint8(0x66);
EmitUint8(0x0F);
- EmitUint8(0x54);
- EmitOperand(dst, src);
+ EmitUint8(0xEB);
+ EmitXmmRegisterOperand(dst, src);
}
@@ -1076,6 +1176,16 @@ void X86Assembler::shufps(XmmRegister dst, XmmRegister src, const Immediate& imm
}
+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 4056ca67fb..4343e2e734 100644
--- a/compiler/utils/x86/assembler_x86.h
+++ b/compiler/utils/x86/assembler_x86.h
@@ -430,6 +430,16 @@ class X86Assembler FINAL : public Assembler {
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 @@ class X86Assembler FINAL : public Assembler {
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 1768d8b715..c6ab893aea 100644
--- a/compiler/utils/x86/assembler_x86_test.cc
+++ b/compiler/utils/x86/assembler_x86_test.cc
@@ -467,6 +467,28 @@ TEST_F(AssemblerX86Test, MovupdAddr) {
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 @@ TEST_F(AssemblerX86Test, DivPD) {
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 @@ TEST_F(AssemblerX86Test, ShufPD) {
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 c2c44ab58c..b41be80ae4 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::divpd(XmmRegister dst, XmmRegister src) {
}
+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::xorps(XmmRegister dst, XmmRegister src) {
}
+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 @@ void X86_64Assembler::andps(XmmRegister dst, XmmRegister src) {
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 @@ void X86_64Assembler::orps(XmmRegister dst, XmmRegister src) {
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::shufps(XmmRegister dst, XmmRegister src, const Immediate&
}
+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 e140b45a00..43ea12a4cb 100644
--- a/compiler/utils/x86_64/assembler_x86_64.h
+++ b/compiler/utils/x86_64/assembler_x86_64.h
@@ -446,6 +446,16 @@ class X86_64Assembler FINAL : public Assembler {
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 @@ class X86_64Assembler FINAL : public Assembler {
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 efa5cc97ea..aeb1911835 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 @@ TEST_F(AssemblerX86_64Test, Movsd) {
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 @@ TEST_F(AssemblerX86_64Test, Divpd) {
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 @@ TEST_F(AssemblerX86_64Test, Xorpd) {
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 @@ TEST_F(AssemblerX86_64Test, Andpd) {
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 @@ TEST_F(AssemblerX86_64Test, Orpd) {
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 @@ TEST_F(AssemblerX86_64Test, Shufpd) {
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/compiler/verifier_deps_test.cc b/compiler/verifier_deps_test.cc
index 5fc9972d09..c892b25ed3 100644
--- a/compiler/verifier_deps_test.cc
+++ b/compiler/verifier_deps_test.cc
@@ -233,7 +233,7 @@ class VerifierDepsTest : public CommonCompilerTest {
const DexFile::ClassDef& class_def = dex_file->GetClassDef(i);
const char* descriptor = dex_file->GetClassDescriptor(class_def);
cls.Assign(class_linker_->FindClass(soa.Self(), descriptor, class_loader_handle));
- if (cls.Get() == nullptr) {
+ if (cls == nullptr) {
CHECK(soa.Self()->IsExceptionPending());
soa.Self()->ClearException();
} else if (set.find(class_def.class_idx_) == set.end()) {
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 192fc270f9..026a567fe0 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -419,12 +419,9 @@ class WatchDog {
} while (false)
public:
- explicit WatchDog(bool is_watch_dog_enabled) {
- is_watch_dog_enabled_ = is_watch_dog_enabled;
- if (!is_watch_dog_enabled_) {
- return;
- }
- shutting_down_ = false;
+ explicit WatchDog(int64_t timeout_in_milliseconds)
+ : timeout_in_milliseconds_(timeout_in_milliseconds),
+ shutting_down_(false) {
const char* reason = "dex2oat watch dog thread startup";
CHECK_WATCH_DOG_PTHREAD_CALL(pthread_mutex_init, (&mutex_, nullptr), reason);
CHECK_WATCH_DOG_PTHREAD_CALL(pthread_cond_init, (&cond_, nullptr), reason);
@@ -433,9 +430,6 @@ class WatchDog {
CHECK_WATCH_DOG_PTHREAD_CALL(pthread_attr_destroy, (&attr_), reason);
}
~WatchDog() {
- if (!is_watch_dog_enabled_) {
- return;
- }
const char* reason = "dex2oat watch dog thread shutdown";
CHECK_WATCH_DOG_PTHREAD_CALL(pthread_mutex_lock, (&mutex_), reason);
shutting_down_ = true;
@@ -448,6 +442,23 @@ class WatchDog {
CHECK_WATCH_DOG_PTHREAD_CALL(pthread_mutex_destroy, (&mutex_), reason);
}
+ // TODO: tune the multiplier for GC verification, the following is just to make the timeout
+ // large.
+ static constexpr int64_t kWatchdogVerifyMultiplier =
+ kVerifyObjectSupport > kVerifyObjectModeFast ? 100 : 1;
+
+ // When setting timeouts, keep in mind that the build server may not be as fast as your
+ // desktop. Debug builds are slower so they have larger timeouts.
+ static constexpr int64_t kWatchdogSlowdownFactor = kIsDebugBuild ? 5U : 1U;
+
+ // 9.5 minutes scaled by kSlowdownFactor. This is slightly smaller than the Package Manager
+ // watchdog (PackageManagerService.WATCHDOG_TIMEOUT, 10 minutes), so that dex2oat will abort
+ // itself before that watchdog would take down the system server.
+ static constexpr int64_t kWatchDogTimeoutSeconds = kWatchdogSlowdownFactor * (9 * 60 + 30);
+
+ static constexpr int64_t kDefaultWatchdogTimeoutInMS =
+ kWatchdogVerifyMultiplier * kWatchDogTimeoutSeconds * 1000;
+
private:
static void* CallBack(void* arg) {
WatchDog* self = reinterpret_cast<WatchDog*>(arg);
@@ -470,18 +481,15 @@ class WatchDog {
}
void Wait() {
- // TODO: tune the multiplier for GC verification, the following is just to make the timeout
- // large.
- constexpr int64_t multiplier = kVerifyObjectSupport > kVerifyObjectModeFast ? 100 : 1;
timespec timeout_ts;
- InitTimeSpec(true, CLOCK_REALTIME, multiplier * kWatchDogTimeoutSeconds * 1000, 0, &timeout_ts);
+ InitTimeSpec(true, CLOCK_REALTIME, timeout_in_milliseconds_, 0, &timeout_ts);
const char* reason = "dex2oat watch dog thread waiting";
CHECK_WATCH_DOG_PTHREAD_CALL(pthread_mutex_lock, (&mutex_), reason);
while (!shutting_down_) {
int rc = TEMP_FAILURE_RETRY(pthread_cond_timedwait(&cond_, &mutex_, &timeout_ts));
if (rc == ETIMEDOUT) {
Fatal(StringPrintf("dex2oat did not finish after %" PRId64 " seconds",
- kWatchDogTimeoutSeconds));
+ timeout_in_milliseconds_/1000));
} else if (rc != 0) {
std::string message(StringPrintf("pthread_cond_timedwait failed: %s",
strerror(errno)));
@@ -491,16 +499,7 @@ class WatchDog {
CHECK_WATCH_DOG_PTHREAD_CALL(pthread_mutex_unlock, (&mutex_), reason);
}
- // When setting timeouts, keep in mind that the build server may not be as fast as your desktop.
- // Debug builds are slower so they have larger timeouts.
- static constexpr int64_t kSlowdownFactor = kIsDebugBuild ? 5U : 1U;
-
- // 9.5 minutes scaled by kSlowdownFactor. This is slightly smaller than the Package Manager
- // watchdog (PackageManagerService.WATCHDOG_TIMEOUT, 10 minutes), so that dex2oat will abort
- // itself before that watchdog would take down the system server.
- static constexpr int64_t kWatchDogTimeoutSeconds = kSlowdownFactor * (9 * 60 + 30);
-
- bool is_watch_dog_enabled_;
+ const int64_t timeout_in_milliseconds_;
bool shutting_down_;
// TODO: Switch to Mutex when we can guarantee it won't prevent shutdown in error cases.
pthread_mutex_t mutex_;
@@ -591,6 +590,7 @@ class Dex2Oat FINAL {
struct ParserOptions {
std::vector<const char*> oat_symbols;
std::string boot_image_filename;
+ int64_t watch_dog_timeout_in_ms = -1;
bool watch_dog_enabled = true;
bool requested_specific_compiler = false;
std::string error_msg;
@@ -919,7 +919,10 @@ class Dex2Oat FINAL {
// Done with usage checks, enable watchdog if requested
if (parser_options->watch_dog_enabled) {
- watchdog_.reset(new WatchDog(true));
+ int64_t timeout = parser_options->watch_dog_timeout_in_ms > 0
+ ? parser_options->watch_dog_timeout_in_ms
+ : WatchDog::kDefaultWatchdogTimeoutInMS;
+ watchdog_.reset(new WatchDog(timeout));
}
// Fill some values into the key-value store for the oat header.
@@ -1150,6 +1153,11 @@ class Dex2Oat FINAL {
parser_options->watch_dog_enabled = true;
} else if (option == "--no-watch-dog") {
parser_options->watch_dog_enabled = false;
+ } else if (option.starts_with("--watchdog-timeout=")) {
+ ParseIntOption(option,
+ "--watchdog-timeout",
+ &parser_options->watch_dog_timeout_in_ms,
+ Usage);
} else if (option.starts_with("-j")) {
ParseJ(option);
} else if (option.starts_with("--image=")) {
diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index e208337652..5dcdd9e69a 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -66,7 +66,7 @@ class Dex2oatTest : public Dex2oatEnvironmentTest {
bool success = Dex2Oat(args, &error_msg);
if (expect_success) {
- ASSERT_TRUE(success) << error_msg;
+ ASSERT_TRUE(success) << error_msg << std::endl << output_;
// Verify the odex file was generated as expected.
std::unique_ptr<OatFile> odex_file(OatFile::Open(odex_location.c_str(),
@@ -399,6 +399,11 @@ class Dex2oatSwapUseTest : public Dex2oatSwapTest {
};
TEST_F(Dex2oatSwapUseTest, CheckSwapUsage) {
+ // The `native_alloc_2_ >= native_alloc_1_` assertion below may not
+ // hold true on some x86 systems when read barriers are enabled;
+ // disable this test while we investigate (b/29259363).
+ TEST_DISABLED_FOR_READ_BARRIER_ON_X86();
+
RunTest(false /* use_fd */,
false /* expect_use */);
GrabResult1();
@@ -653,4 +658,41 @@ TEST_F(Dex2oatLayoutTest, TestLayout) {
RunTest();
}
+class Dex2oatWatchdogTest : public Dex2oatTest {
+ protected:
+ void RunTest(bool expect_success, const std::vector<std::string>& extra_args = {}) {
+ std::string dex_location = GetScratchDir() + "/Dex2OatSwapTest.jar";
+ std::string odex_location = GetOdexDir() + "/Dex2OatSwapTest.odex";
+
+ Copy(GetTestDexFileName(), dex_location);
+
+ std::vector<std::string> copy(extra_args);
+
+ std::string swap_location = GetOdexDir() + "/Dex2OatSwapTest.odex.swap";
+ copy.push_back("--swap-file=" + swap_location);
+ GenerateOdexForTest(dex_location,
+ odex_location,
+ CompilerFilter::kSpeed,
+ copy,
+ expect_success);
+ }
+
+ std::string GetTestDexFileName() {
+ return GetDexSrc1();
+ }
+};
+
+TEST_F(Dex2oatWatchdogTest, TestWatchdogOK) {
+ // Check with default.
+ RunTest(true);
+
+ // Check with ten minutes.
+ RunTest(true, { "--watchdog-timeout=600000" });
+}
+
+TEST_F(Dex2oatWatchdogTest, TestWatchdogTrigger) {
+ // Check with ten milliseconds.
+ RunTest(false, { "--watchdog-timeout=10" });
+}
+
} // namespace art
diff --git a/dexdump/dexdump.cc b/dexdump/dexdump.cc
index d5776fa61e..5656ddd59c 100644
--- a/dexdump/dexdump.cc
+++ b/dexdump/dexdump.cc
@@ -881,26 +881,30 @@ static std::unique_ptr<char[]> indexString(const DexFile* pDexFile,
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 @@ static void dumpClass(const DexFile* pDexFile, int idx, char** pLastPackage) {
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 @@ static void processDexFile(const char* fileName,
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 9f49ec6f60..ff05733345 100644
--- a/disassembler/disassembler_x86.cc
+++ b/disassembler/disassembler_x86.cc
@@ -859,6 +859,22 @@ DISASSEMBLER_ENTRY(cmp,
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/oatdump/oatdump.cc b/oatdump/oatdump.cc
index ce63e18921..9a3b28b16e 100644
--- a/oatdump/oatdump.cc
+++ b/oatdump/oatdump.cc
@@ -1473,7 +1473,7 @@ class OatDumper {
Runtime* const runtime = Runtime::Current();
Handle<mirror::DexCache> dex_cache(
hs->NewHandle(runtime->GetClassLinker()->RegisterDexFile(*dex_file, nullptr)));
- CHECK(dex_cache.Get() != nullptr);
+ CHECK(dex_cache != nullptr);
DCHECK(options_.class_loader_ != nullptr);
return verifier::MethodVerifier::VerifyMethodAndDump(
soa.Self(), vios, dex_method_idx, dex_file, dex_cache, *options_.class_loader_,
@@ -2950,7 +2950,7 @@ class IMTDumper {
const DexFile::ClassDef& class_def = dex_file->GetClassDef(class_def_index);
const char* descriptor = dex_file->GetClassDescriptor(class_def);
h_klass.Assign(class_linker->FindClass(self, descriptor, h_class_loader));
- if (h_klass.Get() == nullptr) {
+ if (h_klass == nullptr) {
std::cerr << "Warning: could not load " << descriptor << std::endl;
continue;
}
diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc
index 9a73830f99..b9be5f2605 100644
--- a/patchoat/patchoat.cc
+++ b/patchoat/patchoat.cc
@@ -688,6 +688,16 @@ void PatchOat::PatchDexFileArrays(mirror::ObjectArray<mirror::Object>* img_roots
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 7febb458e2..d3a81a9add 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -123,6 +123,7 @@ cc_defaults {
"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 @@ cc_defaults {
"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",
diff --git a/runtime/arch/stub_test.cc b/runtime/arch/stub_test.cc
index 0bf08a6d97..207bf9d365 100644
--- a/runtime/arch/stub_test.cc
+++ b/runtime/arch/stub_test.cc
@@ -984,7 +984,7 @@ TEST_F(StubTest, AllocObject) {
while (length > 10) {
Handle<mirror::Object> h(hsp->NewHandle<mirror::Object>(
mirror::ObjectArray<mirror::Object>::Alloc(soa.Self(), ca.Get(), length / 4)));
- if (self->IsExceptionPending() || h.Get() == nullptr) {
+ if (self->IsExceptionPending() || h == nullptr) {
self->ClearException();
// Try a smaller length
@@ -1003,7 +1003,7 @@ TEST_F(StubTest, AllocObject) {
// Allocate simple objects till it fails.
while (!self->IsExceptionPending()) {
Handle<mirror::Object> h = hsp->NewHandle(c->AllocObject(soa.Self()));
- if (!self->IsExceptionPending() && h.Get() != nullptr) {
+ if (!self->IsExceptionPending() && h != nullptr) {
handles.push_back(h);
}
}
diff --git a/runtime/art_method.cc b/runtime/art_method.cc
index 4902ad42d7..9d74e7c92b 100644
--- a/runtime/art_method.cc
+++ b/runtime/art_method.cc
@@ -274,7 +274,7 @@ uint32_t ArtMethod::FindCatchBlock(Handle<mirror::Class> exception_type,
*has_no_move_exception = (first_catch_instr->Opcode() != Instruction::MOVE_EXCEPTION);
}
// Put the exception back.
- if (exception.Get() != nullptr) {
+ if (exception != nullptr) {
self->SetException(exception.Get());
}
return found_dex_pc;
@@ -441,12 +441,56 @@ static uint32_t GetOatMethodIndexFromMethodIndex(const DexFile& dex_file,
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();
@@ -489,7 +533,7 @@ bool ArtMethod::EqualParameters(Handle<mirror::ObjectArray<mirror::Class>> param
const auto& proto_id = dex_file->GetMethodPrototype(method_id);
const DexFile::TypeList* proto_params = dex_file->GetProtoParameters(proto_id);
auto count = proto_params != nullptr ? proto_params->Size() : 0u;
- auto param_len = params.Get() != nullptr ? params->GetLength() : 0u;
+ auto param_len = params != nullptr ? params->GetLength() : 0u;
if (param_len != count) {
return false;
}
diff --git a/runtime/art_method.h b/runtime/art_method.h
index 383630363e..3d51fdde94 100644
--- a/runtime/art_method.h
+++ b/runtime/art_method.h
@@ -432,6 +432,7 @@ class ArtMethod FINAL {
}
ProfilingInfo* GetProfilingInfo(PointerSize pointer_size) {
+ DCHECK(!IsNative());
return reinterpret_cast<ProfilingInfo*>(GetDataPtrSize(pointer_size));
}
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 7db83688e2..d02cf17d44 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"
@@ -405,7 +407,7 @@ bool ClassLinker::InitWithoutImage(std::vector<std::unique_ptr<const DexFile>> b
auto class_class_size = mirror::Class::ClassClassSize(image_pointer_size_);
Handle<mirror::Class> java_lang_Class(hs.NewHandle(down_cast<mirror::Class*>(
heap->AllocNonMovableObject<true>(self, nullptr, class_class_size, VoidFunctor()))));
- CHECK(java_lang_Class.Get() != nullptr);
+ CHECK(java_lang_Class != nullptr);
mirror::Class::SetClassClass(java_lang_Class.Get());
java_lang_Class->SetClass(java_lang_Class.Get());
if (kUseBakerReadBarrier) {
@@ -425,7 +427,7 @@ bool ClassLinker::InitWithoutImage(std::vector<std::unique_ptr<const DexFile>> b
// java_lang_Object comes next so that object_array_class can be created.
Handle<mirror::Class> java_lang_Object(hs.NewHandle(
AllocClass(self, java_lang_Class.Get(), mirror::Object::ClassSize(image_pointer_size_))));
- CHECK(java_lang_Object.Get() != nullptr);
+ CHECK(java_lang_Object != nullptr);
// backfill Object as the super class of Class.
java_lang_Class->SetSuperClass(java_lang_Object.Get());
mirror::Class::SetStatus(java_lang_Object, mirror::Class::kStatusLoaded, self);
@@ -624,9 +626,9 @@ bool ClassLinker::InitWithoutImage(std::vector<std::unique_ptr<const DexFile>> b
// Setup the single, global copy of "iftable".
auto java_lang_Cloneable = hs.NewHandle(FindSystemClass(self, "Ljava/lang/Cloneable;"));
- CHECK(java_lang_Cloneable.Get() != nullptr);
+ CHECK(java_lang_Cloneable != nullptr);
auto java_io_Serializable = hs.NewHandle(FindSystemClass(self, "Ljava/io/Serializable;"));
- CHECK(java_io_Serializable.Get() != nullptr);
+ CHECK(java_io_Serializable != nullptr);
// We assume that Cloneable/Serializable don't have superinterfaces -- normally we'd have to
// crawl up and explicitly list all of the supers as well.
array_iftable_.Read()->SetInterface(0, java_lang_Cloneable.Get());
@@ -695,6 +697,18 @@ bool ClassLinker::InitWithoutImage(std::vector<std::unique_ptr<const DexFile>> b
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 @@ bool ClassLinker::InitFromBootImage(std::string* error_msg) {
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 @@ bool ClassLinker::UpdateAppImageClassLoadersAndDexCaches(
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 @@ bool ClassLinker::UpdateAppImageClassLoadersAndDexCaches(
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_);
@@ -1615,7 +1648,7 @@ bool ClassLinker::AddImageSpace(
DCHECK(out_dex_files != nullptr);
DCHECK(error_msg != nullptr);
const uint64_t start_time = NanoTime();
- const bool app_image = class_loader.Get() != nullptr;
+ const bool app_image = class_loader != nullptr;
const ImageHeader& header = space->GetImageHeader();
ObjPtr<mirror::Object> dex_caches_object = header.GetImageRoot(ImageHeader::kDexCaches);
DCHECK(dex_caches_object != nullptr);
@@ -1645,7 +1678,7 @@ bool ClassLinker::AddImageSpace(
"Class loader should be the last image root.");
MutableHandle<mirror::ClassLoader> image_class_loader(hs.NewHandle(
app_image ? header.GetImageRoot(ImageHeader::kClassLoader)->AsClassLoader() : nullptr));
- DCHECK(class_roots.Get() != nullptr);
+ DCHECK(class_roots != nullptr);
if (class_roots->GetLength() != static_cast<int32_t>(kClassRootsMax)) {
*error_msg = StringPrintf("Expected %d class roots but got %d",
class_roots->GetLength(),
@@ -2074,7 +2107,7 @@ void ClassLinker::VisitClassesWithoutClassesLock(ClassVisitor* visitor) {
ObjPtr<mirror::Class> array_of_class = FindArrayClass(self, &class_type);
classes.Assign(
mirror::ObjectArray<mirror::Class>::Alloc(self, array_of_class, class_table_size));
- CHECK(classes.Get() != nullptr); // OOME.
+ CHECK(classes != nullptr); // OOME.
GetClassInToObjectArray accumulator(classes.Get());
VisitClasses(&accumulator);
if (accumulator.Succeeded()) {
@@ -2115,6 +2148,8 @@ ClassLinker::~ClassLinker() {
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_) {
@@ -2152,7 +2187,7 @@ mirror::DexCache* ClassLinker::AllocDexCache(ObjPtr<mirror::String>* out_locatio
DCHECK(out_location != nullptr);
auto dex_cache(hs.NewHandle(ObjPtr<mirror::DexCache>::DownCast(
GetClassRoot(kJavaLangDexCache)->AllocObject(self))));
- if (dex_cache.Get() == nullptr) {
+ if (dex_cache == nullptr) {
self->AssertPendingOOMException();
return nullptr;
}
@@ -2453,7 +2488,7 @@ mirror::Class* ClassLinker::FindClass(Thread* self,
return EnsureResolved(self, descriptor, klass);
}
// Class is not yet loaded.
- if (descriptor[0] != '[' && class_loader.Get() == nullptr) {
+ if (descriptor[0] != '[' && class_loader == nullptr) {
// Non-array class and the boot class loader, search the boot class path.
ClassPathEntry pair = FindInClassPath(descriptor, hash, boot_class_path_);
if (pair.second != nullptr) {
@@ -2616,14 +2651,14 @@ mirror::Class* ClassLinker::DefineClass(Thread* self,
}
}
- if (klass.Get() == nullptr) {
+ if (klass == nullptr) {
// Allocate a class with the status of not ready.
// Interface object should get the right size here. Regular class will
// figure out the right size later and be replaced with one of the right
// size when the class becomes resolved.
klass.Assign(AllocClass(self, SizeOfClassWithoutEmbeddedTables(dex_file, dex_class_def)));
}
- if (UNLIKELY(klass.Get() == nullptr)) {
+ if (UNLIKELY(klass == nullptr)) {
self->AssertPendingOOMException();
return nullptr;
}
@@ -2716,7 +2751,7 @@ mirror::Class* ClassLinker::DefineClass(Thread* self,
return nullptr;
}
self->AssertNoPendingException();
- CHECK(h_new_class.Get() != nullptr) << descriptor;
+ CHECK(h_new_class != nullptr) << descriptor;
CHECK(h_new_class->IsResolved() && !h_new_class->IsErroneousResolved()) << descriptor;
// Instrumentation may have updated entrypoints for all methods of all
@@ -2997,7 +3032,7 @@ void ClassLinker::SetupClass(const DexFile& dex_file,
const DexFile::ClassDef& dex_class_def,
Handle<mirror::Class> klass,
ObjPtr<mirror::ClassLoader> class_loader) {
- CHECK(klass.Get() != nullptr);
+ CHECK(klass != nullptr);
CHECK(klass->GetDexCache() != nullptr);
CHECK_EQ(mirror::Class::kStatusNotReady, klass->GetStatus());
const char* descriptor = dex_file.GetClassDescriptor(dex_class_def);
@@ -3112,6 +3147,7 @@ void ClassLinker::LoadClassMembers(Thread* self,
last_field_idx = field_idx;
}
}
+
// Load instance fields.
LengthPrefixedArray<ArtField>* ifields = AllocArtFieldArray(self,
allocator,
@@ -3128,6 +3164,7 @@ void ClassLinker::LoadClassMembers(Thread* self,
last_field_idx = field_idx;
}
}
+
if (UNLIKELY(num_sfields != it.NumStaticFields()) ||
UNLIKELY(num_ifields != it.NumInstanceFields())) {
LOG(WARNING) << "Duplicate fields in class " << klass->PrettyDescriptor()
@@ -3367,7 +3404,7 @@ ObjPtr<mirror::DexCache> ClassLinker::RegisterDexFile(const DexFile& dex_file,
WriterMutexLock mu(self, *Locks::dex_lock_);
old_data = FindDexCacheDataLocked(dex_file);
old_dex_cache = DecodeDexCache(self, old_data);
- if (old_dex_cache == nullptr && h_dex_cache.Get() != nullptr) {
+ if (old_dex_cache == nullptr && h_dex_cache != nullptr) {
// Do InitializeDexCache while holding dex lock to make sure two threads don't call it at the
// same time with the same dex cache. Since the .bss is shared this can cause failing DCHECK
// that the arrays are null.
@@ -3383,12 +3420,12 @@ ObjPtr<mirror::DexCache> ClassLinker::RegisterDexFile(const DexFile& dex_file,
if (old_dex_cache != nullptr) {
// Another thread managed to initialize the dex cache faster, so use that DexCache.
// If this thread encountered OOME, ignore it.
- DCHECK_EQ(h_dex_cache.Get() == nullptr, self->IsExceptionPending());
+ DCHECK_EQ(h_dex_cache == nullptr, self->IsExceptionPending());
self->ClearException();
// We cannot call EnsureSameClassLoader() while holding the dex_lock_.
return EnsureSameClassLoader(self, old_dex_cache, old_data, h_class_loader.Get());
}
- if (h_dex_cache.Get() == nullptr) {
+ if (h_dex_cache == nullptr) {
self->AssertPendingOOMException();
return nullptr;
}
@@ -3517,12 +3554,12 @@ mirror::Class* ClassLinker::CreateArrayClass(Thread* self, const char* descripto
StackHandleScope<2> hs(self);
MutableHandle<mirror::Class> component_type(hs.NewHandle(FindClass(self, descriptor + 1,
class_loader)));
- if (component_type.Get() == nullptr) {
+ if (component_type == nullptr) {
DCHECK(self->IsExceptionPending());
// We need to accept erroneous classes as component types.
const size_t component_hash = ComputeModifiedUtf8Hash(descriptor + 1);
component_type.Assign(LookupClass(self, descriptor + 1, component_hash, class_loader.Get()));
- if (component_type.Get() == nullptr) {
+ if (component_type == nullptr) {
DCHECK(self->IsExceptionPending());
return nullptr;
} else {
@@ -3583,9 +3620,9 @@ mirror::Class* ClassLinker::CreateArrayClass(Thread* self, const char* descripto
new_class.Assign(GetClassRoot(kLongArrayClass));
}
}
- if (new_class.Get() == nullptr) {
+ if (new_class == nullptr) {
new_class.Assign(AllocClass(self, mirror::Array::ClassSize(image_pointer_size_)));
- if (new_class.Get() == nullptr) {
+ if (new_class == nullptr) {
self->AssertPendingOOMException();
return nullptr;
}
@@ -3818,8 +3855,8 @@ bool ClassLinker::AttemptSupertypeVerification(Thread* self,
Handle<mirror::Class> klass,
Handle<mirror::Class> supertype) {
DCHECK(self != nullptr);
- DCHECK(klass.Get() != nullptr);
- DCHECK(supertype.Get() != nullptr);
+ DCHECK(klass != nullptr);
+ DCHECK(supertype != nullptr);
if (!supertype->IsVerified() && !supertype->IsErroneous()) {
VerifyClass(self, supertype);
@@ -3836,13 +3873,13 @@ bool ClassLinker::AttemptSupertypeVerification(Thread* self,
LOG(WARNING) << error_msg << " in " << klass->GetDexCache()->GetLocation()->ToModifiedUtf8();
StackHandleScope<1> hs(self);
Handle<mirror::Throwable> cause(hs.NewHandle(self->GetException()));
- if (cause.Get() != nullptr) {
+ if (cause != nullptr) {
// Set during VerifyClass call (if at all).
self->ClearException();
}
// Change into a verify error.
ThrowVerifyError(klass.Get(), "%s", error_msg.c_str());
- if (cause.Get() != nullptr) {
+ if (cause != nullptr) {
self->GetException()->SetCause(cause.Get());
}
ClassReference ref(klass->GetDexCache()->GetDexFile(), klass->GetDexClassDefIndex());
@@ -3921,7 +3958,7 @@ verifier::MethodVerifier::FailureKind ClassLinker::VerifyClass(
StackHandleScope<2> hs(self);
MutableHandle<mirror::Class> supertype(hs.NewHandle(klass->GetSuperClass()));
// If we have a superclass and we get a hard verification failure we can return immediately.
- if (supertype.Get() != nullptr && !AttemptSupertypeVerification(self, klass, supertype)) {
+ if (supertype != nullptr && !AttemptSupertypeVerification(self, klass, supertype)) {
CHECK(self->IsExceptionPending()) << "Verification error should be pending.";
return verifier::MethodVerifier::kHardFailure;
}
@@ -3936,14 +3973,14 @@ verifier::MethodVerifier::FailureKind ClassLinker::VerifyClass(
// but choose not to for an optimization. If the interfaces is being verified due to a class
// initialization (which would need all the default interfaces to be verified) the class code
// will trigger the recursive verification anyway.
- if ((supertype.Get() == nullptr || supertype->IsVerified()) // See (1)
+ if ((supertype == nullptr || supertype->IsVerified()) // See (1)
&& !klass->IsInterface()) { // See (2)
int32_t iftable_count = klass->GetIfTableCount();
MutableHandle<mirror::Class> iface(hs.NewHandle<mirror::Class>(nullptr));
// Loop through all interfaces this class has defined. It doesn't matter the order.
for (int32_t i = 0; i < iftable_count; i++) {
iface.Assign(klass->GetIfTable()->GetInterface(i));
- DCHECK(iface.Get() != nullptr);
+ DCHECK(iface != nullptr);
// We only care if we have default interfaces and can skip if we are already verified...
if (LIKELY(!iface->HasDefaultMethods() || iface->IsVerified())) {
continue;
@@ -3963,7 +4000,7 @@ verifier::MethodVerifier::FailureKind ClassLinker::VerifyClass(
// At this point if verification failed, then supertype is the "first" supertype that failed
// verification (without a specific order). If verification succeeded, then supertype is either
// null or the original superclass of klass and is verified.
- DCHECK(supertype.Get() == nullptr ||
+ DCHECK(supertype == nullptr ||
supertype.Get() == klass->GetSuperClass() ||
!supertype->IsVerified());
@@ -4004,7 +4041,7 @@ verifier::MethodVerifier::FailureKind ClassLinker::VerifyClass(
if (verifier_failure == verifier::MethodVerifier::kNoFailure) {
// Even though there were no verifier failures we need to respect whether the super-class and
// super-default-interfaces were verified or requiring runtime reverification.
- if (supertype.Get() == nullptr || supertype->IsVerified()) {
+ if (supertype == nullptr || supertype->IsVerified()) {
mirror::Class::SetStatus(klass, mirror::Class::kStatusVerified, self);
} else {
CHECK_EQ(supertype->GetStatus(), mirror::Class::kStatusRetryVerificationAtRuntime);
@@ -4187,7 +4224,7 @@ mirror::Class* ClassLinker::CreateProxyClass(ScopedObjectAccessAlreadyRunnable&
StackHandleScope<10> hs(self);
MutableHandle<mirror::Class> klass(hs.NewHandle(
AllocClass(self, GetClassRoot(kJavaLangClass), sizeof(mirror::Class))));
- if (klass.Get() == nullptr) {
+ if (klass == nullptr) {
CHECK(self->IsExceptionPending()); // OOME.
return nullptr;
}
@@ -4611,7 +4648,7 @@ bool ClassLinker::InitializeClass(Thread* self, Handle<mirror::Class> klass,
MutableHandle<mirror::Class> handle_scope_iface(hs_iface.NewHandle<mirror::Class>(nullptr));
for (size_t i = 0; i < num_direct_interfaces; i++) {
handle_scope_iface.Assign(mirror::Class::GetDirectInterface(self, klass.Get(), i));
- CHECK(handle_scope_iface.Get() != nullptr);
+ CHECK(handle_scope_iface != nullptr);
CHECK(handle_scope_iface->IsInterface());
if (handle_scope_iface->HasBeenRecursivelyInitialized()) {
// We have already done this for this interface. Skip it.
@@ -4890,7 +4927,7 @@ static bool HasSameSignatureWithDifferentClassLoaders(Thread* self,
{
StackHandleScope<1> hs(self);
Handle<mirror::Class> return_type(hs.NewHandle(method1->GetReturnType(true /* resolve */)));
- if (UNLIKELY(return_type.Get() == nullptr)) {
+ if (UNLIKELY(return_type == nullptr)) {
ThrowSignatureCheckResolveReturnTypeException(klass, super_klass, method1, method1);
return false;
}
@@ -4940,7 +4977,7 @@ static bool HasSameSignatureWithDifferentClassLoaders(Thread* self,
dex::TypeIndex param_type_idx = types1->GetTypeItem(i).type_idx_;
Handle<mirror::Class> param_type(hs.NewHandle(
method1->GetClassFromTypeIndex(param_type_idx, true /* resolve */)));
- if (UNLIKELY(param_type.Get() == nullptr)) {
+ if (UNLIKELY(param_type == nullptr)) {
ThrowSignatureCheckResolveArgException(klass, super_klass, method1,
method1, i, param_type_idx);
return false;
@@ -5022,7 +5059,7 @@ bool ClassLinker::EnsureInitialized(Thread* self,
Handle<mirror::Class> c,
bool can_init_fields,
bool can_init_parents) {
- DCHECK(c.Get() != nullptr);
+ DCHECK(c != nullptr);
if (c->IsInitialized()) {
EnsureSkipAccessChecksMethods(c, image_pointer_size_);
self->AssertNoPendingException();
@@ -5202,7 +5239,7 @@ bool ClassLinker::LinkClass(Thread* self,
klass->SetMethodsPtrUnchecked(nullptr, 0, 0);
klass->SetSFieldsPtrUnchecked(nullptr);
klass->SetIFieldsPtrUnchecked(nullptr);
- if (UNLIKELY(h_new_class.Get() == nullptr)) {
+ if (UNLIKELY(h_new_class == nullptr)) {
self->AssertPendingOOMException();
mirror::Class::SetStatus(klass, mirror::Class::kStatusErrorUnresolved, self);
return false;
@@ -5746,7 +5783,7 @@ bool ClassLinker::LinkVirtualMethods(
MutableHandle<mirror::PointerArray> vtable;
if (super_class->ShouldHaveEmbeddedVTable()) {
vtable = hs.NewHandle(AllocPointerArray(self, max_count));
- if (UNLIKELY(vtable.Get() == nullptr)) {
+ if (UNLIKELY(vtable == nullptr)) {
self->AssertPendingOOMException();
return false;
}
@@ -5775,7 +5812,7 @@ bool ClassLinker::LinkVirtualMethods(
}
vtable = hs.NewHandle(down_cast<mirror::PointerArray*>(
super_vtable->CopyOf(self, max_count)));
- if (UNLIKELY(vtable.Get() == nullptr)) {
+ if (UNLIKELY(vtable == nullptr)) {
self->AssertPendingOOMException();
return false;
}
@@ -5911,7 +5948,7 @@ bool ClassLinker::LinkVirtualMethods(
CHECK_LE(actual_count, max_count);
if (actual_count < max_count) {
vtable.Assign(down_cast<mirror::PointerArray*>(vtable->CopyOf(self, actual_count)));
- if (UNLIKELY(vtable.Get() == nullptr)) {
+ if (UNLIKELY(vtable == nullptr)) {
self->AssertPendingOOMException();
return false;
}
@@ -5964,8 +6001,8 @@ static bool ContainsOverridingMethodOf(Thread* self,
PointerSize image_pointer_size)
REQUIRES_SHARED(Locks::mutator_lock_) {
DCHECK(self != nullptr);
- DCHECK(iface.Get() != nullptr);
- DCHECK(iftable.Get() != nullptr);
+ DCHECK(iface != nullptr);
+ DCHECK(iftable != nullptr);
DCHECK_GE(ifstart, 0u);
DCHECK_LT(ifstart, iftable->Count());
DCHECK_EQ(iface.Get(), iftable->GetInterface(ifstart));
@@ -6050,7 +6087,7 @@ ClassLinker::DefaultMethodSearchResult ClassLinker::FindDefaultMethodImplementat
<< "This will be a fatal error in subsequent versions of android. "
<< "Continuing anyway.";
}
- if (UNLIKELY(chosen_iface.Get() != nullptr)) {
+ if (UNLIKELY(chosen_iface != nullptr)) {
// We have multiple default impls of the same method. This is a potential default conflict.
// We need to check if this possibly conflicting method is either a superclass of the chosen
// default implementation or is overridden by a non-default interface method. In either case
@@ -6505,7 +6542,7 @@ bool ClassLinker::SetupInterfaceLookupTable(Thread* self, Handle<mirror::Class>
StackHandleScope<1> hs(self);
const bool has_superclass = klass->HasSuperClass();
const size_t super_ifcount = has_superclass ? klass->GetSuperClass()->GetIfTableCount() : 0U;
- const bool have_interfaces = interfaces.Get() != nullptr;
+ const bool have_interfaces = interfaces != nullptr;
const size_t num_interfaces =
have_interfaces ? interfaces->GetLength() : klass->NumDirectInterfaces();
if (num_interfaces == 0) {
@@ -6551,7 +6588,7 @@ bool ClassLinker::SetupInterfaceLookupTable(Thread* self, Handle<mirror::Class>
}
// Create the interface function table.
MutableHandle<mirror::IfTable> iftable(hs.NewHandle(AllocIfTable(self, ifcount)));
- if (UNLIKELY(iftable.Get() == nullptr)) {
+ if (UNLIKELY(iftable == nullptr)) {
self->AssertPendingOOMException();
return false;
}
@@ -6589,7 +6626,7 @@ bool ClassLinker::SetupInterfaceLookupTable(Thread* self, Handle<mirror::Class>
DCHECK_NE(num_interfaces, 0U);
iftable.Assign(down_cast<mirror::IfTable*>(
iftable->CopyOf(self, new_ifcount * mirror::IfTable::kMax)));
- if (UNLIKELY(iftable.Get() == nullptr)) {
+ if (UNLIKELY(iftable == nullptr)) {
self->AssertPendingOOMException();
return false;
}
@@ -6630,7 +6667,7 @@ static void CheckClassOwnsVTableEntries(Thread* self,
Handle<mirror::PointerArray> check_vtable(hs.NewHandle(klass->GetVTableDuringLinking()));
ObjPtr<mirror::Class> super_temp = (klass->HasSuperClass()) ? klass->GetSuperClass() : nullptr;
Handle<mirror::Class> superclass(hs.NewHandle(super_temp));
- int32_t super_vtable_length = (superclass.Get() != nullptr) ? superclass->GetVTableLength() : 0;
+ int32_t super_vtable_length = (superclass != nullptr) ? superclass->GetVTableLength() : 0;
for (int32_t i = 0; i < check_vtable->GetLength(); ++i) {
ArtMethod* m = check_vtable->GetElementPtrSize<ArtMethod*>(i, pointer_size);
CHECK(m != nullptr);
@@ -7289,7 +7326,7 @@ bool ClassLinker::LinkInterfaceMethods(
// For a new interface, however, we need the whole vtable in case a new
// interface method is implemented in the whole superclass.
using_virtuals = false;
- DCHECK(vtable.Get() != nullptr);
+ DCHECK(vtable != nullptr);
input_vtable_array = vtable;
input_array_length = input_vtable_array->GetLength();
}
@@ -7432,7 +7469,7 @@ bool ClassLinker::LinkInterfaceMethods(
if (fill_tables) {
vtable.Assign(helper.UpdateVtable(default_translations, vtable.Get()));
- if (UNLIKELY(vtable.Get() == nullptr)) {
+ if (UNLIKELY(vtable == nullptr)) {
// The helper has already called self->AssertPendingOOMException();
return false;
}
@@ -7452,12 +7489,12 @@ bool ClassLinker::LinkInterfaceMethods(
}
bool ClassLinker::LinkInstanceFields(Thread* self, Handle<mirror::Class> klass) {
- CHECK(klass.Get() != nullptr);
+ CHECK(klass != nullptr);
return LinkFields(self, klass, false, nullptr);
}
bool ClassLinker::LinkStaticFields(Thread* self, Handle<mirror::Class> klass, size_t* class_size) {
- CHECK(klass.Get() != nullptr);
+ CHECK(klass != nullptr);
return LinkFields(self, klass, true, class_size);
}
@@ -7713,7 +7750,7 @@ void ClassLinker::CreateReferenceInstanceOffsets(Handle<mirror::Class> klass) {
mirror::String* ClassLinker::ResolveString(const DexFile& dex_file,
dex::StringIndex string_idx,
Handle<mirror::DexCache> dex_cache) {
- DCHECK(dex_cache.Get() != nullptr);
+ DCHECK(dex_cache != nullptr);
Thread::PoisonObjectPointersIfDebug();
ObjPtr<mirror::String> resolved = dex_cache->GetResolvedString(string_idx);
if (resolved != nullptr) {
@@ -7729,7 +7766,7 @@ mirror::String* ClassLinker::ResolveString(const DexFile& dex_file,
mirror::String* ClassLinker::LookupString(const DexFile& dex_file,
dex::StringIndex string_idx,
Handle<mirror::DexCache> dex_cache) {
- DCHECK(dex_cache.Get() != nullptr);
+ DCHECK(dex_cache != nullptr);
ObjPtr<mirror::String> resolved = dex_cache->GetResolvedString(string_idx);
if (resolved != nullptr) {
return resolved.Ptr();
@@ -7783,7 +7820,7 @@ mirror::Class* ClassLinker::ResolveType(const DexFile& dex_file,
dex::TypeIndex type_idx,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader) {
- DCHECK(dex_cache.Get() != nullptr);
+ DCHECK(dex_cache != nullptr);
Thread::PoisonObjectPointersIfDebug();
ObjPtr<mirror::Class> resolved = dex_cache->GetResolvedType(type_idx);
if (resolved == nullptr) {
@@ -7821,7 +7858,7 @@ ArtMethod* ClassLinker::ResolveMethod(const DexFile& dex_file,
Handle<mirror::ClassLoader> class_loader,
ArtMethod* referrer,
InvokeType type) {
- DCHECK(dex_cache.Get() != nullptr);
+ DCHECK(dex_cache != nullptr);
// Check for hit in the dex cache.
ArtMethod* resolved = dex_cache->GetResolvedMethod(method_idx, image_pointer_size_);
Thread::PoisonObjectPointersIfDebug();
@@ -8060,7 +8097,7 @@ ArtField* ClassLinker::ResolveField(const DexFile& dex_file,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader,
bool is_static) {
- DCHECK(dex_cache.Get() != nullptr);
+ DCHECK(dex_cache != nullptr);
ArtField* resolved = dex_cache->GetResolvedField(field_idx, image_pointer_size_);
Thread::PoisonObjectPointersIfDebug();
if (resolved != nullptr) {
@@ -8101,7 +8138,7 @@ ArtField* ClassLinker::ResolveFieldJLS(const DexFile& dex_file,
uint32_t field_idx,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader) {
- DCHECK(dex_cache.Get() != nullptr);
+ DCHECK(dex_cache != nullptr);
ArtField* resolved = dex_cache->GetResolvedField(field_idx, image_pointer_size_);
Thread::PoisonObjectPointersIfDebug();
if (resolved != nullptr) {
@@ -8132,7 +8169,7 @@ mirror::MethodType* ClassLinker::ResolveMethodType(const DexFile& dex_file,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader) {
DCHECK(Runtime::Current()->IsMethodHandlesEnabled());
- DCHECK(dex_cache.Get() != nullptr);
+ DCHECK(dex_cache != nullptr);
ObjPtr<mirror::MethodType> resolved = dex_cache->GetResolvedMethodType(proto_idx);
if (resolved != nullptr) {
@@ -8146,7 +8183,7 @@ mirror::MethodType* ClassLinker::ResolveMethodType(const DexFile& dex_file,
const DexFile::ProtoId& proto_id = dex_file.GetProtoId(proto_idx);
Handle<mirror::Class> return_type(hs.NewHandle(
ResolveType(dex_file, proto_id.return_type_idx_, dex_cache, class_loader)));
- if (return_type.Get() == nullptr) {
+ if (return_type == nullptr) {
DCHECK(self->IsExceptionPending());
return nullptr;
}
@@ -8161,7 +8198,7 @@ mirror::MethodType* ClassLinker::ResolveMethodType(const DexFile& dex_file,
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_method_args)));
- if (method_params.Get() == nullptr) {
+ if (method_params == nullptr) {
DCHECK(self->IsExceptionPending());
return nullptr;
}
@@ -8172,7 +8209,7 @@ mirror::MethodType* ClassLinker::ResolveMethodType(const DexFile& dex_file,
for (; it.HasNext(); it.Next()) {
const dex::TypeIndex type_idx = it.GetTypeIdx();
param_class.Assign(ResolveType(dex_file, type_idx, dex_cache, class_loader));
- if (param_class.Get() == nullptr) {
+ if (param_class == nullptr) {
DCHECK(self->IsExceptionPending());
return nullptr;
}
@@ -8189,6 +8226,148 @@ mirror::MethodType* ClassLinker::ResolveMethodType(const DexFile& dex_file,
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 @@ const char* ClassLinker::GetClassRootDescriptor(ClassRoot class_root) {
"[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;",
@@ -8352,7 +8533,7 @@ jobject ClassLinker::CreatePathClassLoader(Thread* self,
jni::DecodeArtField(WellKnownClasses::dalvik_system_DexPathList_dexElements);
Handle<mirror::Class> dex_elements_class(hs.NewHandle(dex_elements_field->GetType<true>()));
- DCHECK(dex_elements_class.Get() != nullptr);
+ DCHECK(dex_elements_class != nullptr);
DCHECK(dex_elements_class->IsArrayClass());
Handle<mirror::ObjectArray<mirror::Object>> h_dex_elements(hs.NewHandle(
mirror::ObjectArray<mirror::Object>::Alloc(self,
@@ -8381,21 +8562,21 @@ jobject ClassLinker::CreatePathClassLoader(Thread* self,
Handle<mirror::LongArray> h_long_array = hs2.NewHandle(mirror::LongArray::Alloc(
self,
kDexFileIndexStart + 1));
- DCHECK(h_long_array.Get() != nullptr);
+ DCHECK(h_long_array != nullptr);
h_long_array->Set(kDexFileIndexStart, reinterpret_cast<intptr_t>(dex_file));
Handle<mirror::Object> h_dex_file = hs2.NewHandle(
cookie_field->GetDeclaringClass()->AllocObject(self));
- DCHECK(h_dex_file.Get() != nullptr);
+ DCHECK(h_dex_file != nullptr);
cookie_field->SetObject<false>(h_dex_file.Get(), h_long_array.Get());
Handle<mirror::String> h_file_name = hs2.NewHandle(
mirror::String::AllocFromModifiedUtf8(self, dex_file->GetLocation().c_str()));
- DCHECK(h_file_name.Get() != nullptr);
+ DCHECK(h_file_name != nullptr);
file_name_field->SetObject<false>(h_dex_file.Get(), h_file_name.Get());
Handle<mirror::Object> h_element = hs2.NewHandle(h_dex_element_class->AllocObject(self));
- DCHECK(h_element.Get() != nullptr);
+ DCHECK(h_element != nullptr);
element_file_field->SetObject<false>(h_element.Get(), h_dex_file.Get());
h_dex_elements->Set(index, h_element.Get());
@@ -8406,7 +8587,7 @@ jobject ClassLinker::CreatePathClassLoader(Thread* self,
// Create DexPathList.
Handle<mirror::Object> h_dex_path_list = hs.NewHandle(
dex_elements_field->GetDeclaringClass()->AllocObject(self));
- DCHECK(h_dex_path_list.Get() != nullptr);
+ DCHECK(h_dex_path_list != nullptr);
// Set elements.
dex_elements_field->SetObject<false>(h_dex_path_list.Get(), h_dex_elements.Get());
@@ -8415,7 +8596,7 @@ jobject ClassLinker::CreatePathClassLoader(Thread* self,
soa.Decode<mirror::Class>(WellKnownClasses::dalvik_system_PathClassLoader));
Handle<mirror::Object> h_path_class_loader = hs.NewHandle(
h_path_class_class->AllocObject(self));
- DCHECK(h_path_class_loader.Get() != nullptr);
+ DCHECK(h_path_class_loader != nullptr);
// Set DexPathList.
ArtField* path_list_field =
jni::DecodeArtField(WellKnownClasses::dalvik_system_BaseDexClassLoader_pathList);
diff --git a/runtime/class_linker.h b/runtime/class_linker.h
index 62d3c29a19..e27a53d15c 100644
--- a/runtime/class_linker.h
+++ b/runtime/class_linker.h
@@ -55,6 +55,8 @@ namespace mirror {
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 @@ class ClassLinker {
kJavaLangReflectConstructorArrayClass,
kJavaLangReflectFieldArrayClass,
kJavaLangReflectMethodArrayClass,
+ kJavaLangInvokeCallSite,
kJavaLangInvokeMethodHandleImpl,
+ kJavaLangInvokeMethodHandlesLookup,
kJavaLangInvokeMethodType,
kJavaLangClassLoader,
kJavaLangThrowable,
@@ -366,6 +370,12 @@ class ClassLinker {
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 03105cb6fb..07f3744b69 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"
@@ -185,7 +187,7 @@ class ClassLinkerTest : public CommonRuntimeTest {
void AssertArrayClass(const std::string& array_descriptor, Handle<mirror::Class> array)
REQUIRES_SHARED(Locks::mutator_lock_) {
- ASSERT_TRUE(array.Get() != nullptr);
+ ASSERT_TRUE(array != nullptr);
ASSERT_TRUE(array->GetClass() != nullptr);
ASSERT_EQ(array->GetClass(), array->GetClass()->GetClass());
EXPECT_TRUE(array->GetClass()->GetSuperClass() != nullptr);
@@ -409,7 +411,7 @@ class ClassLinkerTest : public CommonRuntimeTest {
StackHandleScope<1> hs(self);
Handle<mirror::Class> klass(
hs.NewHandle(class_linker_->FindSystemClass(self, descriptor.c_str())));
- ASSERT_TRUE(klass.Get() != nullptr);
+ ASSERT_TRUE(klass != nullptr);
std::string temp;
EXPECT_STREQ(descriptor.c_str(), klass.Get()->GetDescriptor(&temp));
EXPECT_EQ(class_loader, klass->GetClassLoader());
@@ -669,11 +671,13 @@ struct DexCacheOffsets : public CheckOffsets<mirror::DexCache> {
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 MethodHandleImplOffsets : public CheckOffsets<mirror::MethodHandleImpl> {
}
};
+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 EmulatedStackFrameOffsets : public CheckOffsets<mirror::EmulatedStackFram
}
};
+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 @@ TEST_F(ClassLinkerTest, ValidateFieldOrderOfJavaCppUnionClasses) {
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) {
@@ -1411,13 +1432,13 @@ TEST_F(ClassLinkerTest, IsBootStrapClassLoaded) {
// java.lang.Object is a bootstrap class.
Handle<mirror::Class> jlo_class(
hs.NewHandle(class_linker_->FindSystemClass(soa.Self(), "Ljava/lang/Object;")));
- ASSERT_TRUE(jlo_class.Get() != nullptr);
+ ASSERT_TRUE(jlo_class != nullptr);
EXPECT_TRUE(jlo_class.Get()->IsBootStrapClassLoaded());
// Statics is not a bootstrap class.
Handle<mirror::Class> statics(
hs.NewHandle(class_linker_->FindClass(soa.Self(), "LStatics;", class_loader)));
- ASSERT_TRUE(statics.Get() != nullptr);
+ ASSERT_TRUE(statics != nullptr);
EXPECT_FALSE(statics.Get()->IsBootStrapClassLoaded());
}
@@ -1431,11 +1452,11 @@ TEST_F(ClassLinkerTest, RegisterDexFileName) {
ReaderMutexLock mu(soa.Self(), *Locks::dex_lock_);
for (const ClassLinker::DexCacheData& data : class_linker->GetDexCachesData()) {
dex_cache.Assign(soa.Self()->DecodeJObject(data.weak_root)->AsDexCache());
- if (dex_cache.Get() != nullptr) {
+ if (dex_cache != nullptr) {
break;
}
}
- ASSERT_TRUE(dex_cache.Get() != nullptr);
+ ASSERT_TRUE(dex_cache != nullptr);
}
// Make a copy of the dex cache and change the name.
dex_cache.Assign(dex_cache->Clone(soa.Self())->AsDexCache());
@@ -1487,7 +1508,7 @@ TEST_F(ClassLinkerMethodHandlesTest, TestResolveMethodTypes) {
class_linker_->ResolveMethodType(dex_file, method1_id.proto_idx_, dex_cache, class_loader));
// Assert that the method type was resolved successfully.
- ASSERT_TRUE(method1_type.Get() != nullptr);
+ ASSERT_TRUE(method1_type != nullptr);
// Assert that the return type and the method arguments are as we expect.
Handle<mirror::Class> string_class(
diff --git a/runtime/class_table_test.cc b/runtime/class_table_test.cc
index f1248eb00c..18c2b827fe 100644
--- a/runtime/class_table_test.cc
+++ b/runtime/class_table_test.cc
@@ -80,7 +80,7 @@ TEST_F(ClassTableTest, ClassTable) {
Handle<mirror::Class> h_Y(
hs.NewHandle(class_linker_->FindClass(soa.Self(), descriptor_y, class_loader)));
Handle<mirror::Object> obj_X = hs.NewHandle(h_X->AllocObject(soa.Self()));
- ASSERT_TRUE(obj_X.Get() != nullptr);
+ ASSERT_TRUE(obj_X != nullptr);
ClassTable table;
EXPECT_EQ(table.NumZygoteClasses(class_loader.Get()), 0u);
EXPECT_EQ(table.NumNonZygoteClasses(class_loader.Get()), 0u);
diff --git a/runtime/common_runtime_test.h b/runtime/common_runtime_test.h
index 26ec364285..17e3729a20 100644
--- a/runtime/common_runtime_test.h
+++ b/runtime/common_runtime_test.h
@@ -223,6 +223,12 @@ class CheckJniAbortCatcher {
return; \
}
+#define TEST_DISABLED_FOR_READ_BARRIER_ON_X86() \
+ if (kUseReadBarrier && kRuntimeISA == kX86) { \
+ printf("WARNING: TEST DISABLED FOR READ BARRIER ON X86\n"); \
+ return; \
+ }
+
#define TEST_DISABLED_FOR_STRING_COMPRESSION() \
if (mirror::kUseStringCompression) { \
printf("WARNING: TEST DISABLED FOR STRING COMPRESSION\n"); \
diff --git a/runtime/common_throws.cc b/runtime/common_throws.cc
index a44f79e193..4f4bed0169 100644
--- a/runtime/common_throws.cc
+++ b/runtime/common_throws.cc
@@ -126,6 +126,22 @@ void ThrowArrayStoreException(ObjPtr<mirror::Class> element_class,
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 76ea2ae6c8..55a89388ea 100644
--- a/runtime/common_throws.h
+++ b/runtime/common_throws.h
@@ -56,6 +56,14 @@ void ThrowArrayStoreException(ObjPtr<mirror::Class> element_class,
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 @@ void ThrowVerifyError(ObjPtr<mirror::Class> referrer, const char* fmt, ...)
__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/debugger.cc b/runtime/debugger.cc
index 1a0cec075c..cfdc6e1afb 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -1765,13 +1765,13 @@ static JDWP::JdwpError GetFieldValueImpl(JDWP::RefTypeId ref_type_id, JDWP::Obje
StackHandleScope<2> hs(self);
MutableHandle<mirror::Object>
o(hs.NewHandle(Dbg::GetObjectRegistry()->Get<mirror::Object*>(object_id, &error)));
- if ((!is_static && o.Get() == nullptr) || error != JDWP::ERR_NONE) {
+ if ((!is_static && o == nullptr) || error != JDWP::ERR_NONE) {
return JDWP::ERR_INVALID_OBJECT;
}
ArtField* f = FromFieldId(field_id);
mirror::Class* receiver_class = c;
- if (receiver_class == nullptr && o.Get() != nullptr) {
+ if (receiver_class == nullptr && o != nullptr) {
receiver_class = o->GetClass();
}
@@ -1899,7 +1899,7 @@ static JDWP::JdwpError SetFieldValueImpl(JDWP::ObjectId object_id, JDWP::FieldId
StackHandleScope<2> hs(self);
MutableHandle<mirror::Object>
o(hs.NewHandle(Dbg::GetObjectRegistry()->Get<mirror::Object*>(object_id, &error)));
- if ((!is_static && o.Get() == nullptr) || error != JDWP::ERR_NONE) {
+ if ((!is_static && o == nullptr) || error != JDWP::ERR_NONE) {
return JDWP::ERR_INVALID_OBJECT;
}
ArtField* f = FromFieldId(field_id);
@@ -2867,7 +2867,7 @@ void Dbg::PostLocationEvent(ArtMethod* m, int dex_pc, mirror::Object* this_objec
StackHandleScope<1> hs(self);
Handle<mirror::Throwable> pending_exception(hs.NewHandle(self->GetException()));
self->ClearException();
- if (kIsDebugBuild && pending_exception.Get() != nullptr) {
+ if (kIsDebugBuild && pending_exception != nullptr) {
const DexFile::CodeItem* code_item = location.method->GetCodeItem();
const Instruction* instr = Instruction::At(&code_item->insns_[location.dex_pc]);
CHECK_EQ(Instruction::MOVE_EXCEPTION, instr->Opcode());
@@ -2875,7 +2875,7 @@ void Dbg::PostLocationEvent(ArtMethod* m, int dex_pc, mirror::Object* this_objec
gJdwpState->PostLocationEvent(&location, this_object, event_flags, return_value);
- if (pending_exception.Get() != nullptr) {
+ if (pending_exception != nullptr) {
self->SetException(pending_exception.Get());
}
}
@@ -4027,7 +4027,7 @@ void Dbg::ExecuteMethod(DebugInvokeReq* pReq) {
ExecuteMethodWithoutPendingException(soa, pReq);
// If an exception was pending before the invoke, restore it now.
- if (old_exception.Get() != nullptr) {
+ if (old_exception != nullptr) {
soa.Self()->SetException(old_exception.Get());
}
}
@@ -4356,9 +4356,9 @@ void Dbg::DdmSendThreadNotification(Thread* t, uint32_t type) {
ScopedObjectAccessUnchecked soa(Thread::Current());
StackHandleScope<1> hs(soa.Self());
Handle<mirror::String> name(hs.NewHandle(t->GetThreadName()));
- size_t char_count = (name.Get() != nullptr) ? name->GetLength() : 0;
- const jchar* chars = (name.Get() != nullptr) ? name->GetValue() : nullptr;
- bool is_compressed = (name.Get() != nullptr) ? name->IsCompressed() : false;
+ size_t char_count = (name != nullptr) ? name->GetLength() : 0;
+ const jchar* chars = (name != nullptr) ? name->GetValue() : nullptr;
+ bool is_compressed = (name != nullptr) ? name->IsCompressed() : false;
std::vector<uint8_t> bytes;
JDWP::Append4BE(bytes, t->GetThreadId());
diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc
index 9ad4063ce1..b6a2e09719 100644
--- a/runtime/dex_file.cc
+++ b/runtime/dex_file.cc
@@ -331,7 +331,32 @@ std::unique_ptr<const DexFile> DexFile::OpenOneDexFileFromZip(const ZipArchive&
*error_code = ZipOpenErrorCode::kDexFileError;
return nullptr;
}
- std::unique_ptr<MemMap> map(zip_entry->ExtractToMemMap(location.c_str(), entry_name, error_msg));
+
+ std::unique_ptr<MemMap> map;
+ if (zip_entry->IsUncompressed()) {
+ if (!zip_entry->IsAlignedTo(alignof(Header))) {
+ // Do not mmap unaligned ZIP entries because
+ // doing so would fail dex verification which requires 4 byte alignment.
+ LOG(WARNING) << "Can't mmap dex file " << location << "!" << entry_name << " directly; "
+ << "please zipalign to " << alignof(Header) << " bytes. "
+ << "Falling back to extracting file.";
+ } else {
+ // Map uncompressed files within zip as file-backed to avoid a dirty copy.
+ map.reset(zip_entry->MapDirectlyFromFile(location.c_str(), /*out*/error_msg));
+ if (map == nullptr) {
+ LOG(WARNING) << "Can't mmap dex file " << location << "!" << entry_name << " directly; "
+ << "is your ZIP file corrupted? Falling back to extraction.";
+ // Try again with Extraction which still has a chance of recovery.
+ }
+ }
+ }
+
+ if (map == nullptr) {
+ // Default path for compressed ZIP entries,
+ // and fallback for stored ZIP entries.
+ map.reset(zip_entry->ExtractToMemMap(location.c_str(), entry_name, error_msg));
+ }
+
if (map == nullptr) {
*error_msg = StringPrintf("Failed to extract '%s' from '%s': %s", entry_name, location.c_str(),
error_msg->c_str());
@@ -413,7 +438,7 @@ bool DexFile::OpenAllDexFilesFromZip(const ZipArchive& zip_archive,
&error_code));
if (next_dex_file.get() == nullptr) {
if (error_code != ZipOpenErrorCode::kEntryNotFound) {
- LOG(WARNING) << error_msg;
+ LOG(WARNING) << "Zip open failed: " << *error_msg;
}
break;
} else {
@@ -502,6 +527,11 @@ DexFile::DexFile(const uint8_t* base,
oat_dex_file_(oat_dex_file) {
CHECK(begin_ != nullptr) << GetLocation();
CHECK_GT(size_, 0U) << GetLocation();
+ // Check base (=header) alignment.
+ // Must be 4-byte aligned to avoid undefined behavior when accessing
+ // any of the sections via a pointer.
+ CHECK_ALIGNED(begin_, alignof(Header));
+
InitializeSectionsFromMapList();
}
diff --git a/runtime/dex_file.h b/runtime/dex_file.h
index 2101782d62..58b8e792ee 100644
--- a/runtime/dex_file.h
+++ b/runtime/dex_file.h
@@ -264,11 +264,11 @@ class DexFile {
// MethodHandle Types
enum class MethodHandleType : uint16_t { // private
- kPutStatic = 0x0000, // a setter for a given static field.
- kGetStatic = 0x0001, // a getter for a given static field.
- kPutInstance = 0x0002, // a setter for a given instance field.
- kGetInstance = 0x0003, // a getter for a given instance field.
- kInvokeStatic = 0x0004, // an invoker for a given static method
+ 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>”.
@@ -279,9 +279,9 @@ class DexFile {
// raw method_handle_item
struct MethodHandleItem {
uint16_t method_handle_type_;
- uint16_t reserved1_; // Reserved for future use.
- uint16_t field_or_method_idx_;
- uint16_t reserved2_; // Reserved for future use.
+ 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);
};
@@ -729,6 +729,20 @@ class DexFile {
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) {
diff --git a/runtime/dex_file_annotations.cc b/runtime/dex_file_annotations.cc
index 16a447b0a6..a95f94cabb 100644
--- a/runtime/dex_file_annotations.cc
+++ b/runtime/dex_file_annotations.cc
@@ -252,7 +252,7 @@ mirror::Object* ProcessEncodedAnnotation(Handle<mirror::Class> klass, const uint
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
Handle<mirror::Class> annotation_class(hs.NewHandle(
class_linker->ResolveType(klass->GetDexFile(), dex::TypeIndex(type_index), klass.Get())));
- if (annotation_class.Get() == nullptr) {
+ if (annotation_class == nullptr) {
LOG(INFO) << "Unable to resolve " << klass->PrettyClass() << " annotation class " << type_index;
DCHECK(Thread::Current()->IsExceptionPending());
Thread::Current()->ClearException();
@@ -481,7 +481,7 @@ bool ProcessAnnotationValue(Handle<mirror::Class> klass,
break;
}
case DexFile::kDexAnnotationArray:
- if (result_style == DexFile::kAllRaw || array_class.Get() == nullptr) {
+ if (result_style == DexFile::kAllRaw || array_class == nullptr) {
return false;
} else {
ScopedObjectAccessUnchecked soa(self);
@@ -491,7 +491,7 @@ bool ProcessAnnotationValue(Handle<mirror::Class> klass,
Handle<mirror::Array> new_array(hs.NewHandle(mirror::Array::Alloc<true>(
self, array_class.Get(), size, array_class->GetComponentSizeShift(),
Runtime::Current()->GetHeap()->GetCurrentAllocator())));
- if (new_array.Get() == nullptr) {
+ if (new_array == nullptr) {
LOG(ERROR) << "Annotation element array allocation failed with size " << size;
return false;
}
@@ -631,8 +631,8 @@ mirror::Object* CreateAnnotationMember(Handle<mirror::Class> klass,
}
Handle<mirror::Method> method_object(hs.NewHandle(method_obj_ptr));
- if (new_member.Get() == nullptr || string_name.Get() == nullptr ||
- method_object.Get() == nullptr || method_return.Get() == nullptr) {
+ if (new_member == nullptr || string_name == nullptr ||
+ method_object == nullptr || method_return == nullptr) {
LOG(ERROR) << StringPrintf("Failed creating annotation element (m=%p n=%p a=%p r=%p",
new_member.Get(), string_name.Get(), method_object.Get(), method_return.Get());
return nullptr;
@@ -740,7 +740,7 @@ mirror::ObjectArray<mirror::String>* GetSignatureValue(Handle<mirror::Class> kla
ObjPtr<mirror::Class> string_class = mirror::String::GetJavaLangString();
Handle<mirror::Class> string_array_class(hs.NewHandle(
Runtime::Current()->GetClassLinker()->FindArrayClass(Thread::Current(), &string_class)));
- if (string_array_class.Get() == nullptr) {
+ if (string_array_class == nullptr) {
return nullptr;
}
mirror::Object* obj =
@@ -766,7 +766,7 @@ mirror::ObjectArray<mirror::Class>* GetThrowsValue(Handle<mirror::Class> klass,
ObjPtr<mirror::Class> class_class = mirror::Class::GetJavaLangClass();
Handle<mirror::Class> class_array_class(hs.NewHandle(
Runtime::Current()->GetClassLinker()->FindArrayClass(Thread::Current(), &class_class)));
- if (class_array_class.Get() == nullptr) {
+ if (class_array_class == nullptr) {
return nullptr;
}
mirror::Object* obj =
@@ -796,7 +796,7 @@ mirror::ObjectArray<mirror::Object>* ProcessAnnotationSet(
uint32_t size = annotation_set->size_;
Handle<mirror::ObjectArray<mirror::Object>> result(hs.NewHandle(
mirror::ObjectArray<mirror::Object>::Alloc(self, annotation_array_class.Get(), size)));
- if (result.Get() == nullptr) {
+ if (result == nullptr) {
return nullptr;
}
@@ -854,7 +854,7 @@ mirror::ObjectArray<mirror::Object>* ProcessAnnotationSetRefList(
}
Handle<mirror::ObjectArray<mirror::Object>> annotation_array_array(hs.NewHandle(
mirror::ObjectArray<mirror::Object>::Alloc(self, annotation_array_array_class, size)));
- if (annotation_array_array.Get() == nullptr) {
+ if (annotation_array_array == nullptr) {
LOG(ERROR) << "Annotation set ref array allocation failed";
return nullptr;
}
@@ -1056,7 +1056,7 @@ bool GetParametersMetadataForMethod(ArtMethod* method,
ObjPtr<mirror::Class> string_class = mirror::String::GetJavaLangString();
Handle<mirror::Class> string_array_class(hs.NewHandle(
Runtime::Current()->GetClassLinker()->FindArrayClass(Thread::Current(), &string_class)));
- if (UNLIKELY(string_array_class.Get() == nullptr)) {
+ if (UNLIKELY(string_array_class == nullptr)) {
return false;
}
@@ -1067,13 +1067,13 @@ bool GetParametersMetadataForMethod(ArtMethod* method,
"names",
string_array_class,
DexFile::kDexAnnotationArray));
- if (names_obj.Get() == nullptr) {
+ if (names_obj == nullptr) {
return false;
}
// Extract the parameters' access flags int[].
Handle<mirror::Class> int_array_class(hs.NewHandle(mirror::IntArray::GetArrayClass()));
- if (UNLIKELY(int_array_class.Get() == nullptr)) {
+ if (UNLIKELY(int_array_class == nullptr)) {
return false;
}
Handle<mirror::Object> access_flags_obj =
@@ -1082,7 +1082,7 @@ bool GetParametersMetadataForMethod(ArtMethod* method,
"accessFlags",
int_array_class,
DexFile::kDexAnnotationArray));
- if (access_flags_obj.Get() == nullptr) {
+ if (access_flags_obj == nullptr) {
return false;
}
@@ -1146,7 +1146,7 @@ mirror::ObjectArray<mirror::Class>* GetDeclaredClasses(Handle<mirror::Class> kla
ObjPtr<mirror::Class> class_class = mirror::Class::GetJavaLangClass();
Handle<mirror::Class> class_array_class(hs.NewHandle(
Runtime::Current()->GetClassLinker()->FindArrayClass(hs.Self(), &class_class)));
- if (class_array_class.Get() == nullptr) {
+ if (class_array_class == nullptr) {
return nullptr;
}
mirror::Object* obj =
diff --git a/runtime/dex_file_verifier.cc b/runtime/dex_file_verifier.cc
index d870e52a52..0b3f16a3cb 100644
--- a/runtime/dex_file_verifier.cc
+++ b/runtime/dex_file_verifier.cc
@@ -2374,10 +2374,10 @@ bool DexFileVerifier::CheckInterMethodHandleItem() {
uint32_t index = item->field_or_method_idx_;
switch (method_handle_type) {
- case DexFile::MethodHandleType::kPutStatic:
- case DexFile::MethodHandleType::kGetStatic:
- case DexFile::MethodHandleType::kPutInstance:
- case DexFile::MethodHandleType::kGetInstance: {
+ 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;
}
diff --git a/runtime/dex_instruction.cc b/runtime/dex_instruction.cc
index 37f3ac92e9..091085a85c 100644
--- a/runtime/dex_instruction.cc
+++ b/runtime/dex_instruction.cc
@@ -407,6 +407,20 @@ std::string Instruction::DumpString(const DexFile* file) const {
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 @@ std::string Instruction::DumpString(const DexFile* file) const {
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 @@ std::string Instruction::DumpString(const DexFile* file) const {
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 @@ std::string Instruction::DumpString(const DexFile* file) const {
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 578550cae2..d269110570 100644
--- a/runtime/dex_instruction.h
+++ b/runtime/dex_instruction.h
@@ -126,14 +126,15 @@ class Instruction {
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 @@ class Instruction {
};
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 ca2ce1d990..a5ce3c2f8a 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/entrypoint_utils.cc b/runtime/entrypoints/entrypoint_utils.cc
index fb8139b7c6..6301362e09 100644
--- a/runtime/entrypoints/entrypoint_utils.cc
+++ b/runtime/entrypoints/entrypoint_utils.cc
@@ -39,7 +39,7 @@
namespace art {
void CheckReferenceResult(Handle<mirror::Object> o, Thread* self) {
- if (o.Get() == nullptr) {
+ if (o == nullptr) {
return;
}
// Make sure that the result is an instance of the type this method was expected to return.
diff --git a/runtime/entrypoints/quick/quick_field_entrypoints.cc b/runtime/entrypoints/quick/quick_field_entrypoints.cc
index 4544aef148..822c5a8d9d 100644
--- a/runtime/entrypoints/quick/quick_field_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_field_entrypoints.cc
@@ -48,7 +48,7 @@ ALWAYS_INLINE static inline ArtField* FindInstanceField(uint32_t field_idx,
StackHandleScope<1> hs(self);
HandleWrapper<mirror::Object> h(hs.NewHandleWrapper(obj));
ArtField* field = FindFieldFromCode<type, kAccessCheck>(field_idx, referrer, self, size);
- if (LIKELY(field != nullptr) && UNLIKELY(h.Get() == nullptr)) {
+ if (LIKELY(field != nullptr) && UNLIKELY(h == nullptr)) {
ThrowNullPointerExceptionForFieldAccess(field, /*is_read*/FindFieldTypeIsRead(type));
return nullptr;
}
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index 3ef47c427e..c2bca5305d 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -2435,8 +2435,8 @@ extern "C" uintptr_t artInvokePolymorphic(
// 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 @@ extern "C" uintptr_t artInvokePolymorphic(
// 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/reference_queue_test.cc b/runtime/gc/reference_queue_test.cc
index 3ca3353562..613b034f59 100644
--- a/runtime/gc/reference_queue_test.cc
+++ b/runtime/gc/reference_queue_test.cc
@@ -38,11 +38,11 @@ TEST_F(ReferenceQueueTest, EnqueueDequeue) {
auto ref_class = hs.NewHandle(
Runtime::Current()->GetClassLinker()->FindClass(self, "Ljava/lang/ref/WeakReference;",
ScopedNullHandle<mirror::ClassLoader>()));
- ASSERT_TRUE(ref_class.Get() != nullptr);
+ ASSERT_TRUE(ref_class != nullptr);
auto ref1(hs.NewHandle(ref_class->AllocObject(self)->AsReference()));
- ASSERT_TRUE(ref1.Get() != nullptr);
+ ASSERT_TRUE(ref1 != nullptr);
auto ref2(hs.NewHandle(ref_class->AllocObject(self)->AsReference()));
- ASSERT_TRUE(ref2.Get() != nullptr);
+ ASSERT_TRUE(ref2 != nullptr);
queue.EnqueueReference(ref1.Get());
ASSERT_TRUE(!queue.IsEmpty());
ASSERT_EQ(queue.GetLength(), 1U);
@@ -73,15 +73,15 @@ TEST_F(ReferenceQueueTest, Dump) {
auto weak_ref_class = hs.NewHandle(
Runtime::Current()->GetClassLinker()->FindClass(self, "Ljava/lang/ref/WeakReference;",
ScopedNullHandle<mirror::ClassLoader>()));
- ASSERT_TRUE(weak_ref_class.Get() != nullptr);
+ ASSERT_TRUE(weak_ref_class != nullptr);
auto finalizer_ref_class = hs.NewHandle(
Runtime::Current()->GetClassLinker()->FindClass(self, "Ljava/lang/ref/FinalizerReference;",
ScopedNullHandle<mirror::ClassLoader>()));
- ASSERT_TRUE(finalizer_ref_class.Get() != nullptr);
+ ASSERT_TRUE(finalizer_ref_class != nullptr);
auto ref1(hs.NewHandle(weak_ref_class->AllocObject(self)->AsReference()));
- ASSERT_TRUE(ref1.Get() != nullptr);
+ ASSERT_TRUE(ref1 != nullptr);
auto ref2(hs.NewHandle(finalizer_ref_class->AllocObject(self)->AsReference()));
- ASSERT_TRUE(ref2.Get() != nullptr);
+ ASSERT_TRUE(ref2 != nullptr);
queue.EnqueueReference(ref1.Get());
oss.str("");
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index f4b6f081a2..2163a20e87 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -1283,6 +1283,14 @@ class ImageSpaceLoader {
}
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);
+ }
}
}
{
diff --git a/runtime/gc/space/space_create_test.cc b/runtime/gc/space/space_create_test.cc
index 7bc4dc40e4..ca5f306264 100644
--- a/runtime/gc/space/space_create_test.cc
+++ b/runtime/gc/space/space_create_test.cc
@@ -108,7 +108,7 @@ TEST_P(SpaceCreateTest, ZygoteSpaceTestBody) {
&ptr1_bytes_allocated,
&ptr1_usable_size,
&ptr1_bytes_tl_bulk_allocated)));
- EXPECT_TRUE(ptr1.Get() != nullptr);
+ EXPECT_TRUE(ptr1 != nullptr);
EXPECT_LE(1U * MB, ptr1_bytes_allocated);
EXPECT_LE(1U * MB, ptr1_usable_size);
EXPECT_LE(ptr1_usable_size, ptr1_bytes_allocated);
@@ -126,7 +126,7 @@ TEST_P(SpaceCreateTest, ZygoteSpaceTestBody) {
&ptr3_bytes_allocated,
&ptr3_usable_size,
&ptr3_bytes_tl_bulk_allocated)));
- EXPECT_TRUE(ptr3.Get() != nullptr);
+ EXPECT_TRUE(ptr3 != nullptr);
EXPECT_LE(8U * MB, ptr3_bytes_allocated);
EXPECT_LE(8U * MB, ptr3_usable_size);
EXPECT_LE(ptr3_usable_size, ptr3_bytes_allocated);
@@ -154,7 +154,7 @@ TEST_P(SpaceCreateTest, ZygoteSpaceTestBody) {
&ptr6_bytes_allocated,
&ptr6_usable_size,
&ptr6_bytes_tl_bulk_allocated)));
- EXPECT_TRUE(ptr6.Get() != nullptr);
+ EXPECT_TRUE(ptr6 != nullptr);
EXPECT_LE(9U * MB, ptr6_bytes_allocated);
EXPECT_LE(9U * MB, ptr6_usable_size);
EXPECT_LE(ptr6_usable_size, ptr6_bytes_allocated);
@@ -193,7 +193,7 @@ TEST_P(SpaceCreateTest, ZygoteSpaceTestBody) {
&ptr1_bytes_allocated,
&ptr1_usable_size,
&ptr1_bytes_tl_bulk_allocated));
- EXPECT_TRUE(ptr1.Get() != nullptr);
+ EXPECT_TRUE(ptr1 != nullptr);
EXPECT_LE(1U * MB, ptr1_bytes_allocated);
EXPECT_LE(1U * MB, ptr1_usable_size);
EXPECT_LE(ptr1_usable_size, ptr1_bytes_allocated);
@@ -210,7 +210,7 @@ TEST_P(SpaceCreateTest, ZygoteSpaceTestBody) {
&ptr3_bytes_allocated,
&ptr3_usable_size,
&ptr3_bytes_tl_bulk_allocated));
- EXPECT_TRUE(ptr3.Get() != nullptr);
+ EXPECT_TRUE(ptr3 != nullptr);
EXPECT_LE(2U * MB, ptr3_bytes_allocated);
EXPECT_LE(2U * MB, ptr3_usable_size);
EXPECT_LE(ptr3_usable_size, ptr3_bytes_allocated);
@@ -242,7 +242,7 @@ TEST_P(SpaceCreateTest, AllocAndFreeTestBody) {
&ptr1_bytes_allocated,
&ptr1_usable_size,
&ptr1_bytes_tl_bulk_allocated)));
- EXPECT_TRUE(ptr1.Get() != nullptr);
+ EXPECT_TRUE(ptr1 != nullptr);
EXPECT_LE(1U * MB, ptr1_bytes_allocated);
EXPECT_LE(1U * MB, ptr1_usable_size);
EXPECT_LE(ptr1_usable_size, ptr1_bytes_allocated);
@@ -260,7 +260,7 @@ TEST_P(SpaceCreateTest, AllocAndFreeTestBody) {
&ptr3_bytes_allocated,
&ptr3_usable_size,
&ptr3_bytes_tl_bulk_allocated)));
- EXPECT_TRUE(ptr3.Get() != nullptr);
+ EXPECT_TRUE(ptr3 != nullptr);
EXPECT_LE(8U * MB, ptr3_bytes_allocated);
EXPECT_LE(8U * MB, ptr3_usable_size);
EXPECT_LE(ptr3_usable_size, ptr3_bytes_allocated);
@@ -288,7 +288,7 @@ TEST_P(SpaceCreateTest, AllocAndFreeTestBody) {
&ptr6_bytes_allocated,
&ptr6_usable_size,
&ptr6_bytes_tl_bulk_allocated)));
- EXPECT_TRUE(ptr6.Get() != nullptr);
+ EXPECT_TRUE(ptr6 != nullptr);
EXPECT_LE(9U * MB, ptr6_bytes_allocated);
EXPECT_LE(9U * MB, ptr6_usable_size);
EXPECT_LE(ptr6_usable_size, ptr6_bytes_allocated);
diff --git a/runtime/gc/space/space_test.h b/runtime/gc/space/space_test.h
index cbb3d73497..1fe3fb2e86 100644
--- a/runtime/gc/space/space_test.h
+++ b/runtime/gc/space/space_test.h
@@ -200,7 +200,7 @@ void SpaceTest<Super>::SizeFootPrintGrowthLimitAndTrimBody(MallocSpace* space,
}
footprint = space->GetFootprint();
EXPECT_GE(space->Size(), footprint); // invariant
- if (object.Get() != nullptr) { // allocation succeeded
+ if (object != nullptr) { // allocation succeeded
lots_of_objects[i] = object.Get();
size_t allocation_size = space->AllocationSize(object.Get(), nullptr);
EXPECT_EQ(bytes_allocated, allocation_size);
@@ -296,7 +296,7 @@ void SpaceTest<Super>::SizeFootPrintGrowthLimitAndTrimBody(MallocSpace* space,
large_object.Assign(AllocWithGrowth(space, self, three_quarters_space, &bytes_allocated,
nullptr, &bytes_tl_bulk_allocated));
}
- EXPECT_TRUE(large_object.Get() != nullptr);
+ EXPECT_TRUE(large_object != nullptr);
// Sanity check footprint
footprint = space->GetFootprint();
diff --git a/runtime/handle.h b/runtime/handle.h
index e4b6d29a55..ccff575495 100644
--- a/runtime/handle.h
+++ b/runtime/handle.h
@@ -81,6 +81,14 @@ class Handle : public ValueObject {
return reference_;
}
+ ALWAYS_INLINE bool operator!=(std::nullptr_t) const REQUIRES_SHARED(Locks::mutator_lock_) {
+ return !IsNull();
+ }
+
+ ALWAYS_INLINE bool operator==(std::nullptr_t) const REQUIRES_SHARED(Locks::mutator_lock_) {
+ return IsNull();
+ }
+
protected:
template<typename S>
explicit Handle(StackReference<S>* reference)
diff --git a/runtime/imtable_test.cc b/runtime/imtable_test.cc
index 8cbe2916ec..17149dfe44 100644
--- a/runtime/imtable_test.cc
+++ b/runtime/imtable_test.cc
@@ -53,7 +53,7 @@ class ImTableTest : public CommonRuntimeTest {
ObjPtr<mirror::ClassLoader>::DownCast(self->DecodeJObject(jclass_loader_a)));
Handle<mirror::Class> h_class_a(
hs.NewHandle(class_linker->FindClass(self, class_name.c_str(), h_class_loader)));
- if (h_class_a.Get() == nullptr) {
+ if (h_class_a == nullptr) {
LOG(ERROR) << self->GetException()->Dump();
CHECK(false) << "h_class_a == nullptr";
}
@@ -63,7 +63,7 @@ class ImTableTest : public CommonRuntimeTest {
ObjPtr<mirror::ClassLoader>::DownCast(self->DecodeJObject(jclass_loader_b)));
Handle<mirror::Class> h_class_b(
hs.NewHandle(class_linker->FindClass(self, class_name.c_str(), h_class_loader)));
- if (h_class_b.Get() == nullptr) {
+ if (h_class_b == nullptr) {
LOG(ERROR) << self->GetException()->Dump();
CHECK(false) << "h_class_b == nullptr";
}
diff --git a/runtime/indirect_reference_table_test.cc b/runtime/indirect_reference_table_test.cc
index bf4cab24cc..6aefe239a9 100644
--- a/runtime/indirect_reference_table_test.cc
+++ b/runtime/indirect_reference_table_test.cc
@@ -64,13 +64,13 @@ TEST_F(IndirectReferenceTableTest, BasicTest) {
StackHandleScope<4> hs(soa.Self());
ASSERT_TRUE(c != nullptr);
Handle<mirror::Object> obj0 = hs.NewHandle(c->AllocObject(soa.Self()));
- ASSERT_TRUE(obj0.Get() != nullptr);
+ ASSERT_TRUE(obj0 != nullptr);
Handle<mirror::Object> obj1 = hs.NewHandle(c->AllocObject(soa.Self()));
- ASSERT_TRUE(obj1.Get() != nullptr);
+ ASSERT_TRUE(obj1 != nullptr);
Handle<mirror::Object> obj2 = hs.NewHandle(c->AllocObject(soa.Self()));
- ASSERT_TRUE(obj2.Get() != nullptr);
+ ASSERT_TRUE(obj2 != nullptr);
Handle<mirror::Object> obj3 = hs.NewHandle(c->AllocObject(soa.Self()));
- ASSERT_TRUE(obj3.Get() != nullptr);
+ ASSERT_TRUE(obj3 != nullptr);
const IRTSegmentState cookie = kIRTFirstSegment;
@@ -282,15 +282,15 @@ TEST_F(IndirectReferenceTableTest, Holes) {
StackHandleScope<5> hs(soa.Self());
ASSERT_TRUE(c != nullptr);
Handle<mirror::Object> obj0 = hs.NewHandle(c->AllocObject(soa.Self()));
- ASSERT_TRUE(obj0.Get() != nullptr);
+ ASSERT_TRUE(obj0 != nullptr);
Handle<mirror::Object> obj1 = hs.NewHandle(c->AllocObject(soa.Self()));
- ASSERT_TRUE(obj1.Get() != nullptr);
+ ASSERT_TRUE(obj1 != nullptr);
Handle<mirror::Object> obj2 = hs.NewHandle(c->AllocObject(soa.Self()));
- ASSERT_TRUE(obj2.Get() != nullptr);
+ ASSERT_TRUE(obj2 != nullptr);
Handle<mirror::Object> obj3 = hs.NewHandle(c->AllocObject(soa.Self()));
- ASSERT_TRUE(obj3.Get() != nullptr);
+ ASSERT_TRUE(obj3 != nullptr);
Handle<mirror::Object> obj4 = hs.NewHandle(c->AllocObject(soa.Self()));
- ASSERT_TRUE(obj4.Get() != nullptr);
+ ASSERT_TRUE(obj4 != nullptr);
std::string error_msg;
@@ -491,7 +491,7 @@ TEST_F(IndirectReferenceTableTest, Resize) {
StackHandleScope<1> hs(soa.Self());
ASSERT_TRUE(c != nullptr);
Handle<mirror::Object> obj0 = hs.NewHandle(c->AllocObject(soa.Self()));
- ASSERT_TRUE(obj0.Get() != nullptr);
+ ASSERT_TRUE(obj0 != nullptr);
std::string error_msg;
IndirectReferenceTable irt(kTableMax,
diff --git a/runtime/intern_table_test.cc b/runtime/intern_table_test.cc
index 3991d6550d..f0d0260482 100644
--- a/runtime/intern_table_test.cc
+++ b/runtime/intern_table_test.cc
@@ -36,10 +36,10 @@ TEST_F(InternTableTest, Intern) {
Handle<mirror::String> foo_3(
hs.NewHandle(mirror::String::AllocFromModifiedUtf8(soa.Self(), "foo")));
Handle<mirror::String> bar(hs.NewHandle(intern_table.InternStrong(3, "bar")));
- ASSERT_TRUE(foo_1.Get() != nullptr);
- ASSERT_TRUE(foo_2.Get() != nullptr);
- ASSERT_TRUE(foo_3.Get() != nullptr);
- ASSERT_TRUE(bar.Get() != nullptr);
+ ASSERT_TRUE(foo_1 != nullptr);
+ ASSERT_TRUE(foo_2 != nullptr);
+ ASSERT_TRUE(foo_3 != nullptr);
+ ASSERT_TRUE(bar != nullptr);
EXPECT_EQ(foo_1.Get(), foo_2.Get());
EXPECT_TRUE(foo_1->Equals("foo"));
EXPECT_TRUE(foo_2->Equals("foo"));
@@ -204,9 +204,9 @@ TEST_F(InternTableTest, LookupStrong) {
Handle<mirror::String> foo(hs.NewHandle(intern_table.InternStrong(3, "foo")));
Handle<mirror::String> bar(hs.NewHandle(intern_table.InternStrong(3, "bar")));
Handle<mirror::String> foobar(hs.NewHandle(intern_table.InternStrong(6, "foobar")));
- ASSERT_TRUE(foo.Get() != nullptr);
- ASSERT_TRUE(bar.Get() != nullptr);
- ASSERT_TRUE(foobar.Get() != nullptr);
+ ASSERT_TRUE(foo != nullptr);
+ ASSERT_TRUE(bar != nullptr);
+ ASSERT_TRUE(foobar != nullptr);
ASSERT_TRUE(foo->Equals("foo"));
ASSERT_TRUE(bar->Equals("bar"));
ASSERT_TRUE(foobar->Equals("foobar"));
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc
index 28bcb97105..8978bfd5af 100644
--- a/runtime/interpreter/interpreter_common.cc
+++ b/runtime/interpreter/interpreter_common.cc
@@ -519,7 +519,7 @@ void SetStringInitValueToAllAliases(ShadowFrame* shadow_frame,
}
}
-template<bool is_range, bool do_access_check>
+template<bool is_range>
bool DoInvokePolymorphic(Thread* self,
ShadowFrame& shadow_frame,
const Instruction* inst,
@@ -539,10 +539,10 @@ bool DoInvokePolymorphic(Thread* self,
// 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)) {
+ if (UNLIKELY(method_handle == nullptr)) {
// Note that the invoke type is kVirtual here because a call to a signature
// polymorphic method is shaped like a virtual call at the bytecode level.
ThrowNullPointerExceptionForMethodAccess(invoke_method_idx, InvokeType::kVirtual);
@@ -564,7 +564,7 @@ bool DoInvokePolymorphic(Thread* self,
hs.NewHandle<mirror::ClassLoader>(caller_class->GetClassLoader()))));
// This implies we couldn't resolve one or more types in this method handle.
- if (UNLIKELY(callsite_type.Get() == nullptr)) {
+ if (UNLIKELY(callsite_type == nullptr)) {
CHECK(self->IsExceptionPending());
return false;
}
@@ -584,31 +584,300 @@ bool DoInvokePolymorphic(Thread* self,
// 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, false);
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 7ef3508164..6b22af9829 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 @@ static inline bool DoInvoke(Thread* self,
}
// 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 a77a3fc2b3..b191dd79a1 100644
--- a/runtime/interpreter/interpreter_switch_impl.cc
+++ b/runtime/interpreter/interpreter_switch_impl.cc
@@ -1524,7 +1524,7 @@ JValue ExecuteSwitchImpl(Thread* self, const DexFile::CodeItem* code_item,
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 @@ JValue ExecuteSwitchImpl(Thread* self, const DexFile::CodeItem* code_item,
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 @@ JValue ExecuteSwitchImpl(Thread* self, const DexFile::CodeItem* code_item,
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/interpreter/unstarted_runtime.cc b/runtime/interpreter/unstarted_runtime.cc
index 545cc1ad42..c7e84420d3 100644
--- a/runtime/interpreter/unstarted_runtime.cc
+++ b/runtime/interpreter/unstarted_runtime.cc
@@ -124,7 +124,7 @@ static void UnstartedRuntimeFindClass(Thread* self, Handle<mirror::String> class
const std::string& method_name, bool initialize_class,
bool abort_if_not_found)
REQUIRES_SHARED(Locks::mutator_lock_) {
- CHECK(className.Get() != nullptr);
+ CHECK(className != nullptr);
std::string descriptor(DotToDescriptor(className->ToModifiedUtf8().c_str()));
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
@@ -239,7 +239,7 @@ void UnstartedRuntime::UnstartedClassNewInstance(
Handle<mirror::Class> h_klass(hs.NewHandle(klass));
// Check that it's not null.
- if (h_klass.Get() == nullptr) {
+ if (h_klass == nullptr) {
AbortTransactionOrFail(self, "Class reference is null for newInstance");
return;
}
@@ -263,7 +263,7 @@ void UnstartedRuntime::UnstartedClassNewInstance(
auto* cons = h_klass->FindDeclaredDirectMethod("<init>", "()V", cl->GetImagePointerSize());
if (cons != nullptr) {
Handle<mirror::Object> h_obj(hs.NewHandle(klass->AllocObject(self)));
- CHECK(h_obj.Get() != nullptr); // We don't expect OOM at compile-time.
+ CHECK(h_obj != nullptr); // We don't expect OOM at compile-time.
EnterInterpreterFromInvoke(self, cons, h_obj.Get(), nullptr, nullptr);
if (!self->IsExceptionPending()) {
result->SetL(h_obj.Get());
@@ -542,7 +542,7 @@ static void GetResourceAsStream(Thread* self,
// Create byte array for content.
Handle<mirror::ByteArray> h_array(hs.NewHandle(mirror::ByteArray::Alloc(self, map_size)));
- if (h_array.Get() == nullptr) {
+ if (h_array == nullptr) {
AbortTransactionOrFail(self, "Could not find/create byte array class");
return;
}
@@ -556,7 +556,7 @@ static void GetResourceAsStream(Thread* self,
runtime->GetClassLinker()->FindClass(self,
"Ljava/io/ByteArrayInputStream;",
ScopedNullHandle<mirror::ClassLoader>())));
- if (h_class.Get() == nullptr) {
+ if (h_class == nullptr) {
AbortTransactionOrFail(self, "Could not find ByteArrayInputStream class");
return;
}
@@ -566,7 +566,7 @@ static void GetResourceAsStream(Thread* self,
}
Handle<mirror::Object> h_obj(hs.NewHandle(h_class->AllocObject(self)));
- if (h_obj.Get() == nullptr) {
+ if (h_obj == nullptr) {
AbortTransactionOrFail(self, "Could not allocate ByteArrayInputStream object");
return;
}
@@ -800,7 +800,7 @@ static void GetSystemProperty(Thread* self,
StackHandleScope<4> hs(self);
Handle<mirror::String> h_key(
hs.NewHandle(reinterpret_cast<mirror::String*>(shadow_frame->GetVRegReference(arg_offset))));
- if (h_key.Get() == nullptr) {
+ if (h_key == nullptr) {
AbortTransactionOrFail(self, "getProperty key was null");
return;
}
@@ -815,7 +815,7 @@ static void GetSystemProperty(Thread* self,
class_linker->FindClass(self,
"Ljava/lang/AndroidHardcodedSystemProperties;",
ScopedNullHandle<mirror::ClassLoader>())));
- if (h_props_class.Get() == nullptr) {
+ if (h_props_class == nullptr) {
AbortTransactionOrFail(self, "Could not find AndroidHardcodedSystemProperties");
return;
}
@@ -837,7 +837,7 @@ static void GetSystemProperty(Thread* self,
ObjPtr<mirror::Object> props = static_properties->GetObject(h_props_class.Get());
Handle<mirror::ObjectArray<mirror::ObjectArray<mirror::String>>> h_2string_array(hs.NewHandle(
props->AsObjectArray<mirror::ObjectArray<mirror::String>>()));
- if (h_2string_array.Get() == nullptr) {
+ if (h_2string_array == nullptr) {
AbortTransactionOrFail(self, "Field %s is null", kAndroidHardcodedSystemPropertiesFieldName);
return;
}
@@ -849,7 +849,7 @@ static void GetSystemProperty(Thread* self,
hs.NewHandle<mirror::ObjectArray<mirror::String>>(nullptr));
for (int32_t i = 0; i < prop_count; ++i) {
h_string_array.Assign(h_2string_array->Get(i));
- if (h_string_array.Get() == nullptr ||
+ if (h_string_array == nullptr ||
h_string_array->GetLength() != 2 ||
h_string_array->Get(0) == nullptr) {
AbortTransactionOrFail(self,
@@ -924,7 +924,7 @@ static ObjPtr<mirror::Object> CreateInstanceOf(Thread* self, const char* class_d
StackHandleScope<2> hs(self);
Handle<mirror::Class> h_class(hs.NewHandle(klass));
Handle<mirror::Object> h_obj(hs.NewHandle(h_class->AllocObject(self)));
- if (h_obj.Get() != nullptr) {
+ if (h_obj != nullptr) {
ArtMethod* init_method = h_class->FindDirectMethod(
"<init>", "()V", class_linker->GetImagePointerSize());
if (init_method == nullptr) {
diff --git a/runtime/interpreter/unstarted_runtime_test.cc b/runtime/interpreter/unstarted_runtime_test.cc
index 31be587e9c..16b7b55e00 100644
--- a/runtime/interpreter/unstarted_runtime_test.cc
+++ b/runtime/interpreter/unstarted_runtime_test.cc
@@ -960,7 +960,7 @@ TEST_F(UnstartedRuntimeTest, ThreadLocalGet) {
class_linker->FindClass(self,
"Lsun/misc/FloatingDecimal;",
ScopedNullHandle<mirror::ClassLoader>()));
- ASSERT_TRUE(floating_decimal.Get() != nullptr);
+ ASSERT_TRUE(floating_decimal != nullptr);
ASSERT_TRUE(class_linker->EnsureInitialized(self, floating_decimal, true, true));
ArtMethod* caller_method = floating_decimal->FindDeclaredDirectMethod(
@@ -1014,7 +1014,7 @@ TEST_F(UnstartedRuntimeTest, FloatConversion) {
class_linker->FindClass(self,
"Ljava/lang/Double;",
ScopedNullHandle<mirror::ClassLoader>()));
- ASSERT_TRUE(double_class.Get() != nullptr);
+ ASSERT_TRUE(double_class != nullptr);
ASSERT_TRUE(class_linker->EnsureInitialized(self, double_class, true, true));
ArtMethod* method = double_class->FindDeclaredDirectMethod("toString",
diff --git a/runtime/jdwp/object_registry.cc b/runtime/jdwp/object_registry.cc
index 4615574947..bd7251baeb 100644
--- a/runtime/jdwp/object_registry.cc
+++ b/runtime/jdwp/object_registry.cc
@@ -57,7 +57,7 @@ JDWP::ObjectId ObjectRegistry::Add(ObjPtr<mirror::Object> o) {
// Template instantiations must be declared below.
template<class T>
JDWP::ObjectId ObjectRegistry::Add(Handle<T> obj_h) {
- if (obj_h.Get() == nullptr) {
+ if (obj_h == nullptr) {
return 0;
}
return InternalAdd(obj_h);
@@ -76,7 +76,7 @@ JDWP::ObjectId ObjectRegistry::Add(Handle<mirror::Throwable> obj_h);
template<class T>
JDWP::ObjectId ObjectRegistry::InternalAdd(Handle<T> obj_h) {
- CHECK(obj_h.Get() != nullptr);
+ CHECK(obj_h != nullptr);
Thread* const self = Thread::Current();
self->AssertNoPendingException();
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 0ac388ac02..60ab275641 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -686,6 +686,10 @@ void JitCodeCache::NotifyMethodRedefined(ArtMethod* method) {
// 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/jni_internal.cc b/runtime/jni_internal.cc
index 3c641b0b75..547b5b8a2d 100644
--- a/runtime/jni_internal.cc
+++ b/runtime/jni_internal.cc
@@ -196,7 +196,7 @@ static jfieldID FindFieldID(const ScopedObjectAccess& soa, jclass jni_class, con
StackHandleScope<2> hs(soa.Self());
Handle<mirror::Class> c(
hs.NewHandle(EnsureInitialized(soa.Self(), soa.Decode<mirror::Class>(jni_class))));
- if (c.Get() == nullptr) {
+ if (c == nullptr) {
return nullptr;
}
ArtField* field = nullptr;
diff --git a/runtime/jobject_comparator.cc b/runtime/jobject_comparator.cc
index 443f095d05..4c45e3839b 100644
--- a/runtime/jobject_comparator.cc
+++ b/runtime/jobject_comparator.cc
@@ -34,9 +34,9 @@ bool JobjectComparator::operator()(jobject jobj1, jobject jobj2) const {
StackHandleScope<2> hs(soa.Self());
Handle<mirror::Object> obj1(hs.NewHandle(soa.Decode<mirror::Object>(jobj1)));
Handle<mirror::Object> obj2(hs.NewHandle(soa.Decode<mirror::Object>(jobj2)));
- if (obj1.Get() == nullptr) {
+ if (obj1 == nullptr) {
return true;
- } else if (obj2.Get() == nullptr) {
+ } else if (obj2 == nullptr) {
return false;
}
// Sort by class...
diff --git a/runtime/method_handles.cc b/runtime/method_handles.cc
index 99886e5c2f..6ecfd8c714 100644
--- a/runtime/method_handles.cc
+++ b/runtime/method_handles.cc
@@ -220,7 +220,7 @@ bool ConvertJValueCommon(
StackHandleScope<2> hs(Thread::Current());
Handle<mirror::Class> h_to(hs.NewHandle(to));
Handle<mirror::Object> h_obj(hs.NewHandle(src_value.GetL()));
- if (h_obj.Get() != nullptr && !to->IsAssignableFrom(h_obj->GetClass())) {
+ if (h_obj != nullptr && !to->IsAssignableFrom(h_obj->GetClass())) {
ThrowClassCastException(h_to.Get(), h_obj->GetClass());
return false;
}
@@ -555,7 +555,7 @@ static inline bool DoCallTransform(ArtMethod* called_method,
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)
@@ -599,7 +599,7 @@ static inline bool DoCallTransform(ArtMethod* called_method,
// Something went wrong while creating the emulated stack frame, we should
// throw the pending exception.
- if (sf.Get() == nullptr) {
+ if (sf == nullptr) {
DCHECK(self->IsExceptionPending());
return false;
}
@@ -645,7 +645,7 @@ inline static ObjPtr<mirror::Class> GetAndInitializeDeclaringClass(Thread* self,
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 @@ inline static void DoFieldGetForInvokePolymorphic(Thread* self,
}
// 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 @@ inline bool DoFieldPutForInvokePolymorphic(Thread* self,
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 @@ static JValue GetValueFromShadowFrame(const ShadowFrame& shadow_frame,
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 @@ bool DoInvokePolymorphicFieldAccess(Thread* self,
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 @@ bool DoInvokePolymorphicFieldAccess(Thread* self,
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 @@ bool DoInvokePolymorphicFieldAccess(Thread* self,
}
}
-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 @@ static inline bool DoInvokePolymorphicNonExact(Thread* self,
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 @@ static inline bool DoInvokePolymorphicNonExact(Thread* self,
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 @@ static inline bool DoInvokePolymorphicNonExact(Thread* self,
}
}
-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 @@ bool DoInvokePolymorphicExact(Thread* self,
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 @@ bool DoInvokePolymorphicExact(Thread* self,
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 @@ bool DoInvokePolymorphicExact(Thread* self,
} // 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)
-
-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);
+#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);
+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 734d7c7bf4..5bea0ab5cd 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 @@ class ShadowFrameSetter {
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/array.cc b/runtime/mirror/array.cc
index cc548b9cc8..f283ec3e9d 100644
--- a/runtime/mirror/array.cc
+++ b/runtime/mirror/array.cc
@@ -52,7 +52,7 @@ static Array* RecursiveCreateMultiArray(Thread* self,
Array::Alloc<true>(self, array_class.Get(), array_length,
array_class->GetComponentSizeShift(),
Runtime::Current()->GetHeap()->GetCurrentAllocator())));
- if (UNLIKELY(new_array.Get() == nullptr)) {
+ if (UNLIKELY(new_array == nullptr)) {
CHECK(self->IsExceptionPending());
return nullptr;
}
@@ -98,14 +98,14 @@ Array* Array::CreateMultiArray(Thread* self, Handle<Class> element_class,
StackHandleScope<1> hs(self);
MutableHandle<mirror::Class> array_class(
hs.NewHandle(class_linker->FindArrayClass(self, &element_class_ptr)));
- if (UNLIKELY(array_class.Get() == nullptr)) {
+ if (UNLIKELY(array_class == nullptr)) {
CHECK(self->IsExceptionPending());
return nullptr;
}
for (int32_t i = 1; i < dimensions->GetLength(); ++i) {
ObjPtr<mirror::Class> array_class_ptr = array_class.Get();
array_class.Assign(class_linker->FindArrayClass(self, &array_class_ptr));
- if (UNLIKELY(array_class.Get() == nullptr)) {
+ if (UNLIKELY(array_class == nullptr)) {
CHECK(self->IsExceptionPending());
return nullptr;
}
diff --git a/runtime/mirror/call_site.cc b/runtime/mirror/call_site.cc
new file mode 100644
index 0000000000..eb613df4c6
--- /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 0000000000..db244a5442
--- /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/class.cc b/runtime/mirror/class.cc
index 1b8f3f83e7..9a9a5d8398 100644
--- a/runtime/mirror/class.cc
+++ b/runtime/mirror/class.cc
@@ -81,7 +81,7 @@ ClassExt* Class::EnsureExtDataPresent(Thread* self) {
self->ClearException();
// Allocate the ClassExt
Handle<ClassExt> new_ext(hs.NewHandle(ClassExt::Alloc(self)));
- if (new_ext.Get() == nullptr) {
+ if (new_ext == nullptr) {
// OOM allocating the classExt.
// TODO Should we restore the suppressed exception?
self->AssertPendingOOMException();
@@ -103,7 +103,7 @@ ClassExt* Class::EnsureExtDataPresent(Thread* self) {
DCHECK(!set || h_this->GetExtData() == new_ext.Get());
CHECK(!ret.IsNull());
// Restore the exception if there was one.
- if (throwable.Get() != nullptr) {
+ if (throwable != nullptr) {
self->SetException(throwable.Get());
}
return ret.Ptr();
@@ -269,10 +269,10 @@ void Class::DumpClass(std::ostream& os, int flags) {
os << "----- " << (IsInterface() ? "interface" : "class") << " "
<< "'" << GetDescriptor(&temp) << "' cl=" << GetClassLoader() << " -----\n",
os << " objectSize=" << SizeOf() << " "
- << "(" << (h_super.Get() != nullptr ? h_super->SizeOf() : -1) << " from super)\n",
+ << "(" << (h_super != nullptr ? h_super->SizeOf() : -1) << " from super)\n",
os << StringPrintf(" access=0x%04x.%04x\n",
GetAccessFlags() >> 16, GetAccessFlags() & kAccJavaFlagsMask);
- if (h_super.Get() != nullptr) {
+ if (h_super != nullptr) {
os << " super='" << h_super->PrettyClass() << "' (cl=" << h_super->GetClassLoader()
<< ")\n";
}
@@ -297,7 +297,7 @@ void Class::DumpClass(std::ostream& os, int flags) {
} else {
// After this point, this may have moved due to GetDirectInterface.
os << " vtable (" << h_this->NumVirtualMethods() << " entries, "
- << (h_super.Get() != nullptr ? h_super->NumVirtualMethods() : 0) << " in super):\n";
+ << (h_super != nullptr ? h_super->NumVirtualMethods() : 0) << " in super):\n";
for (size_t i = 0; i < NumVirtualMethods(); ++i) {
os << StringPrintf(" %2zd: %s\n", i, ArtMethod::PrettyMethod(
h_this->GetVirtualMethodDuringLinking(i, image_pointer_size)).c_str());
@@ -971,7 +971,7 @@ ObjPtr<Class> Class::ResolveDirectInterface(Thread* self, Handle<Class> klass, u
}
ObjPtr<Class> Class::GetCommonSuperClass(Handle<Class> klass) {
- DCHECK(klass.Get() != nullptr);
+ DCHECK(klass != nullptr);
DCHECK(!klass->IsInterface());
DCHECK(!IsInterface());
ObjPtr<Class> common_super_class = this;
@@ -1165,7 +1165,7 @@ ObjPtr<Method> Class::GetDeclaredMethodInternal(
constexpr uint32_t kSkipModifiers = kAccMiranda | kAccSynthetic;
StackHandleScope<3> hs(self);
auto h_method_name = hs.NewHandle(name);
- if (UNLIKELY(h_method_name.Get() == nullptr)) {
+ if (UNLIKELY(h_method_name == nullptr)) {
ThrowNullPointerException("name == null");
return nullptr;
}
diff --git a/runtime/mirror/class_ext.cc b/runtime/mirror/class_ext.cc
index efd949e031..7270079a8f 100644
--- a/runtime/mirror/class_ext.cc
+++ b/runtime/mirror/class_ext.cc
@@ -58,8 +58,8 @@ bool ClassExt::ExtendObsoleteArrays(Thread* self, uint32_t increase) {
Handle<ObjectArray<DexCache>> old_dex_caches(hs.NewHandle(h_this->GetObsoleteDexCaches()));
ClassLinker* cl = Runtime::Current()->GetClassLinker();
size_t new_len;
- if (old_methods.Get() == nullptr) {
- CHECK(old_dex_caches.Get() == nullptr);
+ if (old_methods == nullptr) {
+ CHECK(old_dex_caches == nullptr);
new_len = increase;
} else {
CHECK_EQ(old_methods->GetLength(), old_dex_caches->GetLength());
diff --git a/runtime/mirror/dex_cache-inl.h b/runtime/mirror/dex_cache-inl.h
index a59bb7b880..973c8ed07d 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 @@ inline void DexCache::SetResolvedMethodType(uint32_t proto_idx, MethodType* reso
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 @@ inline void DexCache::VisitReferences(ObjPtr<Class> klass, const Visitor& visito
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 @@ inline void DexCache::FixupResolvedMethodTypes(mirror::MethodTypeDexCacheType* d
}
}
+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 741cf3bb47..0f6acab7e1 100644
--- a/runtime/mirror/dex_cache.cc
+++ b/runtime/mirror/dex_cache.cc
@@ -90,6 +90,10 @@ void DexCache::InitializeDexCache(Thread* self,
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 @@ void DexCache::InitializeDexCache(Thread* self,
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 @@ void DexCache::InitializeDexCache(Thread* self,
dex_file->NumFieldIds(),
method_types,
num_method_types,
+ call_sites,
+ dex_file->NumCallSiteIds(),
image_pointer_size);
}
@@ -151,6 +160,8 @@ void DexCache::Init(const DexFile* dex_file,
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 @@ void DexCache::Init(const DexFile* dex_file,
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 @@ void DexCache::Init(const DexFile* dex_file,
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 6f88cc5df4..10bb5aa01c 100644
--- a/runtime/mirror/dex_cache.h
+++ b/runtime/mirror/dex_cache.h
@@ -36,6 +36,7 @@ class Thread;
namespace mirror {
+class CallSite;
class MethodType;
class String;
@@ -163,6 +164,10 @@ class MANAGED DexCache FINAL : public Object {
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 @@ class MANAGED DexCache FINAL : public Object {
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 @@ class MANAGED DexCache FINAL : public Object {
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 @@ class MANAGED DexCache FINAL : public Object {
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 @@ class MANAGED DexCache FINAL : public Object {
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 @@ class MANAGED DexCache FINAL : public Object {
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 @@ class MANAGED DexCache FINAL : public Object {
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 @@ class MANAGED DexCache FINAL : public Object {
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 @@ class MANAGED DexCache FINAL : public Object {
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/dex_cache_test.cc b/runtime/mirror/dex_cache_test.cc
index 8f978e122c..5a2ab7151c 100644
--- a/runtime/mirror/dex_cache_test.cc
+++ b/runtime/mirror/dex_cache_test.cc
@@ -47,7 +47,7 @@ TEST_F(DexCacheTest, Open) {
soa.Self(),
*java_lang_dex_file_,
Runtime::Current()->GetLinearAlloc())));
- ASSERT_TRUE(dex_cache.Get() != nullptr);
+ ASSERT_TRUE(dex_cache != nullptr);
EXPECT_TRUE(dex_cache->StaticStringSize() == dex_cache->NumStrings()
|| java_lang_dex_file_->NumStringIds() == dex_cache->NumStrings());
@@ -95,10 +95,10 @@ TEST_F(DexCacheTest, TestResolvedFieldAccess) {
soa.Decode<mirror::ClassLoader>(jclass_loader)));
Handle<mirror::Class> klass1 =
hs.NewHandle(class_linker_->FindClass(soa.Self(), "Lpackage1/Package1;", class_loader));
- ASSERT_TRUE(klass1.Get() != nullptr);
+ ASSERT_TRUE(klass1 != nullptr);
Handle<mirror::Class> klass2 =
hs.NewHandle(class_linker_->FindClass(soa.Self(), "Lpackage2/Package2;", class_loader));
- ASSERT_TRUE(klass2.Get() != nullptr);
+ ASSERT_TRUE(klass2 != nullptr);
EXPECT_EQ(klass1->GetDexCache(), klass2->GetDexCache());
EXPECT_NE(klass1->NumStaticFields(), 0u);
diff --git a/runtime/mirror/emulated_stack_frame.cc b/runtime/mirror/emulated_stack_frame.cc
index 978cc32320..be0eac05c9 100644
--- a/runtime/mirror/emulated_stack_frame.cc
+++ b/runtime/mirror/emulated_stack_frame.cc
@@ -173,13 +173,13 @@ mirror::EmulatedStackFrame* EmulatedStackFrame::CreateFromShadowFrameAndArgs(
Handle<mirror::ObjectArray<mirror::Object>> references(hs.NewHandle(
mirror::ObjectArray<mirror::Object>::Alloc(self, array_class, refs_size)));
- if (references.Get() == nullptr) {
+ if (references == nullptr) {
DCHECK(self->IsExceptionPending());
return nullptr;
}
Handle<ByteArray> stack_frame(hs.NewHandle(ByteArray::Alloc(self, frame_size)));
- if (stack_frame.Get() == nullptr) {
+ if (stack_frame == nullptr) {
DCHECK(self->IsExceptionPending());
return nullptr;
}
diff --git a/runtime/mirror/field-inl.h b/runtime/mirror/field-inl.h
index c03f20a991..2496989337 100644
--- a/runtime/mirror/field-inl.h
+++ b/runtime/mirror/field-inl.h
@@ -33,7 +33,7 @@ inline mirror::Field* Field::CreateFromArtField(Thread* self, ArtField* field, b
// Try to resolve type before allocating since this is a thread suspension point.
Handle<mirror::Class> type = hs.NewHandle(field->GetType<true>());
- if (type.Get() == nullptr) {
+ if (type == nullptr) {
if (force_resolve) {
if (kIsDebugBuild) {
self->AssertPendingException();
@@ -49,7 +49,7 @@ inline mirror::Field* Field::CreateFromArtField(Thread* self, ArtField* field, b
}
}
auto ret = hs.NewHandle(ObjPtr<Field>::DownCast(StaticClass()->AllocObject(self)));
- if (UNLIKELY(ret.Get() == nullptr)) {
+ if (UNLIKELY(ret == nullptr)) {
self->AssertPendingOOMException();
return nullptr;
}
diff --git a/runtime/mirror/method_handle_impl.cc b/runtime/mirror/method_handle_impl.cc
index 4f1c448b56..fa4d25a031 100644
--- a/runtime/mirror/method_handle_impl.cc
+++ b/runtime/mirror/method_handle_impl.cc
@@ -28,6 +28,18 @@ mirror::Class* MethodHandle::StaticClass() {
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 @@ void MethodHandleImpl::VisitRoots(RootVisitor* visitor) {
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 53d267b52c..9938af8abf 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 @@ class MANAGED MethodHandle : public Object {
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 @@ class MANAGED MethodHandle : public Object {
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 @@ class MANAGED MethodHandle : public Object {
// 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 0000000000..c758e54dd4
--- /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 0000000000..63eb428f94
--- /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 5d77a16e7d..4b8dfacec6 100644
--- a/runtime/mirror/method_type.cc
+++ b/runtime/mirror/method_type.cc
@@ -44,6 +44,22 @@ mirror::MethodType* MethodType::Create(Thread* const self,
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 9a98143144..374bbe5df3 100644
--- a/runtime/mirror/method_type.h
+++ b/runtime/mirror/method_type.h
@@ -44,6 +44,10 @@ class MANAGED MethodType : public Object {
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/method_type_test.cc b/runtime/mirror/method_type_test.cc
index 637bafd75e..41231ef617 100644
--- a/runtime/mirror/method_type_test.cc
+++ b/runtime/mirror/method_type_test.cc
@@ -51,7 +51,7 @@ static mirror::MethodType* CreateMethodType(const std::string& return_type,
Handle<mirror::Class> return_clazz = hs.NewHandle(class_linker->FindClass(
soa.Self(), FullyQualifiedType(return_type).c_str(), boot_class_loader));
- CHECK(return_clazz.Get() != nullptr);
+ CHECK(return_clazz != nullptr);
ObjPtr<mirror::Class> class_type = mirror::Class::GetJavaLangClass();
mirror::Class* class_array_type = class_linker->FindArrayClass(self, &class_type);
diff --git a/runtime/mirror/object_test.cc b/runtime/mirror/object_test.cc
index 6a4ec9dca7..e761e4db7a 100644
--- a/runtime/mirror/object_test.cc
+++ b/runtime/mirror/object_test.cc
@@ -530,8 +530,8 @@ TEST_F(ObjectTest, InstanceOf) {
Handle<Object> x(hs.NewHandle(X->AllocObject(soa.Self())));
Handle<Object> y(hs.NewHandle(Y->AllocObject(soa.Self())));
- ASSERT_TRUE(x.Get() != nullptr);
- ASSERT_TRUE(y.Get() != nullptr);
+ ASSERT_TRUE(x != nullptr);
+ ASSERT_TRUE(y != nullptr);
EXPECT_TRUE(x->InstanceOf(X));
EXPECT_FALSE(x->InstanceOf(Y));
@@ -650,7 +650,7 @@ TEST_F(ObjectTest, FindInstanceField) {
ScopedObjectAccess soa(Thread::Current());
StackHandleScope<1> hs(soa.Self());
Handle<String> s(hs.NewHandle(String::AllocFromModifiedUtf8(soa.Self(), "ABC")));
- ASSERT_TRUE(s.Get() != nullptr);
+ ASSERT_TRUE(s != nullptr);
Class* c = s->GetClass();
ASSERT_TRUE(c != nullptr);
@@ -684,9 +684,9 @@ TEST_F(ObjectTest, FindStaticField) {
ScopedObjectAccess soa(Thread::Current());
StackHandleScope<4> hs(soa.Self());
Handle<String> s(hs.NewHandle(String::AllocFromModifiedUtf8(soa.Self(), "ABC")));
- ASSERT_TRUE(s.Get() != nullptr);
+ ASSERT_TRUE(s != nullptr);
Handle<Class> c(hs.NewHandle(s->GetClass()));
- ASSERT_TRUE(c.Get() != nullptr);
+ ASSERT_TRUE(c != nullptr);
// Wrong type.
EXPECT_TRUE(c->FindDeclaredStaticField("CASE_INSENSITIVE_ORDER", "I") == nullptr);
diff --git a/runtime/monitor_test.cc b/runtime/monitor_test.cc
index 4fbfe4781c..27ce149342 100644
--- a/runtime/monitor_test.cc
+++ b/runtime/monitor_test.cc
@@ -77,7 +77,7 @@ static void FillHeap(Thread* self, ClassLinker* class_linker,
while (length > 10) {
MutableHandle<mirror::Object> h((*hsp)->NewHandle<mirror::Object>(
mirror::ObjectArray<mirror::Object>::Alloc(self, ca.Get(), length / 4)));
- if (self->IsExceptionPending() || h.Get() == nullptr) {
+ if (self->IsExceptionPending() || h == nullptr) {
self->ClearException();
// Try a smaller length
@@ -95,7 +95,7 @@ static void FillHeap(Thread* self, ClassLinker* class_linker,
// Allocate simple objects till it fails.
while (!self->IsExceptionPending()) {
MutableHandle<mirror::Object> h = (*hsp)->NewHandle<mirror::Object>(c->AllocObject(self));
- if (!self->IsExceptionPending() && h.Get() != nullptr) {
+ if (!self->IsExceptionPending() && h != nullptr) {
handles->push_back(h);
}
}
diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc
index 24308d9e81..6bfccdc8fb 100644
--- a/runtime/native/dalvik_system_VMRuntime.cc
+++ b/runtime/native/dalvik_system_VMRuntime.cc
@@ -350,7 +350,7 @@ static void PreloadDexCachesResolveField(Handle<mirror::DexCache> dex_cache, uin
Thread* const self = Thread::Current();
StackHandleScope<1> hs(self);
Handle<mirror::Class> klass(hs.NewHandle(dex_cache->GetResolvedType(field_id.class_idx_)));
- if (klass.Get() == nullptr) {
+ if (klass == nullptr) {
return;
}
if (is_static) {
@@ -512,7 +512,7 @@ static void VMRuntime_preloadDexCaches(JNIEnv* env, jobject) {
CHECK(dex_file != nullptr);
StackHandleScope<1> hs(soa.Self());
Handle<mirror::DexCache> dex_cache(hs.NewHandle(linker->RegisterDexFile(*dex_file, nullptr)));
- CHECK(dex_cache.Get() != nullptr); // Boot class path dex caches are never unloaded.
+ CHECK(dex_cache != nullptr); // Boot class path dex caches are never unloaded.
if (kPreloadDexCachesStrings) {
for (size_t j = 0; j < dex_cache->NumStrings(); j++) {
PreloadDexCachesResolveString(dex_cache, dex::StringIndex(j), strings);
diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc
index 5438a6ddb4..256787b2a1 100644
--- a/runtime/native/java_lang_Class.cc
+++ b/runtime/native/java_lang_Class.cc
@@ -81,7 +81,7 @@ static jclass Class_classForName(JNIEnv* env, jclass, jstring javaName, jboolean
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
Handle<mirror::Class> c(
hs.NewHandle(class_linker->FindClass(soa.Self(), descriptor.c_str(), class_loader)));
- if (c.Get() == nullptr) {
+ if (c == nullptr) {
ScopedLocalRef<jthrowable> cause(env, env->ExceptionOccurred());
env->ExceptionClear();
jthrowable cnfe = reinterpret_cast<jthrowable>(
@@ -137,7 +137,7 @@ static mirror::ObjectArray<mirror::Field>* GetDeclaredFields(
size_t array_idx = 0;
auto object_array = hs.NewHandle(mirror::ObjectArray<mirror::Field>::Alloc(
self, mirror::Field::ArrayClass(), array_size));
- if (object_array.Get() == nullptr) {
+ if (object_array == nullptr) {
return nullptr;
}
for (ArtField& field : ifields) {
@@ -267,7 +267,7 @@ static mirror::Field* GetPublicFieldRecursive(
Handle<mirror::String> h_name(hs.NewHandle(name));
// We search the current class, its direct interfaces then its superclass.
- while (h_clazz.Get() != nullptr) {
+ while (h_clazz != nullptr) {
mirror::Field* result = GetDeclaredField(self, h_clazz.Get(), h_name.Get());
if ((result != nullptr) && (result->GetAccessFlags() & kAccPublic)) {
return result;
@@ -319,14 +319,14 @@ static jobject Class_getDeclaredField(JNIEnv* env, jobject javaThis, jstring nam
ScopedFastNativeObjectAccess soa(env);
StackHandleScope<3> hs(soa.Self());
Handle<mirror::String> h_string = hs.NewHandle(soa.Decode<mirror::String>(name));
- if (h_string.Get() == nullptr) {
+ if (h_string == nullptr) {
ThrowNullPointerException("name == null");
return nullptr;
}
Handle<mirror::Class> h_klass = hs.NewHandle(DecodeClass(soa, javaThis));
Handle<mirror::Field> result =
hs.NewHandle(GetDeclaredField(soa.Self(), h_klass.Get(), h_string.Get()));
- if (result.Get() == nullptr) {
+ if (result == nullptr) {
std::string name_str = h_string->ToModifiedUtf8();
if (name_str == "value" && h_klass->IsStringClass()) {
// We log the error for this specific case, as the user might just swallow the exception.
@@ -377,7 +377,7 @@ static jobjectArray Class_getDeclaredConstructorsInternal(
}
auto h_constructors = hs.NewHandle(mirror::ObjectArray<mirror::Constructor>::Alloc(
soa.Self(), mirror::Constructor::ArrayClass(), constructor_count));
- if (UNLIKELY(h_constructors.Get() == nullptr)) {
+ if (UNLIKELY(h_constructors == nullptr)) {
soa.Self()->AssertPendingException();
return nullptr;
}
@@ -428,7 +428,7 @@ static jobjectArray Class_getDeclaredMethodsUnchecked(JNIEnv* env, jobject javaT
}
auto ret = hs.NewHandle(mirror::ObjectArray<mirror::Method>::Alloc(
soa.Self(), mirror::Method::ArrayClass(), num_methods));
- if (ret.Get() == nullptr) {
+ if (ret == nullptr) {
soa.Self()->AssertPendingOOMException();
return nullptr;
}
@@ -645,7 +645,7 @@ static jobject Class_newInstance(JNIEnv* env, jobject javaThis) {
// Verify that we can access the class.
if (!klass->IsPublic()) {
caller.Assign(GetCallingClass(soa.Self(), 1));
- if (caller.Get() != nullptr && !caller->CanAccess(klass.Get())) {
+ if (caller != nullptr && !caller->CanAccess(klass.Get())) {
soa.Self()->ThrowNewExceptionF(
"Ljava/lang/IllegalAccessException;", "%s is not accessible from %s",
klass->PrettyClass().c_str(), caller->PrettyClass().c_str());
@@ -673,17 +673,17 @@ static jobject Class_newInstance(JNIEnv* env, jobject javaThis) {
}
}
auto receiver = hs.NewHandle(klass->AllocObject(soa.Self()));
- if (UNLIKELY(receiver.Get() == nullptr)) {
+ if (UNLIKELY(receiver == nullptr)) {
soa.Self()->AssertPendingOOMException();
return nullptr;
}
// Verify that we can access the constructor.
auto* declaring_class = constructor->GetDeclaringClass();
if (!constructor->IsPublic()) {
- if (caller.Get() == nullptr) {
+ if (caller == nullptr) {
caller.Assign(GetCallingClass(soa.Self(), 1));
}
- if (UNLIKELY(caller.Get() != nullptr && !VerifyAccess(receiver.Get(),
+ if (UNLIKELY(caller != nullptr && !VerifyAccess(receiver.Get(),
declaring_class,
constructor->GetAccessFlags(),
caller.Get()))) {
diff --git a/runtime/native/java_lang_invoke_MethodHandleImpl.cc b/runtime/native/java_lang_invoke_MethodHandleImpl.cc
index 72a37f875d..9113841909 100644
--- a/runtime/native/java_lang_invoke_MethodHandleImpl.cc
+++ b/runtime/native/java_lang_invoke_MethodHandleImpl.cc
@@ -57,7 +57,7 @@ static jobject MethodHandleImpl_getMemberInternal(JNIEnv* env, jobject thiz) {
}
}
- if (UNLIKELY(h_object.Get() == nullptr)) {
+ if (UNLIKELY(h_object == nullptr)) {
soa.Self()->AssertPendingOOMException();
return nullptr;
}
diff --git a/runtime/native/java_lang_reflect_Executable.cc b/runtime/native/java_lang_reflect_Executable.cc
index ee59c4a9e2..2a3942829f 100644
--- a/runtime/native/java_lang_reflect_Executable.cc
+++ b/runtime/native/java_lang_reflect_Executable.cc
@@ -103,7 +103,7 @@ static jobjectArray Executable_getParameters0(JNIEnv* env, jobject javaMethod) {
}
// Validate the MethodParameters system annotation data.
- if (UNLIKELY(names.Get() == nullptr || access_flags.Get() == nullptr)) {
+ if (UNLIKELY(names == nullptr || access_flags == nullptr)) {
ThrowIllegalArgumentException(
StringPrintf("Missing parameter metadata for names or access flags for %s",
art_method->PrettyMethod().c_str()).c_str());
@@ -132,7 +132,7 @@ static jobjectArray Executable_getParameters0(JNIEnv* env, jobject javaMethod) {
mirror::ObjectArray<mirror::Object>::Alloc(self,
parameter_array_class.Get(),
names_count));
- if (UNLIKELY(parameter_array.Get() == nullptr)) {
+ if (UNLIKELY(parameter_array == nullptr)) {
self->AssertPendingException();
return nullptr;
}
@@ -154,7 +154,7 @@ static jobjectArray Executable_getParameters0(JNIEnv* env, jobject javaMethod) {
// Allocate / initialize the Parameter to add to parameter_array.
parameter.Assign(parameter_class->AllocObject(self));
- if (UNLIKELY(parameter.Get() == nullptr)) {
+ if (UNLIKELY(parameter == nullptr)) {
self->AssertPendingOOMException();
return nullptr;
}
diff --git a/runtime/native/libcore_util_CharsetUtils.cc b/runtime/native/libcore_util_CharsetUtils.cc
index 2590452678..e51b6d2a89 100644
--- a/runtime/native/libcore_util_CharsetUtils.cc
+++ b/runtime/native/libcore_util_CharsetUtils.cc
@@ -155,7 +155,7 @@ static jbyteArray charsToBytes(JNIEnv* env, jstring java_string, jint offset, ji
ScopedObjectAccess soa(env);
StackHandleScope<1> hs(soa.Self());
Handle<mirror::String> string(hs.NewHandle(soa.Decode<mirror::String>(java_string)));
- if (string.Get() == nullptr) {
+ if (string == nullptr) {
return nullptr;
}
@@ -192,7 +192,7 @@ static jbyteArray CharsetUtils_toUtf8Bytes(JNIEnv* env, jclass, jstring java_str
ScopedObjectAccess soa(env);
StackHandleScope<1> hs(soa.Self());
Handle<mirror::String> string(hs.NewHandle(soa.Decode<mirror::String>(java_string)));
- if (string.Get() == nullptr) {
+ if (string == nullptr) {
return nullptr;
}
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index c8396a900f..493da271d1 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -273,6 +273,36 @@ inline static bool ReadOatDexFileData(const OatFile& oat_file,
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 @@ bool OatFileBase::Setup(const char* abs_dex_location, std::string* error_msg) {
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 "
diff --git a/runtime/oat_file_assistant_test.cc b/runtime/oat_file_assistant_test.cc
index 6cfe3d1315..9b35489330 100644
--- a/runtime/oat_file_assistant_test.cc
+++ b/runtime/oat_file_assistant_test.cc
@@ -1059,7 +1059,7 @@ TEST_F(OatFileAssistantTest, DexOptStatusValues) {
ClassLinker* linker = Runtime::Current()->GetClassLinker();
Handle<mirror::Class> dexfile(
hs.NewHandle(linker->FindSystemClass(soa.Self(), "Ldalvik/system/DexFile;")));
- ASSERT_FALSE(dexfile.Get() == nullptr);
+ ASSERT_FALSE(dexfile == nullptr);
linker->EnsureInitialized(soa.Self(), dexfile, true, true);
for (std::pair<OatFileAssistant::DexOptNeeded, const char*> field : mapping) {
diff --git a/runtime/oat_file_manager.cc b/runtime/oat_file_manager.cc
index a46b47075c..70796148a4 100644
--- a/runtime/oat_file_manager.cc
+++ b/runtime/oat_file_manager.cc
@@ -342,7 +342,7 @@ static void GetDexFilesFromDexElementsArray(
ScopedObjectAccessAlreadyRunnable& soa,
Handle<mirror::ObjectArray<mirror::Object>> dex_elements,
std::priority_queue<DexFileAndClassPair>* queue) REQUIRES_SHARED(Locks::mutator_lock_) {
- if (dex_elements.Get() == nullptr) {
+ if (dex_elements == nullptr) {
// Nothing to do.
return;
}
@@ -463,14 +463,14 @@ bool OatFileManager::HasCollisions(const OatFile* oat_file,
hs.NewHandle(soa.Decode<mirror::ClassLoader>(class_loader));
Handle<mirror::ObjectArray<mirror::Object>> h_dex_elements =
hs.NewHandle(soa.Decode<mirror::ObjectArray<mirror::Object>>(dex_elements));
- if (h_class_loader.Get() != nullptr &&
+ if (h_class_loader != nullptr &&
GetDexFilesFromClassLoader(soa, h_class_loader.Get(), &queue)) {
class_loader_ok = true;
// In this case, also take into account the dex_elements array, if given. We don't need to
// read it otherwise, as we'll compare against all open oat files anyways.
GetDexFilesFromDexElementsArray(soa, h_dex_elements, &queue);
- } else if (h_class_loader.Get() != nullptr) {
+ } else if (h_class_loader != nullptr) {
VLOG(class_linker) << "Something unsupported with "
<< mirror::Class::PrettyClass(h_class_loader->GetClass());
}
@@ -658,7 +658,7 @@ std::vector<std::unique_ptr<const DexFile>> OatFileManager::OpenDexFilesFromOat(
Handle<mirror::ClassLoader> h_loader(
hs.NewHandle(soa.Decode<mirror::ClassLoader>(class_loader)));
// Can not load app image without class loader.
- if (h_loader.Get() != nullptr) {
+ if (h_loader != nullptr) {
std::string temp_error_msg;
// Add image space has a race condition since other threads could be reading from the
// spaces array.
diff --git a/runtime/object_lock.cc b/runtime/object_lock.cc
index 39ab52fb2d..f6db544276 100644
--- a/runtime/object_lock.cc
+++ b/runtime/object_lock.cc
@@ -24,7 +24,7 @@ namespace art {
template <typename T>
ObjectLock<T>::ObjectLock(Thread* self, Handle<T> object) : self_(self), obj_(object) {
- CHECK(object.Get() != nullptr);
+ CHECK(object != nullptr);
obj_->MonitorEnter(self_);
}
@@ -50,7 +50,7 @@ void ObjectLock<T>::NotifyAll() {
template <typename T>
ObjectTryLock<T>::ObjectTryLock(Thread* self, Handle<T> object) : self_(self), obj_(object) {
- CHECK(object.Get() != nullptr);
+ CHECK(object != nullptr);
acquired_ = obj_->MonitorTryEnter(self_) != nullptr;
}
diff --git a/runtime/openjdkjvmti/ti_class_loader.cc b/runtime/openjdkjvmti/ti_class_loader.cc
index afec0bfac0..d05f579407 100644
--- a/runtime/openjdkjvmti/ti_class_loader.cc
+++ b/runtime/openjdkjvmti/ti_class_loader.cc
@@ -119,11 +119,11 @@ art::ObjPtr<art::mirror::LongArray> ClassLoaderHelper::AllocateNewDexFileCookie(
art::Handle<art::mirror::LongArray> cookie,
const art::DexFile* dex_file) {
art::StackHandleScope<1> hs(self);
- CHECK(cookie.Get() != nullptr);
+ CHECK(cookie != nullptr);
CHECK_GE(cookie->GetLength(), 1);
art::Handle<art::mirror::LongArray> new_cookie(
hs.NewHandle(art::mirror::LongArray::Alloc(self, cookie->GetLength() + 1)));
- if (new_cookie.Get() == nullptr) {
+ if (new_cookie == nullptr) {
self->AssertPendingOOMException();
return nullptr;
}
@@ -183,13 +183,13 @@ art::ObjPtr<art::mirror::Object> ClassLoaderHelper::FindSourceDexFileObject(
// Start navigating the fields of the loader (now known to be a BaseDexClassLoader derivative)
art::Handle<art::mirror::Object> path_list(
hs.NewHandle(path_list_field->GetObject(loader.Get())));
- CHECK(path_list.Get() != nullptr);
+ CHECK(path_list != nullptr);
CHECK(!self->IsExceptionPending());
art::Handle<art::mirror::ObjectArray<art::mirror::Object>> dex_elements_list(hs.NewHandle(
dex_path_list_element_field->GetObject(path_list.Get())->
AsObjectArray<art::mirror::Object>()));
CHECK(!self->IsExceptionPending());
- CHECK(dex_elements_list.Get() != nullptr);
+ CHECK(dex_elements_list != nullptr);
size_t num_elements = dex_elements_list->GetLength();
// Iterate over the DexPathList$Element to find the right one
for (size_t i = 0; i < num_elements; i++) {
diff --git a/runtime/openjdkjvmti/ti_redefine.cc b/runtime/openjdkjvmti/ti_redefine.cc
index 843fd8c8e4..f01acc11aa 100644
--- a/runtime/openjdkjvmti/ti_redefine.cc
+++ b/runtime/openjdkjvmti/ti_redefine.cc
@@ -68,6 +68,66 @@ namespace openjdkjvmti {
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 @@ class ObsoleteMethodStackVisitor : public art::StackVisitor {
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 @@ class ObsoleteMethodStackVisitor : public art::StackVisitor {
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 @@ class ObsoleteMethodStackVisitor : public art::StackVisitor {
}
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 @@ class ObsoleteMethodStackVisitor : public art::StackVisitor {
// 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 @@ class ObsoleteMethodStackVisitor : public art::StackVisitor {
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 @@ class ObsoleteMethodStackVisitor : public art::StackVisitor {
// 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 @@ class ObsoleteMethodStackVisitor : public art::StackVisitor {
// 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 @@ art::mirror::ByteArray* Redefiner::ClassRedefinition::AllocateOrGetOriginalDexFi
}
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 @@ void DoAllocateObsoleteMethodsCallback(art::Thread* t, void* vdata) NO_THREAD_SA
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 @@ void Redefiner::ClassRedefinition::FindAndAllocateObsoleteMethods(art::mirror::C
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 @@ void Redefiner::ClassRedefinition::FindAndAllocateObsoleteMethods(art::mirror::C
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
@@ -939,7 +977,7 @@ bool Redefiner::ClassRedefinition::FinishRemainingAllocations(
art::Handle<art::mirror::Object> dex_file_obj(hs.NewHandle(
ClassLoaderHelper::FindSourceDexFileObject(driver_->self_, loader)));
holder->SetJavaDexFile(klass_index, dex_file_obj.Get());
- if (dex_file_obj.Get() == nullptr) {
+ if (dex_file_obj == nullptr) {
// TODO Better error msg.
RecordFailure(ERR(INTERNAL), "Unable to find dex file!");
return false;
@@ -1212,13 +1250,13 @@ bool Redefiner::ClassRedefinition::EnsureClassAllocationsFinished() {
art::StackHandleScope<2> hs(driver_->self_);
art::Handle<art::mirror::Class> klass(hs.NewHandle(
driver_->self_->DecodeJObject(klass_)->AsClass()));
- if (klass.Get() == nullptr) {
+ if (klass == nullptr) {
RecordFailure(ERR(INVALID_CLASS), "Unable to decode class argument!");
return false;
}
// Allocate the classExt
art::Handle<art::mirror::ClassExt> ext(hs.NewHandle(klass->EnsureExtDataPresent(driver_->self_)));
- if (ext.Get() == nullptr) {
+ if (ext == nullptr) {
// No memory. Clear exception (it's not useful) and return error.
// TODO This doesn't need to be fatal. We could just not support obsolete methods after hitting
// this case.
diff --git a/runtime/openjdkjvmti/ti_redefine.h b/runtime/openjdkjvmti/ti_redefine.h
index c441377b10..65ee2912e2 100644
--- a/runtime/openjdkjvmti/ti_redefine.h
+++ b/runtime/openjdkjvmti/ti_redefine.h
@@ -155,12 +155,6 @@ class Redefiner {
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/openjdkjvmti/ti_threadgroup.cc b/runtime/openjdkjvmti/ti_threadgroup.cc
index e63ce6576a..142387433e 100644
--- a/runtime/openjdkjvmti/ti_threadgroup.cc
+++ b/runtime/openjdkjvmti/ti_threadgroup.cc
@@ -155,7 +155,7 @@ jvmtiError ThreadGroupUtil::GetThreadGroupInfo(jvmtiEnv* env,
static bool IsInDesiredThreadGroup(art::Handle<art::mirror::Object> desired_thread_group,
art::ObjPtr<art::mirror::Object> peer)
REQUIRES_SHARED(art::Locks::mutator_lock_) {
- CHECK(desired_thread_group.Get() != nullptr);
+ CHECK(desired_thread_group != nullptr);
art::ArtField* thread_group_field =
art::jni::DecodeArtField(art::WellKnownClasses::java_lang_Thread_group);
@@ -167,7 +167,7 @@ static bool IsInDesiredThreadGroup(art::Handle<art::mirror::Object> desired_thre
static void GetThreads(art::Handle<art::mirror::Object> thread_group,
std::vector<art::ObjPtr<art::mirror::Object>>* thread_peers)
REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(!art::Locks::thread_list_lock_) {
- CHECK(thread_group.Get() != nullptr);
+ CHECK(thread_group != nullptr);
art::MutexLock mu(art::Thread::Current(), *art::Locks::thread_list_lock_);
for (art::Thread* t : art::Runtime::Current()->GetThreadList()->GetList()) {
@@ -187,7 +187,7 @@ static void GetThreads(art::Handle<art::mirror::Object> thread_group,
static void GetChildThreadGroups(art::Handle<art::mirror::Object> thread_group,
std::vector<art::ObjPtr<art::mirror::Object>>* thread_groups)
REQUIRES_SHARED(art::Locks::mutator_lock_) {
- CHECK(thread_group.Get() != nullptr);
+ CHECK(thread_group != nullptr);
// Get the ThreadGroup[] "groups" out of this thread group...
art::ArtField* groups_field =
diff --git a/runtime/proxy_test.cc b/runtime/proxy_test.cc
index 1292a819a3..5748475163 100644
--- a/runtime/proxy_test.cc
+++ b/runtime/proxy_test.cc
@@ -114,8 +114,8 @@ TEST_F(ProxyTest, ProxyClassHelper) {
class_linker_->FindClass(soa.Self(), "LInterfaces$I;", class_loader)));
Handle<mirror::Class> J(hs.NewHandle(
class_linker_->FindClass(soa.Self(), "LInterfaces$J;", class_loader)));
- ASSERT_TRUE(I.Get() != nullptr);
- ASSERT_TRUE(J.Get() != nullptr);
+ ASSERT_TRUE(I != nullptr);
+ ASSERT_TRUE(J != nullptr);
std::vector<mirror::Class*> interfaces;
interfaces.push_back(I.Get());
@@ -123,7 +123,7 @@ TEST_F(ProxyTest, ProxyClassHelper) {
Handle<mirror::Class> proxy_class(hs.NewHandle(
GenerateProxyClass(soa, jclass_loader, "$Proxy1234", interfaces)));
interfaces.clear(); // Don't least possibly stale objects in the array as good practice.
- ASSERT_TRUE(proxy_class.Get() != nullptr);
+ ASSERT_TRUE(proxy_class != nullptr);
ASSERT_TRUE(proxy_class->IsProxyClass());
ASSERT_TRUE(proxy_class->IsInitialized());
@@ -148,8 +148,8 @@ TEST_F(ProxyTest, ProxyFieldHelper) {
class_linker_->FindClass(soa.Self(), "LInterfaces$I;", class_loader)));
Handle<mirror::Class> J(hs.NewHandle(
class_linker_->FindClass(soa.Self(), "LInterfaces$J;", class_loader)));
- ASSERT_TRUE(I.Get() != nullptr);
- ASSERT_TRUE(J.Get() != nullptr);
+ ASSERT_TRUE(I != nullptr);
+ ASSERT_TRUE(J != nullptr);
Handle<mirror::Class> proxyClass;
{
@@ -159,7 +159,7 @@ TEST_F(ProxyTest, ProxyFieldHelper) {
proxyClass = hs.NewHandle(GenerateProxyClass(soa, jclass_loader, "$Proxy1234", interfaces));
}
- ASSERT_TRUE(proxyClass.Get() != nullptr);
+ ASSERT_TRUE(proxyClass != nullptr);
ASSERT_TRUE(proxyClass->IsProxyClass());
ASSERT_TRUE(proxyClass->IsInitialized());
@@ -171,10 +171,10 @@ TEST_F(ProxyTest, ProxyFieldHelper) {
Handle<mirror::Class> interfacesFieldClass(
hs.NewHandle(class_linker_->FindSystemClass(soa.Self(), "[Ljava/lang/Class;")));
- ASSERT_TRUE(interfacesFieldClass.Get() != nullptr);
+ ASSERT_TRUE(interfacesFieldClass != nullptr);
Handle<mirror::Class> throwsFieldClass(
hs.NewHandle(class_linker_->FindSystemClass(soa.Self(), "[[Ljava/lang/Class;")));
- ASSERT_TRUE(throwsFieldClass.Get() != nullptr);
+ ASSERT_TRUE(throwsFieldClass != nullptr);
// Test "Class[] interfaces" field.
ArtField* field = &static_fields->At(0);
@@ -208,10 +208,10 @@ TEST_F(ProxyTest, CheckArtMirrorFieldsOfProxyStaticFields) {
proxyClass1 = hs.NewHandle(GenerateProxyClass(soa, jclass_loader, "$Proxy1", interfaces));
}
- ASSERT_TRUE(proxyClass0.Get() != nullptr);
+ ASSERT_TRUE(proxyClass0 != nullptr);
ASSERT_TRUE(proxyClass0->IsProxyClass());
ASSERT_TRUE(proxyClass0->IsInitialized());
- ASSERT_TRUE(proxyClass1.Get() != nullptr);
+ ASSERT_TRUE(proxyClass1 != nullptr);
ASSERT_TRUE(proxyClass1->IsProxyClass());
ASSERT_TRUE(proxyClass1->IsInitialized());
diff --git a/runtime/reference_table_test.cc b/runtime/reference_table_test.cc
index 9523e92d7c..4ccfb6d83b 100644
--- a/runtime/reference_table_test.cc
+++ b/runtime/reference_table_test.cc
@@ -48,12 +48,12 @@ static mirror::Object* CreateWeakReference(mirror::Object* referent)
class_linker->FindClass(self,
"Ljava/lang/ref/WeakReference;",
ScopedNullHandle<mirror::ClassLoader>())));
- CHECK(h_ref_class.Get() != nullptr);
+ CHECK(h_ref_class != nullptr);
CHECK(class_linker->EnsureInitialized(self, h_ref_class, true, true));
Handle<mirror::Object> h_ref_instance(scope.NewHandle<mirror::Object>(
h_ref_class->AllocObject(self)));
- CHECK(h_ref_instance.Get() != nullptr);
+ CHECK(h_ref_instance != nullptr);
ArtMethod* constructor = h_ref_class->FindDeclaredDirectMethod(
"<init>", "(Ljava/lang/Object;)V", class_linker->GetImagePointerSize());
diff --git a/runtime/reflection.cc b/runtime/reflection.cc
index a2b4cb37a9..3c64d40720 100644
--- a/runtime/reflection.cc
+++ b/runtime/reflection.cc
@@ -231,8 +231,8 @@ class ArgArray {
hs.NewHandle<mirror::ObjectArray<mirror::Object>>(raw_args));
for (size_t i = 1, args_offset = 0; i < shorty_len_; ++i, ++args_offset) {
arg.Assign(args->Get(args_offset));
- if (((shorty_[i] == 'L') && (arg.Get() != nullptr)) ||
- ((arg.Get() == nullptr && shorty_[i] != 'L'))) {
+ if (((shorty_[i] == 'L') && (arg != nullptr)) ||
+ ((arg == nullptr && shorty_[i] != 'L'))) {
// TODO: The method's parameter's type must have been previously resolved, yet
// we've seen cases where it's not b/34440020.
ObjPtr<mirror::Class> dst_class(
@@ -242,7 +242,7 @@ class ArgArray {
CHECK(self->IsExceptionPending());
return false;
}
- if (UNLIKELY(arg.Get() == nullptr || !arg->InstanceOf(dst_class))) {
+ if (UNLIKELY(arg == nullptr || !arg->InstanceOf(dst_class))) {
ThrowIllegalArgumentException(
StringPrintf("method %s argument %zd has type %s, got %s",
m->PrettyMethod(false).c_str(),
@@ -254,13 +254,13 @@ class ArgArray {
}
#define DO_FIRST_ARG(match_descriptor, get_fn, append) { \
- if (LIKELY(arg.Get() != nullptr && \
+ if (LIKELY(arg != nullptr && \
arg->GetClass()->DescriptorEquals(match_descriptor))) { \
ArtField* primitive_field = arg->GetClass()->GetInstanceField(0); \
append(primitive_field-> get_fn(arg.Get()));
#define DO_ARG(match_descriptor, get_fn, append) \
- } else if (LIKELY(arg.Get() != nullptr && \
+ } else if (LIKELY(arg != nullptr && \
arg->GetClass<>()->DescriptorEquals(match_descriptor))) { \
ArtField* primitive_field = arg->GetClass()->GetInstanceField(0); \
append(primitive_field-> get_fn(arg.Get()));
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 9609bee022..f8f3d766c0 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 @@ void Runtime::VisitConstantRoots(RootVisitor* visitor) {
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/runtime_callbacks_test.cc b/runtime/runtime_callbacks_test.cc
index f1e78b40e0..abe99e0d50 100644
--- a/runtime/runtime_callbacks_test.cc
+++ b/runtime/runtime_callbacks_test.cc
@@ -294,7 +294,7 @@ TEST_F(ClassLoadCallbackRuntimeCallbacksTest, ClassLoadCallback) {
const char* descriptor_y = "LY;";
Handle<mirror::Class> h_Y(
hs.NewHandle(class_linker_->FindClass(soa.Self(), descriptor_y, class_loader)));
- ASSERT_TRUE(h_Y.Get() != nullptr);
+ ASSERT_TRUE(h_Y != nullptr);
bool expect1 = Expect({ "PreDefine:LY; <art-gtest-XandY.jar>",
"PreDefine:LX; <art-gtest-XandY.jar>",
diff --git a/runtime/stack.cc b/runtime/stack.cc
index d7ba1d75d8..51a24e4e01 100644
--- a/runtime/stack.cc
+++ b/runtime/stack.cc
@@ -874,9 +874,13 @@ void StackVisitor::WalkStack(bool include_transitions) {
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 @@ void StackVisitor::WalkStack(bool include_transitions) {
<< " native=" << method->IsNative()
<< std::noboolalpha
<< " entrypoints=" << method->GetEntryPointFromQuickCompiledCode()
- << "," << method->GetEntryPointFromJni()
+ << "," << (method->IsNative() ? method->GetEntryPointFromJni() : nullptr)
<< " next=" << *cur_quick_frame_;
}
diff --git a/runtime/stack_map.h b/runtime/stack_map.h
index 61d6a5847c..f7a64026b7 100644
--- a/runtime/stack_map.h
+++ b/runtime/stack_map.h
@@ -747,6 +747,7 @@ class StackMapEncoding {
return total_bit_size_;
}
+ // Encode the encoding into the vector.
template<typename Vector>
void Encode(Vector* dest) const {
static_assert(alignof(StackMapEncoding) == 1, "Should not require alignment");
@@ -754,6 +755,7 @@ class StackMapEncoding {
dest->insert(dest->end(), ptr, ptr + sizeof(*this));
}
+ // Decode the encoding from a pointer, updates the pointer.
void Decode(const uint8_t** ptr) {
*this = *reinterpret_cast<const StackMapEncoding*>(*ptr);
*ptr += sizeof(*this);
@@ -924,6 +926,7 @@ class InlineInfoEncoding {
void Dump(VariableIndentationOutputStream* vios) const;
+ // Encode the encoding into the vector.
template<typename Vector>
void Encode(Vector* dest) const {
static_assert(alignof(InlineInfoEncoding) == 1, "Should not require alignment");
@@ -931,6 +934,7 @@ class InlineInfoEncoding {
dest->insert(dest->end(), ptr, ptr + sizeof(*this));
}
+ // Decode the encoding from a pointer, updates the pointer.
void Decode(const uint8_t** ptr) {
*this = *reinterpret_cast<const InlineInfoEncoding*>(*ptr);
*ptr += sizeof(*this);
@@ -1171,6 +1175,7 @@ struct CodeInfoEncoding {
ComputeTableOffsets();
}
+ // Compress is not const since it calculates cache_header_size. This is used by PrepareForFillIn.
template<typename Vector>
void Compress(Vector* dest) {
dex_register_map.Encode(dest);
@@ -1210,9 +1215,9 @@ struct CodeInfoEncoding {
private:
// Computed fields (not serialized).
- // Header size in bytes.
+ // Header size in bytes, cached to avoid needing to re-decoding the encoding in HeaderSize.
uint32_t cache_header_size = kInvalidSize;
- // Non header size in bytes.
+ // Non header size in bytes, cached to avoid needing to re-decoding the encoding in NonHeaderSize.
uint32_t cache_non_header_size = kInvalidSize;
};
@@ -1221,7 +1226,13 @@ struct CodeInfoEncoding {
* The information is of the form:
*
* [CodeInfoEncoding, DexRegisterMap+, DexLocationCatalog+, StackMap+, RegisterMask+, StackMask+,
- * DexRegisterMap+, InlineInfo*]
+ * InlineInfo*]
+ *
+ * where CodeInfoEncoding is of the form:
+ *
+ * [ByteSizedTable(dex_register_map), ByteSizedTable(location_catalog),
+ * BitEncodingTable<StackMapEncoding>, BitEncodingTable<BitRegionEncoding>,
+ * BitEncodingTable<BitRegionEncoding>, BitEncodingTable<InlineInfoEncoding>]
*/
class CodeInfo {
public:
@@ -1331,7 +1342,9 @@ class CodeInfo {
}
InlineInfo GetInlineInfo(size_t index, const CodeInfoEncoding& encoding) const {
- // Since we do not know the depth, we just return the whole remaining map.
+ // Since we do not know the depth, we just return the whole remaining map. The caller may
+ // access the inline info for arbitrary depths. To return the precise inline info we would need
+ // to count the depth before returning.
// TODO: Clean this up.
const size_t bit_offset = encoding.inline_info.bit_offset +
index * encoding.inline_info.encoding.BitSize();
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 7b6540436a..f33da18e5f 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -874,7 +874,7 @@ void Thread::CreatePeer(const char* name, bool as_daemon, jobject thread_group)
ScopedObjectAccess soa(self);
StackHandleScope<1> hs(self);
MutableHandle<mirror::String> peer_thread_name(hs.NewHandle(GetThreadName()));
- if (peer_thread_name.Get() == nullptr) {
+ if (peer_thread_name == nullptr) {
// The Thread constructor should have set the Thread.name to a
// non-null value. However, because we can run without code
// available (in the compiler, in tests), we manually assign the
@@ -887,7 +887,7 @@ void Thread::CreatePeer(const char* name, bool as_daemon, jobject thread_group)
peer_thread_name.Assign(GetThreadName());
}
// 'thread_name' may have been null, so don't trust 'peer_thread_name' to be non-null.
- if (peer_thread_name.Get() != nullptr) {
+ if (peer_thread_name != nullptr) {
SetThreadName(peer_thread_name->ToModifiedUtf8().c_str());
}
}
@@ -2284,7 +2284,7 @@ class BuildInternalStackTraceVisitor : public StackVisitor {
Handle<mirror::ObjectArray<mirror::Object>> trace(
hs.NewHandle(
mirror::ObjectArray<mirror::Object>::Alloc(hs.Self(), array_class, depth + 1)));
- if (trace.Get() == nullptr) {
+ if (trace == nullptr) {
// Acquire uninterruptible_ in all paths.
self_->StartAssertNoThreadSuspension("Building internal stack trace");
self_->AssertPendingOOMException();
@@ -2479,14 +2479,14 @@ jobjectArray Thread::InternalStackTraceToStackTraceElementArray(
std::string class_name(PrettyDescriptor(descriptor));
class_name_object.Assign(
mirror::String::AllocFromModifiedUtf8(soa.Self(), class_name.c_str()));
- if (class_name_object.Get() == nullptr) {
+ if (class_name_object == nullptr) {
soa.Self()->AssertPendingOOMException();
return nullptr;
}
const char* source_file = method->GetDeclaringClassSourceFile();
if (source_file != nullptr) {
source_name_object.Assign(mirror::String::AllocFromModifiedUtf8(soa.Self(), source_file));
- if (source_name_object.Get() == nullptr) {
+ if (source_name_object == nullptr) {
soa.Self()->AssertPendingOOMException();
return nullptr;
}
@@ -2496,7 +2496,7 @@ jobjectArray Thread::InternalStackTraceToStackTraceElementArray(
CHECK(method_name != nullptr);
Handle<mirror::String> method_name_object(
hs.NewHandle(mirror::String::AllocFromModifiedUtf8(soa.Self(), method_name)));
- if (method_name_object.Get() == nullptr) {
+ if (method_name_object == nullptr) {
return nullptr;
}
ObjPtr<mirror::StackTraceElement> obj =mirror::StackTraceElement::Alloc(soa.Self(),
@@ -2554,7 +2554,7 @@ void Thread::ThrowNewWrappedException(const char* exception_class_descriptor,
auto* cl = runtime->GetClassLinker();
Handle<mirror::Class> exception_class(
hs.NewHandle(cl->FindClass(this, exception_class_descriptor, class_loader)));
- if (UNLIKELY(exception_class.Get() == nullptr)) {
+ if (UNLIKELY(exception_class == nullptr)) {
CHECK(IsExceptionPending());
LOG(ERROR) << "No exception class " << PrettyDescriptor(exception_class_descriptor);
return;
@@ -2570,7 +2570,7 @@ void Thread::ThrowNewWrappedException(const char* exception_class_descriptor,
hs.NewHandle(ObjPtr<mirror::Throwable>::DownCast(exception_class->AllocObject(this))));
// If we couldn't allocate the exception, throw the pre-allocated out of memory exception.
- if (exception.Get() == nullptr) {
+ if (exception == nullptr) {
SetException(Runtime::Current()->GetPreAllocatedOutOfMemoryError());
return;
}
diff --git a/runtime/transaction_test.cc b/runtime/transaction_test.cc
index a43c967092..97c1228038 100644
--- a/runtime/transaction_test.cc
+++ b/runtime/transaction_test.cc
@@ -35,7 +35,7 @@ class TransactionTest : public CommonRuntimeTest {
StackHandleScope<2> hs(soa.Self());
Handle<mirror::ClassLoader> class_loader(
hs.NewHandle(soa.Decode<mirror::ClassLoader>(jclass_loader)));
- ASSERT_TRUE(class_loader.Get() != nullptr);
+ ASSERT_TRUE(class_loader != nullptr);
// Load and initialize java.lang.ExceptionInInitializerError and the exception class used
// to abort transaction so they can be thrown during class initialization if the transaction
@@ -43,26 +43,26 @@ class TransactionTest : public CommonRuntimeTest {
MutableHandle<mirror::Class> h_klass(
hs.NewHandle(class_linker_->FindSystemClass(soa.Self(),
"Ljava/lang/ExceptionInInitializerError;")));
- ASSERT_TRUE(h_klass.Get() != nullptr);
+ ASSERT_TRUE(h_klass != nullptr);
class_linker_->EnsureInitialized(soa.Self(), h_klass, true, true);
ASSERT_TRUE(h_klass->IsInitialized());
h_klass.Assign(class_linker_->FindSystemClass(soa.Self(),
Transaction::kAbortExceptionSignature));
- ASSERT_TRUE(h_klass.Get() != nullptr);
+ ASSERT_TRUE(h_klass != nullptr);
class_linker_->EnsureInitialized(soa.Self(), h_klass, true, true);
ASSERT_TRUE(h_klass->IsInitialized());
// Load and verify utility class.
h_klass.Assign(class_linker_->FindClass(soa.Self(), "LTransaction$AbortHelperClass;",
class_loader));
- ASSERT_TRUE(h_klass.Get() != nullptr);
+ ASSERT_TRUE(h_klass != nullptr);
class_linker_->VerifyClass(soa.Self(), h_klass);
ASSERT_TRUE(h_klass->IsVerified());
// Load and verify tested class.
h_klass.Assign(class_linker_->FindClass(soa.Self(), tested_class_signature, class_loader));
- ASSERT_TRUE(h_klass.Get() != nullptr);
+ ASSERT_TRUE(h_klass != nullptr);
class_linker_->VerifyClass(soa.Self(), h_klass);
ASSERT_TRUE(h_klass->IsVerified());
@@ -95,12 +95,12 @@ TEST_F(TransactionTest, Object_class) {
StackHandleScope<2> hs(soa.Self());
Handle<mirror::Class> h_klass(
hs.NewHandle(class_linker_->FindSystemClass(soa.Self(), "Ljava/lang/Object;")));
- ASSERT_TRUE(h_klass.Get() != nullptr);
+ ASSERT_TRUE(h_klass != nullptr);
Transaction transaction;
Runtime::Current()->EnterTransactionMode(&transaction);
Handle<mirror::Object> h_obj(hs.NewHandle(h_klass->AllocObject(soa.Self())));
- ASSERT_TRUE(h_obj.Get() != nullptr);
+ ASSERT_TRUE(h_obj != nullptr);
ASSERT_EQ(h_obj->GetClass(), h_klass.Get());
Runtime::Current()->ExitTransactionMode();
@@ -115,9 +115,9 @@ TEST_F(TransactionTest, Object_monitor) {
StackHandleScope<2> hs(soa.Self());
Handle<mirror::Class> h_klass(
hs.NewHandle(class_linker_->FindSystemClass(soa.Self(), "Ljava/lang/Object;")));
- ASSERT_TRUE(h_klass.Get() != nullptr);
+ ASSERT_TRUE(h_klass != nullptr);
Handle<mirror::Object> h_obj(hs.NewHandle(h_klass->AllocObject(soa.Self())));
- ASSERT_TRUE(h_obj.Get() != nullptr);
+ ASSERT_TRUE(h_obj != nullptr);
ASSERT_EQ(h_obj->GetClass(), h_klass.Get());
// Lock object's monitor outside the transaction.
@@ -144,7 +144,7 @@ TEST_F(TransactionTest, Array_length) {
StackHandleScope<2> hs(soa.Self());
Handle<mirror::Class> h_klass(
hs.NewHandle(class_linker_->FindSystemClass(soa.Self(), "[Ljava/lang/Object;")));
- ASSERT_TRUE(h_klass.Get() != nullptr);
+ ASSERT_TRUE(h_klass != nullptr);
constexpr int32_t kArraySize = 2;
@@ -157,7 +157,7 @@ TEST_F(TransactionTest, Array_length) {
mirror::Array::Alloc<true>(soa.Self(), h_klass.Get(), kArraySize,
h_klass->GetComponentSizeShift(),
Runtime::Current()->GetHeap()->GetCurrentAllocator())));
- ASSERT_TRUE(h_obj.Get() != nullptr);
+ ASSERT_TRUE(h_obj != nullptr);
ASSERT_EQ(h_obj->GetClass(), h_klass.Get());
Runtime::Current()->ExitTransactionMode();
@@ -172,11 +172,11 @@ TEST_F(TransactionTest, StaticFieldsTest) {
StackHandleScope<4> hs(soa.Self());
Handle<mirror::ClassLoader> class_loader(
hs.NewHandle(soa.Decode<mirror::ClassLoader>(LoadDex("Transaction"))));
- ASSERT_TRUE(class_loader.Get() != nullptr);
+ ASSERT_TRUE(class_loader != nullptr);
Handle<mirror::Class> h_klass(
hs.NewHandle(class_linker_->FindClass(soa.Self(), "LStaticFieldsTest;", class_loader)));
- ASSERT_TRUE(h_klass.Get() != nullptr);
+ ASSERT_TRUE(h_klass != nullptr);
bool success = class_linker_->EnsureInitialized(soa.Self(), h_klass, true, true);
ASSERT_TRUE(success);
ASSERT_TRUE(h_klass->IsInitialized());
@@ -232,9 +232,9 @@ TEST_F(TransactionTest, StaticFieldsTest) {
// Create a java.lang.Object instance to set objectField.
Handle<mirror::Class> object_klass(
hs.NewHandle(class_linker_->FindSystemClass(soa.Self(), "Ljava/lang/Object;")));
- ASSERT_TRUE(object_klass.Get() != nullptr);
+ ASSERT_TRUE(object_klass != nullptr);
Handle<mirror::Object> h_obj(hs.NewHandle(h_klass->AllocObject(soa.Self())));
- ASSERT_TRUE(h_obj.Get() != nullptr);
+ ASSERT_TRUE(h_obj != nullptr);
ASSERT_EQ(h_obj->GetClass(), h_klass.Get());
// Modify fields inside transaction then rollback changes.
@@ -270,11 +270,11 @@ TEST_F(TransactionTest, InstanceFieldsTest) {
StackHandleScope<5> hs(soa.Self());
Handle<mirror::ClassLoader> class_loader(
hs.NewHandle(soa.Decode<mirror::ClassLoader>(LoadDex("Transaction"))));
- ASSERT_TRUE(class_loader.Get() != nullptr);
+ ASSERT_TRUE(class_loader != nullptr);
Handle<mirror::Class> h_klass(
hs.NewHandle(class_linker_->FindClass(soa.Self(), "LInstanceFieldsTest;", class_loader)));
- ASSERT_TRUE(h_klass.Get() != nullptr);
+ ASSERT_TRUE(h_klass != nullptr);
bool success = class_linker_->EnsureInitialized(soa.Self(), h_klass, true, true);
ASSERT_TRUE(success);
ASSERT_TRUE(h_klass->IsInitialized());
@@ -282,7 +282,7 @@ TEST_F(TransactionTest, InstanceFieldsTest) {
// Allocate an InstanceFieldTest object.
Handle<mirror::Object> h_instance(hs.NewHandle(h_klass->AllocObject(soa.Self())));
- ASSERT_TRUE(h_instance.Get() != nullptr);
+ ASSERT_TRUE(h_instance != nullptr);
// Lookup fields.
ArtField* booleanField = h_klass->FindDeclaredInstanceField("booleanField", "Z");
@@ -334,9 +334,9 @@ TEST_F(TransactionTest, InstanceFieldsTest) {
// Create a java.lang.Object instance to set objectField.
Handle<mirror::Class> object_klass(
hs.NewHandle(class_linker_->FindSystemClass(soa.Self(), "Ljava/lang/Object;")));
- ASSERT_TRUE(object_klass.Get() != nullptr);
+ ASSERT_TRUE(object_klass != nullptr);
Handle<mirror::Object> h_obj(hs.NewHandle(h_klass->AllocObject(soa.Self())));
- ASSERT_TRUE(h_obj.Get() != nullptr);
+ ASSERT_TRUE(h_obj != nullptr);
ASSERT_EQ(h_obj->GetClass(), h_klass.Get());
// Modify fields inside transaction then rollback changes.
@@ -372,11 +372,11 @@ TEST_F(TransactionTest, StaticArrayFieldsTest) {
StackHandleScope<4> hs(soa.Self());
Handle<mirror::ClassLoader> class_loader(
hs.NewHandle(soa.Decode<mirror::ClassLoader>(LoadDex("Transaction"))));
- ASSERT_TRUE(class_loader.Get() != nullptr);
+ ASSERT_TRUE(class_loader != nullptr);
Handle<mirror::Class> h_klass(
hs.NewHandle(class_linker_->FindClass(soa.Self(), "LStaticArrayFieldsTest;", class_loader)));
- ASSERT_TRUE(h_klass.Get() != nullptr);
+ ASSERT_TRUE(h_klass != nullptr);
bool success = class_linker_->EnsureInitialized(soa.Self(), h_klass, true, true);
ASSERT_TRUE(success);
ASSERT_TRUE(h_klass->IsInitialized());
@@ -451,9 +451,9 @@ TEST_F(TransactionTest, StaticArrayFieldsTest) {
// Create a java.lang.Object instance to set objectField.
Handle<mirror::Class> object_klass(
hs.NewHandle(class_linker_->FindSystemClass(soa.Self(), "Ljava/lang/Object;")));
- ASSERT_TRUE(object_klass.Get() != nullptr);
+ ASSERT_TRUE(object_klass != nullptr);
Handle<mirror::Object> h_obj(hs.NewHandle(h_klass->AllocObject(soa.Self())));
- ASSERT_TRUE(h_obj.Get() != nullptr);
+ ASSERT_TRUE(h_obj != nullptr);
ASSERT_EQ(h_obj->GetClass(), h_klass.Get());
// Modify fields inside transaction then rollback changes.
@@ -489,15 +489,15 @@ TEST_F(TransactionTest, ResolveString) {
StackHandleScope<3> hs(soa.Self());
Handle<mirror::ClassLoader> class_loader(
hs.NewHandle(soa.Decode<mirror::ClassLoader>(LoadDex("Transaction"))));
- ASSERT_TRUE(class_loader.Get() != nullptr);
+ ASSERT_TRUE(class_loader != nullptr);
Handle<mirror::Class> h_klass(
hs.NewHandle(class_linker_->FindClass(soa.Self(), "LTransaction$ResolveString;",
class_loader)));
- ASSERT_TRUE(h_klass.Get() != nullptr);
+ ASSERT_TRUE(h_klass != nullptr);
Handle<mirror::DexCache> h_dex_cache(hs.NewHandle(h_klass->GetDexCache()));
- ASSERT_TRUE(h_dex_cache.Get() != nullptr);
+ ASSERT_TRUE(h_dex_cache != nullptr);
const DexFile* const dex_file = h_dex_cache->GetDexFile();
ASSERT_TRUE(dex_file != nullptr);
@@ -538,12 +538,12 @@ TEST_F(TransactionTest, EmptyClass) {
StackHandleScope<2> hs(soa.Self());
Handle<mirror::ClassLoader> class_loader(
hs.NewHandle(soa.Decode<mirror::ClassLoader>(LoadDex("Transaction"))));
- ASSERT_TRUE(class_loader.Get() != nullptr);
+ ASSERT_TRUE(class_loader != nullptr);
Handle<mirror::Class> h_klass(
hs.NewHandle(class_linker_->FindClass(soa.Self(), "LTransaction$EmptyStatic;",
class_loader)));
- ASSERT_TRUE(h_klass.Get() != nullptr);
+ ASSERT_TRUE(h_klass != nullptr);
class_linker_->VerifyClass(soa.Self(), h_klass);
ASSERT_TRUE(h_klass->IsVerified());
@@ -562,12 +562,12 @@ TEST_F(TransactionTest, StaticFieldClass) {
StackHandleScope<2> hs(soa.Self());
Handle<mirror::ClassLoader> class_loader(
hs.NewHandle(soa.Decode<mirror::ClassLoader>(LoadDex("Transaction"))));
- ASSERT_TRUE(class_loader.Get() != nullptr);
+ ASSERT_TRUE(class_loader != nullptr);
Handle<mirror::Class> h_klass(
hs.NewHandle(class_linker_->FindClass(soa.Self(), "LTransaction$StaticFieldClass;",
class_loader)));
- ASSERT_TRUE(h_klass.Get() != nullptr);
+ ASSERT_TRUE(h_klass != nullptr);
class_linker_->VerifyClass(soa.Self(), h_klass);
ASSERT_TRUE(h_klass->IsVerified());
diff --git a/runtime/utils.h b/runtime/utils.h
index 67438b5881..96e5bfa8ec 100644
--- a/runtime/utils.h
+++ b/runtime/utils.h
@@ -301,6 +301,30 @@ constexpr PointerSize ConvertToPointerSize(T any) {
}
}
+// 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 bd1b044dae..98658215f7 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 @@ inline DexCacheArraysLayout::DexCacheArraysLayout(PointerSize pointer_size,
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::MethodTypesSize(size_t num_elements) const {
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 7d4b23a8dd..ed677ed3f4 100644
--- a/runtime/utils/dex_cache_arrays_layout.h
+++ b/runtime/utils/dex_cache_arrays_layout.h
@@ -37,11 +37,14 @@ class DexCacheArraysLayout {
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 @@ class DexCacheArraysLayout {
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 @@ class DexCacheArraysLayout {
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 02f1e1bbfe..634bd47f05 100644
--- a/runtime/utils_test.cc
+++ b/runtime/utils_test.cc
@@ -408,4 +408,23 @@ TEST_F(UtilsTest, IsValidDescriptor) {
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 5f55f3fd29..16739fa3bc 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -3114,6 +3114,44 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) {
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(&param_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(&reg_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 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) {
/* 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 @@ void MethodVerifier::VerifyInvocationArgsUnresolvedMethod(const Instruction* ins
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 fa5a698423..7b67967c28 100644
--- a/runtime/verifier/method_verifier.h
+++ b/runtime/verifier/method_verifier.h
@@ -697,6 +697,11 @@ class MethodVerifier {
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/runtime/verifier/verifier_deps.cc b/runtime/verifier/verifier_deps.cc
index 113160785c..000cf7c393 100644
--- a/runtime/verifier/verifier_deps.cc
+++ b/runtime/verifier/verifier_deps.cc
@@ -890,12 +890,12 @@ bool VerifierDeps::VerifyAssignability(Handle<mirror::ClassLoader> class_loader,
source.Assign(
FindClassAndClearException(class_linker, self, source_desc.c_str(), class_loader));
- if (destination.Get() == nullptr) {
+ if (destination == nullptr) {
LOG(INFO) << "VerifiersDeps: Could not resolve class " << destination_desc;
return false;
}
- if (source.Get() == nullptr) {
+ if (source == nullptr) {
LOG(INFO) << "VerifierDeps: Could not resolve class " << source_desc;
return false;
}
@@ -925,7 +925,7 @@ bool VerifierDeps::VerifyClasses(Handle<mirror::ClassLoader> class_loader,
cls.Assign(FindClassAndClearException(class_linker, self, descriptor, class_loader));
if (entry.IsResolved()) {
- if (cls.Get() == nullptr) {
+ if (cls == nullptr) {
LOG(INFO) << "VerifierDeps: Could not resolve class " << descriptor;
return false;
} else if (entry.GetAccessFlags() != GetAccessFlags(cls.Get())) {
@@ -939,7 +939,7 @@ bool VerifierDeps::VerifyClasses(Handle<mirror::ClassLoader> class_loader,
<< std::dec;
return false;
}
- } else if (cls.Get() != nullptr) {
+ } else if (cls != nullptr) {
LOG(INFO) << "VerifierDeps: Unexpected successful resolution of class " << descriptor;
return false;
}
diff --git a/runtime/zip_archive.cc b/runtime/zip_archive.cc
index cd79bb61f3..416873f4c3 100644
--- a/runtime/zip_archive.cc
+++ b/runtime/zip_archive.cc
@@ -23,10 +23,16 @@
#include <unistd.h>
#include <vector>
+#include "android-base/stringprintf.h"
#include "base/unix_file/fd_file.h"
namespace art {
+// Log file contents and mmap info when mapping entries directly.
+static constexpr const bool kDebugZipMapDirectly = false;
+
+using android::base::StringPrintf;
+
uint32_t ZipEntry::GetUncompressedLength() {
return zip_entry_->uncompressed_length;
}
@@ -35,6 +41,15 @@ uint32_t ZipEntry::GetCrc32() {
return zip_entry_->crc32;
}
+bool ZipEntry::IsUncompressed() {
+ return zip_entry_->method == kCompressStored;
+}
+
+bool ZipEntry::IsAlignedTo(size_t alignment) {
+ DCHECK(IsPowerOfTwo(alignment)) << alignment;
+ return IsAlignedParam(zip_entry_->offset, static_cast<int>(alignment));
+}
+
ZipEntry::~ZipEntry() {
delete zip_entry_;
}
@@ -73,6 +88,102 @@ MemMap* ZipEntry::ExtractToMemMap(const char* zip_filename, const char* entry_fi
return map.release();
}
+MemMap* ZipEntry::MapDirectlyFromFile(const char* zip_filename, std::string* error_msg) {
+ const int zip_fd = GetFileDescriptor(handle_);
+ const char* entry_filename = entry_name_.c_str();
+
+ // Should not happen since we don't have a memory ZipArchive constructor.
+ // However the underlying ZipArchive isn't required to have an FD,
+ // so check to be sure.
+ CHECK_GE(zip_fd, 0) <<
+ StringPrintf("Cannot map '%s' (in zip '%s') directly because the zip archive "
+ "is not file backed.",
+ entry_filename,
+ zip_filename);
+
+ if (!IsUncompressed()) {
+ *error_msg = StringPrintf("Cannot map '%s' (in zip '%s') directly because it is compressed.",
+ entry_filename,
+ zip_filename);
+ return nullptr;
+ } else if (zip_entry_->uncompressed_length != zip_entry_->compressed_length) {
+ *error_msg = StringPrintf("Cannot map '%s' (in zip '%s') directly because "
+ "entry has bad size (%u != %u).",
+ entry_filename,
+ zip_filename,
+ zip_entry_->uncompressed_length,
+ zip_entry_->compressed_length);
+ return nullptr;
+ }
+
+ std::string name(entry_filename);
+ name += " mapped directly in memory from ";
+ name += zip_filename;
+
+ const off_t offset = zip_entry_->offset;
+
+ if (kDebugZipMapDirectly) {
+ LOG(INFO) << "zip_archive: " << "make mmap of " << name << " @ offset = " << offset;
+ }
+
+ std::unique_ptr<MemMap> map(
+ MemMap::MapFileAtAddress(nullptr, // Expected pointer address
+ GetUncompressedLength(), // Byte count
+ PROT_READ | PROT_WRITE,
+ MAP_PRIVATE,
+ zip_fd,
+ offset,
+ false, // Don't restrict allocation to lower4GB
+ false, // Doesn't overlap existing map (reuse=false)
+ name.c_str(),
+ /*out*/error_msg));
+
+ if (map == nullptr) {
+ DCHECK(!error_msg->empty());
+ }
+
+ if (kDebugZipMapDirectly) {
+ // Dump contents of file, same format as using this shell command:
+ // $> od -j <offset> -t x1 <zip_filename>
+ static constexpr const int kMaxDumpChars = 15;
+ lseek(zip_fd, 0, SEEK_SET);
+
+ int count = offset + kMaxDumpChars;
+
+ std::string tmp;
+ char buf;
+
+ // Dump file contents.
+ int i = 0;
+ while (read(zip_fd, &buf, 1) > 0 && i < count) {
+ tmp += StringPrintf("%3d ", (unsigned int)buf);
+ ++i;
+ }
+
+ LOG(INFO) << "map_fd raw bytes starting at 0";
+ LOG(INFO) << "" << tmp;
+ LOG(INFO) << "---------------------------";
+
+ // Dump map contents.
+ if (map != nullptr) {
+ tmp = "";
+
+ count = kMaxDumpChars;
+
+ uint8_t* begin = map->Begin();
+ for (i = 0; i < count; ++i) {
+ tmp += StringPrintf("%3d ", (unsigned int)begin[i]);
+ }
+
+ LOG(INFO) << "map address " << StringPrintf("%p", begin);
+ LOG(INFO) << "map first " << kMaxDumpChars << " chars:";
+ LOG(INFO) << tmp;
+ }
+ }
+
+ return map.release();
+}
+
static void SetCloseOnExec(int fd) {
// This dance is more portable than Linux's O_CLOEXEC open(2) flag.
int flags = fcntl(fd, F_GETFD);
@@ -129,7 +240,7 @@ ZipEntry* ZipArchive::Find(const char* name, std::string* error_msg) const {
return nullptr;
}
- return new ZipEntry(handle_, zip_entry.release());
+ return new ZipEntry(handle_, zip_entry.release(), name);
}
ZipArchive::~ZipArchive() {
diff --git a/runtime/zip_archive.h b/runtime/zip_archive.h
index 42bf55cb3f..18584447e8 100644
--- a/runtime/zip_archive.h
+++ b/runtime/zip_archive.h
@@ -37,19 +37,35 @@ class MemMap;
class ZipEntry {
public:
bool ExtractToFile(File& file, std::string* error_msg);
+ // Extract this entry to anonymous memory (R/W).
+ // Returns null on failure and sets error_msg.
MemMap* ExtractToMemMap(const char* zip_filename, const char* entry_filename,
std::string* error_msg);
+ // Create a file-backed private (clean, R/W) memory mapping to this entry.
+ // 'zip_filename' is used for diagnostics only,
+ // the original file that the ZipArchive was open with is used
+ // for the mapping.
+ //
+ // Will only succeed if the entry is stored uncompressed.
+ // Returns null on failure and sets error_msg.
+ MemMap* MapDirectlyFromFile(const char* zip_filename, /*out*/std::string* error_msg);
virtual ~ZipEntry();
uint32_t GetUncompressedLength();
uint32_t GetCrc32();
+ bool IsUncompressed();
+ bool IsAlignedTo(size_t alignment);
+
private:
ZipEntry(ZipArchiveHandle handle,
- ::ZipEntry* zip_entry) : handle_(handle), zip_entry_(zip_entry) {}
+ ::ZipEntry* zip_entry,
+ const std::string& entry_name)
+ : handle_(handle), zip_entry_(zip_entry), entry_name_(entry_name) {}
ZipArchiveHandle handle_;
::ZipEntry* const zip_entry_;
+ std::string const entry_name_;
friend class ZipArchive;
DISALLOW_COPY_AND_ASSIGN(ZipEntry);
diff --git a/test/044-proxy/build b/test/044-proxy/build
new file mode 100755
index 0000000000..ab956e26e1
--- /dev/null
+++ b/test/044-proxy/build
@@ -0,0 +1,17 @@
+#!/bin/bash
+#
+# Copyright 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.
+
+./default-build "$@" --experimental java-8
diff --git a/test/044-proxy/expected.txt b/test/044-proxy/expected.txt
index 2a5f0b90db..63a46200d9 100644
--- a/test/044-proxy/expected.txt
+++ b/test/044-proxy/expected.txt
@@ -87,7 +87,7 @@ Got expected exception
Proxy methods: [public final boolean $PROXY_CLASS_NAME1$.equals(java.lang.Object), public final java.lang.Object $PROXY_CLASS_NAME1$.foo(), public final java.lang.String $PROXY_CLASS_NAME1$.foo(), public final int $PROXY_CLASS_NAME1$.hashCode(), public final java.lang.String $PROXY_CLASS_NAME1$.toString()]
Invocation of public abstract java.lang.String NarrowingTest$I2.foo()
Invoking foo using I2 type: hello
-Invocation of public abstract java.lang.Object NarrowingTest$I1.foo()
+Invocation of public default java.lang.Object NarrowingTest$I2.foo()
Invoking foo using I1 type: 1
Invocation of public abstract java.lang.String NarrowingTest$I2.foo()
Got expected exception
diff --git a/test/071-dexfile-map-clean/build b/test/071-dexfile-map-clean/build
new file mode 100755
index 0000000000..a171fc3b3b
--- /dev/null
+++ b/test/071-dexfile-map-clean/build
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# Copyright 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.
+
+# Any JAR files used by this test shall have their classes.dex be stored, NOT compressed.
+# This is needed for our test correctness which validates classes.dex are mapped file-backed.
+#
+# In addition, align to at least 4 bytes since that's the dex alignment requirement.
+./default-build "$@" --zip-compression-method store --zip-align 4
diff --git a/test/071-dexfile-map-clean/expected.txt b/test/071-dexfile-map-clean/expected.txt
new file mode 100644
index 0000000000..af7fb2806b
--- /dev/null
+++ b/test/071-dexfile-map-clean/expected.txt
@@ -0,0 +1,3 @@
+Another
+Secondary dexfile mmap is clean
+Another Instance
diff --git a/test/071-dexfile-map-clean/info.txt b/test/071-dexfile-map-clean/info.txt
new file mode 100644
index 0000000000..7e45808603
--- /dev/null
+++ b/test/071-dexfile-map-clean/info.txt
@@ -0,0 +1,11 @@
+Exercise Dalvik-specific DEX file feature. Will not work on RI.
+
+If these conditions are met:
+* When we are loading in a secondary dex file
+* and when dex2oat is not used
+* and the dex file is stored uncompressed in a ZIP file
+
+Then check:
+* The dex file is memory-mapped file-backed as clean memory
+(i.e. there is no extraction step)
+
diff --git a/test/071-dexfile-map-clean/run b/test/071-dexfile-map-clean/run
new file mode 100755
index 0000000000..9c100ec497
--- /dev/null
+++ b/test/071-dexfile-map-clean/run
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# Copyright 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.
+
+# Run without dex2oat so that we don't create oat/vdex files
+# when trying to load the secondary dex file.
+
+# In this way, the secondary dex file will be forced to be
+# loaded directly.
+#
+# In addition, make sure we call 'sync'
+# before executing dalvikvm because otherwise
+# it's highly likely the pushed JAR files haven't
+# been committed to permanent storage yet,
+# and when we mmap them the kernel will think
+# the memory is dirty (despite being file-backed).
+# (Note: this was reproducible 100% of the time on
+# a target angler device).
+./default-run "$@" --no-dex2oat --sync
diff --git a/test/071-dexfile-map-clean/src-ex/Another.java b/test/071-dexfile-map-clean/src-ex/Another.java
new file mode 100644
index 0000000000..58464a65ab
--- /dev/null
+++ b/test/071-dexfile-map-clean/src-ex/Another.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+public class Another {
+ public Another() {
+ System.out.println("Another Instance");
+ }
+}
diff --git a/test/071-dexfile-map-clean/src/Main.java b/test/071-dexfile-map-clean/src/Main.java
new file mode 100644
index 0000000000..8a196dd52e
--- /dev/null
+++ b/test/071-dexfile-map-clean/src/Main.java
@@ -0,0 +1,147 @@
+/*
+ * 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 java.lang.reflect.Method;
+import java.util.Enumeration;
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+/**
+ * DexFile tests (Dalvik-specific).
+ */
+public class Main {
+ private static final String CLASS_PATH =
+ System.getenv("DEX_LOCATION") + "/071-dexfile-map-clean-ex.jar";
+
+ /**
+ * Prep the environment then run the test.
+ */
+ public static void main(String[] args) throws Exception {
+ // Load the dex file, this is a pre-requisite to mmap-ing it in.
+ Class<?> AnotherClass = testDexFile();
+ // Check that the memory maps are clean.
+ testDexMemoryMaps();
+
+ // Prevent garbage collector from collecting our DexFile
+ // (and unmapping too early) by using it after we finish
+ // our verification.
+ AnotherClass.newInstance();
+ }
+
+ private static boolean checkSmapsEntry(String[] smapsLines, int offset) {
+ String nameDescription = smapsLines[offset];
+ String[] split = nameDescription.split(" ");
+
+ String permissions = split[1];
+ // Mapped as read-only + anonymous.
+ if (!permissions.startsWith("r--p")) {
+ return false;
+ }
+
+ boolean validated = false;
+
+ // We have the right entry, now make sure it's valid.
+ for (int i = offset; i < smapsLines.length; ++i) {
+ String line = smapsLines[i];
+
+ if (line.startsWith("Shared_Dirty") || line.startsWith("Private_Dirty")) {
+ String lineTrimmed = line.trim();
+ String[] lineSplit = lineTrimmed.split(" +");
+
+ String sizeUsuallyInKb = lineSplit[lineSplit.length - 2];
+
+ sizeUsuallyInKb = sizeUsuallyInKb.trim();
+
+ if (!sizeUsuallyInKb.equals("0")) {
+ System.out.println(
+ "ERROR: Memory mapping for " + CLASS_PATH + " is unexpectedly dirty");
+ System.out.println(line);
+ } else {
+ validated = true;
+ }
+ }
+
+ // VmFlags marks the "end" of an smaps entry.
+ if (line.startsWith("VmFlags")) {
+ break;
+ }
+ }
+
+ if (validated) {
+ System.out.println("Secondary dexfile mmap is clean");
+ } else {
+ System.out.println("ERROR: Memory mapping is missing Shared_Dirty/Private_Dirty entries");
+ }
+
+ return true;
+ }
+
+ // This test takes relies on dex2oat being skipped.
+ // (enforced in 'run' file by using '--no-dex2oat'
+ //
+ // This could happen in a non-test situation
+ // if a secondary dex file is loaded (but not yet maintenance-mode compiled)
+ // with JIT.
+ //
+ // Or it could also happen if a secondary dex file is loaded and forced
+ // into running into the interpreter (e.g. duplicate classes).
+ //
+ // Rather than relying on those weird fallbacks,
+ // we force the runtime not to dex2oat the dex file to ensure
+ // this test is repeatable and less brittle.
+ private static void testDexMemoryMaps() throws Exception {
+ // Ensure that the secondary dex file is mapped clean (directly from JAR file).
+ String smaps = new String(Files.readAllBytes(Paths.get("/proc/self/smaps")));
+
+ String[] smapsLines = smaps.split("\n");
+ boolean found = true;
+ for (int i = 0; i < smapsLines.length; ++i) {
+ if (smapsLines[i].contains(CLASS_PATH)) {
+ if (checkSmapsEntry(smapsLines, i)) {
+ return;
+ } // else we found the wrong one, keep going.
+ }
+ }
+
+ // Error case:
+ System.out.println("Could not find " + CLASS_PATH + " RO-anonymous smaps entry");
+ System.out.println(smaps);
+ }
+
+ private static Class<?> testDexFile() throws Exception {
+ ClassLoader classLoader = Main.class.getClassLoader();
+ Class<?> DexFile = classLoader.loadClass("dalvik.system.DexFile");
+ Method DexFile_loadDex = DexFile.getMethod("loadDex",
+ String.class,
+ String.class,
+ Integer.TYPE);
+ Method DexFile_entries = DexFile.getMethod("entries");
+ Object dexFile = DexFile_loadDex.invoke(null, CLASS_PATH, null, 0);
+ Enumeration<String> e = (Enumeration<String>) DexFile_entries.invoke(dexFile);
+ while (e.hasMoreElements()) {
+ String className = e.nextElement();
+ System.out.println(className);
+ }
+
+ Method DexFile_loadClass = DexFile.getMethod("loadClass",
+ String.class,
+ ClassLoader.class);
+ Class<?> AnotherClass = (Class<?>)DexFile_loadClass.invoke(dexFile,
+ "Another", Main.class.getClassLoader());
+ return AnotherClass;
+ }
+}
diff --git a/test/121-modifiers/build b/test/121-modifiers/build
deleted file mode 100644
index 771dd51829..0000000000
--- a/test/121-modifiers/build
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2014 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.
-
-# Stop if something fails.
-set -e
-
-# The classes are pre-compiled and modified with ASM.
-#
-# To reproduce, compile the source files. Asm.java needs the ASM libraries (core and tree). Then
-# run Asm.java, which produces Inf.out and NonInf.out. Rename these to class files and put them
-# into the classes directory (this assumes the ASM libraries are names asm.jar and asm-tree.jar):
-#
-# javac Inf.java NonInf.java Main.java
-# javac -cp asm.jar:asm-tree.jar:. Asm.java
-# java -cp asm.jar:asm-tree.jar:. Asm
-# mv Inf.out classes/Inf.class
-# mv NonInf.out classes/NonInf.class
-# mv Main.class A.class A\$B.class A\$C.class classes/
-
-if [ ${USE_JACK} = "true" ]; then
- jar cf classes.jill.jar -C classes .
- # Workaround b/19561685: disable sanity checks to produce a DEX file with invalid modifiers.
- ${JACK} --sanity-checks off --import classes.jill.jar --output-dex .
-else
- ${DX} --debug --dex --dump-to=classes.lst --output=classes.dex classes
-fi
-zip $TEST_NAME.jar classes.dex
diff --git a/test/121-modifiers/info.txt b/test/121-modifiers/info.txt
index 943cbf8aba..129aee8ae6 100644
--- a/test/121-modifiers/info.txt
+++ b/test/121-modifiers/info.txt
@@ -1 +1,18 @@
This is a test checking the modifier (access flags) handling of ART.
+
+The classes are pre-compiled and modified with ASM.
+
+To reproduce, compile the source files. Asm.java needs the ASM libraries (core and tree). Then
+run Asm.java, which produces Inf.out and NonInf.out. Rename these to class files and put them
+into the classes directory (this assumes the ASM libraries are names asm.jar and asm-tree.jar).
+Finally, compile with jack/jill or dx, and run baksmali.
+
+javac Inf.java NonInf.java Main.java
+javac -cp asm.jar:asm-tree.jar:. Asm.java
+java -cp asm.jar:asm-tree.jar:. Asm
+mv Inf.out classes/Inf.class
+mv NonInf.out classes/NonInf.class
+mv Main.class A.class A\$B.class A\$C.class classes/
+dx --debug --dex --output=classes.dex classes
+baksmali classes.dex
+mv out/*.smali smali/
diff --git a/test/121-modifiers/smali/A$B.smali b/test/121-modifiers/smali/A$B.smali
new file mode 100644
index 0000000000..d6addc2c94
--- /dev/null
+++ b/test/121-modifiers/smali/A$B.smali
@@ -0,0 +1,42 @@
+#
+# Copyright (C) 2014 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 LA$B;
+.super Ljava/lang/Object;
+.source "Main.java"
+
+
+# annotations
+.annotation system Ldalvik/annotation/EnclosingClass;
+ value = LA;
+.end annotation
+
+.annotation system Ldalvik/annotation/InnerClass;
+ accessFlags = 0xa
+ name = "B"
+.end annotation
+
+
+# direct methods
+.method private constructor <init>()V
+ .registers 1
+
+ .prologue
+ .line 19
+ invoke-direct {p0}, Ljava/lang/Object;-><init>()V
+
+ return-void
+.end method
diff --git a/test/121-modifiers/smali/A$C.smali b/test/121-modifiers/smali/A$C.smali
new file mode 100644
index 0000000000..eba4756ad6
--- /dev/null
+++ b/test/121-modifiers/smali/A$C.smali
@@ -0,0 +1,30 @@
+#
+# Copyright (C) 2014 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 public interface abstract LA$C;
+.super Ljava/lang/Object;
+.source "Main.java"
+
+
+# annotations
+.annotation system Ldalvik/annotation/EnclosingClass;
+ value = LA;
+.end annotation
+
+.annotation system Ldalvik/annotation/InnerClass;
+ accessFlags = 0x60c
+ name = "C"
+.end annotation
diff --git a/test/121-modifiers/smali/A.smali b/test/121-modifiers/smali/A.smali
new file mode 100644
index 0000000000..b1078bcce0
--- /dev/null
+++ b/test/121-modifiers/smali/A.smali
@@ -0,0 +1,41 @@
+#
+# Copyright (C) 2014 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 LA;
+.super Ljava/lang/Object;
+.source "Main.java"
+
+
+# annotations
+.annotation system Ldalvik/annotation/MemberClasses;
+ value = {
+ LA$B;,
+ LA$C;
+ }
+.end annotation
+
+
+# direct methods
+.method constructor <init>()V
+ .registers 1
+
+ .prologue
+ .line 18
+ invoke-direct {p0}, Ljava/lang/Object;-><init>()V
+
+ .line 21
+ return-void
+.end method
diff --git a/test/121-modifiers/smali/Inf.smali b/test/121-modifiers/smali/Inf.smali
new file mode 100644
index 0000000000..6a3a7ab24c
--- /dev/null
+++ b/test/121-modifiers/smali/Inf.smali
@@ -0,0 +1,23 @@
+#
+# Copyright (C) 2014 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 public interface abstract LInf;
+.super Ljava/lang/Object;
+.source "Inf.java"
+
+
+# static fields
+.field public static final I:I
diff --git a/test/121-modifiers/smali/NonInf.smali b/test/121-modifiers/smali/NonInf.smali
new file mode 100644
index 0000000000..34bf0312e4
--- /dev/null
+++ b/test/121-modifiers/smali/NonInf.smali
@@ -0,0 +1,177 @@
+#
+# Copyright (C) 2014 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 public abstract LNonInf;
+.super Ljava/lang/Object;
+.source "NonInf.java"
+
+
+# static fields
+.field static staticField:I
+
+
+# instance fields
+.field final finalField:I
+
+.field private privateField:I
+
+.field protected protectedField:I
+
+.field public publicField:I
+
+.field transient transientField:I
+
+.field volatile volatileField:I
+
+
+# direct methods
+.method public constructor <init>()V
+ .registers 2
+
+ .prologue
+ .line 11
+ invoke-direct {p0}, Ljava/lang/Object;-><init>()V
+
+ .line 12
+ const/4 v0, 0x0
+
+ iput v0, p0, LNonInf;->publicField:I
+
+ .line 13
+ const/4 v0, 0x1
+
+ iput v0, p0, LNonInf;->privateField:I
+
+ .line 14
+ const/4 v0, 0x2
+
+ iput v0, p0, LNonInf;->protectedField:I
+
+ .line 15
+ const/4 v0, 0x3
+
+ sput v0, LNonInf;->staticField:I
+
+ .line 16
+ const/4 v0, 0x4
+
+ iput v0, p0, LNonInf;->transientField:I
+
+ .line 17
+ const/4 v0, 0x5
+
+ iput v0, p0, LNonInf;->volatileField:I
+
+ .line 18
+ const/4 v0, 0x6
+
+ iput v0, p0, LNonInf;->finalField:I
+
+ .line 19
+ return-void
+.end method
+
+.method private privateMethod()I
+ .registers 2
+
+ .prologue
+ .line 24
+ const/4 v0, 0x0
+
+ return v0
+.end method
+
+.method public static staticMethod()I
+ .registers 1
+
+ .prologue
+ .line 42
+ const/4 v0, 0x0
+
+ return v0
+.end method
+
+
+# virtual methods
+.method public abstract abstractMethod()I
+.end method
+
+.method public final finalMethod()I
+ .registers 2
+
+ .prologue
+ .line 54
+ const/4 v0, 0x0
+
+ return v0
+.end method
+
+.method public native nativeMethod()V
+.end method
+
+.method protected protectedMethod()I
+ .registers 2
+
+ .prologue
+ .line 28
+ const/4 v0, 0x0
+
+ return v0
+.end method
+
+.method public publicMethod()I
+ .registers 2
+
+ .prologue
+ .line 32
+ const/4 v0, 0x0
+
+ return v0
+.end method
+
+.method public strictfp strictfpMethod()D
+ .registers 3
+
+ .prologue
+ .line 46
+ const-wide/16 v0, 0x0
+
+ return-wide v0
+.end method
+
+.method public declared-synchronized synchronizedMethod()I
+ .registers 2
+
+ .prologue
+ monitor-enter p0
+
+ .line 38
+ const/4 v0, 0x0
+
+ monitor-exit p0
+
+ return v0
+.end method
+
+.method public varargs varargsMethod([Ljava/lang/Object;)I
+ .registers 3
+
+ .prologue
+ .line 50
+ const/4 v0, 0x0
+
+ return v0
+.end method
diff --git a/test/121-modifiers/src-java/A.java b/test/121-modifiers/src-java/A.java
new file mode 100644
index 0000000000..d97f6b3f89
--- /dev/null
+++ b/test/121-modifiers/src-java/A.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+// These classes are to check the additional flags for inner classes.
+class A {
+ private static class B {
+ }
+ protected static interface C {
+ }
+}
diff --git a/test/121-modifiers/src/Asm.java b/test/121-modifiers/src-java/Asm.java
index f120622120..f120622120 100644
--- a/test/121-modifiers/src/Asm.java
+++ b/test/121-modifiers/src-java/Asm.java
diff --git a/test/121-modifiers/src/Inf.java b/test/121-modifiers/src-java/Inf.java
index 1dadae0e47..1dadae0e47 100644
--- a/test/121-modifiers/src/Inf.java
+++ b/test/121-modifiers/src-java/Inf.java
diff --git a/test/121-modifiers/src/NonInf.java b/test/121-modifiers/src-java/NonInf.java
index 52e4882532..52e4882532 100644
--- a/test/121-modifiers/src/NonInf.java
+++ b/test/121-modifiers/src-java/NonInf.java
diff --git a/test/121-modifiers/src/Main.java b/test/121-modifiers/src2/Main.java
index e21b789cc7..62e65a8fbe 100644
--- a/test/121-modifiers/src/Main.java
+++ b/test/121-modifiers/src2/Main.java
@@ -14,14 +14,6 @@
* limitations under the License.
*/
-// These classes are to check the additional flags for inner classes.
-class A {
- private static class B {
- }
- protected static interface C {
- }
-}
-
public class Main {
public final static int INTERFACE_DEFINED_BITS =
0x0001 | // public, may be set.
diff --git a/test/626-const-class-linking/clear_dex_cache_types.cc b/test/626-const-class-linking/clear_dex_cache_types.cc
index c0aedc199f..b35dff48ee 100644
--- a/test/626-const-class-linking/clear_dex_cache_types.cc
+++ b/test/626-const-class-linking/clear_dex_cache_types.cc
@@ -49,7 +49,7 @@ extern "C" JNIEXPORT void JNICALL Java_Main_nativeDumpClasses(JNIEnv*, jclass, j
StackHandleScope<1> hs(soa.Self());
Handle<mirror::ObjectArray<mirror::Object>> classes =
hs.NewHandle(soa.Decode<mirror::ObjectArray<mirror::Object>>(array));
- CHECK(classes.Get() != nullptr);
+ CHECK(classes != nullptr);
for (size_t i = 0, length = classes->GetLength(); i != length; ++i) {
CHECK(classes->Get(i) != nullptr) << i;
CHECK(classes->Get(i)->IsClass())
diff --git a/test/911-get-stack-trace/expected.txt b/test/911-get-stack-trace/expected.txt
index 2687f85b09..feabb2087e 100644
--- a/test/911-get-stack-trace/expected.txt
+++ b/test/911-get-stack-trace/expected.txt
@@ -211,52 +211,34 @@ From bottom
### Other threads (suspended) ###
################################
---------
-FinalizerDaemon
-<not printed>
----------
-FinalizerWatchdogDaemon
-<not printed>
----------
-HeapTaskDaemon
-<not printed>
----------
-ReferenceQueueDaemon
-<not printed>
----------
-Signal Catcher
-
----------
-Thread-10
+AllTraces Thread 0
---------
-Thread-11
+AllTraces Thread 1
---------
-Thread-12
+AllTraces Thread 2
---------
-Thread-13
+AllTraces Thread 3
---------
-Thread-4
+AllTraces Thread 4
---------
-Thread-5
+AllTraces Thread 5
---------
-Thread-6
+AllTraces Thread 6
---------
-Thread-7
+AllTraces Thread 7
---------
-Thread-8
+AllTraces Thread 8
---------
-Thread-9
-
----------
-main
+AllTraces Thread 9
---------
FinalizerDaemon
@@ -274,7 +256,10 @@ ReferenceQueueDaemon
Signal Catcher
---------
-Thread-10
+main
+
+---------
+AllTraces Thread 0
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -282,7 +267,7 @@ Thread-10
foo (IIILControlData;)I 0 19
---------
-Thread-11
+AllTraces Thread 1
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -290,7 +275,7 @@ Thread-11
foo (IIILControlData;)I 0 19
---------
-Thread-12
+AllTraces Thread 2
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -298,7 +283,7 @@ Thread-12
foo (IIILControlData;)I 0 19
---------
-Thread-13
+AllTraces Thread 3
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -306,7 +291,7 @@ Thread-13
foo (IIILControlData;)I 0 19
---------
-Thread-4
+AllTraces Thread 4
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -314,7 +299,7 @@ Thread-4
foo (IIILControlData;)I 0 19
---------
-Thread-5
+AllTraces Thread 5
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -322,7 +307,7 @@ Thread-5
foo (IIILControlData;)I 0 19
---------
-Thread-6
+AllTraces Thread 6
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -330,7 +315,7 @@ Thread-6
foo (IIILControlData;)I 0 19
---------
-Thread-7
+AllTraces Thread 7
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -338,7 +323,7 @@ Thread-7
foo (IIILControlData;)I 0 19
---------
-Thread-8
+AllTraces Thread 8
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -346,7 +331,7 @@ Thread-8
foo (IIILControlData;)I 0 19
---------
-Thread-9
+AllTraces Thread 9
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -354,13 +339,6 @@ Thread-9
foo (IIILControlData;)I 0 19
---------
-main
- getAllStackTraces (I)[[Ljava/lang/Object; -1 -2
- printAll (I)V 0 73
- doTest ()V 102 57
- main ([Ljava/lang/String;)V 27 33
-
----------
FinalizerDaemon
<not printed>
---------
@@ -376,7 +354,14 @@ ReferenceQueueDaemon
Signal Catcher
---------
-Thread-10
+main
+ getAllStackTraces (I)[[Ljava/lang/Object; -1 -2
+ printAll (I)V 0 73
+ doTest ()V 128 57
+ main ([Ljava/lang/String;)V 27 33
+
+---------
+AllTraces Thread 0
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -397,7 +382,7 @@ Thread-10
run ()V 4 45
---------
-Thread-11
+AllTraces Thread 1
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -418,7 +403,7 @@ Thread-11
run ()V 4 45
---------
-Thread-12
+AllTraces Thread 2
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -439,7 +424,7 @@ Thread-12
run ()V 4 45
---------
-Thread-13
+AllTraces Thread 3
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -460,7 +445,7 @@ Thread-13
run ()V 4 45
---------
-Thread-4
+AllTraces Thread 4
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -481,7 +466,7 @@ Thread-4
run ()V 4 45
---------
-Thread-5
+AllTraces Thread 5
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -502,7 +487,7 @@ Thread-5
run ()V 4 45
---------
-Thread-6
+AllTraces Thread 6
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -523,7 +508,7 @@ Thread-6
run ()V 4 45
---------
-Thread-7
+AllTraces Thread 7
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -544,7 +529,7 @@ Thread-7
run ()V 4 45
---------
-Thread-8
+AllTraces Thread 8
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -565,7 +550,7 @@ Thread-8
run ()V 4 45
---------
-Thread-9
+AllTraces Thread 9
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -586,10 +571,25 @@ Thread-9
run ()V 4 45
---------
+FinalizerDaemon
+<not printed>
+---------
+FinalizerWatchdogDaemon
+<not printed>
+---------
+HeapTaskDaemon
+<not printed>
+---------
+ReferenceQueueDaemon
+<not printed>
+---------
+Signal Catcher
+
+---------
main
getAllStackTraces (I)[[Ljava/lang/Object; -1 -2
printAll (I)V 0 73
- doTest ()V 107 59
+ doTest ()V 133 59
main ([Ljava/lang/String;)V 27 33
@@ -597,25 +597,25 @@ main
### Other select threads (suspended) ###
########################################
---------
-Thread-14
+ThreadListTraces Thread 0
---------
-Thread-16
+ThreadListTraces Thread 2
---------
-Thread-18
+ThreadListTraces Thread 4
---------
-Thread-20
+ThreadListTraces Thread 6
---------
-Thread-22
+ThreadListTraces Thread 8
---------
main
---------
-Thread-14
+ThreadListTraces Thread 0
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -623,7 +623,7 @@ Thread-14
foo (IIILControlData;)I 0 19
---------
-Thread-16
+ThreadListTraces Thread 2
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -631,7 +631,7 @@ Thread-16
foo (IIILControlData;)I 0 19
---------
-Thread-18
+ThreadListTraces Thread 4
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -639,7 +639,7 @@ Thread-18
foo (IIILControlData;)I 0 19
---------
-Thread-20
+ThreadListTraces Thread 6
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -647,7 +647,7 @@ Thread-20
foo (IIILControlData;)I 0 19
---------
-Thread-22
+ThreadListTraces Thread 8
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -658,11 +658,11 @@ Thread-22
main
getThreadListStackTraces ([Ljava/lang/Thread;I)[[Ljava/lang/Object; -1 -2
printList ([Ljava/lang/Thread;I)V 0 66
- doTest ()V 96 52
+ doTest ()V 116 52
main ([Ljava/lang/String;)V 35 37
---------
-Thread-14
+ThreadListTraces Thread 0
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -683,7 +683,7 @@ Thread-14
run ()V 4 35
---------
-Thread-16
+ThreadListTraces Thread 2
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -704,7 +704,7 @@ Thread-16
run ()V 4 35
---------
-Thread-18
+ThreadListTraces Thread 4
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -725,7 +725,7 @@ Thread-18
run ()V 4 35
---------
-Thread-20
+ThreadListTraces Thread 6
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -746,7 +746,7 @@ Thread-20
run ()V 4 35
---------
-Thread-22
+ThreadListTraces Thread 8
wait ()V -1 -2
printOrWait (IILControlData;)V 24 45
baz (IIILControlData;)Ljava/lang/Object; 2 30
@@ -770,7 +770,7 @@ Thread-22
main
getThreadListStackTraces ([Ljava/lang/Thread;I)[[Ljava/lang/Object; -1 -2
printList ([Ljava/lang/Thread;I)V 0 66
- doTest ()V 101 54
+ doTest ()V 121 54
main ([Ljava/lang/String;)V 35 37
diff --git a/test/911-get-stack-trace/src/AllTraces.java b/test/911-get-stack-trace/src/AllTraces.java
index adf6f38f5a..1d9aa96d6e 100644
--- a/test/911-get-stack-trace/src/AllTraces.java
+++ b/test/911-get-stack-trace/src/AllTraces.java
@@ -26,8 +26,8 @@ public class AllTraces {
System.out.println("################################");
// Also create an unstarted and a dead thread.
- RETAIN.add(new Thread());
- Thread deadThread = new Thread();
+ RETAIN.add(new Thread("UNSTARTED"));
+ Thread deadThread = new Thread("DEAD");
RETAIN.add(deadThread);
deadThread.start();
deadThread.join();
@@ -40,7 +40,7 @@ public class AllTraces {
Thread threads[] = new Thread[N];
for (int i = 0; i < N; i++) {
- Thread t = new Thread() {
+ Thread t = new Thread("AllTraces Thread " + i) {
public void run() {
Recurse.foo(4, 0, 0, data);
}
diff --git a/test/911-get-stack-trace/src/Frames.java b/test/911-get-stack-trace/src/Frames.java
index a1a11c3785..54d4165130 100644
--- a/test/911-get-stack-trace/src/Frames.java
+++ b/test/911-get-stack-trace/src/Frames.java
@@ -59,7 +59,7 @@ public class Frames {
System.out.println("################################");
final ControlData data = new ControlData();
data.waitFor = new Object();
- Thread t = new Thread() {
+ Thread t = new Thread("Frames doTestOtherThreadWait") {
public void run() {
Recurse.foo(4, 0, 0, data);
}
@@ -97,7 +97,7 @@ public class Frames {
System.out.println("### Other thread (live) ###");
System.out.println("###########################");
final ControlData data = new ControlData();
- Thread t = new Thread() {
+ Thread t = new Thread("Frames doTestOtherThreadBusyLoop") {
public void run() {
Recurse.foo(4, 0, 0, data);
}
diff --git a/test/911-get-stack-trace/src/OtherThread.java b/test/911-get-stack-trace/src/OtherThread.java
index 0748433a20..0a78523a91 100644
--- a/test/911-get-stack-trace/src/OtherThread.java
+++ b/test/911-get-stack-trace/src/OtherThread.java
@@ -21,7 +21,7 @@ public class OtherThread {
System.out.println("################################");
final ControlData data = new ControlData();
data.waitFor = new Object();
- Thread t = new Thread() {
+ Thread t = new Thread("OtherThread doTestOtherThreadWait") {
public void run() {
Recurse.foo(4, 0, 0, data);
}
@@ -54,7 +54,7 @@ public class OtherThread {
System.out.println("### Other thread (live) ###");
System.out.println("###########################");
final ControlData data = new ControlData();
- Thread t = new Thread() {
+ Thread t = new Thread("OtherThread doTestOtherThreadBusyLoop") {
public void run() {
Recurse.foo(4, 0, 0, data);
}
diff --git a/test/911-get-stack-trace/src/ThreadListTraces.java b/test/911-get-stack-trace/src/ThreadListTraces.java
index f66557f3bd..14868e9c36 100644
--- a/test/911-get-stack-trace/src/ThreadListTraces.java
+++ b/test/911-get-stack-trace/src/ThreadListTraces.java
@@ -30,7 +30,7 @@ public class ThreadListTraces {
Thread list[] = new Thread[N/2 + 1];
for (int i = 0; i < N; i++) {
- Thread t = new Thread() {
+ Thread t = new Thread("ThreadListTraces Thread " + i) {
public void run() {
Recurse.foo(4, 0, 0, data);
}
diff --git a/test/945-obsolete-native/build b/test/945-obsolete-native/build
new file mode 100755
index 0000000000..898e2e54a2
--- /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 0000000000..83efda144d
--- /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 0000000000..c8b892cedd
--- /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 0000000000..061e7afbbc
--- /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 0000000000..c6e62ae6cd
--- /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 0000000000..5e2154e9a3
--- /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 0000000000..2b7cc1b3a1
--- /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 0000000000..a423ca6b4e
--- /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 0000000000..bb87296e60
--- /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 0000000000..5d5cae4147
--- /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 0000000000..93d96a9a7b
--- /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 0000000000..4e4d97e15e
--- /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 0000000000..90a60e6f8f
--- /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 0000000000..e9a9f6c4a5
--- /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 0000000000..2abc3122fa
--- /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 0000000000..9a77e67e49
--- /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" +
+ "AADeFwAA7BcAAP8XAAASGAAAJRgAADgYAABLGAAAXhgAAHEYAACFGAAAlhgAAK0YAAC5GAAA" +
+ "zRgAANEYAADVGAAA2RgAAN0YAADlGAAA7RgAAPEYAAD1GAAABBkAABgZAAAnGQAALxkAADMZ" +
+ "AAA3GQAAQxkAAEsZAABQGQAAYRkAAHEZAAB0GQAAeBkAAHwZAACDGQAAkRkAAKIZAACwGQAA" +
+ "uhkAAM4ZAADUGQAA2hkAAN4ZAADiGQAA8BkAAPwZAAAAGgAABhoAABEaAAAaGgAAHRoAACIa" +
+ "AAAlGgAANRoAAD4aAABKGgAATxoAAFMaAABXGgAAXBoAAGcaAABuGgAAdRoAAIAaAACGGgAA" +
+ "jBoAAJkaAACiGgAArBoAALIaAAC5GgAAwhoAAMkaAADSGgAAEAAAABEAAAATAAAAFAAAABUA" +
+ "AAAYAAAAIwAAACQAAAAmAAAAJwAAACgAAAApAAAAKgAAACsAAAAsAAAALQAAAC4AAAAvAAAA" +
+ "MAAAADEAAAAyAAAAMwAAADQAAAA1AAAANgAAADgAAAA5AAAAOgAAADsAAAA8AAAAPQAAAD4A" +
+ "AAA/AAAAQAAAAEIAAABGAAAAVAAAAFYAAABXAAAAWAAAAFkAAABaAAAAFQAAAAQAAAAAAAAA" +
+ "FgAAAAQAAADcEAAAIQAAABAAAADkEAAAGQAAABMAAAAAAAAAHQAAABMAAADcEAAAGQAAABQA" +
+ "AAAAAAAAGQAAABUAAAAAAAAAGgAAABYAAADsEAAAGwAAABYAAAD0EAAAHAAAABYAAAD8EAAA" +
+ "HQAAABYAAADcEAAAHgAAABYAAAAEEQAAHwAAABYAAAAMEQAAHwAAABYAAAAUEQAAJQAAABYA" +
+ "AAAcEQAAIgAAABsAAAAkEQAAIgAAAB0AAAAwEQAAIAAAAB0AAAA8EQAAIAAAAB0AAABIEQAA" +
+ "GQAAACAAAAAAAAAAGQAAACEAAAAAAAAARgAAACMAAAAAAAAARwAAACMAAABUEQAASAAAACMA" +
+ "AABcEQAASQAAACMAAABkEQAASgAAACMAAABsEQAASwAAACMAAADcEAAATAAAACMAAAB0EQAA" +
+ "TQAAACMAAAAEEQAATgAAACMAAAB8EQAATwAAACMAAAAMEQAAUAAAACMAAACEEQAATwAAACMA" +
+ "AAAUEQAAUAAAACMAAACMEQAATwAAACMAAACUEQAAUQAAACMAAACcEQAAUgAAACMAAAAcEQAA" +
+ "VQAAACQAAAAMEQAABwAEAEEAAAAHACkAbwAAAAcAKACEAAAABwAhAI8AAAAHACkAngAAAAcA" +
+ "GQChAAAACgAKABcAAAATABIAQwAAABcAEACSAAAABgAVAA4AAAAGAAMAggAAAAYABQCCAAAA" +
+ "BwAUAAsAAAAHABUADQAAAAcAFQAOAAAABwAWAF4AAAAHABcAXgAAAAcAGABeAAAABwAZAF4A" +
+ "AAAHABsAXgAAAAcAHQBeAAAABwAfAF4AAAAHACEAXgAAAAcAIwBeAAAABwAfAGcAAAAHACQA" +
+ "aQAAAAcAAAB9AAAABwAPAIsAAAAHAAEAkAAAAAcAFQCXAAAABwABAJsAAAAHABUAnwAAABAA" +
+ "AgB6AAAAEAAgAJUAAAARAB4ADgAAABMAAACFAAAAEwAEAKYAAAAUACUAdgAAABUAJQB2AAAA" +
+ "FgAVAA4AAAAWAAcAXAAAABYACABcAAAAFgAJAFwAAAAWAAoAXAAAABYACwBcAAAAFgAMAFwA" +
+ "AAAWAA0AXAAAABYADgBcAAAAFgAGAKMAAAAYABUADgAAABgAFQCHAAAAGAAcAJwAAAAYABUA" +
+ "nQAAABkAFQAOAAAAGQAFAHsAAAAcACIADgAAAB0AEwCkAAAAHgAQAHkAAAAfABEAcwAAAB8A" +
+ "EgCDAAAAIAAAAJQAAAAhABoADgAAACEAAAB7AAAAIQAAAHwAAAAhABoAmgAAAFMcAAAGAAAA" +
+ "EAAAABkAAAAAAAAARAAAAJwQAABaHAAAAAAAAAcAAAABAAAAGAAAAAAAAABEAAAArBAAAG0c" +
+ "AABQHAAABAAAABIAAAADAAAA9BsAAPsbAAAEHAAAAQAAABMcAAABAAAABBwAAAEAAAAcHAAA" +
+ "AQAAACUcAAABAAEAAQAAANUaAAAEAAAAcBAsAAAADgACAAEAAQAAAN0aAAANAAAAcQADAAAA" +
+ "DABuEDYAAAAKAHEQGwAAAAwAEQAAAAIAAQABAAAA4hoAAAUAAABuEAEAAQAMABEAAAABAAAA" +
+ "AAAAAAAAAAADAAAAYgADABEAAAADAAAAAgAAAOcaAAAeAAAAEwIQACIAIQASAXAgNAAQAGkA" +
+ "AwAiAAYAcBAAAAAAaQAFACMgKABpAAIAIyApAGkAAQAjICkAaQAEAA4AAQABAAEAAAD0GgAA" +
+ "BAAAAHAQKAAAAA4ABQACAAIAAAD5GgAAKAAAADNDAwAOACIAEQAiARYAcBAeAAEAGwJfAAAA" +
+ "biAlACEADAFuICIAMQAMARsCAwAAAG4gJQAhAAwBbiAiAEEADAFuECcAAQAMAXAgGQAQACcA" +
+ "BQACAAIAAAACGwAAKAAAADNDAwAOACIAEQAiARYAcBAeAAEAGwJgAAAAbiAlACEADAFuIB8A" +
+ "MQAMARsCBAAAAG4gJQAhAAwBbiAfAEEADAFuECcAAQAMAXAgGQAQACcACAAEAAMAAAALGwAA" +
+ "KgAAAC8ABAY5AAMADgAiABEAIgEWAHAQHgABABsCYQAAAG4gJQAhAAwBbjAgAEEFDAEbAgUA" +
+ "AABuICUAIQAMAW4wIABhBwwBbhAnAAEADAFwIBkAEAAnAAUAAgACAAAAFBsAACoAAAAtAAME" +
+ "OQADAA4AIgARACIBFgBwEB4AAQAbAmIAAABuICUAIQAMAW4gIQAxAAwBGwIGAAAAbiAlACEA" +
+ "DAFuICEAQQAMAW4QJwABAAwBcCAZABAAJwAFAAIAAgAAAB0bAAAoAAAAM0MDAA4AIgARACIB" +
+ "FgBwEB4AAQAbAmMAAABuICUAIQAMAW4gIgAxAAwBGwIHAAAAbiAlACEADAFuICIAQQAMAW4Q" +
+ "JwABAAwBcCAZABAAJwAIAAQAAwAAACgbAAAqAAAAMQAEBjkAAwAOACIAEQAiARYAcBAeAAEA" +
+ "GwJkAAAAbiAlACEADAFuMCMAQQUMARsCCAAAAG4gJQAhAAwBbjAjAGEHDAFuECcAAQAMAXAg" +
+ "GQAQACcABQACAAIAAAAzGwAAMwAAADNDAwAOADgDCwA4BAkAbiAcAEMACgA4AAMADgAiABEA" +
+ "IgEWAHAQHgABABsCZgAAAG4gJQAhAAwBbiAkADEADAEbAgkAAABuICUAIQAMAW4gJABBAAwB" +
+ "bhAnAAEADAFwIBkAEAAnAAAABQACAAIAAAA/GwAAMwAAADNDAwAOADgDCwA4BAkAbiAdAEMA" +
+ "CgA4AAMADgAiABEAIgEWAHAQHgABABsCZQAAAG4gJQAhAAwBbiAlADEADAEbAgoAAABuICUA" +
+ "IQAMAW4gJQBBAAwBbhAnAAEADAFwIBkAEAAnAAAABQACAAIAAABNGwAAKAAAADNDAwAOACIA" +
+ "EQAiARYAcBAeAAEAGwJlAAAAbiAlACEADAFuICIAMQAMARsCCgAAAG4gJQAhAAwBbiAiAEEA" +
+ "DAFuECcAAQAMAXAgGQAQACcABQACAAIAAABYGwAANQAAADJDAwAOADgDDQA4BAsAbiAcAEMA" +
+ "CgDfAAABOAADAA4AIgARACIBFgBwEB4AAQAbAmgAAABuICUAIQAMAW4gJAAxAAwBGwIJAAAA" +
+ "biAlACEADAFuICQAQQAMAW4QJwABAAwBcCAZABAAJwAAAAQAAQACAAAAZBsAAB0AAAA5AxwA" +
+ "IgARACIBFgBwEB4AAQAbAmoAAABuICUAIQAMAW4gJgAxAAwBbhAnAAEADAFwIBkAEAAnAA4A" +
+ "AAABAAAAAQAAAHAbAAANAAAAYgAFAG4QLQAAAAwAHwATAG4QGgAAAAoADwAAAAkAAwAEAAAA" +
+ "dRsAAGEAAAASFRIEcQARAAAACgEcAgcAbkAwACaHDABuEC8AAAAMAnEgDAAoAG4QLwAAAAwC" +
+ "bhAzAAIACgJxIAoAUgAjUiYAcRAbAAEADANNAwIEcTAyAEACDAAjUiUAYgMHAE0DAgRxMDEA" +
+ "QAIMAG4QLwAAAAwCbhAzAAIACgJxIAoAUgBuEC8AAAAMAnEgDAAoABYCfQBxICoAMgBiAgIA" +
+ "cQARAAAACgMiBBwAcCAuAAQATQQCA2ICAgBxABEAAAAKA0YCAgMRAgAAAQABAAAAAACTGwAA" +
+ "AQAAAA8AAAADAAEAAgAAAJobAAAUAAAAYgABAEYAAAJuEDYAAABiAAQAcQARAAAACgFGAAAB" +
+ "biA3ACAAEgAPAAwAAAADAAAAoxsAAOgAAAASKxIaEgkTCBAAEgA1gBcAYgQBACIFIQBwIDQA" +
+ "lQBNBQQAYgQEACIFIQBwIDQAlQBNBQQA2AAAASjqI4EnABIANYARACIEBwBwEAUABABNBAEA" +
+ "RgQBAG4QKwAEANgAAAEo8BIANYAKAEYEAQBuECkABADYAAABKPcSAxICEgA1gCIAYgQCAEYE" +
+ "BAASBXEgDwBUAGIEAQBGBAQAbhA1AAQACgQ4BA0A2AMDAWIEAQBGBAQAbhA1AAQACgSwQtgA" +
+ "AAEo32IECAAiBRYAcBAeAAUAGwZTAAAAbiAlAGUADAVuICIANQAMBRsGAgAAAG4gJQBlAAwF" +
+ "biAiACUADAVuECcABQAMBW4gGABUADKjLgBiBAgAGwVFAAAAbiAYAFQAEgA1gCMAYgQIABsF" +
+ "AQAAACO2JgBxEBsAAAAMB00HBgliBwQARgcHAG4QNQAHAAoHcRAbAAcADAdNBwYKbjAXAFQG" +
+ "2AAAASjeMoIuAGIECAAbBRIAAABuIBgAVAASADWAIwBiBAgAGwUAAAAAI7YmAHEQGwAAAAwH" +
+ "TQcGCWIHAQBGBwcAbhA1AAcACgdxEBsABwAMB00HBgpuMBcAVAbYAAABKN5xIAoAowBxIAoA" +
+ "ggAOAAMAAQABAAAA6BsAAAkAAAAS8fwQAAABAAoAcRATAAAADgAAANwHAAAAAAAAAAAAAAAA" +
+ "AADsBwAAAQAAAAMAAAAAAAAABQAAAPQHAAASAAAA/AcAABUAAAAECAAAFgAAAPwHAAABAAAA" +
+ "BAAAAAIAAAAVACYAAQAAAAEAAAABAAAAAgAAAAEAAAADAAAAAQAAAAUAAAABAAAAFAAAAAEA" +
+ "AAAVAAAAAQAAACQAAAADAAAAHgAVACAAAAADAAAAEgAVACAAAAADAAAAHQAEACUAAAADAAAA" +
+ "HQAEACYAAAACAAAAAAAAAAIAAAABAAEAAgAAAAIAAgACAAAAAwADAAIAAAAEAAQAAgAAAAUA" +
+ "BQACAAAAFAAUAAIAAAAVABUAAQAAAB0AAAACAAAAIgAiADEgQ2FsbCBzaXRlIGluc3RhbmNl" +
+ "ICMlMDJkIHdhcyBpbnZva2VkICUgMmQgdGltZXMKAC4gVGhyZWFkICUgMmQgaW52b2tlZCBj" +
+ "YWxsIHNpdGUgaW5zdGFuY2UgIyUwMmQKAAcgVm90ZXMgAAYsIGIyOiAABiwgYzI6IAAGLCBk" +
+ "MjogAAYsIGYyOiAABiwgaTI6IAAGLCBsMjogAAYsIG8yOiAABiwgczI6IAAFLWdldDAAATwA" +
+ "CDxjbGluaXQ+AAY8aW5pdD4AAj47AAFCAAFDABhDYWxsLXNpdGVzIGludm9jYXRpb25zIDoA" +
+ "AUQAAUYAAUkAAklJAA1JTlZPS0VfU1RBVElDAAFKAAFMAAJMQwACTEQAAkxGAAJMSQACTEoA" +
+ "AkxMAARMTElMAANMTEwABExMTEwAKUxUZXN0SW52b2tlQ3VzdG9tV2l0aENvbmN1cnJlbnRU" +
+ "aHJlYWRzJDE7ACdMVGVzdEludm9rZUN1c3RvbVdpdGhDb25jdXJyZW50VGhyZWFkczsAAkxa" +
+ "ADNMY29tL2FuZHJvaWQvamFjay9hbm5vdGF0aW9ucy9DYWxsZWRCeUludm9rZUN1c3RvbTsA" +
+ "MUxjb20vYW5kcm9pZC9qYWNrL2Fubm90YXRpb25zL0xpbmtlck1ldGhvZEhhbmRsZTsAL0xj" +
+ "b20vYW5kcm9pZC9qYWNrL2Fubm90YXRpb25zL01ldGhvZEhhbmRsZUtpbmQ7ACJMZGFsdmlr" +
+ "L2Fubm90YXRpb24vRW5jbG9zaW5nQ2xhc3M7AB5MZGFsdmlrL2Fubm90YXRpb24vSW5uZXJD" +
+ "bGFzczsAIUxkYWx2aWsvYW5ub3RhdGlvbi9NZW1iZXJDbGFzc2VzOwAdTGRhbHZpay9hbm5v" +
+ "dGF0aW9uL1NpZ25hdHVyZTsAGkxkYWx2aWsvYW5ub3RhdGlvbi9UaHJvd3M7ABVMamF2YS9p" +
+ "by9QcmludFN0cmVhbTsAGkxqYXZhL2xhbmcvQXNzZXJ0aW9uRXJyb3I7ABFMamF2YS9sYW5n" +
+ "L0NsYXNzOwATTGphdmEvbGFuZy9JbnRlZ2VyOwASTGphdmEvbGFuZy9PYmplY3Q7ABJMamF2" +
+ "YS9sYW5nL1N0cmluZzsAGUxqYXZhL2xhbmcvU3RyaW5nQnVpbGRlcjsAEkxqYXZhL2xhbmcv" +
+ "U3lzdGVtOwASTGphdmEvbGFuZy9UaHJlYWQ7ABZMamF2YS9sYW5nL1RocmVhZExvY2FsABdM" +
+ "amF2YS9sYW5nL1RocmVhZExvY2FsOwAVTGphdmEvbGFuZy9UaHJvd2FibGU7ABtMamF2YS9s" +
+ "YW5nL2ludm9rZS9DYWxsU2l0ZTsAI0xqYXZhL2xhbmcvaW52b2tlL0NvbnN0YW50Q2FsbFNp" +
+ "dGU7AB9MamF2YS9sYW5nL2ludm9rZS9NZXRob2RIYW5kbGU7ACdMamF2YS9sYW5nL2ludm9r" +
+ "ZS9NZXRob2RIYW5kbGVzJExvb2t1cDsAIExqYXZhL2xhbmcvaW52b2tlL01ldGhvZEhhbmRs" +
+ "ZXM7AB1MamF2YS9sYW5nL2ludm9rZS9NZXRob2RUeXBlOwArTGphdmEvdXRpbC9jb25jdXJy" +
+ "ZW50L2F0b21pYy9BdG9taWNJbnRlZ2VyOwARTlVNQkVSX09GX1RIUkVBRFMAAVMABFRZUEUA" +
+ "KlRlc3RJbnZva2VDdXN0b21XaXRoQ29uY3VycmVudFRocmVhZHMuamF2YQAkVGhyZWFkcyBk" +
+ "aWQgbm90IHRoZSBzYW1lIGNhbGwtc2l0ZXM6AAFWAANWQkIAA1ZDQwADVkREAANWRkYAAlZJ" +
+ "AANWSUkAAlZKAANWSkoAAlZMAANWTEwAA1ZTUwACVloACFdpbm5lcnMgAAFaAAJaTAASW0xq" +
+ "YXZhL2xhbmcvQ2xhc3M7ABNbTGphdmEvbGFuZy9PYmplY3Q7ABNbTGphdmEvbGFuZy9UaHJl" +
+ "YWQ7ABxbTGphdmEvbGFuZy9pbnZva2UvQ2FsbFNpdGU7ACxbTGphdmEvdXRpbC9jb25jdXJy" +
+ "ZW50L2F0b21pYy9BdG9taWNJbnRlZ2VyOwALYWNjZXNzRmxhZ3MABmFwcGVuZAANYXJndW1l" +
+ "bnRUeXBlcwAMYXNzZXJ0RXF1YWxzABFhc3NlcnRFcXVhbHMgYjE6IAARYXNzZXJ0RXF1YWxz" +
+ "IGMxOiAAEWFzc2VydEVxdWFscyBkMTogABFhc3NlcnRFcXVhbHMgZjE6IAARYXNzZXJ0RXF1" +
+ "YWxzIGkxOiAAEWFzc2VydEVxdWFscyBsMTogABFhc3NlcnRFcXVhbHMgczE6IAASYXNzZXJ0" +
+ "RXF1YWxzOiBvMTogAA9hc3NlcnROb3RFcXVhbHMAFWFzc2VydE5vdEVxdWFsczogbzE6IAAK" +
+ "YXNzZXJ0VHJ1ZQASYXNzZXJ0VHJ1ZSB2YWx1ZTogAAJiMQACYjIAAmMxAAJjMgAGY2FsbGVk" +
+ "AAZjYWxsZXIAAmQxAAJkMgANZHJvcEFyZ3VtZW50cwASZW1pdHRlcjogamFjay00LjI1AA1l" +
+ "bmNsb3NpbmdUeXBlAAZlcXVhbHMAAmYxAAJmMgAKZmluZFN0YXRpYwAGZm9ybWF0AANnZXQA" +
+ "D2dldEFuZEluY3JlbWVudAAOZ2V0VGhyZWFkSW5kZXgAAWkAAmkxAAJpMgAFaW5kZXgADGlu" +
+ "aXRpYWxWYWx1ZQAPaW5zZXJ0QXJndW1lbnRzAAxpbnN0YW50aWF0ZWQACGludFZhbHVlABJp" +
+ "bnZva2VNZXRob2RIYW5kbGUABGpvaW4ABGtpbmQAAmwxAAJsMgAMbGlua2VyTWV0aG9kAApt" +
+ "ZXRob2RUeXBlAAJtaAAEbmFtZQAJbmV4dEluZGV4AAdub3RVc2VkAAFvAANvdXQAAXAADnBh" +
+ "cmFtZXRlckNvdW50AAdwcmludGxuAApyZXR1cm5UeXBlAANydW4AAnMxAAJzMgADc2V0AAlz" +
+ "ZXRDYWxsZWQABXNsZWVwAAVzdGFydAAJdGFyZ2V0dGVkAAR0ZXN0AAR0aGlzAAt0aHJlYWRJ" +
+ "bmRleAAHdGhyZWFkcwAIdG9TdHJpbmcABHR5cGUABXZhbHVlAAd2YWx1ZU9mAAV2b3RlcwAH" +
+ "d2lubmVycwABeAAmAAcOAls7ACkABw4AJwAHDgAjAAcsiVg1TU0CbEoANgAHDgCqAQJsbQcO" +
+ "PACvAQJubwcOPADIAQJycwcOWgDDAQJ4eQcOWgC5AQKAAYEBBw48AL4BAooBiwEHDloAzQEC" +
+ "kgGUAQcOPLQA2QECmQGaAQcOLSClIAC0AQKZAZoBBw48ANMBApIBlAEHDjzSAKQBAaYBBw4t" +
+ "ARoQADkABw4AWANxjwGNAQcsTAMBogEFaQMAjgEeeLTDpbR8W9IAPQGqAQcOAE8BggEHDni0" +
+ "AG0AB1kBAQMAfwUtlpNBLQMBowEoPHhXQTxYQB4DA6kBBR4DAqgBBTyHpS2RQwEkEi2HPHgB" +
+ "FA06Qy2HPHgBFA06QTw8AEIABw5aAwCqAQU8AAILAaUBGAcCDAJbBAiOAR4CDgGlARwEFzcX" +
+ "DBcxFw8CDQGlARwBGAYCDwGlARwBGBoACARdHAEYBIYBHAEdCQRdHAMYHhgVGCB1GAeIARsG" +
+ "jgEXi44BF5uWARgEAQQQAxYAF5sVAQAAAQIAgIAEjBABBKQQAcQg0BAGABMBABoBCgEKARoB" +
+ "CgEaA4gg7BABiIAEhBEBgoAE0BEBCegRAQnIEgEJqBMBCYwUAQnwFAEJ0BUBCbQWAQmsFwEJ" +
+ "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 0000000000..443a7af187
--- /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" +
+ "DAFuEB8AAQAMAXAgEQAQACcACAAEAAMAAACPEwAAKgAAAC8ABAY5AAMADgAiAA0AIgESAHAQ" +
+ "FgABABsCUQAAAG4gHQAhAAwBbjAYAEEFDAEbAgUAAABuIB0AIQAMAW4wGABhBwwBbhAfAAEA" +
+ "DAFwIBEAEAAnAAUAAgACAAAAlxMAACoAAAAtAAMEOQADAA4AIgANACIBEgBwEBYAAQAbAlIA" +
+ "AABuIB0AIQAMAW4gGQAxAAwBGwIGAAAAbiAdACEADAFuIBkAQQAMAW4QHwABAAwBcCARABAA" +
+ "JwAFAAIAAgAAAJ8TAAAoAAAAM0MDAA4AIgANACIBEgBwEBYAAQAbAlMAAABuIB0AIQAMAW4g" +
+ "GgAxAAwBGwIHAAAAbiAdACEADAFuIBoAQQAMAW4QHwABAAwBcCARABAAJwAIAAQAAwAAAKcT" +
+ "AAAqAAAAMQAEBjkAAwAOACIADQAiARIAcBAWAAEAGwJUAAAAbiAdACEADAFuMBsAQQUMARsC" +
+ "CAAAAG4gHQAhAAwBbjAbAGEHDAFuEB8AAQAMAXAgEQAQACcABQACAAIAAACvEwAAMwAAADND" +
+ "AwAOADgDCwA4BAkAbiAUAEMACgA4AAMADgAiAA0AIgESAHAQFgABABsCVgAAAG4gHQAhAAwB" +
+ "biAcADEADAEbAgkAAABuIB0AIQAMAW4gHABBAAwBbhAfAAEADAFwIBEAEAAnAAAABQACAAIA" +
+ "AAC4EwAAMwAAADNDAwAOADgDCwA4BAkAbiAVAEMACgA4AAMADgAiAA0AIgESAHAQFgABABsC" +
+ "VQAAAG4gHQAhAAwBbiAdADEADAEbAgoAAABuIB0AIQAMAW4gHQBBAAwBbhAfAAEADAFwIBEA" +
+ "EAAnAAAABQACAAIAAADDEwAAKAAAADNDAwAOACIADQAiARIAcBAWAAEAGwJVAAAAbiAdACEA" +
+ "DAFuIBoAMQAMARsCCgAAAG4gHQAhAAwBbiAaAEEADAFuEB8AAQAMAXAgEQAQACcABAABAAIA" +
+ "AADLEwAAHQAAADkDHAAiAA0AIgESAHAQFgABABsCWAAAAG4gHQAhAAwBbiAeADEADAFuEB8A" +
+ "AQAMAXAgEQAQACcADgAAAAcAAwAEAAAA1RMAAGoAAABiAQYAIgISAHAQFgACABsDcAAAAG4g" +
+ "HQAyAAwCYAMEAG4gGgAyAAwCbhAfAAIADAJuIA8AIQAcAQYAbkAhABRlDABgAQQAYAIAADMh" +
+ "KABiAQYAIgISAHAQFgACABsDNwAAAG4gHQAyAAwCbiAdAFIADAIbAwAAAABuIB0AMgAMAm4g" +
+ "HABiAAwCbhAfAAIADAJuIA8AIQASAREBYAEEAGACAQAzIRMAYgEGABsCOwAAAG4gDwAhACIB" +
+ "DwAbAm8AAABwIBIAIQAnASIBFgBwICAAAQARAQYAAwACAAAA7RMAAFAAAAASERICYAACADQD" +
+ "SAABEHEQDAAAAGAAAwA2A0IAcRAMAAEAZwMEAJAABAX8IAAAVAAKAXEgBwAQAGIABgAiARIA" +
+ "cBAWAAEAGwIVAAAAbiAdACEADAFuIBoAMQAMARsCAQAAAG4gHQAhAAwBbiAaAEEADAFuIBoA" +
+ "UQAMARsCAgAAAG4gHQAhAAwBbhAfAAEADAFuIA8AEAAOAAEgKLoBISi/AAAAAAAAAAADAAAA" +
+ "AAAAAAIAAACsBQAADQAAALQFAAAOAAAAtAUAAAIAAAAEAAQAAQAAAAEAAAABAAAAAgAAAAEA" +
+ "AAADAAAAAQAAAAQAAAABAAAABQAAAAEAAAAQAAAAAQAAABEAAAABAAAAHAAAAAMAAAAYABEA" +
+ "GQAAAAMAAAAOABEAGQAAAAIAAAAAAAAAAgAAAAEAAQACAAAAAgACAAIAAAADAAMAAwAAAAQA" +
+ "BAAEAAAAAgAAAAUABQACAAAAEAAQAAIAAAARABEAAQAAABcAAAACAAAAGgAaAAEgAAIgKAAB" +
+ "KQAGLCBiMjogAAYsIGMyOiAABiwgZDI6IAAGLCBmMjogAAYsIGkyOiAABiwgbDI6IAAGLCBv" +
+ "MjogAAYsIHMyOiAACDxjbGluaXQ+AAY8aW5pdD4AAUIAAUMAAUQAAUYAJ0ZBSUxVUkVfVFlQ" +
+ "RV9MSU5LRVJfTUVUSE9EX1JFVFVSTlNfTlVMTAAhRkFJTFVSRV9UWVBFX0xJTktFUl9NRVRI" +
+ "T0RfVEhST1dTABFGQUlMVVJFX1RZUEVfTk9ORQAhRkFJTFVSRV9UWVBFX1RBUkdFVF9NRVRI" +
+ "T0RfVEhST1dTAA9GYWlsdXJlIFR5cGUgKyAAAUkAA0lJSQANSU5WT0tFX1NUQVRJQwABSgAB" +
+ "TAACTEMAAkxEAAJMRgACTEkAAkxKAAJMTAAETExMTAAiTFRlc3RMaW5rZXJNZXRob2RNaW5p" +
+ "bWFsQXJndW1lbnRzOwACTFoAM0xjb20vYW5kcm9pZC9qYWNrL2Fubm90YXRpb25zL0NhbGxl" +
+ "ZEJ5SW52b2tlQ3VzdG9tOwAxTGNvbS9hbmRyb2lkL2phY2svYW5ub3RhdGlvbnMvTGlua2Vy" +
+ "TWV0aG9kSGFuZGxlOwAvTGNvbS9hbmRyb2lkL2phY2svYW5ub3RhdGlvbnMvTWV0aG9kSGFu" +
+ "ZGxlS2luZDsAGkxkYWx2aWsvYW5ub3RhdGlvbi9UaHJvd3M7ABVMamF2YS9pby9QcmludFN0" +
+ "cmVhbTsAH0xqYXZhL2xhbmcvQXJpdGhtZXRpY0V4Y2VwdGlvbjsAGkxqYXZhL2xhbmcvQXNz" +
+ "ZXJ0aW9uRXJyb3I7ABFMamF2YS9sYW5nL0NsYXNzOwAiTGphdmEvbGFuZy9JbnN0YW50aWF0" +
+ "aW9uRXhjZXB0aW9uOwASTGphdmEvbGFuZy9PYmplY3Q7ABJMamF2YS9sYW5nL1N0cmluZzsA" +
+ "GUxqYXZhL2xhbmcvU3RyaW5nQnVpbGRlcjsAEkxqYXZhL2xhbmcvU3lzdGVtOwAVTGphdmEv" +
+ "bGFuZy9UaHJvd2FibGU7ABtMamF2YS9sYW5nL2ludm9rZS9DYWxsU2l0ZTsAI0xqYXZhL2xh" +
+ "bmcvaW52b2tlL0NvbnN0YW50Q2FsbFNpdGU7AB9MamF2YS9sYW5nL2ludm9rZS9NZXRob2RI" +
+ "YW5kbGU7ACdMamF2YS9sYW5nL2ludm9rZS9NZXRob2RIYW5kbGVzJExvb2t1cDsAHUxqYXZh" +
+ "L2xhbmcvaW52b2tlL01ldGhvZFR5cGU7ACdSZXR1cm5pbmcgbnVsbCBpbnN0ZWFkIG9mIENh" +
+ "bGxTaXRlIGZvciAAAVMAJVRlc3RMaW5rZXJNZXRob2RNaW5pbWFsQXJndW1lbnRzLmphdmEA" +
+ "JVRocm93aW5nIEFyaXRobWV0aWNFeGNlcHRpb24gaW4gYWRkKCkAMVRocm93aW5nIEluc3Rh" +
+ "bnRpYXRpb25FeGNlcHRpb24gaW4gbGlua2VyTWV0aG9kKCkAAVYAA1ZCQgADVkNDAANWREQA" +
+ "A1ZGRgADVklJAARWSUlJAANWSkoAAlZMAANWTEwAA1ZTUwACVloAAVoAAlpMAAFhAANhZGQA" +
+ "BmFwcGVuZAANYXJndW1lbnRUeXBlcwAMYXNzZXJ0RXF1YWxzABFhc3NlcnRFcXVhbHMgYjE6" +
+ "IAARYXNzZXJ0RXF1YWxzIGMxOiAAEWFzc2VydEVxdWFscyBkMTogABFhc3NlcnRFcXVhbHMg" +
+ "ZjE6IAARYXNzZXJ0RXF1YWxzIGkxOiAAEWFzc2VydEVxdWFscyBsMTogABFhc3NlcnRFcXVh" +
+ "bHMgczE6IAASYXNzZXJ0RXF1YWxzOiBvMTogAAphc3NlcnRUcnVlABJhc3NlcnRUcnVlIHZh" +
+ "bHVlOiAAAWIAAmIxAAJiMgACYzEAAmMyAAZjYWxsZXIAAmQxAAJkMgASZW1pdHRlcjogamFj" +
+ "ay00LjI1AA1lbmNsb3NpbmdUeXBlAAZlcXVhbHMAAmYxAAJmMgALZmFpbHVyZVR5cGUACmZp" +
+ "bmRTdGF0aWMAEGZvcmNlRmFpbHVyZVR5cGUAAmkxAAJpMgASaW52b2tlTWV0aG9kSGFuZGxl" +
+ "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 0000000000..b96e18486f
--- /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" +
+ "EgAHAEsAAAASAAgASwAAABIACQBLAAAAEgAKAEsAAAASAAIAhQAAABYAGQAMAAAAGAAMAGsA" +
+ "AABpFAAABgAAAAEAAAAQAAAAAAAAADkAAABgCwAAkhQAAAAAAAAEAAAADgAAAAEAAACpEwAA" +
+ "AgAAAEcUAABgFAAAAQAAAGAUAAABAAAAAAAAAPgSAAAEAAAAEgBnAAAADgABAAEAAQAAAP4S" +
+ "AAAEAAAAcBATAAAADgADAAIAAAAAAAMTAAADAAAAkAABAg8AAAAFAAIAAgAAAAoTAAAoAAAA" +
+ "M0MDAA4AIgAOACIBEgBwEBYAAQAbAk4AAABuIB0AIQAMAW4gGgAxAAwBGwICAAAAbiAdACEA" +
+ "DAFuIBoAQQAMAW4QHwABAAwBcCASABAAJwAFAAIAAgAAABITAAAoAAAAM0MDAA4AIgAOACIB" +
+ "EgBwEBYAAQAbAk8AAABuIB0AIQAMAW4gFwAxAAwBGwIDAAAAbiAdACEADAFuIBcAQQAMAW4Q" +
+ "HwABAAwBcCASABAAJwAIAAQAAwAAABoTAAAqAAAALwAEBjkAAwAOACIADgAiARIAcBAWAAEA" +
+ "GwJQAAAAbiAdACEADAFuMBgAQQUMARsCBAAAAG4gHQAhAAwBbjAYAGEHDAFuEB8AAQAMAXAg" +
+ "EgAQACcABQACAAIAAAAiEwAAKgAAAC0AAwQ5AAMADgAiAA4AIgESAHAQFgABABsCUQAAAG4g" +
+ "HQAhAAwBbiAZADEADAEbAgUAAABuIB0AIQAMAW4gGQBBAAwBbhAfAAEADAFwIBIAEAAnAAUA" +
+ "AgACAAAAKhMAACgAAAAzQwMADgAiAA4AIgESAHAQFgABABsCUgAAAG4gHQAhAAwBbiAaADEA" +
+ "DAEbAgYAAABuIB0AIQAMAW4gGgBBAAwBbhAfAAEADAFwIBIAEAAnAAgABAADAAAAMhMAACoA" +
+ "AAAxAAQGOQADAA4AIgAOACIBEgBwEBYAAQAbAlMAAABuIB0AIQAMAW4wGwBBBQwBGwIHAAAA" +
+ "biAdACEADAFuMBsAYQcMAW4QHwABAAwBcCASABAAJwAFAAIAAgAAADoTAAAzAAAAM0MDAA4A" +
+ "OAMLADgECQBuIBQAQwAKADgAAwAOACIADgAiARIAcBAWAAEAGwJVAAAAbiAdACEADAFuIBwA" +
+ "MQAMARsCCAAAAG4gHQAhAAwBbiAcAEEADAFuEB8AAQAMAXAgEgAQACcAAAAFAAIAAgAAAEMT" +
+ "AAAzAAAAM0MDAA4AOAMLADgECQBuIBUAQwAKADgAAwAOACIADgAiARIAcBAWAAEAGwJUAAAA" +
+ "biAdACEADAFuIB0AMQAMARsCCQAAAG4gHQAhAAwBbiAdAEEADAFuEB8AAQAMAXAgEgAQACcA" +
+ "AAAFAAIAAgAAAFETAAAoAAAAM0MDAA4AIgAOACIBEgBwEBYAAQAbAlQAAABuIB0AIQAMAW4g" +
+ "GgAxAAwBGwIJAAAAbiAdACEADAFuIBoAQQAMAW4QHwABAAwBcCASABAAJwAEAAEAAgAAAFsT" +
+ "AAAdAAAAOQMcACIADgAiARIAcBAWAAEAGwJXAAAAbiAdACEADAFuIB4AMQAMAW4QHwABAAwB" +
+ "cCASABAAJwAOAAAAFgAPAAQAAABmEwAAbAAAAGIDAgAiBBIAcBAWAAQAGwUoAAAAbiAdAFQA" +
+ "DARuIB0AhAAMBBsFAAAAAG4gHQBUAAwEbiAcAJQADARuEB8ABAAMBG4gEQBDAHEQDQAKABIT" +
+ "cSAIALMAEwNhAHEgBQDDABMDAARxIAgA0wASE3EgCADjABQDmpkxQXEgBwDzABgEmpmZmZmZ" +
+ "AUAFABAAcUAGAFQQGwMSAAAACAASAHEgCwADABwDBgAIABMAcSAKAAMAFwQVzVsHBQAUAHFA" +
+ "CQBUEBwDBgBuQCEAN5gMAiIDFgBwICAAIwARAwQAAgACAAAAmRMAABEAAACQAAID/CAAADIA" +
+ "CgFxIAgAEABiAAIAkAECA24gEAAQAA4AAAACAAEAAAAAAKQTAAADAAAAYAAAAA8AAAAAAAAA" +
+ "AAAAAAMAAAAAAAAAAwAAAOAFAAAOAAAA6AUAAA8AAAD0BQAAAgAAAAQABAABAAAAAQAAAAEA" +
+ "AAACAAAAAQAAAAMAAAABAAAABAAAAAEAAAAFAAAAAQAAABAAAAABAAAAEQAAAAEAAAAcAAAA" +
+ "DQAAABgAEQAZABwAAAABABoABAADAAIAEQAPAAUAAAADAAAADwARABkAAAACAAAAAAAAAAIA" +
+ "AAABAAEAAgAAAAIAAgACAAAAAwADAAIAAAAFAAUAAgAAABAAEAACAAAAEQARAAEAAAAXAAAA" +
+ "AgAAABoAGgABIAABKAAGLCBiMjogAAYsIGMyOiAABiwgZDI6IAAGLCBmMjogAAYsIGkyOiAA" +
+ "BiwgbDI6IAAGLCBvMjogAAYsIHMyOiAABjwqPjtKKQAIPGNsaW5pdD4ABjxpbml0PgABQgAB" +
+ "QwABRAABRgAUR2V0Qm9vdHN0cmFwUnVuQ291bnQABUhlbGxvAAFJAANJSUkADUlOVk9LRV9T" +
+ "VEFUSUMAAUoAAUwAAkxDAAJMRAACTEYAAkxJAAJMSgACTEwABExMTEwADkxMTExaQkNTSUZE" +
+ "TExKACdMVGVzdExpbmtlck1ldGhvZE11bHRpcGxlQXJndW1lbnRUeXBlczsAAkxaADNMY29t" +
+ "L2FuZHJvaWQvamFjay9hbm5vdGF0aW9ucy9DYWxsZWRCeUludm9rZUN1c3RvbTsAJ0xjb20v" +
+ "YW5kcm9pZC9qYWNrL2Fubm90YXRpb25zL0NvbnN0YW50OwAxTGNvbS9hbmRyb2lkL2phY2sv" +
+ "YW5ub3RhdGlvbnMvTGlua2VyTWV0aG9kSGFuZGxlOwAvTGNvbS9hbmRyb2lkL2phY2svYW5u" +
+ "b3RhdGlvbnMvTWV0aG9kSGFuZGxlS2luZDsAHUxkYWx2aWsvYW5ub3RhdGlvbi9TaWduYXR1" +
+ "cmU7ABpMZGFsdmlrL2Fubm90YXRpb24vVGhyb3dzOwAITGlua2luZyAAFUxqYXZhL2lvL1By" +
+ "aW50U3RyZWFtOwAaTGphdmEvbGFuZy9Bc3NlcnRpb25FcnJvcjsAEExqYXZhL2xhbmcvQ2xh" +
+ "c3MAEUxqYXZhL2xhbmcvQ2xhc3M7ABRMamF2YS9sYW5nL0NsYXNzPCo+OwASTGphdmEvbGFu" +
+ "Zy9PYmplY3Q7ABJMamF2YS9sYW5nL1N0cmluZzsAGUxqYXZhL2xhbmcvU3RyaW5nQnVpbGRl" +
+ "cjsAEkxqYXZhL2xhbmcvU3lzdGVtOwAVTGphdmEvbGFuZy9UaHJvd2FibGU7ABtMamF2YS9s" +
+ "YW5nL2ludm9rZS9DYWxsU2l0ZTsAI0xqYXZhL2xhbmcvaW52b2tlL0NvbnN0YW50Q2FsbFNp" +
+ "dGU7AB9MamF2YS9sYW5nL2ludm9rZS9NZXRob2RIYW5kbGU7ACdMamF2YS9sYW5nL2ludm9r" +
+ "ZS9NZXRob2RIYW5kbGVzJExvb2t1cDsAHUxqYXZhL2xhbmcvaW52b2tlL01ldGhvZFR5cGU7" +
+ "AAFTACpUZXN0TGlua2VyTWV0aG9kTXVsdGlwbGVBcmd1bWVudFR5cGVzLmphdmEAAVYAA1ZC" +
+ "QgADVkNDAANWREQAA1ZGRgACVkkAA1ZJSQADVkpKAAJWTAADVkxMAANWU1MAAlZaAAFaAAda" +
+ "QkNTSUZEAAJaTAABYQADYWRkAAZhcHBlbmQADWFyZ3VtZW50VHlwZXMADGFzc2VydEVxdWFs" +
+ "cwARYXNzZXJ0RXF1YWxzIGIxOiAAEWFzc2VydEVxdWFscyBjMTogABFhc3NlcnRFcXVhbHMg" +
+ "ZDE6IAARYXNzZXJ0RXF1YWxzIGYxOiAAEWFzc2VydEVxdWFscyBpMTogABFhc3NlcnRFcXVh" +
+ "bHMgbDE6IAARYXNzZXJ0RXF1YWxzIHMxOiAAEmFzc2VydEVxdWFsczogbzE6IAAKYXNzZXJ0" +
+ "VHJ1ZQASYXNzZXJ0VHJ1ZSB2YWx1ZTogAAFiAAJiMQACYjIADGJvb2xlYW5WYWx1ZQARYm9v" +
+ "dHN0cmFwUnVuQ291bnQACWJ5dGVWYWx1ZQACYzEAAmMyAAZjYWxsZXIACWNoYXJWYWx1ZQAK" +
+ "Y2xhc3NWYWx1ZQACZDEAAmQyAAtkb3VibGVWYWx1ZQASZW1pdHRlcjogamFjay00LjI1AA1l" +
+ "bmNsb3NpbmdUeXBlAAZlcXVhbHMAAmYxAAJmMgAKZmluZFN0YXRpYwAKZmxvYXRWYWx1ZQAC" +
+ "aTEAAmkyAAhpbnRWYWx1ZQASaW52b2tlTWV0aG9kSGFuZGxlAARraW5kAAJsMQACbDIADGxp" +
+ "bmtlck1ldGhvZAAJbG9uZ1ZhbHVlABVtZXRob2RIYW5kbGVFeHRyYUFyZ3MACm1ldGhvZFR5" +
+ "cGUABm1oX2FkZAAEbmFtZQABbwADb3V0AAFwAAdwcmludGxuAApyZXR1cm5UeXBlAAJzMQAC" +
+ "czIACnNob3J0VmFsdWUAC3N0cmluZ1ZhbHVlAAR0ZXN0AAR0aGlzAAh0b1N0cmluZwACdjEA" +
+ "A3YxMAACdjIAAnYzAAJ2NAACdjUAAnY2AAJ2NwACdjgAAnY5AAV2YWx1ZQABeAABeQAeAAcO" +
+ "OQAcAAcOADECSlkHDgBZAlpbBw48AF4CX2AHDjwAdwJkZQcOWgByAmprBw5aAGgCbm8HDjwA" +
+ "bQJzdAcOWgB8Ant9Bw48tACCAQKAAYEBBw4tIKUgAGMCgAGBAQcOPABTAZEBBw4tARoQADkN" +
+ "YXp4hwGJAYoBiwGMAY0BjgGPAQCIAQQTkAEQLgcOASQPPEtaWktppYd4iGkDAnkYAE4CkgGT" +
+ "AQcOlngASgAHDgAABwVMHAIYBBgEcBwBHQkETBwNGBgYERgZGBwYABgBGBoYBBgDGAIYERgP" +
+ "GAVnGAZxGwF5F3R2HAodCAFbHAE/HQgBXRwBAAEdCAFhHAEDYR0IAYEBHAEiAAQdCAFvHAEE" +
+ "AR0IAWwcAXCamTFBHQgBZRwB8ZqZmZmZmQFAHQgBggEcARcSHQgBYhwBGAYdCAF1HAFmFc1b" +
+ "B3kXSn4YBAILAZABHAkXARc2Fy8XNxdHFy8XKxcKFzMCDAGQARwBGBQNFgAXShUBBAEEAQRh" +
+ "JAAEBAFwmpkxQfGamZmZmZkBQBcSGAZmFc1bBwEADwEACgCIgAT8CwGBgASUDAIKrAwBCcQM" +
+ "AQmkDQEJhA4BCegOAQnMDwEJrBABCZARAQmIEgEJgBMBCeATAQqsFAEJlBYCAcgWEwAAAAAA" +
+ "AAABAAAAAAAAAAEAAACTAAAAcAAAAAIAAAAdAAAAvAIAAAMAAAAdAAAAMAMAAAQAAAADAAAA" +
+ "jAQAAAUAAAAiAAAApAQAAAcAAAABAAAAtAUAAAYAAAABAAAAuAUAAAgAAAABAAAA2AUAAAMQ" +
+ "AAADAAAA4AUAAAEgAAAQAAAA/AUAAAYgAAABAAAAYAsAAAEQAAAUAAAAiAsAAAIgAACTAAAA" +
+ "RAwAAAMgAAAQAAAA+BIAAAQgAAADAAAAqRMAAAUgAAABAAAAaRQAAAAgAAABAAAAkhQAAAAQ" +
+ "AAABAAAA3BQAAA==";
+}
diff --git a/test/Android.bp b/test/Android.bp
index d3244a683a..00c890a834 100644
--- a/test/Android.bp
+++ b/test/Android.bp
@@ -274,6 +274,7 @@ art_cc_defaults {
"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 0000000000..67261cad79
--- /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 0000000000..3540bd10d5
--- /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 0000000000..e92549a086
--- /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 0000000000..2a2966738a
--- /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/etc/default-build b/test/etc/default-build
index e9e388646a..3d7b7dd046 100755
--- a/test/etc/default-build
+++ b/test/etc/default-build
@@ -60,6 +60,12 @@ else
HAS_SRC_DEX2OAT_UNRESOLVED=false
fi
+# Allow overriding ZIP_COMPRESSION_METHOD with e.g. 'store'
+ZIP_COMPRESSION_METHOD="deflate"
+# Align every ZIP file made by calling $ZIPALIGN command?
+WITH_ZIP_ALIGN=false
+ZIP_ALIGN_BYTES="-1"
+
DX_FLAGS=""
SKIP_DX_MERGER="false"
EXPERIMENTAL=""
@@ -73,6 +79,7 @@ JACK_EXPERIMENTAL_ARGS["agents"]="-D jack.java.source.version=1.8 -D jack.androi
JACK_EXPERIMENTAL_ARGS["default-methods"]="-D jack.java.source.version=1.8 -D jack.android.min-api-level=24"
JACK_EXPERIMENTAL_ARGS["lambdas"]="-D jack.java.source.version=1.8 -D jack.android.min-api-level=24"
JACK_EXPERIMENTAL_ARGS["method-handles"]="-D jack.java.source.version=1.7 -D jack.android.min-api-level=o-b1"
+JACK_EXPERIMENTAL_ARGS["java-8"]="-D jack.java.source.version=1.8 -D jack.android.min-api-level=24"
declare -A SMALI_EXPERIMENTAL_ARGS
SMALI_EXPERIMENTAL_ARGS["default-methods"]="--api-level 24"
@@ -118,6 +125,17 @@ while true; do
DEFAULT_EXPERIMENT=""
EXPERIMENTAL="${EXPERIMENTAL} $1"
shift
+ elif [ "x$1" = "x--zip-compression-method" ]; then
+ # Allow using different zip compression method, e.g. 'store'
+ shift
+ ZIP_COMPRESSION_METHOD="$1"
+ shift
+ elif [ "x$1" = "x--zip-align" ]; then
+ # Align ZIP entries to some # of bytes.
+ shift
+ WITH_ZIP_ALIGN=true
+ ZIP_ALIGN_BYTES="$1"
+ shift
elif expr "x$1" : "x--" >/dev/null 2>&1; then
echo "unknown $0 option: $1" 1>&2
exit 1
@@ -146,6 +164,26 @@ for experiment in ${EXPERIMENTAL}; do
JAVAC_ARGS="${JAVAC_ARGS} ${JAVAC_EXPERIMENTAL_ARGS[${experiment}]}"
done
+#########################################
+
+# Catch all commands to 'ZIP' and prepend extra flags.
+# Optionally, zipalign results to some alignment.
+function zip() {
+ local zip_target="$1"
+ local entry_src="$2"
+ shift 2
+
+ command zip --compression-method "$ZIP_COMPRESSION_METHOD" "$zip_target" "$entry_src" "$@"
+
+ if "$WITH_ZIP_ALIGN"; then
+ # zipalign does not operate in-place, so write results to a temp file.
+ local tmp_file="$(mktemp)"
+ "$ZIPALIGN" -f "$ZIP_ALIGN_BYTES" "$zip_target" "$tmp_file"
+ # replace original zip target with our temp file.
+ mv "$tmp_file" "$zip_target"
+ fi
+}
+
if [ -e classes.dex ]; then
zip $TEST_NAME.jar classes.dex
exit 0
@@ -234,7 +272,7 @@ else
fi
fi
-if [ "${HAS_SMALI}" = "true" ]; then
+if [ "${HAS_SMALI}" = "true" -a ${NEED_DEX} = "true" ]; then
# Compile Smali classes
${SMALI} -JXmx512m ${SMALI_ARGS} --output smali_classes.dex `find smali -name '*.smali'`
@@ -246,7 +284,7 @@ if [ "${HAS_SMALI}" = "true" ]; then
fi
fi
-if [ "${HAS_SMALI_MULTIDEX}" = "true" ]; then
+if [ "${HAS_SMALI_MULTIDEX}" = "true" -a ${NEED_DEX} = "true" ]; then
# Compile Smali classes
${SMALI} -JXmx512m ${SMALI_ARGS} --output smali_classes2.dex `find smali-multidex -name '*.smali'`
diff --git a/test/etc/run-test-jar b/test/etc/run-test-jar
index 186a1513ee..7d218f1d61 100755
--- a/test/etc/run-test-jar
+++ b/test/etc/run-test-jar
@@ -64,6 +64,10 @@ TEST_IS_NDEBUG="n"
APP_IMAGE="y"
VDEX_FILTER=""
+# if "y", run 'sync' before dalvikvm to make sure all files from
+# build step (e.g. dex2oat) were finished writing.
+SYNC_BEFORE_RUN="n"
+
while true; do
if [ "x$1" = "x--quiet" ]; then
QUIET="y"
@@ -262,6 +266,9 @@ while true; do
option="$1"
VDEX_FILTER="--compiler-filter=$option"
shift
+ elif [ "x$1" = "x--sync" ]; then
+ SYNC_BEFORE_RUN="y"
+ shift
elif expr "x$1" : "x--" >/dev/null 2>&1; then
echo "unknown $0 option: $1" 1>&2
exit 1
@@ -491,6 +498,7 @@ dex2oat_cmdline="true"
vdex_cmdline="true"
mkdir_locations="${DEX_LOCATION}/dalvik-cache/$ISA"
strip_cmdline="true"
+sync_cmdline="true"
if [ "$PREBUILD" = "y" ]; then
@@ -530,6 +538,10 @@ if [ "$STRIP_DEX" = "y" ]; then
strip_cmdline="zip --quiet --delete $DEX_LOCATION/$TEST_NAME.jar classes.dex"
fi
+if [ "$SYNC_BEFORE_RUN" = "y" ]; then
+ sync_cmdline="sync"
+fi
+
DALVIKVM_ISA_FEATURES_ARGS=""
if [ "x$INSTRUCTION_SET_FEATURES" != "x" ] ; then
DALVIKVM_ISA_FEATURES_ARGS="-Xcompiler-option --instruction-set-features=${INSTRUCTION_SET_FEATURES}"
@@ -589,7 +601,8 @@ if [ "$HOST" = "n" ]; then
LD_LIBRARY_PATH=$ANDROID_ROOT/$LIBRARY_DIRECTORY:$LD_LIBRARY_PATH
fi
- PUBLIC_LIBS=libart.so:libartd.so
+ # System libraries needed by libarttestd.so
+ PUBLIC_LIBS=libart.so:libartd.so:libc++.so:libbacktrace.so:libbase.so:libnativehelper.so
# Create a script with the command. The command can get longer than the longest
# allowed adb command and there is no way to get the exit status from a adb shell
@@ -607,6 +620,7 @@ if [ "$HOST" = "n" ]; then
$dex2oat_cmdline && \
$vdex_cmdline && \
$strip_cmdline && \
+ $sync_cmdline && \
$dalvikvm_cmdline"
cmdfile=$(tempfile -p "cmd-" -s "-$TEST_NAME")
@@ -679,7 +693,7 @@ else
fi
if [ "$DEV_MODE" = "y" ]; then
- echo "mkdir -p ${mkdir_locations} && $dex2oat_cmdline && $vdex_cmdline && $strip_cmdline && $cmdline"
+ echo "mkdir -p ${mkdir_locations} && $dex2oat_cmdline && $vdex_cmdline && $strip_cmdline && $sync_cmdline && $cmdline"
fi
cd $ANDROID_BUILD_TOP
@@ -689,6 +703,7 @@ else
$dex2oat_cmdline || { echo "Dex2oat failed." >&2 ; exit 2; }
$vdex_cmdline || { echo "Dex2oat failed." >&2 ; exit 2; }
$strip_cmdline || { echo "Strip failed." >&2 ; exit 3; }
+ $sync_cmdline || { echo "Sync failed." >&2 ; exit 4; }
# For running, we must turn off logging when dex2oat or patchoat are missing. Otherwise we use
# the same defaults as for prebuilt: everything when --dev, otherwise errors and above only.
diff --git a/test/run-test b/test/run-test
index 27c700e89e..c926c115e2 100755
--- a/test/run-test
+++ b/test/run-test
@@ -90,6 +90,22 @@ fi
export JACK="$JACK -g -cp $JACK_CLASSPATH"
+# Zipalign is not on the PATH in some configs, auto-detect it.
+if [ -z "$ZIPALIGN" ]; then
+ if which zipalign >/dev/null; then
+ ZIPALIGN="zipalign";
+ else
+ # TODO: Add a dependency for zipalign in Android.run-test.mk
+ # once it doesn't depend on libandroidfw (b/35246701)
+ case "$OSTYPE" in
+ darwin*) ZIPALIGN="$ANDROID_BUILD_TOP/prebuilts/sdk/tools/darwin/bin/zipalign" ;;
+ linux*) ZIPALIGN="$ANDROID_BUILD_TOP/prebuilts/sdk/tools/linux/bin/zipalign" ;;
+ *) echo "Can't find zipalign: unknown: $OSTYPE" >&2;;
+ esac
+ fi
+fi
+export ZIPALIGN
+
info="info.txt"
build="build"
run="run"
@@ -495,7 +511,7 @@ elif [ "$runtime" = "art" ]; then
run_args="${run_args} --runtime-option -Djava.library.path=${ANDROID_HOST_OUT}/lib${suffix64}:${ANDROID_HOST_OUT}/nativetest${suffix64}"
else
guess_target_arch_name
- run_args="${run_args} --runtime-option -Djava.library.path=/data/nativetest${suffix64}/art/${target_arch_name}:${android_root}/lib${suffix64}"
+ run_args="${run_args} --runtime-option -Djava.library.path=/data/nativetest${suffix64}/art/${target_arch_name}"
run_args="${run_args} --boot /data/art-test/core${image_suffix}${pic_image_suffix}${multi_image_suffix}.art"
fi
if [ "$relocate" = "yes" ]; then
diff --git a/test/ti-agent/common_load.cc b/test/ti-agent/common_load.cc
index c5a93568c6..351857d1d9 100644
--- a/test/ti-agent/common_load.cc
+++ b/test/ti-agent/common_load.cc
@@ -122,6 +122,7 @@ static AgentLib agents[] = {
{ "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) {