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

Update filter for suspending functions with tail call optimization #1016

Merged
merged 7 commits into from Feb 9, 2020

Conversation

Godin
Copy link
Member

@Godin Godin commented Feb 9, 2020

For Example.kt

suspend fun example() {
   suspendingFunction()
}

suspend fun suspendingFunction() {
}

kotlinc version 1.3.31 generates

  public static final java.lang.Object example(kotlin.coroutines.Continuation<? super kotlin.Unit>);
    descriptor: (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
    flags: ACC_PUBLIC, ACC_STATIC, ACC_FINAL
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokestatic  #12                 // Method suspendingFunction:(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
         4: areturn
      LineNumberTable:
        line 2: 0

whereas starting from version 1.3.60 (see change JetBrains/kotlin@cc06798) generates

  public static final java.lang.Object example(kotlin.coroutines.Continuation<? super kotlin.Unit>);
    descriptor: (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
    flags: ACC_PUBLIC, ACC_STATIC, ACC_FINAL
    Code:
      stack=3, locals=1, args_size=1
         0: aload_0
         1: invokestatic  #12                 // Method suspendingFunction:(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
         4: dup
         5: invokestatic  #18                 // Method kotlin/coroutines/intrinsics/IntrinsicsKt.getCOROUTINE_SUSPENDED:()Ljava/lang/Object;
         8: if_acmpne     12
        11: areturn
        12: pop
        13: getstatic     #24                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
        16: areturn
      LineNumberTable:
        line 2: 0
        line 3: 13

@Godin Godin added this to Implementation in Current work items via automation Feb 9, 2020
@Godin Godin self-assigned this Feb 9, 2020
@Godin Godin added this to the 0.8.6 milestone Feb 9, 2020
@Godin Godin marked this pull request as ready for review February 9, 2020 03:24
@Godin Godin requested a review from marchof February 9, 2020 03:24
@Godin Godin moved this from Implementation to Review in Current work items Feb 9, 2020
@marchof marchof merged commit 71f9341 into master Feb 9, 2020
Current work items automation moved this from Review to Done Feb 9, 2020
@marchof marchof deleted the kotlin_suspending_tail_call branch February 9, 2020 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants