DSPEmitter: Use std::vector instead of raw allocation
This commit is contained in:
parent
400d5f6940
commit
c37889efcb
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "Core/DSP/Jit/DSPEmitter.h"
|
#include "Core/DSP/Jit/DSPEmitter.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "Common/Assert.h"
|
#include "Common/Assert.h"
|
||||||
|
@ -22,14 +23,10 @@
|
||||||
|
|
||||||
using namespace Gen;
|
using namespace Gen;
|
||||||
|
|
||||||
DSPEmitter::DSPEmitter()
|
DSPEmitter::DSPEmitter() : blockLinks(MAX_BLOCKS), blockSize(MAX_BLOCKS), blocks(MAX_BLOCKS)
|
||||||
{
|
{
|
||||||
AllocCodeSpace(COMPILED_CODE_SIZE);
|
AllocCodeSpace(COMPILED_CODE_SIZE);
|
||||||
|
|
||||||
blocks = new DSPCompiledCode[MAX_BLOCKS];
|
|
||||||
blockLinks = new Block[MAX_BLOCKS];
|
|
||||||
blockSize = new u16[MAX_BLOCKS];
|
|
||||||
|
|
||||||
compileSR = 0;
|
compileSR = 0;
|
||||||
compileSR |= SR_INT_ENABLE;
|
compileSR |= SR_INT_ENABLE;
|
||||||
compileSR |= SR_EXT_INT_ENABLE;
|
compileSR |= SR_EXT_INT_ENABLE;
|
||||||
|
@ -37,20 +34,12 @@ DSPEmitter::DSPEmitter()
|
||||||
CompileDispatcher();
|
CompileDispatcher();
|
||||||
stubEntryPoint = CompileStub();
|
stubEntryPoint = CompileStub();
|
||||||
|
|
||||||
// clear all of the block references
|
// Clear all of the block references
|
||||||
for (int i = 0x0000; i < MAX_BLOCKS; i++)
|
std::fill(blocks.begin(), blocks.end(), (DSPCompiledCode)stubEntryPoint);
|
||||||
{
|
|
||||||
blocks[i] = (DSPCompiledCode)stubEntryPoint;
|
|
||||||
blockLinks[i] = nullptr;
|
|
||||||
blockSize[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DSPEmitter::~DSPEmitter()
|
DSPEmitter::~DSPEmitter()
|
||||||
{
|
{
|
||||||
delete[] blocks;
|
|
||||||
delete[] blockLinks;
|
|
||||||
delete[] blockSize;
|
|
||||||
FreeCodeSpace();
|
FreeCodeSpace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,7 +397,7 @@ void DSPEmitter::CompileDispatcher()
|
||||||
|
|
||||||
// Execute block. Cycles executed returned in EAX.
|
// Execute block. Cycles executed returned in EAX.
|
||||||
MOVZX(64, 16, ECX, M(&g_dsp.pc));
|
MOVZX(64, 16, ECX, M(&g_dsp.pc));
|
||||||
MOV(64, R(RBX), ImmPtr(blocks));
|
MOV(64, R(RBX), ImmPtr(blocks.data()));
|
||||||
JMPptr(MComplex(RBX, RCX, SCALE_8, 0));
|
JMPptr(MComplex(RBX, RCX, SCALE_8, 0));
|
||||||
|
|
||||||
returnDispatcher = GetCodePtr();
|
returnDispatcher = GetCodePtr();
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "Common/x64ABI.h"
|
#include "Common/x64ABI.h"
|
||||||
#include "Common/x64Emitter.h"
|
#include "Common/x64Emitter.h"
|
||||||
|
@ -243,14 +244,14 @@ public:
|
||||||
const u8* returnDispatcher;
|
const u8* returnDispatcher;
|
||||||
u16 compilePC;
|
u16 compilePC;
|
||||||
u16 startAddr;
|
u16 startAddr;
|
||||||
Block* blockLinks;
|
std::vector<Block> blockLinks;
|
||||||
u16* blockSize;
|
std::vector<u16> blockSize;
|
||||||
std::list<u16> unresolvedJumps[MAX_BLOCKS];
|
std::list<u16> unresolvedJumps[MAX_BLOCKS];
|
||||||
|
|
||||||
DSPJitRegCache gpr{*this};
|
DSPJitRegCache gpr{*this};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DSPCompiledCode* blocks;
|
std::vector<DSPCompiledCode> blocks;
|
||||||
Block blockLinkEntry;
|
Block blockLinkEntry;
|
||||||
u16 compileSR;
|
u16 compileSR;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue