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

fix(transformer/decorator): decoration disappear due to incorrect statement address #9062

Conversation

Dunqing
Copy link
Member

@Dunqing Dunqing commented Feb 12, 2025

close: #9058
close: #9129

Copy link
Member Author

Dunqing commented Feb 12, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

Copy link

codspeed-hq bot commented Feb 12, 2025

CodSpeed Performance Report

Merging #9062 will not alter performance

Comparing 02-12-fix_transformer_decorator_decoration_disappear_due_to_incorrect_statement_address (bad08cf) with main (cf969e2)

Summary

✅ 33 untouched benchmarks

@Dunqing Dunqing changed the base branch from 02-12-feat_transformer_statement-injector_add_a_series_of_insert___before_after_current_statement_methods to graphite-base/9062 February 16, 2025 03:09
@Dunqing Dunqing force-pushed the 02-12-fix_transformer_decorator_decoration_disappear_due_to_incorrect_statement_address branch from 27b2fe4 to 0abf0d8 Compare February 16, 2025 03:09
@Dunqing Dunqing changed the base branch from graphite-base/9062 to main February 16, 2025 03:09
@Boshen Boshen added the P-high Priority - High label Feb 20, 2025
@overlookmotel overlookmotel force-pushed the 02-12-fix_transformer_decorator_decoration_disappear_due_to_incorrect_statement_address branch from 0abf0d8 to cac5d47 Compare February 21, 2025 10:47
Copy link
Contributor

@overlookmotel overlookmotel left a comment

Choose a reason for hiding this comment

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

I rebased on latest main to fix merge conflicts and tidied up whitespace in test fixtures, but made no substantive changes. I'll follow up with a couple of style nit things in separate PRs.

@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Feb 21, 2025
Copy link
Contributor

overlookmotel commented Feb 21, 2025

Merge activity

  • Feb 21, 5:59 AM EST: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Feb 21, 5:59 AM EST: A user added this pull request to the Graphite merge queue.
  • Feb 21, 6:03 AM EST: A user merged this pull request with the Graphite merge queue.

@graphite-app graphite-app bot force-pushed the 02-12-fix_transformer_decorator_decoration_disappear_due_to_incorrect_statement_address branch from cac5d47 to bad08cf Compare February 21, 2025 10:59
@graphite-app graphite-app bot merged commit bad08cf into main Feb 21, 2025
26 checks passed
@graphite-app graphite-app bot deleted the 02-12-fix_transformer_decorator_decoration_disappear_due_to_incorrect_statement_address branch February 21, 2025 11:03
@overlookmotel
Copy link
Contributor

@Dunqing You were not keen on passing stmt_address as a param into transform_class_impl and transform_class_declaration_without_class_decorators.

A way to avoid that would be to record the Address as self.stmt_address, and then pull that value out of self again in transform_class_declaration_without_class_decorators.

But personally I think the way you have it now is good. The call chain is short, these functions have few parameters, and those params are all small (8 bytes each). So probably stmt_address just stays in a register the whole time. That's more efficient than writing to self.stmt_address, which would definitely incur a memory write every time.

It makes very little difference either way - this is micro-optimization stuff - but just mentioning it as you said you didn't like passing it as a param.

graphite-app bot pushed a commit that referenced this pull request Feb 21, 2025
…ess::address` (#9264)

Follow-on after #9062. Pure refactor.

In all these cases, `class` / `export` is a `Box`, so we can use `class.address()` to get the address, instead of `Address::from_ptr(class.as_ref())`.

These 2 both do exactly the same thing, but personally I think it's preferable to avoid `Address::from_ptr` where we can. `Address::GetAddress` always produces a valid, permanent `Address`, whereas `Address::from_ptr` is a bit of a hack and can give you an unreliable `Address` in some cases. If we only use `Address::from_ptr` where we *have* to, it's easier to see where we have a potential sources of bugs.
graphite-app bot pushed a commit that referenced this pull request Feb 21, 2025
Follow-on after #9062. Just a small code style refactor.

Make `&mut Class` the first param of these methods, because it's the "main" input to the function. The `Address` is a less important param, so can go after it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0-merge Merge with Graphite Merge Queue A-transformer Area - Transformer / Transpiler C-bug Category - Bug P-high Priority - High
Projects
None yet
3 participants