< prev index next >

src/share/vm/opto/compile.cpp

Print this page
rev 10656 : [backport] Purge some G1-related cruft in C2
rev 10764 : [backport] Rename BrooksPointer to ShenandoahBrooksPointer


  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "asm/macroAssembler.hpp"
  27 #include "asm/macroAssembler.inline.hpp"
  28 #include "ci/ciReplay.hpp"
  29 #include "classfile/systemDictionary.hpp"
  30 #include "code/exceptionHandlerTable.hpp"
  31 #include "code/nmethod.hpp"
  32 #include "compiler/compileLog.hpp"
  33 #include "compiler/disassembler.hpp"
  34 #include "compiler/oopMap.hpp"
  35 #include "gc_implementation/shenandoah/brooksPointer.hpp"
  36 #include "opto/addnode.hpp"
  37 #include "opto/block.hpp"
  38 #include "opto/c2compiler.hpp"
  39 #include "opto/callGenerator.hpp"
  40 #include "opto/callnode.hpp"
  41 #include "opto/cfgnode.hpp"
  42 #include "opto/chaitin.hpp"
  43 #include "opto/compile.hpp"
  44 #include "opto/connode.hpp"
  45 #include "opto/divnode.hpp"
  46 #include "opto/escape.hpp"
  47 #include "opto/idealGraphPrinter.hpp"
  48 #include "opto/loopnode.hpp"
  49 #include "opto/machnode.hpp"
  50 #include "opto/macro.hpp"
  51 #include "opto/matcher.hpp"
  52 #include "opto/mathexactnode.hpp"
  53 #include "opto/memnode.hpp"
  54 #include "opto/mulnode.hpp"
  55 #include "opto/node.hpp"


1439     }
1440   } else if( ta && _AliasLevel >= 2 ) {
1441     // For arrays indexed by constant indices, we flatten the alias
1442     // space to include all of the array body.  Only the header, klass
1443     // and array length can be accessed un-aliased.
1444     if( offset != Type::OffsetBot ) {
1445       if( ta->const_oop() ) { // MethodData* or Method*
1446         offset = Type::OffsetBot;   // Flatten constant access into array body
1447         tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),ta->ary(),ta->klass(),false,offset);
1448       } else if( offset == arrayOopDesc::length_offset_in_bytes() ) {
1449         // range is OK as-is.
1450         tj = ta = TypeAryPtr::RANGE;
1451       } else if( offset == oopDesc::klass_offset_in_bytes() ) {
1452         tj = TypeInstPtr::KLASS; // all klass loads look alike
1453         ta = TypeAryPtr::RANGE; // generic ignored junk
1454         ptr = TypePtr::BotPTR;
1455       } else if( offset == oopDesc::mark_offset_in_bytes() ) {
1456         tj = TypeInstPtr::MARK;
1457         ta = TypeAryPtr::RANGE; // generic ignored junk
1458         ptr = TypePtr::BotPTR;
1459       } else if (offset == BrooksPointer::byte_offset() && UseShenandoahGC) {
1460         // Need to distinguish brooks ptr as is.
1461         tj = ta = TypeAryPtr::make(ptr,ta->ary(),ta->klass(),false,offset);
1462       } else {                  // Random constant offset into array body
1463         offset = Type::OffsetBot;   // Flatten constant access into array body
1464         tj = ta = TypeAryPtr::make(ptr,ta->ary(),ta->klass(),false,offset);
1465       }
1466     }
1467     // Arrays of fixed size alias with arrays of unknown size.
1468     if (ta->size() != TypeInt::POS) {
1469       const TypeAry *tary = TypeAry::make(ta->elem(), TypeInt::POS);
1470       tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,ta->klass(),false,offset);
1471     }
1472     // Arrays of known objects become arrays of unknown objects.
1473     if (ta->elem()->isa_narrowoop() && ta->elem() != TypeNarrowOop::BOTTOM) {
1474       const TypeAry *tary = TypeAry::make(TypeNarrowOop::BOTTOM, ta->size());
1475       tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,NULL,false,offset);
1476     }
1477     if (ta->elem()->isa_oopptr() && ta->elem() != TypeInstPtr::BOTTOM) {
1478       const TypeAry *tary = TypeAry::make(TypeInstPtr::BOTTOM, ta->size());
1479       tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,NULL,false,offset);


