< prev index next >

src/share/vm/opto/escape.cpp

Print this page
rev 12700 : 8176506: C2: loop unswitching and unsafe accesses cause crash
Reviewed-by:


2293   // case #7. Klass's field reference.
2294   //      LoadKlass
2295   //       | |
2296   //       AddP  ( base == address )
2297   //
2298   // case #8. narrow Klass's field reference.
2299   //      LoadNKlass
2300   //       |
2301   //      DecodeN
2302   //       | |
2303   //       AddP  ( base == address )
2304   //
2305   Node *base = addp->in(AddPNode::Base);
2306   if (base->uncast()->is_top()) { // The AddP case #3 and #6.
2307     base = addp->in(AddPNode::Address);
2308     while (base->is_AddP()) {
2309       // Case #6 (unsafe access) may have several chained AddP nodes.
2310       assert(base->in(AddPNode::Base)->uncast()->is_top(), "expected unsafe access address only");
2311       base = base->in(AddPNode::Address);
2312     }





2313     Node* uncast_base = base->uncast();
2314     int opcode = uncast_base->Opcode();
2315     assert(opcode == Op_ConP || opcode == Op_ThreadLocal ||
2316            opcode == Op_CastX2P || uncast_base->is_DecodeNarrowPtr() ||
2317            (uncast_base->is_Mem() && (uncast_base->bottom_type()->isa_rawptr() != NULL)) ||
2318            (uncast_base->is_Proj() && uncast_base->in(0)->is_Allocate()), "sanity");

2319   }
2320   return base;
2321 }
2322 
2323 Node* ConnectionGraph::find_second_addp(Node* addp, Node* n) {
2324   assert(addp->is_AddP() && addp->outcnt() > 0, "Don't process dead nodes");
2325   Node* addp2 = addp->raw_out(0);
2326   if (addp->outcnt() == 1 && addp2->is_AddP() &&
2327       addp2->in(AddPNode::Base) == n &&
2328       addp2->in(AddPNode::Address) == addp) {
2329     assert(addp->in(AddPNode::Base) == n, "expecting the same base");
2330     //
2331     // Find array's offset to push it on worklist first and
2332     // as result process an array's element offset first (pushed second)
2333     // to avoid CastPP for the array's offset.
2334     // Otherwise the inserted CastPP (LocalVar) will point to what
2335     // the AddP (Field) points to. Which would be wrong since
2336     // the algorithm expects the CastPP has the same point as
2337     // as AddP's base CheckCastPP (LocalVar).
2338     //




2293   // case #7. Klass's field reference.
2294   //      LoadKlass
2295   //       | |
2296   //       AddP  ( base == address )
2297   //
2298   // case #8. narrow Klass's field reference.
2299   //      LoadNKlass
2300   //       |
2301   //      DecodeN
2302   //       | |
2303   //       AddP  ( base == address )
2304   //
2305   Node *base = addp->in(AddPNode::Base);
2306   if (base->uncast()->is_top()) { // The AddP case #3 and #6.
2307     base = addp->in(AddPNode::Address);
2308     while (base->is_AddP()) {
2309       // Case #6 (unsafe access) may have several chained AddP nodes.
2310       assert(base->in(AddPNode::Base)->uncast()->is_top(), "expected unsafe access address only");
2311       base = base->in(AddPNode::Address);
2312     }
2313     if (base->Opcode() == Op_CheckCastPP &&
2314         base->bottom_type()->isa_rawptr() &&
2315         _igvn->type(base->in(1))->isa_oopptr()) {
2316       base = base->in(1);
2317     } else {
2318       Node* uncast_base = base->uncast();
2319       int opcode = uncast_base->Opcode();
2320       assert(opcode == Op_ConP || opcode == Op_ThreadLocal ||
2321              opcode == Op_CastX2P || uncast_base->is_DecodeNarrowPtr() ||
2322              (uncast_base->is_Mem() && (uncast_base->bottom_type()->isa_rawptr() != NULL)) ||
2323              (uncast_base->is_Proj() && uncast_base->in(0)->is_Allocate()), "sanity");
2324     }
2325   }
2326   return base;
2327 }
2328 
2329 Node* ConnectionGraph::find_second_addp(Node* addp, Node* n) {
2330   assert(addp->is_AddP() && addp->outcnt() > 0, "Don't process dead nodes");
2331   Node* addp2 = addp->raw_out(0);
2332   if (addp->outcnt() == 1 && addp2->is_AddP() &&
2333       addp2->in(AddPNode::Base) == n &&
2334       addp2->in(AddPNode::Address) == addp) {
2335     assert(addp->in(AddPNode::Base) == n, "expecting the same base");
2336     //
2337     // Find array's offset to push it on worklist first and
2338     // as result process an array's element offset first (pushed second)
2339     // to avoid CastPP for the array's offset.
2340     // Otherwise the inserted CastPP (LocalVar) will point to what
2341     // the AddP (Field) points to. Which would be wrong since
2342     // the algorithm expects the CastPP has the same point as
2343     // as AddP's base CheckCastPP (LocalVar).
2344     //


< prev index next >