Home | History | Annotate | Download | only in self-is-catch-block
      1 # Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file
      2 # for details. All rights reserved. Use of this source code is governed by a
      3 # BSD-style license that can be found in the LICENSE file.
      4 
      5 .class public LTest;
      6 
      7 .super Ljava/lang/Object;
      8 
      9 .method private static throwOnPositive(I)V
     10     .registers 2
     11     if-lez v1, :cond_nothrow
     12     new-instance v0, Ljava/lang/RuntimeException;
     13     invoke-direct {v0}, Ljava/lang/RuntimeException;-><init>()V
     14     throw v0
     15     :cond_nothrow
     16     return-void
     17 .end method
     18 
     19 # Tests the flow of values in the pathological case that the block is its own catch handler.
     20 # This tests that the register allocator does not insert moves at the end of the throwing
     21 # block since in the case of a throw the block does not actually complete.
     22 .method static loopWhileThrow(I)I
     23     .registers 4
     24     :catchall_0
     25     move v0, p0
     26     add-int/lit8 p0, p0, -0x1
     27     :try_start_6
     28     invoke-static {v0}, LTest;->throwOnPositive(I)V
     29     :try_end_9
     30     .catchall {:try_start_6 .. :try_end_9} :catchall_0
     31     return p0
     32 .end method
     33 
     34 .method public static main([Ljava/lang/String;)V
     35     .registers 2
     36     const v0, 0x64
     37     sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
     38     invoke-virtual {v1, v0}, Ljava/io/PrintStream;->println(I)V
     39     invoke-static {v0}, LTest;->loopWhileThrow(I)I
     40     move-result v0
     41     invoke-virtual {v1, v0}, Ljava/io/PrintStream;->println(I)V
     42     return-void
     43 .end method
     44