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
Class method effects #4018
Merged
Merged
Class method effects #4018
Commits on Mar 26, 2021
-
Move logic from ClassBody into ClassNode
So that it sits in one place and is easier to extend.
-
Track static class fields and improve handling of class getters/setters
This aims to improve tree-shaking of code that uses static class properties (rollup#3989) and to improve detection of side effects through class getters/setters (rollup#4016). The first part works by keeping a map of positively known static properties (methods and simple getters) in `ClassNode.staticPropertyMap`, along with a flag (`ClassNode.deoptimizedStatic`) that indicates that something happened that removed our confidence that we know anything about the class object. Access and calls to these known static properties are handled by routing the calls to `getLiteralValueAtPath`, `getReturnExpressionWhenCalledAtPath`, and `hasEffectsWhenCalledAtPath` to the known values in the properties. In contrast to `ObjectExpression`, this class does not try to keep track of multiple expressions associated with a property, since that doesn't come up a lot on classes. The handling of side effect detection through getters and setters is done by, _if_ the entire class object (or its prototype in case of access to the prototype) hasn't been deoptimized, scanning through the directly defined getters and setters to see if one exists (calling through to superclasses as appropriate). I believe that this is solid because any code that would be able to change the set of getters and setters on a class would cause the entire object to be deoptimized.
Commits on Mar 27, 2021
Commits on Apr 2, 2021
Commits on Apr 14, 2021
Commits on Apr 15, 2021
Commits on Apr 17, 2021
Commits on Apr 19, 2021
Commits on Apr 20, 2021
Commits on Apr 21, 2021
Commits on Apr 22, 2021
Commits on Apr 23, 2021
Commits on Apr 24, 2021
Commits on Apr 25, 2021
Commits on May 6, 2021
Commits on May 8, 2021
Commits on May 9, 2021
Commits on May 10, 2021
Commits on May 12, 2021
Commits on May 14, 2021
Commits on May 15, 2021
Commits on May 16, 2021
Commits on May 17, 2021
Commits on May 18, 2021
Commits on May 20, 2021
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.