OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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() { |
| 8 class O { |
| 9 get x() { |
| 10 return 1; |
| 11 } |
| 12 } |
| 13 var o = new O; |
| 14 |
| 15 function foo(o) { |
| 16 try { |
| 17 return o.x; |
| 18 } catch (e) { |
| 19 return 0; |
| 20 } |
| 21 } |
| 22 |
| 23 assertEquals(1, foo(o)); |
| 24 assertEquals(1, foo(o)); |
| 25 %OptimizeFunctionOnNextCall(foo); |
| 26 assertEquals(1, foo(o)); |
| 27 })(); |
| 28 |
| 29 (function() { |
| 30 class O { |
| 31 get x() { |
| 32 %DeoptimizeFunction(foo); |
| 33 return 1; |
| 34 } |
| 35 } |
| 36 var o = new O; |
| 37 |
| 38 function foo(o) { |
| 39 try { |
| 40 return o.x; |
| 41 } catch (e) { |
| 42 return 0; |
| 43 } |
| 44 } |
| 45 |
| 46 assertEquals(1, foo(o)); |
| 47 assertEquals(1, foo(o)); |
| 48 %OptimizeFunctionOnNextCall(foo); |
| 49 assertEquals(1, foo(o)); |
| 50 })(); |
| 51 |
| 52 (function() { |
| 53 function bar(x) { |
| 54 throw x; |
| 55 } |
| 56 |
| 57 class O { |
| 58 get x() { |
| 59 %DeoptimizeFunction(foo); |
| 60 return bar("x"); |
| 61 } |
| 62 } |
| 63 var o = new O; |
| 64 |
| 65 function foo(o) { |
| 66 try { |
| 67 return o.x; |
| 68 } catch (e) { |
| 69 return 0; |
| 70 } |
| 71 } |
| 72 |
| 73 assertEquals(0, foo(o)); |
| 74 assertEquals(0, foo(o)); |
| 75 %OptimizeFunctionOnNextCall(foo); |
| 76 assertEquals(0, foo(o)); |
| 77 })(); |
OLD | NEW |