Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Track frame layout changes. (cont.d) #1204

Merged
merged 10 commits into from
Nov 18, 2019

Conversation

iximeow
Copy link
Collaborator

@iximeow iximeow commented Nov 6, 2019

  • This has been discussed in issue #..., or if not, please tell us why
    here.
  • A short description of what this does, why it is needed; if the
    description becomes long, the matter should probably be discussed in an issue
    first.
  • This PR contains test cases, if meaningful.
  • A reviewer from the core maintainer team has been assigned for this PR.
    If you don't know who could review this, please indicate so and/or ping
    bnjbvr. The list of suggested reviewers on the right can help you.

Continuation of #679 as Yury asked I open a new PR from my fork.

This PR teaches cranelift-codegen to track changes to a call frame layout, on top of which we can generate unwind and debug information (as done in #902)

@bnjbvr you were looking at this most recently in #679, so I figure you might be most interested in reviewing?

@bnjbvr bnjbvr self-requested a review November 6, 2019 10:19
@bnjbvr
Copy link
Member

bnjbvr commented Nov 6, 2019

Yes, I'll be looking at it since it's still fresh in my mind. Thanks for picking this up!

Copy link
Member

@bnjbvr bnjbvr left a comment

Choose a reason for hiding this comment

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

Looking great, mostly nits here, so approving. Thanks for continuing this!

Please make sure to squash before landing.

.and_modify(|insts| {
*insts = insts
.into_iter()
.map(|x| *x)
Copy link
Member

Choose a reason for hiding this comment

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

Can this be replaced with a .clone()?

cfa_state.current_depth += word_size;
cfa_state.cf_ptr_offset -= word_size;
// And now that we're going to overwrite `rbp`, `rsp` is the only way to get to the call frame.
cfa_state.cf_ptr_reg = RU::rsp as RegUnit;
Copy link
Member

Choose a reason for hiding this comment

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

I feel I've asked this before, but: don't we need to "publish" the changes as FrameLayoutChange here? (and below when popping out nonvolatile regs)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We do need to record the layout change here, and do just that. It's definitely not immediately obvious since tracks frame layout after pop rbp but isn't applied until popping other registers.

I added some comments to try clarifying this for future readers.

}

/// Set of frame layout changes.
pub type FrameLayoutChanges = Box<[FrameLayoutChange]>;
Copy link
Member

Choose a reason for hiding this comment

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

I guess we need data in the first place, but I wonder if using a SmallVec here wouldn't be as efficient and as simple. This looks a bit like premature optimization, since as far as I recall there's no good justification of it being a problem or causing too many allocations. We can let it as is right now, but using the simplest thing first and then revisiting it if it's a problem would be a better strategy.

@iximeow
Copy link
Collaborator Author

iximeow commented Nov 18, 2019

Looking great, mostly nits here, so approving. Thanks for continuing this!

Emphasis mine, on the part I missed when I saw the notification last week :) Another small round of tweaks in line with comments.

@bnjbvr if #1204 (comment) and the comments referenced there read well to you I'll squash, merge, and get back to #902!

Copy link
Contributor

@bjorn3 bjorn3 left a comment

Choose a reason for hiding this comment

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

Just some nits.

@bjorn3
Copy link
Contributor

bjorn3 commented Nov 18, 2019

@iximeow Tip: If you switch to the "files changed" tab, you can queue multiple suggestions to be committed together in a single commit.

@iximeow
Copy link
Collaborator Author

iximeow commented Nov 18, 2019

Ah that would have been good, I was wondering about that.. thanks.

@iximeow iximeow merged commit 70ccd91 into bytecodealliance:master Nov 18, 2019
@iximeow iximeow deleted the frame-layout branch November 18, 2019 18:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants