mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-26 23:10:38 +00:00
mipsjit: Correct inheritance/compilation.
This commit is contained in:
parent
cae0815095
commit
7de77e4683
@ -27,9 +27,13 @@
|
||||
#include "Common/CPUDetect.h"
|
||||
|
||||
namespace MIPSGen {
|
||||
void MIPSEmitter::SetCodePtr(u8 *ptr) {
|
||||
code_ = ptr;
|
||||
lastCacheFlushEnd_ = ptr;
|
||||
void MIPSEmitter::SetCodePointer(const u8 *ptr, u8 *writePtr) {
|
||||
code_ = writePtr;
|
||||
lastCacheFlushEnd_ = writePtr;
|
||||
}
|
||||
|
||||
const u8 *MIPSEmitter::GetCodePointer() const {
|
||||
return code_;
|
||||
}
|
||||
|
||||
void MIPSEmitter::ReserveCodeSpace(u32 bytes) {
|
||||
@ -466,27 +470,14 @@ void MIPSEmitter::MOVI2R(MIPSReg reg, u32 imm) {
|
||||
}
|
||||
}
|
||||
|
||||
void MIPSCodeBlock::AllocCodeSpace(int size) {
|
||||
region_size = size;
|
||||
region = (u8 *)AllocateExecutableMemory(region_size);
|
||||
SetCodePtr(region);
|
||||
}
|
||||
|
||||
// Always clear code space with breakpoints, so that if someone accidentally executes
|
||||
// uninitialized, it just breaks into the debugger.
|
||||
void MIPSCodeBlock::ClearCodeSpace(int offset) {
|
||||
// Set BREAK instructions on all of it.
|
||||
u32 *region32 = (u32 *)region;
|
||||
for (u32 i = 0; i < region_size / 4; ++i) {
|
||||
*region32++ = 0x0000000d;
|
||||
}
|
||||
ResetCodePtr();
|
||||
}
|
||||
|
||||
void MIPSCodeBlock::FreeCodeSpace() {
|
||||
FreeMemoryPages(region, region_size);
|
||||
region = NULL;
|
||||
region_size = 0;
|
||||
void MIPSCodeBlock::PoisonMemory(int offset) {
|
||||
u32 *ptr = (u32 *)(region + offset);
|
||||
u32 *maxptr = (u32 *)(region + region_size - offset);
|
||||
// If our memory isn't a multiple of u32 then this won't write the last remaining bytes with anything
|
||||
// Less than optimal, but there would be nothing we could do but throw a runtime warning anyway.
|
||||
// AArch64: 0x0000000d = break 0
|
||||
while (ptr < maxptr)
|
||||
*ptr++ = 0x0000000d;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,8 @@
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "Common.h"
|
||||
#include "Common/CodeBlock.h"
|
||||
#include "Common/Common.h"
|
||||
|
||||
namespace MIPSGen {
|
||||
|
||||
@ -72,12 +73,14 @@ public:
|
||||
MIPSEmitter() : code_(0), lastCacheFlushEnd_(0) {
|
||||
}
|
||||
MIPSEmitter(u8 *code_ptr) : code_(code_ptr), lastCacheFlushEnd_(code_ptr) {
|
||||
SetCodePtr(code_ptr);
|
||||
SetCodePointer(code_ptr, code_ptr);
|
||||
}
|
||||
virtual ~MIPSEmitter() {
|
||||
}
|
||||
|
||||
void SetCodePtr(u8 *ptr);
|
||||
void SetCodePointer(const u8 *ptr, u8 *writePtr);
|
||||
const u8* GetCodePointer() const;
|
||||
|
||||
void ReserveCodeSpace(u32 bytes);
|
||||
const u8 *AlignCode16();
|
||||
const u8 *AlignCodePage();
|
||||
@ -270,45 +273,9 @@ private:
|
||||
// Everything that needs to generate machine code should inherit from this.
|
||||
// You get memory management for free, plus, you can use all the LUI etc functions without
|
||||
// having to prefix them with gen-> or something similar.
|
||||
class MIPSCodeBlock : public MIPSEmitter {
|
||||
class MIPSCodeBlock : public CodeBlock<MIPSEmitter> {
|
||||
public:
|
||||
MIPSCodeBlock() : region(nullptr), region_size(0) {
|
||||
}
|
||||
virtual ~MIPSCodeBlock() {
|
||||
if (region) {
|
||||
FreeCodeSpace();
|
||||
}
|
||||
}
|
||||
|
||||
// Call this before you generate any code.
|
||||
void AllocCodeSpace(int size);
|
||||
|
||||
// Always clear code space with breakpoints, so that if someone accidentally executes
|
||||
// uninitialized, it just breaks into the debugger.
|
||||
void ClearCodeSpace(int offset);
|
||||
|
||||
// Call this when shutting down. Don't rely on the destructor, even though it'll do the job.
|
||||
void FreeCodeSpace();
|
||||
|
||||
bool IsInSpace(const u8 *ptr) const {
|
||||
return ptr >= region && ptr < region + region_size;
|
||||
}
|
||||
|
||||
void ResetCodePtr() {
|
||||
SetCodePtr(region);
|
||||
}
|
||||
|
||||
size_t GetSpaceLeft() const {
|
||||
return region_size - (GetCodePtr() - region);
|
||||
}
|
||||
|
||||
u8 *GetBasePtr() {
|
||||
return region;
|
||||
}
|
||||
|
||||
size_t GetOffset(const u8 *ptr) const {
|
||||
return ptr - region;
|
||||
}
|
||||
void PoisonMemory(int offset) override;
|
||||
|
||||
protected:
|
||||
u8 *region;
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "Common/Profiler/Profiler.h"
|
||||
#include "Common/Serialize/Serializer.h"
|
||||
#include "Common/Serialize/SerializeFuncs.h"
|
||||
#include "Core/Reporting.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/Core.h"
|
||||
|
Loading…
Reference in New Issue
Block a user