OLD | NEW |
---|---|
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/base/adapters.h" | 5 #include "src/base/adapters.h" |
6 #include "src/base/bits.h" | 6 #include "src/base/bits.h" |
7 #include "src/compiler/instruction-selector-impl.h" | 7 #include "src/compiler/instruction-selector-impl.h" |
8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
10 | 10 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 DCHECK_NE(0u, input_count); | 260 DCHECK_NE(0u, input_count); |
261 DCHECK_NE(0u, output_count); | 261 DCHECK_NE(0u, output_count); |
262 DCHECK_GE(arraysize(inputs), input_count); | 262 DCHECK_GE(arraysize(inputs), input_count); |
263 DCHECK_GE(arraysize(outputs), output_count); | 263 DCHECK_GE(arraysize(outputs), output_count); |
264 DCHECK_NE(kMode_None, AddressingModeField::decode(opcode)); | 264 DCHECK_NE(kMode_None, AddressingModeField::decode(opcode)); |
265 | 265 |
266 opcode = cont->Encode(opcode); | 266 opcode = cont->Encode(opcode); |
267 if (cont->IsDeoptimize()) { | 267 if (cont->IsDeoptimize()) { |
268 selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, | 268 selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, |
269 cont->reason(), cont->frame_state()); | 269 cont->reason(), cont->frame_state()); |
270 } else if (cont->IsTrap()) { | |
271 inputs[input_count++] = g.UseImmediate(cont->trap_id()); | |
272 selector->Emit(opcode, output_count, outputs, input_count, inputs); | |
270 } else { | 273 } else { |
271 selector->Emit(opcode, output_count, outputs, input_count, inputs); | 274 selector->Emit(opcode, output_count, outputs, input_count, inputs); |
272 } | 275 } |
273 } | 276 } |
274 | 277 |
275 | 278 |
276 void VisitBinop(InstructionSelector* selector, Node* node, | 279 void VisitBinop(InstructionSelector* selector, Node* node, |
277 InstructionCode opcode, InstructionCode reverse_opcode) { | 280 InstructionCode opcode, InstructionCode reverse_opcode) { |
278 FlagsContinuation cont; | 281 FlagsContinuation cont; |
279 VisitBinop(selector, node, opcode, reverse_opcode, &cont); | 282 VisitBinop(selector, node, opcode, reverse_opcode, &cont); |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
883 DCHECK_NE(0u, input_count); | 886 DCHECK_NE(0u, input_count); |
884 DCHECK_NE(0u, output_count); | 887 DCHECK_NE(0u, output_count); |
885 DCHECK_GE(arraysize(inputs), input_count); | 888 DCHECK_GE(arraysize(inputs), input_count); |
886 DCHECK_GE(arraysize(outputs), output_count); | 889 DCHECK_GE(arraysize(outputs), output_count); |
887 DCHECK_NE(kMode_None, AddressingModeField::decode(opcode)); | 890 DCHECK_NE(kMode_None, AddressingModeField::decode(opcode)); |
888 | 891 |
889 opcode = cont->Encode(opcode); | 892 opcode = cont->Encode(opcode); |
890 if (cont->IsDeoptimize()) { | 893 if (cont->IsDeoptimize()) { |
891 selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, | 894 selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, |
892 cont->reason(), cont->frame_state()); | 895 cont->reason(), cont->frame_state()); |
896 } else if (cont->IsTrap()) { | |
897 inputs[input_count++] = g.UseImmediate(cont->trap_id()); | |
898 selector->Emit(opcode, output_count, outputs, input_count, inputs); | |
893 } else { | 899 } else { |
894 selector->Emit(opcode, output_count, outputs, input_count, inputs); | 900 selector->Emit(opcode, output_count, outputs, input_count, inputs); |
895 } | 901 } |
896 } | 902 } |
897 | 903 |
898 | 904 |
899 template <typename TryMatchShift> | 905 template <typename TryMatchShift> |
900 void VisitShift(InstructionSelector* selector, Node* node, | 906 void VisitShift(InstructionSelector* selector, Node* node, |
901 TryMatchShift try_match_shift) { | 907 TryMatchShift try_match_shift) { |
902 FlagsContinuation cont; | 908 FlagsContinuation cont; |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1250 InstructionOperand shift_31 = g.UseImmediate(31); | 1256 InstructionOperand shift_31 = g.UseImmediate(31); |
1251 InstructionCode opcode = cont->Encode(kArmCmp) | | 1257 InstructionCode opcode = cont->Encode(kArmCmp) | |
1252 AddressingModeField::encode(kMode_Operand2_R_ASR_I); | 1258 AddressingModeField::encode(kMode_Operand2_R_ASR_I); |
1253 if (cont->IsBranch()) { | 1259 if (cont->IsBranch()) { |
1254 selector->Emit(opcode, g.NoOutput(), temp_operand, result_operand, shift_31, | 1260 selector->Emit(opcode, g.NoOutput(), temp_operand, result_operand, shift_31, |
1255 g.Label(cont->true_block()), g.Label(cont->false_block())); | 1261 g.Label(cont->true_block()), g.Label(cont->false_block())); |
1256 } else if (cont->IsDeoptimize()) { | 1262 } else if (cont->IsDeoptimize()) { |
1257 InstructionOperand in[] = {temp_operand, result_operand, shift_31}; | 1263 InstructionOperand in[] = {temp_operand, result_operand, shift_31}; |
1258 selector->EmitDeoptimize(opcode, 0, nullptr, 3, in, cont->reason(), | 1264 selector->EmitDeoptimize(opcode, 0, nullptr, 3, in, cont->reason(), |
1259 cont->frame_state()); | 1265 cont->frame_state()); |
1260 } else { | 1266 } else if (cont->IsSet()) { |
1261 DCHECK(cont->IsSet()); | 1267 DCHECK(cont->IsSet()); |
georgia.kouveli
2016/12/15 16:39:35
You've missed a couple of redundant DCHECKs here a
ahaas
2016/12/15 16:57:59
Done.
| |
1262 selector->Emit(opcode, g.DefineAsRegister(cont->result()), temp_operand, | 1268 selector->Emit(opcode, g.DefineAsRegister(cont->result()), temp_operand, |
1263 result_operand, shift_31); | 1269 result_operand, shift_31); |
1270 } else { | |
1271 DCHECK(cont->IsTrap()); | |
1272 InstructionOperand in[] = {temp_operand, result_operand, shift_31, | |
1273 g.UseImmediate(cont->trap_id())}; | |
1274 selector->Emit(opcode, 0, nullptr, 4, in); | |
1264 } | 1275 } |
1265 } | 1276 } |
1266 | 1277 |
1267 } // namespace | 1278 } // namespace |
1268 | 1279 |
1269 void InstructionSelector::VisitInt32Mul(Node* node) { | 1280 void InstructionSelector::VisitInt32Mul(Node* node) { |
1270 ArmOperandGenerator g(this); | 1281 ArmOperandGenerator g(this); |
1271 Int32BinopMatcher m(node); | 1282 Int32BinopMatcher m(node); |
1272 if (m.right().HasValue() && m.right().Value() > 0) { | 1283 if (m.right().HasValue() && m.right().Value() > 0) { |
1273 int32_t value = m.right().Value(); | 1284 int32_t value = m.right().Value(); |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1641 InstructionOperand left, InstructionOperand right, | 1652 InstructionOperand left, InstructionOperand right, |
1642 FlagsContinuation* cont) { | 1653 FlagsContinuation* cont) { |
1643 ArmOperandGenerator g(selector); | 1654 ArmOperandGenerator g(selector); |
1644 opcode = cont->Encode(opcode); | 1655 opcode = cont->Encode(opcode); |
1645 if (cont->IsBranch()) { | 1656 if (cont->IsBranch()) { |
1646 selector->Emit(opcode, g.NoOutput(), left, right, | 1657 selector->Emit(opcode, g.NoOutput(), left, right, |
1647 g.Label(cont->true_block()), g.Label(cont->false_block())); | 1658 g.Label(cont->true_block()), g.Label(cont->false_block())); |
1648 } else if (cont->IsDeoptimize()) { | 1659 } else if (cont->IsDeoptimize()) { |
1649 selector->EmitDeoptimize(opcode, g.NoOutput(), left, right, cont->reason(), | 1660 selector->EmitDeoptimize(opcode, g.NoOutput(), left, right, cont->reason(), |
1650 cont->frame_state()); | 1661 cont->frame_state()); |
1662 } else if (cont->IsSet()) { | |
1663 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); | |
1651 } else { | 1664 } else { |
1652 DCHECK(cont->IsSet()); | 1665 DCHECK(cont->IsTrap()); |
1653 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); | 1666 selector->Emit(opcode, g.NoOutput(), left, right, |
1667 g.UseImmediate(cont->trap_id())); | |
1654 } | 1668 } |
1655 } | 1669 } |
1656 | 1670 |
1657 | 1671 |
1658 // Shared routine for multiple float32 compare operations. | 1672 // Shared routine for multiple float32 compare operations. |
1659 void VisitFloat32Compare(InstructionSelector* selector, Node* node, | 1673 void VisitFloat32Compare(InstructionSelector* selector, Node* node, |
1660 FlagsContinuation* cont) { | 1674 FlagsContinuation* cont) { |
1661 ArmOperandGenerator g(selector); | 1675 ArmOperandGenerator g(selector); |
1662 Float32BinopMatcher m(node); | 1676 Float32BinopMatcher m(node); |
1663 if (m.right().Is(0.0f)) { | 1677 if (m.right().Is(0.0f)) { |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1834 } | 1848 } |
1835 | 1849 |
1836 DCHECK_NE(0u, input_count); | 1850 DCHECK_NE(0u, input_count); |
1837 DCHECK_GE(arraysize(inputs), input_count); | 1851 DCHECK_GE(arraysize(inputs), input_count); |
1838 DCHECK_GE(arraysize(outputs), output_count); | 1852 DCHECK_GE(arraysize(outputs), output_count); |
1839 | 1853 |
1840 opcode = cont->Encode(opcode); | 1854 opcode = cont->Encode(opcode); |
1841 if (cont->IsDeoptimize()) { | 1855 if (cont->IsDeoptimize()) { |
1842 selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, | 1856 selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, |
1843 cont->reason(), cont->frame_state()); | 1857 cont->reason(), cont->frame_state()); |
1858 } else if (cont->IsTrap()) { | |
1859 inputs[input_count++] = g.UseImmediate(cont->trap_id()); | |
1860 selector->Emit(opcode, output_count, outputs, input_count, inputs); | |
1844 } else { | 1861 } else { |
1845 selector->Emit(opcode, output_count, outputs, input_count, inputs); | 1862 selector->Emit(opcode, output_count, outputs, input_count, inputs); |
1846 } | 1863 } |
1847 } | 1864 } |
1848 | 1865 |
1849 | 1866 |
1850 void VisitWordCompare(InstructionSelector* selector, Node* node, | 1867 void VisitWordCompare(InstructionSelector* selector, Node* node, |
1851 FlagsContinuation* cont) { | 1868 FlagsContinuation* cont) { |
1852 InstructionCode opcode = kArmCmp; | 1869 InstructionCode opcode = kArmCmp; |
1853 Int32BinopMatcher m(node); | 1870 Int32BinopMatcher m(node); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1990 ArmOperandGenerator g(selector); | 2007 ArmOperandGenerator g(selector); |
1991 InstructionCode const opcode = | 2008 InstructionCode const opcode = |
1992 cont->Encode(kArmTst) | AddressingModeField::encode(kMode_Operand2_R); | 2009 cont->Encode(kArmTst) | AddressingModeField::encode(kMode_Operand2_R); |
1993 InstructionOperand const value_operand = g.UseRegister(value); | 2010 InstructionOperand const value_operand = g.UseRegister(value); |
1994 if (cont->IsBranch()) { | 2011 if (cont->IsBranch()) { |
1995 selector->Emit(opcode, g.NoOutput(), value_operand, value_operand, | 2012 selector->Emit(opcode, g.NoOutput(), value_operand, value_operand, |
1996 g.Label(cont->true_block()), g.Label(cont->false_block())); | 2013 g.Label(cont->true_block()), g.Label(cont->false_block())); |
1997 } else if (cont->IsDeoptimize()) { | 2014 } else if (cont->IsDeoptimize()) { |
1998 selector->EmitDeoptimize(opcode, g.NoOutput(), value_operand, value_operand, | 2015 selector->EmitDeoptimize(opcode, g.NoOutput(), value_operand, value_operand, |
1999 cont->reason(), cont->frame_state()); | 2016 cont->reason(), cont->frame_state()); |
2000 } else { | 2017 } else if (cont->IsSet()) { |
2001 DCHECK(cont->IsSet()); | 2018 DCHECK(cont->IsSet()); |
2002 selector->Emit(opcode, g.DefineAsRegister(cont->result()), value_operand, | 2019 selector->Emit(opcode, g.DefineAsRegister(cont->result()), value_operand, |
2003 value_operand); | 2020 value_operand); |
2021 } else { | |
2022 DCHECK(cont->IsTrap()); | |
2023 selector->Emit(opcode, g.NoOutput(), value_operand, value_operand, | |
2024 g.UseImmediate(cont->trap_id())); | |
2004 } | 2025 } |
2005 } | 2026 } |
2006 | 2027 |
2007 } // namespace | 2028 } // namespace |
2008 | 2029 |
2009 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, | 2030 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, |
2010 BasicBlock* fbranch) { | 2031 BasicBlock* fbranch) { |
2011 FlagsContinuation cont(kNotEqual, tbranch, fbranch); | 2032 FlagsContinuation cont(kNotEqual, tbranch, fbranch); |
2012 VisitWordCompareZero(this, branch, branch->InputAt(0), &cont); | 2033 VisitWordCompareZero(this, branch, branch->InputAt(0), &cont); |
2013 } | 2034 } |
2014 | 2035 |
2015 void InstructionSelector::VisitDeoptimizeIf(Node* node) { | 2036 void InstructionSelector::VisitDeoptimizeIf(Node* node) { |
2016 FlagsContinuation cont = FlagsContinuation::ForDeoptimize( | 2037 FlagsContinuation cont = FlagsContinuation::ForDeoptimize( |
2017 kNotEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1)); | 2038 kNotEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1)); |
2018 VisitWordCompareZero(this, node, node->InputAt(0), &cont); | 2039 VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
2019 } | 2040 } |
2020 | 2041 |
2021 void InstructionSelector::VisitDeoptimizeUnless(Node* node) { | 2042 void InstructionSelector::VisitDeoptimizeUnless(Node* node) { |
2022 FlagsContinuation cont = FlagsContinuation::ForDeoptimize( | 2043 FlagsContinuation cont = FlagsContinuation::ForDeoptimize( |
2023 kEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1)); | 2044 kEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1)); |
2024 VisitWordCompareZero(this, node, node->InputAt(0), &cont); | 2045 VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
2025 } | 2046 } |
2026 | 2047 |
2027 void InstructionSelector::VisitTrapIf(Node* node) { UNREACHABLE(); } | 2048 void InstructionSelector::VisitTrapIf(Node* node) { |
2049 FlagsContinuation cont = FlagsContinuation::ForTrap( | |
2050 kNotEqual, OpParameter<Runtime::FunctionId>(node->op()), | |
2051 node->InputAt(1)); | |
2052 VisitWordCompareZero(this, node, node->InputAt(0), &cont); | |
2053 } | |
2028 | 2054 |
2029 void InstructionSelector::VisitTrapUnless(Node* node) { UNREACHABLE(); } | 2055 void InstructionSelector::VisitTrapUnless(Node* node) { |
2056 FlagsContinuation cont = FlagsContinuation::ForTrap( | |
2057 kEqual, OpParameter<Runtime::FunctionId>(node->op()), node->InputAt(1)); | |
2058 VisitWordCompareZero(this, node, node->InputAt(0), &cont); | |
2059 } | |
2030 | 2060 |
2031 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { | 2061 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { |
2032 ArmOperandGenerator g(this); | 2062 ArmOperandGenerator g(this); |
2033 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); | 2063 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); |
2034 | 2064 |
2035 // Emit either ArchTableSwitch or ArchLookupSwitch. | 2065 // Emit either ArchTableSwitch or ArchLookupSwitch. |
2036 size_t table_space_cost = 4 + sw.value_range; | 2066 size_t table_space_cost = 4 + sw.value_range; |
2037 size_t table_time_cost = 3; | 2067 size_t table_time_cost = 3; |
2038 size_t lookup_space_cost = 3 + 2 * sw.case_count; | 2068 size_t lookup_space_cost = 3 + 2 * sw.case_count; |
2039 size_t lookup_time_cost = sw.case_count; | 2069 size_t lookup_time_cost = sw.case_count; |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2291 Vector<MachineType> req_aligned = Vector<MachineType>::New(2); | 2321 Vector<MachineType> req_aligned = Vector<MachineType>::New(2); |
2292 req_aligned[0] = MachineType::Float32(); | 2322 req_aligned[0] = MachineType::Float32(); |
2293 req_aligned[1] = MachineType::Float64(); | 2323 req_aligned[1] = MachineType::Float64(); |
2294 return MachineOperatorBuilder::AlignmentRequirements:: | 2324 return MachineOperatorBuilder::AlignmentRequirements:: |
2295 SomeUnalignedAccessUnsupported(req_aligned, req_aligned); | 2325 SomeUnalignedAccessUnsupported(req_aligned, req_aligned); |
2296 } | 2326 } |
2297 | 2327 |
2298 } // namespace compiler | 2328 } // namespace compiler |
2299 } // namespace internal | 2329 } // namespace internal |
2300 } // namespace v8 | 2330 } // namespace v8 |
OLD | NEW |