Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1 | // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Flags: --allow-natives-syntax |
| 6 | |
| 7 | function DeoptFromTry(x) { |
| 8 | try { |
| 9 | %DeoptimizeFunction(DeoptFromTry); |
| 10 | throw x; |
| 11 | } catch (e) { |
| 12 | return e + 1; |
| 13 | } |
| 14 | return x + 2; |
| 15 | } |
| 16 | %OptimizeFunctionOnNextCall(DeoptFromTry); |
| 17 | assertEquals(24, DeoptFromTry(23)); |
| 18 | |
| 19 | |
| 20 | function DeoptFromCatch(x) { |
| 21 | try { |
| 22 | throw x; |
| 23 | } catch (e) { |
| 24 | %DeoptimizeFunction(DeoptFromCatch); |
| 25 | return e + 1; |
| 26 | } |
| 27 | return x + 2; |
| 28 | } |
| 29 | %OptimizeFunctionOnNextCall(DeoptFromCatch); |
| 30 | assertEquals(24, DeoptFromCatch(23)); |
| 31 | |
| 32 | |
| 33 | function DeoptFromFinally_Return(x) { |
| 34 | try { |
| 35 | throw x; |
| 36 | } finally { |
| 37 | %DeoptimizeFunction(DeoptFromFinally_Return); |
| 38 | return x + 1; |
| 39 | } |
| 40 | return x + 2; |
| 41 | } |
| 42 | %OptimizeFunctionOnNextCall(DeoptFromFinally_Return); |
| 43 | assertEquals(24, DeoptFromFinally_Return(23)); |
| 44 | |
| 45 | |
| 46 | function DeoptFromFinally_ReThrow(x) { |
| 47 | try { |
| 48 | throw x; |
| 49 | } finally { |
| 50 | %DeoptimizeFunction(DeoptFromFinally_ReThrow); |
| 51 | } |
| 52 | return x + 2; |
| 53 | } |
| 54 | %OptimizeFunctionOnNextCall(DeoptFromFinally_ReThrow); |
| 55 | assertThrows("DeoptFromFinally_ReThrow(new Error)", Error); |