OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1254 __ Drop(5); | 1254 __ Drop(5); |
1255 | 1255 |
1256 // Exit and decrement the loop depth. | 1256 // Exit and decrement the loop depth. |
1257 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 1257 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
1258 __ Bind(&exit); | 1258 __ Bind(&exit); |
1259 decrement_loop_depth(); | 1259 decrement_loop_depth(); |
1260 } | 1260 } |
1261 | 1261 |
1262 | 1262 |
1263 void FullCodeGenerator::VisitForOfStatement(ForOfStatement* stmt) { | 1263 void FullCodeGenerator::VisitForOfStatement(ForOfStatement* stmt) { |
1264 UNIMPLEMENTED(); | 1264 Comment cmnt(masm_, "[ ForOfStatement"); |
| 1265 SetStatementPosition(stmt); |
| 1266 |
| 1267 Iteration loop_statement(this, stmt); |
| 1268 increment_loop_depth(); |
| 1269 |
| 1270 // var iterator = iterable[@@iterator]() |
| 1271 VisitForAccumulatorValue(stmt->assign_iterator()); |
| 1272 |
| 1273 // As with for-in, skip the loop if the iterator is null or undefined. |
| 1274 __ CompareRoot(x0, Heap::kUndefinedValueRootIndex); |
| 1275 __ B(eq, loop_statement.break_label()); |
| 1276 __ CompareRoot(x0, Heap::kNullValueRootIndex); |
| 1277 __ B(eq, loop_statement.break_label()); |
| 1278 |
| 1279 // Convert the iterator to a JS object. |
| 1280 Label convert, done_convert; |
| 1281 __ JumpIfSmi(x0, &convert); |
| 1282 __ CompareObjectType(x0, x10, x11, FIRST_SPEC_OBJECT_TYPE); |
| 1283 __ B(ge, &done_convert); |
| 1284 __ Bind(&convert); |
| 1285 __ Push(x0); |
| 1286 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
| 1287 __ Bind(&done_convert); |
| 1288 __ Push(x0); |
| 1289 |
| 1290 // Loop entry. |
| 1291 __ Bind(loop_statement.continue_label()); |
| 1292 |
| 1293 // result = iterator.next() |
| 1294 VisitForEffect(stmt->next_result()); |
| 1295 |
| 1296 // if (result.done) break; |
| 1297 Label result_not_done; |
| 1298 VisitForControl(stmt->result_done(), |
| 1299 loop_statement.break_label(), |
| 1300 &result_not_done, |
| 1301 &result_not_done); |
| 1302 __ Bind(&result_not_done); |
| 1303 |
| 1304 // each = result.value |
| 1305 VisitForEffect(stmt->assign_each()); |
| 1306 |
| 1307 // Generate code for the body of the loop. |
| 1308 Visit(stmt->body()); |
| 1309 |
| 1310 // Check stack before looping. |
| 1311 PrepareForBailoutForId(stmt->BackEdgeId(), NO_REGISTERS); |
| 1312 EmitBackEdgeBookkeeping(stmt, loop_statement.continue_label()); |
| 1313 __ B(loop_statement.continue_label()); |
| 1314 |
| 1315 // Exit and decrement the loop depth. |
| 1316 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
| 1317 __ Bind(loop_statement.break_label()); |
| 1318 decrement_loop_depth(); |
1265 } | 1319 } |
1266 | 1320 |
1267 | 1321 |
1268 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, | 1322 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, |
1269 bool pretenure) { | 1323 bool pretenure) { |
1270 // Use the fast case closure allocation code that allocates in new space for | 1324 // Use the fast case closure allocation code that allocates in new space for |
1271 // nested functions that don't need literals cloning. If we're running with | 1325 // nested functions that don't need literals cloning. If we're running with |
1272 // the --always-opt or the --prepare-always-opt flag, we need to use the | 1326 // the --always-opt or the --prepare-always-opt flag, we need to use the |
1273 // runtime function so that the new function we are creating here gets a | 1327 // runtime function so that the new function we are creating here gets a |
1274 // chance to have its code optimized and doesn't just get a copy of the | 1328 // chance to have its code optimized and doesn't just get a copy of the |
(...skipping 3663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4938 return previous_; | 4992 return previous_; |
4939 } | 4993 } |
4940 | 4994 |
4941 | 4995 |
4942 #undef __ | 4996 #undef __ |
4943 | 4997 |
4944 | 4998 |
4945 } } // namespace v8::internal | 4999 } } // namespace v8::internal |
4946 | 5000 |
4947 #endif // V8_TARGET_ARCH_A64 | 5001 #endif // V8_TARGET_ARCH_A64 |
OLD | NEW |