mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
[Common/Core/HLE] Object out of scope optimization for better codegeneration (lower level scope)
This commit is contained in:
parent
bbcaeb9d13
commit
2a31f8c6c0
18 changed files with 43 additions and 37 deletions
|
@ -7,7 +7,6 @@
|
|||
|
||||
// Not strictly a parser...
|
||||
void NiceSizeFormat(uint64_t size, char *out, size_t bufSize) {
|
||||
const char *sizes[] = { "B","KB","MB","GB","TB","PB","EB" };
|
||||
int s = 0;
|
||||
int frac = 0;
|
||||
while (size >= 1024) {
|
||||
|
@ -18,8 +17,10 @@ void NiceSizeFormat(uint64_t size, char *out, size_t bufSize) {
|
|||
float f = (float)size + ((float)frac / 1024.0f);
|
||||
if (s == 0)
|
||||
snprintf(out, bufSize, "%d B", (int)size);
|
||||
else
|
||||
else {
|
||||
const char* sizes[] = { "B","KB","MB","GB","TB","PB","EB" };
|
||||
snprintf(out, bufSize, "%3.2f %s", f, sizes[s]);
|
||||
}
|
||||
}
|
||||
|
||||
std::string NiceSizeFormat(uint64_t size) {
|
||||
|
|
|
@ -519,8 +519,8 @@ bool CreateDir(const Path &path) {
|
|||
// Convert it to a "CreateDirIn" call, if possible, since that's
|
||||
// what we can do with the storage API.
|
||||
AndroidContentURI uri(path.ToString());
|
||||
std::string newDirName = uri.GetLastPart();
|
||||
if (uri.NavigateUp()) {
|
||||
std::string newDirName = uri.GetLastPart();
|
||||
INFO_LOG(COMMON, "Calling Android_CreateDirectory(%s, %s)", uri.ToString().c_str(), newDirName.c_str());
|
||||
return Android_CreateDirectory(uri.ToString(), newDirName) == StorageError::SUCCESS;
|
||||
} else {
|
||||
|
|
|
@ -35,9 +35,9 @@ bool LoadRemoteFileList(const Path &url, const std::string &userAgent, bool *can
|
|||
}
|
||||
|
||||
// Start by requesting the list of files from the server.
|
||||
http::RequestParams req(baseURL.Resource(), "text/plain, text/html; q=0.9, */*; q=0.8");
|
||||
if (http.Resolve(baseURL.Host().c_str(), baseURL.Port())) {
|
||||
if (http.Connect(2, 20.0, cancel)) {
|
||||
http::RequestParams req(baseURL.Resource(), "text/plain, text/html; q=0.9, */*; q=0.8");
|
||||
net::RequestProgress progress(cancel);
|
||||
code = http.GET(req, &result, responseHeaders, &progress);
|
||||
http.Disconnect();
|
||||
|
|
|
@ -159,10 +159,10 @@ std::string GetWindowsVersion() {
|
|||
|
||||
// Start from higher to lower
|
||||
for (auto release = rbegin(windowsReleases); release != rend(windowsReleases); ++release) {
|
||||
std::string previewText = release->first;
|
||||
WindowsReleaseInfo releaseInfo = release->second;
|
||||
bool buildMatch = DoesVersionMatchWindows(releaseInfo);
|
||||
if (buildMatch) {
|
||||
std::string previewText = release->first;
|
||||
return previewText;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -333,7 +333,6 @@ void SliderPopupScreen::UpdateTextBox() {
|
|||
void SliderPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
using namespace UI;
|
||||
UIContext &dc = *screenManager()->getUIContext();
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
|
||||
sliderValue_ = *value_;
|
||||
if (disabled_ && sliderValue_ < 0)
|
||||
|
@ -362,6 +361,7 @@ void SliderPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
|||
lin->Add(new TextView(units_))->SetTextColor(dc.theme->itemStyle.fgColor);
|
||||
|
||||
if (defaultValue_ != NO_DEFAULT_FLOAT) {
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
lin->Add(new Button(di->T("Reset")))->OnClick.Add([=](UI::EventParams &) {
|
||||
sliderValue_ = defaultValue_;
|
||||
changing_ = true;
|
||||
|
@ -381,7 +381,6 @@ void SliderPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
|||
void SliderFloatPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
using namespace UI;
|
||||
UIContext &dc = *screenManager()->getUIContext();
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
|
||||
sliderValue_ = *value_;
|
||||
LinearLayout *vert = parent->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(UI::Margins(10, 10))));
|
||||
|
@ -406,6 +405,7 @@ void SliderFloatPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
|||
lin->Add(new TextView(units_))->SetTextColor(dc.theme->itemStyle.fgColor);
|
||||
|
||||
if (defaultValue_ != NO_DEFAULT_FLOAT) {
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
lin->Add(new Button(di->T("Reset")))->OnClick.Add([=](UI::EventParams &) {
|
||||
sliderValue_ = defaultValue_;
|
||||
if (liveUpdate_) {
|
||||
|
|
|
@ -421,8 +421,8 @@ void PopupScreen::CreateViews() {
|
|||
box_->SetDropShadowExpand(std::max(g_display.dp_xres, g_display.dp_yres));
|
||||
box_->SetSpacing(0.0f);
|
||||
|
||||
View *title = new PopupHeader(title_);
|
||||
if (HasTitleBar()) {
|
||||
View* title = new PopupHeader(title_);
|
||||
box_->Add(title);
|
||||
}
|
||||
|
||||
|
|
|
@ -239,7 +239,6 @@ int PSPNetconfDialog::Update(int animSpeed) {
|
|||
UpdateButtons();
|
||||
UpdateCommon();
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
auto err = GetI18NCategory(I18NCat::ERRORS);
|
||||
u64 now = (u64)(time_now_d() * 1000000.0);
|
||||
|
||||
// It seems JPCSP doesn't check for NETCONF_STATUS_APNET
|
||||
|
@ -250,6 +249,7 @@ int PSPNetconfDialog::Update(int animSpeed) {
|
|||
StartDraw();
|
||||
|
||||
if (!hideNotice) {
|
||||
auto err = GetI18NCategory(I18NCat::ERRORS);
|
||||
const float WRAP_WIDTH = 254.0f;
|
||||
const int confirmBtn = GetConfirmButton();
|
||||
const int cancelBtn = GetCancelButton();
|
||||
|
|
|
@ -235,11 +235,11 @@ int PSPNpSigninDialog::Update(int animSpeed) {
|
|||
|
||||
UpdateButtons();
|
||||
UpdateCommon();
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
auto err = GetI18NCategory(I18NCat::ERRORS);
|
||||
u64 now = (u64)(time_now_d() * 1000000.0);
|
||||
|
||||
if (request.npSigninStatus == NP_SIGNIN_STATUS_NONE) {
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
UpdateFade(animSpeed);
|
||||
StartDraw();
|
||||
|
||||
|
|
|
@ -1391,10 +1391,10 @@ bool SavedataParam::GetSize(SceUtilitySavedataParam *param)
|
|||
|
||||
const std::string saveDir = savePath + GetGameName(param) + GetSaveName(param);
|
||||
bool exists = false;
|
||||
auto listing = pspFileSystem.GetDirListing(saveDir, &exists);
|
||||
|
||||
if (param->sizeInfo.IsValid())
|
||||
{
|
||||
auto listing = pspFileSystem.GetDirListing(saveDir, &exists);
|
||||
const u64 freeBytes = MemoryStick_FreeSpace();
|
||||
|
||||
s64 overwriteBytes = 0;
|
||||
|
|
|
@ -66,8 +66,8 @@ BlockDevice *constructBlockDevice(FileLoader *fileLoader) {
|
|||
}
|
||||
|
||||
void BlockDevice::NotifyReadError() {
|
||||
auto err = GetI18NCategory(I18NCat::ERRORS);
|
||||
if (!reportedError_) {
|
||||
auto err = GetI18NCategory(I18NCat::ERRORS);
|
||||
g_OSD.Show(OSDType::MESSAGE_WARNING, err->T("Game disc read error - ISO corrupt"), fileLoader_->GetPath().ToVisualString(), 6.0f);
|
||||
reportedError_ = true;
|
||||
}
|
||||
|
|
|
@ -180,8 +180,6 @@ bool Load() {
|
|||
auto sy = GetI18NCategory(I18NCat::SYSTEM);
|
||||
|
||||
for (const std::string &filename : prxPlugins) {
|
||||
std::string shortName = Path(filename).GetFilename();
|
||||
|
||||
std::string error_string = "";
|
||||
SceUID module = KernelLoadModule(filename, &error_string);
|
||||
if (!error_string.empty() || module < 0) {
|
||||
|
@ -193,6 +191,7 @@ bool Load() {
|
|||
if (ret < 0) {
|
||||
ERROR_LOG(SYSTEM, "Unable to start plugin %s: %08x", filename.c_str(), ret);
|
||||
} else {
|
||||
std::string shortName = Path(filename).GetFilename();
|
||||
g_OSD.Show(OSDType::MESSAGE_SUCCESS, ApplySafeSubstitutions(sy->T("Loaded plugin: %1"), shortName));
|
||||
started = true;
|
||||
}
|
||||
|
|
|
@ -1312,7 +1312,6 @@ void timeoutFriendsRecursive(SceNetAdhocctlPeerInfo * node, int32_t* count) {
|
|||
|
||||
void sendChat(const std::string &chatString) {
|
||||
SceNetAdhocctlChatPacketC2S chat;
|
||||
auto n = GetI18NCategory(I18NCat::NETWORKING);
|
||||
chat.base.opcode = OPCODE_CHAT;
|
||||
//TODO check network inited, check send success or not, chatlog.pushback error on failed send, pushback error on not connected
|
||||
if (friendFinderRunning) {
|
||||
|
@ -1334,6 +1333,7 @@ void sendChat(const std::string &chatString) {
|
|||
}
|
||||
} else {
|
||||
std::lock_guard<std::mutex> guard(chatLogLock);
|
||||
auto n = GetI18NCategory(I18NCat::NETWORKING);
|
||||
chatLog.push_back(n->T("You're in Offline Mode, go to lobby or online hall"));
|
||||
chatMessageGeneration++;
|
||||
}
|
||||
|
|
|
@ -100,8 +100,6 @@ static int sceAudiocodecDecode(u32 ctxPtr, int codec) {
|
|||
}
|
||||
|
||||
if (IsValidCodec(codec)){
|
||||
// Use SimpleAudioDec to decode audio
|
||||
auto ctx = PSPPointer<AudioCodecContext>::Create(ctxPtr); // On stack, no need to allocate.
|
||||
int outbytes = 0;
|
||||
// find a decoder in audioList
|
||||
auto decoder = findDecoder(ctxPtr);
|
||||
|
@ -115,6 +113,8 @@ static int sceAudiocodecDecode(u32 ctxPtr, int codec) {
|
|||
}
|
||||
|
||||
if (decoder != NULL) {
|
||||
// Use SimpleAudioDec to decode audio
|
||||
auto ctx = PSPPointer<AudioCodecContext>::Create(ctxPtr); // On stack, no need to allocate.
|
||||
// Decode audio
|
||||
decoder->Decode(Memory::GetPointer(ctx->inDataPtr), ctx->inDataSize, Memory::GetPointerWrite(ctx->outDataPtr), &outbytes);
|
||||
}
|
||||
|
|
|
@ -519,10 +519,10 @@ public:
|
|||
fontMap.erase(fonts_[i]);
|
||||
}
|
||||
}
|
||||
u32 args[2] = { userDataAddr(), (u32)handle_ };
|
||||
// TODO: The return value of this is leaking.
|
||||
if (handle_) { // Avoid calling free-callback on double-free
|
||||
if (coreState != CORE_POWERDOWN) {
|
||||
u32 args[2] = { userDataAddr(), (u32)handle_ };
|
||||
hleEnqueueCall(freeFuncAddr(), 2, args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2164,7 +2164,6 @@ int KernelStartModule(SceUID moduleId, u32 argsize, u32 argAddr, u32 returnValue
|
|||
|
||||
static void sceKernelStartModule(u32 moduleId, u32 argsize, u32 argAddr, u32 returnValueAddr, u32 optionAddr)
|
||||
{
|
||||
auto smoption = PSPPointer<SceKernelSMOption>::Create(optionAddr);
|
||||
u32 error;
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(moduleId, error);
|
||||
if (!module) {
|
||||
|
@ -2190,6 +2189,7 @@ static void sceKernelStartModule(u32 moduleId, u32 argsize, u32 argAddr, u32 ret
|
|||
moduleId,argsize,argAddr,returnValueAddr,optionAddr);
|
||||
|
||||
bool needsWait;
|
||||
auto smoption = PSPPointer<SceKernelSMOption>::Create(optionAddr);
|
||||
int ret = KernelStartModule(moduleId, argsize, argAddr, returnValueAddr, smoption.PtrOrNull(), &needsWait);
|
||||
|
||||
if (needsWait) {
|
||||
|
|
|
@ -1179,10 +1179,10 @@ skip:
|
|||
void FinalizeScan(bool insertSymbols) {
|
||||
HashFunctions();
|
||||
|
||||
Path hashMapFilename = GetSysDirectory(DIRECTORY_SYSTEM) / "knownfuncs.ini";
|
||||
if (g_Config.bFuncHashMap || g_Config.bFuncReplacements) {
|
||||
LoadBuiltinHashMap();
|
||||
if (g_Config.bFuncHashMap) {
|
||||
Path hashMapFilename = GetSysDirectory(DIRECTORY_SYSTEM) / "knownfuncs.ini";
|
||||
LoadHashMap(hashMapFilename);
|
||||
StoreHashMap(hashMapFilename);
|
||||
}
|
||||
|
|
|
@ -364,7 +364,6 @@ namespace SaveState
|
|||
}
|
||||
|
||||
// Memory is a bit tricky when jit is enabled, since there's emuhacks in it.
|
||||
auto savedReplacements = SaveAndClearReplacements();
|
||||
if (MIPSComp::jit && p.mode == p.MODE_WRITE) {
|
||||
std::lock_guard<std::recursive_mutex> guard(MIPSComp::jitLock);
|
||||
if (MIPSComp::jit) {
|
||||
|
@ -385,8 +384,10 @@ namespace SaveState
|
|||
|
||||
// Don't bother restoring if reading, we'll deal with that in KernelModuleDoState.
|
||||
// In theory, different functions might have been runtime loaded in the state.
|
||||
if (p.mode != p.MODE_READ)
|
||||
if (p.mode != p.MODE_READ) {
|
||||
auto savedReplacements = SaveAndClearReplacements();
|
||||
RestoreSavedReplacements(savedReplacements);
|
||||
}
|
||||
|
||||
MemoryStick_DoState(p);
|
||||
currentMIPS->DoState(p);
|
||||
|
@ -598,18 +599,20 @@ namespace SaveState
|
|||
Load(fn, slot, callback, cbUserData);
|
||||
}
|
||||
} else {
|
||||
auto sy = GetI18NCategory(I18NCat::SYSTEM);
|
||||
if (callback)
|
||||
if (callback) {
|
||||
auto sy = GetI18NCategory(I18NCat::SYSTEM);
|
||||
callback(Status::FAILURE, sy->T("Failed to load state. Error in the file system."), cbUserData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool UndoLoad(const Path &gameFilename, Callback callback, void *cbUserData)
|
||||
{
|
||||
if (g_Config.sStateLoadUndoGame != GenerateFullDiscId(gameFilename)) {
|
||||
auto sy = GetI18NCategory(I18NCat::SYSTEM);
|
||||
if (callback)
|
||||
if (callback) {
|
||||
auto sy = GetI18NCategory(I18NCat::SYSTEM);
|
||||
callback(Status::FAILURE, sy->T("Error: load undo state is from a different game"), cbUserData);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -618,9 +621,10 @@ namespace SaveState
|
|||
Load(fn, LOAD_UNDO_SLOT, callback, cbUserData);
|
||||
return true;
|
||||
} else {
|
||||
auto sy = GetI18NCategory(I18NCat::SYSTEM);
|
||||
if (callback)
|
||||
if (callback) {
|
||||
auto sy = GetI18NCategory(I18NCat::SYSTEM);
|
||||
callback(Status::FAILURE, sy->T("Failed to load state for load undo. Error in the file system."), cbUserData);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -628,10 +632,9 @@ namespace SaveState
|
|||
void SaveSlot(const Path &gameFilename, int slot, Callback callback, void *cbUserData)
|
||||
{
|
||||
Path fn = GenerateSaveSlotFilename(gameFilename, slot, STATE_EXTENSION);
|
||||
Path shot = GenerateSaveSlotFilename(gameFilename, slot, SCREENSHOT_EXTENSION);
|
||||
Path fnUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_STATE_EXTENSION);
|
||||
Path shotUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_SCREENSHOT_EXTENSION);
|
||||
if (!fn.empty()) {
|
||||
Path shot = GenerateSaveSlotFilename(gameFilename, slot, SCREENSHOT_EXTENSION);
|
||||
auto renameCallback = [=](Status status, const std::string &message, void *data) {
|
||||
if (status != Status::FAILURE) {
|
||||
if (g_Config.bEnableStateUndo) {
|
||||
|
@ -651,26 +654,28 @@ namespace SaveState
|
|||
};
|
||||
// Let's also create a screenshot.
|
||||
if (g_Config.bEnableStateUndo) {
|
||||
Path shotUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_SCREENSHOT_EXTENSION);
|
||||
DeleteIfExists(shotUndo);
|
||||
RenameIfExists(shot, shotUndo);
|
||||
}
|
||||
SaveScreenshot(shot, Callback(), 0);
|
||||
Save(fn.WithExtraExtension(".tmp"), slot, renameCallback, cbUserData);
|
||||
} else {
|
||||
auto sy = GetI18NCategory(I18NCat::SYSTEM);
|
||||
if (callback)
|
||||
if (callback) {
|
||||
auto sy = GetI18NCategory(I18NCat::SYSTEM);
|
||||
callback(Status::FAILURE, sy->T("Failed to save state. Error in the file system."), cbUserData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool UndoSaveSlot(const Path &gameFilename, int slot) {
|
||||
Path fn = GenerateSaveSlotFilename(gameFilename, slot, STATE_EXTENSION);
|
||||
Path shot = GenerateSaveSlotFilename(gameFilename, slot, SCREENSHOT_EXTENSION);
|
||||
bool UndoSaveSlot(const Path &gameFilename, int slot) {
|
||||
Path fnUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_STATE_EXTENSION);
|
||||
Path shotUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_SCREENSHOT_EXTENSION);
|
||||
|
||||
// Do nothing if there's no undo.
|
||||
if (File::Exists(fnUndo)) {
|
||||
Path fn = GenerateSaveSlotFilename(gameFilename, slot, STATE_EXTENSION);
|
||||
Path shot = GenerateSaveSlotFilename(gameFilename, slot, SCREENSHOT_EXTENSION);
|
||||
Path shotUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_SCREENSHOT_EXTENSION);
|
||||
// Swap them so they can undo again to redo. Mistakes happen.
|
||||
SwapIfExists(shotUndo, shot);
|
||||
SwapIfExists(fnUndo, fn);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <array>
|
||||
|
||||
#include "Common/Arm64Emitter.h"
|
||||
#include "Common/StringUtils.h"
|
||||
|
@ -496,7 +497,7 @@ static void DataProcessingRegister(uint32_t w, uint64_t addr, Instruction *instr
|
|||
int op31 = (w >> 21) & 0x7;
|
||||
int o0 = (w >> 15) & 1;
|
||||
int Ra = (w >> 10) & 0x1f;
|
||||
const char *opnames[8] = { 0, 0, "maddl", "msubl", "smulh", 0, 0, 0 };
|
||||
static constexpr std::array<const char*, 8> opnames = { 0, 0, "maddl", "msubl", "smulh", 0, 0, 0 };
|
||||
|
||||
if (op31 == 0) {
|
||||
// madd/msub supports both 32-bit and 64-bit modes
|
||||
|
|
Loading…
Add table
Reference in a new issue