Baekalfen / PyBoy

Game Boy emulator written in Python
Other
4.57k stars 472 forks source link

Refactor breakpoint checking #317

Closed thatguy11325 closed 5 months ago

thatguy11325 commented 5 months ago

Attempted to refactor the breakpoint/hooks logic to not loop over the breakpoints list and use a table lookup for every call. Hopefully it's faster.

Baekalfen commented 5 months ago

Could you split up the commits? I would like to test out the breakpoint changes alone, and cherry-pick them onto master. Then we can look at the Makefile afterwards.

thatguy11325 commented 5 months ago

Took care of all the requested changes. I didn't know if you wanted new commits or amended old commits. I went with the latter.

One possible change I saw, but didn't make is changing the breakpoints dict to a fixed-length array of size 0xFFFF (similar to your trick in your jit experiment). I believe that'd allow removing the gil from breakpoint_reached. Using libcpp's unordered_map would allow for a similar no-gil, but would create a stricter dependency on cython.