Merge "Revert "ART: Fix noreturn for Mac""
diff --git a/build/Android.common_build.mk b/build/Android.common_build.mk
index 8eeeec6..c60e75b 100644
--- a/build/Android.common_build.mk
+++ b/build/Android.common_build.mk
@@ -141,8 +141,14 @@
 # Enable warning for deprecated language features.
 art_clang_cflags += -Wdeprecated
 
-# Enable warning for unreachable break & return, and missing NO_RETURN annotations.
-art_clang_cflags += -Wunreachable-code-break -Wunreachable-code-return -Wmissing-noreturn
+# Enable warning for unreachable break & return.
+art_clang_cflags += -Wunreachable-code-break -Wunreachable-code-return
+
+# Enable missing-noreturn only on non-Mac. As lots of things are not implemented for Apple, it's
+# a pain.
+ifneq ($(HOST_OS),darwin)
+  art_clang_cflags += -Wmissing-noreturn
+endif
 
 
 # GCC-only warnings.
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk
index 6714480..0e2dad9 100644
--- a/build/Android.gtest.mk
+++ b/build/Android.gtest.mk
@@ -257,7 +257,7 @@
 LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.gtest.mk
 $(eval $(call set-target-local-clang-vars))
 $(eval $(call set-target-local-cflags-vars,debug))
-LOCAL_CLANG_CFLAGS += -Wno-used-but-marked-unused -Wno-deprecated  # gtest issue
+LOCAL_CLANG_CFLAGS += -Wno-used-but-marked-unused -Wno-deprecated -Wno-missing-noreturn # gtest issue
 include $(BUILD_SHARED_LIBRARY)
 
 include $(CLEAR_VARS)
@@ -272,7 +272,7 @@
 LOCAL_LDLIBS += -ldl -lpthread
 LOCAL_MULTILIB := both
 LOCAL_CLANG := $(ART_HOST_CLANG)
-LOCAL_CLANG_CFLAGS += -Wno-used-but-marked-unused -Wno-deprecated  # gtest issue
+LOCAL_CLANG_CFLAGS += -Wno-used-but-marked-unused -Wno-deprecated -Wno-missing-noreturn  # gtest issue
 LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk
 LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.gtest.mk
 include $(BUILD_HOST_SHARED_LIBRARY)
@@ -425,7 +425,7 @@
     LOCAL_MODULE_PATH_32 := $$(ART_TARGET_NATIVETEST_OUT)/$$(ART_TARGET_ARCH_32)
     LOCAL_MODULE_PATH_64 := $$(ART_TARGET_NATIVETEST_OUT)/$$(ART_TARGET_ARCH_64)
     LOCAL_MULTILIB := both
-    LOCAL_CLANG_CFLAGS += -Wno-used-but-marked-unused -Wno-deprecated  # gtest issue
+    LOCAL_CLANG_CFLAGS += -Wno-used-but-marked-unused -Wno-deprecated -Wno-missing-noreturn  # gtest issue
     include $$(BUILD_EXECUTABLE)
     library_path :=
     2nd_library_path :=
@@ -464,7 +464,7 @@
     LOCAL_MULTILIB := both
     LOCAL_MODULE_STEM_32 := $$(art_gtest_name)32
     LOCAL_MODULE_STEM_64 := $$(art_gtest_name)64
-    LOCAL_CLANG_CFLAGS += -Wno-used-but-marked-unused -Wno-deprecated  # gtest issue
+    LOCAL_CLANG_CFLAGS += -Wno-used-but-marked-unused -Wno-deprecated -Wno-missing-noreturn  # gtest issue
     include $$(BUILD_HOST_EXECUTABLE)
 
     ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index f52f50e..f6b217a 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -350,6 +350,7 @@
       verification_results_(verification_results),
       method_inliner_map_(method_inliner_map),
       compiler_(Compiler::Create(this, compiler_kind)),
+      compiler_kind_(compiler_kind),
       instruction_set_(instruction_set),
       instruction_set_features_(instruction_set_features),
       freezing_constructor_lock_("freezing constructor lock"),
@@ -2214,10 +2215,8 @@
         InstructionSetHasGenericJniStub(instruction_set_)) {
       // Leaving this empty will trigger the generic JNI version
     } else {
-      if (instruction_set_ != kMips64) {  // Use generic JNI for Mips64 (temporarily).
-        compiled_method = compiler_->JniCompile(access_flags, method_idx, dex_file);
-        CHECK(compiled_method != nullptr);
-      }
+      compiled_method = compiler_->JniCompile(access_flags, method_idx, dex_file);
+      CHECK(compiled_method != nullptr);
     }
   } else if ((access_flags & kAccAbstract) != 0) {
     // Abstract methods don't have code.
@@ -2272,8 +2271,11 @@
     DCHECK(GetCompiledMethod(method_ref) != nullptr) << PrettyMethod(method_idx, dex_file);
   }
 
-  // Done compiling, delete the verified method to reduce native memory usage.
-  verification_results_->RemoveVerifiedMethod(method_ref);
+  // Done compiling, delete the verified method to reduce native memory usage. Do not delete in
+  // optimizing compiler, which may need the verified method again for inlining.
+  if (compiler_kind_ != Compiler::kOptimizing) {
+    verification_results_->RemoveVerifiedMethod(method_ref);
+  }
 
   if (self->IsExceptionPending()) {
     ScopedObjectAccess soa(self);
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index efcaae4..edd1bd2 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -557,6 +557,7 @@
   DexFileToMethodInlinerMap* const method_inliner_map_;
 
   std::unique_ptr<Compiler> compiler_;
+  Compiler::Kind compiler_kind_;
 
   const InstructionSet instruction_set_;
   const InstructionSetFeatures* const instruction_set_features_;
diff --git a/compiler/jni/quick/mips64/calling_convention_mips64.cc b/compiler/jni/quick/mips64/calling_convention_mips64.cc
index 17325d6..d446867 100644
--- a/compiler/jni/quick/mips64/calling_convention_mips64.cc
+++ b/compiler/jni/quick/mips64/calling_convention_mips64.cc
@@ -126,25 +126,20 @@
 Mips64JniCallingConvention::Mips64JniCallingConvention(bool is_static, bool is_synchronized,
                                                        const char* shorty)
     : JniCallingConvention(is_static, is_synchronized, shorty, kFramePointerSize) {
-  callee_save_regs_.push_back(Mips64ManagedRegister::FromGpuRegister(S0));
-  callee_save_regs_.push_back(Mips64ManagedRegister::FromGpuRegister(S1));
   callee_save_regs_.push_back(Mips64ManagedRegister::FromGpuRegister(S2));
   callee_save_regs_.push_back(Mips64ManagedRegister::FromGpuRegister(S3));
   callee_save_regs_.push_back(Mips64ManagedRegister::FromGpuRegister(S4));
   callee_save_regs_.push_back(Mips64ManagedRegister::FromGpuRegister(S5));
   callee_save_regs_.push_back(Mips64ManagedRegister::FromGpuRegister(S6));
   callee_save_regs_.push_back(Mips64ManagedRegister::FromGpuRegister(S7));
-
   callee_save_regs_.push_back(Mips64ManagedRegister::FromGpuRegister(GP));
-  callee_save_regs_.push_back(Mips64ManagedRegister::FromGpuRegister(SP));
   callee_save_regs_.push_back(Mips64ManagedRegister::FromGpuRegister(S8));
 }
 
 uint32_t Mips64JniCallingConvention::CoreSpillMask() const {
   // Compute spill mask to agree with callee saves initialized in the constructor
   uint32_t result = 0;
-  result = 1 << S0 | 1 << S1 | 1 << S2 | 1 << S3 | 1 << S4 | 1 << S5 | 1 << S6 |
-           1 << S7 | 1 << GP | 1 << SP | 1 << S8;
+  result = 1 << S2 | 1 << S3 | 1 << S4 | 1 << S5 | 1 << S6 | 1 << S7 | 1 << GP | 1 << S8 | 1 << RA;
   return result;
 }
 
diff --git a/compiler/utils/mips64/assembler_mips64.cc b/compiler/utils/mips64/assembler_mips64.cc
index 233ae7d..388d274 100644
--- a/compiler/utils/mips64/assembler_mips64.cc
+++ b/compiler/utils/mips64/assembler_mips64.cc
@@ -1025,7 +1025,7 @@
   __ Move(A0, scratch_.AsGpuRegister());
   // Set up call to Thread::Current()->pDeliverException
   __ LoadFromOffset(kLoadDoubleword, T9, S1,
-                    QUICK_ENTRYPOINT_OFFSET(4, pDeliverException).Int32Value());
+                    QUICK_ENTRYPOINT_OFFSET(8, pDeliverException).Int32Value());
   __ Jr(T9);
   // Call never returns
   __ Break();
