< prev index next >

src/hotspot/share/opto/graphKit.cpp

Print this page
rev 49910 : imported patch removeAllGCs.fixIncludes
rev 49911 : imported patch removeAllGCs


   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  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 "ci/ciUtilities.hpp"
  27 #include "compiler/compileLog.hpp"
  28 #include "gc/g1/g1BarrierSet.hpp"
  29 #include "gc/g1/g1CardTable.hpp"
  30 #include "gc/g1/heapRegion.hpp"
  31 #include "gc/shared/barrierSet.hpp"
  32 #include "gc/shared/cardTable.hpp"
  33 #include "gc/shared/cardTableBarrierSet.hpp"
  34 #include "gc/shared/collectedHeap.hpp"
  35 #include "interpreter/interpreter.hpp"
  36 #include "memory/resourceArea.hpp"
  37 #include "opto/addnode.hpp"
  38 #include "opto/castnode.hpp"
  39 #include "opto/convertnode.hpp"
  40 #include "opto/graphKit.hpp"
  41 #include "opto/idealKit.hpp"
  42 #include "opto/intrinsicnode.hpp"
  43 #include "opto/locknode.hpp"
  44 #include "opto/machnode.hpp"
  45 #include "opto/opaquenode.hpp"
  46 #include "opto/parse.hpp"
  47 #include "opto/rootnode.hpp"
  48 #include "opto/runtime.hpp"
  49 #include "runtime/deoptimization.hpp"
  50 #include "runtime/sharedRuntime.hpp"
  51 #if INCLUDE_ALL_GCS

  52 #include "gc/g1/g1ThreadLocalData.hpp"

  53 #endif // INCLUDE_ALL_GCS
  54 
  55 //----------------------------GraphKit-----------------------------------------
  56 // Main utility constructor.
  57 GraphKit::GraphKit(JVMState* jvms)
  58   : Phase(Phase::Parser),
  59     _env(C->env()),
  60     _gvn(*C->initial_gvn())
  61 {
  62   _exceptions = jvms->map()->next_exception();
  63   if (_exceptions != NULL)  jvms->map()->set_next_exception(NULL);
  64   set_jvms(jvms);
  65 }
  66 
  67 // Private constructor for parser.
  68 GraphKit::GraphKit()
  69   : Phase(Phase::Parser),
  70     _env(C->env()),
  71     _gvn(*C->initial_gvn())
  72 {


1548   if (mem->req() > MemNode::Address && adr == mem->in(MemNode::Address))
1549     record_for_igvn(st);
1550 
1551   return st;
1552 }
1553 
1554 
1555 void GraphKit::pre_barrier(bool do_load,
1556                            Node* ctl,
1557                            Node* obj,
1558                            Node* adr,
1559                            uint  adr_idx,
1560                            Node* val,
1561                            const TypeOopPtr* val_type,
1562                            Node* pre_val,
1563                            BasicType bt) {
1564 
1565   BarrierSet* bs = BarrierSet::barrier_set();
1566   set_control(ctl);
1567   switch (bs->kind()) {


1568     case BarrierSet::G1BarrierSet:
1569       g1_write_barrier_pre(do_load, obj, adr, adr_idx, val, val_type, pre_val, bt);
1570       break;

1571 
1572     case BarrierSet::CardTableBarrierSet:
1573       break;
1574 
1575     default      :
1576       ShouldNotReachHere();
1577 
1578   }
1579 }
1580 
1581 bool GraphKit::can_move_pre_barrier() const {
1582   BarrierSet* bs = BarrierSet::barrier_set();
1583   switch (bs->kind()) {


1584     case BarrierSet::G1BarrierSet:
1585       return true; // Can move it if no safepoint

1586 
1587     case BarrierSet::CardTableBarrierSet:
1588       return true; // There is no pre-barrier
1589 
1590     default      :
1591       ShouldNotReachHere();
1592   }
1593   return false;
1594 }
1595 
1596 void GraphKit::post_barrier(Node* ctl,
1597                             Node* store,
1598                             Node* obj,
1599                             Node* adr,
1600                             uint  adr_idx,
1601                             Node* val,
1602                             BasicType bt,
1603                             bool use_precise) {
1604   BarrierSet* bs = BarrierSet::barrier_set();
1605   set_control(ctl);
1606   switch (bs->kind()) {

1607     case BarrierSet::G1BarrierSet:
1608       g1_write_barrier_post(store, obj, adr, adr_idx, val, bt, use_precise);
1609       break;

1610 
1611     case BarrierSet::CardTableBarrierSet:
1612       write_barrier_post(store, obj, adr, adr_idx, val, use_precise);
1613       break;
1614 
1615     default      :
1616       ShouldNotReachHere();
1617 
1618   }
1619 }
1620 
1621 Node* GraphKit::store_oop(Node* ctl,
1622                           Node* obj,
1623                           Node* adr,
1624                           const TypePtr* adr_type,
1625                           Node* val,
1626                           const TypeOopPtr* val_type,
1627                           BasicType bt,
1628                           bool use_precise,
1629                           MemNode::MemOrd mo,


3912     // no_ctrl, but that doesn't buy much latitude.
3913     Node* card_val = __ load( __ ctrl(), card_adr, TypeInt::BYTE, bt, adr_type);
3914     __ if_then(card_val, BoolTest::ne, zero);
3915   }
3916 
3917   // Smash zero into card
3918   if( !UseConcMarkSweepGC ) {
3919     __ store(__ ctrl(), card_adr, zero, bt, adr_type, MemNode::unordered);
3920   } else {
3921     // Specialized path for CM store barrier
3922     __ storeCM(__ ctrl(), card_adr, zero, oop_store, adr_idx, bt, adr_type);
3923   }
3924 
3925   if (UseCondCardMark) {
3926     __ end_if();
3927   }
3928 
3929   // Final sync IdealKit and GraphKit.
3930   final_sync(ideal);
3931 }



3932 /*
3933  * Determine if the G1 pre-barrier can be removed. The pre-barrier is
3934  * required by SATB to make sure all objects live at the start of the
3935  * marking are kept alive, all reference updates need to any previous
3936  * reference stored before writing.
3937  *
3938  * If the previous value is NULL there is no need to save the old value.
3939  * References that are NULL are filtered during runtime by the barrier
3940  * code to avoid unnecessary queuing.
3941  *
3942  * However in the case of newly allocated objects it might be possible to
3943  * prove that the reference about to be overwritten is NULL during compile
3944  * time and avoid adding the barrier code completely.
3945  *
3946  * The compiler needs to determine that the object in which a field is about
3947  * to be written is newly allocated, and that no prior store to the same field
3948  * has happened since the allocation.
3949  *
3950  * Returns true if the pre-barrier can be removed
3951  */


4344         } __ end_if();
4345       } __ end_if();
4346     } __ end_if();
4347   } else {
4348     // The Object.clone() intrinsic uses this path if !ReduceInitialCardMarks.
4349     // We don't need a barrier here if the destination is a newly allocated object
4350     // in Eden. Otherwise, GC verification breaks because we assume that cards in Eden
4351     // are set to 'g1_young_gen' (see G1CardTable::verify_g1_young_region()).
4352     assert(!use_ReduceInitialCardMarks(), "can only happen with card marking");
4353     Node* card_val = __ load(__ ctrl(), card_adr, TypeInt::INT, T_BYTE, Compile::AliasIdxRaw);
4354     __ if_then(card_val, BoolTest::ne, young_card); {
4355       g1_mark_card(ideal, card_adr, oop_store, alias_idx, index, index_adr, buffer, tf);
4356     } __ end_if();
4357   }
4358 
4359   // Final sync IdealKit and GraphKit.
4360   final_sync(ideal);
4361 }
4362 #undef __
4363 

4364 
4365 Node* GraphKit::load_String_length(Node* ctrl, Node* str) {
4366   Node* len = load_array_length(load_String_value(ctrl, str));
4367   Node* coder = load_String_coder(ctrl, str);
4368   // Divide length by 2 if coder is UTF16
4369   return _gvn.transform(new RShiftINode(len, coder));
4370 }
4371 
4372 Node* GraphKit::load_String_value(Node* ctrl, Node* str) {
4373   int value_offset = java_lang_String::value_offset_in_bytes();
4374   const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(),
4375                                                      false, NULL, 0);
4376   const TypePtr* value_field_type = string_type->add_offset(value_offset);
4377   const TypeAryPtr* value_type = TypeAryPtr::make(TypePtr::NotNull,
4378                                                   TypeAry::make(TypeInt::BYTE, TypeInt::POS),
4379                                                   ciTypeArrayKlass::make(T_BYTE), true, 0);
4380   int value_field_idx = C->get_alias_index(value_field_type);
4381   Node* load = make_load(ctrl, basic_plus_adr(str, str, value_offset),
4382                          value_type, T_OBJECT, value_field_idx, MemNode::unordered);
4383   // String.value field is known to be @Stable.




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  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 "ci/ciUtilities.hpp"
  27 #include "compiler/compileLog.hpp"



  28 #include "gc/shared/barrierSet.hpp"
  29 #include "gc/shared/cardTable.hpp"
  30 #include "gc/shared/cardTableBarrierSet.hpp"
  31 #include "gc/shared/collectedHeap.hpp"
  32 #include "interpreter/interpreter.hpp"
  33 #include "memory/resourceArea.hpp"
  34 #include "opto/addnode.hpp"
  35 #include "opto/castnode.hpp"
  36 #include "opto/convertnode.hpp"
  37 #include "opto/graphKit.hpp"
  38 #include "opto/idealKit.hpp"
  39 #include "opto/intrinsicnode.hpp"
  40 #include "opto/locknode.hpp"
  41 #include "opto/machnode.hpp"
  42 #include "opto/opaquenode.hpp"
  43 #include "opto/parse.hpp"
  44 #include "opto/rootnode.hpp"
  45 #include "opto/runtime.hpp"
  46 #include "runtime/deoptimization.hpp"
  47 #include "runtime/sharedRuntime.hpp"
  48 #if INCLUDE_G1GC
  49 #include "gc/g1/g1CardTable.hpp"
  50 #include "gc/g1/g1ThreadLocalData.hpp"
  51 #include "gc/g1/heapRegion.hpp"
  52 #endif // INCLUDE_ALL_GCS
  53 
  54 //----------------------------GraphKit-----------------------------------------
  55 // Main utility constructor.
  56 GraphKit::GraphKit(JVMState* jvms)
  57   : Phase(Phase::Parser),
  58     _env(C->env()),
  59     _gvn(*C->initial_gvn())
  60 {
  61   _exceptions = jvms->map()->next_exception();
  62   if (_exceptions != NULL)  jvms->map()->set_next_exception(NULL);
  63   set_jvms(jvms);
  64 }
  65 
  66 // Private constructor for parser.
  67 GraphKit::GraphKit()
  68   : Phase(Phase::Parser),
  69     _env(C->env()),
  70     _gvn(*C->initial_gvn())
  71 {


1547   if (mem->req() > MemNode::Address && adr == mem->in(MemNode::Address))
1548     record_for_igvn(st);
1549 
1550   return st;
1551 }
1552 
1553 
1554 void GraphKit::pre_barrier(bool do_load,
1555                            Node* ctl,
1556                            Node* obj,
1557                            Node* adr,
1558                            uint  adr_idx,
1559                            Node* val,
1560                            const TypeOopPtr* val_type,
1561                            Node* pre_val,
1562                            BasicType bt) {
1563 
1564   BarrierSet* bs = BarrierSet::barrier_set();
1565   set_control(ctl);
1566   switch (bs->kind()) {
1567 
1568 #if INCLUDE_G1GC
1569     case BarrierSet::G1BarrierSet:
1570       g1_write_barrier_pre(do_load, obj, adr, adr_idx, val, val_type, pre_val, bt);
1571       break;
1572 #endif
1573 
1574     case BarrierSet::CardTableBarrierSet:
1575       break;
1576 
1577     default      :
1578       ShouldNotReachHere();
1579 
1580   }
1581 }
1582 
1583 bool GraphKit::can_move_pre_barrier() const {
1584   BarrierSet* bs = BarrierSet::barrier_set();
1585   switch (bs->kind()) {
1586 
1587 #if INCLUDE_G1GC
1588     case BarrierSet::G1BarrierSet:
1589       return true; // Can move it if no safepoint
1590 #endif
1591 
1592     case BarrierSet::CardTableBarrierSet:
1593       return true; // There is no pre-barrier
1594 
1595     default      :
1596       ShouldNotReachHere();
1597   }
1598   return false;
1599 }
1600 
1601 void GraphKit::post_barrier(Node* ctl,
1602                             Node* store,
1603                             Node* obj,
1604                             Node* adr,
1605                             uint  adr_idx,
1606                             Node* val,
1607                             BasicType bt,
1608                             bool use_precise) {
1609   BarrierSet* bs = BarrierSet::barrier_set();
1610   set_control(ctl);
1611   switch (bs->kind()) {
1612 #if INCLUDE_G1GC
1613     case BarrierSet::G1BarrierSet:
1614       g1_write_barrier_post(store, obj, adr, adr_idx, val, bt, use_precise);
1615       break;
1616 #endif
1617 
1618     case BarrierSet::CardTableBarrierSet:
1619       write_barrier_post(store, obj, adr, adr_idx, val, use_precise);
1620       break;
1621 
1622     default      :
1623       ShouldNotReachHere();
1624 
1625   }
1626 }
1627 
1628 Node* GraphKit::store_oop(Node* ctl,
1629                           Node* obj,
1630                           Node* adr,
1631                           const TypePtr* adr_type,
1632                           Node* val,
1633                           const TypeOopPtr* val_type,
1634                           BasicType bt,
1635                           bool use_precise,
1636                           MemNode::MemOrd mo,


3919     // no_ctrl, but that doesn't buy much latitude.
3920     Node* card_val = __ load( __ ctrl(), card_adr, TypeInt::BYTE, bt, adr_type);
3921     __ if_then(card_val, BoolTest::ne, zero);
3922   }
3923 
3924   // Smash zero into card
3925   if( !UseConcMarkSweepGC ) {
3926     __ store(__ ctrl(), card_adr, zero, bt, adr_type, MemNode::unordered);
3927   } else {
3928     // Specialized path for CM store barrier
3929     __ storeCM(__ ctrl(), card_adr, zero, oop_store, adr_idx, bt, adr_type);
3930   }
3931 
3932   if (UseCondCardMark) {
3933     __ end_if();
3934   }
3935 
3936   // Final sync IdealKit and GraphKit.
3937   final_sync(ideal);
3938 }
3939 
3940 #if INCLUDE_G1GC
3941 
3942 /*
3943  * Determine if the G1 pre-barrier can be removed. The pre-barrier is
3944  * required by SATB to make sure all objects live at the start of the
3945  * marking are kept alive, all reference updates need to any previous
3946  * reference stored before writing.
3947  *
3948  * If the previous value is NULL there is no need to save the old value.
3949  * References that are NULL are filtered during runtime by the barrier
3950  * code to avoid unnecessary queuing.
3951  *
3952  * However in the case of newly allocated objects it might be possible to
3953  * prove that the reference about to be overwritten is NULL during compile
3954  * time and avoid adding the barrier code completely.
3955  *
3956  * The compiler needs to determine that the object in which a field is about
3957  * to be written is newly allocated, and that no prior store to the same field
3958  * has happened since the allocation.
3959  *
3960  * Returns true if the pre-barrier can be removed
3961  */


