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 Kotlin suspending functions #809

Merged
merged 9 commits into from
Dec 30, 2018

Conversation

Godin
Copy link
Member

@Godin Godin commented Dec 27, 2018

Example.kt

import kotlinx.coroutines.delay

fun nop() {
}

suspend fun example() { // line 6
  delay(0) // line 7
  nop()
}

javap -v -p ExampleKt.class

  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=5, locals=4, args_size=1
         0: aload_0
         1: instanceof    #12                 // class ExampleKt$example$1
         4: ifeq          36
         7: aload_0
         8: checkcast     #12                 // class ExampleKt$example$1
        11: astore_2
        12: aload_2
        13: getfield      #16                 // Field ExampleKt$example$1.label:I
        16: ldc           #17                 // int -2147483648
        18: iand
        19: ifeq          36
        22: aload_2
        23: dup
        24: getfield      #16                 // Field ExampleKt$example$1.label:I
        27: ldc           #17                 // int -2147483648
        29: isub
        30: putfield      #16                 // Field ExampleKt$example$1.label:I
        33: goto          45
        36: new           #12                 // class ExampleKt$example$1
        39: dup
        40: aload_0
        41: invokespecial #21                 // Method ExampleKt$example$1."<init>":(Lkotlin/coroutines/Continuation;)V
        44: astore_2
        45: aload_2
        46: getfield      #25                 // Field ExampleKt$example$1.result:Ljava/lang/Object;
        49: astore_1
        50: invokestatic  #31                 // Method kotlin/coroutines/intrinsics/IntrinsicsKt.getCOROUTINE_SUSPENDED:()Ljava/lang/Object;
        53: astore_3
        54: aload_2
        55: getfield      #16                 // Field ExampleKt$example$1.label:I
        58: tableswitch   { // 0 to 1
                       0: 80
                       1: 113
                 default: 138
            }
        80: aload_1
        81: dup
        82: instanceof    #33                 // class kotlin/Result$Failure
        85: ifeq          95
        88: checkcast     #33                 // class kotlin/Result$Failure
        91: getfield      #37                 // Field kotlin/Result$Failure.exception:Ljava/lang/Throwable;
        94: athrow
        95: pop
        96: lconst_0
        97: aload_2
        98: aload_2
        99: iconst_1
       100: putfield      #16                 // Field ExampleKt$example$1.label:I
       103: invokestatic  #43                 // Method kotlinx/coroutines/DelayKt.delay:(JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
       106: dup
       107: aload_3
       108: if_acmpne     130
       111: aload_3
       112: areturn
       113: aload_1
       114: dup
       115: instanceof    #33                 // class kotlin/Result$Failure
       118: ifeq          128
       121: checkcast     #33                 // class kotlin/Result$Failure
       124: getfield      #37                 // Field kotlin/Result$Failure.exception:Ljava/lang/Throwable;
       127: athrow
       128: pop
       129: aload_1
       130: pop
       131: invokestatic  #45                 // Method nop:()V
       134: getstatic     #51                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
       137: areturn
       138: new           #53                 // class java/lang/IllegalStateException
       141: dup
       142: ldc           #55                 // String call to 'resume' before 'invoke' with coroutine
       144: invokespecial #58                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
       147: athrow
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
           45      93     2 $continuation   Lkotlin/coroutines/Continuation;
      LineNumberTable:
        line 6: 53
        line 7: 96
        line 6: 111
        line 8: 130
        line 9: 134

@Godin Godin self-assigned this Dec 26, 2018
@Godin Godin added this to To Do in Filtering via automation Dec 26, 2018
@Godin Godin added this to Candidates in Current work items via automation Dec 26, 2018
@Godin Godin moved this from Candidates to Implementation in Current work items Dec 27, 2018
@Godin Godin changed the title Add filter for Kotlin suspend functions Add filter for Kotlin suspending functions Dec 28, 2018
@Godin Godin added this to the 0.8.3 milestone Dec 28, 2018
@Godin Godin moved this from Implementation to Review in Current work items Dec 28, 2018
@Godin Godin requested a review from marchof December 28, 2018 02:17
Copy link
Member

@marchof marchof left a comment

Choose a reason for hiding this comment

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

There are two warnings in the init test which should be fixed.

Also I wonder whether is would make sense to pull out some private methods from the big match() method to clearly identify and label the different aspects (for readablity and documentation).

@Godin Godin changed the title Add filter for Kotlin suspending functions Update filter for Kotlin suspending functions Dec 28, 2018
@marchof marchof merged commit 9c45dab into master Dec 30, 2018
Filtering automation moved this from To Do to Done Dec 30, 2018
Current work items automation moved this from Review to Done Dec 30, 2018
@marchof marchof deleted the filter_kotlin_suspend_functions branch December 30, 2018 08:18
@jacoco jacoco locked as resolved and limited conversation to collaborators May 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Filtering
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants