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

[JIT] Cleanup, share more code between x86 and x64 in genAllocLclFrame #76647

Closed
wants to merge 2 commits into from

Conversation

TIHan
Copy link
Contributor

@TIHan TIHan commented Oct 5, 2022

Description
I'm in the process of getting familiar with our xarch codegen/emitter. Am trying to wrap my head around the differences between x86 and x64 for stack pointers - noticed that the two could share a little bit more logic in genAllocLclFrame.

This change is purely cleanup and should produce zero diffs.

Acceptance Criteria

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Oct 5, 2022
@ghost ghost assigned TIHan Oct 5, 2022
@ghost
Copy link

ghost commented Oct 5, 2022

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

Description
I'm in the process of getting familiar with our xarch codegen/emitter. Am trying to wrap my head around the differences between x86 and x64 for stack pointers - noticed that the two could share a little bit more logic in genAllocLclFrame.

This change is purely cleanup and should produce zero diffs.

Acceptance Criteria

  • No Diffs
Author: TIHan
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@TIHan
Copy link
Contributor Author

TIHan commented Oct 5, 2022

@dotnet/jit-contrib is ready @BruceForstall PTAL

@TIHan TIHan changed the title Cleanup, share more code between x86 and x64 in genAllocLclFrame [JIT] Cleanup, share more code between x86 and x64 in genAllocLclFrame Oct 5, 2022
@BruceForstall BruceForstall self-requested a review October 6, 2022 16:46
Copy link
Member

@BruceForstall BruceForstall left a comment

Choose a reason for hiding this comment

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

Hmmm... While this reduces a little code duplication, I don't think it helps code readability -- you've gone from 3 #ifdef/#else/#endif lines to 7. It seems like the logic flow is thus more complicated to understand.

@ghost ghost added the needs-author-action An issue or pull request that requires more info or actions from the author. label Oct 6, 2022
@TIHan
Copy link
Contributor Author

TIHan commented Oct 7, 2022

@BruceForstall - I do agree it seems a little more complicated, but on the other hand it's clearer to know what the differences are between x86/x64. I will close the PR as I don't think much else could be done.

@TIHan TIHan closed this Oct 7, 2022
@markples
Copy link
Member

markples commented Oct 7, 2022

I think you can potentially iterate on this. A typical way to simplify the code (could be used with or without your PR) is to add abstractions for the complexity - likely function calls in this case. The key point is probably whether those function calls can have good abstraction value ((DoXXX, code, DoYYY) vs (Helper1, code, Helper2)). You've basically regrouped the code by moving it around - does this make it easier or harder to add good abstractions? For example, is the original large TARGET_X86 a good functional unit, do the new separate ones work better, or is it somewhere in between?

Looking at your PR code, one could ask

  • first ifdef - maybe make a helper PublishStubParam() or ConsiderStubParam()?
  • there's a section about stack probes. maybe that (even the code that is always the same) can be factored out?
  • but why is that initReg stuff in the middle of the stack probe - does it make sense it move it out so the stack probe stuff is one block?
  • oh wait, there's more with stub param, so PublishStubParam() above isn't good enough. Ok, how do the two sections relate - is there good naming that can reflect that?

The ideal would be that you can get this function to basically straight-line code that can be reasoned about without looking at the helpers. Then the helpers can individually be read. Then it's simpler. If you have to read the helpers' implementations in order to understand the main code, then it's more complicated.

Please note that this isn't a prescription for how to rewrite the code but the beginning of a thought process for how you could continue. It should raise more questions than it answers. And at some point, one of them could be "is the cleanup worth the effort?"

@TIHan
Copy link
Contributor Author

TIHan commented Oct 7, 2022

You've basically regrouped the code by moving it around - does this make it easier or harder to add good abstractions?

Part of the issue is that I do not fully understand what was written, so it's hard to make a judgement call around building an abstraction. I based the cleanup only by looking at what was the same. I could create functions that can wrap the specific functionality, but my primary goal was being able to see the differences between the archs.

I didn't want to spend more time on this cleanup, but I will try to look at it again - so I'll re-open it.

@TIHan TIHan reopened this Oct 7, 2022
@ghost ghost removed the needs-author-action An issue or pull request that requires more info or actions from the author. label Oct 7, 2022
@BruceForstall
Copy link
Member

@TIHan Please change this to "Draft" (or close) if you aren't actively working on it.

@TIHan TIHan marked this pull request as draft November 14, 2022 17:26
@ghost ghost closed this Dec 14, 2022
@ghost
Copy link

ghost commented Dec 14, 2022

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

@ghost ghost locked as resolved and limited conversation to collaborators Jan 14, 2023
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants