Skip to content

Wow64: Spin loop on atomic with WFE#5660

Open
Sonicadvance1 wants to merge 1 commit into
FEX-Emu:mainfrom
Sonicadvance1:183
Open

Wow64: Spin loop on atomic with WFE#5660
Sonicadvance1 wants to merge 1 commit into
FEX-Emu:mainfrom
Sonicadvance1:183

Conversation

@Sonicadvance1

Copy link
Copy Markdown
Member

Instead of burning roughly a million watts, put this spinloop on a WFE. This tends to occur on a crash during shutdown that isn't fully able to be avoided. The least we can do is not consume all the power in the world.

Instead of burning roughly a million watts, put this spinloop on a WFE.
This tends to occur on a crash during shutdown that isn't fully able to
be avoided. The least we can do is not consume all the power in the
world.
}

template<typename Pred, typename T>
static inline void WaitBitMaskPred(T* Futex, T BitMask, T ComparisonValue) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewriting the signature so the template args are reversed, and passing the predicate in like so:

Suggested change
static inline void WaitBitMaskPred(T* Futex, T BitMask, T ComparisonValue) {
template<typename T, typename Pred>
static inline void WaitBitMaskPred(T* Futex, T BitMask, T ComparisonValue, Pred Predicate) {

and then invoking it as:

SpinWaitLock::WaitBitMaskPred(TLS.ControlWordAddress(), ControlBits::IN_JIT, 0U, std::equal_to<>());

and removing the braces from Pred {} in the implementation would make the interface a little more flexible (and also allow passing regular lambdas in too).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants