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

Compute sizedness with a fixed-point analysis #1102

Merged
merged 3 commits into from Oct 25, 2017

Conversation

Projects
None yet
4 participants
@fitzgen
Copy link
Member

fitzgen commented Oct 25, 2017

This fixes a couple bugs where we weren't properly adding an _address byte. It also helps pave the way for computing implicit fields (such as padding, _address, vtable pointers, etc) in its own pass, before codegen.

Fixes #768

r? @pepyakin

@pepyakin
Copy link
Contributor

pepyakin left a comment

looks great!

}

TypeKind::ObjCInterface(..) => {
trace!(" I guess obj-c interfaces are not zero-sized?");

This comment has been minimized.

@pepyakin

pepyakin Oct 25, 2017

Contributor

FWIW, as far as I know, every obj-c "interface" have an isa pointer.

This comment has been minimized.

@fitzgen

fitzgen Oct 25, 2017

Author Member

Cool, I'll note this. FWIW, I was just copying existing behavior.

trace!(" comp considers its own fields and bases");

if !info.fields().is_empty() {
return self.insert(id, SizednessResult::NonZeroSized);

This comment has been minimized.

@pepyakin

pepyakin Oct 25, 2017

Contributor

But what if all fields are zero sized 🤔 ?

This comment has been minimized.

@fitzgen

fitzgen Oct 25, 2017

Author Member

They can't be, because of the every-object-must-be-addressable rules. Only base members can truly be zero sized, because its the "same" object.

This comment has been minimized.

@fitzgen

fitzgen Oct 25, 2017

Author Member

That is, with

struct Empty {};

struct Inherits : public Empty {
    int x;
};

struct Contains {
    Empty empty;
    int x;
};

sizeof(Contains) is one greater than sizeof(Inherits)

This comment has been minimized.

@pepyakin

pepyakin Oct 25, 2017

Contributor

yeah, makes sense. Thank you!

@fitzgen

This comment has been minimized.

Copy link
Member Author

fitzgen commented Oct 25, 2017

Thanks for the review @pepyakin !

Compute sizedness with a fixed-point analysis
This fixes a couple bugs where we weren't properly adding an `_address`
byte. It also helps pave the way for computing implicit fields (such as padding,
`_address`, vtable pointers, etc) in its own pass, before codegen.

Fixes #768

@fitzgen fitzgen force-pushed the fitzgen:sizedness branch from e7622f9 to 379bb16 Oct 25, 2017

@fitzgen

This comment has been minimized.

Copy link
Member Author

fitzgen commented Oct 25, 2017

I added that example, and another for arrays of zero-sized types, as tests.

Thanks again for review @pepyakin !

@bors-servo r=pepyakin

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo commented Oct 25, 2017

📌 Commit d018f42 has been approved by pepyakin

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo commented Oct 25, 2017

⌛️ Testing commit d018f42 with merge 88a1e24...

bors-servo added a commit that referenced this pull request Oct 25, 2017

Auto merge of #1102 - fitzgen:sizedness, r=pepyakin
Compute sizedness with a fixed-point analysis

This fixes a couple bugs where we weren't properly adding an `_address` byte. It also helps pave the way for computing implicit fields (such as padding, `_address`, vtable pointers, etc) in its own pass, before codegen.

Fixes #768

r? @pepyakin
@fitzgen

This comment has been minimized.

Copy link
Member Author

fitzgen commented Oct 25, 2017

Added one more test for arrays of zero elements and flexible arrays also.

@bors-servo r=pepyakin

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo commented Oct 25, 2017

📌 Commit fd7afb6 has been approved by pepyakin

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo commented Oct 25, 2017

⌛️ Testing commit fd7afb6 with merge 1cb1101...

bors-servo added a commit that referenced this pull request Oct 25, 2017

Auto merge of #1102 - fitzgen:sizedness, r=pepyakin
Compute sizedness with a fixed-point analysis

This fixes a couple bugs where we weren't properly adding an `_address` byte. It also helps pave the way for computing implicit fields (such as padding, `_address`, vtable pointers, etc) in its own pass, before codegen.

Fixes #768

r? @pepyakin
@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo commented Oct 25, 2017

☀️ Test successful - status-travis
Approved by: pepyakin
Pushing 1cb1101 to master...

@bors-servo bors-servo merged commit fd7afb6 into rust-lang:master Oct 25, 2017

2 checks passed

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

bors-servo added a commit that referenced this pull request Oct 30, 2017

Auto merge of #1119 - pepyakin:derive-partialeq-partialord-refactorin…
…g, r=emilio

Simple refactoring of derive_partialeq_or_partialord

Just simple refactoring with some tricks from #1102

r? @fitzgen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.