Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
melonDS
Commits
f56aa60e
Commit
f56aa60e
authored
Jul 28, 2020
by
RSDuck
Browse files
check IRQ first then Idle loop
apparently I put it this way for a reason
parent
ea734084
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/ARM.cpp
View file @
f56aa60e
...
...
@@ -660,19 +660,20 @@ void ARMv5::ExecuteJIT()
if
(
StopExecution
)
{
// this order is crucial otherwise idle loops waiting for an IRQ won't function
if
(
IRQ
)
TriggerIRQ
();
if
(
Halted
||
IdleLoop
)
{
bool
idleLoop
=
IdleLoop
;
IdleLoop
=
0
;
if
((
Halted
==
1
||
idleLoop
)
&&
NDS
::
ARM9Timestamp
<
NDS
::
ARM9Target
)
if
((
Halted
==
1
||
IdleLoop
)
&&
NDS
::
ARM9Timestamp
<
NDS
::
ARM9Target
)
{
Cycles
=
0
;
NDS
::
ARM9Timestamp
=
NDS
::
ARM9Target
;
}
IdleLoop
=
0
;
break
;
}
if
(
IRQ
)
TriggerIRQ
();
}
NDS
::
ARM9Timestamp
+=
Cycles
;
...
...
@@ -808,22 +809,21 @@ void ARMv4::ExecuteJIT()
else
ARMJIT
::
CompileBlock
(
this
);
// TODO optimize this shit!!!
if
(
StopExecution
)
{
if
(
IRQ
)
TriggerIRQ
();
if
(
Halted
||
IdleLoop
)
{
bool
idleLoop
=
IdleLoop
;
IdleLoop
=
0
;
if
((
Halted
==
1
||
idleLoop
)
&&
NDS
::
ARM7Timestamp
<
NDS
::
ARM7Target
)
if
((
Halted
==
1
||
IdleLoop
)
&&
NDS
::
ARM7Timestamp
<
NDS
::
ARM7Target
)
{
Cycles
=
0
;
NDS
::
ARM7Timestamp
=
NDS
::
ARM7Target
;
}
IdleLoop
=
0
;
break
;
}
if
(
IRQ
)
TriggerIRQ
();
}
NDS
::
ARM7Timestamp
+=
Cycles
;
...
...
src/ARMJIT.cpp
View file @
f56aa60e
...
...
@@ -504,7 +504,7 @@ bool DecodeBranch(bool thumb, const FetchedInstr& instr, u32& cond, bool hasLink
return
false
;
}
bool
IsIdleLoop
(
FetchedInstr
*
instrs
,
int
instrsCount
)
bool
IsIdleLoop
(
bool
thumb
,
FetchedInstr
*
instrs
,
int
instrsCount
)
{
// see https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/Core/PowerPC/PPCAnalyst.cpp#L678
// it basically checks if one iteration of a loop depends on another
...
...
@@ -515,9 +515,11 @@ bool IsIdleLoop(FetchedInstr* instrs, int instrsCount)
u16
regsDisallowedToWrite
=
0
;
for
(
int
i
=
0
;
i
<
instrsCount
;
i
++
)
{
JIT_DEBUGPRINT
(
"instr %d %x regs(%x %x) %x %x
\n
"
,
i
,
instrs
[
i
].
Instr
,
instrs
[
i
].
Info
.
DstRegs
,
instrs
[
i
].
Info
.
SrcRegs
,
regsWrittenTo
,
regsDisallowedToWrite
);
JIT_DEBUGPRINT
(
"instr %d %
08
x regs(%x %x) %x %x
\n
"
,
i
,
instrs
[
i
].
Instr
,
instrs
[
i
].
Info
.
DstRegs
,
instrs
[
i
].
Info
.
SrcRegs
,
regsWrittenTo
,
regsDisallowedToWrite
);
if
(
instrs
[
i
].
Info
.
SpecialKind
==
ARMInstrInfo
::
special_WriteMem
)
return
false
;
if
(
!
thumb
&&
instrs
[
i
].
Info
.
Kind
>=
ARMInstrInfo
::
ak_MSR_IMM
&&
instrs
[
i
].
Info
.
Kind
<=
ARMInstrInfo
::
ak_MRC
)
return
false
;
if
(
i
<
instrsCount
-
1
&&
instrs
[
i
].
Info
.
Branches
())
return
false
;
...
...
@@ -852,10 +854,10 @@ void CompileBlock(ARM* cpu)
{
// we might have an idle loop
u32
backwardsOffset
=
(
instrs
[
i
].
Addr
-
target
)
/
(
thumb
?
2
:
4
);
if
(
IsIdleLoop
(
&
instrs
[
i
-
backwardsOffset
],
backwardsOffset
+
1
))
if
(
IsIdleLoop
(
thumb
,
&
instrs
[
i
-
backwardsOffset
],
backwardsOffset
+
1
))
{
instrs
[
i
].
BranchFlags
|=
branch_IdleBranch
;
JIT_DEBUGPRINT
(
"found %s idle loop %d in block %x
\n
"
,
thumb
?
"thumb"
:
"arm"
,
cpu
->
Num
,
blockAddr
);
JIT_DEBUGPRINT
(
"found %s idle loop %d in block %
08
x
\n
"
,
thumb
?
"thumb"
:
"arm"
,
cpu
->
Num
,
blockAddr
);
}
}
else
if
(
hasBranched
&&
!
isBackJump
&&
i
+
1
<
Config
::
JIT_MaxBlockSize
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment