1*795d594fSAndroid Build Coastguard WorkerExercise a method containing a `try' statement with several 2*795d594fSAndroid Build Coastguard Workerinstructions with a `finally' clause but without any `catch' block, 3*795d594fSAndroid Build Coastguard Workerenclosed in a loop. 4*795d594fSAndroid Build Coastguard Worker 5*795d594fSAndroid Build Coastguard WorkerWhen dx processes an integer division (or modulo) enclosing a `try' 6*795d594fSAndroid Build Coastguard Workerblock and whose result is assigned to a local value, it is smart 7*795d594fSAndroid Build Coastguard Workerenough not to emit a `div-int' (or `rem-int') instruction when the 8*795d594fSAndroid Build Coastguard Workerdivisor is non-null, as it wouldn't be used. However, dx is not 9*795d594fSAndroid Build Coastguard Workerthat clever regarding exception handling: if the divisor is known to 10*795d594fSAndroid Build Coastguard Workerbe non-null at compile-time (as is the case in this test), it will 11*795d594fSAndroid Build Coastguard Workerstill emit a block with the exception catching and rethrowing 12*795d594fSAndroid Build Coastguard Workermechanism, even if it is not used. 13*795d594fSAndroid Build Coastguard Worker 14*795d594fSAndroid Build Coastguard WorkerThis used to be a problem for a `try' block followed by a `finally' 15*795d594fSAndroid Build Coastguard Workerclause but with no `catch' block: in that case, the generated Dex code 16*795d594fSAndroid Build Coastguard Workeritem would list zero catch block for this method (see 17*795d594fSAndroid Build Coastguard Workerart::CodeItem::tries_size_) and the optimizing compiler would have no 18*795d594fSAndroid Build Coastguard Workerclue that it contains a `try' statement, which it cannot optimize 19*795d594fSAndroid Build Coastguard Worker(yet). With no hint that this method might contain one (or several) 20*795d594fSAndroid Build Coastguard Workerspecial block(s) related to `catch'-less `try' statement(s), the 21*795d594fSAndroid Build Coastguard Workeroptimizing compiler considered this (these) as dead block(s) and 22*795d594fSAndroid Build Coastguard Workerimproperly tried to remove its (their) instructions, sometimes 23*795d594fSAndroid Build Coastguard Workerremoving instructions used by others instructions, thus triggering 24*795d594fSAndroid Build Coastguard Workerassertions. The optimizing compiler was thus adjusted to remove these 25*795d594fSAndroid Build Coastguard Workerinstructions in a proper fashion, by removing them as users first, and 26*795d594fSAndroid Build Coastguard Workerthen by suppressing them for good. 27