melonDS icon indicating copy to clipboard operation
melonDS copied to clipboard

ARMJit Compiler::Reset(): Cleaner way to fill memory with BRK.

Open AdmiralCurtiss opened this issue 4 years ago • 6 comments

See https://melonds.kuribo64.net/comments.php?id=137&cid=2971#comment2971

I have no way to test this because of a lack of debuggable high-power ARM devices, but I think this is right.

AdmiralCurtiss avatar Mar 24 '21 22:03 AdmiralCurtiss

Let me test on my M1 with the full change.

Edit: Fails during build with the following error.

/Volumes/Extras HD/GitHub/melonDS/src/ARMJIT_A64/ARMJIT_Compiler.cpp:836:15: error: cannot initialize a variable of type 'u8 *const' (aka 'unsigned char *const') with an rvalue of type 'const u8 *' (aka 'const unsigned char ') u8 const rw_ptr = GetRWPtr(); ^ ~~~~~~~~~~

ghost avatar Mar 24 '21 22:03 ghost

we break aliasing all the time, so while this is more correct, it's really a drop in the ocean

EDIT: also regarding your comment, on the post, it was different reason it crashed.

RSDuck avatar Mar 24 '21 22:03 RSDuck

Ah there was a hidden const_cast in there before, that's even more sketchy. Well either way, fair enough, I just saw the blog post and my brain went 'wait this is not right'.

AdmiralCurtiss avatar Mar 24 '21 22:03 AdmiralCurtiss

Ah there was a hidden const_cast in there before, that's even more sketchy. Well either way, fair enough, I just saw the blog post and my brain went 'wait this is not right'.

It's definitely not. It's not so much a full on crash as a hang when the JIT and FastMem are both enabled.

ghost avatar Mar 24 '21 22:03 ghost

How about this now?

ghost avatar Jul 30 '21 01:07 ghost

I mean we can merge this, though we still rely massively break aliasing on so many other places in so much more complex ways, that if the compiler ever bits back, it'll do somewhere else first.

RSDuck avatar Jul 30 '21 01:07 RSDuck