Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1 | // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 | // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 3 | // |
| 4 | // Redistribution and use in source and binary forms, with or without |
| 5 | // modification, are permitted provided that the following conditions |
| 6 | // are met: |
| 7 | // 1. Redistributions of source code must retain the above copyright |
| 8 | // notice, this list of conditions and the following disclaimer. |
| 9 | // 2. Redistributions in binary form must reproduce the above copyright |
| 10 | // notice, this list of conditions and the following disclaimer in the |
| 11 | // documentation and/or other materials provided with the distribution. |
| 12 | // |
| 13 | // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY |
| 14 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 15 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 16 | // DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 17 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 18 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 19 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 20 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 21 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 22 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 | |
| 24 | description( |
| 25 | "This tests that exceptions are thrown correctly." |
| 26 | ); |
| 27 | |
| 28 | // A large function containing a try/catch - this prevent DFG compilation. |
| 29 | function doesntDFGCompile() |
| 30 | { |
| 31 | function callMe() {}; |
| 32 | |
| 33 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 34 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 35 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 36 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 37 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 38 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 39 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 40 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 41 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 42 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 43 | |
| 44 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 45 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 46 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 47 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 48 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 49 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 50 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 51 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 52 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 53 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 54 | |
| 55 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 56 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 57 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 58 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 59 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 60 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 61 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 62 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 63 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 64 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 65 | |
| 66 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 67 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 68 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 69 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 70 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 71 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 72 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 73 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 74 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 75 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 76 | |
| 77 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 78 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 79 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 80 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 81 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 82 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 83 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 84 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 85 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 86 | callMe(0,1,2,3,4,5,6,7,8,9); |
| 87 | |
| 88 | try { |
| 89 | return 1; |
| 90 | } catch (e) { |
| 91 | return 2; |
| 92 | } |
| 93 | }; |
| 94 | |
| 95 | function test(x) |
| 96 | { |
| 97 | return x(); |
| 98 | }; |
| 99 | |
| 100 | // warmup the test method |
| 101 | for (i = 0; i < 200; ++i) |
| 102 | test(doesntDFGCompile); |
| 103 | |
| 104 | // |
| 105 | var caughtException = false; |
| 106 | try { |
| 107 | test(); |
| 108 | } catch (e) { |
| 109 | caughtException = true; |
| 110 | } |
| 111 | |
| 112 | shouldBe("caughtException", 'true'); |
| 113 | var successfullyParsed = true; |