1373 //------------------------------cast_not_null----------------------------------
1374 // Cast obj to not-null on this path
1375 Node* GraphKit::cast_not_null(Node* obj, bool do_replace_in_map) {
1376 const Type *t = _gvn.type(obj);
1377 const Type *t_not_null = t->join_speculative(TypePtr::NOTNULL);
1378 // Object is already not-null?
1379 if( t == t_not_null ) return obj;
1380
1381 Node *cast = new CastPPNode(obj,t_not_null);
1382 cast->init_req(0, control());
1383 cast = _gvn.transform( cast );
1384
1385 // Scan for instances of 'obj' in the current JVM mapping.
1386 // These instances are known to be not-null after the test.
1387 if (do_replace_in_map)
1388 replace_in_map(obj, cast);
1389
1390 return cast; // Return casted value
1391 }
1392
1393
1394 //--------------------------replace_in_map-------------------------------------
1395 void GraphKit::replace_in_map(Node* old, Node* neww) {
1396 if (old == neww) {
1397 return;
1398 }
1399
1400 map()->replace_edge(old, neww);
1401
1402 // Note: This operation potentially replaces any edge
1403 // on the map. This includes locals, stack, and monitors
1404 // of the current (innermost) JVM state.
1405
1406 // don't let inconsistent types from profiling escape this
1407 // method
1408
1409 const Type* told = _gvn.type(old);
1410 const Type* tnew = _gvn.type(neww);
1411
1412 if (!tnew->higher_equal(told)) {
|
1373 //------------------------------cast_not_null----------------------------------
1374 // Cast obj to not-null on this path
1375 Node* GraphKit::cast_not_null(Node* obj, bool do_replace_in_map) {
1376 const Type *t = _gvn.type(obj);
1377 const Type *t_not_null = t->join_speculative(TypePtr::NOTNULL);
1378 // Object is already not-null?
1379 if( t == t_not_null ) return obj;
1380
1381 Node *cast = new CastPPNode(obj,t_not_null);
1382 cast->init_req(0, control());
1383 cast = _gvn.transform( cast );
1384
1385 // Scan for instances of 'obj' in the current JVM mapping.
1386 // These instances are known to be not-null after the test.
1387 if (do_replace_in_map)
1388 replace_in_map(obj, cast);
1389
1390 return cast; // Return casted value
1391 }
1392
1393 // Sometimes in intrinsics, we implicitly know an object is not null
1394 // (there's no actual null check) so we can cast it to not null. In
1395 // the course of optimizations, the input to the cast can become null.
1396 // In that case that data path will die and we need the control path
1397 // to become dead as well to keep the graph consistent. So we have to
1398 // add a check for null for which one branch can't be taken. It uses
1399 // and Opaque4 node that will cause the check to be removed after loop
1400 // opts so the test goes away and the compiled code doesn't execute a
1401 // useless check.
1402 Node* GraphKit::must_be_not_null(Node* value, bool do_replace_in_map) {
1403 Node* chk = _gvn.transform(new CmpPNode(value, null()));
1404 Node *tst = _gvn.transform(new BoolNode(chk, BoolTest::ne));
1405 Node* opaq = _gvn.transform(new Opaque4Node(C, tst, intcon(1)));
1406 IfNode *iff = new IfNode(control(), opaq, PROB_MAX, COUNT_UNKNOWN);
1407 _gvn.set_type(iff, iff->Value(&_gvn));
1408 Node *if_f = _gvn.transform(new IfFalseNode(iff));
1409 Node *frame = _gvn.transform(new ParmNode(C->start(), TypeFunc::FramePtr));
1410 Node *halt = _gvn.transform(new HaltNode(if_f, frame));
1411 C->root()->add_req(halt);
1412 Node *if_t = _gvn.transform(new IfTrueNode(iff));
1413 set_control(if_t);
1414 return cast_not_null(value, true);
1415 }
1416
1417
1418 //--------------------------replace_in_map-------------------------------------
1419 void GraphKit::replace_in_map(Node* old, Node* neww) {
1420 if (old == neww) {
1421 return;
1422 }
1423
1424 map()->replace_edge(old, neww);
1425
1426 // Note: This operation potentially replaces any edge
1427 // on the map. This includes locals, stack, and monitors
1428 // of the current (innermost) JVM state.
1429
1430 // don't let inconsistent types from profiling escape this
1431 // method
1432
1433 const Type* told = _gvn.type(old);
1434 const Type* tnew = _gvn.type(neww);
1435
1436 if (!tnew->higher_equal(told)) {
|