https://kotlinlang.org logo
#coroutines
Title
# coroutines
l

louiscad

06/17/2020, 8:16 AM
Hello, I just had an idea to optimize the size of binaries using coroutines even further by reusing
ContinuationImpl
classes whenever possible. What do you think? Details here: https://youtrack.jetbrains.com/issue/KT-39644
👀 2
h

Hamza

06/17/2020, 8:19 AM
Definitely interesting and I follow your logic. Hopefully it leads to something new
w

wasyl

06/17/2020, 8:32 AM
Do I understand correctly that the compiler would generate a shared
ContinuationImpl
for each combination of fields that right now the anonymous class has, eg.
Copy code
// $FF: synthetic field
Object result;
int label;
Object L$0;
?
e

elizarov

06/17/2020, 9:23 AM
Great idea, very hard to implement in practice.
Each coroutine impl also has a call to the underlying method, which has to be different for each instance.
l

louiscad

06/17/2020, 9:38 AM
Yes, I was thinking about a switch for these, taking the needed parameters in the needed order. That implies the "continuation implementation signature" orders the "keys", but that the needed order is kept right for calls to the underlying method. Should I edit the YouTrack ticket to make this more clear?
@wasyl I didn't quite understand your example, but I think you got it, it'd share the
ContinuationImpl
classes for compatible usages.
👍 1
3 Views