OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 })(); | 1142 })(); |
1143 | 1143 |
1144 | 1144 |
1145 (function TestNonStrictFunctionCallerPillSimple() { | 1145 (function TestNonStrictFunctionCallerPillSimple() { |
1146 function return_my_caller() { | 1146 function return_my_caller() { |
1147 return return_my_caller.caller; | 1147 return return_my_caller.caller; |
1148 } | 1148 } |
1149 | 1149 |
1150 function strict() { | 1150 function strict() { |
1151 "use strict"; | 1151 "use strict"; |
1152 return return_my_caller(); | 1152 // Returning result via local variable to avoid tail call optimization. |
| 1153 var res = return_my_caller(); |
| 1154 return res; |
1153 } | 1155 } |
1154 assertSame(null, strict()); | 1156 assertSame(null, strict()); |
1155 | 1157 |
1156 function non_strict() { | 1158 function non_strict() { |
1157 return return_my_caller(); | 1159 return return_my_caller(); |
1158 } | 1160 } |
1159 assertSame(non_strict(), non_strict); | 1161 assertSame(non_strict(), non_strict); |
1160 })(); | 1162 })(); |
1161 | 1163 |
1162 | 1164 |
1163 (function TestNonStrictFunctionCallerPill() { | 1165 (function TestNonStrictFunctionCallerPill() { |
1164 function strict(n) { | 1166 function strict(n) { |
1165 "use strict"; | 1167 "use strict"; |
1166 return non_strict(n); | 1168 // Returning result via local variable to avoid tail call optimization. |
| 1169 var res = non_strict(n); |
| 1170 return res; |
1167 } | 1171 } |
1168 | 1172 |
1169 function recurse(n, then) { | 1173 function recurse(n, then) { |
1170 if (n > 0) { | 1174 if (n > 0) { |
1171 return recurse(n - 1, then); | 1175 return recurse(n - 1, then); |
1172 } else { | 1176 } else { |
1173 return then(); | 1177 return then(); |
1174 } | 1178 } |
1175 } | 1179 } |
1176 | 1180 |
1177 function non_strict(n) { | 1181 function non_strict(n) { |
1178 return recurse(n, function() { return non_strict.caller; }); | 1182 return recurse(n, function() { return non_strict.caller; }); |
1179 } | 1183 } |
1180 | 1184 |
1181 function test(n) { | 1185 function test(n) { |
1182 return recurse(n, function() { return strict(n); }); | 1186 return recurse(n, function() { return strict(n); }); |
1183 } | 1187 } |
1184 | 1188 |
1185 for (var i = 0; i < 10; i ++) { | 1189 for (var i = 0; i < 10; i ++) { |
1186 assertSame(null, test(i)); | 1190 assertSame(null, test(i)); |
1187 } | 1191 } |
1188 })(); | 1192 })(); |
1189 | 1193 |
1190 | 1194 |
1191 (function TestNonStrictFunctionCallerDescriptorPill() { | 1195 (function TestNonStrictFunctionCallerDescriptorPill() { |
1192 function strict(n) { | 1196 function strict(n) { |
1193 "use strict"; | 1197 "use strict"; |
1194 return non_strict(n); | 1198 // Returning result via local variable to avoid tail call optimization. |
| 1199 var res = non_strict(n); |
| 1200 return res; |
1195 } | 1201 } |
1196 | 1202 |
1197 function recurse(n, then) { | 1203 function recurse(n, then) { |
1198 if (n > 0) { | 1204 if (n > 0) { |
1199 return recurse(n - 1, then); | 1205 return recurse(n - 1, then); |
1200 } else { | 1206 } else { |
1201 return then(); | 1207 return then(); |
1202 } | 1208 } |
1203 } | 1209 } |
1204 | 1210 |
(...skipping 11 matching lines...) Expand all Loading... |
1216 assertSame(null, test(i)); | 1222 assertSame(null, test(i)); |
1217 } | 1223 } |
1218 })(); | 1224 })(); |
1219 | 1225 |
1220 | 1226 |
1221 (function TestStrictModeEval() { | 1227 (function TestStrictModeEval() { |
1222 "use strict"; | 1228 "use strict"; |
1223 eval("var eval_local = 10;"); | 1229 eval("var eval_local = 10;"); |
1224 assertThrows(function() { return eval_local; }, ReferenceError); | 1230 assertThrows(function() { return eval_local; }, ReferenceError); |
1225 })(); | 1231 })(); |
OLD | NEW |