< prev index next >

src/hotspot/share/opto/parse2.cpp

Print this page




1908     }
1909   } else {
1910     // Update method data
1911     profile_not_taken_branch();
1912     adjust_map_after_if(untaken_btest, c, untaken_prob, next_block);
1913   }
1914 }
1915 
1916 void Parse::do_acmp(BoolTest::mask btest, Node* a, Node* b) {
1917   ciMethod* subst_method = ciEnv::current()->ValueBootstrapMethods_klass()->find_method(ciSymbol::isSubstitutable_name(), ciSymbol::object_object_boolean_signature());
1918   // If current method is ValueBootstrapMethods::isSubstitutable(),
1919   // compile the acmp as a regular pointer comparison otherwise we
1920   // could call ValueBootstrapMethods::isSubstitutable() back
1921   if (!EnableValhalla || (method() == subst_method)) {
1922     Node* cmp = CmpP(a, b);
1923     cmp = optimize_cmp_with_klass(cmp);
1924     do_if(btest, cmp);
1925     return;
1926   }
1927 
1928   // Substitutability test
1929   if (a->is_ValueType()) {
1930     inc_sp(2);
1931     a = a->as_ValueType()->allocate(this, true)->get_oop();
1932     dec_sp(2);
1933   }
1934   if (b->is_ValueType()) {
1935     inc_sp(2);
1936     b = b->as_ValueType()->allocate(this, true)->get_oop();
1937     dec_sp(2);
1938   }
1939 

1940   const TypeOopPtr* ta = _gvn.type(a)->isa_oopptr();
1941   const TypeOopPtr* tb = _gvn.type(b)->isa_oopptr();
1942 
1943   if (ta == NULL || !ta->can_be_value_type_raw() ||
1944       tb == NULL || !tb->can_be_value_type_raw()) {
1945     Node* cmp = CmpP(a, b);
1946     cmp = optimize_cmp_with_klass(cmp);



1947     do_if(btest, cmp);
1948     return;
1949   }
1950 
1951   Node* cmp = CmpP(a, b);
1952   cmp = optimize_cmp_with_klass(cmp);
1953   Node* eq_region = NULL;
1954   if (btest == BoolTest::eq) {
1955     do_if(btest, cmp, true);
1956     if (stopped()) {
1957       return;
1958     }
1959   } else {
1960     assert(btest == BoolTest::ne, "only eq or ne");
1961     Node* is_not_equal = NULL;
1962     eq_region = new RegionNode(3);
1963     {
1964       PreserveJVMState pjvms(this);
1965       do_if(btest, cmp, false, &is_not_equal);
1966       if (!stopped()) {
1967         eq_region->init_req(1, control());
1968       }
1969     }
1970     if (is_not_equal == NULL || is_not_equal->is_top()) {
1971       record_for_igvn(eq_region);
1972       set_control(_gvn.transform(eq_region));
1973       return;
1974     }
1975     set_control(is_not_equal);
1976   }
1977   // Pointers not equal, check for values

1978   Node* ne_region = new RegionNode(6);
1979   inc_sp(2);
1980   Node* null_ctl = top();
1981   Node* not_null_a = null_check_oop(a, &null_ctl, !too_many_traps(Deoptimization::Reason_null_check), false, false);
1982   dec_sp(2);
1983   ne_region->init_req(1, null_ctl);
1984   if (stopped()) {
1985     record_for_igvn(ne_region);
1986     set_control(_gvn.transform(ne_region));
1987     if (btest == BoolTest::ne) {
1988       {
1989         PreserveJVMState pjvms(this);
1990         int target_bci = iter().get_dest();
1991         merge(target_bci);
1992       }
1993       record_for_igvn(eq_region);
1994       set_control(_gvn.transform(eq_region));
1995     }
1996     return;
1997   }
1998 

1999   Node* is_value = is_always_locked(not_null_a);
2000   Node* value_mask = _gvn.MakeConX(markWord::always_locked_pattern);
2001   Node* is_value_cmp = _gvn.transform(new CmpXNode(is_value, value_mask));
2002   Node* is_value_bol = _gvn.transform(new BoolNode(is_value_cmp, BoolTest::ne));
2003   IfNode* is_value_iff = create_and_map_if(control(), is_value_bol, PROB_FAIR, COUNT_UNKNOWN);
2004   Node* not_value = _gvn.transform(new IfTrueNode(is_value_iff));
2005   set_control(_gvn.transform(new IfFalseNode(is_value_iff)));
2006   ne_region->init_req(2, not_value);

2007 
2008   // One of the 2 pointers refers to a value, check if both are of
2009   // the same class
2010   inc_sp(2);
2011   null_ctl = top();
2012   Node* not_null_b = null_check_oop(b, &null_ctl, !too_many_traps(Deoptimization::Reason_null_check), false, false);
2013   dec_sp(2);
2014   ne_region->init_req(3, null_ctl);
2015   if (stopped()) {
2016     record_for_igvn(ne_region);
2017     set_control(_gvn.transform(ne_region));
2018     if (btest == BoolTest::ne) {
2019       {
2020         PreserveJVMState pjvms(this);
2021         int target_bci = iter().get_dest();
2022         merge(target_bci);
2023       }
2024       record_for_igvn(eq_region);
2025       set_control(_gvn.transform(eq_region));
2026     }
2027     return;
2028   }
2029   Node* kls_a = load_object_klass(not_null_a);
2030   Node* kls_b = load_object_klass(not_null_b);



2031   Node* kls_cmp = CmpP(kls_a, kls_b);
2032   Node* kls_bol = _gvn.transform(new BoolNode(kls_cmp, BoolTest::ne));
2033   IfNode* kls_iff = create_and_map_if(control(), kls_bol, PROB_FAIR, COUNT_UNKNOWN);
2034   Node* kls_ne = _gvn.transform(new IfTrueNode(kls_iff));
2035   set_control(_gvn.transform(new IfFalseNode(kls_iff)));
2036   ne_region->init_req(4, kls_ne);
2037 
2038   if (stopped()) {
2039     record_for_igvn(ne_region);
2040     set_control(_gvn.transform(ne_region));
2041     if (btest == BoolTest::ne) {
2042       {
2043         PreserveJVMState pjvms(this);
2044         int target_bci = iter().get_dest();
2045         merge(target_bci);
2046       }
2047       record_for_igvn(eq_region);
2048       set_control(_gvn.transform(eq_region));
2049     }
2050     return;
2051   }
2052   // Both are values of the same class, we need to perform a
2053   // substitutability test. Delegate to
2054   // ValueBootstrapMethods::isSubstitutable().
2055 


2056   Node* ne_io_phi = PhiNode::make(ne_region, i_o());
2057   Node* mem = reset_memory();
2058   Node* ne_mem_phi = PhiNode::make(ne_region, mem);
2059 
2060   Node* eq_io_phi = NULL;
2061   Node* eq_mem_phi = NULL;
2062   if (eq_region != NULL) {
2063     eq_io_phi = PhiNode::make(eq_region, i_o());
2064     eq_mem_phi = PhiNode::make(eq_region, mem);
2065   }
2066 
2067   set_all_memory(mem);
2068 
2069   kill_dead_locals();
2070   CallStaticJavaNode *call = new CallStaticJavaNode(C, TypeFunc::make(subst_method), SharedRuntime::get_resolve_static_call_stub(), subst_method, bci());
2071   call->set_override_symbolic_info(true);
2072   call->init_req(TypeFunc::Parms, not_null_a);
2073   call->init_req(TypeFunc::Parms+1, not_null_b);
2074   inc_sp(2);
2075   set_edges_for_java_call(call, false, false);




1908     }
1909   } else {
1910     // Update method data
1911     profile_not_taken_branch();
1912     adjust_map_after_if(untaken_btest, c, untaken_prob, next_block);
1913   }
1914 }
1915 
1916 void Parse::do_acmp(BoolTest::mask btest, Node* a, Node* b) {
1917   ciMethod* subst_method = ciEnv::current()->ValueBootstrapMethods_klass()->find_method(ciSymbol::isSubstitutable_name(), ciSymbol::object_object_boolean_signature());
1918   // If current method is ValueBootstrapMethods::isSubstitutable(),
1919   // compile the acmp as a regular pointer comparison otherwise we
1920   // could call ValueBootstrapMethods::isSubstitutable() back
1921   if (!EnableValhalla || (method() == subst_method)) {
1922     Node* cmp = CmpP(a, b);
1923     cmp = optimize_cmp_with_klass(cmp);
1924     do_if(btest, cmp);
1925     return;
1926   }
1927 
1928   // Allocate value type operands
1929   if (a->is_ValueType()) {
1930     inc_sp(2);
1931     a = a->as_ValueType()->allocate(this, true)->get_oop();
1932     dec_sp(2);
1933   }
1934   if (b->is_ValueType()) {
1935     inc_sp(2);
1936     b = b->as_ValueType()->allocate(this, true)->get_oop();
1937     dec_sp(2);
1938   }
1939 
1940   // First, do a normal pointer comparison
1941   const TypeOopPtr* ta = _gvn.type(a)->isa_oopptr();
1942   const TypeOopPtr* tb = _gvn.type(b)->isa_oopptr();



1943   Node* cmp = CmpP(a, b);
1944   cmp = optimize_cmp_with_klass(cmp);
1945   if (ta == NULL || !ta->can_be_value_type_raw() ||
1946       tb == NULL || !tb->can_be_value_type_raw()) {
1947     // This is sufficient, if one of the operands can't be a value type
1948     do_if(btest, cmp);
1949     return;
1950   }



1951   Node* eq_region = NULL;
1952   if (btest == BoolTest::eq) {
1953     do_if(btest, cmp, true);
1954     if (stopped()) {
1955       return;
1956     }
1957   } else {
1958     assert(btest == BoolTest::ne, "only eq or ne");
1959     Node* is_not_equal = NULL;
1960     eq_region = new RegionNode(3);
1961     {
1962       PreserveJVMState pjvms(this);
1963       do_if(btest, cmp, false, &is_not_equal);
1964       if (!stopped()) {
1965         eq_region->init_req(1, control());
1966       }
1967     }
1968     if (is_not_equal == NULL || is_not_equal->is_top()) {
1969       record_for_igvn(eq_region);
1970       set_control(_gvn.transform(eq_region));
1971       return;
1972     }
1973     set_control(is_not_equal);
1974   }
1975 
1976   // Pointers are not equal, check if first operand is non-null
1977   Node* ne_region = new RegionNode(6);
1978   inc_sp(2);
1979   Node* null_ctl = top();
1980   Node* not_null_a = null_check_oop(a, &null_ctl, !too_many_traps(Deoptimization::Reason_null_check), false, false);
1981   dec_sp(2);
1982   ne_region->init_req(1, null_ctl);
1983   if (stopped()) {
1984     record_for_igvn(ne_region);
1985     set_control(_gvn.transform(ne_region));
1986     if (btest == BoolTest::ne) {
1987       {
1988         PreserveJVMState pjvms(this);
1989         int target_bci = iter().get_dest();
1990         merge(target_bci);
1991       }
1992       record_for_igvn(eq_region);
1993       set_control(_gvn.transform(eq_region));
1994     }
1995     return;
1996   }
1997 
1998   // First operand is non-null, check if it is a value type
1999   Node* is_value = is_always_locked(not_null_a);
2000   IfNode* is_value_iff = create_and_map_if(control(), is_value, PROB_FAIR, COUNT_UNKNOWN);
2001   Node* not_value = _gvn.transform(new IfFalseNode(is_value_iff));




2002   ne_region->init_req(2, not_value);
2003   set_control(_gvn.transform(new IfTrueNode(is_value_iff)));
2004 
2005   // The first operand is a value type, check if the second operand is non-null

2006   inc_sp(2);
2007   null_ctl = top();
2008   Node* not_null_b = null_check_oop(b, &null_ctl, !too_many_traps(Deoptimization::Reason_null_check), false, false);
2009   dec_sp(2);
2010   ne_region->init_req(3, null_ctl);
2011   if (stopped()) {
2012     record_for_igvn(ne_region);
2013     set_control(_gvn.transform(ne_region));
2014     if (btest == BoolTest::ne) {
2015       {
2016         PreserveJVMState pjvms(this);
2017         int target_bci = iter().get_dest();
2018         merge(target_bci);
2019       }
2020       record_for_igvn(eq_region);
2021       set_control(_gvn.transform(eq_region));
2022     }
2023     return;
2024   }
2025 
2026   // Check if both operands are of the same class. We don't need to clear the array property
2027   // bits in the klass pointer for the cmp because we know that the first operand is a value type.
2028   Node* kls_a = load_object_klass(not_null_a, /* clear_prop_bits = */ false);
2029   Node* kls_b = load_object_klass(not_null_b, /* clear_prop_bits = */ false);
2030   Node* kls_cmp = CmpP(kls_a, kls_b);
2031   Node* kls_bol = _gvn.transform(new BoolNode(kls_cmp, BoolTest::ne));
2032   IfNode* kls_iff = create_and_map_if(control(), kls_bol, PROB_FAIR, COUNT_UNKNOWN);
2033   Node* kls_ne = _gvn.transform(new IfTrueNode(kls_iff));
2034   set_control(_gvn.transform(new IfFalseNode(kls_iff)));
2035   ne_region->init_req(4, kls_ne);
2036 
2037   if (stopped()) {
2038     record_for_igvn(ne_region);
2039     set_control(_gvn.transform(ne_region));
2040     if (btest == BoolTest::ne) {
2041       {
2042         PreserveJVMState pjvms(this);
2043         int target_bci = iter().get_dest();
2044         merge(target_bci);
2045       }
2046       record_for_igvn(eq_region);
2047       set_control(_gvn.transform(eq_region));
2048     }
2049     return;
2050   }



2051 
2052   // Both operands are values types of the same class, we need to perform a
2053   // substitutability test. Delegate to ValueBootstrapMethods::isSubstitutable().
2054   Node* ne_io_phi = PhiNode::make(ne_region, i_o());
2055   Node* mem = reset_memory();
2056   Node* ne_mem_phi = PhiNode::make(ne_region, mem);
2057 
2058   Node* eq_io_phi = NULL;
2059   Node* eq_mem_phi = NULL;
2060   if (eq_region != NULL) {
2061     eq_io_phi = PhiNode::make(eq_region, i_o());
2062     eq_mem_phi = PhiNode::make(eq_region, mem);
2063   }
2064 
2065   set_all_memory(mem);
2066 
2067   kill_dead_locals();
2068   CallStaticJavaNode *call = new CallStaticJavaNode(C, TypeFunc::make(subst_method), SharedRuntime::get_resolve_static_call_stub(), subst_method, bci());
2069   call->set_override_symbolic_info(true);
2070   call->init_req(TypeFunc::Parms, not_null_a);
2071   call->init_req(TypeFunc::Parms+1, not_null_b);
2072   inc_sp(2);
2073   set_edges_for_java_call(call, false, false);


< prev index next >