-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Fix StabilityInferencer's handling of internal types
#5596
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
Open
derekxu16
wants to merge
1
commit into
master
Choose a base branch
from
prr/derekx/fix-stability-inferencer
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...n.FunctionBodySkippingTransformTests/testInternalStableUnstableParams[useFir = false].txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // | ||
| // Source | ||
| // ------------------------------------------ | ||
|
|
||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.NonRestartableComposable | ||
| import androidx.compose.runtime.ReadOnlyComposable | ||
|
|
||
|
|
||
| @Composable | ||
| internal fun CanSkip(foo: Foo = Foo()) { | ||
| used(foo) | ||
| } | ||
| @Composable | ||
| internal fun CannotSkip(foo: Foo) { | ||
| used(foo) | ||
| } | ||
|
|
||
| // | ||
| // Transformed IR | ||
| // ------------------------------------------ | ||
|
|
||
| @Composable | ||
| internal fun CanSkip(foo: Foo?, %composer: Composer?, %changed: Int, %default: Int) { | ||
| %composer = %composer.startRestartGroup(<>) | ||
| sourceInformation(%composer, "C(CanSkip):Test.kt") | ||
| val %dirty = %changed | ||
| if (%changed and 0b0110 == 0) { | ||
| %dirty = %dirty or if (%default and 0b0001 == 0 && %composer.changedInstance(foo)) 0b0100 else 0b0010 | ||
| } | ||
| if (%composer.shouldExecute(%dirty and 0b0011 != 0b0010, %dirty and 0b0001)) { | ||
| %composer.startDefaults() | ||
| if (%changed and 0b0001 == 0 || %composer.defaultsInvalid) { | ||
| if (%default and 0b0001 != 0) { | ||
| foo = Foo() | ||
| %dirty = %dirty and 0b1110.inv() | ||
| } | ||
| } else { | ||
| %composer.skipToGroupEnd() | ||
| if (%default and 0b0001 != 0) { | ||
| %dirty = %dirty and 0b1110.inv() | ||
| } | ||
| } | ||
| %composer.endDefaults() | ||
| if (isTraceInProgress()) { | ||
| traceEventStart(<>, %dirty, -1, <>) | ||
| } | ||
| used(foo as Foo) | ||
| if (isTraceInProgress()) { | ||
| traceEventEnd() | ||
| } | ||
| } else { | ||
| %composer.skipToGroupEnd() | ||
| } | ||
| %composer.endRestartGroup()?.updateScope { %composer: Composer?, %force: Int -> | ||
| CanSkip(foo, %composer, updateChangedFlags(%changed or 0b0001), %default) | ||
| } | ||
| } | ||
| @Composable | ||
| internal fun CannotSkip(foo: Foo, %composer: Composer?, %changed: Int) { | ||
| %composer = %composer.startRestartGroup(<>) | ||
| sourceInformation(%composer, "C(CannotSkip):Test.kt") | ||
| val %dirty = %changed | ||
| if (%changed and 0b0110 == 0) { | ||
| %dirty = %dirty or if (%composer.changedInstance(foo)) 0b0100 else 0b0010 | ||
| } | ||
| if (%composer.shouldExecute(%dirty and 0b0011 != 0b0010, %dirty and 0b0001)) { | ||
| if (isTraceInProgress()) { | ||
| traceEventStart(<>, %dirty, -1, <>) | ||
| } | ||
| used(foo) | ||
| if (isTraceInProgress()) { | ||
| traceEventEnd() | ||
| } | ||
| } else { | ||
| %composer.skipToGroupEnd() | ||
| } | ||
| %composer.endRestartGroup()?.updateScope { %composer: Composer?, %force: Int -> | ||
| CannotSkip(foo, %composer, updateChangedFlags(%changed or 0b0001)) | ||
| } | ||
| } |
81 changes: 81 additions & 0 deletions
81
...in.FunctionBodySkippingTransformTests/testInternalStableUnstableParams[useFir = true].txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // | ||
| // Source | ||
| // ------------------------------------------ | ||
|
|
||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.NonRestartableComposable | ||
| import androidx.compose.runtime.ReadOnlyComposable | ||
|
|
||
|
|
||
| @Composable | ||
| internal fun CanSkip(foo: Foo = Foo()) { | ||
| used(foo) | ||
| } | ||
| @Composable | ||
| internal fun CannotSkip(foo: Foo) { | ||
| used(foo) | ||
| } | ||
|
|
||
| // | ||
| // Transformed IR | ||
| // ------------------------------------------ | ||
|
|
||
| @Composable | ||
| internal fun CanSkip(foo: Foo?, %composer: Composer?, %changed: Int, %default: Int) { | ||
| %composer = %composer.startRestartGroup(<>) | ||
| sourceInformation(%composer, "C(CanSkip)N(foo):Test.kt") | ||
| val %dirty = %changed | ||
| if (%changed and 0b0110 == 0) { | ||
| %dirty = %dirty or if (%default and 0b0001 == 0 && %composer.changedInstance(foo)) 0b0100 else 0b0010 | ||
| } | ||
| if (%composer.shouldExecute(%dirty and 0b0011 != 0b0010, %dirty and 0b0001)) { | ||
| %composer.startDefaults() | ||
| if (%changed and 0b0001 == 0 || %composer.defaultsInvalid) { | ||
| if (%default and 0b0001 != 0) { | ||
| foo = Foo() | ||
| %dirty = %dirty and 0b1110.inv() | ||
| } | ||
| } else { | ||
| %composer.skipToGroupEnd() | ||
| if (%default and 0b0001 != 0) { | ||
| %dirty = %dirty and 0b1110.inv() | ||
| } | ||
| } | ||
| %composer.endDefaults() | ||
| if (isTraceInProgress()) { | ||
| traceEventStart(<>, %dirty, -1, <>) | ||
| } | ||
| used(foo as Foo) | ||
| if (isTraceInProgress()) { | ||
| traceEventEnd() | ||
| } | ||
| } else { | ||
| %composer.skipToGroupEnd() | ||
| } | ||
| %composer.endRestartGroup()?.updateScope { %composer: Composer?, %force: Int -> | ||
| CanSkip(foo, %composer, updateChangedFlags(%changed or 0b0001), %default) | ||
| } | ||
| } | ||
| @Composable | ||
| internal fun CannotSkip(foo: Foo, %composer: Composer?, %changed: Int) { | ||
| %composer = %composer.startRestartGroup(<>) | ||
| sourceInformation(%composer, "C(CannotSkip)N(foo):Test.kt") | ||
| val %dirty = %changed | ||
| if (%changed and 0b0110 == 0) { | ||
| %dirty = %dirty or if (%composer.changedInstance(foo)) 0b0100 else 0b0010 | ||
| } | ||
| if (%composer.shouldExecute(%dirty and 0b0011 != 0b0010, %dirty and 0b0001)) { | ||
| if (isTraceInProgress()) { | ||
| traceEventStart(<>, %dirty, -1, <>) | ||
| } | ||
| used(foo) | ||
| if (isTraceInProgress()) { | ||
| traceEventEnd() | ||
| } | ||
| } else { | ||
| %composer.skipToGroupEnd() | ||
| } | ||
| %composer.endRestartGroup()?.updateScope { %composer: Composer?, %force: Int -> | ||
| CannotSkip(foo, %composer, updateChangedFlags(%changed or 0b0001)) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure this test makes a lot of sense as is.
You want to check for codegen of parameters with the types of
internal class FooStable(val value: Int)andinternal class FooUnstable(var value: Int)instead of unstable class only.The other thing I noticed is that unstable class produced
changedInstancerather thanchangedcall, which tells me thatchangedInstanceis always generated forRuntimestability. Please file a bug for this.Also no need to check default arguments, that does not affect stability here.