1 /* 2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /** 25 * JDK-8069338: Implement sharedScopeCall for optimistic types 26 * 27 * @test 28 * @run 29 */ 30 31 var c = 0; 32 var n = 1; 33 34 function f() { 35 return c++ > 10 ? 'f' : 1; 36 } 37 38 function h() { 39 var x = 0; 40 x += n; 41 x += n; 42 x += n; 43 x += n; 44 x += n; 45 x += n; 46 x += n; 47 x += n; 48 x += n; 49 x += n; 50 x += n; 51 n = 'b'; 52 x += n; 53 x += n; 54 x += n; 55 x += n; 56 x += n; 57 x += n; 58 return x; 59 } 60 61 function g() { 62 var x = 0; 63 x += f(); 64 x += f(); 65 x += f(); 66 x += f(); 67 x += f(); 68 x += f(); 69 x += f(); 70 x += f(); 71 x += f(); 72 x += f(); 73 x += f(); 74 x += f(); 75 x += f(); 76 x += f(); 77 x += f(); 78 x += f(); 79 x += f(); 80 return x; 81 } 82 83 Assert.assertEquals(h(), '11bbbbbb'); 84 Assert.assertEquals(g(), '11ffffff'); 85