OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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: --strong-mode --allow-natives-syntax |
| 6 |
| 7 "use strict"; |
| 8 |
| 9 function inline_add_strong(x, y) { |
| 10 "use strong"; |
| 11 return x + y; |
| 12 } |
| 13 |
| 14 function inline_add_strong_outer(x, y) { |
| 15 return inline_add_strong(x, y); |
| 16 } |
| 17 |
| 18 function inline_sub_strong(x, y) { |
| 19 "use strong"; |
| 20 return x - y; |
| 21 } |
| 22 |
| 23 function inline_sub_strong_outer(x, y) { |
| 24 return inline_sub_strong(x, y); |
| 25 } |
| 26 |
| 27 function inline_mul_strong(x, y) { |
| 28 "use strong"; |
| 29 return x * y; |
| 30 } |
| 31 |
| 32 function inline_mul_strong_outer(x, y) { |
| 33 return inline_mul_strong(x, y); |
| 34 } |
| 35 |
| 36 function inline_div_strong(x, y) { |
| 37 "use strong"; |
| 38 return x / y; |
| 39 } |
| 40 |
| 41 function inline_div_strong_outer(x, y) { |
| 42 return inline_div_strong(x, y); |
| 43 } |
| 44 |
| 45 function inline_mod_strong(x, y) { |
| 46 "use strong"; |
| 47 return x % y; |
| 48 } |
| 49 |
| 50 function inline_mod_strong_outer(x, y) { |
| 51 return inline_mod_strong(x, y); |
| 52 } |
| 53 |
| 54 function inline_or_strong(x, y) { |
| 55 "use strong"; |
| 56 return x | y; |
| 57 } |
| 58 |
| 59 function inline_or_strong_outer(x, y) { |
| 60 return inline_or_strong(x, y); |
| 61 } |
| 62 |
| 63 function inline_and_strong(x, y) { |
| 64 "use strong"; |
| 65 return x & y; |
| 66 } |
| 67 |
| 68 function inline_and_strong_outer(x, y) { |
| 69 return inline_and_strong(x, y); |
| 70 } |
| 71 |
| 72 function inline_xor_strong(x, y) { |
| 73 "use strong"; |
| 74 return x ^ y; |
| 75 } |
| 76 |
| 77 function inline_xor_strong_outer(x, y) { |
| 78 return inline_xor_strong(x, y); |
| 79 } |
| 80 |
| 81 function inline_shl_strong(x, y) { |
| 82 "use strong"; |
| 83 return x << y; |
| 84 } |
| 85 |
| 86 function inline_shl_strong_outer(x, y) { |
| 87 return inline_shl_strong(x, y); |
| 88 } |
| 89 |
| 90 function inline_shr_strong(x, y) { |
| 91 "use strong"; |
| 92 return x >> y; |
| 93 } |
| 94 |
| 95 function inline_shr_strong_outer(x, y) { |
| 96 return inline_shr_strong(x, y); |
| 97 } |
| 98 |
| 99 function inline_sar_strong(x, y) { |
| 100 "use strong"; |
| 101 return x >>> y; |
| 102 } |
| 103 |
| 104 function inline_sar_strong_outer(x, y) { |
| 105 return inline_sar_strong(x, y); |
| 106 } |
| 107 |
| 108 function inline_add(x, y) { |
| 109 return x + y; |
| 110 } |
| 111 |
| 112 function inline_add_outer_strong(x, y) { |
| 113 "use strong"; |
| 114 return inline_add(x, y); |
| 115 } |
| 116 |
| 117 function inline_sub(x, y) { |
| 118 return x - y; |
| 119 } |
| 120 |
| 121 function inline_sub_outer_strong(x, y) { |
| 122 "use strong"; |
| 123 return inline_sub(x, y); |
| 124 } |
| 125 |
| 126 function inline_mul(x, y) { |
| 127 return x * y; |
| 128 } |
| 129 |
| 130 function inline_mul_outer_strong(x, y) { |
| 131 "use strong"; |
| 132 return inline_mul(x, y); |
| 133 } |
| 134 |
| 135 function inline_div(x, y) { |
| 136 return x / y; |
| 137 } |
| 138 |
| 139 function inline_div_outer_strong(x, y) { |
| 140 "use strong"; |
| 141 return inline_div(x, y); |
| 142 } |
| 143 |
| 144 function inline_mod(x, y) { |
| 145 return x % y; |
| 146 } |
| 147 |
| 148 function inline_mod_outer_strong(x, y) { |
| 149 "use strong"; |
| 150 return inline_mod(x, y); |
| 151 } |
| 152 |
| 153 function inline_or(x, y) { |
| 154 return x | y; |
| 155 } |
| 156 |
| 157 function inline_or_outer_strong(x, y) { |
| 158 "use strong"; |
| 159 return inline_or(x, y); |
| 160 } |
| 161 |
| 162 function inline_and(x, y) { |
| 163 return x & y; |
| 164 } |
| 165 |
| 166 function inline_and_outer_strong(x, y) { |
| 167 "use strong"; |
| 168 return inline_and(x, y); |
| 169 } |
| 170 |
| 171 function inline_xor(x, y) { |
| 172 return x ^ y; |
| 173 } |
| 174 |
| 175 function inline_xor_outer_strong(x, y) { |
| 176 "use strong"; |
| 177 return inline_xor(x, y); |
| 178 } |
| 179 |
| 180 function inline_shl(x, y) { |
| 181 return x << y; |
| 182 } |
| 183 |
| 184 function inline_shl_outer_strong(x, y) { |
| 185 "use strong"; |
| 186 return inline_shl(x, y); |
| 187 } |
| 188 |
| 189 function inline_shr(x, y) { |
| 190 return x >> y; |
| 191 } |
| 192 |
| 193 function inline_shr_outer_strong(x, y) { |
| 194 "use strong"; |
| 195 return inline_shr(x, y); |
| 196 } |
| 197 |
| 198 function inline_sar(x, y) { |
| 199 return x >>> y; |
| 200 } |
| 201 |
| 202 function inline_sar_outer_strong(x, y) { |
| 203 "use strong"; |
| 204 return inline_sar(x, y); |
| 205 } |
| 206 |
| 207 let strong_inner_funcs = [inline_add_strong_outer, inline_sub_strong_outer, |
| 208 inline_mul_strong_outer, inline_div_strong_outer, |
| 209 inline_mod_strong_outer, inline_or_strong_outer, |
| 210 inline_and_strong_outer, inline_xor_strong_outer, |
| 211 inline_shl_strong_outer, inline_shr_strong_outer]; |
| 212 |
| 213 let strong_outer_funcs = [inline_add_outer_strong, inline_sub_outer_strong, |
| 214 inline_mul_outer_strong, inline_div_outer_strong, |
| 215 inline_mod_outer_strong, inline_or_outer_strong, |
| 216 inline_and_outer_strong, inline_xor_outer_strong, |
| 217 inline_shl_outer_strong, inline_shr_outer_strong]; |
| 218 |
| 219 for (let strong_inner_func of strong_inner_funcs) { |
| 220 assertThrows(function(){strong_inner_func(1, {})}, TypeError); |
| 221 for (var i = 0; i < 100; i++) { |
| 222 strong_inner_func(1, 2); |
| 223 } |
| 224 %OptimizeFunctionOnNextCall(strong_inner_func); |
| 225 assertThrows(function(){strong_inner_func(1, {})}, TypeError); |
| 226 } |
| 227 |
| 228 for (let strong_outer_func of strong_outer_funcs) { |
| 229 assertDoesNotThrow(function(){strong_outer_func(1, {})}); |
| 230 for (var i = 0; i < 100; i++) { |
| 231 strong_outer_func(1, 2); |
| 232 } |
| 233 %OptimizeFunctionOnNextCall(strong_outer_func); |
| 234 assertDoesNotThrow(function(){strong_outer_func(1, {})}); |
| 235 } |
OLD | NEW |