1506         tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset);
1507       }
1508     } else if( is_known_inst ) {
1509       tj = to; // Keep NotNull and klass_is_exact for instance type
1510     } else if( ptr == TypePtr::NotNull || to->klass_is_exact() ) {
1511       // During the 2nd round of IterGVN, NotNull castings are removed.
1512       // Make sure the Bottom and NotNull variants alias the same.
1513       // Also, make sure exact and non-exact variants alias the same.
1514       tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset);
1515     }
1516     if (to->speculative() != NULL) {
1517       tj = to = TypeInstPtr::make(to->ptr(),to->klass(),to->klass_is_exact(),to->const_oop(),to->offset(), to->instance_id());
1518     }
1519     // Canonicalize the holder of this field
1520     if (offset >= 0 && offset < instanceOopDesc::base_offset_in_bytes()) {
1521       // First handle header references such as a LoadKlassNode, even if the
1522       // object's klass is unloaded at compile time (4965979).
1523       if (!is_known_inst) { // Do it only for non-instance types
1524         tj = to = TypeInstPtr::make(TypePtr::BotPTR, env()->Object_klass(), false, NULL, offset);
1525       }
1526     } else if ((offset != BrooksPointer::byte_offset() || !UseShenandoahGC) && (offset < 0 || offset >= k->size_helper() * wordSize)) {
1527       // Static fields are in the space above the normal instance
1528       // fields in the java.lang.Class instance.
1529       if (to->klass() != ciEnv::current()->Class_klass()) {
1530         to = NULL;
1531         tj = TypeOopPtr::BOTTOM;
1532         offset = tj->offset();
1533       }
1534     } else {
1535       ciInstanceKlass *canonical_holder = k->get_canonical_holder(offset);
1536       if (!k->equals(canonical_holder) || tj->offset() != offset) {
1537         if( is_known_inst ) {
1538           tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, true, NULL, offset, to->instance_id());
1539         } else {
1540           tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, false, NULL, offset);
1541         }
1542       }
1543     }
1544   }
1545 
1546   // Klass pointers to object array klasses need some flattening


1605     default: ShouldNotReachHere();
1606     }
1607     break;
1608   case 2:                       // No collapsing at level 2; keep all splits
1609   case 3:                       // No collapsing at level 3; keep all splits
1610     break;
1611   default:
1612     Unimplemented();
1613   }
1614 
1615   offset = tj->offset();
1616   assert( offset != Type::OffsetTop, "Offset has fallen from constant" );
1617 
1618   assert( (offset != Type::OffsetBot && tj->base() != Type::AryPtr) ||
1619           (offset == Type::OffsetBot && tj->base() == Type::AryPtr) ||
1620           (offset == Type::OffsetBot && tj == TypeOopPtr::BOTTOM) ||
1621           (offset == Type::OffsetBot && tj == TypePtr::BOTTOM) ||
1622           (offset == oopDesc::mark_offset_in_bytes() && tj->base() == Type::AryPtr) ||
1623           (offset == oopDesc::klass_offset_in_bytes() && tj->base() == Type::AryPtr) ||
1624           (offset == arrayOopDesc::length_offset_in_bytes() && tj->base() == Type::AryPtr) ||
1625           (offset == BrooksPointer::byte_offset() && tj->base() == Type::AryPtr && UseShenandoahGC),
1626           "For oops, klasses, raw offset must be constant; for arrays the offset is never known" );
1627   assert( tj->ptr() != TypePtr::TopPTR &&
1628           tj->ptr() != TypePtr::AnyNull &&
1629           tj->ptr() != TypePtr::Null, "No imprecise addresses" );
1630 //    assert( tj->ptr() != TypePtr::Constant ||
1631 //            tj->base() == Type::RawPtr ||
1632 //            tj->base() == Type::KlassPtr, "No constant oop addresses" );
1633 
1634   return tj;
1635 }
1636 
1637 void Compile::AliasType::Init(int i, const TypePtr* at) {
1638   _index = i;
1639   _adr_type = at;
1640   _field = NULL;
1641   _element = NULL;
1642   _is_rewritable = true; // default
1643   const TypeOopPtr *atoop = (at != NULL) ? at->isa_oopptr() : NULL;
1644   if (atoop != NULL && atoop->is_known_instance()) {
1645     const TypeOopPtr *gt = atoop->cast_to_instance_id(TypeOopPtr::InstanceBot);


3646 
3647       if (x->is_Region()) {
3648         for (uint i = 1; i < x->req(); i++) {
3649           worklist.push(x->in(i));
3650         }
3651       } else {
3652         worklist.push(x->in(0));
3653         // We are looking for the pattern:
3654         //                            /->ThreadLocal
3655         // If->Bool->CmpI->LoadB->AddP->ConL(marking_offset)
3656         //              \->ConI(0)
3657         // We want to verify that the If and the LoadB have the same control
3658         // See GraphKit::g1_write_barrier_pre()
3659         if (x->is_If()) {
3660           IfNode *iff = x->as_If();
3661           if (iff->in(1)->is_Bool() && iff->in(1)->in(1)->is_Cmp()) {
3662             CmpNode *cmp = iff->in(1)->in(1)->as_Cmp();
3663             if (cmp->Opcode() == Op_CmpI && cmp->in(2)->is_Con() && cmp->in(2)->bottom_type()->is_int()->get_con() == 0
3664                 && cmp->in(1)->is_Load()) {
3665               LoadNode* load = cmp->in(1)->as_Load();
3666               if (load->is_g1_marking_load()) {


3667 
3668                 Node* if_ctrl = iff->in(0);
3669                 Node* load_ctrl = load->in(0);
3670 
3671                 if (if_ctrl != load_ctrl) {
3672                   // Skip possible CProj->NeverBranch in infinite loops
3673                   if ((if_ctrl->is_Proj() && if_ctrl->Opcode() == Op_CProj)
3674                       && (if_ctrl->in(0)->is_MultiBranch() && if_ctrl->in(0)->Opcode() == Op_NeverBranch)) {
3675                     if_ctrl = if_ctrl->in(0)->in(0);
3676                   }
3677                 }
3678                 assert(load_ctrl != NULL && if_ctrl == load_ctrl, "controls must match");
3679               }
3680             }
3681           }
3682         }
3683       }
3684     }
3685   }
3686 }




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "asm/macroAssembler.hpp"
  27 #include "asm/macroAssembler.inline.hpp"
  28 #include "ci/ciReplay.hpp"
  29 #include "classfile/systemDictionary.hpp"
  30 #include "code/exceptionHandlerTable.hpp"
  31 #include "code/nmethod.hpp"
  32 #include "compiler/compileLog.hpp"
  33 #include "compiler/disassembler.hpp"
  34 #include "compiler/oopMap.hpp"
  35 #include "gc_implementation/shenandoah/shenandoahBrooksPointer.hpp"
  36 #include "opto/addnode.hpp"
  37 #include "opto/block.hpp"
  38 #include "opto/c2compiler.hpp"
  39 #include "opto/callGenerator.hpp"
  40 #include "opto/callnode.hpp"
  41 #include "opto/cfgnode.hpp"
  42 #include "opto/chaitin.hpp"
  43 #include "opto/compile.hpp"
  44 #include "opto/connode.hpp"
  45 #include "opto/divnode.hpp"
  46 #include "opto/escape.hpp"
  47 #include "opto/idealGraphPrinter.hpp"
  48 #include "opto/loopnode.hpp"
  49 #include "opto/machnode.hpp"
  50 #include "opto/macro.hpp"
  51 #include "opto/matcher.hpp"
  52 #include "opto/mathexactnode.hpp"
  53 #include "opto/memnode.hpp"
  54 #include "opto/mulnode.hpp"
  55 #include "opto/node.hpp"


