mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Merge pull request #12691 from mitaclaw/jit-profiling-restoration
JitCache: Software Profiling Restoration
This commit is contained in:
@ -385,16 +385,9 @@ public final class NativeLibrary
|
||||
public static native boolean IsRunningAndUnpaused();
|
||||
|
||||
/**
|
||||
* Enables or disables CPU block profiling
|
||||
*
|
||||
* @param enable
|
||||
* Writes out the JitBlock Cache log dump
|
||||
*/
|
||||
public static native void SetProfiling(boolean enable);
|
||||
|
||||
/**
|
||||
* Writes out the block profile results
|
||||
*/
|
||||
public static native void WriteProfileResults();
|
||||
public static native void WriteJitBlockLogDump();
|
||||
|
||||
/**
|
||||
* Native EGL functions not exposed by Java bindings
|
||||
@ -454,6 +447,14 @@ public final class NativeLibrary
|
||||
|
||||
private static native String GetCurrentTitleDescriptionUnchecked();
|
||||
|
||||
@Keep
|
||||
public static void displayToastMsg(final String text, final boolean long_length)
|
||||
{
|
||||
final int length = long_length ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT;
|
||||
new Handler(Looper.getMainLooper())
|
||||
.post(() -> Toast.makeText(DolphinApplication.getAppContext(), text, length).show());
|
||||
}
|
||||
|
||||
@Keep
|
||||
public static boolean displayAlertMsg(final String caption, final String text,
|
||||
final boolean yesNo, final boolean isWarning, final boolean nonBlocking)
|
||||
@ -466,9 +467,7 @@ public final class NativeLibrary
|
||||
// and are allowed to block. As a fallback, we can use toasts.
|
||||
if (emulationActivity == null || nonBlocking)
|
||||
{
|
||||
new Handler(Looper.getMainLooper()).post(
|
||||
() -> Toast.makeText(DolphinApplication.getAppContext(), text, Toast.LENGTH_LONG)
|
||||
.show());
|
||||
displayToastMsg(text, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -214,6 +214,12 @@ enum class BooleanSetting(
|
||||
"JitRegisterCacheOff",
|
||||
false
|
||||
),
|
||||
MAIN_DEBUG_JIT_ENABLE_PROFILING(
|
||||
Settings.FILE_DOLPHIN,
|
||||
Settings.SECTION_DEBUG,
|
||||
"JitEnableProfiling",
|
||||
false
|
||||
),
|
||||
MAIN_EMULATE_SKYLANDER_PORTAL(
|
||||
Settings.FILE_DOLPHIN,
|
||||
Settings.SECTION_EMULATED_USB_DEVICES,
|
||||
|
@ -1978,6 +1978,26 @@ class SettingsFragmentPresenter(
|
||||
)
|
||||
)
|
||||
|
||||
sl.add(HeaderSetting(context, R.string.debug_jit_profiling_header, 0))
|
||||
sl.add(
|
||||
SwitchSetting(
|
||||
context,
|
||||
BooleanSetting.MAIN_DEBUG_JIT_ENABLE_PROFILING,
|
||||
R.string.debug_jit_enable_block_profiling,
|
||||
0
|
||||
)
|
||||
)
|
||||
sl.add(
|
||||
RunRunnable(
|
||||
context,
|
||||
R.string.debug_jit_write_block_log_dump,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
true
|
||||
) { NativeLibrary.WriteJitBlockLogDump() }
|
||||
)
|
||||
|
||||
sl.add(HeaderSetting(context, R.string.debug_jit_header, 0))
|
||||
sl.add(
|
||||
SwitchSetting(
|
||||
|
@ -406,6 +406,9 @@
|
||||
<string name="debug_fastmem">Disable Fastmem</string>
|
||||
<string name="debug_fastmem_arena">Disable Fastmem Arena</string>
|
||||
<string name="debug_large_entry_points_map">Disable Large Entry Points Map</string>
|
||||
<string name="debug_jit_profiling_header">Jit Profiling</string>
|
||||
<string name="debug_jit_enable_block_profiling">Enable Jit Block Profiling</string>
|
||||
<string name="debug_jit_write_block_log_dump">Write Jit Block Log Dump</string>
|
||||
<string name="debug_jit_header">Jit</string>
|
||||
<string name="debug_jitoff">Jit Disabled</string>
|
||||
<string name="debug_jitloadstoreoff">Jit Load Store Disabled</string>
|
||||
|
@ -12,6 +12,7 @@ static JavaVM* s_java_vm;
|
||||
static jclass s_string_class;
|
||||
|
||||
static jclass s_native_library_class;
|
||||
static jmethodID s_display_toast_msg;
|
||||
static jmethodID s_display_alert_msg;
|
||||
static jmethodID s_update_touch_pointer;
|
||||
static jmethodID s_on_title_changed;
|
||||
@ -146,6 +147,11 @@ jclass GetNativeLibraryClass()
|
||||
return s_native_library_class;
|
||||
}
|
||||
|
||||
jmethodID GetDisplayToastMsg()
|
||||
{
|
||||
return s_display_toast_msg;
|
||||
}
|
||||
|
||||
jmethodID GetDisplayAlertMsg()
|
||||
{
|
||||
return s_display_alert_msg;
|
||||
@ -528,6 +534,8 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
|
||||
|
||||
const jclass native_library_class = env->FindClass("org/dolphinemu/dolphinemu/NativeLibrary");
|
||||
s_native_library_class = reinterpret_cast<jclass>(env->NewGlobalRef(native_library_class));
|
||||
s_display_toast_msg =
|
||||
env->GetStaticMethodID(s_native_library_class, "displayToastMsg", "(Ljava/lang/String;Z)V");
|
||||
s_display_alert_msg = env->GetStaticMethodID(s_native_library_class, "displayAlertMsg",
|
||||
"(Ljava/lang/String;Ljava/lang/String;ZZZ)Z");
|
||||
s_update_touch_pointer =
|
||||
|
@ -12,6 +12,7 @@ JNIEnv* GetEnvForThread();
|
||||
jclass GetStringClass();
|
||||
|
||||
jclass GetNativeLibraryClass();
|
||||
jmethodID GetDisplayToastMsg();
|
||||
jmethodID GetDisplayAlertMsg();
|
||||
jmethodID GetUpdateTouchPointer();
|
||||
jmethodID GetOnTitleChanged();
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <android/native_window_jni.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <fmt/format.h>
|
||||
#include <jni.h>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
@ -22,6 +23,7 @@
|
||||
#include "Common/Event.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/Flag.h"
|
||||
#include "Common/IOFile.h"
|
||||
#include "Common/IniFile.h"
|
||||
#include "Common/Logging/LogManager.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
@ -42,7 +44,6 @@
|
||||
#include "Core/Host.h"
|
||||
#include "Core/PowerPC/JitInterface.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
#include "Core/PowerPC/Profiler.h"
|
||||
#include "Core/State.h"
|
||||
#include "Core/System.h"
|
||||
|
||||
@ -404,26 +405,34 @@ JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetMaxLogLev
|
||||
return static_cast<jint>(Common::Log::MAX_LOGLEVEL);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling(JNIEnv*, jclass,
|
||||
jboolean enable)
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteJitBlockLogDump(
|
||||
JNIEnv* env, jclass native_library_class)
|
||||
{
|
||||
HostThreadLock guard;
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& jit_interface = system.GetJitInterface();
|
||||
const Core::CPUThreadGuard cpu_guard(system);
|
||||
jit_interface.ClearCache(cpu_guard);
|
||||
jit_interface.SetProfilingState(enable ? JitInterface::ProfilingState::Enabled :
|
||||
JitInterface::ProfilingState::Disabled);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteProfileResults(JNIEnv*,
|
||||
jclass)
|
||||
{
|
||||
HostThreadLock guard;
|
||||
std::string filename = File::GetUserPath(D_DUMP_IDX) + "Debug/profiler.txt";
|
||||
File::CreateFullPath(filename);
|
||||
auto& jit_interface = Core::System::GetInstance().GetJitInterface();
|
||||
jit_interface.WriteProfileResults(filename);
|
||||
if (jit_interface.GetCore() == nullptr)
|
||||
{
|
||||
env->CallStaticVoidMethod(native_library_class, IDCache::GetDisplayToastMsg(),
|
||||
ToJString(env, Common::GetStringT("JIT is not active")),
|
||||
static_cast<jboolean>(false));
|
||||
return;
|
||||
}
|
||||
const std::string filename = fmt::format("{}{}.txt", File::GetUserPath(D_DUMPDEBUG_JITBLOCKS_IDX),
|
||||
SConfig::GetInstance().GetGameID());
|
||||
File::IOFile f(filename, "w");
|
||||
if (!f)
|
||||
{
|
||||
env->CallStaticVoidMethod(
|
||||
native_library_class, IDCache::GetDisplayToastMsg(),
|
||||
ToJString(env, Common::FmtFormatT("Failed to open \"{0}\" for writing.", filename)),
|
||||
static_cast<jboolean>(false));
|
||||
return;
|
||||
}
|
||||
jit_interface.JitBlockLogDump(Core::CPUThreadGuard{system}, f.GetHandle());
|
||||
env->CallStaticVoidMethod(native_library_class, IDCache::GetDisplayToastMsg(),
|
||||
ToJString(env, Common::FmtFormatT("Wrote to \"{0}\".", filename)),
|
||||
static_cast<jboolean>(false));
|
||||
}
|
||||
|
||||
// Surface Handling
|
||||
|
Reference in New Issue
Block a user