OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --min-preparse-length=1 --allow-natives-syntax --lazy-inner-functions | 5 // Flags: --min-preparse-length=1 --allow-natives-syntax --lazy-inner-functions |
6 | 6 |
7 // Test that the information on which variables to allocate in context doesn't | 7 // Test that the information on which variables to allocate in context doesn't |
8 // change when recompiling. | 8 // change when recompiling. |
9 | 9 |
10 (function TestVarInInnerFunction() { | 10 (function TestVarInInnerFunction() { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 for (var i = 0; i < 3; ++i) { | 95 for (var i = 0; i < 3; ++i) { |
96 if (i == 1) { | 96 if (i == 1) { |
97 %OptimizeOsr(); | 97 %OptimizeOsr(); |
98 } | 98 } |
99 assertEquals(1, a); | 99 assertEquals(1, a); |
100 assertEquals(2, b); | 100 assertEquals(2, b); |
101 assertEquals(3, c); | 101 assertEquals(3, c); |
102 } | 102 } |
103 })(); | 103 })(); |
104 | 104 |
| 105 (function TestInnerFunctionDestructuredParameter_1() { |
| 106 var a = 1; |
| 107 var b = 2; |
| 108 var c = 3; |
| 109 function inner([d, a]) { |
| 110 a; b; c; |
| 111 } |
| 112 for (var i = 0; i < 3; ++i) { |
| 113 if (i == 1) { |
| 114 %OptimizeOsr(); |
| 115 } |
| 116 assertEquals(1, a); |
| 117 assertEquals(2, b); |
| 118 assertEquals(3, c); |
| 119 } |
| 120 })(); |
| 121 |
| 122 (function TestInnerFunctionDestructuredParameter_2() { |
| 123 var a = 1; |
| 124 var b = 2; |
| 125 var c = 3; |
| 126 function inner({d, a}) { |
| 127 a; b; c; |
| 128 } |
| 129 for (var i = 0; i < 3; ++i) { |
| 130 if (i == 1) { |
| 131 %OptimizeOsr(); |
| 132 } |
| 133 assertEquals(1, a); |
| 134 assertEquals(2, b); |
| 135 assertEquals(3, c); |
| 136 } |
| 137 })(); |
| 138 |
| 139 (function TestInnerArrowFunctionParameter() { |
| 140 var a = 1; |
| 141 var b = 2; |
| 142 var c = 3; |
| 143 (a) => { a; b; c; } |
| 144 for (var i = 0; i < 3; ++i) { |
| 145 if (i == 1) { |
| 146 %OptimizeOsr(); |
| 147 } |
| 148 assertEquals(1, a); |
| 149 assertEquals(2, b); |
| 150 assertEquals(3, c); |
| 151 } |
| 152 })(); |
| 153 |
| 154 (function TestInnerArrowFunctionRestParameter() { |
| 155 var a = 1; |
| 156 var b = 2; |
| 157 var c = 3; |
| 158 (...a) => { a; b; c; } |
| 159 for (var i = 0; i < 3; ++i) { |
| 160 if (i == 1) { |
| 161 %OptimizeOsr(); |
| 162 } |
| 163 assertEquals(1, a); |
| 164 assertEquals(2, b); |
| 165 assertEquals(3, c); |
| 166 } |
| 167 })(); |
| 168 |
| 169 (function TestInnerArrowFunctionDestructuredParameter_1() { |
| 170 var a = 1; |
| 171 var b = 2; |
| 172 var c = 3; |
| 173 ([d, a]) => { a; b; c; } |
| 174 for (var i = 0; i < 3; ++i) { |
| 175 if (i == 1) { |
| 176 %OptimizeOsr(); |
| 177 } |
| 178 assertEquals(1, a); |
| 179 assertEquals(2, b); |
| 180 assertEquals(3, c); |
| 181 } |
| 182 })(); |
| 183 |
| 184 (function TestInnerArrowFunctionDestructuredParameter_2() { |
| 185 var a = 1; |
| 186 var b = 2; |
| 187 var c = 3; |
| 188 ({d, a}) => { a; b; c; } |
| 189 for (var i = 0; i < 3; ++i) { |
| 190 if (i == 1) { |
| 191 %OptimizeOsr(); |
| 192 } |
| 193 assertEquals(1, a); |
| 194 assertEquals(2, b); |
| 195 assertEquals(3, c); |
| 196 } |
| 197 })(); |
| 198 |
105 (function TestInnerInnerFunctionParameter() { | 199 (function TestInnerInnerFunctionParameter() { |
106 var a = 1; | 200 var a = 1; |
107 var b = 2; | 201 var b = 2; |
108 var c = 3; | 202 var c = 3; |
109 function inner() { | 203 function inner() { |
110 function innerinner(a) { a; b; c; } | 204 function innerinner(a) { a; b; c; } |
111 } | 205 } |
112 for (var i = 0; i < 3; ++i) { | 206 for (var i = 0; i < 3; ++i) { |
113 if (i == 1) { | 207 if (i == 1) { |
114 %OptimizeOsr(); | 208 %OptimizeOsr(); |
(...skipping 14 matching lines...) Expand all Loading... |
129 for (var i = 0; i < 3; ++i) { | 223 for (var i = 0; i < 3; ++i) { |
130 if (i == 1) { | 224 if (i == 1) { |
131 %OptimizeOsr(); | 225 %OptimizeOsr(); |
132 } | 226 } |
133 assertEquals(1, a); | 227 assertEquals(1, a); |
134 assertEquals(2, b); | 228 assertEquals(2, b); |
135 assertEquals(3, c); | 229 assertEquals(3, c); |
136 } | 230 } |
137 })(); | 231 })(); |
138 | 232 |
139 (function TestInnerArrowFunctionParameter() { | 233 (function TestInnerInnerFunctionDestructuredParameter_1() { |
140 var a = 1; | 234 var a = 1; |
141 var b = 2; | 235 var b = 2; |
142 var c = 3; | 236 var c = 3; |
| 237 function inner() { |
| 238 function innerinner({d, a}) { a; b; c; } |
| 239 } |
| 240 for (var i = 0; i < 3; ++i) { |
| 241 if (i == 1) { |
| 242 %OptimizeOsr(); |
| 243 } |
| 244 assertEquals(1, a); |
| 245 assertEquals(2, b); |
| 246 assertEquals(3, c); |
| 247 } |
| 248 })(); |
| 249 |
| 250 (function TestInnerInnerFunctionDestructuredParameter_2() { |
| 251 var a = 1; |
| 252 var b = 2; |
| 253 var c = 3; |
| 254 function inner() { |
| 255 function innerinner([d, a]) { a; b; c; } |
| 256 } |
| 257 for (var i = 0; i < 3; ++i) { |
| 258 if (i == 1) { |
| 259 %OptimizeOsr(); |
| 260 } |
| 261 assertEquals(1, a); |
| 262 assertEquals(2, b); |
| 263 assertEquals(3, c); |
| 264 } |
| 265 })(); |
| 266 |
| 267 (function TestInnerInnerArrowFunctionParameter() { |
| 268 var a = 1; |
| 269 var b = 2; |
| 270 var c = 3; |
143 function inner() { | 271 function inner() { |
144 var f = a => a + b + c; | 272 var f = a => a + b + c; |
145 } | 273 } |
146 for (var i = 0; i < 3; ++i) { | 274 for (var i = 0; i < 3; ++i) { |
147 if (i == 1) { | 275 if (i == 1) { |
148 %OptimizeOsr(); | 276 %OptimizeOsr(); |
149 } | 277 } |
150 assertEquals(1, a); | 278 assertEquals(1, a); |
151 assertEquals(2, b); | 279 assertEquals(2, b); |
152 assertEquals(3, c); | 280 assertEquals(3, c); |
153 } | 281 } |
154 })(); | 282 })(); |
155 | 283 |
156 (function TestInnerArrowFunctionRestParameter() { | 284 (function TestInnerInnerArrowFunctionRestParameter() { |
157 var a = 1; | 285 var a = 1; |
158 var b = 2; | 286 var b = 2; |
159 var c = 3; | 287 var c = 3; |
160 function inner() { | 288 function inner() { |
161 var f = (...a) => a + b + c; | 289 var f = (...a) => a + b + c; |
162 } | 290 } |
163 for (var i = 0; i < 3; ++i) { | 291 for (var i = 0; i < 3; ++i) { |
164 if (i == 1) { | 292 if (i == 1) { |
165 %OptimizeOsr(); | 293 %OptimizeOsr(); |
166 } | 294 } |
167 assertEquals(1, a); | 295 assertEquals(1, a); |
168 assertEquals(2, b); | 296 assertEquals(2, b); |
169 assertEquals(3, c); | 297 assertEquals(3, c); |
170 } | 298 } |
171 })(); | 299 })(); |
172 | 300 |
| 301 (function TestInnerInnerArrowFunctionDestructuredParameter_1() { |
| 302 var a = 1; |
| 303 var b = 2; |
| 304 var c = 3; |
| 305 function inner() { |
| 306 var f = ([d, a]) => a + b + c; |
| 307 } |
| 308 for (var i = 0; i < 3; ++i) { |
| 309 if (i == 1) { |
| 310 %OptimizeOsr(); |
| 311 } |
| 312 assertEquals(1, a); |
| 313 assertEquals(2, b); |
| 314 assertEquals(3, c); |
| 315 } |
| 316 })(); |
| 317 |
| 318 (function TestInnerInnerArrowFunctionDestructuredParameter_2() { |
| 319 var a = 1; |
| 320 var b = 2; |
| 321 var c = 3; |
| 322 function inner() { |
| 323 var f = ({d, a}) => a + b + c; |
| 324 } |
| 325 for (var i = 0; i < 3; ++i) { |
| 326 if (i == 1) { |
| 327 %OptimizeOsr(); |
| 328 } |
| 329 assertEquals(1, a); |
| 330 assertEquals(2, b); |
| 331 assertEquals(3, c); |
| 332 } |
| 333 })(); |
| 334 |
173 (function TestInnerFunctionInnerFunction() { | 335 (function TestInnerFunctionInnerFunction() { |
174 var a = 1; | 336 var a = 1; |
175 var b = 2; | 337 var b = 2; |
176 var c = 3; | 338 var c = 3; |
177 function inner() { | 339 function inner() { |
178 function a() { } | 340 function a() { } |
179 a; b; c; | 341 a; b; c; |
180 } | 342 } |
181 for (var i = 0; i < 3; ++i) { | 343 for (var i = 0; i < 3; ++i) { |
182 if (i == 1) { | 344 if (i == 1) { |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 if (i == 1) { | 760 if (i == 1) { |
599 %OptimizeOsr(); | 761 %OptimizeOsr(); |
600 } | 762 } |
601 var a; | 763 var a; |
602 function inner() { | 764 function inner() { |
603 const a = 0, b = 0; | 765 const a = 0, b = 0; |
604 } | 766 } |
605 } | 767 } |
606 })(); | 768 })(); |
607 | 769 |
608 (function TestRegress650969_9() { | 770 (function TestRegress650969_9_parameter() { |
609 for (var i = 0; i < 3; ++i) { | 771 for (var i = 0; i < 3; ++i) { |
610 if (i == 1) { | 772 if (i == 1) { |
611 %OptimizeOsr(); | 773 %OptimizeOsr(); |
612 } | 774 } |
613 var a; | 775 var a; |
614 function inner(a) { | 776 function inner(a) {} |
615 } | |
616 } | 777 } |
617 })(); | 778 })(); |
618 | 779 |
619 (function TestRegress650969_10() { | 780 (function TestRegress650969_9_restParameter() { |
620 for (var i = 0; i < 3; ++i) { | 781 for (var i = 0; i < 3; ++i) { |
621 if (i == 1) { | 782 if (i == 1) { |
622 %OptimizeOsr(); | 783 %OptimizeOsr(); |
623 } | 784 } |
624 var a; | 785 var a; |
625 function inner(...a) { | 786 function inner(...a) {} |
| 787 } |
| 788 })(); |
| 789 |
| 790 (function TestRegress650969_9_destructuredParameter_1() { |
| 791 for (var i = 0; i < 3; ++i) { |
| 792 if (i == 1) { |
| 793 %OptimizeOsr(); |
| 794 } |
| 795 var a; |
| 796 function inner([d, a]) {} |
| 797 } |
| 798 })(); |
| 799 |
| 800 (function TestRegress650969_9_destructuredParameter_2() { |
| 801 for (var i = 0; i < 3; ++i) { |
| 802 if (i == 1) { |
| 803 %OptimizeOsr(); |
| 804 } |
| 805 var a; |
| 806 function inner({d, a}) {} |
| 807 } |
| 808 })(); |
| 809 |
| 810 (function TestRegress650969_10_parameter() { |
| 811 for (var i = 0; i < 3; ++i) { |
| 812 if (i == 1) { |
| 813 %OptimizeOsr(); |
| 814 } |
| 815 var a; |
| 816 function inner() { |
| 817 function innerinner(a) {} |
626 } | 818 } |
627 } | 819 } |
628 })(); | 820 })(); |
| 821 |
| 822 (function TestRegress650969_10_restParameter() { |
| 823 for (var i = 0; i < 3; ++i) { |
| 824 if (i == 1) { |
| 825 %OptimizeOsr(); |
| 826 } |
| 827 var a; |
| 828 function inner() { |
| 829 function innerinner(...a) {} |
| 830 } |
| 831 } |
| 832 })(); |
| 833 |
| 834 (function TestRegress650969_10_destructuredParameter_1() { |
| 835 for (var i = 0; i < 3; ++i) { |
| 836 if (i == 1) { |
| 837 %OptimizeOsr(); |
| 838 } |
| 839 var a; |
| 840 function inner() { |
| 841 function innerinner([d, a]) {} |
| 842 } |
| 843 } |
| 844 })(); |
| 845 |
| 846 (function TestRegress650969_10_destructuredParameter_2() { |
| 847 for (var i = 0; i < 3; ++i) { |
| 848 if (i == 1) { |
| 849 %OptimizeOsr(); |
| 850 } |
| 851 var a; |
| 852 function inner() { |
| 853 function innerinner({d, a}) {} |
| 854 } |
| 855 } |
| 856 })(); |
629 | 857 |
630 (function TestRegress650969_11_var() { | 858 (function TestRegress650969_11_var() { |
631 for (var i = 0; i < 3; ++i) { | 859 for (var i = 0; i < 3; ++i) { |
632 if (i == 1) { | 860 if (i == 1) { |
633 %OptimizeOsr(); | 861 %OptimizeOsr(); |
634 } | 862 } |
635 var a; | 863 var a; |
636 function inner() { | 864 function inner() { |
637 var [a, b] = [1, 2]; | 865 var [a, b] = [1, 2]; |
638 } | 866 } |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 if (i == 1) { | 1100 if (i == 1) { |
873 %OptimizeOsr(); | 1101 %OptimizeOsr(); |
874 } | 1102 } |
875 var a; | 1103 var a; |
876 function inner() { | 1104 function inner() { |
877 for (const a = 0; 0 == 1; ) { } | 1105 for (const a = 0; 0 == 1; ) { } |
878 } | 1106 } |
879 } | 1107 } |
880 })(); | 1108 })(); |
881 | 1109 |
| 1110 (function TestRegress650969_18() { |
| 1111 for (var i = 0; i < 3; ++i) { |
| 1112 if (i == 1) { |
| 1113 %OptimizeOsr(); |
| 1114 } |
| 1115 var a; |
| 1116 function inner() { |
| 1117 function innerinner([a, b]) {} |
| 1118 } |
| 1119 } |
| 1120 })(); |
| 1121 |
| 1122 (function TestRegress650969_18() { |
| 1123 for (var i = 0; i < 3; ++i) { |
| 1124 if (i == 1) { |
| 1125 %OptimizeOsr(); |
| 1126 } |
| 1127 var a; |
| 1128 function inner() { |
| 1129 function innerinner(a) {} |
| 1130 } |
| 1131 } |
| 1132 })(); |
| 1133 |
882 // Regression tests for an intermediate stage where unresolved references were | 1134 // Regression tests for an intermediate stage where unresolved references were |
883 // discarded too aggressively. | 1135 // discarded too aggressively. |
884 (function TestRegress650969_sidetrack_var() { | 1136 (function TestRegress650969_sidetrack_var() { |
885 for (var i = 0; i < 3; ++i) { | 1137 for (var i = 0; i < 3; ++i) { |
886 if (i == 1) { | 1138 if (i == 1) { |
887 %OptimizeOsr(); | 1139 %OptimizeOsr(); |
888 } | 1140 } |
889 var a = 0; | 1141 var a = 0; |
890 function inner() { | 1142 function inner() { |
891 return a; | 1143 return a; |
(...skipping 20 matching lines...) Expand all Loading... |
912 if (i == 1) { | 1164 if (i == 1) { |
913 %OptimizeOsr(); | 1165 %OptimizeOsr(); |
914 } | 1166 } |
915 var a = 0; | 1167 var a = 0; |
916 function inner() { | 1168 function inner() { |
917 return a; | 1169 return a; |
918 const {b: {a}, c} = {b: {a: 1}, c: 2}; | 1170 const {b: {a}, c} = {b: {a: 1}, c: 2}; |
919 } | 1171 } |
920 } | 1172 } |
921 })(); | 1173 })(); |
OLD | NEW |