Chromium Code Reviews| 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 2517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2528 void BytecodeGenerator::VisitCallSuper(Call* expr) { | 2528 void BytecodeGenerator::VisitCallSuper(Call* expr) { |
| 2529 RegisterAllocationScope register_scope(this); | 2529 RegisterAllocationScope register_scope(this); |
| 2530 SuperCallReference* super = expr->expression()->AsSuperCallReference(); | 2530 SuperCallReference* super = expr->expression()->AsSuperCallReference(); |
| 2531 | 2531 |
| 2532 // Prepare the constructor to the super call. | 2532 // Prepare the constructor to the super call. |
| 2533 VisitForAccumulatorValue(super->this_function_var()); | 2533 VisitForAccumulatorValue(super->this_function_var()); |
| 2534 Register constructor = register_allocator()->NewRegister(); | 2534 Register constructor = register_allocator()->NewRegister(); |
| 2535 builder()->GetSuperConstructor(constructor); | 2535 builder()->GetSuperConstructor(constructor); |
| 2536 | 2536 |
| 2537 ZoneList<Expression*>* args = expr->arguments(); | 2537 ZoneList<Expression*>* args = expr->arguments(); |
| 2538 RegisterList args_regs = register_allocator()->NewGrowableRegisterList(); | |
| 2539 VisitArguments(args, &args_regs); | |
| 2540 // The new target is loaded into the accumulator from the | |
| 2541 // {new.target} variable. | |
| 2542 VisitForAccumulatorValue(super->new_target_var()); | |
| 2538 | 2543 |
| 2539 // When a super call contains a spread, a CallSuper AST node is only created | 2544 // When a super call contains a spread, a CallSuper AST node is only created |
| 2540 // if there is exactly one spread, and it is the last argument. | 2545 // if there is exactly one spread, and it is the last argument. |
| 2541 if (!args->is_empty() && args->last()->IsSpread()) { | 2546 if (!args->is_empty() && args->last()->IsSpread()) { |
| 2542 RegisterList args_regs = register_allocator()->NewGrowableRegisterList(); | 2547 builder()->NewWithSpread(constructor, args_regs); |
|
rmcilroy
2017/01/16 16:28:02
nit - add a TODO to collect type on the feedback s
petermarshall
2017/01/18 10:05:32
Done
petermarshall
2017/01/18 10:05:32
Done
| |
| 2543 Register constructor_arg = | |
| 2544 register_allocator()->GrowRegisterList(&args_regs); | |
| 2545 builder()->MoveRegister(constructor, constructor_arg); | |
| 2546 // Reserve argument reg for new.target in correct place for runtime call. | |
| 2547 // TODO(petermarshall): Remove this when changing bytecode to use the new | |
| 2548 // stub. | |
| 2549 Register new_target = register_allocator()->GrowRegisterList(&args_regs); | |
| 2550 VisitArguments(args, &args_regs); | |
| 2551 VisitForRegisterValue(super->new_target_var(), new_target); | |
| 2552 builder()->NewWithSpread(args_regs); | |
| 2553 } else { | 2548 } else { |
| 2554 RegisterList args_regs = register_allocator()->NewGrowableRegisterList(); | |
| 2555 VisitArguments(args, &args_regs); | |
| 2556 // The new target is loaded into the accumulator from the | |
| 2557 // {new.target} variable. | |
| 2558 VisitForAccumulatorValue(super->new_target_var()); | |
| 2559 | |
| 2560 // Call construct. | 2549 // Call construct. |
| 2561 builder()->SetExpressionPosition(expr); | 2550 builder()->SetExpressionPosition(expr); |
|
rmcilroy
2017/01/16 16:28:02
nit - move setExpressionPosition to be outside the
petermarshall
2017/01/18 10:05:32
Oops - done
| |
| 2562 // TODO(turbofan): For now we do gather feedback on super constructor | 2551 // TODO(turbofan): For now we do gather feedback on super constructor |
| 2563 // calls, utilizing the existing machinery to inline the actual call | 2552 // calls, utilizing the existing machinery to inline the actual call |
| 2564 // target and the JSCreate for the implicit receiver allocation. This | 2553 // target and the JSCreate for the implicit receiver allocation. This |
| 2565 // is not an ideal solution for super constructor calls, but it gets | 2554 // is not an ideal solution for super constructor calls, but it gets |
| 2566 // the job done for now. In the long run we might want to revisit this | 2555 // the job done for now. In the long run we might want to revisit this |
| 2567 // and come up with a better way. | 2556 // and come up with a better way. |
| 2568 int const feedback_slot_index = feedback_index(expr->CallFeedbackICSlot()); | 2557 int const feedback_slot_index = feedback_index(expr->CallFeedbackICSlot()); |
| 2569 builder()->New(constructor, args_regs, feedback_slot_index); | 2558 builder()->New(constructor, args_regs, feedback_slot_index); |
| 2570 } | 2559 } |
| 2571 } | 2560 } |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3321 } | 3310 } |
| 3322 | 3311 |
| 3323 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 3312 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { |
| 3324 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 3313 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict |
| 3325 : Runtime::kStoreKeyedToSuper_Sloppy; | 3314 : Runtime::kStoreKeyedToSuper_Sloppy; |
| 3326 } | 3315 } |
| 3327 | 3316 |
| 3328 } // namespace interpreter | 3317 } // namespace interpreter |
| 3329 } // namespace internal | 3318 } // namespace internal |
| 3330 } // namespace v8 | 3319 } // namespace v8 |
| OLD | NEW |