src/share/vm/c1/c1_GraphBuilder.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/c1

src/share/vm/c1/c1_GraphBuilder.cpp

Print this page




1900         receiver_klass->is_loaded() && code != Bytecodes::_invokespecial) {
1901       // If we have the exact receiver type we can bind directly to
1902       // the method to call.
1903       exact_target = target->resolve_invoke(calling_klass, receiver_klass);
1904       if (exact_target != NULL) {
1905         target = exact_target;
1906         code = Bytecodes::_invokespecial;
1907       }
1908     }
1909     if (receiver_klass != NULL &&
1910         receiver_klass->is_subtype_of(actual_recv) &&
1911         actual_recv->is_initialized()) {
1912       actual_recv = receiver_klass;
1913     }
1914 
1915     if ((code == Bytecodes::_invokevirtual && callee_holder->is_initialized()) ||
1916         (code == Bytecodes::_invokeinterface && callee_holder->is_initialized() && !actual_recv->is_interface())) {
1917       // Use CHA on the receiver to select a more precise method.
1918       cha_monomorphic_target = target->find_monomorphic_target(calling_klass, callee_holder, actual_recv);
1919     } else if (code == Bytecodes::_invokeinterface && callee_holder->is_loaded() && receiver != NULL) {
1920       // if there is only one implementor of this interface then we

1921       // may be able bind this invoke directly to the implementing
1922       // klass but we need both a dependence on the single interface
1923       // and on the method we bind to.  Additionally since all we know
1924       // about the receiver type is the it's supposed to implement the
1925       // interface we have to insert a check that it's the class we
1926       // expect.  Interface types are not checked by the verifier so
1927       // they are roughly equivalent to Object.
1928       ciInstanceKlass* singleton = NULL;
1929       if (target->holder()->nof_implementors() == 1) {
1930         singleton = target->holder()->implementor();
1931         assert(singleton != NULL && singleton != target->holder(),
1932                "just checking");
1933 
1934         assert(holder->is_interface(), "invokeinterface to non interface?");
1935         ciInstanceKlass* decl_interface = (ciInstanceKlass*)holder;
1936         // the number of implementors for decl_interface is less or
1937         // equal to the number of implementors for target->holder() so
1938         // if number of implementors of target->holder() == 1 then
1939         // number of implementors for decl_interface is 0 or 1. If
1940         // it's 0 then no class implements decl_interface and there's
1941         // no point in inlining.
1942         if (!holder->is_loaded() || decl_interface->nof_implementors() != 1 || decl_interface->has_nonstatic_concrete_methods()) {
1943           singleton = NULL;
1944         }
1945       }
1946       if (singleton) {
1947         cha_monomorphic_target = target->find_monomorphic_target(calling_klass, target->holder(), singleton);

1948         if (cha_monomorphic_target != NULL) {
1949           // If CHA is able to bind this invoke then update the class
1950           // to match that class, otherwise klass will refer to the
1951           // interface.
1952           klass = cha_monomorphic_target->holder();
1953           actual_recv = target->holder();
1954 
1955           // insert a check it's really the expected class.
1956           CheckCast* c = new CheckCast(klass, receiver, copy_state_for_exception());
1957           c->set_incompatible_class_change_check();
1958           c->set_direct_compare(klass->is_final());
1959           // pass the result of the checkcast so that the compiler has
1960           // more accurate type info in the inlinee
1961           better_receiver = append_split(c);
1962         }
1963       }
1964     }
1965   }
1966 
1967   if (cha_monomorphic_target != NULL) {
1968     if (cha_monomorphic_target->is_abstract()) {
1969       // Do not optimize for abstract methods
1970       cha_monomorphic_target = NULL;
1971     }
1972   }
1973 
1974   if (cha_monomorphic_target != NULL) {
1975     if (!(target->is_final_method())) {
1976       // If we inlined because CHA revealed only a single target method,
1977       // then we are dependent on that target method not getting overridden
1978       // by dynamic class loading.  Be sure to test the "static" receiver
1979       // dest_method here, as opposed to the actual receiver, which may
1980       // falsely lead us to believe that the receiver is final or private.
1981       dependency_recorder()->assert_unique_concrete_method(actual_recv, cha_monomorphic_target);
1982     }
1983     code = Bytecodes::_invokespecial;
1984   }
1985 
1986   // check if we could do inlining
1987   if (!PatchALot && Inline && target->is_loaded() &&
1988       (klass->is_initialized() || klass->is_interface() && target->holder()->is_initialized())
1989       && !patch_for_appendix) {
1990     // callee is known => check if we have static binding
1991     if (code == Bytecodes::_invokestatic  ||
1992         code == Bytecodes::_invokespecial ||
1993         code == Bytecodes::_invokevirtual && target->is_final_method() ||
1994         code == Bytecodes::_invokedynamic) {




1900         receiver_klass->is_loaded() && code != Bytecodes::_invokespecial) {
1901       // If we have the exact receiver type we can bind directly to
1902       // the method to call.
1903       exact_target = target->resolve_invoke(calling_klass, receiver_klass);
1904       if (exact_target != NULL) {
1905         target = exact_target;
1906         code = Bytecodes::_invokespecial;
1907       }
1908     }
1909     if (receiver_klass != NULL &&
1910         receiver_klass->is_subtype_of(actual_recv) &&
1911         actual_recv->is_initialized()) {
1912       actual_recv = receiver_klass;
1913     }
1914 
1915     if ((code == Bytecodes::_invokevirtual && callee_holder->is_initialized()) ||
1916         (code == Bytecodes::_invokeinterface && callee_holder->is_initialized() && !actual_recv->is_interface())) {
1917       // Use CHA on the receiver to select a more precise method.
1918       cha_monomorphic_target = target->find_monomorphic_target(calling_klass, callee_holder, actual_recv);
1919     } else if (code == Bytecodes::_invokeinterface && callee_holder->is_loaded() && receiver != NULL) {
1920       assert(callee_holder->is_interface(), "invokeinterface to non interface?");
1921       // If there is only one implementor of this interface then we
1922       // may be able bind this invoke directly to the implementing
1923       // klass but we need both a dependence on the single interface
1924       // and on the method we bind to.  Additionally since all we know
1925       // about the receiver type is the it's supposed to implement the
1926       // interface we have to insert a check that it's the class we
1927       // expect.  Interface types are not checked by the verifier so
1928       // they are roughly equivalent to Object.
1929       // The number of implementors for declared_interface is less or








1930       // equal to the number of implementors for target->holder() so
1931       // if number of implementors of target->holder() == 1 then
1932       // number of implementors for decl_interface is 0 or 1. If
1933       // it's 0 then no class implements decl_interface and there's
1934       // no point in inlining.
1935       ciInstanceKlass* singleton = NULL;
1936       ciInstanceKlass* declared_interface = callee_holder;
1937       if (declared_interface->nof_implementors() == 1 &&
1938           (!target->is_default_method() || target->is_overpass()) /* CHA doesn't support default methods yet. */) {
1939         singleton = declared_interface->implementor();
1940         assert(singleton != NULL && singleton != declared_interface, "");
1941         cha_monomorphic_target = target->find_monomorphic_target(calling_klass, declared_interface, singleton);
1942         if (cha_monomorphic_target != NULL) {
1943           // If CHA is able to bind this invoke then update the class
1944           // to match that class, otherwise klass will refer to the
1945           // interface.
1946           klass = cha_monomorphic_target->holder();
1947           actual_recv = declared_interface;
1948 
1949           // insert a check it's really the expected class.
1950           CheckCast* c = new CheckCast(klass, receiver, copy_state_for_exception());
1951           c->set_incompatible_class_change_check();
1952           c->set_direct_compare(klass->is_final());
1953           // pass the result of the checkcast so that the compiler has
1954           // more accurate type info in the inlinee
1955           better_receiver = append_split(c);
1956         }
1957       }
1958     }
1959   }
1960 
1961   if (cha_monomorphic_target != NULL) {
1962     assert(!cha_monomorphic_target->is_abstract(), "");






1963     if (!(target->is_final_method())) {
1964       // If we inlined because CHA revealed only a single target method,
1965       // then we are dependent on that target method not getting overridden
1966       // by dynamic class loading.  Be sure to test the "static" receiver
1967       // dest_method here, as opposed to the actual receiver, which may
1968       // falsely lead us to believe that the receiver is final or private.
1969       dependency_recorder()->assert_unique_concrete_method(actual_recv, cha_monomorphic_target);
1970     }
1971     code = Bytecodes::_invokespecial;
1972   }
1973 
1974   // check if we could do inlining
1975   if (!PatchALot && Inline && target->is_loaded() &&
1976       (klass->is_initialized() || klass->is_interface() && target->holder()->is_initialized())
1977       && !patch_for_appendix) {
1978     // callee is known => check if we have static binding
1979     if (code == Bytecodes::_invokestatic  ||
1980         code == Bytecodes::_invokespecial ||
1981         code == Bytecodes::_invokevirtual && target->is_final_method() ||
1982         code == Bytecodes::_invokedynamic) {


src/share/vm/c1/c1_GraphBuilder.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File