summaryrefslogtreecommitdiff
path: root/compiler/optimizing
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2020-11-06 13:39:54 +0000
committer Treehugger Robot <treehugger-gerrit@google.com> 2020-11-06 15:26:27 +0000
commit8f2eb25ca40136a36a5d7002c8ca5a05723e334e (patch)
tree51778c592bdd3eb65d3fde8c21997eec30bd1e23 /compiler/optimizing
parent8411c5ddb824bae1d3202a3bc2e42c77d351e916 (diff)
Remove NeedsDexCache logic from the compiler.
The compiled code and runtime stubs don't need to have direct access to the dex cache anymore. Test: test.py Change-Id: Id3aab9b10445ba2599e1a9ffd8e36506a745bfec
Diffstat (limited to 'compiler/optimizing')
-rw-r--r--compiler/optimizing/critical_native_abi_fixup_arm.cc1
-rw-r--r--compiler/optimizing/inliner.cc10
-rw-r--r--compiler/optimizing/instruction_simplifier.cc4
-rw-r--r--compiler/optimizing/intrinsics.h5
-rw-r--r--compiler/optimizing/nodes.cc32
-rw-r--r--compiler/optimizing/nodes.h26
6 files changed, 18 insertions, 60 deletions
diff --git a/compiler/optimizing/critical_native_abi_fixup_arm.cc b/compiler/optimizing/critical_native_abi_fixup_arm.cc
index bf9233f51e..11d42a41ee 100644
--- a/compiler/optimizing/critical_native_abi_fixup_arm.cc
+++ b/compiler/optimizing/critical_native_abi_fixup_arm.cc
@@ -77,7 +77,6 @@ static void FixUpArguments(HInvokeStaticOrDirect* invoke) {
// The intrinsic has no side effects and does not need environment or dex cache on ARM.
new_input->SetSideEffects(SideEffects::None());
IntrinsicOptimizations opt(new_input);
- opt.SetDoesNotNeedDexCache();
opt.SetDoesNotNeedEnvironment();
new_input->SetRawInputAt(0u, input);
block->InsertInstructionBefore(new_input, invoke);
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index 4eb671eb8d..a8bd4e5f9e 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -1823,8 +1823,6 @@ bool HInliner::CanInlineBody(const HGraph* callee_graph,
const DexFile& callee_dex_file = callee_graph->GetDexFile();
ArtMethod* const resolved_method = callee_graph->GetArtMethod();
const uint32_t method_index = resolved_method->GetMethodIndex();
- const bool same_dex_file =
- IsSameDexFile(*outer_compilation_unit_.GetDexFile(), *resolved_method->GetDexFile());
HBasicBlock* exit_block = callee_graph->GetExitBlock();
if (exit_block == nullptr) {
@@ -1925,14 +1923,6 @@ bool HInliner::CanInlineBody(const HGraph* callee_graph,
return false;
}
- if (!same_dex_file && current->NeedsDexCacheOfDeclaringClass()) {
- LOG_FAIL(stats_, MethodCompilationStat::kNotInlinedDexCache)
- << "Method " << callee_dex_file.PrettyMethod(method_index)
- << " could not be inlined because " << current->DebugName()
- << " it is in a different dex file and requires access to the dex cache";
- return false;
- }
-
if (current->IsUnresolvedStaticFieldGet() ||
current->IsUnresolvedInstanceFieldGet() ||
current->IsUnresolvedStaticFieldSet() ||
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index d7d5b597c0..96f82f61ca 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -2326,14 +2326,14 @@ void InstructionSimplifierVisitor::SimplifyFP2Int(HInvoke* invoke) {
if (type == DataType::Type::kFloat64) {
nan = GetGraph()->GetLongConstant(0x7ff8000000000000L);
invoke->SetIntrinsic(Intrinsics::kDoubleDoubleToRawLongBits,
- kNeedsEnvironmentOrCache,
+ kNeedsEnvironment,
kNoSideEffects,
kNoThrow);
} else {
DCHECK_EQ(type, DataType::Type::kFloat32);
nan = GetGraph()->GetIntConstant(0x7fc00000);
invoke->SetIntrinsic(Intrinsics::kFloatFloatToRawIntBits,
- kNeedsEnvironmentOrCache,
+ kNeedsEnvironment,
kNoSideEffects,
kNoThrow);
}
diff --git a/compiler/optimizing/intrinsics.h b/compiler/optimizing/intrinsics.h
index a0f9420d95..96f178e25e 100644
--- a/compiler/optimizing/intrinsics.h
+++ b/compiler/optimizing/intrinsics.h
@@ -163,9 +163,8 @@ class IntrinsicOptimizations : public ValueObject {
explicit IntrinsicOptimizations(const HInvoke& invoke)
: value_(invoke.GetIntrinsicOptimizations()) {}
- static constexpr int kNumberOfGenericOptimizations = 2;
- GENERIC_OPTIMIZATION(DoesNotNeedDexCache, 0);
- GENERIC_OPTIMIZATION(DoesNotNeedEnvironment, 1);
+ static constexpr int kNumberOfGenericOptimizations = 1;
+ GENERIC_OPTIMIZATION(DoesNotNeedEnvironment, 0);
protected:
bool IsBitSet(uint32_t bit) const {
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc
index 50cedd2502..e2d164e1a2 100644
--- a/compiler/optimizing/nodes.cc
+++ b/compiler/optimizing/nodes.cc
@@ -2881,7 +2881,7 @@ bool HInstruction::HasAnyEnvironmentUseBefore(HInstruction* other) {
}
void HInvoke::SetIntrinsic(Intrinsics intrinsic,
- IntrinsicNeedsEnvironmentOrCache needs_env_or_cache,
+ IntrinsicNeedsEnvironment needs_env,
IntrinsicSideEffects side_effects,
IntrinsicExceptions exceptions) {
intrinsic_ = intrinsic;
@@ -2895,8 +2895,7 @@ void HInvoke::SetIntrinsic(Intrinsics intrinsic,
case kAllSideEffects: SetSideEffects(SideEffects::AllExceptGCDependency()); break;
}
- if (needs_env_or_cache == kNoEnvironmentOrCache) {
- opt.SetDoesNotNeedDexCache();
+ if (needs_env == kNoEnvironment) {
opt.SetDoesNotNeedEnvironment();
} else {
// If we need an environment, that means there will be a call, which can trigger GC.
@@ -2926,17 +2925,6 @@ const DexFile& HInvokeStaticOrDirect::GetDexFileForPcRelativeDexCache() const {
return caller == nullptr ? GetBlock()->GetGraph()->GetDexFile() : *caller->GetDexFile();
}
-bool HInvokeStaticOrDirect::NeedsDexCacheOfDeclaringClass() const {
- if (GetMethodLoadKind() != MethodLoadKind::kRuntimeCall) {
- return false;
- }
- if (!IsIntrinsic()) {
- return true;
- }
- IntrinsicOptimizations opt(*this);
- return !opt.GetDoesNotNeedDexCache();
-}
-
std::ostream& operator<<(std::ostream& os, HInvokeStaticOrDirect::ClinitCheckRequirement rhs) {
switch (rhs) {
case HInvokeStaticOrDirect::ClinitCheckRequirement::kExplicit:
@@ -3114,19 +3102,19 @@ std::ostream& operator<<(std::ostream& os, TypeCheckKind rhs) {
#undef CHECK_INTRINSICS_ENUM_VALUES
// Function that returns whether an intrinsic needs an environment or not.
-static inline IntrinsicNeedsEnvironmentOrCache NeedsEnvironmentOrCacheIntrinsic(Intrinsics i) {
+static inline IntrinsicNeedsEnvironment NeedsEnvironmentIntrinsic(Intrinsics i) {
switch (i) {
case Intrinsics::kNone:
- return kNeedsEnvironmentOrCache; // Non-sensical for intrinsic.
-#define OPTIMIZING_INTRINSICS(Name, InvokeType, NeedsEnvOrCache, SideEffects, Exceptions, ...) \
+ return kNeedsEnvironment; // Non-sensical for intrinsic.
+#define OPTIMIZING_INTRINSICS(Name, InvokeType, NeedsEnv, SideEffects, Exceptions, ...) \
case Intrinsics::k ## Name: \
- return NeedsEnvOrCache;
+ return NeedsEnv;
#include "intrinsics_list.h"
INTRINSICS_LIST(OPTIMIZING_INTRINSICS)
#undef INTRINSICS_LIST
#undef OPTIMIZING_INTRINSICS
}
- return kNeedsEnvironmentOrCache;
+ return kNeedsEnvironment;
}
// Function that returns whether an intrinsic has side effects.
@@ -3134,7 +3122,7 @@ static inline IntrinsicSideEffects GetSideEffectsIntrinsic(Intrinsics i) {
switch (i) {
case Intrinsics::kNone:
return kAllSideEffects;
-#define OPTIMIZING_INTRINSICS(Name, InvokeType, NeedsEnvOrCache, SideEffects, Exceptions, ...) \
+#define OPTIMIZING_INTRINSICS(Name, InvokeType, NeedsEnv, SideEffects, Exceptions, ...) \
case Intrinsics::k ## Name: \
return SideEffects;
#include "intrinsics_list.h"
@@ -3150,7 +3138,7 @@ static inline IntrinsicExceptions GetExceptionsIntrinsic(Intrinsics i) {
switch (i) {
case Intrinsics::kNone:
return kCanThrow;
-#define OPTIMIZING_INTRINSICS(Name, InvokeType, NeedsEnvOrCache, SideEffects, Exceptions, ...) \
+#define OPTIMIZING_INTRINSICS(Name, InvokeType, NeedsEnv, SideEffects, Exceptions, ...) \
case Intrinsics::k ## Name: \
return Exceptions;
#include "intrinsics_list.h"
@@ -3165,7 +3153,7 @@ void HInvoke::SetResolvedMethod(ArtMethod* method) {
if (method != nullptr && method->IsIntrinsic()) {
Intrinsics intrinsic = static_cast<Intrinsics>(method->GetIntrinsic());
SetIntrinsic(intrinsic,
- NeedsEnvironmentOrCacheIntrinsic(intrinsic),
+ NeedsEnvironmentIntrinsic(intrinsic),
GetSideEffectsIntrinsic(intrinsic),
GetExceptionsIntrinsic(intrinsic));
}
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index 9200689f27..ad56d31667 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -2468,10 +2468,6 @@ class HInstruction : public ArenaObject<kArenaAllocInstruction> {
return NeedsEnvironment() || IsCurrentMethod();
}
- // Returns whether the code generation of the instruction will require to have access
- // to the dex cache of the current method's declaring class via the current method.
- virtual bool NeedsDexCacheOfDeclaringClass() const { return false; }
-
// Does this instruction have any use in an environment before
// control flow hits 'other'?
bool HasAnyEnvironmentUseBefore(HInstruction* other);
@@ -4355,9 +4351,9 @@ class HNewInstance final : public HExpression<1> {
QuickEntrypointEnum entrypoint_;
};
-enum IntrinsicNeedsEnvironmentOrCache {
- kNoEnvironmentOrCache, // Intrinsic does not require an environment or dex cache.
- kNeedsEnvironmentOrCache // Intrinsic requires an environment or requires a dex cache.
+enum IntrinsicNeedsEnvironment {
+ kNoEnvironment, // Intrinsic does not require an environment.
+ kNeedsEnvironment // Intrinsic requires an environment.
};
enum IntrinsicSideEffects {
@@ -4446,7 +4442,7 @@ class HInvoke : public HVariableInputSizeInstruction {
}
void SetIntrinsic(Intrinsics intrinsic,
- IntrinsicNeedsEnvironmentOrCache needs_env_or_cache,
+ IntrinsicNeedsEnvironment needs_env,
IntrinsicSideEffects side_effects,
IntrinsicExceptions exceptions);
@@ -4740,7 +4736,6 @@ class HInvokeStaticOrDirect final : public HInvoke {
MethodLoadKind GetMethodLoadKind() const { return dispatch_info_.method_load_kind; }
CodePtrLocation GetCodePtrLocation() const { return dispatch_info_.code_ptr_location; }
bool IsRecursive() const { return GetMethodLoadKind() == MethodLoadKind::kRecursive; }
- bool NeedsDexCacheOfDeclaringClass() const override;
bool IsStringInit() const { return GetMethodLoadKind() == MethodLoadKind::kStringInit; }
bool HasMethodAddress() const { return GetMethodLoadKind() == MethodLoadKind::kJitDirectAddress; }
bool HasPcRelativeMethodLoadKind() const {
@@ -4972,11 +4967,6 @@ class HInvokeInterface final : public HInvoke {
return (obj == InputAt(0)) && !IsIntrinsic();
}
- bool NeedsDexCacheOfDeclaringClass() const override {
- // The assembly stub currently needs it.
- return true;
- }
-
size_t GetSpecialInputIndex() const {
return GetNumberOfArguments();
}
@@ -6535,10 +6525,6 @@ class HLoadClass final : public HInstruction {
dex::TypeIndex GetTypeIndex() const { return type_index_; }
const DexFile& GetDexFile() const { return dex_file_; }
- bool NeedsDexCacheOfDeclaringClass() const override {
- return GetLoadKind() == LoadKind::kRuntimeCall;
- }
-
static SideEffects SideEffectsForArchRuntimeCalls() {
return SideEffects::CanTriggerGC();
}
@@ -6745,10 +6731,6 @@ class HLoadString final : public HInstruction {
return true;
}
- bool NeedsDexCacheOfDeclaringClass() const override {
- return GetLoadKind() == LoadKind::kRuntimeCall;
- }
-
bool CanBeNull() const override { return false; }
bool CanThrow() const override { return NeedsEnvironment(); }