Merge "Fix CFI fixups for long branches on MIPS."
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 8bdff21..be82956 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -1283,14 +1283,13 @@
return IsImageClass(descriptor);
}
-bool CompilerDriver::CanAssumeTypeIsPresentInDexCache(const DexFile& dex_file, uint32_t type_idx) {
+bool CompilerDriver::CanAssumeTypeIsPresentInDexCache(Handle<mirror::DexCache> dex_cache,
+ uint32_t type_idx) {
bool result = false;
if ((IsBootImage() &&
- IsImageClass(dex_file.StringDataByIdx(dex_file.GetTypeId(type_idx).descriptor_idx_))) ||
+ IsImageClass(dex_cache->GetDexFile()->StringDataByIdx(
+ dex_cache->GetDexFile()->GetTypeId(type_idx).descriptor_idx_))) ||
Runtime::Current()->UseJit()) {
- ScopedObjectAccess soa(Thread::Current());
- mirror::DexCache* dex_cache = Runtime::Current()->GetClassLinker()->FindDexCache(
- soa.Self(), dex_file, false);
mirror::Class* resolved_class = dex_cache->GetResolvedType(type_idx);
result = (resolved_class != nullptr);
}
@@ -1332,32 +1331,16 @@
return result;
}
-bool CompilerDriver::CanAccessTypeWithoutChecks(uint32_t referrer_idx, const DexFile& dex_file,
- uint32_t type_idx,
- bool* type_known_final, bool* type_known_abstract,
- bool* equals_referrers_class) {
- if (type_known_final != nullptr) {
- *type_known_final = false;
- }
- if (type_known_abstract != nullptr) {
- *type_known_abstract = false;
- }
- if (equals_referrers_class != nullptr) {
- *equals_referrers_class = false;
- }
- ScopedObjectAccess soa(Thread::Current());
- mirror::DexCache* dex_cache = Runtime::Current()->GetClassLinker()->FindDexCache(
- soa.Self(), dex_file, false);
+bool CompilerDriver::CanAccessTypeWithoutChecks(uint32_t referrer_idx,
+ Handle<mirror::DexCache> dex_cache,
+ uint32_t type_idx) {
// Get type from dex cache assuming it was populated by the verifier
mirror::Class* resolved_class = dex_cache->GetResolvedType(type_idx);
if (resolved_class == nullptr) {
stats_->TypeNeedsAccessCheck();
return false; // Unknown class needs access checks.
}
- const DexFile::MethodId& method_id = dex_file.GetMethodId(referrer_idx);
- if (equals_referrers_class != nullptr) {
- *equals_referrers_class = (method_id.class_idx_ == type_idx);
- }
+ const DexFile::MethodId& method_id = dex_cache->GetDexFile()->GetMethodId(referrer_idx);
bool is_accessible = resolved_class->IsPublic(); // Public classes are always accessible.
if (!is_accessible) {
mirror::Class* referrer_class = dex_cache->GetResolvedType(method_id.class_idx_);
@@ -1371,12 +1354,6 @@
}
if (is_accessible) {
stats_->TypeDoesntNeedAccessCheck();
- if (type_known_final != nullptr) {
- *type_known_final = resolved_class->IsFinal() && !resolved_class->IsArrayClass();
- }
- if (type_known_abstract != nullptr) {
- *type_known_abstract = resolved_class->IsAbstract() && !resolved_class->IsArrayClass();
- }
} else {
stats_->TypeNeedsAccessCheck();
}
@@ -1384,12 +1361,9 @@
}
bool CompilerDriver::CanAccessInstantiableTypeWithoutChecks(uint32_t referrer_idx,
- const DexFile& dex_file,
+ Handle<mirror::DexCache> dex_cache,
uint32_t type_idx,
bool* finalizable) {
- ScopedObjectAccess soa(Thread::Current());
- mirror::DexCache* dex_cache = Runtime::Current()->GetClassLinker()->FindDexCache(
- soa.Self(), dex_file, false);
// Get type from dex cache assuming it was populated by the verifier.
mirror::Class* resolved_class = dex_cache->GetResolvedType(type_idx);
if (resolved_class == nullptr) {
@@ -1399,7 +1373,7 @@
return false; // Unknown class needs access checks.
}
*finalizable = resolved_class->IsFinalizable();
- const DexFile::MethodId& method_id = dex_file.GetMethodId(referrer_idx);
+ const DexFile::MethodId& method_id = dex_cache->GetDexFile()->GetMethodId(referrer_idx);
bool is_accessible = resolved_class->IsPublic(); // Public classes are always accessible.
if (!is_accessible) {
mirror::Class* referrer_class = dex_cache->GetResolvedType(method_id.class_idx_);
@@ -1587,53 +1561,6 @@
}
}
-bool CompilerDriver::ComputeStaticFieldInfo(uint32_t field_idx, const DexCompilationUnit* mUnit,
- bool is_put, MemberOffset* field_offset,
- uint32_t* storage_index, bool* is_referrers_class,
- bool* is_volatile, bool* is_initialized,
- Primitive::Type* type) {
- ScopedObjectAccess soa(Thread::Current());
- // Try to resolve the field and compiling method's class.
- ArtField* resolved_field;
- mirror::Class* referrer_class;
- Handle<mirror::DexCache> dex_cache(mUnit->GetDexCache());
- {
- StackHandleScope<1> hs(soa.Self());
- Handle<mirror::ClassLoader> class_loader_handle(
- hs.NewHandle(soa.Decode<mirror::ClassLoader*>(mUnit->GetClassLoader())));
- resolved_field =
- ResolveField(soa, dex_cache, class_loader_handle, mUnit, field_idx, true);
- referrer_class = resolved_field != nullptr
- ? ResolveCompilingMethodsClass(soa, dex_cache, class_loader_handle, mUnit) : nullptr;
- }
- bool result = false;
- if (resolved_field != nullptr && referrer_class != nullptr) {
- *is_volatile = IsFieldVolatile(resolved_field);
- std::pair<bool, bool> fast_path = IsFastStaticField(
- dex_cache.Get(), referrer_class, resolved_field, field_idx, storage_index);
- result = is_put ? fast_path.second : fast_path.first;
- }
- if (result) {
- *field_offset = GetFieldOffset(resolved_field);
- *is_referrers_class = IsStaticFieldInReferrerClass(referrer_class, resolved_field);
- // *is_referrers_class == true implies no worrying about class initialization.
- *is_initialized = (*is_referrers_class) ||
- (IsStaticFieldsClassInitialized(referrer_class, resolved_field) &&
- CanAssumeTypeIsPresentInDexCache(*mUnit->GetDexFile(), *storage_index));
- *type = resolved_field->GetTypeAsPrimitiveType();
- } else {
- // Conservative defaults.
- *is_volatile = true;
- *field_offset = MemberOffset(static_cast<size_t>(-1));
- *storage_index = -1;
- *is_referrers_class = false;
- *is_initialized = false;
- *type = Primitive::kPrimVoid;
- }
- ProcessedStaticField(result, *is_referrers_class);
- return result;
-}
-
void CompilerDriver::GetCodeAndMethodForDirectCall(InvokeType* type, InvokeType sharp_type,
bool no_guarantee_of_dex_cache_entry,
const mirror::Class* referrer_class,
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index 4308eac..d63dffa 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -195,25 +195,26 @@
// Callbacks from compiler to see what runtime checks must be generated.
- bool CanAssumeTypeIsPresentInDexCache(const DexFile& dex_file, uint32_t type_idx);
+ bool CanAssumeTypeIsPresentInDexCache(Handle<mirror::DexCache> dex_cache,
+ uint32_t type_idx)
+ SHARED_REQUIRES(Locks::mutator_lock_);
bool CanAssumeStringIsPresentInDexCache(const DexFile& dex_file, uint32_t string_idx)
REQUIRES(!Locks::mutator_lock_);
// Are runtime access checks necessary in the compiled code?
- bool CanAccessTypeWithoutChecks(uint32_t referrer_idx, const DexFile& dex_file,
- uint32_t type_idx, bool* type_known_final = nullptr,
- bool* type_known_abstract = nullptr,
- bool* equals_referrers_class = nullptr)
- REQUIRES(!Locks::mutator_lock_);
+ bool CanAccessTypeWithoutChecks(uint32_t referrer_idx,
+ Handle<mirror::DexCache> dex_cache,
+ uint32_t type_idx)
+ SHARED_REQUIRES(Locks::mutator_lock_);
// Are runtime access and instantiable checks necessary in the code?
// out_is_finalizable is set to whether the type is finalizable.
bool CanAccessInstantiableTypeWithoutChecks(uint32_t referrer_idx,
- const DexFile& dex_file,
+ Handle<mirror::DexCache> dex_cache,
uint32_t type_idx,
bool* out_is_finalizable)
- REQUIRES(!Locks::mutator_lock_);
+ SHARED_REQUIRES(Locks::mutator_lock_);
bool CanEmbedTypeInCode(const DexFile& dex_file, uint32_t type_idx,
bool* is_type_initialized, bool* use_direct_type_ptr,
@@ -368,14 +369,6 @@
SHARED_REQUIRES(Locks::mutator_lock_);
- // Can we fastpath static field access? Computes field's offset, volatility and whether the
- // field is within the referrer (which can avoid checking class initialization).
- bool ComputeStaticFieldInfo(uint32_t field_idx, const DexCompilationUnit* mUnit, bool is_put,
- MemberOffset* field_offset, uint32_t* storage_index,
- bool* is_referrers_class, bool* is_volatile, bool* is_initialized,
- Primitive::Type* type)
- REQUIRES(!Locks::mutator_lock_);
-
// Can we fastpath a interface, super class or virtual method call? Computes method's vtable
// index.
bool ComputeInvokeInfo(const DexCompilationUnit* mUnit, const uint32_t dex_pc,
diff --git a/compiler/optimizing/builder.h b/compiler/optimizing/builder.h
index 4f46d5e..580ef72 100644
--- a/compiler/optimizing/builder.h
+++ b/compiler/optimizing/builder.h
@@ -51,7 +51,7 @@
compiler_driver_(driver),
compilation_stats_(compiler_stats),
block_builder_(graph, dex_file, code_item),
- ssa_builder_(graph, handles),
+ ssa_builder_(graph, dex_compilation_unit->GetDexCache(), handles),
instruction_builder_(graph,
&block_builder_,
&ssa_builder_,
@@ -78,7 +78,7 @@
null_dex_cache_(),
compilation_stats_(nullptr),
block_builder_(graph, nullptr, code_item),
- ssa_builder_(graph, handles),
+ ssa_builder_(graph, null_dex_cache_, handles),
instruction_builder_(graph,
&block_builder_,
&ssa_builder_,
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index 77e0cbc..d60298b9 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -411,7 +411,10 @@
// Run type propagation to get the guard typed, and eventually propagate the
// type of the receiver.
- ReferenceTypePropagation rtp_fixup(graph_, handles_, /* is_first_run */ false);
+ ReferenceTypePropagation rtp_fixup(graph_,
+ outer_compilation_unit_.GetDexCache(),
+ handles_,
+ /* is_first_run */ false);
rtp_fixup.Run();
MaybeRecordStat(kInlinedMonomorphicCall);
@@ -532,7 +535,10 @@
MaybeRecordStat(kInlinedPolymorphicCall);
// Run type propagation to get the guards typed.
- ReferenceTypePropagation rtp_fixup(graph_, handles_, /* is_first_run */ false);
+ ReferenceTypePropagation rtp_fixup(graph_,
+ outer_compilation_unit_.GetDexCache(),
+ handles_,
+ /* is_first_run */ false);
rtp_fixup.Run();
return true;
}
@@ -709,7 +715,10 @@
deoptimize->CopyEnvironmentFrom(invoke_instruction->GetEnvironment());
// Run type propagation to get the guard typed.
- ReferenceTypePropagation rtp_fixup(graph_, handles_, /* is_first_run */ false);
+ ReferenceTypePropagation rtp_fixup(graph_,
+ outer_compilation_unit_.GetDexCache(),
+ handles_,
+ /* is_first_run */ false);
rtp_fixup.Run();
MaybeRecordStat(kInlinedPolymorphicCall);
@@ -971,7 +980,8 @@
// dex pc for the associated stack map. 0 is bogus but valid. Bug: 26854537.
/* dex_pc */ 0);
if (iget->GetType() == Primitive::kPrimNot) {
- ReferenceTypePropagation rtp(graph_, handles_, /* is_first_run */ false);
+ // Use the same dex_cache that we used for field lookup as the hint_dex_cache.
+ ReferenceTypePropagation rtp(graph_, dex_cache, handles_, /* is_first_run */ false);
rtp.Visit(iget);
}
return iget;
@@ -1319,13 +1329,19 @@
if (invoke_rti.IsStrictSupertypeOf(return_rti)
|| (return_rti.IsExact() && !invoke_rti.IsExact())
|| !return_replacement->CanBeNull()) {
- ReferenceTypePropagation(graph_, handles_, /* is_first_run */ false).Run();
+ ReferenceTypePropagation(graph_,
+ outer_compilation_unit_.GetDexCache(),
+ handles_,
+ /* is_first_run */ false).Run();
}
}
} else if (return_replacement->IsInstanceOf()) {
if (do_rtp) {
// Inlining InstanceOf into an If may put a tighter bound on reference types.
- ReferenceTypePropagation(graph_, handles_, /* is_first_run */ false).Run();
+ ReferenceTypePropagation(graph_,
+ outer_compilation_unit_.GetDexCache(),
+ handles_,
+ /* is_first_run */ false).Run();
}
}
}
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc
index 06b3968..f5e49c2 100644
--- a/compiler/optimizing/instruction_builder.cc
+++ b/compiler/optimizing/instruction_builder.cc
@@ -889,8 +889,15 @@
}
bool HInstructionBuilder::BuildNewInstance(uint16_t type_index, uint32_t dex_pc) {
+ ScopedObjectAccess soa(Thread::Current());
+ StackHandleScope<1> hs(soa.Self());
+ Handle<mirror::DexCache> dex_cache = dex_compilation_unit_->GetDexCache();
+ Handle<mirror::Class> resolved_class(hs.NewHandle(dex_cache->GetResolvedType(type_index)));
+ const DexFile& outer_dex_file = *outer_compilation_unit_->GetDexFile();
+ Handle<mirror::DexCache> outer_dex_cache = outer_compilation_unit_->GetDexCache();
+
bool finalizable;
- bool can_throw = NeedsAccessCheck(type_index, &finalizable);
+ bool can_throw = NeedsAccessCheck(type_index, dex_cache, &finalizable);
// Only the non-resolved entrypoint handles the finalizable class case. If we
// need access checks, then we haven't resolved the method and the class may
@@ -899,16 +906,6 @@
? kQuickAllocObject
: kQuickAllocObjectInitialized;
- ScopedObjectAccess soa(Thread::Current());
- StackHandleScope<3> hs(soa.Self());
- Handle<mirror::DexCache> dex_cache(hs.NewHandle(
- dex_compilation_unit_->GetClassLinker()->FindDexCache(
- soa.Self(), *dex_compilation_unit_->GetDexFile())));
- Handle<mirror::Class> resolved_class(hs.NewHandle(dex_cache->GetResolvedType(type_index)));
- const DexFile& outer_dex_file = *outer_compilation_unit_->GetDexFile();
- Handle<mirror::DexCache> outer_dex_cache(hs.NewHandle(
- outer_compilation_unit_->GetClassLinker()->FindDexCache(soa.Self(), outer_dex_file)));
-
if (outer_dex_cache.Get() != dex_cache.Get()) {
// We currently do not support inlining allocations across dex files.
return false;
@@ -921,7 +918,7 @@
IsOutermostCompilingClass(type_index),
dex_pc,
/*needs_access_check*/ can_throw,
- compiler_driver_->CanAssumeTypeIsPresentInDexCache(outer_dex_file, type_index));
+ compiler_driver_->CanAssumeTypeIsPresentInDexCache(outer_dex_cache, type_index));
AppendInstruction(load_class);
HInstruction* cls = load_class;
@@ -979,13 +976,9 @@
HInvokeStaticOrDirect::ClinitCheckRequirement* clinit_check_requirement) {
const DexFile& outer_dex_file = *outer_compilation_unit_->GetDexFile();
Thread* self = Thread::Current();
- StackHandleScope<4> hs(self);
- Handle<mirror::DexCache> dex_cache(hs.NewHandle(
- dex_compilation_unit_->GetClassLinker()->FindDexCache(
- self, *dex_compilation_unit_->GetDexFile())));
- Handle<mirror::DexCache> outer_dex_cache(hs.NewHandle(
- outer_compilation_unit_->GetClassLinker()->FindDexCache(
- self, outer_dex_file)));
+ StackHandleScope<2> hs(self);
+ Handle<mirror::DexCache> dex_cache = dex_compilation_unit_->GetDexCache();
+ Handle<mirror::DexCache> outer_dex_cache = outer_compilation_unit_->GetDexCache();
Handle<mirror::Class> outer_class(hs.NewHandle(GetOutermostCompilingClass()));
Handle<mirror::Class> resolved_method_class(hs.NewHandle(resolved_method->GetDeclaringClass()));
@@ -1016,7 +1009,7 @@
is_outer_class,
dex_pc,
/*needs_access_check*/ false,
- compiler_driver_->CanAssumeTypeIsPresentInDexCache(outer_dex_file, storage_index));
+ compiler_driver_->CanAssumeTypeIsPresentInDexCache(outer_dex_cache, storage_index));
AppendInstruction(load_class);
clinit_check = new (arena_) HClinitCheck(load_class, dex_pc);
AppendInstruction(clinit_check);
@@ -1261,12 +1254,10 @@
static mirror::Class* GetClassFrom(CompilerDriver* driver,
const DexCompilationUnit& compilation_unit) {
ScopedObjectAccess soa(Thread::Current());
- StackHandleScope<2> hs(soa.Self());
- const DexFile& dex_file = *compilation_unit.GetDexFile();
+ StackHandleScope<1> hs(soa.Self());
Handle<mirror::ClassLoader> class_loader(hs.NewHandle(
soa.Decode<mirror::ClassLoader*>(compilation_unit.GetClassLoader())));
- Handle<mirror::DexCache> dex_cache(hs.NewHandle(
- compilation_unit.GetClassLinker()->FindDexCache(soa.Self(), dex_file)));
+ Handle<mirror::DexCache> dex_cache = compilation_unit.GetDexCache();
return driver->ResolveCompilingMethodsClass(soa, dex_cache, class_loader, &compilation_unit);
}
@@ -1281,10 +1272,8 @@
bool HInstructionBuilder::IsOutermostCompilingClass(uint16_t type_index) const {
ScopedObjectAccess soa(Thread::Current());
- StackHandleScope<4> hs(soa.Self());
- Handle<mirror::DexCache> dex_cache(hs.NewHandle(
- dex_compilation_unit_->GetClassLinker()->FindDexCache(
- soa.Self(), *dex_compilation_unit_->GetDexFile())));
+ StackHandleScope<3> hs(soa.Self());
+ Handle<mirror::DexCache> dex_cache = dex_compilation_unit_->GetDexCache();
Handle<mirror::ClassLoader> class_loader(hs.NewHandle(
soa.Decode<mirror::ClassLoader*>(dex_compilation_unit_->GetClassLoader())));
Handle<mirror::Class> cls(hs.NewHandle(compiler_driver_->ResolveClass(
@@ -1324,10 +1313,8 @@
uint16_t field_index = instruction.VRegB_21c();
ScopedObjectAccess soa(Thread::Current());
- StackHandleScope<5> hs(soa.Self());
- Handle<mirror::DexCache> dex_cache(hs.NewHandle(
- dex_compilation_unit_->GetClassLinker()->FindDexCache(
- soa.Self(), *dex_compilation_unit_->GetDexFile())));
+ StackHandleScope<3> hs(soa.Self());
+ Handle<mirror::DexCache> dex_cache = dex_compilation_unit_->GetDexCache();
Handle<mirror::ClassLoader> class_loader(hs.NewHandle(
soa.Decode<mirror::ClassLoader*>(dex_compilation_unit_->GetClassLoader())));
ArtField* resolved_field = compiler_driver_->ResolveField(
@@ -1342,8 +1329,7 @@
Primitive::Type field_type = resolved_field->GetTypeAsPrimitiveType();
const DexFile& outer_dex_file = *outer_compilation_unit_->GetDexFile();
- Handle<mirror::DexCache> outer_dex_cache(hs.NewHandle(
- outer_compilation_unit_->GetClassLinker()->FindDexCache(soa.Self(), outer_dex_file)));
+ Handle<mirror::DexCache> outer_dex_cache = outer_compilation_unit_->GetDexCache();
Handle<mirror::Class> outer_class(hs.NewHandle(GetOutermostCompilingClass()));
// The index at which the field's class is stored in the DexCache's type array.
@@ -1371,7 +1357,7 @@
}
bool is_in_cache =
- compiler_driver_->CanAssumeTypeIsPresentInDexCache(outer_dex_file, storage_index);
+ compiler_driver_->CanAssumeTypeIsPresentInDexCache(outer_dex_cache, storage_index);
HLoadClass* constant = new (arena_) HLoadClass(graph_->GetCurrentMethod(),
storage_index,
outer_dex_file,
@@ -1634,21 +1620,16 @@
uint8_t reference,
uint16_t type_index,
uint32_t dex_pc) {
- bool type_known_final, type_known_abstract, use_declaring_class;
+ ScopedObjectAccess soa(Thread::Current());
+ StackHandleScope<1> hs(soa.Self());
+ const DexFile& dex_file = *dex_compilation_unit_->GetDexFile();
+ Handle<mirror::DexCache> dex_cache = dex_compilation_unit_->GetDexCache();
+ Handle<mirror::Class> resolved_class(hs.NewHandle(dex_cache->GetResolvedType(type_index)));
+
bool can_access = compiler_driver_->CanAccessTypeWithoutChecks(
dex_compilation_unit_->GetDexMethodIndex(),
- *dex_compilation_unit_->GetDexFile(),
- type_index,
- &type_known_final,
- &type_known_abstract,
- &use_declaring_class);
-
- ScopedObjectAccess soa(Thread::Current());
- StackHandleScope<2> hs(soa.Self());
- const DexFile& dex_file = *dex_compilation_unit_->GetDexFile();
- Handle<mirror::DexCache> dex_cache(hs.NewHandle(
- dex_compilation_unit_->GetClassLinker()->FindDexCache(soa.Self(), dex_file)));
- Handle<mirror::Class> resolved_class(hs.NewHandle(dex_cache->GetResolvedType(type_index)));
+ dex_cache,
+ type_index);
HInstruction* object = LoadLocal(reference, Primitive::kPrimNot);
HLoadClass* cls = new (arena_) HLoadClass(
@@ -1658,7 +1639,7 @@
IsOutermostCompilingClass(type_index),
dex_pc,
!can_access,
- compiler_driver_->CanAssumeTypeIsPresentInDexCache(dex_file, type_index));
+ compiler_driver_->CanAssumeTypeIsPresentInDexCache(dex_cache, type_index));
AppendInstruction(cls);
TypeCheckKind check_kind = ComputeTypeCheckKind(resolved_class);
@@ -1676,9 +1657,17 @@
}
}
-bool HInstructionBuilder::NeedsAccessCheck(uint32_t type_index, bool* finalizable) const {
+bool HInstructionBuilder::NeedsAccessCheck(uint32_t type_index,
+ Handle<mirror::DexCache> dex_cache,
+ bool* finalizable) const {
return !compiler_driver_->CanAccessInstantiableTypeWithoutChecks(
- dex_compilation_unit_->GetDexMethodIndex(), *dex_file_, type_index, finalizable);
+ dex_compilation_unit_->GetDexMethodIndex(), dex_cache, type_index, finalizable);
+}
+
+bool HInstructionBuilder::NeedsAccessCheck(uint32_t type_index, bool* finalizable) const {
+ ScopedObjectAccess soa(Thread::Current());
+ Handle<mirror::DexCache> dex_cache = dex_compilation_unit_->GetDexCache();
+ return NeedsAccessCheck(type_index, dex_cache, finalizable);
}
bool HInstructionBuilder::CanDecodeQuickenedInfo() const {
@@ -2612,16 +2601,16 @@
case Instruction::CONST_CLASS: {
uint16_t type_index = instruction.VRegB_21c();
- bool type_known_final;
- bool type_known_abstract;
- bool dont_use_is_referrers_class;
// `CanAccessTypeWithoutChecks` will tell whether the method being
// built is trying to access its own class, so that the generated
// code can optimize for this case. However, the optimization does not
// work for inlining, so we use `IsOutermostCompilingClass` instead.
+ ScopedObjectAccess soa(Thread::Current());
+ Handle<mirror::DexCache> dex_cache = dex_compilation_unit_->GetDexCache();
bool can_access = compiler_driver_->CanAccessTypeWithoutChecks(
- dex_compilation_unit_->GetDexMethodIndex(), *dex_file_, type_index,
- &type_known_final, &type_known_abstract, &dont_use_is_referrers_class);
+ dex_compilation_unit_->GetDexMethodIndex(), dex_cache, type_index);
+ bool is_in_dex_cache =
+ compiler_driver_->CanAssumeTypeIsPresentInDexCache(dex_cache, type_index);
AppendInstruction(new (arena_) HLoadClass(
graph_->GetCurrentMethod(),
type_index,
@@ -2629,7 +2618,7 @@
IsOutermostCompilingClass(type_index),
dex_pc,
!can_access,
- compiler_driver_->CanAssumeTypeIsPresentInDexCache(*dex_file_, type_index)));
+ is_in_dex_cache));
UpdateLocal(instruction.VRegA_21c(), current_block_->GetLastInstruction());
break;
}
diff --git a/compiler/optimizing/instruction_builder.h b/compiler/optimizing/instruction_builder.h
index f480b70..070f7da 100644
--- a/compiler/optimizing/instruction_builder.h
+++ b/compiler/optimizing/instruction_builder.h
@@ -97,6 +97,10 @@
// Returns whether the current method needs access check for the type.
// Output parameter finalizable is set to whether the type is finalizable.
+ bool NeedsAccessCheck(uint32_t type_index,
+ Handle<mirror::DexCache> dex_cache,
+ /*out*/bool* finalizable) const
+ SHARED_REQUIRES(Locks::mutator_lock_);
bool NeedsAccessCheck(uint32_t type_index, /*out*/bool* finalizable) const;
template<typename T>
diff --git a/compiler/optimizing/licm.cc b/compiler/optimizing/licm.cc
index 7a1e06b..5a0b89c 100644
--- a/compiler/optimizing/licm.cc
+++ b/compiler/optimizing/licm.cc
@@ -79,8 +79,15 @@
void LICM::Run() {
DCHECK(side_effects_.HasRun());
+
// Only used during debug.
- ArenaBitVector visited(graph_->GetArena(), graph_->GetBlocks().size(), false, kArenaAllocLICM);
+ ArenaBitVector* visited = nullptr;
+ if (kIsDebugBuild) {
+ visited = new (graph_->GetArena()) ArenaBitVector(graph_->GetArena(),
+ graph_->GetBlocks().size(),
+ false,
+ kArenaAllocLICM);
+ }
// Post order visit to visit inner loops before outer loops.
for (HPostOrderIterator it(*graph_); !it.Done(); it.Advance()) {
@@ -109,10 +116,12 @@
DCHECK(inner->IsInLoop());
if (inner->GetLoopInformation() != loop_info) {
// Thanks to post order visit, inner loops were already visited.
- DCHECK(visited.IsBitSet(inner->GetBlockId()));
+ DCHECK(visited->IsBitSet(inner->GetBlockId()));
continue;
}
- visited.SetBit(inner->GetBlockId());
+ if (kIsDebugBuild) {
+ visited->SetBit(inner->GetBlockId());
+ }
if (contains_irreducible_loop) {
// We cannot licm in an irreducible loop, or in a natural loop containing an
diff --git a/compiler/optimizing/licm_test.cc b/compiler/optimizing/licm_test.cc
index 2a62643..d446539 100644
--- a/compiler/optimizing/licm_test.cc
+++ b/compiler/optimizing/licm_test.cc
@@ -169,11 +169,13 @@
BuildLoop();
// Populate the loop with instructions: set/get array with different types.
+ // ArrayGet is typed as kPrimByte and ArraySet given a float value in order to
+ // avoid SsaBuilder's typing of ambiguous array operations from reference type info.
HInstruction* get_array = new (&allocator_) HArrayGet(
- parameter_, int_constant_, Primitive::kPrimInt, 0);
+ parameter_, int_constant_, Primitive::kPrimByte, 0);
loop_body_->InsertInstructionBefore(get_array, loop_body_->GetLastInstruction());
HInstruction* set_array = new (&allocator_) HArraySet(
- parameter_, int_constant_, float_constant_, Primitive::kPrimFloat, 0);
+ parameter_, int_constant_, float_constant_, Primitive::kPrimShort, 0);
loop_body_->InsertInstructionBefore(set_array, loop_body_->GetLastInstruction());
EXPECT_EQ(get_array->GetBlock(), loop_body_);
@@ -187,11 +189,13 @@
BuildLoop();
// Populate the loop with instructions: set/get array with same types.
+ // ArrayGet is typed as kPrimByte and ArraySet given a float value in order to
+ // avoid SsaBuilder's typing of ambiguous array operations from reference type info.
HInstruction* get_array = new (&allocator_) HArrayGet(
- parameter_, int_constant_, Primitive::kPrimFloat, 0);
+ parameter_, int_constant_, Primitive::kPrimByte, 0);
loop_body_->InsertInstructionBefore(get_array, loop_body_->GetLastInstruction());
HInstruction* set_array = new (&allocator_) HArraySet(
- parameter_, get_array, float_constant_, Primitive::kPrimFloat, 0);
+ parameter_, get_array, float_constant_, Primitive::kPrimByte, 0);
loop_body_->InsertInstructionBefore(set_array, loop_body_->GetLastInstruction());
EXPECT_EQ(get_array->GetBlock(), loop_body_);
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index 6f3e536..7fc39cb 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -169,7 +169,7 @@
return handle.GetReference() != nullptr;
}
- bool IsValid() const SHARED_REQUIRES(Locks::mutator_lock_) {
+ bool IsValid() const {
return IsValidHandle(type_handle_);
}
@@ -1551,21 +1551,21 @@
static SideEffects FieldWriteOfType(Primitive::Type type, bool is_volatile) {
return is_volatile
? AllWritesAndReads()
- : SideEffects(TypeFlag(type, kFieldWriteOffset));
+ : SideEffects(TypeFlagWithAlias(type, kFieldWriteOffset));
}
static SideEffects ArrayWriteOfType(Primitive::Type type) {
- return SideEffects(TypeFlag(type, kArrayWriteOffset));
+ return SideEffects(TypeFlagWithAlias(type, kArrayWriteOffset));
}
static SideEffects FieldReadOfType(Primitive::Type type, bool is_volatile) {
return is_volatile
? AllWritesAndReads()
- : SideEffects(TypeFlag(type, kFieldReadOffset));
+ : SideEffects(TypeFlagWithAlias(type, kFieldReadOffset));
}
static SideEffects ArrayReadOfType(Primitive::Type type) {
- return SideEffects(TypeFlag(type, kArrayReadOffset));
+ return SideEffects(TypeFlagWithAlias(type, kArrayReadOffset));
}
static SideEffects CanTriggerGC() {
@@ -1692,6 +1692,23 @@
static constexpr uint64_t kAllReads =
((1ULL << (kLastBitForReads + 1 - kFieldReadOffset)) - 1) << kFieldReadOffset;
+ // Work around the fact that HIR aliases I/F and J/D.
+ // TODO: remove this interceptor once HIR types are clean
+ static uint64_t TypeFlagWithAlias(Primitive::Type type, int offset) {
+ switch (type) {
+ case Primitive::kPrimInt:
+ case Primitive::kPrimFloat:
+ return TypeFlag(Primitive::kPrimInt, offset) |
+ TypeFlag(Primitive::kPrimFloat, offset);
+ case Primitive::kPrimLong:
+ case Primitive::kPrimDouble:
+ return TypeFlag(Primitive::kPrimLong, offset) |
+ TypeFlag(Primitive::kPrimDouble, offset);
+ default:
+ return TypeFlag(type, offset);
+ }
+ }
+
// Translates type to bit flag.
static uint64_t TypeFlag(Primitive::Type type, int offset) {
CHECK_NE(type, Primitive::kPrimVoid);
@@ -1916,7 +1933,7 @@
ReferenceTypeInfo GetReferenceTypeInfo() const {
DCHECK_EQ(GetType(), Primitive::kPrimNot);
return ReferenceTypeInfo::CreateUnchecked(reference_type_handle_,
- GetPackedFlag<kFlagReferenceTypeIsExact>());;
+ GetPackedFlag<kFlagReferenceTypeIsExact>());
}
void AddUseAt(HInstruction* user, size_t index) {
@@ -5179,8 +5196,10 @@
uint32_t dex_pc,
SideEffects additional_side_effects = SideEffects::None())
: HTemplateInstruction(
- SideEffectsForArchRuntimeCalls(value->GetType()).Union(additional_side_effects),
- dex_pc) {
+ SideEffects::ArrayWriteOfType(expected_component_type).Union(
+ SideEffectsForArchRuntimeCalls(value->GetType())).Union(
+ additional_side_effects),
+ dex_pc) {
SetPackedField<ExpectedComponentTypeField>(expected_component_type);
SetPackedFlag<kFlagNeedsTypeCheck>(value->GetType() == Primitive::kPrimNot);
SetPackedFlag<kFlagValueCanBeNull>(true);
@@ -5188,8 +5207,6 @@
SetRawInputAt(0, array);
SetRawInputAt(1, index);
SetRawInputAt(2, value);
- // We can now call component type logic to set correct type-based side effects.
- AddSideEffects(SideEffects::ArrayWriteOfType(GetComponentType()));
}
bool NeedsEnvironment() const OVERRIDE {
diff --git a/compiler/optimizing/reference_type_propagation.cc b/compiler/optimizing/reference_type_propagation.cc
index 95f10e0..961e3b4 100644
--- a/compiler/optimizing/reference_type_propagation.cc
+++ b/compiler/optimizing/reference_type_propagation.cc
@@ -23,6 +23,17 @@
namespace art {
+static inline mirror::DexCache* FindDexCacheWithHint(Thread* self,
+ const DexFile& dex_file,
+ Handle<mirror::DexCache> hint_dex_cache)
+ SHARED_REQUIRES(Locks::mutator_lock_) {
+ if (LIKELY(hint_dex_cache->GetDexFile() == &dex_file)) {
+ return hint_dex_cache.Get();
+ } else {
+ return Runtime::Current()->GetClassLinker()->FindDexCache(self, dex_file);
+ }
+}
+
static inline ReferenceTypeInfo::TypeHandle GetRootHandle(StackHandleScopeCollection* handles,
ClassLinker::ClassRoot class_root,
ReferenceTypeInfo::TypeHandle* cache) {
@@ -54,10 +65,12 @@
class ReferenceTypePropagation::RTPVisitor : public HGraphDelegateVisitor {
public:
RTPVisitor(HGraph* graph,
+ Handle<mirror::DexCache> hint_dex_cache,
HandleCache* handle_cache,
ArenaVector<HInstruction*>* worklist,
bool is_first_run)
: HGraphDelegateVisitor(graph),
+ hint_dex_cache_(hint_dex_cache),
handle_cache_(handle_cache),
worklist_(worklist),
is_first_run_(is_first_run) {}
@@ -86,16 +99,19 @@
bool is_exact);
private:
+ Handle<mirror::DexCache> hint_dex_cache_;
HandleCache* handle_cache_;
ArenaVector<HInstruction*>* worklist_;
const bool is_first_run_;
};
ReferenceTypePropagation::ReferenceTypePropagation(HGraph* graph,
+ Handle<mirror::DexCache> hint_dex_cache,
StackHandleScopeCollection* handles,
bool is_first_run,
const char* name)
: HOptimization(graph, name),
+ hint_dex_cache_(hint_dex_cache),
handle_cache_(handles),
worklist_(graph->GetArena()->Adapter(kArenaAllocReferenceTypePropagation)),
is_first_run_(is_first_run) {
@@ -130,7 +146,7 @@
}
void ReferenceTypePropagation::Visit(HInstruction* instruction) {
- RTPVisitor visitor(graph_, &handle_cache_, &worklist_, is_first_run_);
+ RTPVisitor visitor(graph_, hint_dex_cache_, &handle_cache_, &worklist_, is_first_run_);
instruction->Accept(&visitor);
}
@@ -149,7 +165,7 @@
}
void ReferenceTypePropagation::VisitBasicBlock(HBasicBlock* block) {
- RTPVisitor visitor(graph_, &handle_cache_, &worklist_, is_first_run_);
+ RTPVisitor visitor(graph_, hint_dex_cache_, &handle_cache_, &worklist_, is_first_run_);
// Handle Phis first as there might be instructions in the same block who depend on them.
for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) {
VisitPhi(it.Current()->AsPhi());
@@ -358,7 +374,6 @@
HLoadClass* load_class = instanceOf->InputAt(1)->AsLoadClass();
ReferenceTypeInfo class_rti = load_class->GetLoadedClassRTI();
{
- ScopedObjectAccess soa(Thread::Current());
if (!class_rti.IsValid()) {
// He have loaded an unresolved class. Don't bother bounding the type.
return;
@@ -412,7 +427,7 @@
ScopedObjectAccess soa(Thread::Current());
StackHandleScope<2> hs(soa.Self());
Handle<mirror::DexCache> dex_cache(
- hs.NewHandle(cl->FindDexCache(soa.Self(), invoke->GetDexFile(), false)));
+ hs.NewHandle(FindDexCacheWithHint(soa.Self(), invoke->GetDexFile(), hint_dex_cache_)));
// Use a null loader. We should probably use the compiling method's class loader,
// but then we would need to pass it to RTPVisitor just for this debug check. Since
// the method is from the String class, the null loader is good enough.
@@ -446,8 +461,7 @@
DCHECK_EQ(instr->GetType(), Primitive::kPrimNot);
ScopedObjectAccess soa(Thread::Current());
- mirror::DexCache* dex_cache = Runtime::Current()->GetClassLinker()->FindDexCache(
- soa.Self(), dex_file, false);
+ mirror::DexCache* dex_cache = FindDexCacheWithHint(soa.Self(), dex_file, hint_dex_cache_);
// Get type from dex cache assuming it was populated by the verifier.
SetClassAsTypeInfo(instr, dex_cache->GetResolvedType(type_idx), is_exact);
}
@@ -460,24 +474,24 @@
UpdateReferenceTypeInfo(instr, instr->GetTypeIndex(), instr->GetDexFile(), /* is_exact */ true);
}
-static mirror::Class* GetClassFromDexCache(Thread* self, const DexFile& dex_file, uint16_t type_idx)
+static mirror::Class* GetClassFromDexCache(Thread* self,
+ const DexFile& dex_file,
+ uint16_t type_idx,
+ Handle<mirror::DexCache> hint_dex_cache)
SHARED_REQUIRES(Locks::mutator_lock_) {
- mirror::DexCache* dex_cache =
- Runtime::Current()->GetClassLinker()->FindDexCache(self, dex_file, /* allow_failure */ true);
- if (dex_cache == nullptr) {
- // Dex cache could not be found. This should only happen during gtests.
- return nullptr;
- }
+ mirror::DexCache* dex_cache = FindDexCacheWithHint(self, dex_file, hint_dex_cache);
// Get type from dex cache assuming it was populated by the verifier.
return dex_cache->GetResolvedType(type_idx);
}
void ReferenceTypePropagation::RTPVisitor::VisitParameterValue(HParameterValue* instr) {
- ScopedObjectAccess soa(Thread::Current());
// We check if the existing type is valid: the inliner may have set it.
if (instr->GetType() == Primitive::kPrimNot && !instr->GetReferenceTypeInfo().IsValid()) {
- mirror::Class* resolved_class =
- GetClassFromDexCache(soa.Self(), instr->GetDexFile(), instr->GetTypeIndex());
+ ScopedObjectAccess soa(Thread::Current());
+ mirror::Class* resolved_class = GetClassFromDexCache(soa.Self(),
+ instr->GetDexFile(),
+ instr->GetTypeIndex(),
+ hint_dex_cache_);
SetClassAsTypeInfo(instr, resolved_class, /* is_exact */ false);
}
}
@@ -488,11 +502,11 @@
return;
}
- ScopedObjectAccess soa(Thread::Current());
mirror::Class* klass = nullptr;
// The field index is unknown only during tests.
if (info.GetFieldIndex() != kUnknownFieldIndex) {
+ ScopedObjectAccess soa(Thread::Current());
ClassLinker* cl = Runtime::Current()->GetClassLinker();
ArtField* field = cl->GetResolvedField(info.GetFieldIndex(), info.GetDexCache().Get());
// TODO: There are certain cases where we can't resolve the field.
@@ -532,8 +546,10 @@
void ReferenceTypePropagation::RTPVisitor::VisitLoadClass(HLoadClass* instr) {
ScopedObjectAccess soa(Thread::Current());
// Get type from dex cache assuming it was populated by the verifier.
- mirror::Class* resolved_class =
- GetClassFromDexCache(soa.Self(), instr->GetDexFile(), instr->GetTypeIndex());
+ mirror::Class* resolved_class = GetClassFromDexCache(soa.Self(),
+ instr->GetDexFile(),
+ instr->GetTypeIndex(),
+ hint_dex_cache_);
if (resolved_class != nullptr) {
instr->SetLoadedClassRTI(ReferenceTypeInfo::Create(
handle_cache_->NewHandle(resolved_class), /* is_exact */ true));
@@ -567,7 +583,6 @@
}
void ReferenceTypePropagation::RTPVisitor::VisitNullCheck(HNullCheck* instr) {
- ScopedObjectAccess soa(Thread::Current());
ReferenceTypeInfo parent_rti = instr->InputAt(0)->GetReferenceTypeInfo();
if (parent_rti.IsValid()) {
instr->SetReferenceTypeInfo(parent_rti);
@@ -575,10 +590,9 @@
}
void ReferenceTypePropagation::RTPVisitor::VisitBoundType(HBoundType* instr) {
- ScopedObjectAccess soa(Thread::Current());
-
ReferenceTypeInfo class_rti = instr->GetUpperBound();
if (class_rti.IsValid()) {
+ ScopedObjectAccess soa(Thread::Current());
// Narrow the type as much as possible.
HInstruction* obj = instr->InputAt(0);
ReferenceTypeInfo obj_rti = obj->GetReferenceTypeInfo();
@@ -609,8 +623,6 @@
}
void ReferenceTypePropagation::RTPVisitor::VisitCheckCast(HCheckCast* check_cast) {
- ScopedObjectAccess soa(Thread::Current());
-
HLoadClass* load_class = check_cast->InputAt(1)->AsLoadClass();
ReferenceTypeInfo class_rti = load_class->GetLoadedClassRTI();
HBoundType* bound_type = check_cast->GetNext()->AsBoundType();
@@ -645,7 +657,6 @@
// point the interpreter jumps to that loop header.
return;
}
- ScopedObjectAccess soa(Thread::Current());
// Set the initial type for the phi. Use the non back edge input for reaching
// a fixed point faster.
HInstruction* first_input = phi->InputAt(0);
@@ -760,7 +771,8 @@
ScopedObjectAccess soa(Thread::Current());
ClassLinker* cl = Runtime::Current()->GetClassLinker();
- mirror::DexCache* dex_cache = cl->FindDexCache(soa.Self(), instr->GetDexFile());
+ mirror::DexCache* dex_cache =
+ FindDexCacheWithHint(soa.Self(), instr->GetDexFile(), hint_dex_cache_);
size_t pointer_size = cl->GetImagePointerSize();
ArtMethod* method = dex_cache->GetResolvedMethod(instr->GetDexMethodIndex(), pointer_size);
mirror::Class* klass = (method == nullptr) ? nullptr : method->GetReturnType(false, pointer_size);
diff --git a/compiler/optimizing/reference_type_propagation.h b/compiler/optimizing/reference_type_propagation.h
index 028a6fc..7362544 100644
--- a/compiler/optimizing/reference_type_propagation.h
+++ b/compiler/optimizing/reference_type_propagation.h
@@ -32,6 +32,7 @@
class ReferenceTypePropagation : public HOptimization {
public:
ReferenceTypePropagation(HGraph* graph,
+ Handle<mirror::DexCache> hint_dex_cache,
StackHandleScopeCollection* handles,
bool is_first_run,
const char* name = kReferenceTypePropagationPassName);
@@ -90,6 +91,10 @@
void ValidateTypes();
+ // Note: hint_dex_cache_ is usually, but not necessarily, the dex cache associated with
+ // graph_->GetDexFile(). Since we may look up also in other dex files, it's used only
+ // as a hint, to reduce the number of calls to the costly ClassLinker::FindDexCache().
+ Handle<mirror::DexCache> hint_dex_cache_;
HandleCache handle_cache_;
ArenaVector<HInstruction*> worklist_;
diff --git a/compiler/optimizing/side_effects_test.cc b/compiler/optimizing/side_effects_test.cc
index b01bc1c..9bbc354 100644
--- a/compiler/optimizing/side_effects_test.cc
+++ b/compiler/optimizing/side_effects_test.cc
@@ -148,19 +148,19 @@
EXPECT_FALSE(any_write.MayDependOn(volatile_read));
}
-TEST(SideEffectsTest, SameWidthTypesNoAlias) {
+TEST(SideEffectsTest, SameWidthTypes) {
// Type I/F.
- testNoWriteAndReadDependence(
+ testWriteAndReadDependence(
SideEffects::FieldWriteOfType(Primitive::kPrimInt, /* is_volatile */ false),
SideEffects::FieldReadOfType(Primitive::kPrimFloat, /* is_volatile */ false));
- testNoWriteAndReadDependence(
+ testWriteAndReadDependence(
SideEffects::ArrayWriteOfType(Primitive::kPrimInt),
SideEffects::ArrayReadOfType(Primitive::kPrimFloat));
// Type L/D.
- testNoWriteAndReadDependence(
+ testWriteAndReadDependence(
SideEffects::FieldWriteOfType(Primitive::kPrimLong, /* is_volatile */ false),
SideEffects::FieldReadOfType(Primitive::kPrimDouble, /* is_volatile */ false));
- testNoWriteAndReadDependence(
+ testWriteAndReadDependence(
SideEffects::ArrayWriteOfType(Primitive::kPrimLong),
SideEffects::ArrayReadOfType(Primitive::kPrimDouble));
}
@@ -216,32 +216,14 @@
"||||||L|",
SideEffects::FieldWriteOfType(Primitive::kPrimNot, false).ToString().c_str());
EXPECT_STREQ(
- "||DFJISCBZL|DFJISCBZL||DFJISCBZL|DFJISCBZL|",
- SideEffects::FieldWriteOfType(Primitive::kPrimNot, true).ToString().c_str());
- EXPECT_STREQ(
"|||||Z||",
SideEffects::ArrayWriteOfType(Primitive::kPrimBoolean).ToString().c_str());
EXPECT_STREQ(
- "|||||C||",
- SideEffects::ArrayWriteOfType(Primitive::kPrimChar).ToString().c_str());
- EXPECT_STREQ(
- "|||||S||",
- SideEffects::ArrayWriteOfType(Primitive::kPrimShort).ToString().c_str());
- EXPECT_STREQ(
"|||B||||",
SideEffects::FieldReadOfType(Primitive::kPrimByte, false).ToString().c_str());
EXPECT_STREQ(
- "||D|||||",
+ "||DJ|||||", // note: DJ alias
SideEffects::ArrayReadOfType(Primitive::kPrimDouble).ToString().c_str());
- EXPECT_STREQ(
- "||J|||||",
- SideEffects::ArrayReadOfType(Primitive::kPrimLong).ToString().c_str());
- EXPECT_STREQ(
- "||F|||||",
- SideEffects::ArrayReadOfType(Primitive::kPrimFloat).ToString().c_str());
- EXPECT_STREQ(
- "||I|||||",
- SideEffects::ArrayReadOfType(Primitive::kPrimInt).ToString().c_str());
SideEffects s = SideEffects::None();
s = s.Union(SideEffects::FieldWriteOfType(Primitive::kPrimChar, /* is_volatile */ false));
s = s.Union(SideEffects::FieldWriteOfType(Primitive::kPrimLong, /* is_volatile */ false));
@@ -249,7 +231,9 @@
s = s.Union(SideEffects::FieldReadOfType(Primitive::kPrimInt, /* is_volatile */ false));
s = s.Union(SideEffects::ArrayReadOfType(Primitive::kPrimFloat));
s = s.Union(SideEffects::ArrayReadOfType(Primitive::kPrimDouble));
- EXPECT_STREQ("||DF|I||S|JC|", s.ToString().c_str());
+ EXPECT_STREQ(
+ "||DFJI|FI||S|DJC|", // note: DJ/FI alias.
+ s.ToString().c_str());
}
} // namespace art
diff --git a/compiler/optimizing/ssa_builder.cc b/compiler/optimizing/ssa_builder.cc
index eeadbeb..e43e33f 100644
--- a/compiler/optimizing/ssa_builder.cc
+++ b/compiler/optimizing/ssa_builder.cc
@@ -506,7 +506,7 @@
// 4) Compute type of reference type instructions. The pass assumes that
// NullConstant has been fixed up.
- ReferenceTypePropagation(graph_, handles_, /* is_first_run */ true).Run();
+ ReferenceTypePropagation(graph_, dex_cache_, handles_, /* is_first_run */ true).Run();
// 5) HInstructionBuilder duplicated ArrayGet instructions with ambiguous type
// (int/float or long/double) and marked ArraySets with ambiguous input type.
diff --git a/compiler/optimizing/ssa_builder.h b/compiler/optimizing/ssa_builder.h
index c37c28c..d7360ad 100644
--- a/compiler/optimizing/ssa_builder.h
+++ b/compiler/optimizing/ssa_builder.h
@@ -47,8 +47,11 @@
*/
class SsaBuilder : public ValueObject {
public:
- SsaBuilder(HGraph* graph, StackHandleScopeCollection* handles)
+ SsaBuilder(HGraph* graph,
+ Handle<mirror::DexCache> dex_cache,
+ StackHandleScopeCollection* handles)
: graph_(graph),
+ dex_cache_(dex_cache),
handles_(handles),
agets_fixed_(false),
ambiguous_agets_(graph->GetArena()->Adapter(kArenaAllocGraphBuilder)),
@@ -112,6 +115,7 @@
void RemoveRedundantUninitializedStrings();
HGraph* graph_;
+ Handle<mirror::DexCache> dex_cache_;
StackHandleScopeCollection* const handles_;
// True if types of ambiguous ArrayGets have been resolved.
diff --git a/compiler/optimizing/ssa_liveness_analysis.h b/compiler/optimizing/ssa_liveness_analysis.h
index 97f2aee..719feec 100644
--- a/compiler/optimizing/ssa_liveness_analysis.h
+++ b/compiler/optimizing/ssa_liveness_analysis.h
@@ -969,6 +969,38 @@
return false;
}
+ bool IsLinearOrderWellFormed(const HGraph& graph) {
+ for (HBasicBlock* header : graph.GetBlocks()) {
+ if (!header->IsLoopHeader()) {
+ continue;
+ }
+
+ HLoopInformation* loop = header->GetLoopInformation();
+ size_t num_blocks = loop->GetBlocks().NumSetBits();
+ size_t found_blocks = 0u;
+
+ for (HLinearOrderIterator it(graph); !it.Done(); it.Advance()) {
+ HBasicBlock* current = it.Current();
+ if (loop->Contains(*current)) {
+ found_blocks++;
+ if (found_blocks == 1u && current != header) {
+ // First block is not the header.
+ return false;
+ } else if (found_blocks == num_blocks && !loop->IsBackEdge(*current)) {
+ // Last block is not a back edge.
+ return false;
+ }
+ } else if (found_blocks != 0u && found_blocks != num_blocks) {
+ // Blocks are not adjacent.
+ return false;
+ }
+ }
+ DCHECK_EQ(found_blocks, num_blocks);
+ }
+
+ return true;
+ }
+
void AddBackEdgeUses(const HBasicBlock& block_at_use) {
DCHECK(block_at_use.IsInLoop());
// Add synthesized uses at the back edge of loops to help the register allocator.
@@ -995,12 +1027,30 @@
if ((first_use_ != nullptr) && (first_use_->GetPosition() <= back_edge_use_position)) {
// There was a use already seen in this loop. Therefore the previous call to `AddUse`
// already inserted the backedge use. We can stop going outward.
- DCHECK(HasSynthesizeUseAt(back_edge_use_position));
+ if (kIsDebugBuild) {
+ if (!HasSynthesizeUseAt(back_edge_use_position)) {
+ // There exists a use prior to `back_edge_use_position` but there is
+ // no synthesized use at the back edge. This can happen in the presence
+ // of irreducible loops, when blocks of the loop are not adjacent in
+ // linear order, i.e. when there is an out-of-loop block between
+ // `block_at_use` and `back_edge_position` that uses this interval.
+ DCHECK(block_at_use.GetGraph()->HasIrreducibleLoops());
+ DCHECK(!IsLinearOrderWellFormed(*block_at_use.GetGraph()));
+ }
+ }
break;
}
- DCHECK(last_in_new_list == nullptr
- || back_edge_use_position > last_in_new_list->GetPosition());
+ if (last_in_new_list != nullptr &&
+ back_edge_use_position <= last_in_new_list->GetPosition()) {
+ // Loops are not properly nested in the linear order, i.e. the back edge
+ // of an outer loop preceeds blocks of an inner loop. This can happen
+ // in the presence of irreducible loops.
+ DCHECK(block_at_use.GetGraph()->HasIrreducibleLoops());
+ DCHECK(!IsLinearOrderWellFormed(*block_at_use.GetGraph()));
+ // We must bail out, otherwise we would generate an unsorted use list.
+ break;
+ }
UsePosition* new_use = new (allocator_) UsePosition(
/* user */ nullptr,
diff --git a/imgdiag/imgdiag.cc b/imgdiag/imgdiag.cc
index cbd0c40..214222d 100644
--- a/imgdiag/imgdiag.cc
+++ b/imgdiag/imgdiag.cc
@@ -51,11 +51,13 @@
explicit ImgDiagDumper(std::ostream* os,
const ImageHeader& image_header,
const std::string& image_location,
- pid_t image_diff_pid)
+ pid_t image_diff_pid,
+ pid_t zygote_diff_pid)
: os_(os),
image_header_(image_header),
image_location_(image_location),
- image_diff_pid_(image_diff_pid) {}
+ image_diff_pid_(image_diff_pid),
+ zygote_diff_pid_(zygote_diff_pid) {}
bool Dump() SHARED_REQUIRES(Locks::mutator_lock_) {
std::ostream& os = *os_;
@@ -68,7 +70,7 @@
bool ret = true;
if (image_diff_pid_ >= 0) {
os << "IMAGE DIFF PID (" << image_diff_pid_ << "): ";
- ret = DumpImageDiff(image_diff_pid_);
+ ret = DumpImageDiff(image_diff_pid_, zygote_diff_pid_);
os << "\n\n";
} else {
os << "IMAGE DIFF PID: disabled\n\n";
@@ -95,7 +97,8 @@
return str.substr(idx + 1);
}
- bool DumpImageDiff(pid_t image_diff_pid) SHARED_REQUIRES(Locks::mutator_lock_) {
+ bool DumpImageDiff(pid_t image_diff_pid, pid_t zygote_diff_pid)
+ SHARED_REQUIRES(Locks::mutator_lock_) {
std::ostream& os = *os_;
{
@@ -138,7 +141,7 @@
}
// Future idea: diff against zygote so we can ignore the shared dirty pages.
- return DumpImageDiffMap(image_diff_pid, boot_map);
+ return DumpImageDiffMap(image_diff_pid, zygote_diff_pid, boot_map);
}
static std::string PrettyFieldValue(ArtField* field, mirror::Object* obj)
@@ -212,8 +215,74 @@
std::vector<mirror::Object*> dirty_objects;
};
+ void DiffObjectContents(mirror::Object* obj,
+ uint8_t* remote_bytes,
+ std::ostream& os) SHARED_REQUIRES(Locks::mutator_lock_) {
+ const char* tabs = " ";
+ // Attempt to find fields for all dirty bytes.
+ mirror::Class* klass = obj->GetClass();
+ if (obj->IsClass()) {
+ os << tabs << "Class " << PrettyClass(obj->AsClass()) << " " << obj << "\n";
+ } else {
+ os << tabs << "Instance of " << PrettyClass(klass) << " " << obj << "\n";
+ }
+
+ std::unordered_set<ArtField*> dirty_instance_fields;
+ std::unordered_set<ArtField*> dirty_static_fields;
+ const uint8_t* obj_bytes = reinterpret_cast<const uint8_t*>(obj);
+ mirror::Object* remote_obj = reinterpret_cast<mirror::Object*>(remote_bytes);
+ for (size_t i = 0, count = obj->SizeOf(); i < count; ++i) {
+ if (obj_bytes[i] != remote_bytes[i]) {
+ ArtField* field = ArtField::FindInstanceFieldWithOffset</*exact*/false>(klass, i);
+ if (field != nullptr) {
+ dirty_instance_fields.insert(field);
+ } else if (obj->IsClass()) {
+ field = ArtField::FindStaticFieldWithOffset</*exact*/false>(obj->AsClass(), i);
+ if (field != nullptr) {
+ dirty_static_fields.insert(field);
+ }
+ }
+ if (field == nullptr) {
+ if (klass->IsArrayClass()) {
+ mirror::Class* component_type = klass->GetComponentType();
+ Primitive::Type primitive_type = component_type->GetPrimitiveType();
+ size_t component_size = Primitive::ComponentSize(primitive_type);
+ size_t data_offset = mirror::Array::DataOffset(component_size).Uint32Value();
+ if (i >= data_offset) {
+ os << tabs << "Dirty array element " << (i - data_offset) / component_size << "\n";
+ // Skip to next element to prevent spam.
+ i += component_size - 1;
+ continue;
+ }
+ }
+ os << tabs << "No field for byte offset " << i << "\n";
+ }
+ }
+ }
+ // Dump different fields. TODO: Dump field contents.
+ if (!dirty_instance_fields.empty()) {
+ os << tabs << "Dirty instance fields " << dirty_instance_fields.size() << "\n";
+ for (ArtField* field : dirty_instance_fields) {
+ os << tabs << PrettyField(field)
+ << " original=" << PrettyFieldValue(field, obj)
+ << " remote=" << PrettyFieldValue(field, remote_obj) << "\n";
+ }
+ }
+ if (!dirty_static_fields.empty()) {
+ os << tabs << "Dirty static fields " << dirty_static_fields.size() << "\n";
+ for (ArtField* field : dirty_static_fields) {
+ os << tabs << PrettyField(field)
+ << " original=" << PrettyFieldValue(field, obj)
+ << " remote=" << PrettyFieldValue(field, remote_obj) << "\n";
+ }
+ }
+ os << "\n";
+ }
+
// Look at /proc/$pid/mem and only diff the things from there
- bool DumpImageDiffMap(pid_t image_diff_pid, const backtrace_map_t& boot_map)
+ bool DumpImageDiffMap(pid_t image_diff_pid,
+ pid_t zygote_diff_pid,
+ const backtrace_map_t& boot_map)
SHARED_REQUIRES(Locks::mutator_lock_) {
std::ostream& os = *os_;
const size_t pointer_size = InstructionSetPointerSize(
@@ -272,6 +341,20 @@
return false;
}
+ std::vector<uint8_t> zygote_contents;
+ std::unique_ptr<File> zygote_map_file;
+ if (zygote_diff_pid != -1) {
+ std::string zygote_file_name =
+ StringPrintf("/proc/%ld/mem", static_cast<long>(zygote_diff_pid)); // NOLINT [runtime/int]
+ zygote_map_file.reset(OS::OpenFileForReading(zygote_file_name.c_str()));
+ // The boot map should be at the same address.
+ zygote_contents.resize(boot_map_size);
+ if (!zygote_map_file->PreadFully(&zygote_contents[0], boot_map_size, boot_map.start)) {
+ LOG(WARNING) << "Could not fully read zygote file " << zygote_file_name;
+ zygote_contents.clear();
+ }
+ }
+
std::string page_map_file_name = StringPrintf(
"/proc/%ld/pagemap", static_cast<long>(image_diff_pid)); // NOLINT [runtime/int]
auto page_map_file = std::unique_ptr<File>(OS::OpenFileForReading(page_map_file_name.c_str()));
@@ -416,8 +499,11 @@
// Look up local classes by their descriptor
std::map<std::string, mirror::Class*> local_class_map;
- // Use set to have sorted output.
- std::set<mirror::Object*> dirty_objects;
+ // Objects that are dirty against the image (possibly shared or private dirty).
+ std::set<mirror::Object*> image_dirty_objects;
+
+ // Objects that are dirty against the zygote (probably private dirty).
+ std::set<mirror::Object*> zygote_dirty_objects;
size_t dirty_object_bytes = 0;
const uint8_t* begin_image_ptr = image_begin_unaligned;
@@ -454,17 +540,29 @@
mirror::Class* klass = obj->GetClass();
- bool different_object = false;
-
// Check against the other object and see if they are different
ptrdiff_t offset = current - begin_image_ptr;
const uint8_t* current_remote = &remote_contents[offset];
mirror::Object* remote_obj = reinterpret_cast<mirror::Object*>(
const_cast<uint8_t*>(current_remote));
- if (memcmp(current, current_remote, obj->SizeOf()) != 0) {
+
+ bool different_image_object = memcmp(current, current_remote, obj->SizeOf()) != 0;
+ if (different_image_object) {
+ bool different_zygote_object = false;
+ if (!zygote_contents.empty()) {
+ const uint8_t* zygote_ptr = &zygote_contents[offset];
+ different_zygote_object = memcmp(current, zygote_ptr, obj->SizeOf()) != 0;
+ }
+ if (different_zygote_object) {
+ // Different from zygote.
+ zygote_dirty_objects.insert(obj);
+ } else {
+ // Just different from iamge.
+ image_dirty_objects.insert(obj);
+ }
+
different_objects++;
dirty_object_bytes += obj->SizeOf();
- dirty_objects.insert(obj);
++class_data[klass].dirty_object_count;
@@ -477,16 +575,13 @@
}
class_data[klass].dirty_object_byte_count += dirty_byte_count_per_object;
class_data[klass].dirty_object_size_in_bytes += obj->SizeOf();
-
- different_object = true;
-
class_data[klass].dirty_objects.push_back(remote_obj);
} else {
++class_data[klass].clean_object_count;
}
std::string descriptor = GetClassDescriptor(klass);
- if (different_object) {
+ if (different_image_object) {
if (klass->IsClassClass()) {
// this is a "Class"
mirror::Class* obj_as_class = reinterpret_cast<mirror::Class*>(remote_obj);
@@ -558,69 +653,23 @@
auto clean_object_class_values = SortByValueDesc<mirror::Class*, int, ClassData>(
class_data, [](const ClassData& d) { return d.clean_object_count; });
- os << "\n" << " Dirty objects: " << dirty_objects.size() << "\n";
- for (mirror::Object* obj : dirty_objects) {
- const char* tabs = " ";
- // Attempt to find fields for all dirty bytes.
- mirror::Class* klass = obj->GetClass();
- if (obj->IsClass()) {
- os << tabs << "Class " << PrettyClass(obj->AsClass()) << " " << obj << "\n";
- } else {
- os << tabs << "Instance of " << PrettyClass(klass) << " " << obj << "\n";
+ if (!zygote_dirty_objects.empty()) {
+ os << "\n" << " Dirty objects compared to zygote (probably private dirty): "
+ << zygote_dirty_objects.size() << "\n";
+ for (mirror::Object* obj : zygote_dirty_objects) {
+ const uint8_t* obj_bytes = reinterpret_cast<const uint8_t*>(obj);
+ ptrdiff_t offset = obj_bytes - begin_image_ptr;
+ uint8_t* remote_bytes = &zygote_contents[offset];
+ DiffObjectContents(obj, remote_bytes, os);
}
-
- std::unordered_set<ArtField*> dirty_instance_fields;
- std::unordered_set<ArtField*> dirty_static_fields;
+ }
+ os << "\n" << " Dirty objects compared to image (private or shared dirty): "
+ << image_dirty_objects.size() << "\n";
+ for (mirror::Object* obj : image_dirty_objects) {
const uint8_t* obj_bytes = reinterpret_cast<const uint8_t*>(obj);
ptrdiff_t offset = obj_bytes - begin_image_ptr;
uint8_t* remote_bytes = &remote_contents[offset];
- mirror::Object* remote_obj = reinterpret_cast<mirror::Object*>(remote_bytes);
- for (size_t i = 0, count = obj->SizeOf(); i < count; ++i) {
- if (obj_bytes[i] != remote_bytes[i]) {
- ArtField* field = ArtField::FindInstanceFieldWithOffset</*exact*/false>(klass, i);
- if (field != nullptr) {
- dirty_instance_fields.insert(field);
- } else if (obj->IsClass()) {
- field = ArtField::FindStaticFieldWithOffset</*exact*/false>(obj->AsClass(), i);
- if (field != nullptr) {
- dirty_static_fields.insert(field);
- }
- }
- if (field == nullptr) {
- if (klass->IsArrayClass()) {
- mirror::Class* component_type = klass->GetComponentType();
- Primitive::Type primitive_type = component_type->GetPrimitiveType();
- size_t component_size = Primitive::ComponentSize(primitive_type);
- size_t data_offset = mirror::Array::DataOffset(component_size).Uint32Value();
- if (i >= data_offset) {
- os << tabs << "Dirty array element " << (i - data_offset) / component_size << "\n";
- // Skip to next element to prevent spam.
- i += component_size - 1;
- continue;
- }
- }
- os << tabs << "No field for byte offset " << i << "\n";
- }
- }
- }
- // Dump different fields. TODO: Dump field contents.
- if (!dirty_instance_fields.empty()) {
- os << tabs << "Dirty instance fields " << dirty_instance_fields.size() << "\n";
- for (ArtField* field : dirty_instance_fields) {
- os << tabs << PrettyField(field)
- << " original=" << PrettyFieldValue(field, obj)
- << " remote=" << PrettyFieldValue(field, remote_obj) << "\n";
- }
- }
- if (!dirty_static_fields.empty()) {
- os << tabs << "Dirty static fields " << dirty_static_fields.size() << "\n";
- for (ArtField* field : dirty_static_fields) {
- os << tabs << PrettyField(field)
- << " original=" << PrettyFieldValue(field, obj)
- << " remote=" << PrettyFieldValue(field, remote_obj) << "\n";
- }
- }
- os << "\n";
+ DiffObjectContents(obj, remote_bytes, os);
}
os << "\n" << " Dirty object count by class:\n";
@@ -959,11 +1008,15 @@
const ImageHeader& image_header_;
const std::string image_location_;
pid_t image_diff_pid_; // Dump image diff against boot.art if pid is non-negative
+ pid_t zygote_diff_pid_; // Dump image diff against zygote boot.art if pid is non-negative
DISALLOW_COPY_AND_ASSIGN(ImgDiagDumper);
};
-static int DumpImage(Runtime* runtime, std::ostream* os, pid_t image_diff_pid) {
+static int DumpImage(Runtime* runtime,
+ std::ostream* os,
+ pid_t image_diff_pid,
+ pid_t zygote_diff_pid) {
ScopedObjectAccess soa(Thread::Current());
gc::Heap* heap = runtime->GetHeap();
std::vector<gc::space::ImageSpace*> image_spaces = heap->GetBootImageSpaces();
@@ -975,8 +1028,11 @@
return EXIT_FAILURE;
}
- ImgDiagDumper img_diag_dumper(
- os, image_header, image_space->GetImageLocation(), image_diff_pid);
+ ImgDiagDumper img_diag_dumper(os,
+ image_header,
+ image_space->GetImageLocation(),
+ image_diff_pid,
+ zygote_diff_pid);
if (!img_diag_dumper.Dump()) {
return EXIT_FAILURE;
}
@@ -1004,6 +1060,13 @@
*error_msg = "Image diff pid out of range";
return kParseError;
}
+ } else if (option.starts_with("--zygote-diff-pid=")) {
+ const char* zygote_diff_pid = option.substr(strlen("--zygote-diff-pid=")).data();
+
+ if (!ParseInt(zygote_diff_pid, &zygote_diff_pid_)) {
+ *error_msg = "Zygote diff pid out of range";
+ return kParseError;
+ }
} else {
return kParseUnknownArgument;
}
@@ -1053,6 +1116,9 @@
usage += // Optional.
" --image-diff-pid=<pid>: provide the PID of a process whose boot.art you want to diff.\n"
" Example: --image-diff-pid=$(pid zygote)\n"
+ " --zygote-diff-pid=<pid>: provide the PID of the zygote whose boot.art you want to diff "
+ "against.\n"
+ " Example: --zygote-diff-pid=$(pid zygote)\n"
"\n";
return usage;
@@ -1060,6 +1126,7 @@
public:
pid_t image_diff_pid_ = -1;
+ pid_t zygote_diff_pid_ = -1;
};
struct ImgDiagMain : public CmdlineMain<ImgDiagArgs> {
@@ -1068,7 +1135,8 @@
return DumpImage(runtime,
args_->os_,
- args_->image_diff_pid_) == EXIT_SUCCESS;
+ args_->image_diff_pid_,
+ args_->zygote_diff_pid_) == EXIT_SUCCESS;
}
};
diff --git a/imgdiag/imgdiag_test.cc b/imgdiag/imgdiag_test.cc
index dc101e5..9f771ba 100644
--- a/imgdiag/imgdiag_test.cc
+++ b/imgdiag/imgdiag_test.cc
@@ -36,6 +36,8 @@
static const char* kImgDiagBootImage = "--boot-image";
static const char* kImgDiagBinaryName = "imgdiag";
+static const char* kImgDiagZygoteDiffPid = "--zygote-diff-pid";
+
// from kernel <include/linux/threads.h>
#define PID_MAX_LIMIT (4*1024*1024) // Upper bound. Most kernel configs will have smaller max pid.
@@ -90,17 +92,25 @@
// Run imgdiag --image-diff-pid=$image_diff_pid and wait until it's done with a 0 exit code.
std::string diff_pid_args;
+ std::string zygote_diff_pid_args;
{
std::stringstream diff_pid_args_ss;
diff_pid_args_ss << kImgDiagDiffPid << "=" << image_diff_pid;
diff_pid_args = diff_pid_args_ss.str();
}
- std::string boot_image_args;
{
- boot_image_args = boot_image_args + kImgDiagBootImage + "=" + boot_image;
+ std::stringstream zygote_pid_args_ss;
+ zygote_pid_args_ss << kImgDiagZygoteDiffPid << "=" << image_diff_pid;
+ zygote_diff_pid_args = zygote_pid_args_ss.str();
}
+ std::string boot_image_args = std::string(kImgDiagBootImage) + "=" + boot_image;
- std::vector<std::string> exec_argv = { file_path, diff_pid_args, boot_image_args };
+ std::vector<std::string> exec_argv = {
+ file_path,
+ diff_pid_args,
+ zygote_diff_pid_args,
+ boot_image_args
+ };
return ::art::Exec(exec_argv, error_msg);
}
diff --git a/runtime/Android.mk b/runtime/Android.mk
index c859079..aa12c83 100644
--- a/runtime/Android.mk
+++ b/runtime/Android.mk
@@ -106,7 +106,6 @@
jit/debugger_interface.cc \
jit/jit.cc \
jit/jit_code_cache.cc \
- jit/jit_instrumentation.cc \
jit/offline_profiling_info.cc \
jit/profiling_info.cc \
jit/profile_saver.cc \
diff --git a/runtime/arch/arm/quick_entrypoints_arm.S b/runtime/arch/arm/quick_entrypoints_arm.S
index da7db1d..e6ff0aa 100644
--- a/runtime/arch/arm/quick_entrypoints_arm.S
+++ b/runtime/arch/arm/quick_entrypoints_arm.S
@@ -1832,7 +1832,7 @@
add sp, #4
.cfi_adjust_cfa_offset -4
pop {pc}
-END art_quick_fmod
+END art_quick_fmodf
/* int64_t art_d2l(double d) */
.extern art_d2l
diff --git a/runtime/asm_support.h b/runtime/asm_support.h
index d27d2f6..21725d3 100644
--- a/runtime/asm_support.h
+++ b/runtime/asm_support.h
@@ -20,7 +20,7 @@
#if defined(__cplusplus)
#include "art_method.h"
#include "gc/allocator/rosalloc.h"
-#include "jit/jit_instrumentation.h"
+#include "jit/jit.h"
#include "lock_word.h"
#include "mirror/class.h"
#include "mirror/string.h"
diff --git a/runtime/dex_file.h b/runtime/dex_file.h
index 3a28422..ce7f62a 100644
--- a/runtime/dex_file.h
+++ b/runtime/dex_file.h
@@ -57,6 +57,7 @@
// TODO: move all of the macro functionality into the DexCache class.
class DexFile {
public:
+ static const uint32_t kDefaultMethodsVersion = 37;
static const uint8_t kDexMagic[];
static constexpr size_t kNumDexVersions = 2;
static constexpr size_t kDexVersionLen = 4;
diff --git a/runtime/dex_file_verifier.cc b/runtime/dex_file_verifier.cc
index 681c5f9..3df4e98 100644
--- a/runtime/dex_file_verifier.cc
+++ b/runtime/dex_file_verifier.cc
@@ -2465,7 +2465,7 @@
GetFieldDescriptionOrError(begin_, header_, idx).c_str(),
field_access_flags,
PrettyJavaAccessFlags(field_access_flags).c_str());
- if (header_->GetVersion() >= 37) {
+ if (header_->GetVersion() >= DexFile::kDefaultMethodsVersion) {
return false;
} else {
// Allow in older versions, but warn.
@@ -2480,7 +2480,7 @@
GetFieldDescriptionOrError(begin_, header_, idx).c_str(),
field_access_flags,
PrettyJavaAccessFlags(field_access_flags).c_str());
- if (header_->GetVersion() >= 37) {
+ if (header_->GetVersion() >= DexFile::kDefaultMethodsVersion) {
return false;
} else {
// Allow in older versions, but warn.
@@ -2628,12 +2628,16 @@
// Interfaces are special.
if ((class_access_flags & kAccInterface) != 0) {
- // Non-static interface methods must be public.
- if ((method_access_flags & (kAccPublic | kAccStatic)) == 0) {
+ // Non-static interface methods must be public or private.
+ uint32_t desired_flags = (kAccPublic | kAccStatic);
+ if (dex_file_->GetVersion() >= DexFile::kDefaultMethodsVersion) {
+ desired_flags |= kAccPrivate;
+ }
+ if ((method_access_flags & desired_flags) == 0) {
*error_msg = StringPrintf("Interface virtual method %" PRIu32 "(%s) is not public",
method_index,
GetMethodDescriptionOrError(begin_, header_, method_index).c_str());
- if (header_->GetVersion() >= 37) {
+ if (header_->GetVersion() >= DexFile::kDefaultMethodsVersion) {
return false;
} else {
// Allow in older versions, but warn.
@@ -2686,7 +2690,7 @@
*error_msg = StringPrintf("Interface method %" PRIu32 "(%s) is not public and abstract",
method_index,
GetMethodDescriptionOrError(begin_, header_, method_index).c_str());
- if (header_->GetVersion() >= 37) {
+ if (header_->GetVersion() >= DexFile::kDefaultMethodsVersion) {
return false;
} else {
// Allow in older versions, but warn.
diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc
index baf4afe..a432782 100644
--- a/runtime/interpreter/interpreter.cc
+++ b/runtime/interpreter/interpreter.cc
@@ -285,16 +285,19 @@
}
jit::Jit* jit = Runtime::Current()->GetJit();
- if (jit != nullptr && jit->CanInvokeCompiledCode(method)) {
- JValue result;
+ if (jit != nullptr) {
+ jit->MethodEntered(self, shadow_frame.GetMethod());
+ if (jit->CanInvokeCompiledCode(method)) {
+ JValue result;
- // Pop the shadow frame before calling into compiled code.
- self->PopShadowFrame();
- ArtInterpreterToCompiledCodeBridge(self, code_item, &shadow_frame, &result);
- // Push the shadow frame back as the caller will expect it.
- self->PushShadowFrame(&shadow_frame);
+ // Pop the shadow frame before calling into compiled code.
+ self->PopShadowFrame();
+ ArtInterpreterToCompiledCodeBridge(self, code_item, &shadow_frame, &result);
+ // Push the shadow frame back as the caller will expect it.
+ self->PushShadowFrame(&shadow_frame);
- return result;
+ return result;
+ }
}
}
diff --git a/runtime/interpreter/interpreter_common.h b/runtime/interpreter/interpreter_common.h
index 19d971e..fb98175 100644
--- a/runtime/interpreter/interpreter_common.h
+++ b/runtime/interpreter/interpreter_common.h
@@ -34,6 +34,7 @@
#include "dex_instruction-inl.h"
#include "entrypoints/entrypoint_utils-inl.h"
#include "handle_scope-inl.h"
+#include "jit/jit.h"
#include "lambda/art_lambda_method.h"
#include "lambda/box_table.h"
#include "lambda/closure.h"
@@ -628,6 +629,15 @@
result->SetJ(0);
return false;
} else {
+ jit::Jit* jit = Runtime::Current()->GetJit();
+ if (jit != nullptr) {
+ if (type == kVirtual || type == kInterface) {
+ jit->InvokeVirtualOrInterface(
+ self, receiver, sf_method, shadow_frame.GetDexPC(), called_method);
+ }
+ jit->AddSamples(self, sf_method, 1);
+ }
+ // TODO: Remove the InvokeVirtualOrInterface instrumentation, as it was only used by the JIT.
if (type == kVirtual || type == kInterface) {
instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation();
if (UNLIKELY(instrumentation->HasInvokeVirtualOrInterfaceListeners())) {
@@ -667,7 +677,14 @@
result->SetJ(0);
return false;
} else {
+ jit::Jit* jit = Runtime::Current()->GetJit();
+ if (jit != nullptr) {
+ jit->InvokeVirtualOrInterface(
+ self, receiver, shadow_frame.GetMethod(), shadow_frame.GetDexPC(), called_method);
+ jit->AddSamples(self, shadow_frame.GetMethod(), 1);
+ }
instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation();
+ // TODO: Remove the InvokeVirtualOrInterface instrumentation, as it was only used by the JIT.
if (UNLIKELY(instrumentation->HasInvokeVirtualOrInterfaceListeners())) {
instrumentation->InvokeVirtualOrInterface(
self, receiver, shadow_frame.GetMethod(), shadow_frame.GetDexPC(), called_method);
diff --git a/runtime/interpreter/interpreter_goto_table_impl.cc b/runtime/interpreter/interpreter_goto_table_impl.cc
index ce698fb..c95af6f 100644
--- a/runtime/interpreter/interpreter_goto_table_impl.cc
+++ b/runtime/interpreter/interpreter_goto_table_impl.cc
@@ -22,7 +22,6 @@
#include "experimental_flags.h"
#include "interpreter_common.h"
#include "jit/jit.h"
-#include "jit/jit_instrumentation.h"
#include "safe_math.h"
#include <memory> // std::unique_ptr
@@ -67,7 +66,9 @@
#define BRANCH_INSTRUMENTATION(offset) \
do { \
- instrumentation->Branch(self, method, dex_pc, offset); \
+ if (UNLIKELY(instrumentation->HasBranchListeners())) { \
+ instrumentation->Branch(self, method, dex_pc, offset); \
+ } \
JValue result; \
if (jit::Jit::MaybeDoOnStackReplacement(self, method, dex_pc, offset, &result)) { \
return result; \
@@ -76,8 +77,8 @@
#define HOTNESS_UPDATE() \
do { \
- if (jit_instrumentation_cache != nullptr) { \
- jit_instrumentation_cache->AddSamples(self, method, 1); \
+ if (jit != nullptr) { \
+ jit->AddSamples(self, method, 1); \
} \
} while (false)
@@ -195,10 +196,6 @@
const auto* const instrumentation = Runtime::Current()->GetInstrumentation();
ArtMethod* method = shadow_frame.GetMethod();
jit::Jit* jit = Runtime::Current()->GetJit();
- jit::JitInstrumentationCache* jit_instrumentation_cache = nullptr;
- if (jit != nullptr) {
- jit_instrumentation_cache = jit->GetInstrumentationCache();
- }
// Jump to first instruction.
ADVANCE(0);
diff --git a/runtime/interpreter/interpreter_switch_impl.cc b/runtime/interpreter/interpreter_switch_impl.cc
index 442e191..ca1d635 100644
--- a/runtime/interpreter/interpreter_switch_impl.cc
+++ b/runtime/interpreter/interpreter_switch_impl.cc
@@ -18,7 +18,6 @@
#include "experimental_flags.h"
#include "interpreter_common.h"
#include "jit/jit.h"
-#include "jit/jit_instrumentation.h"
#include "safe_math.h"
#include <memory> // std::unique_ptr
@@ -74,7 +73,9 @@
#define BRANCH_INSTRUMENTATION(offset) \
do { \
- instrumentation->Branch(self, method, dex_pc, offset); \
+ if (UNLIKELY(instrumentation->HasBranchListeners())) { \
+ instrumentation->Branch(self, method, dex_pc, offset); \
+ } \
JValue result; \
if (jit::Jit::MaybeDoOnStackReplacement(self, method, dex_pc, offset, &result)) { \
if (interpret_one_instruction) { \
@@ -87,8 +88,8 @@
#define HOTNESS_UPDATE() \
do { \
- if (jit_instrumentation_cache != nullptr) { \
- jit_instrumentation_cache->AddSamples(self, method, 1); \
+ if (jit != nullptr) { \
+ jit->AddSamples(self, method, 1); \
} \
} while (false)
@@ -115,10 +116,6 @@
uint16_t inst_data;
ArtMethod* method = shadow_frame.GetMethod();
jit::Jit* jit = Runtime::Current()->GetJit();
- jit::JitInstrumentationCache* jit_instrumentation_cache = nullptr;
- if (jit != nullptr) {
- jit_instrumentation_cache = jit->GetInstrumentationCache();
- }
// TODO: collapse capture-variable+create-lambda into one opcode, then we won't need
// to keep this live for the scope of the entire function call.
diff --git a/runtime/interpreter/mterp/mterp.cc b/runtime/interpreter/mterp/mterp.cc
index 32c45fc..f800683 100644
--- a/runtime/interpreter/mterp/mterp.cc
+++ b/runtime/interpreter/mterp/mterp.cc
@@ -20,8 +20,6 @@
#include "interpreter/interpreter_common.h"
#include "entrypoints/entrypoint_utils-inl.h"
#include "mterp.h"
-#include "jit/jit.h"
-#include "jit/jit_instrumentation.h"
#include "debugger.h"
namespace art {
@@ -652,10 +650,9 @@
int32_t countdown_value = jit::kJitHotnessDisabled;
jit::Jit* jit = Runtime::Current()->GetJit();
if (jit != nullptr) {
- jit::JitInstrumentationCache* cache = jit->GetInstrumentationCache();
- int32_t warm_threshold = cache->WarmMethodThreshold();
- int32_t hot_threshold = cache->HotMethodThreshold();
- int32_t osr_threshold = cache->OSRMethodThreshold();
+ int32_t warm_threshold = jit->WarmMethodThreshold();
+ int32_t hot_threshold = jit->HotMethodThreshold();
+ int32_t osr_threshold = jit->OSRMethodThreshold();
if (hotness_count < warm_threshold) {
countdown_value = warm_threshold - hotness_count;
} else if (hotness_count < hot_threshold) {
@@ -666,7 +663,7 @@
countdown_value = jit::kJitCheckForOSR;
}
if (jit::Jit::ShouldUsePriorityThreadWeight()) {
- int32_t priority_thread_weight = cache->PriorityThreadWeight();
+ int32_t priority_thread_weight = jit->PriorityThreadWeight();
countdown_value = std::min(countdown_value, countdown_value / priority_thread_weight);
}
}
@@ -692,7 +689,7 @@
jit::Jit* jit = Runtime::Current()->GetJit();
if (jit != nullptr) {
int16_t count = shadow_frame->GetCachedHotnessCountdown() - shadow_frame->GetHotnessCountdown();
- jit->GetInstrumentationCache()->AddSamples(self, method, count);
+ jit->AddSamples(self, method, count);
}
return MterpSetUpHotnessCountdown(method, shadow_frame);
}
@@ -705,7 +702,7 @@
uint32_t dex_pc = shadow_frame->GetDexPC();
jit::Jit* jit = Runtime::Current()->GetJit();
if ((jit != nullptr) && (offset <= 0)) {
- jit->GetInstrumentationCache()->AddSamples(self, method, 1);
+ jit->AddSamples(self, method, 1);
}
int16_t countdown_value = MterpSetUpHotnessCountdown(method, shadow_frame);
if (countdown_value == jit::kJitCheckForOSR) {
@@ -725,7 +722,7 @@
jit::Jit* jit = Runtime::Current()->GetJit();
if (offset <= 0) {
// Keep updating hotness in case a compilation request was dropped. Eventually it will retry.
- jit->GetInstrumentationCache()->AddSamples(self, method, 1);
+ jit->AddSamples(self, method, 1);
}
// Assumes caller has already determined that an OSR check is appropriate.
return jit::Jit::MaybeDoOnStackReplacement(self, method, dex_pc, offset, result);
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 3344346..558e443 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -23,7 +23,6 @@
#include "entrypoints/runtime_asm_entrypoints.h"
#include "interpreter/interpreter.h"
#include "jit_code_cache.h"
-#include "jit_instrumentation.h"
#include "oat_file_manager.h"
#include "oat_quick_method_header.h"
#include "offline_profiling_info.h"
@@ -31,12 +30,15 @@
#include "runtime.h"
#include "runtime_options.h"
#include "stack_map.h"
+#include "thread_list.h"
#include "utils.h"
namespace art {
namespace jit {
static constexpr bool kEnableOnStackReplacement = true;
+// At what priority to schedule jit threads. 9 is the lowest foreground priority on device.
+static constexpr int kJitPoolThreadPthreadPriority = 9;
// JIT compiler
void* Jit::jit_library_handle_= nullptr;
@@ -146,6 +148,17 @@
<< ", max_capacity=" << PrettySize(options->GetCodeCacheMaxCapacity())
<< ", compile_threshold=" << options->GetCompileThreshold()
<< ", save_profiling_info=" << options->GetSaveProfilingInfo();
+
+
+ jit->hot_method_threshold_ = options->GetCompileThreshold();
+ jit->warm_method_threshold_ = options->GetWarmupThreshold();
+ jit->osr_method_threshold_ = options->GetOsrThreshold();
+ jit->priority_thread_weight_ = options->GetPriorityThreadWeight();
+
+ jit->CreateThreadPool();
+
+ // Notify native debugger about the classes already loaded before the creation of the jit.
+ jit->DumpTypeInfoForLoadedTypes(Runtime::Current()->GetClassLinker());
return jit.release();
}
@@ -233,13 +246,31 @@
}
void Jit::CreateThreadPool() {
- CHECK(instrumentation_cache_.get() != nullptr);
- instrumentation_cache_->CreateThreadPool();
+ // There is a DCHECK in the 'AddSamples' method to ensure the tread pool
+ // is not null when we instrument.
+ thread_pool_.reset(new ThreadPool("Jit thread pool", 1));
+ thread_pool_->SetPthreadPriority(kJitPoolThreadPthreadPriority);
+ thread_pool_->StartWorkers(Thread::Current());
}
void Jit::DeleteThreadPool() {
- if (instrumentation_cache_.get() != nullptr) {
- instrumentation_cache_->DeleteThreadPool(Thread::Current());
+ Thread* self = Thread::Current();
+ DCHECK(Runtime::Current()->IsShuttingDown(self));
+ if (thread_pool_ != nullptr) {
+ ThreadPool* cache = nullptr;
+ {
+ ScopedSuspendAll ssa(__FUNCTION__);
+ // Clear thread_pool_ field while the threads are suspended.
+ // A mutator in the 'AddSamples' method will check against it.
+ cache = thread_pool_.release();
+ }
+ cache->StopWorkers(self);
+ cache->RemoveAllTasks(self);
+ // We could just suspend all threads, but we know those threads
+ // will finish in a short period, so it's not worth adding a suspend logic
+ // here. Besides, this is only done for shutdown.
+ cache->Wait(self, false, false);
+ delete cache;
}
}
@@ -259,10 +290,7 @@
}
bool Jit::JitAtFirstUse() {
- if (instrumentation_cache_ != nullptr) {
- return instrumentation_cache_->HotMethodThreshold() == 0;
- }
- return false;
+ return HotMethodThreshold() == 0;
}
bool Jit::CanInvokeCompiledCode(ArtMethod* method) {
@@ -285,17 +313,6 @@
}
}
-void Jit::CreateInstrumentationCache(size_t compile_threshold,
- size_t warmup_threshold,
- size_t osr_threshold,
- uint16_t priority_thread_weight) {
- instrumentation_cache_.reset(
- new jit::JitInstrumentationCache(compile_threshold,
- warmup_threshold,
- osr_threshold,
- priority_thread_weight));
-}
-
void Jit::NewTypeLoadedIfUsingJit(mirror::Class* type) {
jit::Jit* jit = Runtime::Current()->GetJit();
if (jit != nullptr && jit->generate_debug_info_) {
@@ -480,5 +497,164 @@
memory_use_.AddValue(bytes);
}
+class JitCompileTask FINAL : public Task {
+ public:
+ enum TaskKind {
+ kAllocateProfile,
+ kCompile,
+ kCompileOsr
+ };
+
+ JitCompileTask(ArtMethod* method, TaskKind kind) : method_(method), kind_(kind) {
+ ScopedObjectAccess soa(Thread::Current());
+ // Add a global ref to the class to prevent class unloading until compilation is done.
+ klass_ = soa.Vm()->AddGlobalRef(soa.Self(), method_->GetDeclaringClass());
+ CHECK(klass_ != nullptr);
+ }
+
+ ~JitCompileTask() {
+ ScopedObjectAccess soa(Thread::Current());
+ soa.Vm()->DeleteGlobalRef(soa.Self(), klass_);
+ }
+
+ void Run(Thread* self) OVERRIDE {
+ ScopedObjectAccess soa(self);
+ if (kind_ == kCompile) {
+ VLOG(jit) << "JitCompileTask compiling method " << PrettyMethod(method_);
+ if (!Runtime::Current()->GetJit()->CompileMethod(method_, self, /* osr */ false)) {
+ VLOG(jit) << "Failed to compile method " << PrettyMethod(method_);
+ }
+ } else if (kind_ == kCompileOsr) {
+ VLOG(jit) << "JitCompileTask compiling method osr " << PrettyMethod(method_);
+ if (!Runtime::Current()->GetJit()->CompileMethod(method_, self, /* osr */ true)) {
+ VLOG(jit) << "Failed to compile method osr " << PrettyMethod(method_);
+ }
+ } else {
+ DCHECK(kind_ == kAllocateProfile);
+ if (ProfilingInfo::Create(self, method_, /* retry_allocation */ true)) {
+ VLOG(jit) << "Start profiling " << PrettyMethod(method_);
+ }
+ }
+ }
+
+ void Finalize() OVERRIDE {
+ delete this;
+ }
+
+ private:
+ ArtMethod* const method_;
+ const TaskKind kind_;
+ jobject klass_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(JitCompileTask);
+};
+
+void Jit::AddSamples(Thread* self, ArtMethod* method, uint16_t count) {
+ if (thread_pool_ == nullptr) {
+ // Should only see this when shutting down.
+ DCHECK(Runtime::Current()->IsShuttingDown(self));
+ return;
+ }
+
+ if (method->IsClassInitializer() || method->IsNative()) {
+ // We do not want to compile such methods.
+ return;
+ }
+ DCHECK(thread_pool_ != nullptr);
+ DCHECK_GT(warm_method_threshold_, 0);
+ DCHECK_GT(hot_method_threshold_, warm_method_threshold_);
+ DCHECK_GT(osr_method_threshold_, hot_method_threshold_);
+ DCHECK_GE(priority_thread_weight_, 1);
+ DCHECK_LE(priority_thread_weight_, hot_method_threshold_);
+
+ int32_t starting_count = method->GetCounter();
+ if (Jit::ShouldUsePriorityThreadWeight()) {
+ count *= priority_thread_weight_;
+ }
+ int32_t new_count = starting_count + count; // int32 here to avoid wrap-around;
+ if (starting_count < warm_method_threshold_) {
+ if (new_count >= warm_method_threshold_) {
+ bool success = ProfilingInfo::Create(self, method, /* retry_allocation */ false);
+ if (success) {
+ VLOG(jit) << "Start profiling " << PrettyMethod(method);
+ }
+
+ if (thread_pool_ == nullptr) {
+ // Calling ProfilingInfo::Create might put us in a suspended state, which could
+ // lead to the thread pool being deleted when we are shutting down.
+ DCHECK(Runtime::Current()->IsShuttingDown(self));
+ return;
+ }
+
+ if (!success) {
+ // We failed allocating. Instead of doing the collection on the Java thread, we push
+ // an allocation to a compiler thread, that will do the collection.
+ thread_pool_->AddTask(self, new JitCompileTask(method, JitCompileTask::kAllocateProfile));
+ }
+ }
+ // Avoid jumping more than one state at a time.
+ new_count = std::min(new_count, hot_method_threshold_ - 1);
+ } else if (starting_count < hot_method_threshold_) {
+ if (new_count >= hot_method_threshold_) {
+ DCHECK(thread_pool_ != nullptr);
+ thread_pool_->AddTask(self, new JitCompileTask(method, JitCompileTask::kCompile));
+ }
+ // Avoid jumping more than one state at a time.
+ new_count = std::min(new_count, osr_method_threshold_ - 1);
+ } else if (starting_count < osr_method_threshold_) {
+ if (new_count >= osr_method_threshold_) {
+ DCHECK(thread_pool_ != nullptr);
+ thread_pool_->AddTask(self, new JitCompileTask(method, JitCompileTask::kCompileOsr));
+ }
+ }
+ // Update hotness counter
+ method->SetCounter(new_count);
+}
+
+void Jit::MethodEntered(Thread* thread, ArtMethod* method) {
+ if (UNLIKELY(Runtime::Current()->GetJit()->JitAtFirstUse())) {
+ // The compiler requires a ProfilingInfo object.
+ ProfilingInfo::Create(thread, method, /* retry_allocation */ true);
+ JitCompileTask compile_task(method, JitCompileTask::kCompile);
+ compile_task.Run(thread);
+ return;
+ }
+
+ ProfilingInfo* profiling_info = method->GetProfilingInfo(sizeof(void*));
+ // Update the entrypoint if the ProfilingInfo has one. The interpreter will call it
+ // instead of interpreting the method.
+ // We avoid doing this if exit stubs are installed to not mess with the instrumentation.
+ // TODO(ngeoffray): Clean up instrumentation and code cache interactions.
+ if ((profiling_info != nullptr) &&
+ (profiling_info->GetSavedEntryPoint() != nullptr) &&
+ !Runtime::Current()->GetInstrumentation()->AreExitStubsInstalled()) {
+ method->SetEntryPointFromQuickCompiledCode(profiling_info->GetSavedEntryPoint());
+ } else {
+ AddSamples(thread, method, 1);
+ }
+}
+
+void Jit::InvokeVirtualOrInterface(Thread* thread,
+ mirror::Object* this_object,
+ ArtMethod* caller,
+ uint32_t dex_pc,
+ ArtMethod* callee ATTRIBUTE_UNUSED) {
+ ScopedAssertNoThreadSuspension ants(thread, __FUNCTION__);
+ DCHECK(this_object != nullptr);
+ ProfilingInfo* info = caller->GetProfilingInfo(sizeof(void*));
+ if (info != nullptr) {
+ // Since the instrumentation is marked from the declaring class we need to mark the card so
+ // that mod-union tables and card rescanning know about the update.
+ Runtime::Current()->GetHeap()->WriteBarrierEveryFieldOf(caller->GetDeclaringClass());
+ info->AddInvokeInfo(dex_pc, this_object->GetClass());
+ }
+}
+
+void Jit::WaitForCompilationToFinish(Thread* self) {
+ if (thread_pool_ != nullptr) {
+ thread_pool_->Wait(self, false, false);
+ }
+}
+
} // namespace jit
} // namespace art
diff --git a/runtime/jit/jit.h b/runtime/jit/jit.h
index e212366..96f9608 100644
--- a/runtime/jit/jit.h
+++ b/runtime/jit/jit.h
@@ -34,9 +34,11 @@
namespace jit {
class JitCodeCache;
-class JitInstrumentationCache;
class JitOptions;
+static constexpr int16_t kJitCheckForOSR = -1;
+static constexpr int16_t kJitHotnessDisabled = -2;
+
class Jit {
public:
static constexpr bool kStressMode = kIsDebugBuild;
@@ -46,17 +48,16 @@
static Jit* Create(JitOptions* options, std::string* error_msg);
bool CompileMethod(ArtMethod* method, Thread* self, bool osr)
SHARED_REQUIRES(Locks::mutator_lock_);
- void CreateInstrumentationCache(size_t compile_threshold,
- size_t warmup_threshold,
- size_t osr_threshold,
- uint16_t priority_thread_weight);
void CreateThreadPool();
+
const JitCodeCache* GetCodeCache() const {
return code_cache_.get();
}
+
JitCodeCache* GetCodeCache() {
return code_cache_.get();
}
+
void DeleteThreadPool();
// Dump interesting info: #methods compiled, code vs data size, compile / verify cumulative
// loggers.
@@ -68,10 +69,39 @@
REQUIRES(!lock_)
SHARED_REQUIRES(Locks::mutator_lock_);
- JitInstrumentationCache* GetInstrumentationCache() const {
- return instrumentation_cache_.get();
+ size_t OSRMethodThreshold() const {
+ return osr_method_threshold_;
}
+ size_t HotMethodThreshold() const {
+ return hot_method_threshold_;
+ }
+
+ size_t WarmMethodThreshold() const {
+ return warm_method_threshold_;
+ }
+
+ uint16_t PriorityThreadWeight() const {
+ return priority_thread_weight_;
+ }
+
+ // Wait until there is no more pending compilation tasks.
+ void WaitForCompilationToFinish(Thread* self);
+
+ // Profiling methods.
+ void MethodEntered(Thread* thread, ArtMethod* method)
+ SHARED_REQUIRES(Locks::mutator_lock_);
+
+ void AddSamples(Thread* self, ArtMethod* method, uint16_t samples)
+ SHARED_REQUIRES(Locks::mutator_lock_);
+
+ void InvokeVirtualOrInterface(Thread* thread,
+ mirror::Object* this_object,
+ ArtMethod* caller,
+ uint32_t dex_pc,
+ ArtMethod* callee)
+ SHARED_REQUIRES(Locks::mutator_lock_);
+
// Starts the profile saver if the config options allow profile recording.
// The profile will be stored in the specified `filename` and will contain
// information collected from the given `code_paths` (a set of dex locations).
@@ -137,11 +167,15 @@
Histogram<uint64_t> memory_use_ GUARDED_BY(lock_);
Mutex lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
- std::unique_ptr<jit::JitInstrumentationCache> instrumentation_cache_;
std::unique_ptr<jit::JitCodeCache> code_cache_;
bool save_profiling_info_;
static bool generate_debug_info_;
+ uint16_t hot_method_threshold_;
+ uint16_t warm_method_threshold_;
+ uint16_t osr_method_threshold_;
+ uint16_t priority_thread_weight_;
+ std::unique_ptr<ThreadPool> thread_pool_;
DISALLOW_COPY_AND_ASSIGN(Jit);
};
diff --git a/runtime/jit/jit_instrumentation.cc b/runtime/jit/jit_instrumentation.cc
deleted file mode 100644
index b2c0c20..0000000
--- a/runtime/jit/jit_instrumentation.cc
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "jit_instrumentation.h"
-
-#include "art_method-inl.h"
-#include "jit.h"
-#include "jit_code_cache.h"
-#include "scoped_thread_state_change.h"
-#include "thread_list.h"
-
-namespace art {
-namespace jit {
-
-// At what priority to schedule jit threads. 9 is the lowest foreground priority on device.
-static constexpr int kJitPoolThreadPthreadPriority = 9;
-
-class JitCompileTask FINAL : public Task {
- public:
- enum TaskKind {
- kAllocateProfile,
- kCompile,
- kCompileOsr
- };
-
- JitCompileTask(ArtMethod* method, TaskKind kind) : method_(method), kind_(kind) {
- ScopedObjectAccess soa(Thread::Current());
- // Add a global ref to the class to prevent class unloading until compilation is done.
- klass_ = soa.Vm()->AddGlobalRef(soa.Self(), method_->GetDeclaringClass());
- CHECK(klass_ != nullptr);
- }
-
- ~JitCompileTask() {
- ScopedObjectAccess soa(Thread::Current());
- soa.Vm()->DeleteGlobalRef(soa.Self(), klass_);
- }
-
- void Run(Thread* self) OVERRIDE {
- ScopedObjectAccess soa(self);
- if (kind_ == kCompile) {
- VLOG(jit) << "JitCompileTask compiling method " << PrettyMethod(method_);
- if (!Runtime::Current()->GetJit()->CompileMethod(method_, self, /* osr */ false)) {
- VLOG(jit) << "Failed to compile method " << PrettyMethod(method_);
- }
- } else if (kind_ == kCompileOsr) {
- VLOG(jit) << "JitCompileTask compiling method osr " << PrettyMethod(method_);
- if (!Runtime::Current()->GetJit()->CompileMethod(method_, self, /* osr */ true)) {
- VLOG(jit) << "Failed to compile method osr " << PrettyMethod(method_);
- }
- } else {
- DCHECK(kind_ == kAllocateProfile);
- if (ProfilingInfo::Create(self, method_, /* retry_allocation */ true)) {
- VLOG(jit) << "Start profiling " << PrettyMethod(method_);
- }
- }
- }
-
- void Finalize() OVERRIDE {
- delete this;
- }
-
- private:
- ArtMethod* const method_;
- const TaskKind kind_;
- jobject klass_;
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(JitCompileTask);
-};
-
-JitInstrumentationCache::JitInstrumentationCache(uint16_t hot_method_threshold,
- uint16_t warm_method_threshold,
- uint16_t osr_method_threshold,
- uint16_t priority_thread_weight)
- : hot_method_threshold_(hot_method_threshold),
- warm_method_threshold_(warm_method_threshold),
- osr_method_threshold_(osr_method_threshold),
- priority_thread_weight_(priority_thread_weight),
- listener_(this) {
-}
-
-void JitInstrumentationCache::CreateThreadPool() {
- // Create the thread pool before setting the instrumentation, so that
- // when the threads stopped being suspended, they can use it directly.
- // There is a DCHECK in the 'AddSamples' method to ensure the tread pool
- // is not null when we instrument.
- thread_pool_.reset(new ThreadPool("Jit thread pool", 1));
- thread_pool_->SetPthreadPriority(kJitPoolThreadPthreadPriority);
- thread_pool_->StartWorkers(Thread::Current());
- {
- // Add Jit interpreter instrumentation, tells the interpreter when
- // to notify the jit to compile something.
- ScopedSuspendAll ssa(__FUNCTION__);
- Runtime::Current()->GetInstrumentation()->AddListener(
- &listener_, JitInstrumentationListener::kJitEvents);
- }
-}
-
-void JitInstrumentationCache::DeleteThreadPool(Thread* self) {
- DCHECK(Runtime::Current()->IsShuttingDown(self));
- if (thread_pool_ != nullptr) {
- // First remove the listener, to avoid having mutators enter
- // 'AddSamples'.
- ThreadPool* cache = nullptr;
- {
- ScopedSuspendAll ssa(__FUNCTION__);
- Runtime::Current()->GetInstrumentation()->RemoveListener(
- &listener_, JitInstrumentationListener::kJitEvents);
- // Clear thread_pool_ field while the threads are suspended.
- // A mutator in the 'AddSamples' method will check against it.
- cache = thread_pool_.release();
- }
- cache->StopWorkers(self);
- cache->RemoveAllTasks(self);
- // We could just suspend all threads, but we know those threads
- // will finish in a short period, so it's not worth adding a suspend logic
- // here. Besides, this is only done for shutdown.
- cache->Wait(self, false, false);
- delete cache;
- }
-}
-
-void JitInstrumentationCache::AddSamples(Thread* self, ArtMethod* method, uint16_t count) {
- // Since we don't have on-stack replacement, some methods can remain in the interpreter longer
- // than we want resulting in samples even after the method is compiled. Also, if the
- // jit is no longer interested in hotness samples because we're shutting down, just return.
- if (method->IsClassInitializer() || method->IsNative() || (thread_pool_ == nullptr)) {
- if (thread_pool_ == nullptr) {
- // Should only see this when shutting down.
- DCHECK(Runtime::Current()->IsShuttingDown(self));
- }
- return;
- }
- DCHECK(thread_pool_ != nullptr);
- DCHECK_GT(warm_method_threshold_, 0);
- DCHECK_GT(hot_method_threshold_, warm_method_threshold_);
- DCHECK_GT(osr_method_threshold_, hot_method_threshold_);
- DCHECK_GE(priority_thread_weight_, 1);
- DCHECK_LE(priority_thread_weight_, hot_method_threshold_);
-
- int32_t starting_count = method->GetCounter();
- if (Jit::ShouldUsePriorityThreadWeight()) {
- count *= priority_thread_weight_;
- }
- int32_t new_count = starting_count + count; // int32 here to avoid wrap-around;
- if (starting_count < warm_method_threshold_) {
- if (new_count >= warm_method_threshold_) {
- bool success = ProfilingInfo::Create(self, method, /* retry_allocation */ false);
- if (success) {
- VLOG(jit) << "Start profiling " << PrettyMethod(method);
- }
-
- if (thread_pool_ == nullptr) {
- // Calling ProfilingInfo::Create might put us in a suspended state, which could
- // lead to the thread pool being deleted when we are shutting down.
- DCHECK(Runtime::Current()->IsShuttingDown(self));
- return;
- }
-
- if (!success) {
- // We failed allocating. Instead of doing the collection on the Java thread, we push
- // an allocation to a compiler thread, that will do the collection.
- thread_pool_->AddTask(self, new JitCompileTask(method, JitCompileTask::kAllocateProfile));
- }
- }
- // Avoid jumping more than one state at a time.
- new_count = std::min(new_count, hot_method_threshold_ - 1);
- } else if (starting_count < hot_method_threshold_) {
- if (new_count >= hot_method_threshold_) {
- DCHECK(thread_pool_ != nullptr);
- thread_pool_->AddTask(self, new JitCompileTask(method, JitCompileTask::kCompile));
- }
- // Avoid jumping more than one state at a time.
- new_count = std::min(new_count, osr_method_threshold_ - 1);
- } else if (starting_count < osr_method_threshold_) {
- if (new_count >= osr_method_threshold_) {
- DCHECK(thread_pool_ != nullptr);
- thread_pool_->AddTask(self, new JitCompileTask(method, JitCompileTask::kCompileOsr));
- }
- }
- // Update hotness counter
- method->SetCounter(new_count);
-}
-
-JitInstrumentationListener::JitInstrumentationListener(JitInstrumentationCache* cache)
- : instrumentation_cache_(cache) {
- CHECK(instrumentation_cache_ != nullptr);
-}
-
-void JitInstrumentationListener::MethodEntered(Thread* thread,
- mirror::Object* /*this_object*/,
- ArtMethod* method,
- uint32_t /*dex_pc*/) {
- if (UNLIKELY(Runtime::Current()->GetJit()->JitAtFirstUse())) {
- // The compiler requires a ProfilingInfo object.
- ProfilingInfo::Create(thread, method, /* retry_allocation */ true);
- JitCompileTask compile_task(method, JitCompileTask::kCompile);
- compile_task.Run(thread);
- return;
- }
-
- ProfilingInfo* profiling_info = method->GetProfilingInfo(sizeof(void*));
- // Update the entrypoint if the ProfilingInfo has one. The interpreter will call it
- // instead of interpreting the method.
- // We avoid doing this if exit stubs are installed to not mess with the instrumentation.
- // TODO(ngeoffray): Clean up instrumentation and code cache interactions.
- if ((profiling_info != nullptr) &&
- (profiling_info->GetSavedEntryPoint() != nullptr) &&
- !Runtime::Current()->GetInstrumentation()->AreExitStubsInstalled()) {
- method->SetEntryPointFromQuickCompiledCode(profiling_info->GetSavedEntryPoint());
- } else {
- instrumentation_cache_->AddSamples(thread, method, 1);
- }
-}
-
-void JitInstrumentationListener::Branch(Thread* thread,
- ArtMethod* method,
- uint32_t dex_pc ATTRIBUTE_UNUSED,
- int32_t dex_pc_offset) {
- if (dex_pc_offset < 0) {
- // Increment method hotness if it is a backward branch.
- instrumentation_cache_->AddSamples(thread, method, 1);
- }
-}
-
-void JitInstrumentationListener::InvokeVirtualOrInterface(Thread* thread,
- mirror::Object* this_object,
- ArtMethod* caller,
- uint32_t dex_pc,
- ArtMethod* callee ATTRIBUTE_UNUSED) {
- // We make sure we cannot be suspended, as the profiling info can be concurrently deleted.
- instrumentation_cache_->AddSamples(thread, caller, 1);
- DCHECK(this_object != nullptr);
- ProfilingInfo* info = caller->GetProfilingInfo(sizeof(void*));
- if (info != nullptr) {
- // Since the instrumentation is marked from the declaring class we need to mark the card so
- // that mod-union tables and card rescanning know about the update.
- Runtime::Current()->GetHeap()->WriteBarrierEveryFieldOf(caller->GetDeclaringClass());
- info->AddInvokeInfo(dex_pc, this_object->GetClass());
- }
-}
-
-void JitInstrumentationCache::WaitForCompilationToFinish(Thread* self) {
- if (thread_pool_ != nullptr) {
- thread_pool_->Wait(self, false, false);
- }
-}
-
-} // namespace jit
-} // namespace art
diff --git a/runtime/jit/jit_instrumentation.h b/runtime/jit/jit_instrumentation.h
deleted file mode 100644
index d0545f8..0000000
--- a/runtime/jit/jit_instrumentation.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef ART_RUNTIME_JIT_JIT_INSTRUMENTATION_H_
-#define ART_RUNTIME_JIT_JIT_INSTRUMENTATION_H_
-
-#include <unordered_map>
-
-#include "instrumentation.h"
-
-#include "atomic.h"
-#include "base/macros.h"
-#include "base/mutex.h"
-#include "gc_root.h"
-#include "jni.h"
-#include "object_callbacks.h"
-#include "thread_pool.h"
-
-namespace art {
-namespace mirror {
- class Object;
- class Throwable;
-} // namespace mirror
-class ArtField;
-class ArtMethod;
-union JValue;
-class Thread;
-
-namespace jit {
-static constexpr int16_t kJitCheckForOSR = -1;
-static constexpr int16_t kJitHotnessDisabled = -2;
-
-class JitInstrumentationCache;
-
-class JitInstrumentationListener : public instrumentation::InstrumentationListener {
- public:
- explicit JitInstrumentationListener(JitInstrumentationCache* cache);
-
- void MethodEntered(Thread* thread, mirror::Object* /*this_object*/,
- ArtMethod* method, uint32_t /*dex_pc*/)
- OVERRIDE SHARED_REQUIRES(Locks::mutator_lock_);
-
- void MethodExited(Thread* /*thread*/, mirror::Object* /*this_object*/,
- ArtMethod* /*method*/, uint32_t /*dex_pc*/,
- const JValue& /*return_value*/)
- OVERRIDE { }
- void MethodUnwind(Thread* /*thread*/, mirror::Object* /*this_object*/,
- ArtMethod* /*method*/, uint32_t /*dex_pc*/) OVERRIDE { }
- void FieldRead(Thread* /*thread*/, mirror::Object* /*this_object*/,
- ArtMethod* /*method*/, uint32_t /*dex_pc*/,
- ArtField* /*field*/) OVERRIDE { }
- void FieldWritten(Thread* /*thread*/, mirror::Object* /*this_object*/,
- ArtMethod* /*method*/, uint32_t /*dex_pc*/,
- ArtField* /*field*/, const JValue& /*field_value*/)
- OVERRIDE { }
- void ExceptionCaught(Thread* /*thread*/,
- mirror::Throwable* /*exception_object*/) OVERRIDE { }
-
- void DexPcMoved(Thread* /*self*/, mirror::Object* /*this_object*/,
- ArtMethod* /*method*/, uint32_t /*new_dex_pc*/) OVERRIDE { }
-
- void Branch(Thread* thread, ArtMethod* method, uint32_t dex_pc, int32_t dex_pc_offset)
- OVERRIDE SHARED_REQUIRES(Locks::mutator_lock_);
-
- void InvokeVirtualOrInterface(Thread* thread,
- mirror::Object* this_object,
- ArtMethod* caller,
- uint32_t dex_pc,
- ArtMethod* callee)
- OVERRIDE
- REQUIRES(Roles::uninterruptible_)
- SHARED_REQUIRES(Locks::mutator_lock_);
-
- static constexpr uint32_t kJitEvents =
- instrumentation::Instrumentation::kMethodEntered |
- instrumentation::Instrumentation::kInvokeVirtualOrInterface;
-
- private:
- JitInstrumentationCache* const instrumentation_cache_;
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(JitInstrumentationListener);
-};
-
-// Keeps track of which methods are hot.
-class JitInstrumentationCache {
- public:
- JitInstrumentationCache(uint16_t hot_method_threshold,
- uint16_t warm_method_threshold,
- uint16_t osr_method_threshold,
- uint16_t priority_thread_weight);
- void AddSamples(Thread* self, ArtMethod* method, uint16_t samples)
- SHARED_REQUIRES(Locks::mutator_lock_);
- void CreateThreadPool();
- void DeleteThreadPool(Thread* self);
-
- size_t OSRMethodThreshold() const {
- return osr_method_threshold_;
- }
-
- size_t HotMethodThreshold() const {
- return hot_method_threshold_;
- }
-
- size_t WarmMethodThreshold() const {
- return warm_method_threshold_;
- }
-
- size_t PriorityThreadWeight() const {
- return priority_thread_weight_;
- }
-
- // Wait until there is no more pending compilation tasks.
- void WaitForCompilationToFinish(Thread* self);
-
- private:
- uint16_t hot_method_threshold_;
- uint16_t warm_method_threshold_;
- uint16_t osr_method_threshold_;
- uint16_t priority_thread_weight_;
- JitInstrumentationListener listener_;
- std::unique_ptr<ThreadPool> thread_pool_;
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(JitInstrumentationCache);
-};
-
-} // namespace jit
-} // namespace art
-
-#endif // ART_RUNTIME_JIT_JIT_INSTRUMENTATION_H_
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index 78e372a..3f95772 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -492,10 +492,21 @@
const ImageInfo* image_info = GetImageInfo();
if (image_info == nullptr) {
VLOG(oat) << "No image for oat image checksum to match against.";
- return true;
- }
- if (file.GetOatHeader().GetImageFileLocationOatChecksum() != GetCombinedImageChecksum()) {
+ if (HasOriginalDexFiles()) {
+ return true;
+ }
+
+ // If there is no original dex file to fall back to, grudgingly accept
+ // the oat file. This could technically lead to crashes, but there's no
+ // way we could find a better oat file to use for this dex location,
+ // and it's better than being stuck in a boot loop with no way out.
+ // The problem will hopefully resolve itself the next time the runtime
+ // starts up.
+ LOG(WARNING) << "Dex location " << dex_location_ << " does not seem to include dex file. "
+ << "Allow oat file use. This is potentially dangerous.";
+ } else if (file.GetOatHeader().GetImageFileLocationOatChecksum()
+ != GetCombinedImageChecksum()) {
VLOG(oat) << "Oat image checksum does not match image checksum.";
return true;
}
diff --git a/runtime/oat_file_manager.cc b/runtime/oat_file_manager.cc
index 94f6345..3846605 100644
--- a/runtime/oat_file_manager.cc
+++ b/runtime/oat_file_manager.cc
@@ -364,7 +364,7 @@
// However, if the app was part of /system and preopted, there is no original dex file
// available. In that case grudgingly accept the oat file.
- if (!DexFile::MaybeDex(dex_location)) {
+ if (!oat_file_assistant.HasOriginalDexFiles()) {
accept_oat_file = true;
LOG(WARNING) << "Dex location " << dex_location << " does not seem to include dex file. "
<< "Allow oat file use. This is potentially dangerous.";
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 37bb4c1..2489e45 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -1921,16 +1921,7 @@
}
std::string error_msg;
jit_.reset(jit::Jit::Create(jit_options_.get(), &error_msg));
- if (jit_.get() != nullptr) {
- jit_->CreateInstrumentationCache(jit_options_->GetCompileThreshold(),
- jit_options_->GetWarmupThreshold(),
- jit_options_->GetOsrThreshold(),
- jit_options_->GetPriorityThreadWeight());
- jit_->CreateThreadPool();
-
- // Notify native debugger about the classes already loaded before the creation of the jit.
- jit_->DumpTypeInfoForLoadedTypes(GetClassLinker());
- } else {
+ if (jit_.get() == nullptr) {
LOG(WARNING) << "Failed to create JIT " << error_msg;
}
}
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index 83da6b7..a0987b5 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -790,9 +790,16 @@
} else if (method_access_flags_ & kAccFinal) {
Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "interfaces may not have final methods";
return false;
- } else if (!(method_access_flags_ & kAccPublic)) {
- Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "interfaces may not have non-public members";
- return false;
+ } else {
+ uint32_t access_flag_options = kAccPublic;
+ if (dex_file_->GetVersion() >= DexFile::kDefaultMethodsVersion) {
+ access_flag_options |= kAccPrivate;
+ }
+ if (!(method_access_flags_ & access_flag_options)) {
+ Fail(VERIFY_ERROR_BAD_CLASS_HARD)
+ << "interfaces may not have protected or package-private members";
+ return false;
+ }
}
}
}
@@ -3794,9 +3801,12 @@
// Note: this check must be after the initializer check, as those are required to fail a class,
// while this check implies an IncompatibleClassChangeError.
if (klass->IsInterface()) {
- // methods called on interfaces should be invoke-interface, invoke-super, or invoke-static.
+ // methods called on interfaces should be invoke-interface, invoke-super, invoke-direct (if
+ // dex file version is 37 or greater), or invoke-static.
if (method_type != METHOD_INTERFACE &&
method_type != METHOD_STATIC &&
+ ((dex_file_->GetVersion() < DexFile::kDefaultMethodsVersion) ||
+ method_type != METHOD_DIRECT) &&
method_type != METHOD_SUPER) {
Fail(VERIFY_ERROR_CLASS_CHANGE)
<< "non-interface method " << PrettyMethod(dex_method_idx, *dex_file_)
@@ -4567,8 +4577,17 @@
// Trying to access C1.field1 using reference of type C2, which is neither C1 or a sub-class
// of C1. For resolution to occur the declared class of the field must be compatible with
// obj_type, we've discovered this wasn't so, so report the field didn't exist.
- Fail(VERIFY_ERROR_NO_FIELD) << "cannot access instance field " << PrettyField(field)
- << " from object of type " << obj_type;
+ VerifyError type;
+ bool is_aot = Runtime::Current()->IsAotCompiler();
+ if (is_aot && (field_klass.IsUnresolvedTypes() || obj_type.IsUnresolvedTypes())) {
+ // Compiler & unresolved types involved, retry at runtime.
+ type = VerifyError::VERIFY_ERROR_NO_CLASS;
+ } else {
+ // Classes known, or at compile time. This is a hard failure.
+ type = VerifyError::VERIFY_ERROR_BAD_CLASS_HARD;
+ }
+ Fail(type) << "cannot access instance field " << PrettyField(field)
+ << " from object of type " << obj_type;
return nullptr;
} else {
return field;
diff --git a/test/141-class-unload/jni_unload.cc b/test/141-class-unload/jni_unload.cc
index d913efe..bbbb0a6 100644
--- a/test/141-class-unload/jni_unload.cc
+++ b/test/141-class-unload/jni_unload.cc
@@ -19,7 +19,6 @@
#include <iostream>
#include "jit/jit.h"
-#include "jit/jit_instrumentation.h"
#include "runtime.h"
#include "thread-inl.h"
@@ -29,7 +28,7 @@
extern "C" JNIEXPORT void JNICALL Java_IntHolder_waitForCompilation(JNIEnv*, jclass) {
jit::Jit* jit = Runtime::Current()->GetJit();
if (jit != nullptr) {
- jit->GetInstrumentationCache()->WaitForCompilationToFinish(Thread::Current());
+ jit->WaitForCompilationToFinish(Thread::Current());
}
}
diff --git a/test/147-stripped-dex-fallback/expected.txt b/test/147-stripped-dex-fallback/expected.txt
new file mode 100644
index 0000000..af5626b
--- /dev/null
+++ b/test/147-stripped-dex-fallback/expected.txt
@@ -0,0 +1 @@
+Hello, world!
diff --git a/test/147-stripped-dex-fallback/info.txt b/test/147-stripped-dex-fallback/info.txt
new file mode 100644
index 0000000..72a2ca8
--- /dev/null
+++ b/test/147-stripped-dex-fallback/info.txt
@@ -0,0 +1,2 @@
+Verify that we fallback to running out of dex code in the oat file if there is
+no image and the original dex code has been stripped.
diff --git a/test/147-stripped-dex-fallback/run b/test/147-stripped-dex-fallback/run
new file mode 100755
index 0000000..e594010
--- /dev/null
+++ b/test/147-stripped-dex-fallback/run
@@ -0,0 +1,24 @@
+#!/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.
+
+# ensure flags includes prebuild.
+flags="$@"
+if [[ "${flags}" == *--no-prebuild* ]] ; then
+ echo "Test 147-stripped-dex-fallback is not intended to run in no-prebuild mode."
+ exit 1
+fi
+
+${RUN} ${flags} --strip-dex --no-dex2oat
diff --git a/test/147-stripped-dex-fallback/src/Main.java b/test/147-stripped-dex-fallback/src/Main.java
new file mode 100644
index 0000000..1ef6289
--- /dev/null
+++ b/test/147-stripped-dex-fallback/src/Main.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class Main {
+ public static void main(String[] args) {
+ System.out.println("Hello, world!");
+ }
+}
diff --git a/test/525-checker-arrays-and-fields/expected.txt b/test/525-checker-arrays-and-fields/expected.txt
index b0aad4d..e69de29 100644
--- a/test/525-checker-arrays-and-fields/expected.txt
+++ b/test/525-checker-arrays-and-fields/expected.txt
@@ -1 +0,0 @@
-passed
diff --git a/test/525-checker-arrays-and-fields/src/Main.java b/test/525-checker-arrays-and-fields/src/Main.java
index b3fbf44..a635a51 100644
--- a/test/525-checker-arrays-and-fields/src/Main.java
+++ b/test/525-checker-arrays-and-fields/src/Main.java
@@ -759,87 +759,12 @@
}
//
- // Misc. tests on false cross-over loops with data types (I/F and J/D) that used
- // to be aliased in an older version of the compiler. This alias has been removed,
- // however, which enables hoisting the invariant array reference.
- //
-
- /// CHECK-START: void Main.FalseCrossOverLoop1() licm (before)
- /// CHECK-DAG: ArraySet loop:none
- /// CHECK-DAG: ArrayGet loop:{{B\d+}}
- /// CHECK-DAG: ArraySet loop:{{B\d+}}
-
- /// CHECK-START: void Main.FalseCrossOverLoop1() licm (after)
- /// CHECK-DAG: ArraySet loop:none
- /// CHECK-DAG: ArrayGet loop:none
- /// CHECK-DAG: ArraySet loop:{{B\d+}}
-
- private static void FalseCrossOverLoop1() {
- sArrF[20] = -1;
- for (int i = 0; i < sArrI.length; i++) {
- sArrI[i] = (int) sArrF[20] - 2;
- }
- }
-
- /// CHECK-START: void Main.FalseCrossOverLoop2() licm (before)
- /// CHECK-DAG: ArraySet loop:none
- /// CHECK-DAG: ArrayGet loop:{{B\d+}}
- /// CHECK-DAG: ArraySet loop:{{B\d+}}
-
- /// CHECK-START: void Main.FalseCrossOverLoop2() licm (after)
- /// CHECK-DAG: ArraySet loop:none
- /// CHECK-DAG: ArrayGet loop:none
- /// CHECK-DAG: ArraySet loop:{{B\d+}}
-
- private static void FalseCrossOverLoop2() {
- sArrI[20] = -2;
- for (int i = 0; i < sArrF.length; i++) {
- sArrF[i] = sArrI[20] - 2;
- }
- }
-
- /// CHECK-START: void Main.FalseCrossOverLoop3() licm (before)
- /// CHECK-DAG: ArraySet loop:none
- /// CHECK-DAG: ArrayGet loop:{{B\d+}}
- /// CHECK-DAG: ArraySet loop:{{B\d+}}
-
- /// CHECK-START: void Main.FalseCrossOverLoop3() licm (after)
- /// CHECK-DAG: ArraySet loop:none
- /// CHECK-DAG: ArrayGet loop:none
- /// CHECK-DAG: ArraySet loop:{{B\d+}}
-
- private static void FalseCrossOverLoop3() {
- sArrD[20] = -3;
- for (int i = 0; i < sArrJ.length; i++) {
- sArrJ[i] = (long) sArrD[20] - 2;
- }
- }
-
- /// CHECK-START: void Main.FalseCrossOverLoop4() licm (before)
- /// CHECK-DAG: ArraySet loop:none
- /// CHECK-DAG: ArrayGet loop:{{B\d+}}
- /// CHECK-DAG: ArraySet loop:{{B\d+}}
-
- /// CHECK-START: void Main.FalseCrossOverLoop4() licm (after)
- /// CHECK-DAG: ArraySet loop:none
- /// CHECK-DAG: ArrayGet loop:none
- /// CHECK-DAG: ArraySet loop:{{B\d+}}
-
- private static void FalseCrossOverLoop4() {
- sArrJ[20] = -4;
- for (int i = 0; i < sArrD.length; i++) {
- sArrD[i] = sArrJ[20] - 2;
- }
- }
-
- //
// Driver and testers.
//
public static void main(String[] args) {
DoStaticTests();
new Main().DoInstanceTests();
- System.out.println("passed");
}
private static void DoStaticTests() {
@@ -978,23 +903,6 @@
for (int i = 0; i < sArrL.length; i++) {
expectEquals(i <= 20 ? anObject : anotherObject, sArrL[i]);
}
- // Misc. tests.
- FalseCrossOverLoop1();
- for (int i = 0; i < sArrI.length; i++) {
- expectEquals(-3, sArrI[i]);
- }
- FalseCrossOverLoop2();
- for (int i = 0; i < sArrF.length; i++) {
- expectEquals(-4, sArrF[i]);
- }
- FalseCrossOverLoop3();
- for (int i = 0; i < sArrJ.length; i++) {
- expectEquals(-5, sArrJ[i]);
- }
- FalseCrossOverLoop4();
- for (int i = 0; i < sArrD.length; i++) {
- expectEquals(-6, sArrD[i]);
- }
}
private void DoInstanceTests() {
diff --git a/test/594-checker-regression-irreducible-linorder/expected.txt b/test/594-checker-regression-irreducible-linorder/expected.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/594-checker-regression-irreducible-linorder/expected.txt
diff --git a/test/594-checker-regression-irreducible-linorder/info.txt b/test/594-checker-regression-irreducible-linorder/info.txt
new file mode 100644
index 0000000..a1783f8
--- /dev/null
+++ b/test/594-checker-regression-irreducible-linorder/info.txt
@@ -0,0 +1,2 @@
+Regression test for a failing DCHECK in SSA liveness analysis in the presence
+of irreducible loops.
diff --git a/test/594-checker-regression-irreducible-linorder/smali/IrreducibleLoop.smali b/test/594-checker-regression-irreducible-linorder/smali/IrreducibleLoop.smali
new file mode 100644
index 0000000..8e01084
--- /dev/null
+++ b/test/594-checker-regression-irreducible-linorder/smali/IrreducibleLoop.smali
@@ -0,0 +1,64 @@
+# 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 public LIrreducibleLoop;
+.super Ljava/lang/Object;
+
+# Test case where liveness analysis produces linear order where loop blocks are
+# not adjacent.
+
+## CHECK-START: int IrreducibleLoop.liveness(boolean, boolean, boolean, int) builder (after)
+## CHECK-DAG: Add loop:none
+## CHECK-DAG: Mul loop:<<Loop:B\d+>>
+## CHECK-DAG: Not loop:<<Loop>>
+
+## CHECK-START: int IrreducibleLoop.liveness(boolean, boolean, boolean, int) liveness (after)
+## CHECK-DAG: Add liveness:<<LPreEntry:\d+>>
+## CHECK-DAG: Mul liveness:<<LHeader:\d+>>
+## CHECK-DAG: Not liveness:<<LBackEdge:\d+>>
+## CHECK-EVAL: (<<LHeader>> < <<LPreEntry>>) and (<<LPreEntry>> < <<LBackEdge>>)
+
+.method public static liveness(ZZZI)I
+ .registers 10
+ const/16 v0, 42
+
+ if-eqz p0, :header
+
+ :pre_entry
+ add-int/2addr p3, p3
+ invoke-static {v0}, Ljava/lang/System;->exit(I)V
+ goto :body1
+
+ :header
+ mul-int/2addr p3, p3
+ if-eqz p1, :body2
+
+ :body1
+ goto :body_merge
+
+ :body2
+ invoke-static {v0}, Ljava/lang/System;->exit(I)V
+ goto :body_merge
+
+ :body_merge
+ if-eqz p2, :exit
+
+ :back_edge
+ not-int p3, p3
+ goto :header
+
+ :exit
+ return p3
+
+.end method
diff --git a/test/594-checker-regression-irreducible-linorder/src/Main.java b/test/594-checker-regression-irreducible-linorder/src/Main.java
new file mode 100644
index 0000000..38b2ab4
--- /dev/null
+++ b/test/594-checker-regression-irreducible-linorder/src/Main.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.
+ */
+
+public class Main {
+ // Workaround for b/18051191.
+ class InnerClass {}
+
+ public static void main(String[] args) {
+ // Nothing to run. This regression test merely makes sure the smali test
+ // case successfully compiles.
+ }
+}
diff --git a/test/800-smali/expected.txt b/test/800-smali/expected.txt
index c2a9a31..11150c2 100644
--- a/test/800-smali/expected.txt
+++ b/test/800-smali/expected.txt
@@ -66,4 +66,5 @@
b/27799205 (4)
b/27799205 (5)
b/27799205 (6)
+b/28187158
Done!
diff --git a/test/800-smali/smali/b_28187158.smali b/test/800-smali/smali/b_28187158.smali
new file mode 100644
index 0000000..7dd2022
--- /dev/null
+++ b/test/800-smali/smali/b_28187158.smali
@@ -0,0 +1,11 @@
+.class public LB28187158;
+
+# Regression test for iget with wrong classes.
+
+.super Ljava/lang/Object;
+
+.method public static run(Ljava/lang/Integer;)V
+ .registers 2
+ iget v0, p0, Ljava/lang/String;->length:I
+.end method
+
diff --git a/test/800-smali/src/Main.java b/test/800-smali/src/Main.java
index 2001cb4..c883b7f 100644
--- a/test/800-smali/src/Main.java
+++ b/test/800-smali/src/Main.java
@@ -174,6 +174,8 @@
testCases.add(new TestCase("b/27799205 (5)", "B27799205Helper", "run5", null,
new VerifyError(), null));
testCases.add(new TestCase("b/27799205 (6)", "B27799205Helper", "run6", null, null, null));
+ testCases.add(new TestCase("b/28187158", "B28187158", "run", new Object[] { null} ,
+ new VerifyError(), null));
}
public void runTests() {
diff --git a/test/955-lambda-smali/build b/test/955-lambda-smali/build
new file mode 100755
index 0000000..14230c2
--- /dev/null
+++ b/test/955-lambda-smali/build
@@ -0,0 +1,20 @@
+#!/bin/bash
+#
+# Copyright 2015 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
+
+./default-build "$@" --experimental default-methods
diff --git a/test/975-iface-private/build b/test/975-iface-private/build
new file mode 100755
index 0000000..14230c2
--- /dev/null
+++ b/test/975-iface-private/build
@@ -0,0 +1,20 @@
+#!/bin/bash
+#
+# Copyright 2015 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
+
+./default-build "$@" --experimental default-methods
diff --git a/test/975-iface-private/expected.txt b/test/975-iface-private/expected.txt
new file mode 100644
index 0000000..908a8f2
--- /dev/null
+++ b/test/975-iface-private/expected.txt
@@ -0,0 +1,4 @@
+Saying hi from class
+HELLO!
+Saying hi from interface
+HELLO!
diff --git a/test/975-iface-private/info.txt b/test/975-iface-private/info.txt
new file mode 100644
index 0000000..d5a8d3f
--- /dev/null
+++ b/test/975-iface-private/info.txt
@@ -0,0 +1,5 @@
+Smali-based tests for experimental interface private methods.
+
+This test cannot be run with --jvm.
+
+This test checks that synthetic private methods in interfaces work correctly.
diff --git a/test/975-iface-private/smali/Iface.smali b/test/975-iface-private/smali/Iface.smali
new file mode 100644
index 0000000..a9a44d1
--- /dev/null
+++ b/test/975-iface-private/smali/Iface.smali
@@ -0,0 +1,45 @@
+
+# /*
+# * Copyright (C) 2015 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 interface Iface {
+# public default void sayHi() {
+# System.out.println(getHiWords());
+# }
+#
+# // Synthetic method
+# private String getHiWords() {
+# return "HELLO!";
+# }
+# }
+
+.class public abstract interface LIface;
+.super Ljava/lang/Object;
+
+.method public sayHi()V
+ .locals 2
+ sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream;
+ invoke-direct {p0}, LIface;->getHiWords()Ljava/lang/String;
+ move-result-object v1
+ invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
+ return-void
+.end method
+
+.method private synthetic getHiWords()Ljava/lang/String;
+ .locals 1
+ const-string v0, "HELLO!"
+ return-object v0
+.end method
diff --git a/test/975-iface-private/smali/Main.smali b/test/975-iface-private/smali/Main.smali
new file mode 100644
index 0000000..dbde203
--- /dev/null
+++ b/test/975-iface-private/smali/Main.smali
@@ -0,0 +1,71 @@
+# /*
+# * Copyright (C) 2015 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 Main implements Iface {
+# public static void main(String[] args) {
+# Main m = new Main();
+# sayHiMain(m);
+# sayHiIface(m);
+# }
+# public static void sayHiMain(Main m) {
+# System.out.println("Saying hi from class");
+# m.sayHi();
+# }
+# public static void sayHiIface(Iface m) {
+# System.out.println("Saying hi from interface");
+# m.sayHi();
+# }
+# }
+.class public LMain;
+.super Ljava/lang/Object;
+.implements LIface;
+
+.method public constructor <init>()V
+ .registers 1
+ invoke-direct {p0}, Ljava/lang/Object;-><init>()V
+ return-void
+.end method
+
+.method public static main([Ljava/lang/String;)V
+ .locals 2
+ new-instance v0, LMain;
+ invoke-direct {v0}, LMain;-><init>()V
+
+ invoke-static {v0}, LMain;->sayHiMain(LMain;)V
+ invoke-static {v0}, LMain;->sayHiIface(LIface;)V
+
+ return-void
+.end method
+
+.method public static sayHiMain(LMain;)V
+ .locals 2
+ sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream;
+ const-string v1, "Saying hi from class"
+ invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
+
+ invoke-virtual {p0}, LMain;->sayHi()V
+ return-void
+.end method
+
+.method public static sayHiIface(LIface;)V
+ .locals 2
+ sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream;
+ const-string v1, "Saying hi from interface"
+ invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
+
+ invoke-interface {p0}, LIface;->sayHi()V
+ return-void
+.end method
diff --git a/test/Android.run-test.mk b/test/Android.run-test.mk
index 1edc599..b750524 100644
--- a/test/Android.run-test.mk
+++ b/test/Android.run-test.mk
@@ -235,8 +235,11 @@
$(IMAGE_TYPES), $(PICTEST_TYPES), $(DEBUGGABLE_TYPES), $(TEST_ART_TIMING_SENSITIVE_RUN_TESTS), $(ALL_ADDRESS_SIZES))
endif
+# 147-stripped-dex-fallback isn't supported on device because --strip-dex
+# requires the zip command.
# 569-checker-pattern-replacement tests behaviour present only on host.
TEST_ART_BROKEN_TARGET_TESTS := \
+ 147-stripped-dex-fallback \
569-checker-pattern-replacement
ifneq (,$(filter target,$(TARGET_TYPES)))
@@ -287,6 +290,7 @@
# 529 and 555: b/27784033
TEST_ART_BROKEN_NO_PREBUILD_TESTS := \
117-nopatchoat \
+ 147-stripped-dex-fallback \
554-jit-profile-file \
529-checker-unresolved \
555-checker-regression-x86const
diff --git a/test/etc/default-build b/test/etc/default-build
index 3d84821..962ae38 100755
--- a/test/etc/default-build
+++ b/test/etc/default-build
@@ -69,10 +69,13 @@
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"
+declare -A SMALI_EXPERIMENTAL_ARGS
+SMALI_EXPERIMENTAL_ARGS["default-methods"]="--api-level 24"
+
while true; do
if [ "x$1" = "x--dx-option" ]; then
shift
- option="$1"
+ on="$1"
DX_FLAGS="${DX_FLAGS} $option"
shift
elif [ "x$1" = "x--jvm" ]; then
@@ -110,6 +113,7 @@
# Add args from the experimental mappings.
for experiment in ${EXPERIMENTAL}; do
JACK_ARGS="${JACK_ARGS} ${JACK_EXPERIMENTAL_ARGS[${experiment}]}"
+ SMALI_ARGS="${SMALI_ARGS} ${SMALI_EXPERIMENTAL_ARGS[${experiment}]}"
done
if [ -e classes.dex ]; then
diff --git a/test/etc/run-test-jar b/test/etc/run-test-jar
index 28a99de..d61fc8f 100755
--- a/test/etc/run-test-jar
+++ b/test/etc/run-test-jar
@@ -37,6 +37,7 @@
PREBUILD="y"
QUIET="n"
RELOCATE="y"
+STRIP_DEX="n"
SECONDARY_DEX=""
TIME_OUT="gdb" # "n" (disabled), "timeout" (use timeout), "gdb" (use gdb)
# Value in seconds
@@ -118,6 +119,9 @@
elif [ "x$1" = "x--prebuild" ]; then
PREBUILD="y"
shift
+ elif [ "x$1" = "x--strip-dex" ]; then
+ STRIP_DEX="y"
+ shift
elif [ "x$1" = "x--host" ]; then
HOST="y"
ANDROID_ROOT="$ANDROID_HOST_OUT"
@@ -380,6 +384,7 @@
dex2oat_cmdline="true"
mkdir_cmdline="mkdir -p ${DEX_LOCATION}/dalvik-cache/$ISA"
+strip_cmdline="true"
# Pick a base that will force the app image to get relocated.
app_image="--base=0x4000 --app-image-file=$DEX_LOCATION/oat/$ISA/$TEST_NAME.art"
@@ -409,6 +414,10 @@
fi
fi
+if [ "$STRIP_DEX" = "y" ]; then
+ strip_cmdline="zip --quiet --delete $DEX_LOCATION/$TEST_NAME.jar classes.dex"
+fi
+
DALVIKVM_ISA_FEATURES_ARGS=""
if [ "x$INSTRUCTION_SET_FEATURES" != "x" ] ; then
DALVIKVM_ISA_FEATURES_ARGS="-Xcompiler-option --instruction-set-features=${INSTRUCTION_SET_FEATURES}"
@@ -478,6 +487,7 @@
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH && \
export PATH=$ANDROID_ROOT/bin:$PATH && \
$dex2oat_cmdline && \
+ $strip_cmdline && \
$dalvikvm_cmdline"
cmdfile=$(tempfile -p "cmd-" -s "-$TEST_NAME")
@@ -548,13 +558,7 @@
fi
if [ "$DEV_MODE" = "y" ]; then
- if [ "$PREBUILD" = "y" ]; then
- echo "$mkdir_cmdline && $dex2oat_cmdline && $cmdline"
- elif [ "$RELOCATE" = "y" ]; then
- echo "$mkdir_cmdline && $cmdline"
- else
- echo $cmdline
- fi
+ echo "$mkdir_cmdline && $dex2oat_cmdline && $strip_cmdline && $cmdline"
fi
cd $ANDROID_BUILD_TOP
@@ -562,6 +566,7 @@
rm -rf ${DEX_LOCATION}/dalvik-cache/
$mkdir_cmdline || exit 1
$dex2oat_cmdline || { echo "Dex2oat failed." >&2 ; exit 2; }
+ $strip_cmdline || { echo "Strip failed." >&2 ; exit 3; }
# 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 01464cd..fc57d09 100755
--- a/test/run-test
+++ b/test/run-test
@@ -46,7 +46,7 @@
export DEX_LOCATION=/data/run-test/${test_dir}
export NEED_DEX="true"
export USE_JACK="true"
-export SMALI_ARGS="--experimental --api-level 23"
+export SMALI_ARGS="--experimental"
# If dx was not set by the environment variable, assume it is in the path.
if [ -z "$DX" ]; then
@@ -190,6 +190,9 @@
run_args="${run_args} --prebuild"
prebuild_mode="yes"
shift;
+ elif [ "x$1" = "x--strip-dex" ]; then
+ run_args="${run_args} --strip-dex"
+ shift;
elif [ "x$1" = "x--debuggable" ]; then
run_args="${run_args} -Xcompiler-option --debuggable"
debuggable="yes"
@@ -449,7 +452,7 @@
if [ "$target_mode" = "no" ]; then
framework="${ANDROID_PRODUCT_OUT}/system/framework"
bpath="${framework}/core-libart.jar:${framework}/core-oj.jar:${framework}/conscrypt.jar:${framework}/okhttp.jar:${framework}/bouncycastle.jar:${framework}/ext.jar"
- run_args="${run_args} --boot -Xbootclasspath:${bpath}"
+ run_args="${run_args} --boot --runtime-option -Xbootclasspath:${bpath}"
else
true # defaults to using target BOOTCLASSPATH
fi
@@ -571,6 +574,7 @@
echo " --prebuild Run dex2oat on the files before starting test. (default)"
echo " --no-prebuild Do not run dex2oat on the files before starting"
echo " the test."
+ echo " --strip-dex Strip the dex files before starting test."
echo " --relocate Force the use of relocating in the test, making"
echo " the image and oat files be relocated to a random"
echo " address before running. (default)"
diff --git a/tools/run-jdwp-tests.sh b/tools/run-jdwp-tests.sh
index 8422e20..354fcef 100755
--- a/tools/run-jdwp-tests.sh
+++ b/tools/run-jdwp-tests.sh
@@ -114,9 +114,6 @@
art_debugee="$art_debugee -verbose:jdwp"
fi
-# Use Jack with "1.8" configuration.
-export JACK_VERSION=`basename prebuilts/sdk/tools/jacks/*ALPHA* | sed 's/^jack-//' | sed 's/.jar$//'`
-
# Run the tests using vogar.
vogar $vm_command \
$vm_args \
diff --git a/tools/run-libcore-tests.sh b/tools/run-libcore-tests.sh
index 45fb4b4d..00bb3c5 100755
--- a/tools/run-libcore-tests.sh
+++ b/tools/run-libcore-tests.sh
@@ -109,7 +109,6 @@
vogar_args="$vogar_args --timeout 480"
# Use Jack with "1.8" configuration.
-export JACK_VERSION=`basename prebuilts/sdk/tools/jacks/*ALPHA* | sed 's/^jack-//' | sed 's/.jar$//'`
vogar_args="$vogar_args --toolchain jack --language JN"
# Run the tests using vogar.