1439     }
1440   } else if( ta && _AliasLevel >= 2 ) {
1441     // For arrays indexed by constant indices, we flatten the alias
1442     // space to include all of the array body.  Only the header, klass
1443     // and array length can be accessed un-aliased.
1444     if( offset != Type::OffsetBot ) {
1445       if( ta->const_oop() ) { // MethodData* or Method*
1446         offset = Type::OffsetBot;   // Flatten constant access into array body
1447         tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),ta->ary(),ta->klass(),false,offset);
1448       } else if( offset == arrayOopDesc::length_offset_in_bytes() ) {
1449         // range is OK as-is.
1450         tj = ta = TypeAryPtr::RANGE;
1451       } else if( offset == oopDesc::klass_offset_in_bytes() ) {
1452         tj = TypeInstPtr::KLASS; // all klass loads look alike
1453         ta = TypeAryPtr::RANGE; // generic ignored junk
1454         ptr = TypePtr::BotPTR;
1455       } else if( offset == oopDesc::mark_offset_in_bytes() ) {
1456         tj = TypeInstPtr::MARK;
1457         ta = TypeAryPtr::RANGE; // generic ignored junk
1458         ptr = TypePtr::BotPTR;
1459       } else if (offset == ShenandoahBrooksPointer::byte_offset() && UseShenandoahGC) {
1460         // Need to distinguish brooks ptr as is.
1461         tj = ta = TypeAryPtr::make(ptr,ta->ary(),ta->klass(),false,offset);
1462       } else {                  // Random constant offset into array body
1463         offset = Type::OffsetBot;   // Flatten constant access into array body
1464         tj = ta = TypeAryPtr::make(ptr,ta->ary(),ta->klass(),false,offset);
1465       }
1466     }
1467     // Arrays of fixed size alias with arrays of unknown size.
1468     if (ta->size() != TypeInt::POS) {
1469       const TypeAry *tary = TypeAry::make(ta->elem(), TypeInt::POS);
1470       tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,ta->klass(),false,offset);
1471     }
1472     // Arrays of known objects become arrays of unknown objects.
1473     if (ta->elem()->isa_narrowoop() && ta->elem() != TypeNarrowOop::BOTTOM) {
1474       const TypeAry *tary = TypeAry::make(TypeNarrowOop::BOTTOM, ta->size());
1475       tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,NULL,false,offset);
1476     }
1477     if (ta->elem()->isa_oopptr() && ta->elem() != TypeInstPtr::BOTTOM) {
1478       const TypeAry *tary = TypeAry::make(TypeInstPtr::BOTTOM, ta->size());
1479       tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,NULL,false,offset);


1506         tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset);
1507       }
1508     } else if( is_known_inst ) {
1509       tj = to; // Keep NotNull and klass_is_exact for instance type
1510     } else if( ptr == TypePtr::NotNull || to->klass_is_exact() ) {
1511       // During the 2nd round of IterGVN, NotNull castings are removed.
1512       // Make sure the Bottom and NotNull variants alias the same.
1513       // Also, make sure exact and non-exact variants alias the same.
1514       tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset);
1515     }
1516     if (to->speculative() != NULL) {
1517       tj = to = TypeInstPtr::make(to->ptr(),to->klass(),to->klass_is_exact(),to->const_oop(),to->offset(), to->instance_id());
1518     }
1519     // Canonicalize the holder of this field
1520     if (offset >= 0 && offset < instanceOopDesc::base_offset_in_bytes()) {
1521       // First handle header references such as a LoadKlassNode, even if the
1522       // object's klass is unloaded at compile time (4965979).
1523       if (!is_known_inst) { // Do it only for non-instance types
1524         tj = to = TypeInstPtr::make(TypePtr::BotPTR, env()->Object_klass(), false, NULL, offset);
1525       }
1526     } else if ((offset != ShenandoahBrooksPointer::byte_offset() || !UseShenandoahGC) && (offset < 0 || offset >= k->size_helper() * wordSize)) {
1527       // Static fields are in the space above the normal instance
1528       // fields in the java.lang.Class instance.
1529       if (to->klass() != ciEnv::current()->Class_klass()) {
1530         to = NULL;
1531         tj = TypeOopPtr::BOTTOM;
1532         offset = tj->offset();
1533       }
1534     } else {
1535       ciInstanceKlass *canonical_holder = k->get_canonical_holder(offset);
1536       if (!k->equals(canonical_holder) || tj->offset() != offset) {
1537         if( is_known_inst ) {
1538           tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, true, NULL, offset, to->instance_id());
1539         } else {
1540           tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, false, NULL, offset);
1541         }
1542       }
1543     }
1544   }
1545 
1546   // Klass pointers to object array klasses need some flattening


