Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
c02e938 to
2f62830
Compare
CodSpeed Instrumentation Performance ReportMerging #9969 will not alter performanceComparing Summary
|
2f62830 to
6711ae3
Compare
Boshen
left a comment
There was a problem hiding this comment.
I'll try and replace Rolldown's adhoc TakeIn trait with ours. Please let me know when.
d3ea17d to
8c4fd76
Compare
|
@Boshen I think this is ready. It's slightly different from Rolldown's version in that Rolldown implements Where they do |
This comment was marked as outdated.
This comment was marked as outdated.
|
Done in https://github.com/rolldown/rolldown/compare/next-oxc?expand=1 @overlookmotel merge after merge conflict. |
8c4fd76 to
24b0e8a
Compare
Merge activity
|
Add 2 traits and implement them for AST types: * `Dummy` trait creates a dummy node for an AST type. * `TakeIn` replaces a node with a dummy. Reason for 2 separate traits is that for some types we need to implement `Dummy`, but it'd be inappropriate to implement `TakeIn`. e.g.: * Fieldless enums which are `Copy`: They should just be copied, rather than replaced. * `Span`: Ditto. * `Box<T>`: You should replace the *contents* of the `Box`, not the `Box` itself. Ideally we wouldn't be implementing `TakeIn` for so many types. Some types are very expensive to generate a dummy for, so we'd ideally guide consumers away from that by not implementing `TakeIn` for those types. But we want to replace the `TakeIn` trait in Rolldown with our own version. Because Rolldown implements `TakeIn` on many many types, it seemed to make sense to codegen `TakeIn` for pretty much all AST types, so we can migrate their code over to using our trait without too much hassle.
24b0e8a to
8cd7430
Compare
`AstBuilder::move_*` methods use `TakeIn::take_in` (added in #9969) to replace nodes with dummy nodes. `take_in` will always generate a dummy in whatever way minimizes the size and number of allocations required. It would be possible to replace all the `move_*` methods with a single `AstBuilder::take` method which is generic over `T: TakeIn` (#9970). But have opted not to do that, because it's useful to be able to see in calling code what type of node is being replaced. Some nodes are quite expensive to create a dummy for (e.g. `Declaration` and `Function` require allocating 56 bytes into arena, `ArrowFunctionExpression` allocates 128 bytes in 2 separate allocations), so it's useful to see where we're doing that, so we can try to replace them with cheaper operations e.g. replacing an `Expression` or `Statement` instead (only 8 bytes). We also want to avoid inadvertently adding further expensive `take_in` calls, which a blanket `AstBuilder::take` method would make it easy to do.

Add 2 traits and implement them for AST types:
Dummytrait creates a dummy node for an AST type.TakeInreplaces a node with a dummy.Reason for 2 separate traits is that for some types we need to implement
Dummy, but it'd be inappropriate to implementTakeIn. e.g.:Copy: They should just be copied, rather than replaced.Span: Ditto.Box<T>: You should replace the contents of theBox, not theBoxitself.Ideally we wouldn't be implementing
TakeInfor so many types. Some types are very expensive to generate a dummy for, so we'd ideally guide consumers away from that by not implementingTakeInfor those types.But we want to replace the
TakeIntrait in Rolldown with our own version. Because Rolldown implementsTakeInon many many types, it seemed to make sense to codegenTakeInfor pretty much all AST types, so we can migrate their code over to using our trait without too much hassle.