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

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

Issue 2562393002: [wasm] Introduce the TrapIf and TrapUnless operators to generate trap code. (Closed)
Patch Set: Rename UseSourcePosition to IsSourcePositionUsed Created 4 years 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/x64/code-generator-x64.cc ('k') | src/compiler/x87/code-generator-x87.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 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "src/base/adapters.h" 7 #include "src/base/adapters.h"
8 #include "src/compiler/instruction-selector-impl.h" 8 #include "src/compiler/instruction-selector-impl.h"
9 #include "src/compiler/node-matchers.h" 9 #include "src/compiler/node-matchers.h"
10 #include "src/compiler/node-properties.h" 10 #include "src/compiler/node-properties.h"
(...skipping 1669 matching lines...) Expand 10 before | Expand all | Expand 10 after
1680 opcode = cont->Encode(opcode); 1680 opcode = cont->Encode(opcode);
1681 inputs[input_count++] = right; 1681 inputs[input_count++] = right;
1682 1682
1683 if (cont->IsBranch()) { 1683 if (cont->IsBranch()) {
1684 inputs[input_count++] = g.Label(cont->true_block()); 1684 inputs[input_count++] = g.Label(cont->true_block());
1685 inputs[input_count++] = g.Label(cont->false_block()); 1685 inputs[input_count++] = g.Label(cont->false_block());
1686 selector->Emit(opcode, 0, nullptr, input_count, inputs); 1686 selector->Emit(opcode, 0, nullptr, input_count, inputs);
1687 } else if (cont->IsDeoptimize()) { 1687 } else if (cont->IsDeoptimize()) {
1688 selector->EmitDeoptimize(opcode, 0, nullptr, input_count, inputs, 1688 selector->EmitDeoptimize(opcode, 0, nullptr, input_count, inputs,
1689 cont->reason(), cont->frame_state()); 1689 cont->reason(), cont->frame_state());
1690 } else { 1690 } else if (cont->IsSet()) {
1691 DCHECK(cont->IsSet());
1692 InstructionOperand output = g.DefineAsRegister(cont->result()); 1691 InstructionOperand output = g.DefineAsRegister(cont->result());
1693 selector->Emit(opcode, 1, &output, input_count, inputs); 1692 selector->Emit(opcode, 1, &output, input_count, inputs);
1693 } else {
1694 DCHECK(cont->IsTrap());
1695 inputs[input_count++] = g.UseImmediate(cont->trap_id());
1696 selector->Emit(opcode, 0, nullptr, input_count, inputs);
1694 } 1697 }
1695 } 1698 }
1696 1699
1697 // Shared routine for multiple compare operations. 1700 // Shared routine for multiple compare operations.
1698 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, 1701 void VisitCompare(InstructionSelector* selector, InstructionCode opcode,
1699 InstructionOperand left, InstructionOperand right, 1702 InstructionOperand left, InstructionOperand right,
1700 FlagsContinuation* cont) { 1703 FlagsContinuation* cont) {
1701 X64OperandGenerator g(selector); 1704 X64OperandGenerator g(selector);
1702 opcode = cont->Encode(opcode); 1705 opcode = cont->Encode(opcode);
1703 if (cont->IsBranch()) { 1706 if (cont->IsBranch()) {
1704 selector->Emit(opcode, g.NoOutput(), left, right, 1707 selector->Emit(opcode, g.NoOutput(), left, right,
1705 g.Label(cont->true_block()), g.Label(cont->false_block())); 1708 g.Label(cont->true_block()), g.Label(cont->false_block()));
1706 } else if (cont->IsDeoptimize()) { 1709 } else if (cont->IsDeoptimize()) {
1707 selector->EmitDeoptimize(opcode, g.NoOutput(), left, right, cont->reason(), 1710 selector->EmitDeoptimize(opcode, g.NoOutput(), left, right, cont->reason(),
1708 cont->frame_state()); 1711 cont->frame_state());
1712 } else if (cont->IsSet()) {
1713 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right);
1709 } else { 1714 } else {
1710 DCHECK(cont->IsSet()); 1715 DCHECK(cont->IsTrap());
1711 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); 1716 selector->Emit(opcode, g.NoOutput(), left, right,
1717 g.UseImmediate(cont->trap_id()));
1712 } 1718 }
1713 } 1719 }
1714 1720
1715 1721
1716 // Shared routine for multiple compare operations. 1722 // Shared routine for multiple compare operations.
1717 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, 1723 void VisitCompare(InstructionSelector* selector, InstructionCode opcode,
1718 Node* left, Node* right, FlagsContinuation* cont, 1724 Node* left, Node* right, FlagsContinuation* cont,
1719 bool commutative) { 1725 bool commutative) {
1720 X64OperandGenerator g(selector); 1726 X64OperandGenerator g(selector);
1721 if (commutative && g.CanBeBetterLeftOperand(right)) { 1727 if (commutative && g.CanBeBetterLeftOperand(right)) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1851 if (mleft.object().Is(js_stack_limit) && mleft.index().Is(0)) { 1857 if (mleft.object().Is(js_stack_limit) && mleft.index().Is(0)) {
1852 // Compare(Load(js_stack_limit), LoadStackPointer) 1858 // Compare(Load(js_stack_limit), LoadStackPointer)
1853 if (!node->op()->HasProperty(Operator::kCommutative)) cont->Commute(); 1859 if (!node->op()->HasProperty(Operator::kCommutative)) cont->Commute();
1854 InstructionCode opcode = cont->Encode(kX64StackCheck); 1860 InstructionCode opcode = cont->Encode(kX64StackCheck);
1855 if (cont->IsBranch()) { 1861 if (cont->IsBranch()) {
1856 selector->Emit(opcode, g.NoOutput(), g.Label(cont->true_block()), 1862 selector->Emit(opcode, g.NoOutput(), g.Label(cont->true_block()),
1857 g.Label(cont->false_block())); 1863 g.Label(cont->false_block()));
1858 } else if (cont->IsDeoptimize()) { 1864 } else if (cont->IsDeoptimize()) {
1859 selector->EmitDeoptimize(opcode, 0, nullptr, 0, nullptr, cont->reason(), 1865 selector->EmitDeoptimize(opcode, 0, nullptr, 0, nullptr, cont->reason(),
1860 cont->frame_state()); 1866 cont->frame_state());
1867 } else if (cont->IsSet()) {
1868 selector->Emit(opcode, g.DefineAsRegister(cont->result()));
1861 } else { 1869 } else {
1862 DCHECK(cont->IsSet()); 1870 DCHECK(cont->IsTrap());
1863 selector->Emit(opcode, g.DefineAsRegister(cont->result())); 1871 selector->Emit(opcode, g.NoOutput(), g.UseImmediate(cont->trap_id()));
1864 } 1872 }
1865 return; 1873 return;
1866 } 1874 }
1867 } 1875 }
1868 VisitWordCompare(selector, node, kX64Cmp, cont); 1876 VisitWordCompare(selector, node, kX64Cmp, cont);
1869 } 1877 }
1870 1878
1871 1879
1872 // Shared routine for comparison with zero. 1880 // Shared routine for comparison with zero.
1873 void VisitCompareZero(InstructionSelector* selector, Node* node, 1881 void VisitCompareZero(InstructionSelector* selector, Node* node,
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
2061 kNotEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1)); 2069 kNotEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1));
2062 VisitWordCompareZero(this, node, node->InputAt(0), &cont); 2070 VisitWordCompareZero(this, node, node->InputAt(0), &cont);
2063 } 2071 }
2064 2072
2065 void InstructionSelector::VisitDeoptimizeUnless(Node* node) { 2073 void InstructionSelector::VisitDeoptimizeUnless(Node* node) {
2066 FlagsContinuation cont = FlagsContinuation::ForDeoptimize( 2074 FlagsContinuation cont = FlagsContinuation::ForDeoptimize(
2067 kEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1)); 2075 kEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1));
2068 VisitWordCompareZero(this, node, node->InputAt(0), &cont); 2076 VisitWordCompareZero(this, node, node->InputAt(0), &cont);
2069 } 2077 }
2070 2078
2079 void InstructionSelector::VisitTrapIf(Node* node) {
2080 FlagsContinuation cont = FlagsContinuation::ForTrap(
2081 kNotEqual, OpParameter<Runtime::FunctionId>(node->op()),
2082 node->InputAt(1));
2083 VisitWordCompareZero(this, node, node->InputAt(0), &cont);
2084 }
2085
2086 void InstructionSelector::VisitTrapUnless(Node* node) {
2087 FlagsContinuation cont = FlagsContinuation::ForTrap(
2088 kEqual, OpParameter<Runtime::FunctionId>(node->op()), node->InputAt(1));
2089 VisitWordCompareZero(this, node, node->InputAt(0), &cont);
2090 }
2091
2071 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { 2092 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) {
2072 X64OperandGenerator g(this); 2093 X64OperandGenerator g(this);
2073 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); 2094 InstructionOperand value_operand = g.UseRegister(node->InputAt(0));
2074 2095
2075 // Emit either ArchTableSwitch or ArchLookupSwitch. 2096 // Emit either ArchTableSwitch or ArchLookupSwitch.
2076 size_t table_space_cost = 4 + sw.value_range; 2097 size_t table_space_cost = 4 + sw.value_range;
2077 size_t table_time_cost = 3; 2098 size_t table_time_cost = 3;
2078 size_t lookup_space_cost = 3 + 2 * sw.case_count; 2099 size_t lookup_space_cost = 3 + 2 * sw.case_count;
2079 size_t lookup_time_cost = sw.case_count; 2100 size_t lookup_time_cost = sw.case_count;
2080 if (sw.case_count > 4 && 2101 if (sw.case_count > 4 &&
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
2430 // static 2451 // static
2431 MachineOperatorBuilder::AlignmentRequirements 2452 MachineOperatorBuilder::AlignmentRequirements
2432 InstructionSelector::AlignmentRequirements() { 2453 InstructionSelector::AlignmentRequirements() {
2433 return MachineOperatorBuilder::AlignmentRequirements:: 2454 return MachineOperatorBuilder::AlignmentRequirements::
2434 FullUnalignedAccessSupport(); 2455 FullUnalignedAccessSupport();
2435 } 2456 }
2436 2457
2437 } // namespace compiler 2458 } // namespace compiler
2438 } // namespace internal 2459 } // namespace internal
2439 } // namespace v8 2460 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/x64/code-generator-x64.cc ('k') | src/compiler/x87/code-generator-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698