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(compiler): closure transform generated parent_this even when not used #6531

Merged
merged 3 commits into from
May 22, 2024

Conversation

yoav-steinberg
Copy link
Contributor

This is a small code cleanup as part of addressing #4925.

We only generate the parent_this variable used in generated closure classes when needed. If the inflight closure never accesses this then we don't generated parent_this. The code avoids traversing into inner classes inside the closure when searching for this accesses, making it a bit cleaner and more efficient.

This relates to #4925 because it solves the problem of accessing this (for assignment into parent_this) before the super() call in a ctor.

Checklist

  • Title matches Winglang's style guide
  • Description explains motivation and solution
  • Tests added (always)
  • Docs updated (only required for features)
  • Added pr/e2e-full label if this feature requires end-to-end testing

By submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.

@yoav-steinberg yoav-steinberg requested a review from a team as a code owner May 22, 2024 10:26
Copy link

Thanks for opening this pull request! 🎉
Please consult the contributing guidelines for details on how to contribute to this project.
If you need any assistance, don't hesitate to ping the relevant owner over Discord.

Topic Owner
Wing SDK and utility APIs @chriscbr
Wing Console @ainvoner, @skyrpex, @polamoros
JSON, structs, primitives and collections @hasanaburayyan
Platforms and plugins @hasanaburayyan
Frontend resources (website, react, etc) @tsuf239
Language design @chriscbr
VSCode extension and language server @markmcculloh
Compiler architecture, inflights, lifting @yoav-steinberg
Wing Testing Framework @tsuf239
Wing CLI @markmcculloh
Build system, dev environment, releases @markmcculloh
Library Ecosystem @chriscbr
Documentation @hasanaburayyan
SDK test suite @tsuf239
Examples @hasanaburayyan
Wing Playground @eladcon

@monadabot
Copy link
Contributor

monadabot commented May 22, 2024

Console preview environment is available at https://wing-console-pr-6531.fly.dev 🚀

Last Updated (UTC) 2024-05-22 10:43

@monadabot
Copy link
Contributor

Benchmarks

Comparison to Baseline 🟥⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
Benchmark Before After Change
version 57ms±0.43 59ms±2.94 +2ms (+3.51%)🟥
functions_10.test.w -t sim 497ms±27.12 494ms±10.75 -3ms (-0.57%)⬜
functions_10.test.w -t tf-aws 2033ms±14.54 2041ms±7.93 +8ms (+0.38%)⬜
hello_world.test.w -t sim 402ms±4.61 406ms±11.78 +4ms (+1.05%)⬜
hello_world.test.w -t tf-aws 1426ms±10.66 1442ms±14.16 +16ms (+1.12%)⬜
functions_1.test.w -t sim 397ms±4.93 402ms±6.7 +5ms (+1.16%)⬜
functions_1.test.w -t tf-aws 817ms±5.98 825ms±6.23 +7ms (+0.9%)⬜
jsii_big.test.w -t sim 2795ms±14.64 2795ms±9.47 0ms (-0.01%)⬜
jsii_big.test.w -t tf-aws 3007ms±13.11 3016ms±11.77 +9ms (+0.3%)⬜
empty.test.w -t sim 361ms±3.93 369ms±3.8 +8ms (+2.15%)⬜
empty.test.w -t tf-aws 597ms±5.12 597ms±6.56 0ms (-0.04%)⬜
jsii_small.test.w -t sim 372ms±4.45 378ms±4.17 +6ms (+1.5%)⬜
jsii_small.test.w -t tf-aws 612ms±5.01 612ms±2.57 +0ms (+0.04%)⬜

⬜ Within 1.5 standard deviations
🟩 Faster, Above 1.5 standard deviations
🟥 Slower, Above 1.5 standard deviations

Benchmarks may vary outside of normal expectations, especially when running in GitHub Actions CI.

Results
name mean min max moe sd
version 59ms 56ms 71ms 3ms 4ms
functions_10.test.w -t sim 494ms 480ms 530ms 11ms 15ms
functions_10.test.w -t tf-aws 2041ms 2022ms 2056ms 8ms 11ms
hello_world.test.w -t sim 406ms 390ms 445ms 12ms 16ms
hello_world.test.w -t tf-aws 1442ms 1417ms 1489ms 14ms 20ms
functions_1.test.w -t sim 402ms 384ms 415ms 7ms 9ms
functions_1.test.w -t tf-aws 825ms 810ms 842ms 6ms 9ms
jsii_big.test.w -t sim 2795ms 2781ms 2825ms 9ms 13ms
jsii_big.test.w -t tf-aws 3016ms 2977ms 3044ms 12ms 16ms
empty.test.w -t sim 369ms 363ms 378ms 4ms 5ms
empty.test.w -t tf-aws 597ms 586ms 611ms 7ms 9ms
jsii_small.test.w -t sim 378ms 369ms 388ms 4ms 6ms
jsii_small.test.w -t tf-aws 612ms 607ms 619ms 3ms 4ms
Last Updated (UTC) 2024-05-22 10:38

@monadabot monadabot added the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label May 22, 2024
@yoav-steinberg yoav-steinberg removed the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label May 22, 2024
Copy link
Contributor

mergify bot commented May 22, 2024

Thanks for contributing, @yoav-steinberg! This PR will now be added to the merge queue, or immediately merged if yoav/parent_this_only_when_needed is up-to-date with main and the queue is empty.

mergify bot added a commit that referenced this pull request May 22, 2024
@mergify mergify bot merged commit 3d2aaa2 into main May 22, 2024
15 checks passed
@mergify mergify bot deleted the yoav/parent_this_only_when_needed branch May 22, 2024 18:14
@monadabot
Copy link
Contributor

Congrats! 🚀 This was released in Wing 0.74.7.

mergify bot pushed a commit that referenced this pull request May 24, 2024
…6535)

This is part of the effort to address #4925.

Because inflight closures turn into class definitions, when they are passed to a `super()` call we use to get an error telling us that `super()` must be the first statement in a ctor. Now this is fixed:
```wing
class Foo {
  new(x: num) {}
}
class Bar extends Foo {
  new() {
    class Baz {} // This is now ok
    super(1);
  }
}
```
This PR also improves the diagnostics for mssing super calls or "not first statement" super calls.

note: waiting for #6531 to be merged first.

## Checklist

- [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted)
- [x] Description explains motivation and solution
- [x] Tests added (always)
- [ ] Docs updated (only required for features)
- [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants