-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
n64: remove call to epilogue function from the jit #1663
Merged
+62
−68
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,10 @@ auto CPU::Recompiler::pool(u32 address) -> Pool* { | |
auto CPU::Recompiler::block(u64 vaddr, u32 address, bool singleInstruction) -> Block* { | ||
if(auto block = pool(address)->blocks[address >> 2 & 0x3f]) return block; | ||
auto block = emit(vaddr, address, singleInstruction); | ||
pool(address)->blocks[address >> 2 & 0x3f] = block; | ||
memory::jitprotect(true); | ||
if(block) { | ||
pool(address)->blocks[address >> 2 & 0x3f] = block; | ||
memory::jitprotect(true); | ||
} | ||
return block; | ||
} | ||
|
||
|
@@ -28,11 +30,16 @@ auto CPU::Recompiler::emit(u64 vaddr, u32 address, bool singleInstruction) -> Bl | |
reset(); | ||
} | ||
|
||
auto block = (Block*)allocator.acquire(sizeof(Block)); | ||
// abort compilation of block asap if the instruction cache is not coherent | ||
if(!self.icache.coherent(vaddr, address)) | ||
return nullptr; | ||
|
||
bool abort = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
beginFunction(3); | ||
|
||
Thread thread; | ||
bool hasBranched = 0; | ||
int numInsn = 0; | ||
constexpr u32 branchToSelf = 0x1000'ffff; //beq 0,0,<pc> | ||
u32 jumpToSelf = 2 << 26 | vaddr >> 2 & 0x3ff'ffff; //j <pc> | ||
while(true) { | ||
|
@@ -46,13 +53,26 @@ auto CPU::Recompiler::emit(u64 vaddr, u32 address, bool singleInstruction) -> Bl | |
mov32(reg(2), imm(instruction)); | ||
call(&CPU::instructionPrologue); | ||
} | ||
if(numInsn == 0 || (vaddr&0x1f)==0){ | ||
//abort compilation of block if the instruction cache is not coherent | ||
if(!self.icache.coherent(vaddr, address)) { | ||
resetCompiler(); | ||
return nullptr; | ||
} | ||
mov64(reg(1), imm(vaddr)); | ||
mov32(reg(2), imm(address)); | ||
call(&CPU::jitFetch); | ||
} | ||
numInsn++; | ||
bool branched = emitEXECUTE(instruction); | ||
if(unlikely(instruction == branchToSelf || instruction == jumpToSelf)) { | ||
//accelerate idle loops | ||
mov32(reg(1), imm(64 * 2)); | ||
call(&CPU::step); | ||
} else { | ||
mov32(reg(1), imm(1 * 2)); | ||
call(&CPU::step); | ||
} | ||
call(&CPU::instructionEpilogue<1>); | ||
test32(PipelineReg(state), imm(Pipeline::EndBlock), set_z); | ||
mov32(PipelineReg(state), PipelineReg(nstate)); | ||
mov64(mem(IpuReg(pc)), PipelineReg(pc)); | ||
|
@@ -64,9 +84,11 @@ auto CPU::Recompiler::emit(u64 vaddr, u32 address, bool singleInstruction) -> Bl | |
hasBranched = branched; | ||
jumpEpilog(flag_nz); | ||
} | ||
|
||
jumpEpilog(); | ||
|
||
memory::jitprotect(false); | ||
auto block = (Block*)allocator.acquire(sizeof(Block)); | ||
block->code = endFunction(); | ||
|
||
//print(hex(PC, 8L), " ", instructions, " ", size(), "\n"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little concerned about losing this assert in debug builds. I guess we could replace it with a check in the JITed code. Not saying this has to be addressed in this PR, but I wanted to make note of it.