Force save profiles for SIGUSR1

Force save profiles from signal catcher for SIGUSR1. Saving the
profiles is expensive but we already do a GC which is also expensive
for this signal.

Test: adb shell ls -l /data/misc/profiles/cur/1000/system_server/
Test: adb shell kill -s SIGUSR1 `pid system_server`
Test: adb shell ls -l /data/misc/profiles/cur/1000/system_server/

Bug: 36457259
Bug: 34927277

(cherry picked from commit 8f23d97af3b10ae56fb16d63fd2932098dac45c0)

Change-Id: I810b66a7fe4b06efc7468d65ac737d74c5669abe
diff --git a/runtime/jit/profile_saver.h b/runtime/jit/profile_saver.h
index 4dd8e60..be2bffc 100644
--- a/runtime/jit/profile_saver.h
+++ b/runtime/jit/profile_saver.h
@@ -52,8 +52,10 @@
       REQUIRES(!Locks::profiler_lock_, !wait_lock_)
       NO_THREAD_SAFETY_ANALYSIS;
 
-  // Just for testing purpose.
+  // For testing or manual purposes (SIGUSR1).
   static void ForceProcessProfiles();
+
+  // Just for testing purpose.
   static bool HasSeenMethod(const std::string& profile,
                             const DexFile* dex_file,
                             uint16_t method_idx);
diff --git a/runtime/signal_catcher.cc b/runtime/signal_catcher.cc
index 674459d..0b7ea2f 100644
--- a/runtime/signal_catcher.cc
+++ b/runtime/signal_catcher.cc
@@ -32,6 +32,7 @@
 #include "base/unix_file/fd_file.h"
 #include "class_linker.h"
 #include "gc/heap.h"
+#include "jit/profile_saver.h"
 #include "os.h"
 #include "runtime.h"
 #include "scoped_thread_state_change-inl.h"
@@ -154,8 +155,9 @@
 }
 
 void SignalCatcher::HandleSigUsr1() {
-  LOG(INFO) << "SIGUSR1 forcing GC (no HPROF)";
+  LOG(INFO) << "SIGUSR1 forcing GC (no HPROF) and profile save";
   Runtime::Current()->GetHeap()->CollectGarbage(false);
+  ProfileSaver::ForceProcessProfiles();
 }
 
 int SignalCatcher::WaitForSignal(Thread* self, SignalSet& signals) {