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

has vtable analysis #850

Merged
merged 1 commit into from Jul 25, 2017
Merged

has vtable analysis #850

merged 1 commit into from Jul 25, 2017

Conversation

photoszzt
Copy link
Contributor

Fix #765 r? @fitzgen

@highfive
Copy link

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @fitzgen (or someone else) soon.

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

Awesome :)

Just a few nitpicks to address before we land this; see below.

Thanks @photoszzt !

};

// Migrate this comment from the original has_vtable in ty.rs
// FIXME: Can we do something about template parameters? Huh...
Copy link
Member

Choose a reason for hiding this comment

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

Let's replace this comment with:

// TODO #851: figure out a way to handle deriving from template type parameters.

src/ir/derive.rs Outdated
fn can_derive_default(&self,
ctx: &BindgenContext,
fn can_derive_default(&'a self,
ctx: &'a BindgenContext,
Copy link
Member

Choose a reason for hiding this comment

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

These references shouldn't be 'a; that should just be for Self::Extra's use. Unless they're required and I'm missing why...

src/ir/comp.rs Outdated
/// Do we see a virtual function during parsing?
/// Get the has_vtable boolean.
pub fn get_has_vtable(&self) -> bool {
return self.has_vtable;
Copy link
Member

Choose a reason for hiding this comment

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

Let's rename these to fn has_own_virtual_method and self.has_own_virtual_method to make it more clear that we are not walking the inheritance DAG.

src/ir/ty.rs Outdated

fn has_vtable(&self, ctx: &BindgenContext, itemid: &ItemId) -> bool {
ctx.lookup_item_id_has_vtable(itemid)
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm on the edge... do you think this trait and these impls are carrying their weight? I guess I like the Item and ItemId impls, but this one seems pretty shaky to me...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the ItemId and Item one doesn't get used. The has_vtable is called on Ty in the codegen/mod.rs inside the impl CodeGenerator for CompInfo. needs_explicit_vtable in CompInfo and is_unsized in Ty and CompInfo also call the has_vtable. I think for Ty and CompInfo, calling lookup_item_id_has_vtable directly might be better. But if we want to keep the same interface for all the types, I'm also fine with that

Copy link
Member

Choose a reason for hiding this comment

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

Right -- anyone calling this impl could (doesn't mean that they are now, but they could) just call the Item or ItemId impl and it would be cleaner than the hoops being jumped through here.

Yeah, I've convinced myself: let's remove the HasVtable impls for everything except Item and ItemId.

Self::consider_edge(edge_kind) {
dependencies.entry(sub_item)
.or_insert(vec![])
.push(item);
Copy link
Member

Choose a reason for hiding this comment

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

Want to do a follow up PR to pull the creation of the dependencies graph out and share its definition between all of our analyses? This is getting copied with slight changes a little too much now, and its clear we need a helper function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure.

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

Looks great! 👍

@fitzgen
Copy link
Member

fitzgen commented Jul 25, 2017

@bors-servo r+

@fitzgen
Copy link
Member

fitzgen commented Jul 25, 2017

@bors r+

@fitzgen
Copy link
Member

fitzgen commented Jul 25, 2017

Ok, manually merging for now.

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

Successfully merging this pull request may close these issues.

None yet

3 participants