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

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

Issue 2161543002: [turbofan] Add support for eager/soft deoptimization reasons. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Do the ports properly 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
« 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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 (buffer->frame_state_descriptor->type() == 637 (buffer->frame_state_descriptor->type() ==
638 FrameStateType::kArgumentsAdaptor || 638 FrameStateType::kArgumentsAdaptor ||
639 buffer->frame_state_descriptor->type() == 639 buffer->frame_state_descriptor->type() ==
640 FrameStateType::kTailCallerFunction)) { 640 FrameStateType::kTailCallerFunction)) {
641 frame_state = NodeProperties::GetFrameStateInput(frame_state, 0); 641 frame_state = NodeProperties::GetFrameStateInput(frame_state, 0);
642 buffer->frame_state_descriptor = 642 buffer->frame_state_descriptor =
643 buffer->frame_state_descriptor->outer_state(); 643 buffer->frame_state_descriptor->outer_state();
644 } 644 }
645 } 645 }
646 646
647 InstructionSequence::StateId state_id = 647 int const state_id = sequence()->AddDeoptimizationEntry(
648 sequence()->AddFrameStateDescriptor(buffer->frame_state_descriptor); 648 buffer->frame_state_descriptor, DeoptimizeReason::kNoReason);
649 buffer->instruction_args.push_back(g.TempImmediate(state_id.ToInt())); 649 buffer->instruction_args.push_back(g.TempImmediate(state_id));
650 650
651 StateObjectDeduplicator deduplicator(instruction_zone()); 651 StateObjectDeduplicator deduplicator(instruction_zone());
652 652
653 frame_state_entries = 653 frame_state_entries =
654 1 + AddInputsToFrameStateDescriptor( 654 1 + AddInputsToFrameStateDescriptor(
655 buffer->frame_state_descriptor, frame_state, &g, &deduplicator, 655 buffer->frame_state_descriptor, frame_state, &g, &deduplicator,
656 &buffer->instruction_args, FrameStateInputKind::kStackSlot, 656 &buffer->instruction_args, FrameStateInputKind::kStackSlot,
657 instruction_zone()); 657 instruction_zone());
658 658
659 DCHECK_EQ(1 + frame_state_entries, buffer->instruction_args.size()); 659 DCHECK_EQ(1 + frame_state_entries, buffer->instruction_args.size());
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 // is 2^31-1, so don't assume that it's non-zero below. 826 // is 2^31-1, so don't assume that it's non-zero below.
827 sw.value_range = 1u + bit_cast<uint32_t>(sw.max_value) - 827 sw.value_range = 1u + bit_cast<uint32_t>(sw.max_value) -
828 bit_cast<uint32_t>(sw.min_value); 828 bit_cast<uint32_t>(sw.min_value);
829 return VisitSwitch(input, sw); 829 return VisitSwitch(input, sw);
830 } 830 }
831 case BasicBlock::kReturn: { 831 case BasicBlock::kReturn: {
832 DCHECK_EQ(IrOpcode::kReturn, input->opcode()); 832 DCHECK_EQ(IrOpcode::kReturn, input->opcode());
833 return VisitReturn(input); 833 return VisitReturn(input);
834 } 834 }
835 case BasicBlock::kDeoptimize: { 835 case BasicBlock::kDeoptimize: {
836 DeoptimizeKind kind = DeoptimizeKindOf(input->op()); 836 DeoptimizeParameters p = DeoptimizeParametersOf(input->op());
837 Node* value = input->InputAt(0); 837 Node* value = input->InputAt(0);
838 return VisitDeoptimize(kind, value); 838 return VisitDeoptimize(p.kind(), p.reason(), value);
839 } 839 }
840 case BasicBlock::kThrow: 840 case BasicBlock::kThrow:
841 DCHECK_EQ(IrOpcode::kThrow, input->opcode()); 841 DCHECK_EQ(IrOpcode::kThrow, input->opcode());
842 return VisitThrow(input->InputAt(0)); 842 return VisitThrow(input->InputAt(0));
843 case BasicBlock::kNone: { 843 case BasicBlock::kNone: {
844 // Exit block doesn't have control. 844 // Exit block doesn't have control.
845 DCHECK_NULL(input); 845 DCHECK_NULL(input);
846 break; 846 break;
847 } 847 }
848 default: 848 default:
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 const int ret_count = ret->op()->ValueInputCount(); 1876 const int ret_count = ret->op()->ValueInputCount();
1877 auto value_locations = zone()->NewArray<InstructionOperand>(ret_count); 1877 auto value_locations = zone()->NewArray<InstructionOperand>(ret_count);
1878 for (int i = 0; i < ret_count; ++i) { 1878 for (int i = 0; i < ret_count; ++i) {
1879 value_locations[i] = 1879 value_locations[i] =
1880 g.UseLocation(ret->InputAt(i), linkage()->GetReturnLocation(i)); 1880 g.UseLocation(ret->InputAt(i), linkage()->GetReturnLocation(i));
1881 } 1881 }
1882 Emit(kArchRet, 0, nullptr, ret_count, value_locations); 1882 Emit(kArchRet, 0, nullptr, ret_count, value_locations);
1883 } 1883 }
1884 } 1884 }
1885 1885
1886 Instruction* InstructionSelector::EmitDeoptimize(InstructionCode opcode, 1886 Instruction* InstructionSelector::EmitDeoptimize(
1887 InstructionOperand output, 1887 InstructionCode opcode, InstructionOperand output, InstructionOperand a,
1888 InstructionOperand a, 1888 InstructionOperand b, DeoptimizeReason reason, Node* frame_state) {
1889 InstructionOperand b,
1890 Node* frame_state) {
1891 size_t output_count = output.IsInvalid() ? 0 : 1; 1889 size_t output_count = output.IsInvalid() ? 0 : 1;
1892 InstructionOperand inputs[] = {a, b}; 1890 InstructionOperand inputs[] = {a, b};
1893 size_t input_count = arraysize(inputs); 1891 size_t input_count = arraysize(inputs);
1894 return EmitDeoptimize(opcode, output_count, &output, input_count, inputs, 1892 return EmitDeoptimize(opcode, output_count, &output, input_count, inputs,
1895 frame_state); 1893 reason, frame_state);
1896 } 1894 }
1897 1895
1898 Instruction* InstructionSelector::EmitDeoptimize( 1896 Instruction* InstructionSelector::EmitDeoptimize(
1899 InstructionCode opcode, size_t output_count, InstructionOperand* outputs, 1897 InstructionCode opcode, size_t output_count, InstructionOperand* outputs,
1900 size_t input_count, InstructionOperand* inputs, Node* frame_state) { 1898 size_t input_count, InstructionOperand* inputs, DeoptimizeReason reason,
1899 Node* frame_state) {
1901 OperandGenerator g(this); 1900 OperandGenerator g(this);
1902 FrameStateDescriptor* const descriptor = GetFrameStateDescriptor(frame_state); 1901 FrameStateDescriptor* const descriptor = GetFrameStateDescriptor(frame_state);
1903 InstructionOperandVector args(instruction_zone()); 1902 InstructionOperandVector args(instruction_zone());
1904 args.reserve(input_count + 1 + descriptor->GetTotalSize()); 1903 args.reserve(input_count + 1 + descriptor->GetTotalSize());
1905 for (size_t i = 0; i < input_count; ++i) { 1904 for (size_t i = 0; i < input_count; ++i) {
1906 args.push_back(inputs[i]); 1905 args.push_back(inputs[i]);
1907 } 1906 }
1908 opcode |= MiscField::encode(static_cast<int>(input_count)); 1907 opcode |= MiscField::encode(static_cast<int>(input_count));
1909 InstructionSequence::StateId const state_id = 1908 int const state_id = sequence()->AddDeoptimizationEntry(descriptor, reason);
1910 sequence()->AddFrameStateDescriptor(descriptor); 1909 args.push_back(g.TempImmediate(state_id));
1911 args.push_back(g.TempImmediate(state_id.ToInt()));
1912 StateObjectDeduplicator deduplicator(instruction_zone()); 1910 StateObjectDeduplicator deduplicator(instruction_zone());
1913 AddInputsToFrameStateDescriptor(descriptor, frame_state, &g, &deduplicator, 1911 AddInputsToFrameStateDescriptor(descriptor, frame_state, &g, &deduplicator,
1914 &args, FrameStateInputKind::kAny, 1912 &args, FrameStateInputKind::kAny,
1915 instruction_zone()); 1913 instruction_zone());
1916 return Emit(opcode, output_count, outputs, args.size(), &args.front(), 0, 1914 return Emit(opcode, output_count, outputs, args.size(), &args.front(), 0,
1917 nullptr); 1915 nullptr);
1918 } 1916 }
1919 1917
1920 void InstructionSelector::EmitIdentity(Node* node) { 1918 void InstructionSelector::EmitIdentity(Node* node) {
1921 OperandGenerator g(this); 1919 OperandGenerator g(this);
1922 Node* value = node->InputAt(0); 1920 Node* value = node->InputAt(0);
1923 Emit(kArchNop, g.DefineSameAsFirst(node), g.Use(value)); 1921 Emit(kArchNop, g.DefineSameAsFirst(node), g.Use(value));
1924 } 1922 }
1925 1923
1926 void InstructionSelector::VisitDeoptimize(DeoptimizeKind kind, Node* value) { 1924 void InstructionSelector::VisitDeoptimize(DeoptimizeKind kind,
1925 DeoptimizeReason reason,
1926 Node* value) {
1927 InstructionCode opcode = kArchDeoptimize; 1927 InstructionCode opcode = kArchDeoptimize;
1928 switch (kind) { 1928 switch (kind) {
1929 case DeoptimizeKind::kEager: 1929 case DeoptimizeKind::kEager:
1930 opcode |= MiscField::encode(Deoptimizer::EAGER); 1930 opcode |= MiscField::encode(Deoptimizer::EAGER);
1931 break; 1931 break;
1932 case DeoptimizeKind::kSoft: 1932 case DeoptimizeKind::kSoft:
1933 opcode |= MiscField::encode(Deoptimizer::SOFT); 1933 opcode |= MiscField::encode(Deoptimizer::SOFT);
1934 break; 1934 break;
1935 } 1935 }
1936 EmitDeoptimize(opcode, 0, nullptr, 0, nullptr, value); 1936 EmitDeoptimize(opcode, 0, nullptr, 0, nullptr, reason, value);
1937 } 1937 }
1938 1938
1939 1939
1940 void InstructionSelector::VisitThrow(Node* value) { 1940 void InstructionSelector::VisitThrow(Node* value) {
1941 OperandGenerator g(this); 1941 OperandGenerator g(this);
1942 Emit(kArchThrowTerminator, g.NoOutput()); 1942 Emit(kArchThrowTerminator, g.NoOutput());
1943 } 1943 }
1944 1944
1945 void InstructionSelector::VisitDebugBreak(Node* node) { 1945 void InstructionSelector::VisitDebugBreak(Node* node) {
1946 OperandGenerator g(this); 1946 OperandGenerator g(this);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 return new (instruction_zone()) FrameStateDescriptor( 1988 return new (instruction_zone()) FrameStateDescriptor(
1989 instruction_zone(), state_info.type(), state_info.bailout_id(), 1989 instruction_zone(), state_info.type(), state_info.bailout_id(),
1990 state_info.state_combine(), parameters, locals, stack, 1990 state_info.state_combine(), parameters, locals, stack,
1991 state_info.shared_info(), outer_state); 1991 state_info.shared_info(), outer_state);
1992 } 1992 }
1993 1993
1994 1994
1995 } // namespace compiler 1995 } // namespace compiler
1996 } // namespace internal 1996 } // namespace internal
1997 } // namespace v8 1997 } // 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