Thu, 03 Dec 2015 13:41:24 -0800
Merge
attila@963 | 1 | /* |
attila@963 | 2 | * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. |
attila@963 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
attila@963 | 4 | * |
attila@963 | 5 | * This code is free software; you can redistribute it and/or modify it |
attila@963 | 6 | * under the terms of the GNU General Public License version 2 only, as |
attila@963 | 7 | * published by the Free Software Foundation. |
attila@963 | 8 | * |
attila@963 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
attila@963 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
attila@963 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
attila@963 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
attila@963 | 13 | * accompanied this code). |
attila@963 | 14 | * |
attila@963 | 15 | * You should have received a copy of the GNU General Public License version |
attila@963 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
attila@963 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
attila@963 | 18 | * |
attila@963 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
attila@963 | 20 | * or visit www.oracle.com if you need additional information or have any |
attila@963 | 21 | * questions. |
attila@963 | 22 | */ |
attila@963 | 23 | |
attila@963 | 24 | /** |
attila@963 | 25 | * apply_to_call4.js - various escaping args patterns that prevent the optimization from being applied |
attila@963 | 26 | * calling call) |
attila@963 | 27 | * |
attila@963 | 28 | * @test |
attila@963 | 29 | * @run |
attila@963 | 30 | */ |
attila@963 | 31 | |
attila@963 | 32 | print("start"); |
attila@963 | 33 | |
attila@963 | 34 | var x = { |
attila@963 | 35 | a : 0, |
attila@963 | 36 | b : 0, |
attila@963 | 37 | c : 0, |
attila@963 | 38 | initialize : function(x,y,z) { |
attila@963 | 39 | this.a = x; |
attila@963 | 40 | this.b = y; |
attila@963 | 41 | this.c = z; |
attila@963 | 42 | } |
attila@963 | 43 | }; |
attila@963 | 44 | |
attila@963 | 45 | function f(x) { |
attila@963 | 46 | print("this is a black hole - arguments escape"); |
attila@963 | 47 | } |
attila@963 | 48 | |
attila@963 | 49 | function test() { |
attila@963 | 50 | f(arguments); |
attila@963 | 51 | x.initialize.apply(x, arguments); |
attila@963 | 52 | } |
attila@963 | 53 | |
attila@963 | 54 | test(4711,23,17); |
attila@963 | 55 | print(x.a); |
attila@963 | 56 | print(x.b); |
attila@963 | 57 | print(x.c); |
attila@963 | 58 | |
attila@963 | 59 | function test2() { |
attila@963 | 60 | arguments[0] = 17; |
attila@963 | 61 | x.initialize.apply(x, arguments); |
attila@963 | 62 | } |
attila@963 | 63 | |
attila@963 | 64 | test2(1,2,3); |
attila@963 | 65 | print(x.a); |
attila@963 | 66 | print(x.b); |
attila@963 | 67 | print(x.c); |
attila@963 | 68 | |
attila@963 | 69 | function test3() { |
attila@963 | 70 | var escape = arguments[0]; |
attila@963 | 71 | f(escape); |
attila@963 | 72 | x.initialize.apply(x, arguments); |
attila@963 | 73 | } |
attila@963 | 74 | |
attila@963 | 75 | test3("alpha", "beta", "gamma"); |
attila@963 | 76 | print(x.a); |
attila@963 | 77 | print(x.b); |
attila@963 | 78 | print(x.c); |
attila@963 | 79 | |
attila@963 | 80 | function test4() { |
attila@963 | 81 | var escape = arguments.length; |
attila@963 | 82 | f(escape); |
attila@963 | 83 | x.initialize.apply(x, arguments); |
attila@963 | 84 | } |
attila@963 | 85 | |
attila@963 | 86 | test4(1.2, 2.3, 3.4); |
attila@963 | 87 | print(x.a); |
attila@963 | 88 | print(x.b); |
attila@963 | 89 | print(x.c); |
attila@963 | 90 | |
attila@963 | 91 | function test5() { |
attila@963 | 92 | x.initialize.apply(x, arguments, 17); |
attila@963 | 93 | } |
attila@963 | 94 | |
attila@963 | 95 | print("test 5 done"); |
attila@963 | 96 | test5(11, 22); |
attila@963 | 97 | print("a="+typeof(x.a)); |
attila@963 | 98 | print(x.b); |
attila@963 | 99 | print(x.c); |
attila@963 | 100 | |
attila@963 | 101 | print("Now it's time for transforms"); |
attila@963 | 102 | |
attila@963 | 103 | function test6() { |
attila@963 | 104 | x.initialize.apply(x, arguments); |
attila@963 | 105 | } |
attila@963 | 106 | |
attila@963 | 107 | test6(19, 20, 21); |
attila@963 | 108 | print(x.a); |
attila@963 | 109 | print(x.b); |
attila@963 | 110 | print(x.c); |
attila@963 | 111 | |
attila@963 | 112 | function test7() { |
attila@963 | 113 | x.initialize.apply(x, arguments); |
attila@963 | 114 | } |
attila@963 | 115 | |
attila@963 | 116 | test7(1, 2.2, 17, 18); |
attila@963 | 117 | print(x.a); |
attila@963 | 118 | print(x.b); |
attila@963 | 119 | print(x.c); |
attila@963 | 120 | |
attila@963 | 121 | print("Should have transformed"); |
attila@963 | 122 | |
attila@963 | 123 | function test8() { |
attila@963 | 124 | var apply = f; |
attila@963 | 125 | x.initialize.apply(x, arguments); |
attila@963 | 126 | } |
attila@963 | 127 | |
attila@963 | 128 | test8(7,8,9); |
attila@963 | 129 | print(x.a); |
attila@963 | 130 | print(x.b); |
attila@963 | 131 | print(x.c); |