| 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/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 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1367 bytecode_iterator().current_bytecode()), | 1367 bytecode_iterator().current_bytecode()), |
| 1368 receiver_mode); | 1368 receiver_mode); |
| 1369 PrepareEagerCheckpoint(); | 1369 PrepareEagerCheckpoint(); |
| 1370 | 1370 |
| 1371 // Slot index of 0 is used indicate no feedback slot is available. Assert | 1371 // Slot index of 0 is used indicate no feedback slot is available. Assert |
| 1372 // the assumption that slot index 0 is never a valid feedback slot. | 1372 // the assumption that slot index 0 is never a valid feedback slot. |
| 1373 STATIC_ASSERT(FeedbackVector::kReservedIndexCount > 0); | 1373 STATIC_ASSERT(FeedbackVector::kReservedIndexCount > 0); |
| 1374 VectorSlotPair feedback = CreateVectorSlotPair(slot_id); | 1374 VectorSlotPair feedback = CreateVectorSlotPair(slot_id); |
| 1375 | 1375 |
| 1376 CallFrequency frequency = ComputeCallFrequency(slot_id); | 1376 CallFrequency frequency = ComputeCallFrequency(slot_id); |
| 1377 const Operator* call = javascript()->Call(arg_count, frequency, feedback, | 1377 const Operator* op = javascript()->Call(arg_count, frequency, feedback, |
| 1378 receiver_mode, tail_call_mode); | 1378 receiver_mode, tail_call_mode); |
| 1379 Node* value = ProcessCallArguments(call, args, static_cast<int>(arg_count)); | 1379 Node* node = nullptr; |
| 1380 environment()->BindAccumulator(value, Environment::kAttachFrameState); | 1380 if (Node* simplified = TryBuildSimplifiedCall( |
| 1381 op, args, static_cast<int>(arg_count), feedback.slot())) { |
| 1382 if (environment() == nullptr) return; |
| 1383 node = simplified; |
| 1384 } else { |
| 1385 node = ProcessCallArguments(op, args, static_cast<int>(arg_count)); |
| 1386 } |
| 1387 environment()->BindAccumulator(node, Environment::kAttachFrameState); |
| 1381 } | 1388 } |
| 1382 | 1389 |
| 1383 void BytecodeGraphBuilder::BuildCallVarArgs(TailCallMode tail_call_mode, | 1390 void BytecodeGraphBuilder::BuildCallVarArgs(TailCallMode tail_call_mode, |
| 1384 ConvertReceiverMode receiver_mode) { | 1391 ConvertReceiverMode receiver_mode) { |
| 1385 DCHECK_EQ(interpreter::Bytecodes::GetReceiverMode( | 1392 DCHECK_EQ(interpreter::Bytecodes::GetReceiverMode( |
| 1386 bytecode_iterator().current_bytecode()), | 1393 bytecode_iterator().current_bytecode()), |
| 1387 receiver_mode); | 1394 receiver_mode); |
| 1388 Node* callee = | 1395 Node* callee = |
| 1389 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1396 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
| 1390 interpreter::Register first_reg = bytecode_iterator().GetRegisterOperand(1); | 1397 interpreter::Register first_reg = bytecode_iterator().GetRegisterOperand(1); |
| (...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2656 Reduction early_reduction = | 2663 Reduction early_reduction = |
| 2657 type_hint_lowering().ReduceToPrimitiveToStringOperation(value, effect, | 2664 type_hint_lowering().ReduceToPrimitiveToStringOperation(value, effect, |
| 2658 control, slot); | 2665 control, slot); |
| 2659 if (early_reduction.Changed()) { | 2666 if (early_reduction.Changed()) { |
| 2660 ApplyEarlyReduction(early_reduction); | 2667 ApplyEarlyReduction(early_reduction); |
| 2661 return early_reduction.replacement(); | 2668 return early_reduction.replacement(); |
| 2662 } | 2669 } |
| 2663 return nullptr; | 2670 return nullptr; |
| 2664 } | 2671 } |
| 2665 | 2672 |
| 2673 Node* BytecodeGraphBuilder::TryBuildSimplifiedCall(const Operator* op, |
| 2674 Node* const* args, |
| 2675 int arg_count, |
| 2676 FeedbackSlot slot) { |
| 2677 // TODO(mstarzinger,6112): This is a workaround for OSR loop entries being |
| 2678 // pruned from the graph by a soft-deopt. It can happen that a CallIC that |
| 2679 // control-dominates the OSR entry is still in "uninitialized" state. |
| 2680 if (!osr_ast_id_.IsNone()) return nullptr; |
| 2681 Node* effect = environment()->GetEffectDependency(); |
| 2682 Node* control = environment()->GetControlDependency(); |
| 2683 Reduction early_reduction = type_hint_lowering().ReduceCallOperation( |
| 2684 op, args, arg_count, effect, control, slot); |
| 2685 if (early_reduction.Changed()) { |
| 2686 ApplyEarlyReduction(early_reduction); |
| 2687 return early_reduction.replacement(); |
| 2688 } |
| 2689 return nullptr; |
| 2690 } |
| 2691 |
| 2666 Node* BytecodeGraphBuilder::TryBuildSimplifiedLoadNamed(const Operator* op, | 2692 Node* BytecodeGraphBuilder::TryBuildSimplifiedLoadNamed(const Operator* op, |
| 2667 Node* receiver, | 2693 Node* receiver, |
| 2668 FeedbackSlot slot) { | 2694 FeedbackSlot slot) { |
| 2669 // TODO(mstarzinger,6112): This is a workaround for OSR loop entries being | 2695 // TODO(mstarzinger,6112): This is a workaround for OSR loop entries being |
| 2670 // pruned from the graph by a soft-deopt. It can happen that a LoadIC that | 2696 // pruned from the graph by a soft-deopt. It can happen that a LoadIC that |
| 2671 // control-dominates the OSR entry is still in "uninitialized" state. | 2697 // control-dominates the OSR entry is still in "uninitialized" state. |
| 2672 if (bytecode_analysis()->HasOSREntryPoint()) return nullptr; | 2698 if (bytecode_analysis()->HasOSREntryPoint()) return nullptr; |
| 2673 Node* effect = environment()->GetEffectDependency(); | 2699 Node* effect = environment()->GetEffectDependency(); |
| 2674 Node* control = environment()->GetControlDependency(); | 2700 Node* control = environment()->GetControlDependency(); |
| 2675 Reduction early_reduction = type_hint_lowering().ReduceLoadNamedOperation( | 2701 Reduction early_reduction = type_hint_lowering().ReduceLoadNamedOperation( |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2949 it->source_position().ScriptOffset(), start_position_.InliningId())); | 2975 it->source_position().ScriptOffset(), start_position_.InliningId())); |
| 2950 it->Advance(); | 2976 it->Advance(); |
| 2951 } else { | 2977 } else { |
| 2952 DCHECK_GT(it->code_offset(), offset); | 2978 DCHECK_GT(it->code_offset(), offset); |
| 2953 } | 2979 } |
| 2954 } | 2980 } |
| 2955 | 2981 |
| 2956 } // namespace compiler | 2982 } // namespace compiler |
| 2957 } // namespace internal | 2983 } // namespace internal |
| 2958 } // namespace v8 | 2984 } // namespace v8 |
| OLD | NEW |