summaryrefslogtreecommitdiff
path: root/compiler/optimizing/instruction_simplifier.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2017-11-07 21:17:24 +0000
committer Vladimir Marko <vmarko@google.com> 2017-11-08 13:23:03 +0000
commitda283050a1a3ddbb7cefae3f36e8c8c1a6acedb7 (patch)
treeb839d69d0bf8d55d89a95b80621fd3f630536531 /compiler/optimizing/instruction_simplifier.cc
parent72627a5f675b1c664beb2ad33d60a1c8dca80826 (diff)
Fix String.equals() for moveable String.class.
If the String.class is moveable (i.e. running without boot image), the instanceof check emitted by the JIT in the String.equals() intrinsic would require read barriers. As we do not really care about the performance of running without the boot image, disable the intrinsic in this case. Test: 669-moveable-string-class-equals (--jit) Bug: 68181300 Change-Id: I39c9f9935e0482b3b30f1ae5cd23515cbda0603b
Diffstat (limited to 'compiler/optimizing/instruction_simplifier.cc')
-rw-r--r--compiler/optimizing/instruction_simplifier.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index 2bd2d5f0a1..fbfee12be9 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -2024,6 +2024,20 @@ void InstructionSimplifierVisitor::SimplifyStringEquals(HInvoke* instruction) {
ReferenceTypeInfo argument_rti = argument->GetReferenceTypeInfo();
if (argument_rti.IsValid() && argument_rti.IsStringClass()) {
optimizations.SetArgumentIsString();
+ } else if (kUseReadBarrier) {
+ DCHECK(instruction->GetResolvedMethod() != nullptr);
+ DCHECK(instruction->GetResolvedMethod()->GetDeclaringClass()->IsStringClass());
+ Runtime* runtime = Runtime::Current();
+ // For AOT, we always assume that the boot image shall contain the String.class and
+ // we do not need a read barrier for boot image classes as they are non-moveable.
+ // For JIT, check if we actually have a boot image; if we do, the String.class
+ // should also be non-moveable.
+ if (runtime->IsAotCompiler() || runtime->GetHeap()->HasBootImageSpace()) {
+ DCHECK(runtime->IsAotCompiler() ||
+ !runtime->GetHeap()->IsMovableObject(
+ instruction->GetResolvedMethod()->GetDeclaringClass()));
+ optimizations.SetNoReadBarrierForStringClass();
+ }
}
}
}