Skip to content
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

PPCAnalyst now detects internal branches better #371

Merged
merged 1 commit into from Jun 6, 2014

Conversation

quarnster
Copy link
Contributor

For example:

addr     opcode    disasm
80026584 48000054  b    ->0x800265D8 

For example:

```
addr     opcode    disasm
80026584 48000054  b	->0x800265D8 
```
@Tilka
Copy link
Member

Tilka commented May 15, 2014

@dolphin-emu-bot rebuild

@shuffle2
Copy link
Contributor

LGTM

@shuffle2
Copy link
Contributor

Does this fix something specific you were looking at? It seems like it runs the risk of being too greedy and clumping external branches into the function being analyzed...breaking the purpose of AnalyzeFunction.

@quarnster
Copy link
Contributor Author

Jumping into a random block in another function is not exactly common practice.

It was this sequence in specific, where the labels mark the function boundaries as detected without this change in it (see the *'s for the relevant branches):

    Address  Opcode hex         Interpreter function                     Disasm
800264e8:
    800264e8 c00286c8         _ZN11Interpreter3lfsE17UGeckoInstruction lfs  f0, -0x7938 (rtoc) 
    800264ec 38800000        _ZN11Interpreter4addiE17UGeckoInstruction li   r4, 0 
    800264f0 38c00010        _ZN11Interpreter4addiE17UGeckoInstruction li   r6, 16 
    800264f4 d0030050        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x0050 (r3) 
    800264f8 d0030054        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x0054 (r3) 
    800264fc d0030058        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x0058 (r3) 
    80026500 c00286cc         _ZN11Interpreter3lfsE17UGeckoInstruction lfs  f0, -0x7934 (rtoc) 
    80026504 90830074         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x0074 (r3) 
    80026508 d0030078        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x0078 (r3) 
    8002650c 9083007c         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x007C (r3) 
    80026510 d0030080        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x0080 (r3) 
    80026514 90830084         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x0084 (r3) 
    80026518 d0030088        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x0088 (r3) 
    8002651c 9083008c         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x008C (r3) 
    80026520 d0030090        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x0090 (r3) 
    80026524 90830094         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x0094 (r3) 
    80026528 d0030098        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x0098 (r3) 
    8002652c 9083009c         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x009C (r3) 
    80026530 d00300a0        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x00A0 (r3) 
    80026534 908300a4         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x00A4 (r3) 
    80026538 d00300a8        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x00A8 (r3) 
    8002653c 908300ac         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x00AC (r3) 
    80026540 d00300b0        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x00B0 (r3) 
    80026544 908300b4         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x00B4 (r3) 
    80026548 d00300b8        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x00B8 (r3) 
    8002654c 908300bc         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x00BC (r3) 
    80026550 d00300c0        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x00C0 (r3) 
    80026554 908300c4         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x00C4 (r3) 
    80026558 d00300c8        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x00C8 (r3) 
    8002655c 908300cc         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x00CC (r3) 
    80026560 d00300d0        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x00D0 (r3) 
    80026564 908300d4         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x00D4 (r3) 
    80026568 d00300d8        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x00D8 (r3) 
    8002656c 908300dc         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x00DC (r3) 
    80026570 d00300e0        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x00E0 (r3) 
    80026574 908300e4         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x00E4 (r3) 
    80026578 d00300e8        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x00E8 (r3) 
    8002657c 908300ec         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x00EC (r3) 
    80026580 d00300f0        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x00F0 (r3) 
*   80026584 48000054          _ZN11Interpreter2bxE17UGeckoInstruction b    ->0x800265D8
    80026588 20060014      _ZN11Interpreter6subficE17UGeckoInstruction subfic   r0, r6, 20 
    8002658c 2c060014        _ZN11Interpreter4cmpiE17UGeckoInstruction cmpwi    r6, 20 
    80026590 7c0903a6       _ZN11Interpreter5mtsprE17UGeckoInstruction mtctr    r0 
    80026594 40800014         _ZN11Interpreter3bcxE17UGeckoInstruction bge- ->0x800265A8 
    80026598 90850074         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x0074 (r5) 
    8002659c d0050078        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x0078 (r5) 
    800265a0 38a50008        _ZN11Interpreter4addiE17UGeckoInstruction addi r5, r5, 8 
    800265a4 4200fff4         _ZN11Interpreter3bcxE17UGeckoInstruction bdnz+    ->0x80026598 
    800265a8 38800000        _ZN11Interpreter4addiE17UGeckoInstruction li   r4, 0 
    800265ac 98830038         _ZN11Interpreter3stbE17UGeckoInstruction stb  r4, 0x0038 (r3) 
    800265b0 380000ff        _ZN11Interpreter4addiE17UGeckoInstruction li   r0, 255 
    800265b4 98030114         _ZN11Interpreter3stbE17UGeckoInstruction stb  r0, 0x0114 (r3) 
    800265b8 c00286cc         _ZN11Interpreter3lfsE17UGeckoInstruction lfs  f0, -0x7934 (rtoc) 
    800265bc d0030068        _ZN11Interpreter4stfsE17UGeckoInstruction stfs f0, 0x0068 (r3) 
    800265c0 9083006c         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x006C (r3) 
    800265c4 90830118         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x0118 (r3) 
    800265c8 90830030         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x0030 (r3) 
    800265cc 90830034         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x0034 (r3) 
    800265d0 9083003c         _ZN11Interpreter3stwE17UGeckoInstruction stw  r4, 0x003C (r3) 
    800265d4 4e800020       _ZN11Interpreter5bclrxE17UGeckoInstruction blr   
800265d8:
    800265d8 54c01838     _ZN11Interpreter7rlwinmxE17UGeckoInstruction rlwinm   r0, r6, 3, 0, 28 (1fffffff) 
    800265dc 7ca30214        _ZN11Interpreter4addxE17UGeckoInstruction add  r5, r3, r0 
*   800265e0 4bffffa8          _ZN11Interpreter2bxE17UGeckoInstruction b    ->0x80026588 
    800265e4 4e800020       _ZN11Interpreter5bclrxE17UGeckoInstruction blr   

@shuffle2
Copy link
Contributor

It's likely to happen on tail calls and no-return code sequences (and shared function chunks, but I don't think it's common in gc-compiler-land). However the current implementation doesn't really protect against this anyways.
I would like to compare success rate of signature creation/matching before and after this change. I will get to it eventually, or if you do it first, that would be nice :)

Sonicadvance1 added a commit that referenced this pull request Jun 6, 2014
PPCAnalyst now detects internal branches better
@Sonicadvance1 Sonicadvance1 merged commit db08f7b into dolphin-emu:master Jun 6, 2014
@JMC47
Copy link
Contributor

JMC47 commented Jun 10, 2014

This commit is causing abnormally long boot times in games. Could we get a fix, or if it will take a while, a revert until it's fixed. It's a bit ridiculous to be waiting nearly 20 seconds for game to start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants