From a36dc19d9be8618a8a2927a3f59b3d0a8835b109 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sun, 10 May 2015 20:03:34 -0500 Subject: [PATCH] Add JNI interface for enabling writing block profile results. --- .../dolphinemu/dolphinemu/NativeLibrary.java | 11 +++++++++++ Source/Core/DolphinWX/MainAndroid.cpp | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java index e7d2e2b328..97d8c62301 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java @@ -202,6 +202,17 @@ public final class NativeLibrary /** Stops emulation. */ public static native void StopEmulation(); + /** + * Enables or disables CPU block profiling + * @param enable + */ + public static native void SetProfiling(boolean enable); + + /** + * Writes out the block profile results + */ + public static native void WriteProfileResults(); + /** Native EGL functions not exposed by Java bindings **/ public static native void eglBindAPI(int api); diff --git a/Source/Core/DolphinWX/MainAndroid.cpp b/Source/Core/DolphinWX/MainAndroid.cpp index 097ad732af..d3cdad82c6 100644 --- a/Source/Core/DolphinWX/MainAndroid.cpp +++ b/Source/Core/DolphinWX/MainAndroid.cpp @@ -35,7 +35,9 @@ #include "Core/Host.h" #include "Core/State.h" #include "Core/HW/Wiimote.h" +#include "Core/PowerPC/JitInterface.h" #include "Core/PowerPC/PowerPC.h" +#include "Core/PowerPC/Profiler.h" #include "DiscIO/VolumeCreator.h" @@ -345,6 +347,8 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_LoadState(JN JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_CreateUserFolders(JNIEnv *env, jobject obj); JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetUserDirectory(JNIEnv *env, jobject obj, jstring jDirectory); JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetUserDirectory(JNIEnv *env, jobject obj); +JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling(JNIEnv *env, jobject obj, jboolean enable); +JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteProfileResults(JNIEnv *env, jobject obj); JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run(JNIEnv *env, jobject obj, jobject _surf); JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_UnPauseEmulation(JNIEnv *env, jobject obj) @@ -520,6 +524,21 @@ JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetUserDi return env->NewStringUTF(File::GetUserPath(D_USER_IDX).c_str()); } +JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling(JNIEnv *env, jobject obj, jboolean enable) +{ + Core::SetState(Core::CORE_PAUSE); + JitInterface::ClearCache(); + Profiler::g_ProfileBlocks = enable; + Core::SetState(Core::CORE_RUN); +} + +JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteProfileResults(JNIEnv *env, jobject obj) +{ + std::string filename = File::GetUserPath(D_DUMP_IDX) + "Debug/profiler.txt"; + File::CreateFullPath(filename); + JitInterface::WriteProfileResults(filename); +} + JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run(JNIEnv *env, jobject obj, jobject _surf) { surf = ANativeWindow_fromSurface(env, _surf);