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

Side by Side Diff: src/compiler/instruction-selector.cc

Issue 1721103003: [turbofan] Introduce DeoptimizeIf And DeoptimizeUnless common operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add comments Created 4 years, 10 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/instruction-selector.h ('k') | src/compiler/instruction-selector-impl.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/instruction-selector.h" 5 #include "src/compiler/instruction-selector.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/adapters.h" 9 #include "src/base/adapters.h"
10 #include "src/compiler/instruction-selector-impl.h" 10 #include "src/compiler/instruction-selector-impl.h"
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 return MarkAsFloat64(node), VisitConstant(node); 866 return MarkAsFloat64(node), VisitConstant(node);
867 case IrOpcode::kHeapConstant: 867 case IrOpcode::kHeapConstant:
868 return MarkAsReference(node), VisitConstant(node); 868 return MarkAsReference(node), VisitConstant(node);
869 case IrOpcode::kNumberConstant: { 869 case IrOpcode::kNumberConstant: {
870 double value = OpParameter<double>(node); 870 double value = OpParameter<double>(node);
871 if (!IsSmiDouble(value)) MarkAsReference(node); 871 if (!IsSmiDouble(value)) MarkAsReference(node);
872 return VisitConstant(node); 872 return VisitConstant(node);
873 } 873 }
874 case IrOpcode::kCall: 874 case IrOpcode::kCall:
875 return VisitCall(node); 875 return VisitCall(node);
876 case IrOpcode::kDeoptimizeIf:
877 return VisitDeoptimizeIf(node);
878 case IrOpcode::kDeoptimizeUnless:
879 return VisitDeoptimizeUnless(node);
876 case IrOpcode::kFrameState: 880 case IrOpcode::kFrameState:
877 case IrOpcode::kStateValues: 881 case IrOpcode::kStateValues:
878 case IrOpcode::kObjectState: 882 case IrOpcode::kObjectState:
879 return; 883 return;
880 case IrOpcode::kLoad: { 884 case IrOpcode::kLoad: {
881 LoadRepresentation type = LoadRepresentationOf(node->op()); 885 LoadRepresentation type = LoadRepresentationOf(node->op());
882 MarkAsRepresentation(type.representation(), node); 886 MarkAsRepresentation(type.representation(), node);
883 return VisitLoad(node); 887 return VisitLoad(node);
884 } 888 }
885 case IrOpcode::kStore: 889 case IrOpcode::kStore:
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 auto value_locations = zone()->NewArray<InstructionOperand>(ret_count); 1624 auto value_locations = zone()->NewArray<InstructionOperand>(ret_count);
1621 for (int i = 0; i < ret_count; ++i) { 1625 for (int i = 0; i < ret_count; ++i) {
1622 value_locations[i] = 1626 value_locations[i] =
1623 g.UseLocation(ret->InputAt(i), linkage()->GetReturnLocation(i), 1627 g.UseLocation(ret->InputAt(i), linkage()->GetReturnLocation(i),
1624 linkage()->GetReturnType(i).representation()); 1628 linkage()->GetReturnType(i).representation());
1625 } 1629 }
1626 Emit(kArchRet, 0, nullptr, ret_count, value_locations); 1630 Emit(kArchRet, 0, nullptr, ret_count, value_locations);
1627 } 1631 }
1628 } 1632 }
1629 1633
1634 Instruction* InstructionSelector::EmitDeoptimize(InstructionCode opcode,
1635 InstructionOperand output,
1636 InstructionOperand a,
1637 InstructionOperand b,
1638 Node* frame_state) {
1639 size_t output_count = output.IsInvalid() ? 0 : 1;
1640 InstructionOperand inputs[] = {a, b};
1641 size_t input_count = arraysize(inputs);
1642 return EmitDeoptimize(opcode, output_count, &output, input_count, inputs,
1643 frame_state);
1644 }
1645
1646 Instruction* InstructionSelector::EmitDeoptimize(
1647 InstructionCode opcode, size_t output_count, InstructionOperand* outputs,
1648 size_t input_count, InstructionOperand* inputs, Node* frame_state) {
1649 OperandGenerator g(this);
1650 FrameStateDescriptor* const descriptor = GetFrameStateDescriptor(frame_state);
1651 InstructionOperandVector args(instruction_zone());
1652 args.reserve(input_count + 1 + descriptor->GetTotalSize());
1653 for (size_t i = 0; i < input_count; ++i) {
1654 args.push_back(inputs[i]);
1655 }
1656 opcode |= MiscField::encode(static_cast<int>(input_count));
1657 InstructionSequence::StateId const state_id =
1658 sequence()->AddFrameStateDescriptor(descriptor);
1659 args.push_back(g.TempImmediate(state_id.ToInt()));
1660 StateObjectDeduplicator deduplicator(instruction_zone());
1661 AddInputsToFrameStateDescriptor(descriptor, frame_state, &g, &deduplicator,
1662 &args, FrameStateInputKind::kAny,
1663 instruction_zone());
1664 return Emit(opcode, output_count, outputs, args.size(), &args.front(), 0,
1665 nullptr);
1666 }
1630 1667
1631 void InstructionSelector::VisitDeoptimize(DeoptimizeKind kind, Node* value) { 1668 void InstructionSelector::VisitDeoptimize(DeoptimizeKind kind, Node* value) {
1632 OperandGenerator g(this);
1633
1634 FrameStateDescriptor* desc = GetFrameStateDescriptor(value);
1635
1636 InstructionOperandVector args(instruction_zone());
1637 args.reserve(desc->GetTotalSize() + 1); // Include deopt id.
1638
1639 InstructionSequence::StateId state_id =
1640 sequence()->AddFrameStateDescriptor(desc);
1641 args.push_back(g.TempImmediate(state_id.ToInt()));
1642
1643 StateObjectDeduplicator deduplicator(instruction_zone());
1644
1645 AddInputsToFrameStateDescriptor(desc, value, &g, &deduplicator, &args,
1646 FrameStateInputKind::kAny,
1647 instruction_zone());
1648
1649 InstructionCode opcode = kArchDeoptimize; 1669 InstructionCode opcode = kArchDeoptimize;
1650 switch (kind) { 1670 switch (kind) {
1651 case DeoptimizeKind::kEager: 1671 case DeoptimizeKind::kEager:
1652 opcode |= MiscField::encode(Deoptimizer::EAGER); 1672 opcode |= MiscField::encode(Deoptimizer::EAGER);
1653 break; 1673 break;
1654 case DeoptimizeKind::kSoft: 1674 case DeoptimizeKind::kSoft:
1655 opcode |= MiscField::encode(Deoptimizer::SOFT); 1675 opcode |= MiscField::encode(Deoptimizer::SOFT);
1656 break; 1676 break;
1657 } 1677 }
1658 Emit(opcode, 0, nullptr, args.size(), &args.front(), 0, nullptr); 1678 EmitDeoptimize(opcode, 0, nullptr, 0, nullptr, value);
1659 } 1679 }
1660 1680
1661 1681
1662 void InstructionSelector::VisitThrow(Node* value) { 1682 void InstructionSelector::VisitThrow(Node* value) {
1663 OperandGenerator g(this); 1683 OperandGenerator g(this);
1664 Emit(kArchThrowTerminator, g.NoOutput()); 1684 Emit(kArchThrowTerminator, g.NoOutput());
1665 } 1685 }
1666 1686
1667 1687
1668 FrameStateDescriptor* InstructionSelector::GetFrameStateDescriptor( 1688 FrameStateDescriptor* InstructionSelector::GetFrameStateDescriptor(
(...skipping 21 matching lines...) Expand all
1690 return new (instruction_zone()) FrameStateDescriptor( 1710 return new (instruction_zone()) FrameStateDescriptor(
1691 instruction_zone(), state_info.type(), state_info.bailout_id(), 1711 instruction_zone(), state_info.type(), state_info.bailout_id(),
1692 state_info.state_combine(), parameters, locals, stack, 1712 state_info.state_combine(), parameters, locals, stack,
1693 state_info.shared_info(), outer_state); 1713 state_info.shared_info(), outer_state);
1694 } 1714 }
1695 1715
1696 1716
1697 } // namespace compiler 1717 } // namespace compiler
1698 } // namespace internal 1718 } // namespace internal
1699 } // namespace v8 1719 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/instruction-selector.h ('k') | src/compiler/instruction-selector-impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698