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 24description("Ensures that we pass exceptions to the correct codeblock when throwing from the DFG to the LLInt."); 25var o = { 26 toString: function() { if (shouldThrow) throw {}; return ""; } 27}; 28 29var shouldThrow = false; 30function h(o) { 31 return String(o); 32} 33 34try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 35try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 36try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 37try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 38try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 39try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 40try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 41try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 42try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 43try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 44try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 45try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 46try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 47try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 48try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 49try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 50try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 51try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 52try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 53try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 54try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 55try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 56try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 57try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 58try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 59try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 60try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 61try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 62try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 63try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 64try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 65try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 66try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 67try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 68try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 69try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 70try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 71try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 72try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 73try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 74try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 75try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 76try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 77try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 78try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 79try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 80try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 81try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 82try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 83try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 84try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 85try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 86try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 87try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 88try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 89try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 90try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 91try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 92try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 93try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 94try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 95try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 96try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 97try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 98try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 99try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 100try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 101try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 102try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 103try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 104try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 105try { shouldThrow = !shouldThrow; h(o); } catch (e) {} 106 107 108function g() { 109 with({}) 110 h(o); 111} 112 113function f1() { 114 try { 115 g(); 116 } catch (e) { 117 testFailed("Caught exception in wrong codeblock"); 118 } 119} 120 121function f2() { 122 try { 123 g(); 124 } catch (e) { 125 testPassed("Caught exception in correct codeblock"); 126 } 127} 128 129f1(); 130f1(); 131f1(); 132f1(); 133f1(); 134f1(); 135f1(); 136f1(); 137f1(); 138f1(); 139f1(); 140f1(); 141f1(); 142f1(); 143f1(); 144f1(); 145f1(); 146f1(); 147f1(); 148f1(); 149f1(); 150f1(); 151f1(); 152f1(); 153f1(); 154f1(); 155f1(); 156f1(); 157f1(); 158f1(); 159f1(); 160f1(); 161f1(); 162f1(); 163f1(); 164f1(); 165f1(); 166f1(); 167f1(); 168f1(); 169f1(); 170f1(); 171f1(); 172f1(); 173f1(); 174f1(); 175f1(); 176f1(); 177f1(); 178f1(); 179f1(); 180f1(); 181f1(); 182f1(); 183f1(); 184f1(); 185f1(); 186f1(); 187f1(); 188f1(); 189f1(); 190f1(); 191f1(); 192f1(); 193f1(); 194f1(); 195f1(); 196f1(); 197f1(); 198f1(); 199f1(); 200f1(); 201f1(); 202f1(); 203f1(); 204f1(); 205f1(); 206f1(); 207f1(); 208shouldThrow = true; 209f2(); 210var successfullyParsed = true; 211