OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_ARM64 | 7 #if V8_TARGET_ARCH_ARM64 |
8 | 8 |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1273 } | 1273 } |
1274 | 1274 |
1275 | 1275 |
1276 void FullCodeGenerator::VisitForOfStatement(ForOfStatement* stmt) { | 1276 void FullCodeGenerator::VisitForOfStatement(ForOfStatement* stmt) { |
1277 Comment cmnt(masm_, "[ ForOfStatement"); | 1277 Comment cmnt(masm_, "[ ForOfStatement"); |
1278 SetStatementPosition(stmt); | 1278 SetStatementPosition(stmt); |
1279 | 1279 |
1280 Iteration loop_statement(this, stmt); | 1280 Iteration loop_statement(this, stmt); |
1281 increment_loop_depth(); | 1281 increment_loop_depth(); |
1282 | 1282 |
1283 // var iterator = iterable[@@iterator]() | 1283 // var iterable = subject |
1284 VisitForAccumulatorValue(stmt->assign_iterator()); | 1284 VisitForAccumulatorValue(stmt->assign_iterable()); |
1285 | 1285 |
1286 // As with for-in, skip the loop if the iterator is null or undefined. | 1286 // As with for-in, skip the loop if the iterator is null or undefined. |
1287 Register iterator = x0; | 1287 Register iterator = x0; |
1288 __ JumpIfRoot(iterator, Heap::kUndefinedValueRootIndex, | 1288 __ JumpIfRoot(iterator, Heap::kUndefinedValueRootIndex, |
1289 loop_statement.break_label()); | 1289 loop_statement.break_label()); |
1290 __ JumpIfRoot(iterator, Heap::kNullValueRootIndex, | 1290 __ JumpIfRoot(iterator, Heap::kNullValueRootIndex, |
1291 loop_statement.break_label()); | 1291 loop_statement.break_label()); |
1292 | 1292 |
1293 // Convert the iterator to a JS object. | 1293 // var iterator = iterable[Symbol.iterator](); |
1294 Label convert, done_convert; | 1294 VisitForEffect(stmt->assign_iterator()); |
1295 __ JumpIfSmi(iterator, &convert); | |
1296 __ CompareObjectType(iterator, x1, x1, FIRST_SPEC_OBJECT_TYPE); | |
1297 __ B(ge, &done_convert); | |
1298 __ Bind(&convert); | |
1299 __ Push(iterator); | |
1300 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | |
1301 __ Bind(&done_convert); | |
1302 __ Push(iterator); | |
1303 | 1295 |
1304 // Loop entry. | 1296 // Loop entry. |
1305 __ Bind(loop_statement.continue_label()); | 1297 __ Bind(loop_statement.continue_label()); |
1306 | 1298 |
1307 // result = iterator.next() | 1299 // result = iterator.next() |
1308 VisitForEffect(stmt->next_result()); | 1300 VisitForEffect(stmt->next_result()); |
1309 | 1301 |
1310 // if (result.done) break; | 1302 // if (result.done) break; |
1311 Label result_not_done; | 1303 Label result_not_done; |
1312 VisitForControl(stmt->result_done(), | 1304 VisitForControl(stmt->result_done(), |
(...skipping 3580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4893 return previous_; | 4885 return previous_; |
4894 } | 4886 } |
4895 | 4887 |
4896 | 4888 |
4897 #undef __ | 4889 #undef __ |
4898 | 4890 |
4899 | 4891 |
4900 } } // namespace v8::internal | 4892 } } // namespace v8::internal |
4901 | 4893 |
4902 #endif // V8_TARGET_ARCH_ARM64 | 4894 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |