Index: src/interpreter/bytecode-generator.cc |
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
index 6d4f1ae75d3bd5109368e15c367bea027ab79608..a0d5dc17bf199d20b4d7e89c24e4358d8634767f 100644 |
--- a/src/interpreter/bytecode-generator.cc |
+++ b/src/interpreter/bytecode-generator.cc |
@@ -587,6 +587,8 @@ BytecodeGenerator::BytecodeGenerator(CompilationInfo* info) |
loop_depth_(0), |
home_object_symbol_(info->isolate()->factory()->home_object_symbol()), |
iterator_symbol_(info->isolate()->factory()->iterator_symbol()), |
+ async_iterator_symbol_( |
+ info->isolate()->factory()->async_iterator_symbol()), |
prototype_string_(info->isolate()->factory()->prototype_string()), |
empty_fixed_array_(info->isolate()->factory()->empty_fixed_array()), |
undefined_string_( |
@@ -2908,21 +2910,63 @@ void BytecodeGenerator::VisitGetIterator(GetIterator* expr) { |
VisitForAccumulatorValue(expr->iterable()); |
- // Let method be GetMethod(obj, @@iterator). |
- builder() |
- ->StoreAccumulatorInRegister(obj) |
- .LoadNamedProperty(obj, iterator_symbol(), feedback_index(load_slot)) |
- .StoreAccumulatorInRegister(method); |
- |
- // Let iterator be Call(method, obj). |
- builder()->Call(method, args, feedback_index(call_slot), |
- Call::NAMED_PROPERTY_CALL); |
- |
- // If Type(iterator) is not Object, throw a TypeError exception. |
- BytecodeLabel no_type_error; |
- builder()->JumpIfJSReceiver(&no_type_error); |
- builder()->CallRuntime(Runtime::kThrowSymbolIteratorInvalid); |
- builder()->Bind(&no_type_error); |
+ if (expr->hint() == GetIterator::kAsync) { |
+ FeedbackVectorSlot load_slot2 = expr->AsyncIteratorPropertyFeedbackSlot(); |
+ FeedbackVectorSlot call_slot2 = expr->AsyncIteratorCallFeedbackSlot(); |
rmcilroy
2017/01/20 10:34:01
nit - could you name these async_load_slot, etc.
caitp
2017/01/20 20:17:19
done
|
+ Register tmp = register_allocator()->NewRegister(); |
rmcilroy
2017/01/20 10:34:01
Unused
caitp
2017/01/20 20:17:19
It's gone
|
+ // Set method to GetMethod(obj, @@asyncIterator) |
+ builder()->StoreAccumulatorInRegister(obj).LoadNamedProperty( |
+ obj, async_iterator_symbol(), feedback_index(load_slot2)); |
neis
2017/01/20 14:38:15
Nit: please format in the same style as below.
|
+ |
+ BytecodeLabel async_iterator_undefined, async_iterator_null, done; |
+ builder()->JumpIfUndefined(&async_iterator_undefined); |
+ builder()->JumpIfNull(&async_iterator_null); |
rmcilroy
2017/01/20 10:34:01
You could use TestUndetectable, JumpIfTrue here in
caitp
2017/01/20 20:17:19
TestUndetectable checks for the Undetectable map b
rmcilroy
2017/01/25 09:20:44
Ahh make sense, I forgot about the weird document.
|
+ |
+ // Let iterator be Call(method, obj) |
+ builder()->StoreAccumulatorInRegister(method).Call( |
+ method, args, feedback_index(call_slot), Call::NAMED_PROPERTY_CALL); |
neis
2017/01/20 14:38:15
Shouldn't this be call_slot2 here? And in the Call
caitp
2017/01/20 20:17:19
Renamed these things to `load_iter_slot`, `call_it
|
+ |
+ // If Type(iterator) is not Object, throw a TypeError exception. |
+ builder()->JumpIfJSReceiver(&done); |
+ builder()->CallRuntime(Runtime::kThrowSymbolAsyncIteratorInvalid); |
+ |
+ builder()->Bind(&async_iterator_undefined); |
+ builder()->Bind(&async_iterator_null); |
+ // If method is undefined, |
+ // Let syncMethod be GetMethod(obj, @@iterator) |
+ builder() |
+ ->LoadNamedProperty(obj, iterator_symbol(), feedback_index(load_slot)) |
+ .StoreAccumulatorInRegister(method); |
+ |
+ // Let syncIterator be Call(syncMethod, obj) |
+ builder()->Call(method, args, feedback_index(call_slot2), |
+ Call::NAMED_PROPERTY_CALL); |
+ |
+ // Return CreateAsyncFromSyncIterator(syncIterator) |
+ RegisterList args = register_allocator()->NewRegisterList(1); |
+ Register sync_iterator = args[0]; |
rmcilroy
2017/01/20 10:34:01
No need to allocate a register list for a single r
caitp
2017/01/20 20:17:19
Something like this?
```
// Return CreateAsyn
rmcilroy
2017/01/25 09:20:44
Yeah this is fine
|
+ builder() |
+ ->StoreAccumulatorInRegister(sync_iterator) |
+ .CallRuntime(Runtime::kInlineCreateAsyncFromSyncIterator, args); |
+ |
+ builder()->Bind(&done); |
+ } else { |
+ // Let method be GetMethod(obj, @@iterator). |
+ builder() |
+ ->StoreAccumulatorInRegister(obj) |
+ .LoadNamedProperty(obj, iterator_symbol(), feedback_index(load_slot)) |
+ .StoreAccumulatorInRegister(method); |
+ |
+ // Let iterator be Call(method, obj). |
+ builder()->Call(method, args, feedback_index(call_slot), |
+ Call::NAMED_PROPERTY_CALL); |
+ |
+ // If Type(iterator) is not Object, throw a TypeError exception. |
+ BytecodeLabel no_type_error; |
+ builder()->JumpIfJSReceiver(&no_type_error); |
+ builder()->CallRuntime(Runtime::kThrowSymbolIteratorInvalid); |
+ builder()->Bind(&no_type_error); |
+ } |
} |
void BytecodeGenerator::VisitThisFunction(ThisFunction* expr) { |