1234 // If so, then the value is already null.
1235 if (t->higher_equal(TypePtr::NULL_PTR)) {
1236 explicit_null_checks_elided++;
1237 return value; // Elided null assert quickly!
1238 }
1239 } else {
1240 // See if mixing in the NULL pointer changes type.
1241 // If so, then the NULL pointer was not allowed in the original
1242 // type. In other words, "value" was not-null.
1243 if (t->meet(TypePtr::NULL_PTR) != t->remove_speculative()) {
1244 // same as: if (!TypePtr::NULL_PTR->higher_equal(t)) ...
1245 explicit_null_checks_elided++;
1246 return value; // Elided null check quickly!
1247 }
1248 }
1249 chk = new CmpPNode( value, null() );
1250 break;
1251 }
1252
1253 default:
1254 fatal(err_msg_res("unexpected type: %s", type2name(type)));
1255 }
1256 assert(chk != NULL, "sanity check");
1257 chk = _gvn.transform(chk);
1258
1259 BoolTest::mask btest = assert_null ? BoolTest::eq : BoolTest::ne;
1260 BoolNode *btst = new BoolNode( chk, btest);
1261 Node *tst = _gvn.transform( btst );
1262
1263 //-----------
1264 // if peephole optimizations occurred, a prior test existed.
1265 // If a prior test existed, maybe it dominates as we can avoid this test.
1266 if (tst != btst && type == T_OBJECT) {
1267 // At this point we want to scan up the CFG to see if we can
1268 // find an identical test (and so avoid this test altogether).
1269 Node *cfg = control();
1270 int depth = 0;
1271 while( depth < 16 ) { // Limit search depth for speed
1272 if( cfg->Opcode() == Op_IfTrue &&
1273 cfg->in(0)->in(1) == tst ) {
1274 // Found prior test. Use "cast_not_null" to construct an identical
1933 void GraphKit::uncommon_trap(int trap_request,
1934 ciKlass* klass, const char* comment,
1935 bool must_throw,
1936 bool keep_exact_action) {
1937 if (failing()) stop();
1938 if (stopped()) return; // trap reachable?
1939
1940 // Note: If ProfileTraps is true, and if a deopt. actually
1941 // occurs here, the runtime will make sure an MDO exists. There is
1942 // no need to call method()->ensure_method_data() at this point.
1943
1944 // Set the stack pointer to the right value for reexecution:
1945 set_sp(reexecute_sp());
1946
1947 #ifdef ASSERT
1948 if (!must_throw) {
1949 // Make sure the stack has at least enough depth to execute
1950 // the current bytecode.
1951 int inputs, ignored_depth;
1952 if (compute_stack_effects(inputs, ignored_depth)) {
1953 assert(sp() >= inputs, err_msg_res("must have enough JVMS stack to execute %s: sp=%d, inputs=%d",
1954 Bytecodes::name(java_bc()), sp(), inputs));
1955 }
1956 }
1957 #endif
1958
1959 Deoptimization::DeoptReason reason = Deoptimization::trap_request_reason(trap_request);
1960 Deoptimization::DeoptAction action = Deoptimization::trap_request_action(trap_request);
1961
1962 switch (action) {
1963 case Deoptimization::Action_maybe_recompile:
1964 case Deoptimization::Action_reinterpret:
1965 // Temporary fix for 6529811 to allow virtual calls to be sure they
1966 // get the chance to go from mono->bi->mega
1967 if (!keep_exact_action &&
1968 Deoptimization::trap_request_index(trap_request) < 0 &&
1969 too_many_recompiles(reason)) {
1970 // This BCI is causing too many recompilations.
1971 if (C->log() != NULL) {
1972 C->log()->elem("observe that='trap_action_change' reason='%s' from='%s' to='none'",
1973 Deoptimization::trap_reason_name(reason),
1974 Deoptimization::trap_action_name(action));
1975 }
1976 action = Deoptimization::Action_none;
1977 trap_request = Deoptimization::make_trap_request(reason, action);
1978 } else {
1979 C->set_trap_can_recompile(true);
1980 }
1981 break;
1982 case Deoptimization::Action_make_not_entrant:
1983 C->set_trap_can_recompile(true);
1984 break;
1985 #ifdef ASSERT
1986 case Deoptimization::Action_none:
1987 case Deoptimization::Action_make_not_compilable:
1988 break;
1989 default:
1990 fatal(err_msg_res("unknown action %d: %s", action, Deoptimization::trap_action_name(action)));
1991 break;
1992 #endif
1993 }
1994
1995 if (TraceOptoParse) {
1996 char buf[100];
1997 tty->print_cr("Uncommon trap %s at bci:%d",
1998 Deoptimization::format_trap_request(buf, sizeof(buf),
1999 trap_request), bci());
2000 }
2001
2002 CompileLog* log = C->log();
2003 if (log != NULL) {
2004 int kid = (klass == NULL)? -1: log->identify(klass);
2005 log->begin_elem("uncommon_trap bci='%d'", bci());
2006 char buf[100];
2007 log->print(" %s", Deoptimization::format_trap_request(buf, sizeof(buf),
2008 trap_request));
2009 if (kid >= 0) log->print(" klass='%d'", kid);
2010 if (comment != NULL) log->print(" comment='%s'", comment);
2492 Deoptimization::Action_none);
2493 } else {
2494 // Create an exception state also.
2495 // Use an exact type if the caller has specified a specific exception.
2496 const Type* ex_type = TypeOopPtr::make_from_klass_unique(ex_klass)->cast_to_ptr_type(TypePtr::NotNull);
2497 Node* ex_oop = new CreateExNode(ex_type, control(), i_o);
2498 add_exception_state(make_exception_state(_gvn.transform(ex_oop)));
2499 }
2500 }
2501 }
2502
2503 // Get the no-exception control from the CatchNode.
2504 set_control(norm);
2505 }
2506
2507 static IfNode* gen_subtype_check_compare(Node* ctrl, Node* in1, Node* in2, BoolTest::mask test, float p, PhaseGVN* gvn, BasicType bt) {
2508 Node* cmp = NULL;
2509 switch(bt) {
2510 case T_INT: cmp = new CmpINode(in1, in2); break;
2511 case T_ADDRESS: cmp = new CmpPNode(in1, in2); break;
2512 default: fatal(err_msg("unexpected comparison type %s", type2name(bt)));
2513 }
2514 gvn->transform(cmp);
2515 Node* bol = gvn->transform(new BoolNode(cmp, test));
2516 IfNode* iff = new IfNode(ctrl, bol, p, COUNT_UNKNOWN);
2517 gvn->transform(iff);
2518 if (!bol->is_Con()) gvn->record_for_igvn(iff);
2519 return iff;
2520 }
2521
2522
2523 //-------------------------------gen_subtype_check-----------------------------
2524 // Generate a subtyping check. Takes as input the subtype and supertype.
2525 // Returns 2 values: sets the default control() to the true path and returns
2526 // the false path. Only reads invariant memory; sets no (visible) memory.
2527 // The PartialSubtypeCheckNode sets the hidden 1-word cache in the encoding
2528 // but that's not exposed to the optimizer. This call also doesn't take in an
2529 // Object; if you wish to check an Object you need to load the Object's class
2530 // prior to coming here.
2531 Node* Phase::gen_subtype_check(Node* subklass, Node* superklass, Node** ctrl, MergeMemNode* mem, PhaseGVN* gvn) {
2532 Compile* C = gvn->C;
|
1234 // If so, then the value is already null.
1235 if (t->higher_equal(TypePtr::NULL_PTR)) {
1236 explicit_null_checks_elided++;
1237 return value; // Elided null assert quickly!
1238 }
1239 } else {
1240 // See if mixing in the NULL pointer changes type.
1241 // If so, then the NULL pointer was not allowed in the original
1242 // type. In other words, "value" was not-null.
1243 if (t->meet(TypePtr::NULL_PTR) != t->remove_speculative()) {
1244 // same as: if (!TypePtr::NULL_PTR->higher_equal(t)) ...
1245 explicit_null_checks_elided++;
1246 return value; // Elided null check quickly!
1247 }
1248 }
1249 chk = new CmpPNode( value, null() );
1250 break;
1251 }
1252
1253 default:
1254 fatal("unexpected type: %s", type2name(type));
1255 }
1256 assert(chk != NULL, "sanity check");
1257 chk = _gvn.transform(chk);
1258
1259 BoolTest::mask btest = assert_null ? BoolTest::eq : BoolTest::ne;
1260 BoolNode *btst = new BoolNode( chk, btest);
1261 Node *tst = _gvn.transform( btst );
1262
1263 //-----------
1264 // if peephole optimizations occurred, a prior test existed.
1265 // If a prior test existed, maybe it dominates as we can avoid this test.
1266 if (tst != btst && type == T_OBJECT) {
1267 // At this point we want to scan up the CFG to see if we can
1268 // find an identical test (and so avoid this test altogether).
1269 Node *cfg = control();
1270 int depth = 0;
1271 while( depth < 16 ) { // Limit search depth for speed
1272 if( cfg->Opcode() == Op_IfTrue &&
1273 cfg->in(0)->in(1) == tst ) {
1274 // Found prior test. Use "cast_not_null" to construct an identical
1933 void GraphKit::uncommon_trap(int trap_request,
1934 ciKlass* klass, const char* comment,
1935 bool must_throw,
1936 bool keep_exact_action) {
1937 if (failing()) stop();
1938 if (stopped()) return; // trap reachable?
1939
1940 // Note: If ProfileTraps is true, and if a deopt. actually
1941 // occurs here, the runtime will make sure an MDO exists. There is
1942 // no need to call method()->ensure_method_data() at this point.
1943
1944 // Set the stack pointer to the right value for reexecution:
1945 set_sp(reexecute_sp());
1946
1947 #ifdef ASSERT
1948 if (!must_throw) {
1949 // Make sure the stack has at least enough depth to execute
1950 // the current bytecode.
1951 int inputs, ignored_depth;
1952 if (compute_stack_effects(inputs, ignored_depth)) {
1953 assert(sp() >= inputs, "must have enough JVMS stack to execute %s: sp=%d, inputs=%d",
1954 Bytecodes::name(java_bc()), sp(), inputs);
1955 }
1956 }
1957 #endif
1958
1959 Deoptimization::DeoptReason reason = Deoptimization::trap_request_reason(trap_request);
1960 Deoptimization::DeoptAction action = Deoptimization::trap_request_action(trap_request);
1961
1962 switch (action) {
1963 case Deoptimization::Action_maybe_recompile:
1964 case Deoptimization::Action_reinterpret:
1965 // Temporary fix for 6529811 to allow virtual calls to be sure they
1966 // get the chance to go from mono->bi->mega
1967 if (!keep_exact_action &&
1968 Deoptimization::trap_request_index(trap_request) < 0 &&
1969 too_many_recompiles(reason)) {
1970 // This BCI is causing too many recompilations.
1971 if (C->log() != NULL) {
1972 C->log()->elem("observe that='trap_action_change' reason='%s' from='%s' to='none'",
1973 Deoptimization::trap_reason_name(reason),
1974 Deoptimization::trap_action_name(action));
1975 }
1976 action = Deoptimization::Action_none;
1977 trap_request = Deoptimization::make_trap_request(reason, action);
1978 } else {
1979 C->set_trap_can_recompile(true);
1980 }
1981 break;
1982 case Deoptimization::Action_make_not_entrant:
1983 C->set_trap_can_recompile(true);
1984 break;
1985 #ifdef ASSERT
1986 case Deoptimization::Action_none:
1987 case Deoptimization::Action_make_not_compilable:
1988 break;
1989 default:
1990 fatal("unknown action %d: %s", action, Deoptimization::trap_action_name(action));
1991 break;
1992 #endif
1993 }
1994
1995 if (TraceOptoParse) {
1996 char buf[100];
1997 tty->print_cr("Uncommon trap %s at bci:%d",
1998 Deoptimization::format_trap_request(buf, sizeof(buf),
1999 trap_request), bci());
2000 }
2001
2002 CompileLog* log = C->log();
2003 if (log != NULL) {
2004 int kid = (klass == NULL)? -1: log->identify(klass);
2005 log->begin_elem("uncommon_trap bci='%d'", bci());
2006 char buf[100];
2007 log->print(" %s", Deoptimization::format_trap_request(buf, sizeof(buf),
2008 trap_request));
2009 if (kid >= 0) log->print(" klass='%d'", kid);
2010 if (comment != NULL) log->print(" comment='%s'", comment);
2492 Deoptimization::Action_none);
2493 } else {
2494 // Create an exception state also.
2495 // Use an exact type if the caller has specified a specific exception.
2496 const Type* ex_type = TypeOopPtr::make_from_klass_unique(ex_klass)->cast_to_ptr_type(TypePtr::NotNull);
2497 Node* ex_oop = new CreateExNode(ex_type, control(), i_o);
2498 add_exception_state(make_exception_state(_gvn.transform(ex_oop)));
2499 }
2500 }
2501 }
2502
2503 // Get the no-exception control from the CatchNode.
2504 set_control(norm);
2505 }
2506
2507 static IfNode* gen_subtype_check_compare(Node* ctrl, Node* in1, Node* in2, BoolTest::mask test, float p, PhaseGVN* gvn, BasicType bt) {
2508 Node* cmp = NULL;
2509 switch(bt) {
2510 case T_INT: cmp = new CmpINode(in1, in2); break;
2511 case T_ADDRESS: cmp = new CmpPNode(in1, in2); break;
2512 default: fatal("unexpected comparison type %s", type2name(bt));
2513 }
2514 gvn->transform(cmp);
2515 Node* bol = gvn->transform(new BoolNode(cmp, test));
2516 IfNode* iff = new IfNode(ctrl, bol, p, COUNT_UNKNOWN);
2517 gvn->transform(iff);
2518 if (!bol->is_Con()) gvn->record_for_igvn(iff);
2519 return iff;
2520 }
2521
2522
2523 //-------------------------------gen_subtype_check-----------------------------
2524 // Generate a subtyping check. Takes as input the subtype and supertype.
2525 // Returns 2 values: sets the default control() to the true path and returns
2526 // the false path. Only reads invariant memory; sets no (visible) memory.
2527 // The PartialSubtypeCheckNode sets the hidden 1-word cache in the encoding
2528 // but that's not exposed to the optimizer. This call also doesn't take in an
2529 // Object; if you wish to check an Object you need to load the Object's class
2530 // prior to coming here.
2531 Node* Phase::gen_subtype_check(Node* subklass, Node* superklass, Node** ctrl, MergeMemNode* mem, PhaseGVN* gvn) {
2532 Compile* C = gvn->C;
|