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

Side by Side Diff: src/compiler/bytecode-graph-builder.cc

Issue 2856103002: [turbofan] Introduce dedicated CallFrequency class. (Closed)
Patch Set: Address offline feedback from jarin@. Created 3 years, 7 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/compiler/bytecode-graph-builder.h ('k') | src/compiler/js-call-reducer.cc » ('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/compiler/bytecode-graph-builder.h" 5 #include "src/compiler/bytecode-graph-builder.h"
6 6
7 #include "src/ast/ast.h" 7 #include "src/ast/ast.h"
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/compiler/access-builder.h" 9 #include "src/compiler/access-builder.h"
10 #include "src/compiler/compiler-source-position-table.h" 10 #include "src/compiler/compiler-source-position-table.h"
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 op, parameters_state_values_, registers_state_values, 431 op, parameters_state_values_, registers_state_values,
432 accumulator_state_values, Context(), builder()->GetFunctionClosure(), 432 accumulator_state_values, Context(), builder()->GetFunctionClosure(),
433 builder()->graph()->start()); 433 builder()->graph()->start());
434 434
435 return result; 435 return result;
436 } 436 }
437 437
438 BytecodeGraphBuilder::BytecodeGraphBuilder( 438 BytecodeGraphBuilder::BytecodeGraphBuilder(
439 Zone* local_zone, Handle<SharedFunctionInfo> shared_info, 439 Zone* local_zone, Handle<SharedFunctionInfo> shared_info,
440 Handle<FeedbackVector> feedback_vector, BailoutId osr_ast_id, 440 Handle<FeedbackVector> feedback_vector, BailoutId osr_ast_id,
441 JSGraph* jsgraph, float invocation_frequency, 441 JSGraph* jsgraph, CallFrequency invocation_frequency,
442 SourcePositionTable* source_positions, int inlining_id, 442 SourcePositionTable* source_positions, int inlining_id,
443 JSTypeHintLowering::Flags flags) 443 JSTypeHintLowering::Flags flags)
444 : local_zone_(local_zone), 444 : local_zone_(local_zone),
445 jsgraph_(jsgraph), 445 jsgraph_(jsgraph),
446 invocation_frequency_(invocation_frequency), 446 invocation_frequency_(invocation_frequency),
447 bytecode_array_(handle(shared_info->bytecode_array())), 447 bytecode_array_(handle(shared_info->bytecode_array())),
448 exception_handler_table_( 448 exception_handler_table_(
449 handle(HandlerTable::cast(bytecode_array()->handler_table()))), 449 handle(HandlerTable::cast(bytecode_array()->handler_table()))),
450 feedback_vector_(feedback_vector), 450 feedback_vector_(feedback_vector),
451 type_hint_lowering_(jsgraph, feedback_vector, flags), 451 type_hint_lowering_(jsgraph, feedback_vector, flags),
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 DCHECK_EQ(interpreter::Bytecodes::GetReceiverMode( 1365 DCHECK_EQ(interpreter::Bytecodes::GetReceiverMode(
1366 bytecode_iterator().current_bytecode()), 1366 bytecode_iterator().current_bytecode()),
1367 receiver_mode); 1367 receiver_mode);
1368 PrepareEagerCheckpoint(); 1368 PrepareEagerCheckpoint();
1369 1369
1370 // Slot index of 0 is used indicate no feedback slot is available. Assert 1370 // Slot index of 0 is used indicate no feedback slot is available. Assert
1371 // the assumption that slot index 0 is never a valid feedback slot. 1371 // the assumption that slot index 0 is never a valid feedback slot.
1372 STATIC_ASSERT(FeedbackVector::kReservedIndexCount > 0); 1372 STATIC_ASSERT(FeedbackVector::kReservedIndexCount > 0);
1373 VectorSlotPair feedback = CreateVectorSlotPair(slot_id); 1373 VectorSlotPair feedback = CreateVectorSlotPair(slot_id);
1374 1374
1375 float const frequency = ComputeCallFrequency(slot_id); 1375 CallFrequency frequency = ComputeCallFrequency(slot_id);
1376 const Operator* call = javascript()->Call(arg_count, frequency, feedback, 1376 const Operator* call = javascript()->Call(arg_count, frequency, feedback,
1377 receiver_mode, tail_call_mode); 1377 receiver_mode, tail_call_mode);
1378 Node* value = ProcessCallArguments(call, args, static_cast<int>(arg_count)); 1378 Node* value = ProcessCallArguments(call, args, static_cast<int>(arg_count));
1379 environment()->BindAccumulator(value, Environment::kAttachFrameState); 1379 environment()->BindAccumulator(value, Environment::kAttachFrameState);
1380 } 1380 }
1381 1381
1382 void BytecodeGraphBuilder::BuildCallVarArgs(TailCallMode tail_call_mode, 1382 void BytecodeGraphBuilder::BuildCallVarArgs(TailCallMode tail_call_mode,
1383 ConvertReceiverMode receiver_mode) { 1383 ConvertReceiverMode receiver_mode) {
1384 DCHECK_EQ(interpreter::Bytecodes::GetReceiverMode( 1384 DCHECK_EQ(interpreter::Bytecodes::GetReceiverMode(
1385 bytecode_iterator().current_bytecode()), 1385 bytecode_iterator().current_bytecode()),
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 size_t reg_count = bytecode_iterator().GetRegisterCountOperand(2); 1647 size_t reg_count = bytecode_iterator().GetRegisterCountOperand(2);
1648 // Slot index of 0 is used indicate no feedback slot is available. Assert 1648 // Slot index of 0 is used indicate no feedback slot is available. Assert
1649 // the assumption that slot index 0 is never a valid feedback slot. 1649 // the assumption that slot index 0 is never a valid feedback slot.
1650 STATIC_ASSERT(FeedbackVector::kReservedIndexCount > 0); 1650 STATIC_ASSERT(FeedbackVector::kReservedIndexCount > 0);
1651 int const slot_id = bytecode_iterator().GetIndexOperand(3); 1651 int const slot_id = bytecode_iterator().GetIndexOperand(3);
1652 VectorSlotPair feedback = CreateVectorSlotPair(slot_id); 1652 VectorSlotPair feedback = CreateVectorSlotPair(slot_id);
1653 1653
1654 Node* new_target = environment()->LookupAccumulator(); 1654 Node* new_target = environment()->LookupAccumulator();
1655 Node* callee = environment()->LookupRegister(callee_reg); 1655 Node* callee = environment()->LookupRegister(callee_reg);
1656 1656
1657 float const frequency = ComputeCallFrequency(slot_id); 1657 CallFrequency frequency = ComputeCallFrequency(slot_id);
1658 const Operator* call = javascript()->Construct( 1658 const Operator* call = javascript()->Construct(
1659 static_cast<uint32_t>(reg_count + 2), frequency, feedback); 1659 static_cast<uint32_t>(reg_count + 2), frequency, feedback);
1660 Node* value = 1660 Node* value =
1661 ProcessConstructArguments(call, callee, new_target, receiver, reg_count); 1661 ProcessConstructArguments(call, callee, new_target, receiver, reg_count);
1662 environment()->BindAccumulator(value, Environment::kAttachFrameState); 1662 environment()->BindAccumulator(value, Environment::kAttachFrameState);
1663 } 1663 }
1664 1664
1665 void BytecodeGraphBuilder::VisitThrow() { 1665 void BytecodeGraphBuilder::VisitThrow() {
1666 BuildLoopExitsForFunctionExit(); 1666 BuildLoopExitsForFunctionExit();
1667 Node* value = environment()->LookupAccumulator(); 1667 Node* value = environment()->LookupAccumulator();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 if (slot_index == 0) { 1715 if (slot_index == 0) {
1716 return CompareOperationHint::kAny; 1716 return CompareOperationHint::kAny;
1717 } 1717 }
1718 FeedbackSlot slot = 1718 FeedbackSlot slot =
1719 feedback_vector()->ToSlot(bytecode_iterator().GetIndexOperand(1)); 1719 feedback_vector()->ToSlot(bytecode_iterator().GetIndexOperand(1));
1720 DCHECK_EQ(FeedbackSlotKind::kCompareOp, feedback_vector()->GetKind(slot)); 1720 DCHECK_EQ(FeedbackSlotKind::kCompareOp, feedback_vector()->GetKind(slot));
1721 CompareICNexus nexus(feedback_vector(), slot); 1721 CompareICNexus nexus(feedback_vector(), slot);
1722 return nexus.GetCompareOperationFeedback(); 1722 return nexus.GetCompareOperationFeedback();
1723 } 1723 }
1724 1724
1725 float BytecodeGraphBuilder::ComputeCallFrequency(int slot_id) const { 1725 CallFrequency BytecodeGraphBuilder::ComputeCallFrequency(int slot_id) const {
1726 if (invocation_frequency_.IsUnknown()) return CallFrequency();
1726 CallICNexus nexus(feedback_vector(), feedback_vector()->ToSlot(slot_id)); 1727 CallICNexus nexus(feedback_vector(), feedback_vector()->ToSlot(slot_id));
1727 return nexus.ComputeCallFrequency() * invocation_frequency_; 1728 return CallFrequency(nexus.ComputeCallFrequency() *
1729 invocation_frequency_.value());
1728 } 1730 }
1729 1731
1730 void BytecodeGraphBuilder::VisitAdd() { 1732 void BytecodeGraphBuilder::VisitAdd() {
1731 BuildBinaryOp( 1733 BuildBinaryOp(
1732 javascript()->Add(GetBinaryOperationHint(kBinaryOperationHintIndex))); 1734 javascript()->Add(GetBinaryOperationHint(kBinaryOperationHintIndex)));
1733 } 1735 }
1734 1736
1735 void BytecodeGraphBuilder::VisitSub() { 1737 void BytecodeGraphBuilder::VisitSub() {
1736 BuildBinaryOp(javascript()->Subtract()); 1738 BuildBinaryOp(javascript()->Subtract());
1737 } 1739 }
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
2801 it->source_position().ScriptOffset(), start_position_.InliningId())); 2803 it->source_position().ScriptOffset(), start_position_.InliningId()));
2802 it->Advance(); 2804 it->Advance();
2803 } else { 2805 } else {
2804 DCHECK_GT(it->code_offset(), offset); 2806 DCHECK_GT(it->code_offset(), offset);
2805 } 2807 }
2806 } 2808 }
2807 2809
2808 } // namespace compiler 2810 } // namespace compiler
2809 } // namespace internal 2811 } // namespace internal
2810 } // namespace v8 2812 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/bytecode-graph-builder.h ('k') | src/compiler/js-call-reducer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698