Chromium Code Reviews| 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 1822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1833 default: | 1833 default: |
| 1834 VisitCompare(selector, opcode, g.UseRegister(right), | 1834 VisitCompare(selector, opcode, g.UseRegister(right), |
| 1835 g.UseRegister(left), cont); | 1835 g.UseRegister(left), cont); |
| 1836 } | 1836 } |
| 1837 } else { | 1837 } else { |
| 1838 VisitCompare(selector, opcode, g.UseRegister(left), g.UseRegister(right), | 1838 VisitCompare(selector, opcode, g.UseRegister(left), g.UseRegister(right), |
| 1839 cont); | 1839 cont); |
| 1840 } | 1840 } |
| 1841 } | 1841 } |
| 1842 | 1842 |
| 1843 bool IsNodeUnsigned(Node* n) { | |
| 1844 NodeMatcher m(n); | |
| 1845 | |
| 1846 if (m.IsLoad()) { | |
| 1847 LoadRepresentation load_rep = LoadRepresentationOf(n->op()); | |
| 1848 return load_rep.IsUnsigned(); | |
| 1849 } else if (m.IsUnalignedLoad()) { | |
| 1850 UnalignedLoadRepresentation load_rep = | |
| 1851 UnalignedLoadRepresentationOf(n->op()); | |
| 1852 return load_rep.IsUnsigned(); | |
| 1853 } else { | |
|
ahaas
2016/10/13 08:10:54
I think you also have to deal with parameter and p
ivica.bogosavljevic
2016/10/14 08:16:40
Hi Ahaas!
I looked at the code: the Phi and Selec
titzer
2016/10/15 10:45:33
Is it possible to add some extra --debug-code chec
| |
| 1854 return m.IsUint32Div() || m.IsUint32LessThan() || | |
| 1855 m.IsUint32LessThanOrEqual() || m.IsUint32Mod() || | |
| 1856 m.IsUint32MulHigh() || m.IsChangeFloat64ToUint32() || | |
| 1857 m.IsTruncateFloat64ToUint32() || m.IsTruncateFloat32ToUint32(); | |
| 1858 } | |
| 1859 } | |
| 1860 | |
| 1861 // Shared routine for multiple word compare operations. | |
| 1862 void VisitSimulateWord32Compare(InstructionSelector* selector, Node* node, | |
| 1863 InstructionCode opcode, FlagsContinuation* cont, | |
| 1864 bool commutative) { | |
| 1865 Mips64OperandGenerator g(selector); | |
| 1866 Node* left = node->InputAt(0); | |
| 1867 Node* right = node->InputAt(1); | |
| 1868 InstructionOperand leftOp = g.TempRegister(); | |
| 1869 InstructionOperand rightOp = g.TempRegister(); | |
| 1870 | |
| 1871 selector->Emit(kMips64Dshl, leftOp, g.UseRegister(left), g.TempImmediate(32)); | |
| 1872 selector->Emit(kMips64Dshl, rightOp, g.UseRegister(right), | |
| 1873 g.TempImmediate(32)); | |
| 1874 | |
| 1875 VisitCompare(selector, opcode, leftOp, rightOp, cont); | |
| 1876 } | |
| 1877 | |
| 1878 void VisitWord32Compare(InstructionSelector* selector, Node* node, | |
| 1879 FlagsContinuation* cont) { | |
| 1880 // MIPS64 doesn't support Word32 compare instructions. Instead it relies | |
| 1881 // that the values in registers are correctly sign-extended and uses | |
| 1882 // Word64 comparison instead. This behavior is correct in most cases, | |
| 1883 // but doesn't work when comparing signed with unsigned operands. | |
| 1884 // We could simulate Word32 compare in all cases but this would create | |
| 1885 // an unnecessary overhead since unsigned integers are rarely used | |
| 1886 // in JavaScript. | |
| 1887 // The solution proposed here tries to match a comparison of signed | |
| 1888 // with unsigned operand, and perform Word32Compare simulation only | |
| 1889 // in those cases. Unfortunately, the solution is not complete because | |
| 1890 // it might skip cases where Word32 compare simulation is needed, so | |
| 1891 // basically it is a hack. | |
| 1892 if (IsNodeUnsigned(node->InputAt(0)) != IsNodeUnsigned(node->InputAt(1))) { | |
| 1893 VisitSimulateWord32Compare(selector, node, kMips64Cmp, cont, false); | |
| 1894 } else { | |
| 1895 VisitWordCompare(selector, node, kMips64Cmp, cont, false); | |
| 1896 } | |
| 1897 } | |
| 1898 | |
| 1843 | 1899 |
| 1844 void VisitWord32Compare(InstructionSelector* selector, Node* node, | |
| 1845 FlagsContinuation* cont) { | |
| 1846 VisitWordCompare(selector, node, kMips64Cmp, cont, false); | |
| 1847 } | |
| 1848 | |
| 1849 | |
| 1850 void VisitWord64Compare(InstructionSelector* selector, Node* node, | 1900 void VisitWord64Compare(InstructionSelector* selector, Node* node, |
| 1851 FlagsContinuation* cont) { | 1901 FlagsContinuation* cont) { |
| 1852 VisitWordCompare(selector, node, kMips64Cmp, cont, false); | 1902 VisitWordCompare(selector, node, kMips64Cmp, cont, false); |
| 1853 } | 1903 } |
| 1854 | 1904 |
| 1855 | 1905 |
| 1856 | 1906 |
| 1857 void EmitWordCompareZero(InstructionSelector* selector, Node* value, | 1907 void EmitWordCompareZero(InstructionSelector* selector, Node* value, |
| 1858 FlagsContinuation* cont) { | 1908 FlagsContinuation* cont) { |
| 1859 Mips64OperandGenerator g(selector); | 1909 Mips64OperandGenerator g(selector); |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2331 } else { | 2381 } else { |
| 2332 DCHECK(kArchVariant == kMips64r2); | 2382 DCHECK(kArchVariant == kMips64r2); |
| 2333 return MachineOperatorBuilder::AlignmentRequirements:: | 2383 return MachineOperatorBuilder::AlignmentRequirements:: |
| 2334 NoUnalignedAccessSupport(); | 2384 NoUnalignedAccessSupport(); |
| 2335 } | 2385 } |
| 2336 } | 2386 } |
| 2337 | 2387 |
| 2338 } // namespace compiler | 2388 } // namespace compiler |
| 2339 } // namespace internal | 2389 } // namespace internal |
| 2340 } // namespace v8 | 2390 } // namespace v8 |
| OLD | NEW |