Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: src/interpreter/bytecode-generator.cc

Issue 2190293003: [Interpreter] Collect type feedback for 'new' in the bytecode handler (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updated cctest.status and mjsunit.status Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/interpreter/bytecode-array-builder.cc ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2601 matching lines...) Expand 10 before | Expand all | Expand 10 after
2612 ->CallRuntime(Runtime::kResolvePossiblyDirectEval, callee_for_eval, 6) 2612 ->CallRuntime(Runtime::kResolvePossiblyDirectEval, callee_for_eval, 6)
2613 .StoreAccumulatorInRegister(callee); 2613 .StoreAccumulatorInRegister(callee);
2614 } 2614 }
2615 2615
2616 builder()->SetExpressionPosition(expr); 2616 builder()->SetExpressionPosition(expr);
2617 2617
2618 int feedback_slot_index; 2618 int feedback_slot_index;
2619 if (expr->CallFeedbackICSlot().IsInvalid()) { 2619 if (expr->CallFeedbackICSlot().IsInvalid()) {
2620 DCHECK(call_type == Call::POSSIBLY_EVAL_CALL); 2620 DCHECK(call_type == Call::POSSIBLY_EVAL_CALL);
2621 // Valid type feedback slots can only be greater than kReservedIndexCount. 2621 // Valid type feedback slots can only be greater than kReservedIndexCount.
2622 // We use 0 to indicate an invalid slot it. Statically assert that 0 cannot 2622 // We use 0 to indicate an invalid slot id. Statically assert that 0 cannot
2623 // be a valid slot id. 2623 // be a valid slot id.
2624 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0); 2624 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0);
2625 feedback_slot_index = 0; 2625 feedback_slot_index = 0;
2626 } else { 2626 } else {
2627 feedback_slot_index = feedback_index(expr->CallFeedbackICSlot()); 2627 feedback_slot_index = feedback_index(expr->CallFeedbackICSlot());
2628 } 2628 }
2629 builder()->Call(callee, receiver, 1 + args->length(), feedback_slot_index, 2629 builder()->Call(callee, receiver, 1 + args->length(), feedback_slot_index,
2630 expr->tail_call_mode()); 2630 expr->tail_call_mode());
2631 execution_result()->SetResultInAccumulator(); 2631 execution_result()->SetResultInAccumulator();
2632 } 2632 }
(...skipping 14 matching lines...) Expand all
2647 2647
2648 ZoneList<Expression*>* args = expr->arguments(); 2648 ZoneList<Expression*>* args = expr->arguments();
2649 Register first_arg = VisitArguments(args); 2649 Register first_arg = VisitArguments(args);
2650 2650
2651 // The new target is loaded into the accumulator from the 2651 // The new target is loaded into the accumulator from the
2652 // {new.target} variable. 2652 // {new.target} variable.
2653 VisitForAccumulatorValue(super->new_target_var()); 2653 VisitForAccumulatorValue(super->new_target_var());
2654 2654
2655 // Call construct. 2655 // Call construct.
2656 builder()->SetExpressionPosition(expr); 2656 builder()->SetExpressionPosition(expr);
2657 builder()->New(constructor, first_arg, args->length()); 2657 // Valid type feedback slots can only be greater than kReservedIndexCount.
2658 // Assert that 0 cannot be valid a valid slot id.
2659 STATIC_ASSERT(TypeFeedbackVector::kReservedIndexCount > 0);
2660 // Type feedback is not necessary for super constructor calls. The type
2661 // information can be inferred in most cases. Slot id 0 indicates type
2662 // feedback is not required.
2663 builder()->New(constructor, first_arg, args->length(), 0);
2658 execution_result()->SetResultInAccumulator(); 2664 execution_result()->SetResultInAccumulator();
2659 } 2665 }
2660 2666
2661 void BytecodeGenerator::VisitCallNew(CallNew* expr) { 2667 void BytecodeGenerator::VisitCallNew(CallNew* expr) {
2662 Register constructor = register_allocator()->NewRegister(); 2668 Register constructor = register_allocator()->NewRegister();
2663 VisitForAccumulatorValue(expr->expression()); 2669 VisitForAccumulatorValue(expr->expression());
2664 builder()->StoreAccumulatorInRegister(constructor); 2670 builder()->StoreAccumulatorInRegister(constructor);
2665 2671
2666 ZoneList<Expression*>* args = expr->arguments(); 2672 ZoneList<Expression*>* args = expr->arguments();
2667 Register first_arg = VisitArguments(args); 2673 Register first_arg = VisitArguments(args);
2668 2674
2669 builder()->SetExpressionPosition(expr); 2675 builder()->SetExpressionPosition(expr);
2670 // The accumulator holds new target which is the same as the 2676 // The accumulator holds new target which is the same as the
2671 // constructor for CallNew. 2677 // constructor for CallNew.
2672 builder() 2678 builder()
2673 ->LoadAccumulatorWithRegister(constructor) 2679 ->LoadAccumulatorWithRegister(constructor)
2674 .New(constructor, first_arg, args->length()); 2680 .New(constructor, first_arg, args->length(),
2681 feedback_index(expr->CallNewFeedbackSlot()));
2675 execution_result()->SetResultInAccumulator(); 2682 execution_result()->SetResultInAccumulator();
2676 } 2683 }
2677 2684
2678 void BytecodeGenerator::VisitCallRuntime(CallRuntime* expr) { 2685 void BytecodeGenerator::VisitCallRuntime(CallRuntime* expr) {
2679 ZoneList<Expression*>* args = expr->arguments(); 2686 ZoneList<Expression*>* args = expr->arguments();
2680 if (expr->is_jsruntime()) { 2687 if (expr->is_jsruntime()) {
2681 // Allocate a register for the receiver and load it with undefined. 2688 // Allocate a register for the receiver and load it with undefined.
2682 register_allocator()->PrepareForConsecutiveAllocations(1 + args->length()); 2689 register_allocator()->PrepareForConsecutiveAllocations(1 + args->length());
2683 Register receiver = register_allocator()->NextConsecutiveRegister(); 2690 Register receiver = register_allocator()->NextConsecutiveRegister();
2684 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver); 2691 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver);
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
3271 return execution_context()->scope()->language_mode(); 3278 return execution_context()->scope()->language_mode();
3272 } 3279 }
3273 3280
3274 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { 3281 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
3275 return TypeFeedbackVector::GetIndex(slot); 3282 return TypeFeedbackVector::GetIndex(slot);
3276 } 3283 }
3277 3284
3278 } // namespace interpreter 3285 } // namespace interpreter
3279 } // namespace internal 3286 } // namespace internal
3280 } // namespace v8 3287 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-array-builder.cc ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698