| 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 2568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2579 ->CallRuntime(Runtime::kResolvePossiblyDirectEval, callee_for_eval, 6) | 2579 ->CallRuntime(Runtime::kResolvePossiblyDirectEval, callee_for_eval, 6) |
| 2580 .StoreAccumulatorInRegister(callee); | 2580 .StoreAccumulatorInRegister(callee); |
| 2581 } | 2581 } |
| 2582 | 2582 |
| 2583 builder()->SetExpressionPosition(expr); | 2583 builder()->SetExpressionPosition(expr); |
| 2584 | 2584 |
| 2585 int feedback_slot_index; | 2585 int feedback_slot_index; |
| 2586 if (expr->CallFeedbackICSlot().IsInvalid()) { | 2586 if (expr->CallFeedbackICSlot().IsInvalid()) { |
| 2587 DCHECK(call_type == Call::POSSIBLY_EVAL_CALL); | 2587 DCHECK(call_type == Call::POSSIBLY_EVAL_CALL); |
| 2588 // Valid type feedback slots can only be greater than kReservedIndexCount. | 2588 // Valid type feedback slots can only be greater than kReservedIndexCount. |
| 2589 // We use 0 to indicate an invalid slot it. Statically assert that 0 cannot | 2589 // We use 0 to indicate an invalid slot id. Statically assert that 0 cannot |
| 2590 // be a valid slot id. | 2590 // be a valid slot id. |
| 2591 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); | 2591 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); |
| 2592 feedback_slot_index = 0; | 2592 feedback_slot_index = 0; |
| 2593 } else { | 2593 } else { |
| 2594 feedback_slot_index = feedback_index(expr->CallFeedbackICSlot()); | 2594 feedback_slot_index = feedback_index(expr->CallFeedbackICSlot()); |
| 2595 } | 2595 } |
| 2596 builder()->Call(callee, receiver, 1 + args->length(), feedback_slot_index, | 2596 builder()->Call(callee, receiver, 1 + args->length(), feedback_slot_index, |
| 2597 expr->tail_call_mode()); | 2597 expr->tail_call_mode()); |
| 2598 execution_result()->SetResultInAccumulator(); | 2598 execution_result()->SetResultInAccumulator(); |
| 2599 } | 2599 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2614 | 2614 |
| 2615 ZoneList<Expression*>* args = expr->arguments(); | 2615 ZoneList<Expression*>* args = expr->arguments(); |
| 2616 Register first_arg = VisitArguments(args); | 2616 Register first_arg = VisitArguments(args); |
| 2617 | 2617 |
| 2618 // The new target is loaded into the accumulator from the | 2618 // The new target is loaded into the accumulator from the |
| 2619 // {new.target} variable. | 2619 // {new.target} variable. |
| 2620 VisitForAccumulatorValue(super->new_target_var()); | 2620 VisitForAccumulatorValue(super->new_target_var()); |
| 2621 | 2621 |
| 2622 // Call construct. | 2622 // Call construct. |
| 2623 builder()->SetExpressionPosition(expr); | 2623 builder()->SetExpressionPosition(expr); |
| 2624 builder()->New(constructor, first_arg, args->length()); | 2624 // Valid type feedback slots can only be greater than kReservedIndexCount. |
| 2625 // Assert that 0 cannot be valid a valid slot id. |
| 2626 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); |
| 2627 // Type feedback is not necessary for super constructor calls. The type |
| 2628 // information can be inferred in most cases. Slot id 0 indicates type |
| 2629 // feedback is not required. |
| 2630 builder()->New(constructor, first_arg, args->length(), 0); |
| 2625 execution_result()->SetResultInAccumulator(); | 2631 execution_result()->SetResultInAccumulator(); |
| 2626 } | 2632 } |
| 2627 | 2633 |
| 2628 void BytecodeGenerator::VisitCallNew(CallNew* expr) { | 2634 void BytecodeGenerator::VisitCallNew(CallNew* expr) { |
| 2629 Register constructor = register_allocator()->NewRegister(); | 2635 Register constructor = register_allocator()->NewRegister(); |
| 2630 VisitForAccumulatorValue(expr->expression()); | 2636 VisitForAccumulatorValue(expr->expression()); |
| 2631 builder()->StoreAccumulatorInRegister(constructor); | 2637 builder()->StoreAccumulatorInRegister(constructor); |
| 2632 | 2638 |
| 2633 ZoneList<Expression*>* args = expr->arguments(); | 2639 ZoneList<Expression*>* args = expr->arguments(); |
| 2634 Register first_arg = VisitArguments(args); | 2640 Register first_arg = VisitArguments(args); |
| 2635 | 2641 |
| 2636 builder()->SetExpressionPosition(expr); | 2642 builder()->SetExpressionPosition(expr); |
| 2637 // The accumulator holds new target which is the same as the | 2643 // The accumulator holds new target which is the same as the |
| 2638 // constructor for CallNew. | 2644 // constructor for CallNew. |
| 2639 builder() | 2645 builder() |
| 2640 ->LoadAccumulatorWithRegister(constructor) | 2646 ->LoadAccumulatorWithRegister(constructor) |
| 2641 .New(constructor, first_arg, args->length()); | 2647 .New(constructor, first_arg, args->length(), |
| 2648 feedback_index(expr->CallNewFeedbackSlot())); |
| 2642 execution_result()->SetResultInAccumulator(); | 2649 execution_result()->SetResultInAccumulator(); |
| 2643 } | 2650 } |
| 2644 | 2651 |
| 2645 void BytecodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 2652 void BytecodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
| 2646 ZoneList<Expression*>* args = expr->arguments(); | 2653 ZoneList<Expression*>* args = expr->arguments(); |
| 2647 if (expr->is_jsruntime()) { | 2654 if (expr->is_jsruntime()) { |
| 2648 // Allocate a register for the receiver and load it with undefined. | 2655 // Allocate a register for the receiver and load it with undefined. |
| 2649 register_allocator()->PrepareForConsecutiveAllocations(1 + args->length()); | 2656 register_allocator()->PrepareForConsecutiveAllocations(1 + args->length()); |
| 2650 Register receiver = register_allocator()->NextConsecutiveRegister(); | 2657 Register receiver = register_allocator()->NextConsecutiveRegister(); |
| 2651 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver); | 2658 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver); |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3238 return execution_context()->scope()->language_mode(); | 3245 return execution_context()->scope()->language_mode(); |
| 3239 } | 3246 } |
| 3240 | 3247 |
| 3241 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3248 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 3242 return TypeFeedbackVector::GetIndex(slot); | 3249 return TypeFeedbackVector::GetIndex(slot); |
| 3243 } | 3250 } |
| 3244 | 3251 |
| 3245 } // namespace interpreter | 3252 } // namespace interpreter |
| 3246 } // namespace internal | 3253 } // namespace internal |
| 3247 } // namespace v8 | 3254 } // namespace v8 |
| OLD | NEW |