< prev index next >

src/hotspot/share/c1/c1_GraphBuilder.cpp

Print this page




1450     }
1451   }
1452 
1453   if (needs_check) {
1454     // Perform the registration of finalizable objects.
1455     ValueStack* state_before = copy_state_for_exception();
1456     load_local(objectType, 0);
1457     append_split(new Intrinsic(voidType, vmIntrinsics::_Object_init,
1458                                state()->pop_arguments(1),
1459                                true, state_before, true));
1460   }
1461 }
1462 
1463 
1464 void GraphBuilder::method_return(Value x, bool ignore_return) {
1465   if (RegisterFinalizersAtInit &&
1466       method()->intrinsic_id() == vmIntrinsics::_Object_init) {
1467     call_register_finalizer();
1468   }
1469 
1470   // The conditions for a memory barrier are described in Parse::do_exits().
1471   bool need_mem_bar = false;
1472   if (method()->name() == ciSymbol::object_initializer_name() &&
1473        (scope()->wrote_final() ||
1474          (AlwaysSafeConstructors && scope()->wrote_fields()) ||
1475          (support_IRIW_for_not_multiple_copy_atomic_cpu && scope()->wrote_volatile()))) {
1476     need_mem_bar = true;
1477   }
1478 
1479   BasicType bt = method()->return_type()->basic_type();
1480   switch (bt) {
1481     case T_BYTE:
1482     {
1483       Value shift = append(new Constant(new IntConstant(24)));
1484       x = append(new ShiftOp(Bytecodes::_ishl, x, shift));
1485       x = append(new ShiftOp(Bytecodes::_ishr, x, shift));
1486       break;
1487     }
1488     case T_SHORT:
1489     {
1490       Value shift = append(new Constant(new IntConstant(16)));
1491       x = append(new ShiftOp(Bytecodes::_ishl, x, shift));
1492       x = append(new ShiftOp(Bytecodes::_ishr, x, shift));
1493       break;
1494     }
1495     case T_CHAR:


1941     if ((code == Bytecodes::_invokevirtual && callee_holder->is_initialized()) ||
1942         (code == Bytecodes::_invokeinterface && callee_holder->is_initialized() && !actual_recv->is_interface())) {
1943       // Use CHA on the receiver to select a more precise method.
1944       cha_monomorphic_target = target->find_monomorphic_target(calling_klass, callee_holder, actual_recv);
1945     } else if (code == Bytecodes::_invokeinterface && callee_holder->is_loaded() && receiver != NULL) {
1946       assert(callee_holder->is_interface(), "invokeinterface to non interface?");
1947       // If there is only one implementor of this interface then we
1948       // may be able bind this invoke directly to the implementing
1949       // klass but we need both a dependence on the single interface
1950       // and on the method we bind to.  Additionally since all we know
1951       // about the receiver type is the it's supposed to implement the
1952       // interface we have to insert a check that it's the class we
1953       // expect.  Interface types are not checked by the verifier so
1954       // they are roughly equivalent to Object.
1955       // The number of implementors for declared_interface is less or
1956       // equal to the number of implementors for target->holder() so
1957       // if number of implementors of target->holder() == 1 then
1958       // number of implementors for decl_interface is 0 or 1. If
1959       // it's 0 then no class implements decl_interface and there's
1960       // no point in inlining.

1961       ciInstanceKlass* declared_interface = callee_holder;
1962       ciInstanceKlass* singleton = declared_interface->unique_implementor();
1963       if (singleton != NULL &&
1964           (!target->is_default_method() || target->is_overpass()) /* CHA doesn't support default methods yet. */ ) {
1965         assert(singleton != declared_interface, "not a unique implementor");
1966         cha_monomorphic_target = target->find_monomorphic_target(calling_klass, declared_interface, singleton);
1967         if (cha_monomorphic_target != NULL) {
1968           if (cha_monomorphic_target->holder() != compilation()->env()->Object_klass()) {
1969             // If CHA is able to bind this invoke then update the class
1970             // to match that class, otherwise klass will refer to the
1971             // interface.
1972             klass = cha_monomorphic_target->holder();
1973             actual_recv = declared_interface;
1974 
1975             // insert a check it's really the expected class.
1976             CheckCast* c = new CheckCast(klass, receiver, copy_state_for_exception());
1977             c->set_incompatible_class_change_check();
1978             c->set_direct_compare(klass->is_final());
1979             // pass the result of the checkcast so that the compiler has
1980             // more accurate type info in the inlinee
1981             better_receiver = append_split(c);
1982           } else {
1983             cha_monomorphic_target = NULL; // subtype check against Object is useless
1984           }
1985         }




1450     }
1451   }
1452 
1453   if (needs_check) {
1454     // Perform the registration of finalizable objects.
1455     ValueStack* state_before = copy_state_for_exception();
1456     load_local(objectType, 0);
1457     append_split(new Intrinsic(voidType, vmIntrinsics::_Object_init,
1458                                state()->pop_arguments(1),
1459                                true, state_before, true));
1460   }
1461 }
1462 
1463 
1464 void GraphBuilder::method_return(Value x, bool ignore_return) {
1465   if (RegisterFinalizersAtInit &&
1466       method()->intrinsic_id() == vmIntrinsics::_Object_init) {
1467     call_register_finalizer();
1468   }
1469 

1470   bool need_mem_bar = false;
1471   if (method()->name() == ciSymbol::object_initializer_name() &&
1472       (scope()->wrote_final() || (AlwaysSafeConstructors && scope()->wrote_fields())
1473                               || (support_IRIW_for_not_multiple_copy_atomic_cpu && scope()->wrote_volatile())
1474      )){
1475     need_mem_bar = true;
1476   }
1477 
1478   BasicType bt = method()->return_type()->basic_type();
1479   switch (bt) {
1480     case T_BYTE:
1481     {
1482       Value shift = append(new Constant(new IntConstant(24)));
1483       x = append(new ShiftOp(Bytecodes::_ishl, x, shift));
1484       x = append(new ShiftOp(Bytecodes::_ishr, x, shift));
1485       break;
1486     }
1487     case T_SHORT:
1488     {
1489       Value shift = append(new Constant(new IntConstant(16)));
1490       x = append(new ShiftOp(Bytecodes::_ishl, x, shift));
1491       x = append(new ShiftOp(Bytecodes::_ishr, x, shift));
1492       break;
1493     }
1494     case T_CHAR:


1940     if ((code == Bytecodes::_invokevirtual && callee_holder->is_initialized()) ||
1941         (code == Bytecodes::_invokeinterface && callee_holder->is_initialized() && !actual_recv->is_interface())) {
1942       // Use CHA on the receiver to select a more precise method.
1943       cha_monomorphic_target = target->find_monomorphic_target(calling_klass, callee_holder, actual_recv);
1944     } else if (code == Bytecodes::_invokeinterface && callee_holder->is_loaded() && receiver != NULL) {
1945       assert(callee_holder->is_interface(), "invokeinterface to non interface?");
1946       // If there is only one implementor of this interface then we
1947       // may be able bind this invoke directly to the implementing
1948       // klass but we need both a dependence on the single interface
1949       // and on the method we bind to.  Additionally since all we know
1950       // about the receiver type is the it's supposed to implement the
1951       // interface we have to insert a check that it's the class we
1952       // expect.  Interface types are not checked by the verifier so
1953       // they are roughly equivalent to Object.
1954       // The number of implementors for declared_interface is less or
1955       // equal to the number of implementors for target->holder() so
1956       // if number of implementors of target->holder() == 1 then
1957       // number of implementors for decl_interface is 0 or 1. If
1958       // it's 0 then no class implements decl_interface and there's
1959       // no point in inlining.
1960       ciInstanceKlass* singleton = NULL;
1961       ciInstanceKlass* declared_interface = callee_holder;
1962       if (declared_interface->nof_implementors() == 1 &&
1963           (!target->is_default_method() || target->is_overpass()) /* CHA doesn't support default methods yet. */) {
1964         singleton = declared_interface->implementor();
1965         assert(singleton != NULL && singleton != declared_interface, "");
1966         cha_monomorphic_target = target->find_monomorphic_target(calling_klass, declared_interface, singleton);
1967         if (cha_monomorphic_target != NULL) {
1968           if (cha_monomorphic_target->holder() != compilation()->env()->Object_klass()) {
1969             // If CHA is able to bind this invoke then update the class
1970             // to match that class, otherwise klass will refer to the
1971             // interface.
1972             klass = cha_monomorphic_target->holder();
1973             actual_recv = declared_interface;
1974 
1975             // insert a check it's really the expected class.
1976             CheckCast* c = new CheckCast(klass, receiver, copy_state_for_exception());
1977             c->set_incompatible_class_change_check();
1978             c->set_direct_compare(klass->is_final());
1979             // pass the result of the checkcast so that the compiler has
1980             // more accurate type info in the inlinee
1981             better_receiver = append_split(c);
1982           } else {
1983             cha_monomorphic_target = NULL; // subtype check against Object is useless
1984           }
1985         }


< prev index next >