1861 set_control(untaken_branch);
1862
1863 // Branch not taken.
1864 if (stopped() && ctrl_taken == NULL) {
1865 if (C->eliminate_boxing()) {
1866 // Mark the successor block as parsed (if caller does not re-wire control flow)
1867 next_block->next_path_num();
1868 }
1869 } else {
1870 // Update method data
1871 profile_not_taken_branch();
1872 adjust_map_after_if(untaken_btest, c, untaken_prob, next_block);
1873 }
1874 }
1875
1876 void Parse::do_acmp(BoolTest::mask btest, Node* a, Node* b) {
1877 ciMethod* subst_method = ciEnv::current()->ValueBootstrapMethods_klass()->find_method(ciSymbol::isSubstitutable_name(), ciSymbol::object_object_boolean_signature());
1878 // If current method is ValueBootstrapMethods::isSubstitutable(),
1879 // compile the acmp as a regular pointer comparison otherwise we
1880 // could call ValueBootstrapMethods::isSubstitutable() back
1881 if (ACmpOnValues == 0 || method() == subst_method) {
1882 Node* cmp = CmpP(a, b);
1883 cmp = optimize_cmp_with_klass(cmp);
1884 do_if(btest, cmp);
1885 return;
1886 }
1887
1888 if (ACmpOnValues == 3) {
1889 // Substitutability test
1890 if (a->is_ValueType()) {
1891 inc_sp(2);
1892 a = a->as_ValueType()->allocate(this, true)->get_oop();
1893 dec_sp(2);
1894 }
1895 if (b->is_ValueType()) {
1896 inc_sp(2);
1897 b = b->as_ValueType()->allocate(this, true)->get_oop();
1898 dec_sp(2);
1899 }
1900
1901 const TypeOopPtr* ta = _gvn.type(a)->isa_oopptr();
1902 const TypeOopPtr* tb = _gvn.type(b)->isa_oopptr();
1903
1904 if (ta == NULL || !ta->can_be_value_type_raw() ||
1905 tb == NULL || !tb->can_be_value_type_raw()) {
1906 Node* cmp = CmpP(a, b);
1907 cmp = optimize_cmp_with_klass(cmp);
1908 do_if(btest, cmp);
2059 ne_region->init_req(5, ctl);
2060 ne_io_phi->init_req(5, i_o());
2061 ne_mem_phi->init_req(5, reset_memory());
2062
2063 record_for_igvn(ne_region);
2064 set_control(_gvn.transform(ne_region));
2065 set_i_o(_gvn.transform(ne_io_phi));
2066 set_all_memory(_gvn.transform(ne_mem_phi));
2067
2068 if (btest == BoolTest::ne) {
2069 {
2070 PreserveJVMState pjvms(this);
2071 int target_bci = iter().get_dest();
2072 merge(target_bci);
2073 }
2074
2075 record_for_igvn(eq_region);
2076 set_control(_gvn.transform(eq_region));
2077 set_i_o(_gvn.transform(eq_io_phi));
2078 set_all_memory(_gvn.transform(eq_mem_phi));
2079 }
2080
2081 return;
2082 }
2083 // In the case were both operands might be value types, we need to
2084 // use the new acmp implementation. Otherwise, i.e. if one operand
2085 // is not a value type, we can use the old acmp implementation.
2086 Node* cmp = C->optimize_acmp(&_gvn, a, b);
2087 if (cmp != NULL) {
2088 // Use optimized/old acmp
2089 cmp = optimize_cmp_with_klass(_gvn.transform(cmp));
2090 do_if(btest, cmp);
2091 return;
2092 }
2093
2094 Node* ctrl = NULL;
2095 bool safe_for_replace = true;
2096 if (ACmpOnValues != 1) {
2097 // Emit old acmp before new acmp for quick a != b check
2098 cmp = CmpP(a, b);
2099 cmp = optimize_cmp_with_klass(_gvn.transform(cmp));
2100 if (btest == BoolTest::ne) {
2101 do_if(btest, cmp, true);
2102 if (stopped()) {
2103 return; // Never equal
2104 }
2105 } else if (btest == BoolTest::eq) {
2106 Node* is_equal = NULL;
2107 {
2108 PreserveJVMState pjvms(this);
2109 do_if(btest, cmp, false, &is_equal);
2110 if (!stopped()) {
2111 // Not equal, skip valuetype check
2112 ctrl = new RegionNode(3);
2113 ctrl->init_req(1, control());
2114 _gvn.set_type(ctrl, Type::CONTROL);
2115 record_for_igvn(ctrl);
2116 safe_for_replace = false;
2117 }
2118 }
2119 if (is_equal == NULL) {
2120 assert(ctrl != NULL, "no control left");
2121 set_control(_gvn.transform(ctrl));
2122 return; // Never equal
2123 }
2124 set_control(is_equal);
2125 }
2126 }
2127
2128 // Null check operand before loading the is_value bit
2129 bool speculate = false;
2130 if (!TypePtr::NULL_PTR->higher_equal(_gvn.type(b))) {
2131 // Operand 'b' is never null, swap operands to avoid null check
2132 swap(a, b);
2133 } else if (!too_many_traps(Deoptimization::Reason_speculate_null_check)) {
2134 // Speculate on non-nullness of one operand
2135 if (!_gvn.type(a)->speculative_maybe_null()) {
2136 speculate = true;
2137 } else if (!_gvn.type(b)->speculative_maybe_null()) {
2138 speculate = true;
2139 swap(a, b);
2140 }
2141 }
2142 inc_sp(2);
2143 Node* null_ctl = top();
2144 Node* not_null_a = null_check_oop(a, &null_ctl, speculate, safe_for_replace, speculate);
2145 assert(!stopped(), "operand is always null");
2146 dec_sp(2);
2147 Node* region = new RegionNode(2);
2148 Node* is_value = new PhiNode(region, TypeX_X);
2149 if (null_ctl != top()) {
2150 assert(!speculate, "should never be null");
2151 region->add_req(null_ctl);
2152 is_value->add_req(_gvn.MakeConX(0));
2153 }
2154
2155 Node* value_mask = _gvn.MakeConX(markOopDesc::always_locked_pattern);
2156 if (ACmpOnValues == 1) {
2157 Node* mark_addr = basic_plus_adr(not_null_a, oopDesc::mark_offset_in_bytes());
2158 Node* mark = make_load(NULL, mark_addr, TypeX_X, TypeX_X->basic_type(), MemNode::unordered);
2159 Node* not_mark = _gvn.transform(new XorXNode(mark, _gvn.MakeConX(-1)));
2160 Node* andn = _gvn.transform(new AndXNode(not_mark, value_mask));
2161 Node* neg_if_value = _gvn.transform(new SubXNode(andn, _gvn.MakeConX(1)));
2162 is_value->init_req(1, _gvn.transform(new RShiftXNode(neg_if_value, _gvn.intcon(63))));
2163 } else {
2164 is_value->init_req(1, is_always_locked(not_null_a));
2165 }
2166 region->init_req(1, control());
2167
2168 set_control(_gvn.transform(region));
2169 is_value = _gvn.transform(is_value);
2170
2171 if (ACmpOnValues == 1) {
2172 // Perturbe oop if operand is a value type to make comparison fail
2173 Node* pert = _gvn.transform(new AddPNode(a, a, is_value));
2174 cmp = _gvn.transform(new CmpPNode(pert, b));
2175 } else {
2176 // Check for a value type because we already know that operands are equal
2177 cmp = _gvn.transform(new CmpXNode(is_value, value_mask));
2178 btest = (btest == BoolTest::eq) ? BoolTest::ne : BoolTest::eq;
2179 }
2180 cmp = optimize_cmp_with_klass(cmp);
2181 do_if(btest, cmp);
2182
2183 if (ctrl != NULL) {
2184 ctrl->init_req(2, control());
2185 set_control(_gvn.transform(ctrl));
2186 }
2187 }
2188
2189 bool Parse::path_is_suitable_for_uncommon_trap(float prob) const {
2190 // Don't want to speculate on uncommon traps when running with -Xcomp
2191 if (!UseInterpreter) {
2192 return false;
2193 }
2194 return (seems_never_taken(prob) && seems_stable_comparison());
2195 }
2196
2197 void Parse::maybe_add_predicate_after_if(Block* path) {
2198 if (path->is_SEL_head() && path->preds_parsed() == 0) {
2199 // Add predicates at bci of if dominating the loop so traps can be
2200 // recorded on the if's profile data
2201 int bc_depth = repush_if_args();
2202 add_predicate();
2203 dec_sp(bc_depth);
2204 path->set_has_predicates();
2205 }
|
1861 set_control(untaken_branch);
1862
1863 // Branch not taken.
1864 if (stopped() && ctrl_taken == NULL) {
1865 if (C->eliminate_boxing()) {
1866 // Mark the successor block as parsed (if caller does not re-wire control flow)
1867 next_block->next_path_num();
1868 }
1869 } else {
1870 // Update method data
1871 profile_not_taken_branch();
1872 adjust_map_after_if(untaken_btest, c, untaken_prob, next_block);
1873 }
1874 }
1875
1876 void Parse::do_acmp(BoolTest::mask btest, Node* a, Node* b) {
1877 ciMethod* subst_method = ciEnv::current()->ValueBootstrapMethods_klass()->find_method(ciSymbol::isSubstitutable_name(), ciSymbol::object_object_boolean_signature());
1878 // If current method is ValueBootstrapMethods::isSubstitutable(),
1879 // compile the acmp as a regular pointer comparison otherwise we
1880 // could call ValueBootstrapMethods::isSubstitutable() back
1881 if (!EnableValhalla || (method() == subst_method)) {
1882 Node* cmp = CmpP(a, b);
1883 cmp = optimize_cmp_with_klass(cmp);
1884 do_if(btest, cmp);
1885 return;
1886 }
1887
1888 // Substitutability test
1889 if (a->is_ValueType()) {
1890 inc_sp(2);
1891 a = a->as_ValueType()->allocate(this, true)->get_oop();
1892 dec_sp(2);
1893 }
1894 if (b->is_ValueType()) {
1895 inc_sp(2);
1896 b = b->as_ValueType()->allocate(this, true)->get_oop();
1897 dec_sp(2);
1898 }
1899
1900 const TypeOopPtr* ta = _gvn.type(a)->isa_oopptr();
1901 const TypeOopPtr* tb = _gvn.type(b)->isa_oopptr();
1902
1903 if (ta == NULL || !ta->can_be_value_type_raw() ||
1904 tb == NULL || !tb->can_be_value_type_raw()) {
1905 Node* cmp = CmpP(a, b);
1906 cmp = optimize_cmp_with_klass(cmp);
1907 do_if(btest, cmp);
2058 ne_region->init_req(5, ctl);
2059 ne_io_phi->init_req(5, i_o());
2060 ne_mem_phi->init_req(5, reset_memory());
2061
2062 record_for_igvn(ne_region);
2063 set_control(_gvn.transform(ne_region));
2064 set_i_o(_gvn.transform(ne_io_phi));
2065 set_all_memory(_gvn.transform(ne_mem_phi));
2066
2067 if (btest == BoolTest::ne) {
2068 {
2069 PreserveJVMState pjvms(this);
2070 int target_bci = iter().get_dest();
2071 merge(target_bci);
2072 }
2073
2074 record_for_igvn(eq_region);
2075 set_control(_gvn.transform(eq_region));
2076 set_i_o(_gvn.transform(eq_io_phi));
2077 set_all_memory(_gvn.transform(eq_mem_phi));
2078 }
2079 }
2080
2081 bool Parse::path_is_suitable_for_uncommon_trap(float prob) const {
2082 // Don't want to speculate on uncommon traps when running with -Xcomp
2083 if (!UseInterpreter) {
2084 return false;
2085 }
2086 return (seems_never_taken(prob) && seems_stable_comparison());
2087 }
2088
2089 void Parse::maybe_add_predicate_after_if(Block* path) {
2090 if (path->is_SEL_head() && path->preds_parsed() == 0) {
2091 // Add predicates at bci of if dominating the loop so traps can be
2092 // recorded on the if's profile data
2093 int bc_depth = repush_if_args();
2094 add_predicate();
2095 dec_sp(bc_depth);
2096 path->set_has_predicates();
2097 }
|