1799 }
1800 }
1801
1802 untaken_branch = _gvn.transform(untaken_branch);
1803 set_control(untaken_branch);
1804
1805 // Branch not taken.
1806 if (stopped() && ctrl_taken == NULL) {
1807 if (C->eliminate_boxing()) {
1808 // Mark the successor block as parsed (if caller does not re-wire control flow)
1809 next_block->next_path_num();
1810 }
1811 } else {
1812 // Update method data
1813 profile_not_taken_branch();
1814 adjust_map_after_if(untaken_btest, c, untaken_prob, next_block);
1815 }
1816 }
1817
1818 void Parse::do_acmp(BoolTest::mask btest, Node* a, Node* b) {
1819 // In the case were both operands might be value types, we need to
1820 // use the new acmp implementation. Otherwise, i.e. if one operand
1821 // is not a value type, we can use the old acmp implementation.
1822 Node* cmp = C->optimize_acmp(&_gvn, a, b);
1823 if (cmp != NULL) {
1824 // Use optimized/old acmp
1825 cmp = optimize_cmp_with_klass(_gvn.transform(cmp));
1826 do_if(btest, cmp);
1827 return;
1828 }
1829
1830 Node* ctrl = NULL;
1831 bool safe_for_replace = true;
1832 if (!UsePointerPerturbation) {
1833 // Emit old acmp before new acmp for quick a != b check
1834 cmp = CmpP(a, b);
1835 cmp = optimize_cmp_with_klass(_gvn.transform(cmp));
1836 if (btest == BoolTest::ne) {
1837 do_if(btest, cmp, true);
1838 if (stopped()) {
1839 return; // Never equal
1840 }
1841 } else if (btest == BoolTest::eq) {
1842 Node* is_equal = NULL;
1843 {
1844 PreserveJVMState pjvms(this);
1845 do_if(btest, cmp, false, &is_equal);
1846 if (!stopped()) {
1847 // Not equal, skip valuetype check
1848 ctrl = new RegionNode(3);
1849 ctrl->init_req(1, control());
1850 _gvn.set_type(ctrl, Type::CONTROL);
1851 record_for_igvn(ctrl);
1852 safe_for_replace = false;
1872 speculate = true;
1873 } else if (!_gvn.type(b)->speculative_maybe_null()) {
1874 speculate = true;
1875 swap(a, b);
1876 }
1877 }
1878 inc_sp(2);
1879 Node* null_ctl = top();
1880 Node* not_null_a = null_check_oop(a, &null_ctl, speculate, safe_for_replace, speculate);
1881 assert(!stopped(), "operand is always null");
1882 dec_sp(2);
1883 Node* region = new RegionNode(2);
1884 Node* is_value = new PhiNode(region, TypeX_X);
1885 if (null_ctl != top()) {
1886 assert(!speculate, "should never be null");
1887 region->add_req(null_ctl);
1888 is_value->add_req(_gvn.MakeConX(0));
1889 }
1890
1891 Node* value_mask = _gvn.MakeConX(markOopDesc::always_locked_pattern);
1892 if (UsePointerPerturbation) {
1893 Node* mark_addr = basic_plus_adr(not_null_a, oopDesc::mark_offset_in_bytes());
1894 Node* mark = make_load(NULL, mark_addr, TypeX_X, TypeX_X->basic_type(), MemNode::unordered);
1895 Node* not_mark = _gvn.transform(new XorXNode(mark, _gvn.MakeConX(-1)));
1896 Node* andn = _gvn.transform(new AndXNode(not_mark, value_mask));
1897 Node* neg_if_value = _gvn.transform(new SubXNode(andn, _gvn.MakeConX(1)));
1898 is_value->init_req(1, _gvn.transform(new RShiftXNode(neg_if_value, _gvn.intcon(63))));
1899 } else {
1900 is_value->init_req(1, is_always_locked(not_null_a));
1901 }
1902 region->init_req(1, control());
1903
1904 set_control(_gvn.transform(region));
1905 is_value = _gvn.transform(is_value);
1906
1907 if (UsePointerPerturbation) {
1908 // Perturbe oop if operand is a value type to make comparison fail
1909 Node* pert = _gvn.transform(new AddPNode(a, a, is_value));
1910 cmp = _gvn.transform(new CmpPNode(pert, b));
1911 } else {
1912 // Check for a value type because we already know that operands are equal
1913 cmp = _gvn.transform(new CmpXNode(is_value, value_mask));
1914 btest = (btest == BoolTest::eq) ? BoolTest::ne : BoolTest::eq;
1915 }
1916 cmp = optimize_cmp_with_klass(cmp);
1917 do_if(btest, cmp);
1918
1919 if (ctrl != NULL) {
1920 ctrl->init_req(2, control());
1921 set_control(_gvn.transform(ctrl));
1922 }
1923 }
1924
1925 bool Parse::path_is_suitable_for_uncommon_trap(float prob) const {
1926 // Don't want to speculate on uncommon traps when running with -Xcomp
1927 if (!UseInterpreter) {
|
1799 }
1800 }
1801
1802 untaken_branch = _gvn.transform(untaken_branch);
1803 set_control(untaken_branch);
1804
1805 // Branch not taken.
1806 if (stopped() && ctrl_taken == NULL) {
1807 if (C->eliminate_boxing()) {
1808 // Mark the successor block as parsed (if caller does not re-wire control flow)
1809 next_block->next_path_num();
1810 }
1811 } else {
1812 // Update method data
1813 profile_not_taken_branch();
1814 adjust_map_after_if(untaken_btest, c, untaken_prob, next_block);
1815 }
1816 }
1817
1818 void Parse::do_acmp(BoolTest::mask btest, Node* a, Node* b) {
1819 ciMethod* subst_method = ciEnv::current()->ValueBootstrapMethods_klass()->find_method(ciSymbol::isSubstitutable_name(), ciSymbol::object_object_boolean_signature());
1820 // If current method is ValueBootstrapMethods::isSubstitutable(),
1821 // compile the acmp as a regular pointer comparison otherwise we
1822 // could call ValueBootstrapMethods::isSubstitutable() back
1823 if (ACmpOnValues == 0 || !EnableValhalla || method() == subst_method) {
1824 Node* cmp = CmpP(a, b);
1825 cmp = optimize_cmp_with_klass(cmp);
1826 do_if(btest, cmp);
1827 return;
1828 }
1829
1830 if (ACmpOnValues == 3) {
1831 // Substituability test
1832 if (a->is_ValueType()) {
1833 inc_sp(2);
1834 a = a->as_ValueType()->allocate(this, true)->get_oop();
1835 dec_sp(2);
1836 }
1837 if (b->is_ValueType()) {
1838 inc_sp(2);
1839 b = b->as_ValueType()->allocate(this, true)->get_oop();
1840 dec_sp(2);
1841 }
1842
1843 const TypeOopPtr* ta = _gvn.type(a)->isa_oopptr();
1844 const TypeOopPtr* tb = _gvn.type(b)->isa_oopptr();
1845
1846 if (ta == NULL || !ta->can_be_value_type() ||
1847 tb == NULL || !tb->can_be_value_type()) {
1848 Node* cmp = CmpP(a, b);
1849 cmp = optimize_cmp_with_klass(cmp);
1850 do_if(btest, cmp);
1851 return;
1852 }
1853
1854 Node* cmp = CmpP(a, b);
1855 cmp = optimize_cmp_with_klass(cmp);
1856 Node* eq_region = NULL;
1857 if (btest == BoolTest::eq) {
1858 do_if(btest, cmp, true);
1859 if (stopped()) {
1860 return;
1861 }
1862 } else {
1863 assert(btest == BoolTest::ne, "only eq or ne");
1864 Node* is_not_equal = NULL;
1865 eq_region = new RegionNode(3);
1866 {
1867 PreserveJVMState pjvms(this);
1868 do_if(btest, cmp, false, &is_not_equal);
1869 if (!stopped()) {
1870 eq_region->init_req(1, control());
1871 }
1872 }
1873 if (is_not_equal == NULL || is_not_equal->is_top()) {
1874 record_for_igvn(eq_region);
1875 set_control(_gvn.transform(eq_region));
1876 return;
1877 }
1878 set_control(is_not_equal);
1879 }
1880 // Pointers not equal, check for values
1881 Node* ne_region = new RegionNode(6);
1882 inc_sp(2);
1883 Node* null_ctl = top();
1884 Node* not_null_a = null_check_oop(a, &null_ctl, !too_many_traps(Deoptimization::Reason_null_check), false, false);
1885 dec_sp(2);
1886 ne_region->init_req(1, null_ctl);
1887 if (stopped()) {
1888 record_for_igvn(ne_region);
1889 set_control(_gvn.transform(ne_region));
1890 if (btest == BoolTest::ne) {
1891 {
1892 PreserveJVMState pjvms(this);
1893 int target_bci = iter().get_dest();
1894 merge(target_bci);
1895 }
1896 record_for_igvn(eq_region);
1897 set_control(_gvn.transform(eq_region));
1898 }
1899 return;
1900 }
1901
1902 Node* is_value = is_always_locked(not_null_a);
1903 Node* value_mask = _gvn.MakeConX(markOopDesc::always_locked_pattern);
1904 Node* is_value_cmp = _gvn.transform(new CmpXNode(is_value, value_mask));
1905 Node* is_value_bol = _gvn.transform(new BoolNode(is_value_cmp, BoolTest::ne));
1906 IfNode* is_value_iff = create_and_map_if(control(), is_value_bol, PROB_FAIR, COUNT_UNKNOWN);
1907 Node* not_value = _gvn.transform(new IfTrueNode(is_value_iff));
1908 set_control(_gvn.transform(new IfFalseNode(is_value_iff)));
1909 ne_region->init_req(2, not_value);
1910
1911 // One of the 2 pointers refer to a value, check if both are of
1912 // the same class
1913 inc_sp(2);
1914 null_ctl = top();
1915 Node* not_null_b = null_check_oop(b, &null_ctl, !too_many_traps(Deoptimization::Reason_null_check), false, false);
1916 dec_sp(2);
1917 ne_region->init_req(3, null_ctl);
1918 if (stopped()) {
1919 record_for_igvn(ne_region);
1920 set_control(_gvn.transform(ne_region));
1921 if (btest == BoolTest::ne) {
1922 {
1923 PreserveJVMState pjvms(this);
1924 int target_bci = iter().get_dest();
1925 merge(target_bci);
1926 }
1927 record_for_igvn(eq_region);
1928 set_control(_gvn.transform(eq_region));
1929 }
1930 return;
1931 }
1932 Node* kls_a = load_object_klass(not_null_a);
1933 Node* kls_b = load_object_klass(not_null_b);
1934 Node* kls_cmp = CmpP(kls_a, kls_b);
1935 Node* kls_bol = _gvn.transform(new BoolNode(kls_cmp, BoolTest::ne));
1936 IfNode* kls_iff = create_and_map_if(control(), kls_bol, PROB_FAIR, COUNT_UNKNOWN);
1937 Node* kls_ne = _gvn.transform(new IfTrueNode(kls_iff));
1938 set_control(_gvn.transform(new IfFalseNode(kls_iff)));
1939 ne_region->init_req(4, kls_ne);
1940
1941 if (stopped()) {
1942 record_for_igvn(ne_region);
1943 set_control(_gvn.transform(ne_region));
1944 if (btest == BoolTest::ne) {
1945 {
1946 PreserveJVMState pjvms(this);
1947 int target_bci = iter().get_dest();
1948 merge(target_bci);
1949 }
1950 record_for_igvn(eq_region);
1951 set_control(_gvn.transform(eq_region));
1952 }
1953 return;
1954 }
1955 // Both are values of the same class, we need to perform a
1956 // substituability test. Delegate to
1957 // ValueBootstrapMethods::isSubstitutable().
1958
1959 Node* ne_io_phi = PhiNode::make(ne_region, i_o());
1960 Node* mem = reset_memory();
1961 Node* ne_mem_phi = PhiNode::make(ne_region, mem);
1962
1963 Node* eq_io_phi = NULL;
1964 Node* eq_mem_phi = NULL;
1965 if (eq_region != NULL) {
1966 eq_io_phi = PhiNode::make(eq_region, i_o());
1967 eq_mem_phi = PhiNode::make(eq_region, mem);
1968 }
1969
1970 set_all_memory(mem);
1971
1972 kill_dead_locals();
1973 CallStaticJavaNode *call = new CallStaticJavaNode(C, TypeFunc::make(subst_method), SharedRuntime::get_resolve_static_call_stub(), subst_method, bci());
1974 call->set_override_symbolic_info(true);
1975 call->init_req(TypeFunc::Parms, not_null_a);
1976 call->init_req(TypeFunc::Parms+1, not_null_b);
1977 inc_sp(2);
1978 set_edges_for_java_call(call, false, false);
1979 Node* ret = set_results_for_java_call(call, false, true);
1980 dec_sp(2);
1981
1982 // Test the return value of ValueBootstrapMethods::isSubstitutable()
1983 Node* subst_cmp = _gvn.transform(new CmpINode(ret, intcon(1)));
1984 if (btest == BoolTest::eq) {
1985 do_if(btest, subst_cmp);
1986 } else {
1987 assert(btest == BoolTest::ne, "only eq or ne");
1988 Node* is_not_equal = NULL;
1989 {
1990 PreserveJVMState pjvms(this);
1991 do_if(btest, subst_cmp, false, &is_not_equal);
1992 if (!stopped()) {
1993 eq_region->init_req(2, control());
1994 eq_io_phi->init_req(2, i_o());
1995 eq_mem_phi->init_req(2, reset_memory());
1996 }
1997 }
1998 set_control(is_not_equal);
1999 }
2000 ne_region->init_req(5, control());
2001 ne_io_phi->init_req(5, i_o());
2002 ne_mem_phi->init_req(5, reset_memory());
2003
2004 record_for_igvn(ne_region);
2005 set_control(_gvn.transform(ne_region));
2006 set_i_o(_gvn.transform(ne_io_phi));
2007 set_all_memory(_gvn.transform(ne_mem_phi));
2008
2009 if (btest == BoolTest::ne) {
2010 {
2011 PreserveJVMState pjvms(this);
2012 int target_bci = iter().get_dest();
2013 merge(target_bci);
2014 }
2015
2016 record_for_igvn(eq_region);
2017 set_control(_gvn.transform(eq_region));
2018 set_i_o(_gvn.transform(eq_io_phi));
2019 set_all_memory(_gvn.transform(eq_mem_phi));
2020 }
2021
2022 return;
2023 }
2024 // In the case were both operands might be value types, we need to
2025 // use the new acmp implementation. Otherwise, i.e. if one operand
2026 // is not a value type, we can use the old acmp implementation.
2027 Node* cmp = C->optimize_acmp(&_gvn, a, b);
2028 if (cmp != NULL) {
2029 // Use optimized/old acmp
2030 cmp = optimize_cmp_with_klass(_gvn.transform(cmp));
2031 do_if(btest, cmp);
2032 return;
2033 }
2034
2035 Node* ctrl = NULL;
2036 bool safe_for_replace = true;
2037 if (ACmpOnValues != 1) {
2038 // Emit old acmp before new acmp for quick a != b check
2039 cmp = CmpP(a, b);
2040 cmp = optimize_cmp_with_klass(_gvn.transform(cmp));
2041 if (btest == BoolTest::ne) {
2042 do_if(btest, cmp, true);
2043 if (stopped()) {
2044 return; // Never equal
2045 }
2046 } else if (btest == BoolTest::eq) {
2047 Node* is_equal = NULL;
2048 {
2049 PreserveJVMState pjvms(this);
2050 do_if(btest, cmp, false, &is_equal);
2051 if (!stopped()) {
2052 // Not equal, skip valuetype check
2053 ctrl = new RegionNode(3);
2054 ctrl->init_req(1, control());
2055 _gvn.set_type(ctrl, Type::CONTROL);
2056 record_for_igvn(ctrl);
2057 safe_for_replace = false;
2077 speculate = true;
2078 } else if (!_gvn.type(b)->speculative_maybe_null()) {
2079 speculate = true;
2080 swap(a, b);
2081 }
2082 }
2083 inc_sp(2);
2084 Node* null_ctl = top();
2085 Node* not_null_a = null_check_oop(a, &null_ctl, speculate, safe_for_replace, speculate);
2086 assert(!stopped(), "operand is always null");
2087 dec_sp(2);
2088 Node* region = new RegionNode(2);
2089 Node* is_value = new PhiNode(region, TypeX_X);
2090 if (null_ctl != top()) {
2091 assert(!speculate, "should never be null");
2092 region->add_req(null_ctl);
2093 is_value->add_req(_gvn.MakeConX(0));
2094 }
2095
2096 Node* value_mask = _gvn.MakeConX(markOopDesc::always_locked_pattern);
2097 if (ACmpOnValues == 1) {
2098 Node* mark_addr = basic_plus_adr(not_null_a, oopDesc::mark_offset_in_bytes());
2099 Node* mark = make_load(NULL, mark_addr, TypeX_X, TypeX_X->basic_type(), MemNode::unordered);
2100 Node* not_mark = _gvn.transform(new XorXNode(mark, _gvn.MakeConX(-1)));
2101 Node* andn = _gvn.transform(new AndXNode(not_mark, value_mask));
2102 Node* neg_if_value = _gvn.transform(new SubXNode(andn, _gvn.MakeConX(1)));
2103 is_value->init_req(1, _gvn.transform(new RShiftXNode(neg_if_value, _gvn.intcon(63))));
2104 } else {
2105 is_value->init_req(1, is_always_locked(not_null_a));
2106 }
2107 region->init_req(1, control());
2108
2109 set_control(_gvn.transform(region));
2110 is_value = _gvn.transform(is_value);
2111
2112 if (ACmpOnValues == 1) {
2113 // Perturbe oop if operand is a value type to make comparison fail
2114 Node* pert = _gvn.transform(new AddPNode(a, a, is_value));
2115 cmp = _gvn.transform(new CmpPNode(pert, b));
2116 } else {
2117 // Check for a value type because we already know that operands are equal
2118 cmp = _gvn.transform(new CmpXNode(is_value, value_mask));
2119 btest = (btest == BoolTest::eq) ? BoolTest::ne : BoolTest::eq;
2120 }
2121 cmp = optimize_cmp_with_klass(cmp);
2122 do_if(btest, cmp);
2123
2124 if (ctrl != NULL) {
2125 ctrl->init_req(2, control());
2126 set_control(_gvn.transform(ctrl));
2127 }
2128 }
2129
2130 bool Parse::path_is_suitable_for_uncommon_trap(float prob) const {
2131 // Don't want to speculate on uncommon traps when running with -Xcomp
2132 if (!UseInterpreter) {
|