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

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

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

Powered by Google App Engine
This is Rietveld 408576698