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

IR Interpreter #8725

Merged
merged 82 commits into from
May 14, 2016
Merged

IR Interpreter #8725

merged 82 commits into from
May 14, 2016

Conversation

hrydgard
Copy link
Owner

@hrydgard hrydgard commented May 8, 2016

So, this is different from the previous one that used MIPS instructions as an IR directly.

This translates code into a fast-to-interpret and easy-to-analyze IR (intermediate representation). Gets rid of delay slots and other MIPS silliness (though there's a small wart with "likely" branch instructions) while still keeping the MIPS register set and semantics, mostly. It then optimizes and caches these blocks like the real JITs and executes them.

This new IR should also suitable as a first step for things like more proper full-function compilation, SSA, etc. you'd probably want to first use this translator, run the constant propagation pass, then link multiple of these blocks together and lift into an AST, transform that into SSA, perform more optimizations and then do register allocation and code generation. Or something simpler :)

Anyhow, this is around 50% faster than the current interpreter already, so will be useful for non-JIT platforms like iOS, even if no more advanced compilation is done.

It's completely missing things like CPU floating point rounding mode for now.


// Let's try that one more time. We won't get back here because we toggled the value.
js.startDefaultPrefix = false;
// TODO ARM64: This crashes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it still? I think we want this, both here and in arm64jit.

-[Unknown]

Copy link
Owner Author

Choose a reason for hiding this comment

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

Hmm, yeah, we do. Have not tried recently on ARM64.

@unknownbrackets
Copy link
Collaborator

I wonder. For this sequence:

088b2f54   divu t0, a2
088b2f58   beql a2, zero, ->$088b2f60
088b2f5c   break  --- unknown ---

Maybe we could just pretend there was no beql at all? It can be relatively common, and it's just skipping the break when the divisor is non zero.

-[Unknown]

@hrydgard
Copy link
Owner Author

@unknownbrackets yes that should be safe. We could even do it before the IR to not have to create a new block, although ideally future multi-block compilation will optimize it away.

@hrydgard
Copy link
Owner Author

Thanks for the fixes @unknownbrackets , I'll merge this later today after a few more changes.

Should get around to fixing the rounding as well, as this will produce broken saves in God Eater etc...

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.

3 participants