4354         } __ end_if();
4355       } __ end_if();
4356     } __ end_if();
4357   } else {
4358     // The Object.clone() intrinsic uses this path if !ReduceInitialCardMarks.
4359     // We don't need a barrier here if the destination is a newly allocated object
4360     // in Eden. Otherwise, GC verification breaks because we assume that cards in Eden
4361     // are set to 'g1_young_gen' (see G1CardTable::verify_g1_young_region()).
4362     assert(!use_ReduceInitialCardMarks(), "can only happen with card marking");
4363     Node* card_val = __ load(__ ctrl(), card_adr, TypeInt::INT, T_BYTE, Compile::AliasIdxRaw);
4364     __ if_then(card_val, BoolTest::ne, young_card); {
4365       g1_mark_card(ideal, card_adr, oop_store, alias_idx, index, index_adr, buffer, tf);
4366     } __ end_if();
4367   }
4368 
4369   // Final sync IdealKit and GraphKit.
4370   final_sync(ideal);
4371 }
4372 #undef __
4373 
4374 #endif // INCLUDE_G1GC
4375 
4376 Node* GraphKit::load_String_length(Node* ctrl, Node* str) {
4377   Node* len = load_array_length(load_String_value(ctrl, str));
4378   Node* coder = load_String_coder(ctrl, str);
4379   // Divide length by 2 if coder is UTF16
4380   return _gvn.transform(new RShiftINode(len, coder));
4381 }
4382 
4383 Node* GraphKit::load_String_value(Node* ctrl, Node* str) {
4384   int value_offset = java_lang_String::value_offset_in_bytes();
4385   const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(),
4386                                                      false, NULL, 0);
4387   const TypePtr* value_field_type = string_type->add_offset(value_offset);
4388   const TypeAryPtr* value_type = TypeAryPtr::make(TypePtr::NotNull,
4389                                                   TypeAry::make(TypeInt::BYTE, TypeInt::POS),
4390                                                   ciTypeArrayKlass::make(T_BYTE), true, 0);
4391   int value_field_idx = C->get_alias_index(value_field_type);
4392   Node* load = make_load(ctrl, basic_plus_adr(str, str, value_offset),
4393                          value_type, T_OBJECT, value_field_idx, MemNode::unordered);
4394   // String.value field is known to be @Stable.


< prev index next >