diff --git a/runtime/arch/instruction_set_features.cc b/runtime/arch/instruction_set_features.cc
index db4b0b1..898f83a 100644
--- a/runtime/arch/instruction_set_features.cc
+++ b/runtime/arch/instruction_set_features.cc
@@ -288,10 +288,10 @@
   return down_cast<const X86_64InstructionSetFeatures*>(this);
 }
 
-bool InstructionSetFeatures::FindVariantInArray(const char* variants[], size_t num_variants,
+bool InstructionSetFeatures::FindVariantInArray(const char* const variants[], size_t num_variants,
                                                 const std::string& variant) {
-  const char** begin = variants;
-  const char** end = begin + num_variants;
+  const char* const * begin = variants;
+  const char* const * end = begin + num_variants;
   return std::find(begin, end, variant) != end;
 }
 
diff --git a/runtime/arch/instruction_set_features.h b/runtime/arch/instruction_set_features.h
index e4513ef..d10ae21 100644
--- a/runtime/arch/instruction_set_features.h
+++ b/runtime/arch/instruction_set_features.h
@@ -103,7 +103,7 @@
   explicit InstructionSetFeatures(bool smp) : smp_(smp) {}
 
   // Returns true if variant appears in the array variants.
-  static bool FindVariantInArray(const char* variants[], size_t num_variants,
+  static bool FindVariantInArray(const char* const variants[], size_t num_variants,
                                  const std::string& variant);
 
   // Add architecture specific features in sub-classes.
diff --git a/runtime/arch/mips64/jni_entrypoints_mips64.S b/runtime/arch/mips64/jni_entrypoints_mips64.S
index 90fd3ee..1085666 100644
--- a/runtime/arch/mips64/jni_entrypoints_mips64.S
+++ b/runtime/arch/mips64/jni_entrypoints_mips64.S
@@ -28,21 +28,21 @@
     .cfi_adjust_cfa_offset 80
     sd     $ra, 64($sp)
     .cfi_rel_offset 31, 64
-    sw     $a7, 56($sp)
+    sd     $a7, 56($sp)
     .cfi_rel_offset 11, 56
-    sw     $a6, 48($sp)
+    sd     $a6, 48($sp)
     .cfi_rel_offset 10, 48
-    sw     $a5, 40($sp)
+    sd     $a5, 40($sp)
     .cfi_rel_offset 9, 40
-    sw     $a4, 32($sp)
+    sd     $a4, 32($sp)
     .cfi_rel_offset 8, 32
-    sw     $a3, 24($sp)
+    sd     $a3, 24($sp)
     .cfi_rel_offset 7, 24
-    sw     $a2, 16($sp)
+    sd     $a2, 16($sp)
     .cfi_rel_offset 6, 16
-    sw     $a1, 8($sp)
+    sd     $a1, 8($sp)
     .cfi_rel_offset 5, 8
-    sw     $a0, 0($sp)
+    sd     $a0, 0($sp)
     .cfi_rel_offset 4, 0
     jal    artFindNativeMethod  # (Thread*)
     move   $a0, $s1             # pass Thread::Current()
diff --git a/runtime/arch/x86/instruction_set_features_x86.cc b/runtime/arch/x86/instruction_set_features_x86.cc
index 782ee00..8227633 100644
--- a/runtime/arch/x86/instruction_set_features_x86.cc
+++ b/runtime/arch/x86/instruction_set_features_x86.cc
@@ -25,20 +25,43 @@
 
 namespace art {
 
+// Feature-support arrays.
+
+static constexpr const char* x86_known_variants[] = {
+    "atom",
+    "silvermont",
+};
+
+static constexpr const char* x86_variants_with_ssse3[] = {
+    "atom",
+    "silvermont",
+};
+
+static constexpr const char* x86_variants_with_sse4_1[] = {
+    "silvermont",
+};
+
+static constexpr const char* x86_variants_with_sse4_2[] = {
+    "silvermont",
+};
+
 const X86InstructionSetFeatures* X86InstructionSetFeatures::FromVariant(
     const std::string& variant, std::string* error_msg ATTRIBUTE_UNUSED,
     bool x86_64) {
-  bool known_variant = false;
   bool smp = true;  // Conservative default.
-  static const char* x86_variants_with_ssse3[] = {
-      "atom"
-  };
   bool has_SSSE3 = FindVariantInArray(x86_variants_with_ssse3, arraysize(x86_variants_with_ssse3),
                                       variant);
-  bool has_SSE4_1 = false;
-  bool has_SSE4_2 = false;
+  bool has_SSE4_1 = FindVariantInArray(x86_variants_with_sse4_1,
+                                       arraysize(x86_variants_with_sse4_1),
+                                       variant);
+  bool has_SSE4_2 = FindVariantInArray(x86_variants_with_sse4_2,
+                                       arraysize(x86_variants_with_sse4_2),
+                                       variant);
   bool has_AVX = false;
   bool has_AVX2 = false;
+
+  bool known_variant = FindVariantInArray(x86_known_variants, arraysize(x86_known_variants),
+                                          variant);
   if (!known_variant && variant != "default") {
     std::ostringstream os;
     LOG(WARNING) << "Unexpected CPU variant for X86 using defaults: " << variant;
diff --git a/runtime/arch/x86/instruction_set_features_x86_test.cc b/runtime/arch/x86/instruction_set_features_x86_test.cc
index d231beb..25a406b 100644
--- a/runtime/arch/x86/instruction_set_features_x86_test.cc
+++ b/runtime/arch/x86/instruction_set_features_x86_test.cc
@@ -67,4 +67,40 @@
   EXPECT_FALSE(x86_features->Equals(x86_default_features.get()));
 }
 
+TEST(X86InstructionSetFeaturesTest, X86FeaturesFromSilvermontVariant) {
+  // Build features for a 32-bit x86 silvermont processor.
+  std::string error_msg;
+  std::unique_ptr<const InstructionSetFeatures> x86_features(
+      InstructionSetFeatures::FromVariant(kX86, "silvermont", &error_msg));
+  ASSERT_TRUE(x86_features.get() != nullptr) << error_msg;
+  EXPECT_EQ(x86_features->GetInstructionSet(), kX86);
+  EXPECT_TRUE(x86_features->Equals(x86_features.get()));
+  EXPECT_STREQ("smp,ssse3,sse4.1,sse4.2,-avx,-avx2", x86_features->GetFeatureString().c_str());
+  EXPECT_EQ(x86_features->AsBitmap(), 15U);
+
+  // Build features for a 32-bit x86 default processor.
+  std::unique_ptr<const InstructionSetFeatures> x86_default_features(
+      InstructionSetFeatures::FromVariant(kX86, "default", &error_msg));
+  ASSERT_TRUE(x86_default_features.get() != nullptr) << error_msg;
+  EXPECT_EQ(x86_default_features->GetInstructionSet(), kX86);
+  EXPECT_TRUE(x86_default_features->Equals(x86_default_features.get()));
+  EXPECT_STREQ("smp,-ssse3,-sse4.1,-sse4.2,-avx,-avx2",
+               x86_default_features->GetFeatureString().c_str());
+  EXPECT_EQ(x86_default_features->AsBitmap(), 1U);
+
+  // Build features for a 64-bit x86-64 silvermont processor.
+  std::unique_ptr<const InstructionSetFeatures> x86_64_features(
+      InstructionSetFeatures::FromVariant(kX86_64, "silvermont", &error_msg));
+  ASSERT_TRUE(x86_64_features.get() != nullptr) << error_msg;
+  EXPECT_EQ(x86_64_features->GetInstructionSet(), kX86_64);
+  EXPECT_TRUE(x86_64_features->Equals(x86_64_features.get()));
+  EXPECT_STREQ("smp,ssse3,sse4.1,sse4.2,-avx,-avx2",
+               x86_64_features->GetFeatureString().c_str());
+  EXPECT_EQ(x86_64_features->AsBitmap(), 15U);
+
+  EXPECT_FALSE(x86_64_features->Equals(x86_features.get()));
+  EXPECT_FALSE(x86_64_features->Equals(x86_default_features.get()));
+  EXPECT_FALSE(x86_features->Equals(x86_default_features.get()));
+}
+
 }  // namespace art
diff --git a/runtime/gc/collector/concurrent_copying.cc b/runtime/gc/collector/concurrent_copying.cc
index 8aa1b52..19d4e1a 100644
--- a/runtime/gc/collector/concurrent_copying.cc
+++ b/runtime/gc/collector/concurrent_copying.cc
@@ -83,6 +83,9 @@
       LOG(INFO) << "Verifying no from-space refs";
     }
     VerifyNoFromSpaceReferences();
+    if (kVerboseMode) {
+      LOG(INFO) << "Done verifying no from-space refs";
+    }
     CheckEmptyMarkQueue();
   }
   {