OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/interpreter/bytecode-generator.h" | 5 #include "src/interpreter/bytecode-generator.h" |
6 | 6 |
7 #include "src/ast/compile-time-value.h" | 7 #include "src/ast/compile-time-value.h" |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/builtins/builtins-constructor.h" | 9 #include "src/builtins/builtins-constructor.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 2521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2532 void BytecodeGenerator::VisitCallSuper(Call* expr) { | 2532 void BytecodeGenerator::VisitCallSuper(Call* expr) { |
2533 RegisterAllocationScope register_scope(this); | 2533 RegisterAllocationScope register_scope(this); |
2534 SuperCallReference* super = expr->expression()->AsSuperCallReference(); | 2534 SuperCallReference* super = expr->expression()->AsSuperCallReference(); |
2535 | 2535 |
2536 // Prepare the constructor to the super call. | 2536 // Prepare the constructor to the super call. |
2537 VisitForAccumulatorValue(super->this_function_var()); | 2537 VisitForAccumulatorValue(super->this_function_var()); |
2538 Register constructor = register_allocator()->NewRegister(); | 2538 Register constructor = register_allocator()->NewRegister(); |
2539 builder()->GetSuperConstructor(constructor); | 2539 builder()->GetSuperConstructor(constructor); |
2540 | 2540 |
2541 ZoneList<Expression*>* args = expr->arguments(); | 2541 ZoneList<Expression*>* args = expr->arguments(); |
| 2542 RegisterList args_regs = register_allocator()->NewGrowableRegisterList(); |
| 2543 VisitArguments(args, &args_regs); |
| 2544 // The new target is loaded into the accumulator from the |
| 2545 // {new.target} variable. |
| 2546 VisitForAccumulatorValue(super->new_target_var()); |
2542 | 2547 |
2543 // When a super call contains a spread, a CallSuper AST node is only created | 2548 // When a super call contains a spread, a CallSuper AST node is only created |
2544 // if there is exactly one spread, and it is the last argument. | 2549 // if there is exactly one spread, and it is the last argument. |
2545 if (!args->is_empty() && args->last()->IsSpread()) { | 2550 if (!args->is_empty() && args->last()->IsSpread()) { |
2546 RegisterList args_regs = register_allocator()->NewGrowableRegisterList(); | 2551 builder()->NewWithSpread(constructor, args_regs); |
2547 Register constructor_arg = | |
2548 register_allocator()->GrowRegisterList(&args_regs); | |
2549 builder()->MoveRegister(constructor, constructor_arg); | |
2550 // Reserve argument reg for new.target in correct place for runtime call. | |
2551 // TODO(petermarshall): Remove this when changing bytecode to use the new | |
2552 // stub. | |
2553 Register new_target = register_allocator()->GrowRegisterList(&args_regs); | |
2554 VisitArguments(args, &args_regs); | |
2555 VisitForRegisterValue(super->new_target_var(), new_target); | |
2556 builder()->NewWithSpread(args_regs); | |
2557 } else { | 2552 } else { |
2558 RegisterList args_regs = register_allocator()->NewGrowableRegisterList(); | |
2559 VisitArguments(args, &args_regs); | |
2560 // The new target is loaded into the accumulator from the | |
2561 // {new.target} variable. | |
2562 VisitForAccumulatorValue(super->new_target_var()); | |
2563 | |
2564 // Call construct. | 2553 // Call construct. |
2565 builder()->SetExpressionPosition(expr); | 2554 builder()->SetExpressionPosition(expr); |
2566 // TODO(turbofan): For now we do gather feedback on super constructor | 2555 // TODO(turbofan): For now we do gather feedback on super constructor |
2567 // calls, utilizing the existing machinery to inline the actual call | 2556 // calls, utilizing the existing machinery to inline the actual call |
2568 // target and the JSCreate for the implicit receiver allocation. This | 2557 // target and the JSCreate for the implicit receiver allocation. This |
2569 // is not an ideal solution for super constructor calls, but it gets | 2558 // is not an ideal solution for super constructor calls, but it gets |
2570 // the job done for now. In the long run we might want to revisit this | 2559 // the job done for now. In the long run we might want to revisit this |
2571 // and come up with a better way. | 2560 // and come up with a better way. |
2572 int const feedback_slot_index = feedback_index(expr->CallFeedbackICSlot()); | 2561 int const feedback_slot_index = feedback_index(expr->CallFeedbackICSlot()); |
2573 builder()->New(constructor, args_regs, feedback_slot_index); | 2562 builder()->New(constructor, args_regs, feedback_slot_index); |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3325 } | 3314 } |
3326 | 3315 |
3327 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 3316 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { |
3328 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 3317 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict |
3329 : Runtime::kStoreKeyedToSuper_Sloppy; | 3318 : Runtime::kStoreKeyedToSuper_Sloppy; |
3330 } | 3319 } |
3331 | 3320 |
3332 } // namespace interpreter | 3321 } // namespace interpreter |
3333 } // namespace internal | 3322 } // namespace internal |
3334 } // namespace v8 | 3323 } // namespace v8 |
OLD | NEW |