Index: src/interpreter/bytecode-generator.cc |
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
index 5565e01f547fc2db137c61a1c82d8594b4cdef41..2858d2c1977842d272127da979aa7c4f1b0514c1 100644 |
--- a/src/interpreter/bytecode-generator.cc |
+++ b/src/interpreter/bytecode-generator.cc |
@@ -583,6 +583,7 @@ BytecodeGenerator::BytecodeGenerator(CompilationInfo* info) |
generator_state_(), |
loop_depth_(0), |
home_object_symbol_(info->isolate()->factory()->home_object_symbol()), |
+ iterator_symbol_(info->isolate()->factory()->iterator_symbol()), |
empty_fixed_array_(info->isolate()->factory()->empty_fixed_array()) { |
AstValueFactory* ast_value_factory = info->parse_info()->ast_value_factory(); |
const AstRawString* prototype_string = ast_value_factory->prototype_string(); |
@@ -2844,6 +2845,30 @@ void BytecodeGenerator::VisitEmptyParentheses(EmptyParentheses* expr) { |
UNREACHABLE(); |
} |
+void BytecodeGenerator::VisitGetIterator(GetIterator* expr) { |
+ FeedbackVectorSlot load_slot = expr->IteratorPropertyFeedbackSlot(); |
+ FeedbackVectorSlot call_slot = expr->IteratorCallFeedbackSlot(); |
+ |
+ RegisterList args = register_allocator()->NewRegisterList(1); |
+ Register method = register_allocator()->NewRegister(); |
+ Register obj = args[0]; |
+ |
+ VisitForAccumulatorValue(expr->iterable()); |
+ |
+ // Let method be ? GetMethod(obj, @@iterator). |
rmcilroy
2016/12/06 15:02:28
Not sure what the "?" means here. Can we just remo
caitp
2016/12/06 15:14:58
It's the spec's short form for "ReturnIfAbrupt(<co
rmcilroy
2016/12/07 10:50:41
Yeah I would rather we remove it (and add the comm
|
+ builder() |
neis
2016/12/07 10:17:27
Please change the comment to reflect that the resu
|
+ ->StoreAccumulatorInRegister(obj) |
+ .LoadNamedProperty(obj, iterator_symbol(), feedback_index(load_slot)) |
+ .StoreAccumulatorInRegister(method) |
+ .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) { |
builder()->LoadAccumulatorWithRegister(Register::function_closure()); |
} |