Revert "ART: Use the bitstring type check for AOT app compilation."
Test failures:
http://build.chromium.org/p/client.art/builders/fugu-debug/builds/4875
01-25 02:05:28.357 23732 23732 F /data/local/tmp/system/bin/../bin/dalvikvm: quick_throw_entrypoints.cc:132] Check failed: !dest_type->IsAssignableFrom(src_type)
This reverts commit 718e8319c728e9ee2ec15b1d56ca96baa4393028.
Change-Id: I022f88cd81ae99143e5670ae29eae326ecc83cc2
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 273bd50..70cbb01 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -872,14 +872,6 @@
TimingLogger* timings) {
CheckThreadPools();
- if (kUseBitstringTypeCheck &&
- !compiler_options_->IsBootImage() &&
- compiler_options_->IsAotCompilationEnabled()) {
- RecordBootImageClassesWithAssignedBitstring();
- VLOG(compiler) << "RecordBootImageClassesWithAssignedBitstring: "
- << GetMemoryUsageString(false);
- }
-
LoadImageClasses(timings);
VLOG(compiler) << "LoadImageClasses: " << GetMemoryUsageString(false);
@@ -948,43 +940,6 @@
}
}
-void CompilerDriver::RecordBootImageClassesWithAssignedBitstring() {
- if (boot_image_classes_with_assigned_bitstring_ != nullptr) {
- return; // Already recorded. (Happens because of class unloading between dex files.)
- }
-
- class Visitor : public ClassVisitor {
- public:
- explicit Visitor(std::unordered_set<mirror::Class*>* recorded_classes)
- : recorded_classes_(recorded_classes) {}
-
- bool operator()(ObjPtr<mirror::Class> klass) OVERRIDE
- REQUIRES(Locks::subtype_check_lock_) REQUIRES_SHARED(Locks::mutator_lock_) {
- DCHECK(klass != nullptr);
- SubtypeCheckInfo::State state = SubtypeCheck<ObjPtr<mirror::Class>>::GetState(klass);
- if (state == SubtypeCheckInfo::kAssigned) {
- recorded_classes_->insert(klass.Ptr());
- }
- return true;
- }
-
- private:
- std::unordered_set<mirror::Class*>* const recorded_classes_;
- };
-
- boot_image_classes_with_assigned_bitstring_.reset(new std::unordered_set<mirror::Class*>());
- Visitor visitor(boot_image_classes_with_assigned_bitstring_.get());
- ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
- ScopedObjectAccess soa(Thread::Current());
- MutexLock subtype_check_lock(soa.Self(), *Locks::subtype_check_lock_);
- class_linker->VisitClasses(&visitor);
-}
-
-bool CompilerDriver::IsBootImageClassWithAssignedBitstring(ObjPtr<mirror::Class> klass) {
- DCHECK(boot_image_classes_with_assigned_bitstring_ != nullptr);
- return boot_image_classes_with_assigned_bitstring_->count(klass.Ptr()) != 0u;
-}
-
bool CompilerDriver::IsImageClass(const char* descriptor) const {
if (image_classes_ != nullptr) {
// If we have a set of image classes, use those.
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index 3004275..4b5916d 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -385,17 +385,12 @@
return dex_to_dex_compiler_;
}
- bool IsBootImageClassWithAssignedBitstring(ObjPtr<mirror::Class> klass)
- REQUIRES_SHARED(Locks::mutator_lock_);
-
private:
void PreCompile(jobject class_loader,
const std::vector<const DexFile*>& dex_files,
TimingLogger* timings)
REQUIRES(!Locks::mutator_lock_);
- void RecordBootImageClassesWithAssignedBitstring() REQUIRES(!Locks::mutator_lock_);
-
void LoadImageClasses(TimingLogger* timings) REQUIRES(!Locks::mutator_lock_);
// Attempt to resolve all type, methods, fields, and strings
@@ -518,12 +513,6 @@
// This option may be restricted to the boot image, depending on a flag in the implementation.
std::unique_ptr<std::unordered_set<std::string>> methods_to_compile_;
- // For AOT app compilation, we keep the set of boot image classes with assigned type check
- // bitstring. We need to retrieve this set before we initialize app image classes as the
- // initialization can cause more boot image bitstrings to be assigned.
- // Note that boot image classes are non-moveable, so it's OK to keep raw pointers.
- std::unique_ptr<std::unordered_set<mirror::Class*>> boot_image_classes_with_assigned_bitstring_;
-
std::atomic<uint32_t> number_of_soft_verifier_failures_;
bool had_hard_verifier_failure_;
diff --git a/compiler/optimizing/sharpening.cc b/compiler/optimizing/sharpening.cc
index 12319df..dffef17 100644
--- a/compiler/optimizing/sharpening.cc
+++ b/compiler/optimizing/sharpening.cc
@@ -253,9 +253,9 @@
// If the target is a boot image class, try to assign a type check bitstring (fall through).
// (If --force-determinism, this was already done; repeating is OK and yields the same result.)
} else {
- // For AOT app compilation we can use the bitstring iff the target class is
- // a boot image class with a bitstring already assigned in the boot image.
- return compiler_driver->IsBootImageClassWithAssignedBitstring(klass);
+ // TODO: Use the bitstring also for AOT app compilation if the target class has a bitstring
+ // already assigned in the boot image.
+ return false;
}
// Try to assign a type check bitstring.
diff --git a/runtime/entrypoints/quick/quick_throw_entrypoints.cc b/runtime/entrypoints/quick/quick_throw_entrypoints.cc
index db4891e..4b26bee 100644
--- a/runtime/entrypoints/quick/quick_throw_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_throw_entrypoints.cc
@@ -126,14 +126,6 @@
dex::TypeIndex type_index(check_cast.VRegB_21c());
ClassLinker* linker = Runtime::Current()->GetClassLinker();
dest_type = linker->LookupResolvedType(type_index, visitor.caller).Ptr();
- if (UNLIKELY(dest_type == nullptr)) {
- // This class must have been resolved to the boot image at AOT compile time
- // but it's not yet resolved in the app's class loader. Just look it up in
- // the boot class path loader.
- DCHECK(visitor.caller->GetClassLoader() != nullptr);
- dest_type = linker->LookupResolvedType(
- type_index, visitor.caller->GetDexCache(), /* class_loader */ nullptr).Ptr();
- }
CHECK(dest_type != nullptr) << "Target class should have been previously resolved: "
<< visitor.caller->GetDexFile()->PrettyType(type_index);
}
diff --git a/test/552-checker-sharpening/src/Main.java b/test/552-checker-sharpening/src/Main.java
index 0623a22..3173afd 100644
--- a/test/552-checker-sharpening/src/Main.java
+++ b/test/552-checker-sharpening/src/Main.java
@@ -14,17 +14,8 @@
* limitations under the License.
*/
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
public class Main {
- public static void assertBooleanEquals(boolean expected, boolean result) {
- if (expected != result) {
- throw new Error("Expected: " + expected + ", found: " + result);
- }
- }
-
public static void assertIntEquals(int expected, int result) {
if (expected != result) {
throw new Error("Expected: " + expected + ", found: " + result);
@@ -204,14 +195,6 @@
return Other.class;
}
- /// CHECK-START: boolean Main.$noinline$instanceOfInputStream(java.lang.Object) builder (after)
- /// CHECK-NOT: LoadClass
- /// CHECK: InstanceOf check_kind:bitstring_check
- public static boolean $noinline$instanceOfInputStream(Object o) {
- // InputStream is known to be in the core image with an initialized type check bitstring.
- return o instanceof InputStream;
- }
-
public static void main(String[] args) {
assertIntEquals(1, testSimple(1));
assertIntEquals(1, testDiamond(false, 1));
@@ -225,10 +208,6 @@
assertStringEquals("non-boot-image-string", $noinline$getNonBootImageString());
assertClassEquals(String.class, $noinline$getStringClass());
assertClassEquals(Other.class, $noinline$getOtherClass());
- assertBooleanEquals(false, $noinline$instanceOfInputStream(null));
- assertBooleanEquals(false, $noinline$instanceOfInputStream(new Integer(1)));
- assertBooleanEquals(true,
- $noinline$instanceOfInputStream(new ByteArrayInputStream(new byte[10])));
}
}