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

Side by Side Diff: runtime/vm/intermediate_language_dbc.cc

Issue 2463593002: VM: Enable branch merging of isnan, isinf. (Closed)
Patch Set: addressed comments Created 4 years, 1 month 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 | « runtime/vm/intermediate_language_arm64.cc ('k') | runtime/vm/intermediate_language_ia32.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 (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_DBC. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_DBC.
6 #if defined(TARGET_ARCH_DBC) 6 #if defined(TARGET_ARCH_DBC)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 switch (op_kind()) { 1642 switch (op_kind()) {
1643 case Token::kADD: __ DAdd(result, left, right); break; 1643 case Token::kADD: __ DAdd(result, left, right); break;
1644 case Token::kSUB: __ DSub(result, left, right); break; 1644 case Token::kSUB: __ DSub(result, left, right); break;
1645 case Token::kMUL: __ DMul(result, left, right); break; 1645 case Token::kMUL: __ DMul(result, left, right); break;
1646 case Token::kDIV: __ DDiv(result, left, right); break; 1646 case Token::kDIV: __ DDiv(result, left, right); break;
1647 default: UNREACHABLE(); 1647 default: UNREACHABLE();
1648 } 1648 }
1649 } 1649 }
1650 1650
1651 1651
1652 Condition DoubleTestOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
1653 BranchLabels labels) {
1654 UNREACHABLE();
1655 return Condition();
1656 }
1657
1658
1659 void DoubleTestOpInstr::EmitBranchCode(FlowGraphCompiler* compiler,
1660 BranchInstr* branch) {
1661 ASSERT(compiler->is_optimizing());
1662 BranchLabels labels = compiler->CreateBranchLabels(branch);
1663 const Register value = locs()->in(0).reg();
1664 switch (op_kind()) {
1665 case MethodRecognizer::kDouble_getIsNaN:
1666 __ DoubleIsNaN(value);
1667 break;
1668 case MethodRecognizer::kDouble_getIsInfinite:
1669 __ DoubleIsInfinite(value);
1670 break;
1671 default:
1672 UNREACHABLE();
1673 }
1674 const bool is_negated = kind() != Token::kEQ;
1675 EmitBranchOnCondition(
1676 compiler, is_negated ? NEXT_IS_FALSE : NEXT_IS_TRUE, labels);
1677 }
1678
1679
1652 EMIT_NATIVE_CODE(DoubleTestOp, 1, Location::RequiresRegister()) { 1680 EMIT_NATIVE_CODE(DoubleTestOp, 1, Location::RequiresRegister()) {
1653 ASSERT(compiler->is_optimizing()); 1681 ASSERT(compiler->is_optimizing());
1654 const Register value = locs()->in(0).reg(); 1682 const Register value = locs()->in(0).reg();
1655 const Register result = locs()->out(0).reg(); 1683 const Register result = locs()->out(0).reg();
1684 const bool is_negated = kind() != Token::kEQ;
1685 __ LoadConstant(result, is_negated ? Bool::True() : Bool::False());
1656 switch (op_kind()) { 1686 switch (op_kind()) {
1657 case MethodRecognizer::kDouble_getIsNaN: 1687 case MethodRecognizer::kDouble_getIsNaN:
1658 __ DoubleIsNaN(result, value); 1688 __ DoubleIsNaN(value);
1659 break; 1689 break;
1660 case MethodRecognizer::kDouble_getIsInfinite: 1690 case MethodRecognizer::kDouble_getIsInfinite:
1661 __ DoubleIsInfinite(result, value); 1691 __ DoubleIsInfinite(value);
1662 break; 1692 break;
1663 default: 1693 default:
1664 UNREACHABLE(); 1694 UNREACHABLE();
1665 } 1695 }
1696 __ LoadConstant(result, is_negated ? Bool::False() : Bool::True());
1666 } 1697 }
1667 1698
1668 1699
1669 EMIT_NATIVE_CODE(UnaryDoubleOp, 1, Location::RequiresRegister()) { 1700 EMIT_NATIVE_CODE(UnaryDoubleOp, 1, Location::RequiresRegister()) {
1670 const Register value = locs()->in(0).reg(); 1701 const Register value = locs()->in(0).reg();
1671 const Register result = locs()->out(0).reg(); 1702 const Register result = locs()->out(0).reg();
1672 __ DNeg(result, value); 1703 __ DNeg(result, value);
1673 } 1704 }
1674 1705
1675 1706
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 condition = NEXT_IS_FALSE; 1856 condition = NEXT_IS_FALSE;
1826 comparison = FlipCondition(kind); 1857 comparison = FlipCondition(kind);
1827 } 1858 }
1828 __ Emit(Bytecode::Encode(OpcodeForSmiCondition(comparison), left, right)); 1859 __ Emit(Bytecode::Encode(OpcodeForSmiCondition(comparison), left, right));
1829 return condition; 1860 return condition;
1830 } 1861 }
1831 1862
1832 1863
1833 static Condition EmitDoubleComparisonOp(FlowGraphCompiler* compiler, 1864 static Condition EmitDoubleComparisonOp(FlowGraphCompiler* compiler,
1834 LocationSummary* locs, 1865 LocationSummary* locs,
1835 Token::Kind kind, 1866 Token::Kind kind) {
1836 BranchLabels labels) {
1837 const Register left = locs->in(0).reg(); 1867 const Register left = locs->in(0).reg();
1838 const Register right = locs->in(1).reg(); 1868 const Register right = locs->in(1).reg();
1839 Token::Kind comparison = kind; 1869 Token::Kind comparison = kind;
1840 // For double comparisons we can't flip the condition like with smi 1870 // For double comparisons we can't flip the condition like with smi
1841 // comparisons because of NaN which will compare false for all except != 1871 // comparisons because of NaN which will compare false for all except !=
1842 // operations. 1872 // operations.
1843 // TODO(fschneider): Change the block order instead in DBC so that the 1873 // TODO(fschneider): Change the block order instead in DBC so that the
1844 // false block in always the fall-through block. 1874 // false block in always the fall-through block.
1845 Condition condition = NEXT_IS_TRUE; 1875 Condition condition = NEXT_IS_TRUE;
1846 __ Emit(Bytecode::Encode(OpcodeForDoubleCondition(comparison), left, right)); 1876 __ Emit(Bytecode::Encode(OpcodeForDoubleCondition(comparison), left, right));
1847 return condition; 1877 return condition;
1848 } 1878 }
1849 1879
1850 1880
1851 Condition EqualityCompareInstr::EmitComparisonCode(FlowGraphCompiler* compiler, 1881 Condition EqualityCompareInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
1852 BranchLabels labels) { 1882 BranchLabels labels) {
1853 if (operation_cid() == kSmiCid) { 1883 if (operation_cid() == kSmiCid) {
1854 return EmitSmiComparisonOp(compiler, locs(), kind(), labels); 1884 return EmitSmiComparisonOp(compiler, locs(), kind(), labels);
1855 } else { 1885 } else {
1856 ASSERT(operation_cid() == kDoubleCid); 1886 ASSERT(operation_cid() == kDoubleCid);
1857 return EmitDoubleComparisonOp(compiler, locs(), kind(), labels); 1887 return EmitDoubleComparisonOp(compiler, locs(), kind());
1858 } 1888 }
1859 } 1889 }
1860 1890
1861 1891
1862 EMIT_NATIVE_CODE(EqualityCompare, 2, Location::RequiresRegister()) { 1892 EMIT_NATIVE_CODE(EqualityCompare, 2, Location::RequiresRegister()) {
1863 ASSERT(compiler->is_optimizing()); 1893 ASSERT(compiler->is_optimizing());
1864 ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE)); 1894 ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE));
1865 Label is_true, is_false; 1895 Label is_true, is_false;
1866 // These labels are not used. They are arranged so that EmitComparisonCode 1896 // These labels are not used. They are arranged so that EmitComparisonCode
1867 // emits a test that executes the following instruction when the test 1897 // emits a test that executes the following instruction when the test
(...skipping 15 matching lines...) Expand all
1883 EmitBranchOnCondition(compiler, true_condition, labels); 1913 EmitBranchOnCondition(compiler, true_condition, labels);
1884 } 1914 }
1885 1915
1886 1916
1887 Condition RelationalOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler, 1917 Condition RelationalOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
1888 BranchLabels labels) { 1918 BranchLabels labels) {
1889 if (operation_cid() == kSmiCid) { 1919 if (operation_cid() == kSmiCid) {
1890 return EmitSmiComparisonOp(compiler, locs(), kind(), labels); 1920 return EmitSmiComparisonOp(compiler, locs(), kind(), labels);
1891 } else { 1921 } else {
1892 ASSERT(operation_cid() == kDoubleCid); 1922 ASSERT(operation_cid() == kDoubleCid);
1893 return EmitDoubleComparisonOp(compiler, locs(), kind(), labels); 1923 return EmitDoubleComparisonOp(compiler, locs(), kind());
1894 } 1924 }
1895 } 1925 }
1896 1926
1897 1927
1898 EMIT_NATIVE_CODE(RelationalOp, 2, Location::RequiresRegister()) { 1928 EMIT_NATIVE_CODE(RelationalOp, 2, Location::RequiresRegister()) {
1899 ASSERT(compiler->is_optimizing()); 1929 ASSERT(compiler->is_optimizing());
1900 Label is_true, is_false; 1930 Label is_true, is_false;
1901 BranchLabels labels = { &is_true, &is_false, &is_false }; 1931 BranchLabels labels = { &is_true, &is_false, &is_false };
1902 const Register result = locs()->out(0).reg(); 1932 const Register result = locs()->out(0).reg();
1903 __ LoadConstant(result, Bool::False()); 1933 __ LoadConstant(result, Bool::False());
(...skipping 25 matching lines...) Expand all
1929 __ IfULe(length, index); 1959 __ IfULe(length, index);
1930 compiler->EmitDeopt(deopt_id(), 1960 compiler->EmitDeopt(deopt_id(),
1931 ICData::kDeoptCheckArrayBound, 1961 ICData::kDeoptCheckArrayBound,
1932 (generalized_ ? ICData::kGeneralized : 0) | 1962 (generalized_ ? ICData::kGeneralized : 0) |
1933 (licm_hoisted_ ? ICData::kHoisted : 0)); 1963 (licm_hoisted_ ? ICData::kHoisted : 0));
1934 } 1964 }
1935 1965
1936 } // namespace dart 1966 } // namespace dart
1937 1967
1938 #endif // defined TARGET_ARCH_DBC 1968 #endif // defined TARGET_ARCH_DBC
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_arm64.cc ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698