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

Implementation of lambda merging for Kotlin lambda classes #257

Open
wants to merge 223 commits into
base: master
Choose a base branch
from

Conversation

heckej
Copy link

@heckej heckej commented Jun 9, 2022

This will add the ability to ProGuard to apply an optimisation called lambda merging which combines the implementations of multiple Kotlin lambda classes in a common class, called a lambda group. This pull request depends on a pull request in ProGuard-CORE: Classes needed for lambda merging in ProGuard #36.

Joren Van Hecke added 30 commits February 8, 2022 14:17
Comment on lines +16 to +19
- uses: actions/[email protected]
with:
repository: heckej/proguard-core
path: proguard-core
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- uses: actions/[email protected]
with:
repository: heckej/proguard-core
path: proguard-core

@@ -20,5 +20,6 @@ include 'gui'
include 'gradle-plugin'
include 'ant'
include 'annotations'
includeBuild "../proguard-core"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
includeBuild "../proguard-core"

@@ -66,6 +66,10 @@
public static final String ASSUME_VALUES_OPTION = "-assumevalues";
public static final String ALLOW_ACCESS_MODIFICATION_OPTION = "-allowaccessmodification";
public static final String MERGE_INTERFACES_AGGRESSIVELY_OPTION = "-mergeinterfacesaggressively";
public static final String PRINT_LAMBDAGROUP_MAPPING_OPTION = "-printlambdagroupmapping";
public static final String MERGE_KOTLIN_LAMBDA_CLASSES_OPTION = "-mergekotlinlambdaclasses";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add the lambda merging to the -optimizations option instead, that will be more consistent e.g.

-optimizations class/merging/kotlinlambda

base/src/main/java/proguard/ConfigurationConstants.java Outdated Show resolved Hide resolved
base/src/main/java/proguard/ConfigurationConstants.java Outdated Show resolved Hide resolved
{
return true;
}
MethodReferenceFinder methodReferenceFinder = new MethodReferenceFinder(invokeMethod);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use ReferencedMemberVisitor here?

Maybe something like:

            new ReferencedMemberVisitor(
                    new MemberVisitor()
                    {
                        @Override
                        public void visitAnyMember(Clazz clazz, Member member)
                        {
                            if (member == myMember) member.accept(clazz, counter);    
                        }
                    }
            );

Joren Van Hecke and others added 23 commits June 29, 2022 16:29
Classes involved are: InnerClasssInfoClassConstantVisitor, ClassConstantReferenceUpdater, FieldReferenceFinder, FieldRenamer, MethodCopier, MethodReferenceFinder and PackageGrouper
@sonarcloud
Copy link

sonarcloud bot commented Jul 10, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@develar
Copy link

develar commented Feb 16, 2023

Hi, what's the status of this pull request?

@ninja-
Copy link

ninja- commented Apr 18, 2023

👀

@heckej
Copy link
Author

heckej commented May 8, 2023

Since this pull request was made, a lot of changes have been made to the internals of ProGuard and ProGuard CORE, if I'm correct. I currently do not have the time to do the required changes to make the code compatible. Besides, this is mainly a proof of concept, developed for my thesis, which would benefit a lot from qualitative improvements or perhaps a new start almost from scratch.

@ninja-
Copy link

ninja- commented May 8, 2023

I raised the issue upstream in Kotlin to get some attention to edge cases that generate class-based lambdas instead of the new invokedynamic based ones.
With some luck, it will be improved in the future and there will be no need for this optimization

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.

4 participants