1605     default: ShouldNotReachHere();
1606     }
1607     break;
1608   case 2:                       // No collapsing at level 2; keep all splits
1609   case 3:                       // No collapsing at level 3; keep all splits
1610     break;
1611   default:
1612     Unimplemented();
1613   }
1614 
1615   offset = tj->offset();
1616   assert( offset != Type::OffsetTop, "Offset has fallen from constant" );
1617 
1618   assert( (offset != Type::OffsetBot && tj->base() != Type::AryPtr) ||
1619           (offset == Type::OffsetBot && tj->base() == Type::AryPtr) ||
1620           (offset == Type::OffsetBot && tj == TypeOopPtr::BOTTOM) ||
1621           (offset == Type::OffsetBot && tj == TypePtr::BOTTOM) ||
1622           (offset == oopDesc::mark_offset_in_bytes() && tj->base() == Type::AryPtr) ||
1623           (offset == oopDesc::klass_offset_in_bytes() && tj->base() == Type::AryPtr) ||
1624           (offset == arrayOopDesc::length_offset_in_bytes() && tj->base() == Type::AryPtr) ||
1625           (offset == ShenandoahBrooksPointer::byte_offset() && tj->base() == Type::AryPtr && UseShenandoahGC),
1626           "For oops, klasses, raw offset must be constant; for arrays the offset is never known" );
1627   assert( tj->ptr() != TypePtr::TopPTR &&
1628           tj->ptr() != TypePtr::AnyNull &&
1629           tj->ptr() != TypePtr::Null, "No imprecise addresses" );
1630 //    assert( tj->ptr() != TypePtr::Constant ||
1631 //            tj->base() == Type::RawPtr ||
1632 //            tj->base() == Type::KlassPtr, "No constant oop addresses" );
1633 
1634   return tj;
1635 }
1636 
1637 void Compile::AliasType::Init(int i, const TypePtr* at) {
1638   _index = i;
1639   _adr_type = at;
1640   _field = NULL;
1641   _element = NULL;
1642   _is_rewritable = true; // default
1643   const TypeOopPtr *atoop = (at != NULL) ? at->isa_oopptr() : NULL;
1644   if (atoop != NULL && atoop->is_known_instance()) {
1645     const TypeOopPtr *gt = atoop->cast_to_instance_id(TypeOopPtr::InstanceBot);


3646 
3647       if (x->is_Region()) {
3648         for (uint i = 1; i < x->req(); i++) {
3649           worklist.push(x->in(i));
3650         }
3651       } else {
3652         worklist.push(x->in(0));
3653         // We are looking for the pattern:
3654         //                            /->ThreadLocal
3655         // If->Bool->CmpI->LoadB->AddP->ConL(marking_offset)
3656         //              \->ConI(0)
3657         // We want to verify that the If and the LoadB have the same control
3658         // See GraphKit::g1_write_barrier_pre()
3659         if (x->is_If()) {
3660           IfNode *iff = x->as_If();
3661           if (iff->in(1)->is_Bool() && iff->in(1)->in(1)->is_Cmp()) {
3662             CmpNode *cmp = iff->in(1)->in(1)->as_Cmp();
3663             if (cmp->Opcode() == Op_CmpI && cmp->in(2)->is_Con() && cmp->in(2)->bottom_type()->is_int()->get_con() == 0
3664                 && cmp->in(1)->is_Load()) {
3665               LoadNode* load = cmp->in(1)->as_Load();
3666               if (load->Opcode() == Op_LoadB && load->in(2)->is_AddP() && load->in(2)->in(2)->Opcode() == Op_ThreadLocal
3667                   && load->in(2)->in(3)->is_Con()
3668                   && load->in(2)->in(3)->bottom_type()->is_intptr_t()->get_con() == marking_offset) {
3669 
3670                 Node* if_ctrl = iff->in(0);
3671                 Node* load_ctrl = load->in(0);
3672 
3673                 if (if_ctrl != load_ctrl) {
3674                   // Skip possible CProj->NeverBranch in infinite loops
3675                   if ((if_ctrl->is_Proj() && if_ctrl->Opcode() == Op_CProj)
3676                       && (if_ctrl->in(0)->is_MultiBranch() && if_ctrl->in(0)->Opcode() == Op_NeverBranch)) {
3677                     if_ctrl = if_ctrl->in(0)->in(0);
3678                   }
3679                 }
3680                 assert(load_ctrl != NULL && if_ctrl == load_ctrl, "controls must match");
3681               }
3682             }
3683           }
3684         }
3685       }
3686     }
3687   }
3688 }


< prev index next >