Fix bug where if the Vertex Decoder JIT failed, we failed to restore mprotect permissions causing a crash

This commit is contained in:
Henrik Rydgård 2017-01-25 19:07:13 +01:00
parent 193b5f3094
commit 3d8c94cf90
2 changed files with 5 additions and 3 deletions

View file

@ -284,6 +284,7 @@ JittedVertexDecoder VertexDecoderJitCache::Compile(const VertexDecoder &dec, int
PLD(srcReg, 64);
for (int i = 0; i < dec.numSteps_; i++) {
if (!CompileStep(dec, i)) {
EndWrite();
// Reset the code ptr and return zero to indicate that we failed.
SetCodePtr(const_cast<u8 *>(start));
char temp[1024] = {0};

View file

@ -243,6 +243,7 @@ JittedVertexDecoder VertexDecoderJitCache::Compile(const VertexDecoder &dec, int
const u8 *loopStart = GetCodePtr();
for (int i = 0; i < dec.numSteps_; i++) {
if (!CompileStep(dec, i)) {
EndWrite();
// Reset the code ptr (effectively undoing what we generated) and return zero to indicate that we failed.
SetCodePtr(const_cast<u8 *>(start));
char temp[1024] = {0};
@ -285,14 +286,14 @@ JittedVertexDecoder VertexDecoderJitCache::Compile(const VertexDecoder &dec, int
char temp[1024] = { 0 };
dec.ToString(temp);
ILOG("=== %s (%d bytes) ===", temp, (int)(GetCodePtr() - start));
std::vector<std::string> lines = DisassembleArm64(start, GetCodePtr() - start);
std::vector<std::string> lines = DisassembleArm64(start, (int)(GetCodePtr() - start));
for (auto line : lines) {
ILOG("%s", line.c_str());
}
ILOG("==========", temp);
ILOG("==========");
}
*jittedSize = GetCodePtr() - start;
*jittedSize = (int)(GetCodePtr() - start);
EndWrite();
return (JittedVertexDecoder)start;
}