Chromium Code Reviews| Index: src/interpreter/bytecode-generator.cc |
| diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
| index 1200cacd0707baeb4b9dbaf7ffbb079fc94479ad..74f2d513e05529e98f11e738729d1637f9af9a48 100644 |
| --- a/src/interpreter/bytecode-generator.cc |
| +++ b/src/interpreter/bytecode-generator.cc |
| @@ -2486,24 +2486,51 @@ void BytecodeGenerator::VisitCallSuper(Call* expr) { |
| Register constructor = this_function; // Re-use dead this_function register. |
| builder()->StoreAccumulatorInRegister(constructor); |
| - RegisterList args = |
| - register_allocator()->NewRegisterList(expr->arguments()->length()); |
| - VisitArguments(expr->arguments(), args); |
| + ZoneList<Expression*>* args = expr->arguments(); |
| - // The new target is loaded into the accumulator from the |
| - // {new.target} variable. |
| - VisitForAccumulatorValue(super->new_target_var()); |
| + bool has_spread = false; |
| + for (int i = 0; i < args->length(); i++) { |
| + if (args->at(i)->IsSpread()) has_spread = true; |
| + } |
| - // Call construct. |
| - builder()->SetExpressionPosition(expr); |
| - // TODO(turbofan): For now we do gather feedback on super constructor |
| - // calls, utilizing the existing machinery to inline the actual call |
| - // target and the JSCreate for the implicit receiver allocation. This |
| - // is not an ideal solution for super constructor calls, but it gets |
| - // the job done for now. In the long run we might want to revisit this |
| - // and come up with a better way. |
| - int const feedback_slot_index = feedback_index(expr->CallFeedbackICSlot()); |
| - builder()->New(constructor, args, feedback_slot_index); |
| + if (has_spread) { |
| + // Deal with the spread arg. |
|
rmcilroy
2016/11/30 14:35:32
nit - Prepare the spread arguments. ?
petermarshall
2016/11/30 15:24:48
Done
|
| + RegisterList spread_prepare_args = |
| + register_allocator()->NewRegisterList(args->length()); |
| + VisitArguments(args, spread_prepare_args); |
| + |
| + Runtime::FunctionId function_id = Runtime::kSpreadIterablePrepareVarargs; |
|
rmcilroy
2016/11/30 14:35:32
nit - no need for the function_id variable now
petermarshall
2016/11/30 15:24:48
Done
|
| + builder()->CallRuntime(function_id, spread_prepare_args); |
| + |
| + // Do ReflectConstruct. |
|
rmcilroy
2016/11/30 14:35:32
nit - Call ReflectConstruct to do the actual super
petermarshall
2016/11/30 15:24:48
Done.
|
| + RegisterList reflect_construct_args = |
| + register_allocator()->NewRegisterList(4); |
| + builder()->StoreAccumulatorInRegister(reflect_construct_args[2]); |
| + Register receiver = reflect_construct_args[0]; |
|
rmcilroy
2016/11/30 14:35:32
nit - I'd prefer that the code just consistently u
petermarshall
2016/11/30 15:24:48
Done
|
| + builder()->LoadUndefined().StoreAccumulatorInRegister(receiver); |
| + builder()->MoveRegister(constructor, reflect_construct_args[1]); |
| + VisitForRegisterValue(super->new_target_var(), reflect_construct_args[3]); |
| + builder()->CallJSRuntime(Context::REFLECT_CONSTRUCT_INDEX, |
| + reflect_construct_args); |
| + } else { |
| + RegisterList args_regs = |
| + register_allocator()->NewRegisterList(args->length()); |
| + VisitArguments(args, args_regs); |
| + // The new target is loaded into the accumulator from the |
| + // {new.target} variable. |
| + VisitForAccumulatorValue(super->new_target_var()); |
| + |
| + // Call construct. |
| + builder()->SetExpressionPosition(expr); |
| + // TODO(turbofan): For now we do gather feedback on super constructor |
| + // calls, utilizing the existing machinery to inline the actual call |
| + // target and the JSCreate for the implicit receiver allocation. This |
| + // is not an ideal solution for super constructor calls, but it gets |
| + // the job done for now. In the long run we might want to revisit this |
| + // and come up with a better way. |
| + int const feedback_slot_index = feedback_index(expr->CallFeedbackICSlot()); |
| + builder()->New(constructor, args_regs, feedback_slot_index); |
| + } |
| } |
| void BytecodeGenerator::VisitCallNew(CallNew* expr) { |
| @@ -2811,7 +2838,7 @@ void BytecodeGenerator::VisitArithmeticExpression(BinaryOperation* expr) { |
| builder()->BinaryOperation(expr->op(), lhs, feedback_index(slot)); |
| } |
| -void BytecodeGenerator::VisitSpread(Spread* expr) { UNREACHABLE(); } |
| +void BytecodeGenerator::VisitSpread(Spread* expr) { Visit(expr->expression()); } |
| void BytecodeGenerator::VisitEmptyParentheses(EmptyParentheses* expr) { |
| UNREACHABLE(); |