| 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/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/interpreter/bytecode-flags.h" | 10 #include "src/interpreter/bytecode-flags.h" |
| (...skipping 2673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2684 ->CallRuntime(Runtime::kResolvePossiblyDirectEval, callee_for_eval, 6) | 2684 ->CallRuntime(Runtime::kResolvePossiblyDirectEval, callee_for_eval, 6) |
| 2685 .StoreAccumulatorInRegister(callee); | 2685 .StoreAccumulatorInRegister(callee); |
| 2686 } | 2686 } |
| 2687 | 2687 |
| 2688 builder()->SetExpressionPosition(expr); | 2688 builder()->SetExpressionPosition(expr); |
| 2689 | 2689 |
| 2690 int feedback_slot_index; | 2690 int feedback_slot_index; |
| 2691 if (expr->CallFeedbackICSlot().IsInvalid()) { | 2691 if (expr->CallFeedbackICSlot().IsInvalid()) { |
| 2692 DCHECK(call_type == Call::POSSIBLY_EVAL_CALL); | 2692 DCHECK(call_type == Call::POSSIBLY_EVAL_CALL); |
| 2693 // Valid type feedback slots can only be greater than kReservedIndexCount. | 2693 // Valid type feedback slots can only be greater than kReservedIndexCount. |
| 2694 // We use 0 to indicate an invalid slot it. Statically assert that 0 cannot | 2694 // We use 0 to indicate an invalid slot id. Statically assert that 0 cannot |
| 2695 // be a valid slot id. | 2695 // be a valid slot id. |
| 2696 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); | 2696 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); |
| 2697 feedback_slot_index = 0; | 2697 feedback_slot_index = 0; |
| 2698 } else { | 2698 } else { |
| 2699 feedback_slot_index = feedback_index(expr->CallFeedbackICSlot()); | 2699 feedback_slot_index = feedback_index(expr->CallFeedbackICSlot()); |
| 2700 } | 2700 } |
| 2701 builder()->Call(callee, receiver, 1 + args->length(), feedback_slot_index, | 2701 builder()->Call(callee, receiver, 1 + args->length(), feedback_slot_index, |
| 2702 expr->tail_call_mode()); | 2702 expr->tail_call_mode()); |
| 2703 execution_result()->SetResultInAccumulator(); | 2703 execution_result()->SetResultInAccumulator(); |
| 2704 } | 2704 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2719 | 2719 |
| 2720 ZoneList<Expression*>* args = expr->arguments(); | 2720 ZoneList<Expression*>* args = expr->arguments(); |
| 2721 Register first_arg = VisitArguments(args); | 2721 Register first_arg = VisitArguments(args); |
| 2722 | 2722 |
| 2723 // The new target is loaded into the accumulator from the | 2723 // The new target is loaded into the accumulator from the |
| 2724 // {new.target} variable. | 2724 // {new.target} variable. |
| 2725 VisitForAccumulatorValue(super->new_target_var()); | 2725 VisitForAccumulatorValue(super->new_target_var()); |
| 2726 | 2726 |
| 2727 // Call construct. | 2727 // Call construct. |
| 2728 builder()->SetExpressionPosition(expr); | 2728 builder()->SetExpressionPosition(expr); |
| 2729 builder()->New(constructor, first_arg, args->length()); | 2729 // Valid type feedback slots can only be greater than kReservedIndexCount. |
| 2730 // Assert that 0 cannot be valid a valid slot id. |
| 2731 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); |
| 2732 // Type feedback is not necessary for super constructor calls. The type |
| 2733 // information can be inferred in most cases. Slot id 0 indicates type |
| 2734 // feedback is not required. |
| 2735 builder()->New(constructor, first_arg, args->length(), 0); |
| 2730 execution_result()->SetResultInAccumulator(); | 2736 execution_result()->SetResultInAccumulator(); |
| 2731 } | 2737 } |
| 2732 | 2738 |
| 2733 void BytecodeGenerator::VisitCallNew(CallNew* expr) { | 2739 void BytecodeGenerator::VisitCallNew(CallNew* expr) { |
| 2734 Register constructor = register_allocator()->NewRegister(); | 2740 Register constructor = register_allocator()->NewRegister(); |
| 2735 VisitForAccumulatorValue(expr->expression()); | 2741 VisitForAccumulatorValue(expr->expression()); |
| 2736 builder()->StoreAccumulatorInRegister(constructor); | 2742 builder()->StoreAccumulatorInRegister(constructor); |
| 2737 | 2743 |
| 2738 ZoneList<Expression*>* args = expr->arguments(); | 2744 ZoneList<Expression*>* args = expr->arguments(); |
| 2739 Register first_arg = VisitArguments(args); | 2745 Register first_arg = VisitArguments(args); |
| 2740 | 2746 |
| 2741 builder()->SetExpressionPosition(expr); | 2747 builder()->SetExpressionPosition(expr); |
| 2742 // The accumulator holds new target which is the same as the | 2748 // The accumulator holds new target which is the same as the |
| 2743 // constructor for CallNew. | 2749 // constructor for CallNew. |
| 2744 builder() | 2750 builder() |
| 2745 ->LoadAccumulatorWithRegister(constructor) | 2751 ->LoadAccumulatorWithRegister(constructor) |
| 2746 .New(constructor, first_arg, args->length()); | 2752 .New(constructor, first_arg, args->length(), |
| 2753 feedback_index(expr->CallNewFeedbackSlot())); |
| 2747 execution_result()->SetResultInAccumulator(); | 2754 execution_result()->SetResultInAccumulator(); |
| 2748 } | 2755 } |
| 2749 | 2756 |
| 2750 void BytecodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 2757 void BytecodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
| 2751 ZoneList<Expression*>* args = expr->arguments(); | 2758 ZoneList<Expression*>* args = expr->arguments(); |
| 2752 if (expr->is_jsruntime()) { | 2759 if (expr->is_jsruntime()) { |
| 2753 // Allocate a register for the receiver and load it with undefined. | 2760 // Allocate a register for the receiver and load it with undefined. |
| 2754 register_allocator()->PrepareForConsecutiveAllocations(1 + args->length()); | 2761 register_allocator()->PrepareForConsecutiveAllocations(1 + args->length()); |
| 2755 Register receiver = register_allocator()->NextConsecutiveRegister(); | 2762 Register receiver = register_allocator()->NextConsecutiveRegister(); |
| 2756 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver); | 2763 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver); |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3403 return execution_context()->scope()->language_mode(); | 3410 return execution_context()->scope()->language_mode(); |
| 3404 } | 3411 } |
| 3405 | 3412 |
| 3406 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3413 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 3407 return TypeFeedbackVector::GetIndex(slot); | 3414 return TypeFeedbackVector::GetIndex(slot); |
| 3408 } | 3415 } |
| 3409 | 3416 |
| 3410 } // namespace interpreter | 3417 } // namespace interpreter |
| 3411 } // namespace internal | 3418 } // namespace internal |
| 3412 } // namespace v8 | 3419 } // namespace v8 |
| OLD | NEW |