| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_X64 | 7 #if V8_TARGET_ARCH_X64 |
| 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 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 } | 1245 } |
| 1246 | 1246 |
| 1247 | 1247 |
| 1248 void FullCodeGenerator::VisitForOfStatement(ForOfStatement* stmt) { | 1248 void FullCodeGenerator::VisitForOfStatement(ForOfStatement* stmt) { |
| 1249 Comment cmnt(masm_, "[ ForOfStatement"); | 1249 Comment cmnt(masm_, "[ ForOfStatement"); |
| 1250 SetStatementPosition(stmt); | 1250 SetStatementPosition(stmt); |
| 1251 | 1251 |
| 1252 Iteration loop_statement(this, stmt); | 1252 Iteration loop_statement(this, stmt); |
| 1253 increment_loop_depth(); | 1253 increment_loop_depth(); |
| 1254 | 1254 |
| 1255 // var iterator = iterable[@@iterator]() | 1255 // var iterable = subject |
| 1256 VisitForAccumulatorValue(stmt->assign_iterator()); | 1256 VisitForAccumulatorValue(stmt->assign_iterable()); |
| 1257 | 1257 |
| 1258 // As with for-in, skip the loop if the iterator is null or undefined. | 1258 // As with for-in, skip the loop if the iterable is null or undefined. |
| 1259 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); | 1259 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); |
| 1260 __ j(equal, loop_statement.break_label()); | 1260 __ j(equal, loop_statement.break_label()); |
| 1261 __ CompareRoot(rax, Heap::kNullValueRootIndex); | 1261 __ CompareRoot(rax, Heap::kNullValueRootIndex); |
| 1262 __ j(equal, loop_statement.break_label()); | 1262 __ j(equal, loop_statement.break_label()); |
| 1263 | 1263 |
| 1264 // Convert the iterator to a JS object. | 1264 // var iterator = iterable[Symbol.iterator](); |
| 1265 Label convert, done_convert; | 1265 VisitForEffect(stmt->assign_iterator()); |
| 1266 __ JumpIfSmi(rax, &convert); | |
| 1267 __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rcx); | |
| 1268 __ j(above_equal, &done_convert); | |
| 1269 __ bind(&convert); | |
| 1270 __ Push(rax); | |
| 1271 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | |
| 1272 __ bind(&done_convert); | |
| 1273 | 1266 |
| 1274 // Loop entry. | 1267 // Loop entry. |
| 1275 __ bind(loop_statement.continue_label()); | 1268 __ bind(loop_statement.continue_label()); |
| 1276 | 1269 |
| 1277 // result = iterator.next() | 1270 // result = iterator.next() |
| 1278 VisitForEffect(stmt->next_result()); | 1271 VisitForEffect(stmt->next_result()); |
| 1279 | 1272 |
| 1280 // if (result.done) break; | 1273 // if (result.done) break; |
| 1281 Label result_not_done; | 1274 Label result_not_done; |
| 1282 VisitForControl(stmt->result_done(), | 1275 VisitForControl(stmt->result_done(), |
| (...skipping 3527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4810 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4803 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 4811 Assembler::target_address_at(call_target_address, | 4804 Assembler::target_address_at(call_target_address, |
| 4812 unoptimized_code)); | 4805 unoptimized_code)); |
| 4813 return OSR_AFTER_STACK_CHECK; | 4806 return OSR_AFTER_STACK_CHECK; |
| 4814 } | 4807 } |
| 4815 | 4808 |
| 4816 | 4809 |
| 4817 } } // namespace v8::internal | 4810 } } // namespace v8::internal |
| 4818 | 4811 |
| 4819 #endif // V8_TARGET_ARCH_X64 | 4812 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |