Skip to content

Commit

Permalink
Step 2 of removing PanicAlert
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jul 19, 2020
1 parent 617bbcf commit 47a3bf1
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 37 deletions.
4 changes: 2 additions & 2 deletions Common/Thunk.cpp
Expand Up @@ -147,8 +147,8 @@ const void *ThunkManager::ProtectFunction(const void *function, int num_params)
iter = thunks.find(function);
if (iter != thunks.end())
return (const void *)iter->second;
if (!region)
PanicAlert("Trying to protect functions before the emu is started. Bad bad bad.");

_assert_msg_(region != nullptr, "Can't protect functions before the emu is started.");

BeginWrite();
const u8 *call_point = GetCodePtr();
Expand Down
15 changes: 5 additions & 10 deletions Common/x64Emitter.cpp
Expand Up @@ -1414,8 +1414,7 @@ static int GetVEXpp(u8 opPrefix)

void XEmitter::WriteAVXOp(u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, OpArg arg, int extrabytes)
{
if (!cpu_info.bAVX)
PanicAlert("Trying to use AVX on a system that doesn't support it. Bad programmer.");
_assert_msg_(cpu_info.bAVX, "Trying to use AVX on a system that doesn't support it. Bad programmer.");
int mmmmm = GetVEXmmmmm(op);
int pp = GetVEXpp(opPrefix);
// FIXME: we currently don't support 256-bit instructions, and "size" is not the vector size here
Expand All @@ -1439,16 +1438,14 @@ void XEmitter::WriteVEXOp(int size, u8 opPrefix, u16 op, X64Reg regOp1, X64Reg r
void XEmitter::WriteBMI1Op(int size, u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, OpArg arg, int extrabytes)
{
CheckFlags();
if (!cpu_info.bBMI1)
PanicAlert("Trying to use BMI1 on a system that doesn't support it. Bad programmer.");
_assert_msg_(cpu_info.bBMI1, "Trying to use BMI1 on a system that doesn't support it. Bad programmer.");
WriteVEXOp(size, opPrefix, op, regOp1, regOp2, arg, extrabytes);
}

void XEmitter::WriteBMI2Op(int size, u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, OpArg arg, int extrabytes)
{
CheckFlags();
if (!cpu_info.bBMI2)
PanicAlert("Trying to use BMI2 on a system that doesn't support it. Bad programmer.");
_assert_msg_(cpu_info.bBMI2, "Trying to use BMI2 on a system that doesn't support it. Bad programmer.");
WriteVEXOp(size, opPrefix, op, regOp1, regOp2, arg, extrabytes);
}

Expand Down Expand Up @@ -1742,15 +1739,13 @@ void XEmitter::PMULUDQ(X64Reg dest, const OpArg &arg) {WriteSSEOp(0x66, 0xF4, de

void XEmitter::WriteSSSE3Op(u8 opPrefix, u16 op, X64Reg regOp, OpArg arg, int extrabytes)
{
if (!cpu_info.bSSSE3)
PanicAlert("Trying to use SSSE3 on a system that doesn't support it. Bad programmer.");
_assert_msg_(cpu_info.bSSSE3, "Trying to use SSSE3 on a system that doesn't support it. Bad programmer.");
WriteSSEOp(opPrefix, op, regOp, arg, extrabytes);
}

void XEmitter::WriteSSE41Op(u8 opPrefix, u16 op, X64Reg regOp, OpArg arg, int extrabytes)
{
if (!cpu_info.bSSE4_1)
PanicAlert("Trying to use SSE4.1 on a system that doesn't support it. Bad programmer.");
_assert_msg_(cpu_info.bSSE4_1, "Trying to use SSE4.1 on a system that doesn't support it. Bad programmer.");
WriteSSEOp(opPrefix, op, regOp, arg, extrabytes);
}

Expand Down
7 changes: 3 additions & 4 deletions Core/MIPS/x86/RegCache.cpp
Expand Up @@ -356,8 +356,8 @@ void GPRRegCache::MapReg(MIPSGPReg i, bool doLoad, bool makeDirty) {

if (!regs[i].away || (regs[i].away && regs[i].location.IsImm())) {
X64Reg xr = GetFreeXReg();
if (xregs[xr].dirty) PanicAlert("Xreg already dirty");
if (xregs[xr].allocLocked) PanicAlert("GetFreeXReg returned locked register");
_assert_msg_(!xregs[xr].dirty, "Xreg already dirty");
_assert_msg_(!xregs[xr].allocLocked, "GetFreeXReg returned locked register");
xregs[xr].free = false;
xregs[xr].mipsReg = i;
xregs[xr].dirty = makeDirty || regs[i].location.IsImm();
Expand All @@ -371,8 +371,7 @@ void GPRRegCache::MapReg(MIPSGPReg i, bool doLoad, bool makeDirty) {
}
for (int j = 0; j < 32; j++) {
if (i != MIPSGPReg(j) && regs[j].location.IsSimpleReg(xr)) {
ERROR_LOG(JIT, "BindToRegister: Strange condition");
Crash();
_assert_msg_(false, "BindToRegister: Strange condition");
}
}
regs[i].away = true;
Expand Down
2 changes: 1 addition & 1 deletion Core/MIPS/x86/RegCache.h
Expand Up @@ -101,7 +101,7 @@ class GPRRegCache
{
if (regs[preg].away && regs[preg].location.IsSimpleReg())
return regs[preg].location.GetSimpleReg();
PanicAlert("Not so simple - %i", preg);
_assert_msg_(false, "Not so simple - %d", preg);
return (Gen::X64Reg)-1;
}
Gen::OpArg GetDefaultLocation(MIPSGPReg reg) const;
Expand Down
3 changes: 1 addition & 2 deletions Core/Util/PPGeDraw.cpp
Expand Up @@ -222,8 +222,7 @@ void __PPGeInit() {

bool loadedZIM = !skipZIM && LoadZIM("ppge_atlas.zim", width, height, &flags, imageData);
if (!skipZIM && !loadedZIM) {
PanicAlert("Failed to load ppge_atlas.zim.\n\nPlace it in the directory \"assets\" under your PPSSPP directory.");
ERROR_LOG(SCEGE, "PPGe init failed - no atlas texture. PPGe stuff will not be drawn.");
ERROR_LOG(SCEGE, "Failed to load ppge_atlas.zim.\n\nPlace it in the directory \"assets\" under your PPSSPP directory.\n\nPPGe stuff will not be drawn.");
}

if (loadedZIM) {
Expand Down
25 changes: 8 additions & 17 deletions Core/WaveFile.cpp
Expand Up @@ -23,19 +23,14 @@ WaveFileWriter::~WaveFileWriter()
bool WaveFileWriter::Start(const std::string& filename, unsigned int HLESampleRate)
{
// Check if the file is already open
if (file)
{
PanicAlert("The file %s was already open, the file header will not be written.",
filename.c_str());
if (file) {
ERROR_LOG(SYSTEM, "The file %s was already open, the file header will not be written.", filename.c_str());
return false;
}

file.Open(filename, "wb");
if (!file)
{
PanicAlert("The file %s could not be opened for writing. Please check if it's already opened "
"by another program.",
filename.c_str());
if (!file) {
ERROR_LOG(SYSTEM, "The file %s could not be opened for writing. Please check if it's already opened by another program.", filename.c_str());
return false;
}

Expand All @@ -61,9 +56,8 @@ bool WaveFileWriter::Start(const std::string& filename, unsigned int HLESampleRa
Write(100 * 1000 * 1000 - 32);

// We are now at offset 44
if (file.Tell() != 44)
PanicAlert("Wrong offset: %lld", (long long)file.Tell());

u64 offset = file.Tell();
_assert_msg_(offset == 44, "Wrong offset: %lld", (long long)offset);
return true;
}

Expand Down Expand Up @@ -91,11 +85,8 @@ void WaveFileWriter::Write4(const char* ptr)

void WaveFileWriter::AddStereoSamples(const short* sample_data, u32 count)
{
if (!file)
PanicAlert("WaveFileWriter - file not open.");

if (count > BUFFER_SIZE * 2)
PanicAlert("WaveFileWriter - buffer too small (count = %u).", count);
_assert_msg_(file, "WaveFileWriter - file not open.");
_assert_msg_(count <= BUFFER_SIZE * 2, "WaveFileWriter - buffer too small (count = %u).", count);

if (skip_silence)
{
Expand Down
2 changes: 1 addition & 1 deletion Windows/GPU/D3D9Context.cpp
Expand Up @@ -218,7 +218,7 @@ void D3D9Context::Resize() {
HRESULT hr = device_->Reset(&presentParams_);
if (FAILED(hr)) {
// Had to remove DXGetErrorStringA calls here because dxerr.lib is deprecated and will not link with VS 2015.
PanicAlert("Unable to reset D3D9 device");
_assert_msg_(false, "Unable to reset D3D9 device");
}
draw_->HandleEvent(Draw::Event::GOT_BACKBUFFER, 0, 0, nullptr);
}
Expand Down

0 comments on commit 47a3bf1

Please sign in to comment.