OSDN Git Service

Revert "Fallback to quick in case of soft verification errors"
authorCalin Juravle <calin@google.com>
Mon, 13 Apr 2015 14:25:53 +0000 (14:25 +0000)
committerCalin Juravle <calin@google.com>
Mon, 13 Apr 2015 14:25:53 +0000 (14:25 +0000)
This reverts commit c751d37e692d89b360f3c09421401f581b5c6d06.

Change-Id: I2183df8e856410989bc019f6a1f58af37d5d7eab

compiler/dex/verified_method.cc
compiler/dex/verified_method.h
compiler/driver/compiler_driver.cc
compiler/driver/compiler_driver.h
compiler/optimizing/inliner.cc
compiler/optimizing/optimizing_compiler.cc
compiler/optimizing/optimizing_compiler_stats.h
test/471-uninitialized-locals/expected.txt [deleted file]
test/471-uninitialized-locals/info.txt [deleted file]
test/471-uninitialized-locals/smali/Test.smali [deleted file]
test/471-uninitialized-locals/src/Main.java [deleted file]

index 7746221..5b90ba9 100644 (file)
@@ -40,7 +40,6 @@ namespace art {
 const VerifiedMethod* VerifiedMethod::Create(verifier::MethodVerifier* method_verifier,
                                              bool compile) {
   std::unique_ptr<VerifiedMethod> verified_method(new VerifiedMethod);
-  verified_method->has_verification_failures_ = method_verifier->HasFailures();
   if (compile) {
     /* Generate a register map. */
     if (!verified_method->GenerateGcMap(method_verifier)) {
index 437ae52..954cbf4 100644 (file)
@@ -70,11 +70,6 @@ class VerifiedMethod {
   // by using the check-cast elision peephole optimization in the verifier.
   bool IsSafeCast(uint32_t pc) const;
 
-  // Returns true if there were any errors during verification.
-  bool HasVerificationFailures() const {
-    return has_verification_failures_;
-  }
-
  private:
   VerifiedMethod() = default;
 
@@ -112,8 +107,6 @@ class VerifiedMethod {
   // dex PC to dex method index or dex field index based on the instruction.
   DequickenMap dequicken_map_;
   SafeCastSet safe_cast_set_;
-
-  bool has_verification_failures_;
 };
 
 }  // namespace art
index 1698464..c2b8375 100644 (file)
@@ -2345,13 +2345,6 @@ CompiledMethod* CompilerDriver::GetCompiledMethod(MethodReference ref) const {
   return it->second;
 }
 
-bool CompilerDriver::IsMethodVerifiedWithoutFailures(uint32_t method_idx,
-                                                     const DexFile& dex_file) const {
-  MethodReference method_ref(&dex_file, method_idx);
-  const VerifiedMethod* verified_method = GetVerificationResults()->GetVerifiedMethod(method_ref);
-  return (verified_method != nullptr) && !verified_method->HasVerificationFailures();
-}
-
 size_t CompilerDriver::GetNonRelativeLinkerPatchCount() const {
   MutexLock mu(Thread::Current(), compiled_methods_lock_);
   return non_relative_linker_patch_count_;
index b3ca25b..a6ed559 100644 (file)
@@ -425,10 +425,6 @@ class CompilerDriver {
   void RecordClassStatus(ClassReference ref, mirror::Class::Status status)
       LOCKS_EXCLUDED(compiled_classes_lock_);
 
-  // Checks if the specified method has been verified without failures. Returns
-  // false if the method is not in the verification results (GetVerificationResults).
-  bool IsMethodVerifiedWithoutFailures(uint32_t method_idx, const DexFile& dex_file) const;
-
   SwapVector<uint8_t>* DeduplicateCode(const ArrayRef<const uint8_t>& code);
   SwapSrcMap* DeduplicateSrcMappingTable(const ArrayRef<SrcMapElem>& src_map);
   SwapVector<uint8_t>* DeduplicateMappingTable(const ArrayRef<const uint8_t>& code);
index 65f1ed2..2c17a67 100644 (file)
@@ -31,8 +31,6 @@
 #include "ssa_phi_elimination.h"
 #include "scoped_thread_state_change.h"
 #include "thread.h"
-#include "dex/verified_method.h"
-#include "dex/verification_results.h"
 
 namespace art {
 
@@ -116,10 +114,9 @@ bool HInliner::TryInline(HInvoke* invoke_instruction,
     return false;
   }
 
-  if (compiler_driver_->IsMethodVerifiedWithoutFailures(
-        method_index, *resolved_method->GetDexFile())) {
+  if (!resolved_method->GetDeclaringClass()->IsVerified()) {
     VLOG(compiler) << "Method " << PrettyMethod(method_index, caller_dex_file)
-                   << " has verification failures, so it cannot be inlined";
+                   << " is not inlined because its class could not be verified";
     return false;
   }
 
index 4f58462..0e02212 100644 (file)
@@ -31,8 +31,6 @@
 #include "constant_folding.h"
 #include "dead_code_elimination.h"
 #include "dex/quick/dex_file_to_method_inliner_map.h"
-#include "dex/verified_method.h"
-#include "dex/verification_results.h"
 #include "driver/compiler_driver.h"
 #include "driver/compiler_options.h"
 #include "driver/dex_compilation_unit.h"
 #include "mirror/art_method-inl.h"
 #include "nodes.h"
 #include "prepare_for_register_allocation.h"
-#include "reference_type_propagation.h"
 #include "register_allocator.h"
 #include "side_effects_analysis.h"
 #include "ssa_builder.h"
 #include "ssa_phi_elimination.h"
 #include "ssa_liveness_analysis.h"
 #include "utils/assembler.h"
+#include "reference_type_propagation.h"
 
 namespace art {
 
@@ -608,26 +606,15 @@ CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item,
                                             InvokeType invoke_type,
                                             uint16_t class_def_idx,
                                             uint32_t method_idx,
-                                            jobject jclass_loader,
+                                            jobject class_loader,
                                             const DexFile& dex_file) const {
-  CompilerDriver* compiler_driver = GetCompilerDriver();
-  CompiledMethod* method = nullptr;
-  if (compiler_driver->IsMethodVerifiedWithoutFailures(method_idx, dex_file)) {
-     method = TryCompile(code_item, access_flags, invoke_type, class_def_idx,
-                         method_idx, jclass_loader, dex_file);
-  } else {
-    if (compiler_driver->GetCompilerOptions().VerifyAtRuntime()) {
-      compilation_stats_.RecordStat(MethodCompilationStat::kNotCompiledVerifyAtRuntime);
-    } else {
-      compilation_stats_.RecordStat(MethodCompilationStat::kNotCompiledClassNotVerified);
-    }
-  }
-
+  CompiledMethod* method = TryCompile(code_item, access_flags, invoke_type, class_def_idx,
+                                      method_idx, class_loader, dex_file);
   if (method != nullptr) {
     return method;
   }
   method = delegate_->Compile(code_item, access_flags, invoke_type, class_def_idx, method_idx,
-                              jclass_loader, dex_file);
+                              class_loader, dex_file);
 
   if (method != nullptr) {
     compilation_stats_.RecordStat(MethodCompilationStat::kCompiledQuick);
index d4a936d..4d5b8d0 100644 (file)
@@ -45,8 +45,6 @@ enum MethodCompilationStat {
   kNotCompiledCantAccesType,
   kNotOptimizedRegisterAllocator,
   kNotCompiledUnhandledInstruction,
-  kNotCompiledVerifyAtRuntime,
-  kNotCompiledClassNotVerified,
   kRemovedCheckedCast,
   kRemovedNullCheck,
   kInstructionSimplifications,
@@ -111,8 +109,6 @@ class OptimizingCompilerStats {
       case kNotCompiledSpaceFilter : return "kNotCompiledSpaceFilter";
       case kNotOptimizedRegisterAllocator : return "kNotOptimizedRegisterAllocator";
       case kNotCompiledUnhandledInstruction : return "kNotCompiledUnhandledInstruction";
-      case kNotCompiledVerifyAtRuntime : return "kNotCompiledVerifyAtRuntime";
-      case kNotCompiledClassNotVerified : return "kNotCompiledClassNotVerified";
       case kRemovedCheckedCast: return "kRemovedCheckedCast";
       case kRemovedNullCheck: return "kRemovedNullCheck";
       case kInstructionSimplifications: return "kInstructionSimplifications";
diff --git a/test/471-uninitialized-locals/expected.txt b/test/471-uninitialized-locals/expected.txt
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/test/471-uninitialized-locals/info.txt b/test/471-uninitialized-locals/info.txt
deleted file mode 100644 (file)
index ebead8e..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Regression for the optimizing for crashes during compilation of methods which
-use values before initializing them.
diff --git a/test/471-uninitialized-locals/smali/Test.smali b/test/471-uninitialized-locals/smali/Test.smali
deleted file mode 100644 (file)
index 17a14bf..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# 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 public LTest;
-
-.super Ljava/lang/Object;
-
-.method public static ThrowException()V
-   .registers 1
-   throw v0
-.end method
diff --git a/test/471-uninitialized-locals/src/Main.java b/test/471-uninitialized-locals/src/Main.java
deleted file mode 100644 (file)
index b24c518..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.
- */
-
-import java.lang.reflect.Method;
-
-public class Main {
-
-  public static void main(String args[]) throws Exception {
-    // Workaround for b/18051191.
-    System.out.println("Test started");
-    try {
-      Class<?> c = Class.forName("Test");
-      Method m = c.getMethod("ThrowException", (Class[]) null);
-      m.invoke(null, (Object[]) null);
-    } catch (VerifyError e) {
-       // Compilation should go fine but we expect the runtime verification to fail.
-      return;
-    }
-
-    throw new Error("Failed to preset verification error!");
-  }
-
-}