| 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 2509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2520 ->CallRuntime(Runtime::kResolvePossiblyDirectEval, callee_for_eval, 6) | 2520 ->CallRuntime(Runtime::kResolvePossiblyDirectEval, callee_for_eval, 6) |
| 2521 .StoreAccumulatorInRegister(callee); | 2521 .StoreAccumulatorInRegister(callee); |
| 2522 } | 2522 } |
| 2523 | 2523 |
| 2524 builder()->SetExpressionPosition(expr); | 2524 builder()->SetExpressionPosition(expr); |
| 2525 | 2525 |
| 2526 int feedback_slot_index; | 2526 int feedback_slot_index; |
| 2527 if (expr->CallFeedbackICSlot().IsInvalid()) { | 2527 if (expr->CallFeedbackICSlot().IsInvalid()) { |
| 2528 DCHECK(call_type == Call::POSSIBLY_EVAL_CALL); | 2528 DCHECK(call_type == Call::POSSIBLY_EVAL_CALL); |
| 2529 // Valid type feedback slots can only be greater than kReservedIndexCount. | 2529 // Valid type feedback slots can only be greater than kReservedIndexCount. |
| 2530 // We use 0 to indicate an invalid slot it. Statically assert that 0 cannot | 2530 // We use 0 to indicate an invalid slot id. Statically assert that 0 cannot |
| 2531 // be a valid slot id. | 2531 // be a valid slot id. |
| 2532 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); | 2532 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); |
| 2533 feedback_slot_index = 0; | 2533 feedback_slot_index = 0; |
| 2534 } else { | 2534 } else { |
| 2535 feedback_slot_index = feedback_index(expr->CallFeedbackICSlot()); | 2535 feedback_slot_index = feedback_index(expr->CallFeedbackICSlot()); |
| 2536 } | 2536 } |
| 2537 builder()->Call(callee, receiver, 1 + args->length(), feedback_slot_index, | 2537 builder()->Call(callee, receiver, 1 + args->length(), feedback_slot_index, |
| 2538 expr->tail_call_mode()); | 2538 expr->tail_call_mode()); |
| 2539 execution_result()->SetResultInAccumulator(); | 2539 execution_result()->SetResultInAccumulator(); |
| 2540 } | 2540 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2555 | 2555 |
| 2556 ZoneList<Expression*>* args = expr->arguments(); | 2556 ZoneList<Expression*>* args = expr->arguments(); |
| 2557 Register first_arg = VisitArguments(args); | 2557 Register first_arg = VisitArguments(args); |
| 2558 | 2558 |
| 2559 // The new target is loaded into the accumulator from the | 2559 // The new target is loaded into the accumulator from the |
| 2560 // {new.target} variable. | 2560 // {new.target} variable. |
| 2561 VisitForAccumulatorValue(super->new_target_var()); | 2561 VisitForAccumulatorValue(super->new_target_var()); |
| 2562 | 2562 |
| 2563 // Call construct. | 2563 // Call construct. |
| 2564 builder()->SetExpressionPosition(expr); | 2564 builder()->SetExpressionPosition(expr); |
| 2565 builder()->New(constructor, first_arg, args->length()); | 2565 // Valid type feedback slots can only be greater than kReservedIndexCount. |
| 2566 // Assert that 0 cannot be valid a valid slot id. |
| 2567 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); |
| 2568 // Type feedback is not necessary for super constructor calls. The type |
| 2569 // information can be inferred in most cases. Slot id 0 indicates type |
| 2570 // feedback is not required. |
| 2571 builder()->New(constructor, first_arg, args->length(), 0); |
| 2566 execution_result()->SetResultInAccumulator(); | 2572 execution_result()->SetResultInAccumulator(); |
| 2567 } | 2573 } |
| 2568 | 2574 |
| 2569 void BytecodeGenerator::VisitCallNew(CallNew* expr) { | 2575 void BytecodeGenerator::VisitCallNew(CallNew* expr) { |
| 2570 Register constructor = register_allocator()->NewRegister(); | 2576 Register constructor = register_allocator()->NewRegister(); |
| 2571 VisitForAccumulatorValue(expr->expression()); | 2577 VisitForAccumulatorValue(expr->expression()); |
| 2572 builder()->StoreAccumulatorInRegister(constructor); | 2578 builder()->StoreAccumulatorInRegister(constructor); |
| 2573 | 2579 |
| 2574 ZoneList<Expression*>* args = expr->arguments(); | 2580 ZoneList<Expression*>* args = expr->arguments(); |
| 2575 Register first_arg = VisitArguments(args); | 2581 Register first_arg = VisitArguments(args); |
| 2576 | 2582 |
| 2577 builder()->SetExpressionPosition(expr); | 2583 builder()->SetExpressionPosition(expr); |
| 2578 // The accumulator holds new target which is the same as the | 2584 // The accumulator holds new target which is the same as the |
| 2579 // constructor for CallNew. | 2585 // constructor for CallNew. |
| 2580 builder() | 2586 builder() |
| 2581 ->LoadAccumulatorWithRegister(constructor) | 2587 ->LoadAccumulatorWithRegister(constructor) |
| 2582 .New(constructor, first_arg, args->length()); | 2588 .New(constructor, first_arg, args->length(), |
| 2589 feedback_index(expr->CallNewFeedbackSlot())); |
| 2583 execution_result()->SetResultInAccumulator(); | 2590 execution_result()->SetResultInAccumulator(); |
| 2584 } | 2591 } |
| 2585 | 2592 |
| 2586 void BytecodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 2593 void BytecodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
| 2587 ZoneList<Expression*>* args = expr->arguments(); | 2594 ZoneList<Expression*>* args = expr->arguments(); |
| 2588 if (expr->is_jsruntime()) { | 2595 if (expr->is_jsruntime()) { |
| 2589 // Allocate a register for the receiver and load it with undefined. | 2596 // Allocate a register for the receiver and load it with undefined. |
| 2590 register_allocator()->PrepareForConsecutiveAllocations(1 + args->length()); | 2597 register_allocator()->PrepareForConsecutiveAllocations(1 + args->length()); |
| 2591 Register receiver = register_allocator()->NextConsecutiveRegister(); | 2598 Register receiver = register_allocator()->NextConsecutiveRegister(); |
| 2592 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver); | 2599 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver); |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3178 return execution_context()->scope()->language_mode(); | 3185 return execution_context()->scope()->language_mode(); |
| 3179 } | 3186 } |
| 3180 | 3187 |
| 3181 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3188 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 3182 return TypeFeedbackVector::GetIndex(slot); | 3189 return TypeFeedbackVector::GetIndex(slot); |
| 3183 } | 3190 } |
| 3184 | 3191 |
| 3185 } // namespace interpreter | 3192 } // namespace interpreter |
| 3186 } // namespace internal | 3193 } // namespace internal |
| 3187 } // namespace v8 | 3194 } // namespace v8 |
| OLD | NEW |