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

Refactor layout to store offsets of fields, not offsets after fields #36904

Merged
merged 1 commit into from Oct 3, 2016

Conversation

Projects
None yet
6 participants
@camlorn
Contributor

camlorn commented Oct 2, 2016

This is the next PR moving us towards being able to reorder struct fields.

The old code implicitly stored the offset of the first field. This is inadequate because the first field may no longer be offset 0 in future. This PR refactors layout to use a offsets vector instead of a offset_after_field vector.

@rust-highfive

This comment has been minimized.

Show comment
Hide comment
@rust-highfive

rust-highfive Oct 2, 2016

Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

Collaborator

rust-highfive commented Oct 2, 2016

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@camlorn

This comment has been minimized.

Show comment
Hide comment
@camlorn

camlorn Oct 2, 2016

Contributor

@mark-buer
Probably, but I'm not concerned with that here unless those functions end up being broken.

The small vector optimization isn't about that struct, it's about avoiding a heap allocation in the compiler itself in some cases. I don't think it's worth it, unless someone adds something to the compiler that can be used in all cases where small vector optimization might be beneficial.

Contributor

camlorn commented Oct 2, 2016

@mark-buer
Probably, but I'm not concerned with that here unless those functions end up being broken.

The small vector optimization isn't about that struct, it's about avoiding a heap allocation in the compiler itself in some cases. I don't think it's worth it, unless someone adds something to the compiler that can be used in all cases where small vector optimization might be beneficial.

@camlorn

This comment has been minimized.

Show comment
Hide comment
@camlorn

camlorn Oct 2, 2016

Contributor

Also, I should clarify: this isn't quite finalized yet.

Contributor

camlorn commented Oct 2, 2016

Also, I should clarify: this isn't quite finalized yet.

@eddyb

This looks great! I only had nits & minor extra cleanups to mention.

Show outdated Hide outdated src/librustc/ty/layout.rs
Show outdated Hide outdated src/librustc/ty/layout.rs
Show outdated Hide outdated src/librustc/ty/layout.rs
Show outdated Hide outdated src/librustc_trans/glue.rs
@camlorn

This comment has been minimized.

Show comment
Hide comment
@camlorn

camlorn Oct 2, 2016

Contributor

I mixed up the SVO FIXME comments. My bad.

Is the small vector optimization anywhere outside layout? It seems to me that the way to fix this is to write something that implements a subset of Vec's API if we want it.

Contributor

camlorn commented Oct 2, 2016

I mixed up the SVO FIXME comments. My bad.

Is the small vector optimization anywhere outside layout? It seems to me that the way to fix this is to write something that implements a subset of Vec's API if we want it.

@camlorn

This comment has been minimized.

Show comment
Hide comment
@camlorn

camlorn Oct 2, 2016

Contributor

The first set of review comments should be incorporated. I squashed the history as well, so it's one commit.

Think all that's maybe left is formatting.

Contributor

camlorn commented Oct 2, 2016

The first set of review comments should be incorporated. I squashed the history as well, so it's one commit.

Think all that's maybe left is formatting.

@eddyb

eddyb approved these changes Oct 2, 2016

@eddyb

This comment has been minimized.

Show comment
Hide comment
@eddyb

eddyb Oct 2, 2016

Member

@bors r+

Member

eddyb commented Oct 2, 2016

@bors r+

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Oct 2, 2016

Contributor

📌 Commit 9482bce has been approved by eddyb

Contributor

bors commented Oct 2, 2016

📌 Commit 9482bce has been approved by eddyb

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Oct 2, 2016

Contributor

⌛️ Testing commit 9482bce with merge 1cdc0fb...

Contributor

bors commented Oct 2, 2016

⌛️ Testing commit 9482bce with merge 1cdc0fb...

bors added a commit that referenced this pull request Oct 2, 2016

Auto merge of #36904 - camlorn:field_offsets_refactor, r=eddyb
Refactor layout to store offsets of fields, not offsets after fields

This is the next PR moving us towards being able to reorder struct fields.

The old code implicitly stored the offset of the first field.  This is inadequate because the first field may no longer be offset 0 in future.  This PR refactors `layout` to use a `offsets` vector instead of a `offset_after_field` vector.

@bors bors merged commit 9482bce into rust-lang:master Oct 3, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

@camlorn camlorn deleted the camlorn:field_offsets_refactor branch Oct 3, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment