-
Notifications
You must be signed in to change notification settings - Fork 738
Add a phase that removes ResolvedTypeRefs before codegen #534
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
If you want to pick this up, leave a comment and I can assign you :) |
Hey Nick! (How are you?!) I've been learning Rust and this looks really interesting. I'd be down to take a stab :) |
Great! Let me know if you have any questions or anything like that. I just realized that fully removing
should become:
The core of this new phase should look something like this pseudo code: impl BindgenContext {
// ...
fn flatten_resolved_type_ref(&mut self) {
for (id, item) in self.items {
if item is a resolved type ref {
self.flatten_one_resolved_type_ref(id);
}
}
}
// Recursively walk the chain of ResolvedTypeRefs and flatten it as we
// come back out of the recursion.
fn flatten_one_resolved_type_ref(&mut self, id: ItemId) -> ItemId {
if id's item is a resolved type ref {
let final_referenced_id = self.flatten_one_resolved_type_ref(item's referenced type);
item's referenced type = final_referenced_id;
final_referenced_id
} else {
id
}
}
// ...
} Bonus points for keeping a debug-only set of items we've walked in the recursive function and asserting that we don't get a cycle :) See https://github.com/servo/rust-bindgen/blob/master/src/ir/item.rs#L69-L87 |
(Also, woah! Hey! Didn't read your username very carefully, at first! :-P) |
I have an issue with this, and is that this would lose the constness information, which we do use for code generation. |
Crap, I forgot about that. It would be great if we separated the concept of a resolved type reference from a @samliu interested in this prerequisite groundwork? |
Definitely!
…On Feb 22, 2017 7:44 AM, "Nick Fitzgerald" ***@***.***> wrote:
I have an issue with this, and is that this would lose the constness
information, which we do use for code generation.
Crap, I forgot about that. It would be great if we separated the concept
of a resolved type reference from a const <type>, then we could move
forward here.
@samliu <https://github.com/samliu> interested in this prerequisite
groundwork?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#534 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAIS_T9m-04rdhW-glpN8zWbTZbxX0e6ks5rfFf1gaJpZM4MHk79>
.
|
As an idea, we probably want to call this something like struct Qualifiers {
is_const: bool,
}
struct QualifiedType {
ty: ItemId,
qualifiers: Qualifiers,
} |
Yep, exactly what I was imagining! It will also need to be |
(And there would be a new |
Why would that be needed? We only care about qualifiers in top-level types, right? I.e., Am I missing something? |
With top-level types, I mean in the stuff that holds from |
I don't understand the distinction you are trying to make, sorry if I'm being thick... |
Aha, I see where our imaginations are diverging. I would imagine
|
Right, I was imagining making
WDYT? I think representing a struct field like: struct foo {
const struct bar* const bar_field;
}; As:
where:
Is more appealing than using the already arguably somewhat bloated |
Ok, yeah that sounds well-motivated. |
@samliu any progress? any questions I can help answer? :) |
Sorry no progress :( haven't had time to get to this, out of town past two
weekends.
What is a good timeline for addressing issues? I definitely want to do this
but probably need to prioritize better.
…On Mon, Mar 6, 2017 at 10:16 AM, Nick Fitzgerald ***@***.***> wrote:
@samliu <https://github.com/samliu> any progress? any questions I can
help answer? :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#534 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAIS_djT-OVgvS41bTkY8CI5T7FBge_Pks5rjE2ZgaJpZM4MHk79>
.
|
No worries! There's no rush with this, so as long as you still plan on tackling it, we can keep it assigned. If for whatever reason you don't want to or can't work on this anymore, then we can unassign and let someone else grab it. |
Thanks Nick. I'll do my best to make progress in a timely fashion
nonetheless, or give it up if I can't commit to that anymore.
…On Mar 6, 2017 10:51 AM, "Nick Fitzgerald" ***@***.***> wrote:
No worries!
There's no rush with this, so as long as you still plan on tackling it, we
can keep it assigned. If for whatever reason you don't want to or can't
work on this anymore, then we can unassign and let someone else grab it.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#534 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAIS_Q_coMCsHuok11vPmaI_jQO4kj6Pks5rjFWlgaJpZM4MHk79>
.
|
Was just about to report this (more precisely, #511), but looks like a known issue. Is there anything I could help with? |
@RReverser if you wanted to pick this up, I think that's fine, given that there's been silence for a while. @samliu you're not still planning on doing this, are you? |
Sorry yeah I won't be able to get to this :( feel free to reassign
…On Jul 27, 2017 10:26 AM, "Nick Fitzgerald" ***@***.***> wrote:
@RReverser <https://github.com/rreverser> if you wanted to pick this up,
I think that's fine, given that there's been silence for a while.
@samliu <https://github.com/samliu> you're not still planning on doing
this, are you?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#534 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAIS_efYnSN0QZ9Z9FD9HDpZEPnx2W_1ks5sSMhMgaJpZM4MHk79>
.
|
Ever since we got the graphviz visualizations of our IR graph, it has become immediately clear that we have a TON of
ResolvedTypeRef
s all over the place. In fact, 8 out of 15 IR items (more than half!) areResolvedTypeRef
s in this example I happen to be looking at:A pass over the IR items where we replace all references to
ResolvedTypeRef
s with references to the type being transitively referenced via theResolvedTypeRef
would probably give us speed ups in codegen and analysis, because we wouldn't have to look at useless items anymore. It would also make looking at these graphs easier, since there would be less visual noise :-PA good time to do this would be in
ir::context::BindgenContext::gen
, after we resolve unresolved type refs inresolve_typerefs
. https://github.com/servo/rust-bindgen/blob/master/src/ir/context.rs#L529I can mentor whoever would like to take a stab at this.
The text was updated successfully, but these errors were encountered: