summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/dex/quick/dex_file_method_inliner.cc11
-rw-r--r--compiler/dex/quick/dex_file_method_inliner.h2
-rw-r--r--compiler/driver/compiler_driver.cc13
-rw-r--r--compiler/driver/compiler_driver_test.cc4
-rw-r--r--compiler/optimizing/instruction_simplifier.cc84
-rw-r--r--compiler/optimizing/intrinsics.cc4
-rw-r--r--compiler/optimizing/intrinsics_arm.cc2
-rw-r--r--compiler/optimizing/intrinsics_arm64.cc2
-rw-r--r--compiler/optimizing/intrinsics_list.h2
-rw-r--r--compiler/optimizing/intrinsics_mips.cc2
-rw-r--r--compiler/optimizing/intrinsics_mips64.cc2
-rw-r--r--compiler/optimizing/intrinsics_x86.cc2
-rw-r--r--compiler/optimizing/intrinsics_x86_64.cc2
13 files changed, 106 insertions, 26 deletions
diff --git a/compiler/dex/quick/dex_file_method_inliner.cc b/compiler/dex/quick/dex_file_method_inliner.cc
index 209f101199..ad4ddadd2f 100644
--- a/compiler/dex/quick/dex_file_method_inliner.cc
+++ b/compiler/dex/quick/dex_file_method_inliner.cc
@@ -37,6 +37,8 @@ namespace { // anonymous namespace
static constexpr bool kIntrinsicIsStatic[] = {
true, // kIntrinsicDoubleCvt
true, // kIntrinsicFloatCvt
+ true, // kIntrinsicFloat2Int
+ true, // kIntrinsicDouble2Long
true, // kIntrinsicFloatIsInfinite
true, // kIntrinsicDoubleIsInfinite
true, // kIntrinsicFloatIsNaN
@@ -106,6 +108,8 @@ static_assert(arraysize(kIntrinsicIsStatic) == kInlineOpNop,
"arraysize of kIntrinsicIsStatic unexpected");
static_assert(kIntrinsicIsStatic[kIntrinsicDoubleCvt], "DoubleCvt must be static");
static_assert(kIntrinsicIsStatic[kIntrinsicFloatCvt], "FloatCvt must be static");
+static_assert(kIntrinsicIsStatic[kIntrinsicFloat2Int], "Float2Int must be static");
+static_assert(kIntrinsicIsStatic[kIntrinsicDouble2Long], "Double2Long must be static");
static_assert(kIntrinsicIsStatic[kIntrinsicFloatIsInfinite], "FloatIsInfinite must be static");
static_assert(kIntrinsicIsStatic[kIntrinsicDoubleIsInfinite], "DoubleIsInfinite must be static");
static_assert(kIntrinsicIsStatic[kIntrinsicFloatIsNaN], "FloatIsNaN must be static");
@@ -277,6 +281,8 @@ const char* const DexFileMethodInliner::kNameCacheNames[] = {
"equals", // kNameCacheEquals
"getCharsNoCheck", // kNameCacheGetCharsNoCheck
"isEmpty", // kNameCacheIsEmpty
+ "floatToIntBits", // kNameCacheFloatToIntBits
+ "doubleToLongBits", // kNameCacheDoubleToLongBits
"isInfinite", // kNameCacheIsInfinite
"isNaN", // kNameCacheIsNaN
"indexOf", // kNameCacheIndexOf
@@ -472,6 +478,9 @@ const DexFileMethodInliner::IntrinsicDef DexFileMethodInliner::kIntrinsicMethods
INTRINSIC(JavaLangFloat, FloatToRawIntBits, F_I, kIntrinsicFloatCvt, 0),
INTRINSIC(JavaLangFloat, IntBitsToFloat, I_F, kIntrinsicFloatCvt, kIntrinsicFlagToFloatingPoint),
+ INTRINSIC(JavaLangFloat, FloatToIntBits, F_I, kIntrinsicFloat2Int, 0),
+ INTRINSIC(JavaLangDouble, DoubleToLongBits, D_J, kIntrinsicDouble2Long, 0),
+
INTRINSIC(JavaLangFloat, IsInfinite, F_Z, kIntrinsicFloatIsInfinite, 0),
INTRINSIC(JavaLangDouble, IsInfinite, D_Z, kIntrinsicDoubleIsInfinite, 0),
INTRINSIC(JavaLangFloat, IsNaN, F_Z, kIntrinsicFloatIsNaN, 0),
@@ -791,6 +800,8 @@ bool DexFileMethodInliner::GenIntrinsic(Mir2Lir* backend, CallInfo* info) {
intrinsic.d.data & kIntrinsicFlagIsOrdered);
case kIntrinsicSystemArrayCopyCharArray:
return backend->GenInlinedArrayCopyCharArray(info);
+ case kIntrinsicFloat2Int:
+ case kIntrinsicDouble2Long:
case kIntrinsicFloatIsInfinite:
case kIntrinsicDoubleIsInfinite:
case kIntrinsicFloatIsNaN:
diff --git a/compiler/dex/quick/dex_file_method_inliner.h b/compiler/dex/quick/dex_file_method_inliner.h
index 59b8a533ae..b465db2c54 100644
--- a/compiler/dex/quick/dex_file_method_inliner.h
+++ b/compiler/dex/quick/dex_file_method_inliner.h
@@ -190,6 +190,8 @@ class DexFileMethodInliner {
kNameCacheEquals,
kNameCacheGetCharsNoCheck,
kNameCacheIsEmpty,
+ kNameCacheFloatToIntBits,
+ kNameCacheDoubleToLongBits,
kNameCacheIsInfinite,
kNameCacheIsNaN,
kNameCacheIndexOf,
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index a9fec30bfe..3100b6da0f 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -384,7 +384,9 @@ CompilerDriver::CompilerDriver(
compiler_->Init();
- CHECK_EQ(boot_image_, image_classes_.get() != nullptr);
+ if (boot_image_) {
+ CHECK(image_classes_.get() != nullptr) << "Expected image classes for boot image";
+ }
}
CompilerDriver::~CompilerDriver() {
@@ -868,12 +870,13 @@ void CompilerDriver::PreCompile(jobject class_loader,
}
bool CompilerDriver::IsImageClass(const char* descriptor) const {
- if (!IsBootImage()) {
- // NOTE: Currently only reachable from InitImageMethodVisitor for the app image case.
- return true;
- } else {
+ if (image_classes_ != nullptr) {
+ // If we have a set of image classes, use those.
return image_classes_->find(descriptor) != image_classes_->end();
}
+ // No set of image classes, assume we include all the classes.
+ // NOTE: Currently only reachable from InitImageMethodVisitor for the app image case.
+ return !IsBootImage();
}
bool CompilerDriver::IsClassToCompile(const char* descriptor) const {
diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc
index 478588561f..00375641f3 100644
--- a/compiler/driver/compiler_driver_test.cc
+++ b/compiler/driver/compiler_driver_test.cc
@@ -250,8 +250,8 @@ class CompilerDriverProfileTest : public CompilerDriverTest {
ProfileCompilationInfo info;
for (const std::unique_ptr<const DexFile>& dex_file : dex_files) {
std::string key = ProfileCompilationInfo::GetProfileDexFileKey(dex_file->GetLocation());
- profile_info_.AddData(key, dex_file->GetLocationChecksum(), 1);
- profile_info_.AddData(key, dex_file->GetLocationChecksum(), 2);
+ profile_info_.AddMethodIndex(key, dex_file->GetLocationChecksum(), 1);
+ profile_info_.AddMethodIndex(key, dex_file->GetLocationChecksum(), 2);
}
return &profile_info_;
}
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index 13d3f752c3..f8a9a94e62 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -93,6 +93,7 @@ class InstructionSimplifierVisitor : public HGraphDelegateVisitor {
void SimplifyStringEquals(HInvoke* invoke);
void SimplifyCompare(HInvoke* invoke, bool has_zero_op);
void SimplifyIsNaN(HInvoke* invoke);
+ void SimplifyFP2Int(HInvoke* invoke);
OptimizingCompilerStats* stats_;
bool simplification_occurred_ = false;
@@ -1562,26 +1563,71 @@ void InstructionSimplifierVisitor::SimplifyIsNaN(HInvoke* invoke) {
invoke->GetBlock()->ReplaceAndRemoveInstructionWith(invoke, condition);
}
+void InstructionSimplifierVisitor::SimplifyFP2Int(HInvoke* invoke) {
+ DCHECK(invoke->IsInvokeStaticOrDirect());
+ uint32_t dex_pc = invoke->GetDexPc();
+ HInstruction* x = invoke->InputAt(0);
+ Primitive::Type type = x->GetType();
+ // Set proper bit pattern for NaN and replace intrinsic with raw version.
+ HInstruction* nan;
+ if (type == Primitive::kPrimDouble) {
+ nan = GetGraph()->GetLongConstant(0x7ff8000000000000L);
+ invoke->SetIntrinsic(Intrinsics::kDoubleDoubleToRawLongBits,
+ kNeedsEnvironmentOrCache,
+ kNoSideEffects,
+ kNoThrow);
+ } else {
+ DCHECK_EQ(type, Primitive::kPrimFloat);
+ nan = GetGraph()->GetIntConstant(0x7fc00000);
+ invoke->SetIntrinsic(Intrinsics::kFloatFloatToRawIntBits,
+ kNeedsEnvironmentOrCache,
+ kNoSideEffects,
+ kNoThrow);
+ }
+ // Test IsNaN(x), which is the same as x != x.
+ HCondition* condition = new (GetGraph()->GetArena()) HNotEqual(x, x, dex_pc);
+ condition->SetBias(ComparisonBias::kLtBias);
+ invoke->GetBlock()->InsertInstructionBefore(condition, invoke->GetNext());
+ // Select between the two.
+ HInstruction* select = new (GetGraph()->GetArena()) HSelect(condition, nan, invoke, dex_pc);
+ invoke->GetBlock()->InsertInstructionBefore(select, condition->GetNext());
+ invoke->ReplaceWithExceptInReplacementAtIndex(select, 0); // false at index 0
+}
+
void InstructionSimplifierVisitor::VisitInvoke(HInvoke* instruction) {
- if (instruction->GetIntrinsic() == Intrinsics::kStringEquals) {
- SimplifyStringEquals(instruction);
- } else if (instruction->GetIntrinsic() == Intrinsics::kSystemArrayCopy) {
- SimplifySystemArrayCopy(instruction);
- } else if (instruction->GetIntrinsic() == Intrinsics::kIntegerRotateRight ||
- instruction->GetIntrinsic() == Intrinsics::kLongRotateRight) {
- SimplifyRotate(instruction, false);
- } else if (instruction->GetIntrinsic() == Intrinsics::kIntegerRotateLeft ||
- instruction->GetIntrinsic() == Intrinsics::kLongRotateLeft) {
- SimplifyRotate(instruction, true);
- } else if (instruction->GetIntrinsic() == Intrinsics::kIntegerCompare ||
- instruction->GetIntrinsic() == Intrinsics::kLongCompare) {
- SimplifyCompare(instruction, /* is_signum */ false);
- } else if (instruction->GetIntrinsic() == Intrinsics::kIntegerSignum ||
- instruction->GetIntrinsic() == Intrinsics::kLongSignum) {
- SimplifyCompare(instruction, /* is_signum */ true);
- } else if (instruction->GetIntrinsic() == Intrinsics::kFloatIsNaN ||
- instruction->GetIntrinsic() == Intrinsics::kDoubleIsNaN) {
- SimplifyIsNaN(instruction);
+ switch (instruction->GetIntrinsic()) {
+ case Intrinsics::kStringEquals:
+ SimplifyStringEquals(instruction);
+ break;
+ case Intrinsics::kSystemArrayCopy:
+ SimplifySystemArrayCopy(instruction);
+ break;
+ case Intrinsics::kIntegerRotateRight:
+ case Intrinsics::kLongRotateRight:
+ SimplifyRotate(instruction, false);
+ break;
+ case Intrinsics::kIntegerRotateLeft:
+ case Intrinsics::kLongRotateLeft:
+ SimplifyRotate(instruction, true);
+ break;
+ case Intrinsics::kIntegerCompare:
+ case Intrinsics::kLongCompare:
+ SimplifyCompare(instruction, /* is_signum */ false);
+ break;
+ case Intrinsics::kIntegerSignum:
+ case Intrinsics::kLongSignum:
+ SimplifyCompare(instruction, /* is_signum */ true);
+ break;
+ case Intrinsics::kFloatIsNaN:
+ case Intrinsics::kDoubleIsNaN:
+ SimplifyIsNaN(instruction);
+ break;
+ case Intrinsics::kFloatFloatToIntBits:
+ case Intrinsics::kDoubleDoubleToLongBits:
+ SimplifyFP2Int(instruction);
+ break;
+ default:
+ break;
}
}
diff --git a/compiler/optimizing/intrinsics.cc b/compiler/optimizing/intrinsics.cc
index 316e86b4c9..3ed0278871 100644
--- a/compiler/optimizing/intrinsics.cc
+++ b/compiler/optimizing/intrinsics.cc
@@ -130,6 +130,10 @@ static Intrinsics GetIntrinsic(InlineMethod method) {
case kIntrinsicFloatCvt:
return ((method.d.data & kIntrinsicFlagToFloatingPoint) == 0) ?
Intrinsics::kFloatFloatToRawIntBits : Intrinsics::kFloatIntBitsToFloat;
+ case kIntrinsicFloat2Int:
+ return Intrinsics::kFloatFloatToIntBits;
+ case kIntrinsicDouble2Long:
+ return Intrinsics::kDoubleDoubleToLongBits;
// Floating-point tests.
case kIntrinsicFloatIsInfinite:
diff --git a/compiler/optimizing/intrinsics_arm.cc b/compiler/optimizing/intrinsics_arm.cc
index 8e22f8677d..4ce919ee39 100644
--- a/compiler/optimizing/intrinsics_arm.cc
+++ b/compiler/optimizing/intrinsics_arm.cc
@@ -2006,6 +2006,8 @@ UNIMPLEMENTED_INTRINSIC(IntegerLowestOneBit)
UNIMPLEMENTED_INTRINSIC(LongLowestOneBit)
// Handled as HIR instructions.
+UNIMPLEMENTED_INTRINSIC(FloatFloatToIntBits)
+UNIMPLEMENTED_INTRINSIC(DoubleDoubleToLongBits)
UNIMPLEMENTED_INTRINSIC(FloatIsNaN)
UNIMPLEMENTED_INTRINSIC(DoubleIsNaN)
UNIMPLEMENTED_INTRINSIC(IntegerRotateLeft)
diff --git a/compiler/optimizing/intrinsics_arm64.cc b/compiler/optimizing/intrinsics_arm64.cc
index 19ccb3d568..4be1695a94 100644
--- a/compiler/optimizing/intrinsics_arm64.cc
+++ b/compiler/optimizing/intrinsics_arm64.cc
@@ -1688,6 +1688,8 @@ UNIMPLEMENTED_INTRINSIC(IntegerLowestOneBit)
UNIMPLEMENTED_INTRINSIC(LongLowestOneBit)
// Handled as HIR instructions.
+UNIMPLEMENTED_INTRINSIC(FloatFloatToIntBits)
+UNIMPLEMENTED_INTRINSIC(DoubleDoubleToLongBits)
UNIMPLEMENTED_INTRINSIC(FloatIsNaN)
UNIMPLEMENTED_INTRINSIC(DoubleIsNaN)
UNIMPLEMENTED_INTRINSIC(IntegerRotateLeft)
diff --git a/compiler/optimizing/intrinsics_list.h b/compiler/optimizing/intrinsics_list.h
index 88217b308e..e1aea924cf 100644
--- a/compiler/optimizing/intrinsics_list.h
+++ b/compiler/optimizing/intrinsics_list.h
@@ -23,10 +23,12 @@
#define INTRINSICS_LIST(V) \
V(DoubleDoubleToRawLongBits, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow) \
+ V(DoubleDoubleToLongBits, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow) \
V(DoubleIsInfinite, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow) \
V(DoubleIsNaN, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow) \
V(DoubleLongBitsToDouble, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow) \
V(FloatFloatToRawIntBits, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow) \
+ V(FloatFloatToIntBits, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow) \
V(FloatIsInfinite, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow) \
V(FloatIsNaN, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow) \
V(FloatIntBitsToFloat, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow) \
diff --git a/compiler/optimizing/intrinsics_mips.cc b/compiler/optimizing/intrinsics_mips.cc
index 2f183c3a62..a737d8100a 100644
--- a/compiler/optimizing/intrinsics_mips.cc
+++ b/compiler/optimizing/intrinsics_mips.cc
@@ -1772,6 +1772,8 @@ UNIMPLEMENTED_INTRINSIC(IntegerLowestOneBit)
UNIMPLEMENTED_INTRINSIC(LongLowestOneBit)
// Handled as HIR instructions.
+UNIMPLEMENTED_INTRINSIC(FloatFloatToIntBits)
+UNIMPLEMENTED_INTRINSIC(DoubleDoubleToLongBits)
UNIMPLEMENTED_INTRINSIC(FloatIsNaN)
UNIMPLEMENTED_INTRINSIC(DoubleIsNaN)
UNIMPLEMENTED_INTRINSIC(IntegerCompare)
diff --git a/compiler/optimizing/intrinsics_mips64.cc b/compiler/optimizing/intrinsics_mips64.cc
index bd4f5329da..ca2652b74a 100644
--- a/compiler/optimizing/intrinsics_mips64.cc
+++ b/compiler/optimizing/intrinsics_mips64.cc
@@ -1824,6 +1824,8 @@ UNIMPLEMENTED_INTRINSIC(IntegerLowestOneBit)
UNIMPLEMENTED_INTRINSIC(LongLowestOneBit)
// Handled as HIR instructions.
+UNIMPLEMENTED_INTRINSIC(FloatFloatToIntBits)
+UNIMPLEMENTED_INTRINSIC(DoubleDoubleToLongBits)
UNIMPLEMENTED_INTRINSIC(FloatIsNaN)
UNIMPLEMENTED_INTRINSIC(DoubleIsNaN)
UNIMPLEMENTED_INTRINSIC(IntegerCompare)
diff --git a/compiler/optimizing/intrinsics_x86.cc b/compiler/optimizing/intrinsics_x86.cc
index 260a8773fb..0df4553f56 100644
--- a/compiler/optimizing/intrinsics_x86.cc
+++ b/compiler/optimizing/intrinsics_x86.cc
@@ -2642,6 +2642,8 @@ UNIMPLEMENTED_INTRINSIC(IntegerLowestOneBit)
UNIMPLEMENTED_INTRINSIC(LongLowestOneBit)
// Handled as HIR instructions.
+UNIMPLEMENTED_INTRINSIC(FloatFloatToIntBits)
+UNIMPLEMENTED_INTRINSIC(DoubleDoubleToLongBits)
UNIMPLEMENTED_INTRINSIC(FloatIsNaN)
UNIMPLEMENTED_INTRINSIC(DoubleIsNaN)
UNIMPLEMENTED_INTRINSIC(IntegerRotateLeft)
diff --git a/compiler/optimizing/intrinsics_x86_64.cc b/compiler/optimizing/intrinsics_x86_64.cc
index 93e8c00e5a..2a9e684d11 100644
--- a/compiler/optimizing/intrinsics_x86_64.cc
+++ b/compiler/optimizing/intrinsics_x86_64.cc
@@ -2719,6 +2719,8 @@ UNIMPLEMENTED_INTRINSIC(FloatIsInfinite)
UNIMPLEMENTED_INTRINSIC(DoubleIsInfinite)
// Handled as HIR instructions.
+UNIMPLEMENTED_INTRINSIC(FloatFloatToIntBits)
+UNIMPLEMENTED_INTRINSIC(DoubleDoubleToLongBits)
UNIMPLEMENTED_INTRINSIC(FloatIsNaN)
UNIMPLEMENTED_INTRINSIC(DoubleIsNaN)
UNIMPLEMENTED_INTRINSIC(IntegerRotateLeft)