Skip to content

Remove access calls from trace #538

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

Merged
merged 11 commits into from
Mar 4, 2025
Merged

Conversation

bbrockbernd
Copy link
Collaborator

@bbrockbernd bbrockbernd commented Feb 20, 2025

Closes #537 And was mentioned here: #534 (comment)

Simplifies:

AccessFunctionRepresentationTest.access$inc(AccessFunctionRepresentationTest#1) at AccessFunctionRepresentationTest$block$1.invoke(AccessFunctionRepresentationTest.kt:19)
    AccessFunctionRepresentationTest#1.inc() at AccessFunctionRepresentationTest.access$inc(AccessFunctionRepresentationTest.kt:13)

Example before:

Detailed trace:
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|                                                                                             Thread 1                                                                                             |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| AccessFunctionRepresentationTest#1.block(): threw IllegalStateException at BaseRunConcurrentRepresentationTest$testRunWithModelChecker$result$1$1.invoke(RunConcurrentRepresentationTests.kt:40) |
|   block(): threw IllegalStateException at AccessFunctionRepresentationTest.block(AccessFunctionRepresentationTest.kt:13)                                                                         |
|     AccessFunctionRepresentationTestKt.runn(block$1) at AccessFunctionRepresentationTest.block(AccessFunctionRepresentationTest.kt:19)                                                           |
|       block$1.invoke() at AccessFunctionRepresentationTestKt.runn(AccessFunctionRepresentationTest.kt:39)                                                                                        |
|         invoke() at AccessFunctionRepresentationTest$block$1.invoke(AccessFunctionRepresentationTest.kt:19)                                                                                      |
|           AccessFunctionRepresentationTest.access$inc(AccessFunctionRepresentationTest#1) at AccessFunctionRepresentationTest$block$1.invoke(AccessFunctionRepresentationTest.kt:19)             |
|             AccessFunctionRepresentationTest#1.inc() at AccessFunctionRepresentationTest.access$inc(AccessFunctionRepresentationTest.kt:13)                                                      |
|               a ➜ 1 at AccessFunctionRepresentationTest.inc(AccessFunctionRepresentationTest.kt:24)                                                                                              |
|               Nested#1.inc2() at AccessFunctionRepresentationTest.inc(AccessFunctionRepresentationTest.kt:24)                                                                                    |
|                 AccessFunctionRepresentationTest.access$inc3(AccessFunctionRepresentationTest#1) at AccessFunctionRepresentationTest$Nested.inc2(AccessFunctionRepresentationTest.kt:32)         |
|                   AccessFunctionRepresentationTest#1.inc3() at AccessFunctionRepresentationTest.access$inc3(AccessFunctionRepresentationTest.kt:13)                                              |
|                     a ➜ 1 at AccessFunctionRepresentationTest.inc3(AccessFunctionRepresentationTest.kt:28)                                                                                       |
|                     a = 2 at AccessFunctionRepresentationTest.inc3(AccessFunctionRepresentationTest.kt:28)                                                                                       |
|   result: IllegalStateException #1                                                                                                                                                               |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |

after:

Detailed trace:
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|                                                                                             Thread 1                                                                                             |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| AccessFunctionRepresentationTest#1.block(): threw IllegalStateException at BaseRunConcurrentRepresentationTest$testRunWithModelChecker$result$1$1.invoke(RunConcurrentRepresentationTests.kt:40) |
|   block(): threw IllegalStateException at AccessFunctionRepresentationTest.block(AccessFunctionRepresentationTest.kt:13)                                                                         |
|     AccessFunctionRepresentationTestKt.runn(block$1) at AccessFunctionRepresentationTest.block(AccessFunctionRepresentationTest.kt:19)                                                           |
|       block$1.invoke() at AccessFunctionRepresentationTestKt.runn(AccessFunctionRepresentationTest.kt:39)                                                                                        |
|         invoke() at AccessFunctionRepresentationTest$block$1.invoke(AccessFunctionRepresentationTest.kt:19)                                                                                      |
|           AccessFunctionRepresentationTest.inc() at AccessFunctionRepresentationTest$block$1.invoke(AccessFunctionRepresentationTest.kt:19)                                                      |
|             a ➜ 1 at AccessFunctionRepresentationTest.inc(AccessFunctionRepresentationTest.kt:24)                                                                                                |
|             Nested#1.inc2() at AccessFunctionRepresentationTest.inc(AccessFunctionRepresentationTest.kt:24)                                                                                      |
|               AccessFunctionRepresentationTest.inc3() at AccessFunctionRepresentationTest$Nested.inc2(AccessFunctionRepresentationTest.kt:32)                                                    |
|                 a ➜ 1 at AccessFunctionRepresentationTest.inc3(AccessFunctionRepresentationTest.kt:28)                                                                                           |
|                 a = 2 at AccessFunctionRepresentationTest.inc3(AccessFunctionRepresentationTest.kt:28)                                                                                           |
|   result: IllegalStateException #1                                                                                                                                                               |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |

Additionally gets rid of synthetic field accesses:
Before:

|         invoke() at AccessFieldRepresentationTest$block$1.invoke(AccessFunctionRepresentationTest.kt:48)                                                                                      |
|           AccessFieldRepresentationTest.access$getA$p(AccessFieldRepresentationTest#1): 1 at AccessFieldRepresentationTest$block$1.invoke(AccessFunctionRepresentationTest.kt:48)             |
|             AccessFieldRepresentationTest#1.a ➜ 1 at AccessFieldRepresentationTest.access$getA$p(AccessFunctionRepresentationTest.kt:42)                                                      |
|           AccessFieldRepresentationTest.access$setA$p(AccessFieldRepresentationTest#1, 2) at AccessFieldRepresentationTest$block$1.invoke(AccessFunctionRepresentationTest.kt:48)             |
|             AccessFieldRepresentationTest#1.a = 2 at AccessFieldRepresentationTest.access$setA$p(AccessFunctionRepresentationTest.kt:42)                                                      |

After:

|         invoke() at AccessFieldRepresentationTest$block$1.invoke(AccessFunctionRepresentationTest.kt:48)                                                                                      |
|           AccessFieldRepresentationTest#1.a ➜ 1 at AccessFieldRepresentationTest$block$1.invoke(AccessFunctionRepresentationTest.kt:48)                                                       |
|           AccessFieldRepresentationTest#1.a = 2 at AccessFieldRepresentationTest$block$1.invoke(AccessFunctionRepresentationTest.kt:48)                                                       |

@bbrockbernd bbrockbernd requested review from eupp and ndkoval February 20, 2025 15:03
@bbrockbernd bbrockbernd linked an issue Feb 20, 2025 that may be closed by this pull request
@bbrockbernd bbrockbernd self-assigned this Feb 20, 2025
@ndkoval ndkoval removed their request for review February 25, 2025 23:08
@eupp
Copy link
Collaborator

eupp commented Feb 26, 2025

While we are here, let's maybe fix .access$ for all cases?

The .access$ methods are generated by the Kotlin compiler to access otherwise inaccessible members (e.g., private) from lambdas, inner classes, etc.:
https://medium.com/@iateyourmic/synthetic-accessors-in-kotlin-a60184afd94e

So it looks like apart from functions, you also need to handle field accesses.

@bbrockbernd
Copy link
Collaborator Author

Good idea, and done!

@bbrockbernd bbrockbernd force-pushed the bbrockbernd/remove-access-functions branch from 9fde094 to 9a9fcc5 Compare February 28, 2025 08:26
@bbrockbernd bbrockbernd requested a review from eupp March 3, 2025 15:45
@bbrockbernd bbrockbernd requested a review from eupp March 4, 2025 08:23
@eupp eupp changed the title Remove access calls from trace (for function accesses only). Remove access calls from trace Mar 4, 2025
@eupp eupp force-pushed the bbrockbernd/remove-access-functions branch from 54b1224 to 511dec2 Compare March 4, 2025 16:50
@eupp eupp merged commit 31612b2 into develop Mar 4, 2025
20 checks passed
@eupp eupp deleted the bbrockbernd/remove-access-functions branch March 4, 2025 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove .access$ calls
2 participants