< prev index next >

src/hotspot/share/opto/graphKit.cpp

G1BarrierSet_merge

7  *                                                                                                                                   
8  * This code is distributed in the hope that it will be useful, but WITHOUT                                                          
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or                                                             
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License                                                             
11  * version 2 for more details (a copy is included in the LICENSE file that                                                           
12  * accompanied this code).                                                                                                           
13  *                                                                                                                                   
14  * You should have received a copy of the GNU General Public License version                                                         
15  * 2 along with this work; if not, write to the Free Software Foundation,                                                            
16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.                                                                     
17  *                                                                                                                                   
18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA                                                           
19  * or visit www.oracle.com if you need additional information or have any                                                            
20  * questions.                                                                                                                        
21  *                                                                                                                                   
22  */                                                                                                                                  
23 
24 #include "precompiled.hpp"                                                                                                           
25 #include "ci/ciUtilities.hpp"                                                                                                        
26 #include "compiler/compileLog.hpp"                                                                                                   
                                                                                                                                     
27 #include "gc/g1/g1CardTable.hpp"                                                                                                     
28 #include "gc/g1/g1SATBCardTableModRefBS.hpp"                                                                                         
29 #include "gc/g1/heapRegion.hpp"                                                                                                      
30 #include "gc/shared/barrierSet.hpp"                                                                                                  
31 #include "gc/shared/cardTable.hpp"                                                                                                   
32 #include "gc/shared/cardTableModRefBS.hpp"                                                                                           
33 #include "gc/shared/collectedHeap.hpp"                                                                                               
34 #include "memory/resourceArea.hpp"                                                                                                   
35 #include "opto/addnode.hpp"                                                                                                          
36 #include "opto/castnode.hpp"                                                                                                         
37 #include "opto/convertnode.hpp"                                                                                                      
38 #include "opto/graphKit.hpp"                                                                                                         
39 #include "opto/idealKit.hpp"                                                                                                         
40 #include "opto/intrinsicnode.hpp"                                                                                                    
41 #include "opto/locknode.hpp"                                                                                                         
42 #include "opto/machnode.hpp"                                                                                                         
43 #include "opto/opaquenode.hpp"                                                                                                       
44 #include "opto/parse.hpp"                                                                                                            
45 #include "opto/rootnode.hpp"                                                                                                         
46 #include "opto/runtime.hpp"                                                                                                          
47 #include "runtime/deoptimization.hpp"                                                                                                

7  *
8  * This code is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11  * version 2 for more details (a copy is included in the LICENSE file that
12  * accompanied this code).
13  *
14  * You should have received a copy of the GNU General Public License version
15  * 2 along with this work; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17  *
18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19  * or visit www.oracle.com if you need additional information or have any
20  * questions.
21  *
22  */
23 
24 #include "precompiled.hpp"
25 #include "ci/ciUtilities.hpp"
26 #include "compiler/compileLog.hpp"
27 #include "gc/g1/g1BarrierSet.hpp"
28 #include "gc/g1/g1CardTable.hpp"

29 #include "gc/g1/heapRegion.hpp"
30 #include "gc/shared/barrierSet.hpp"
31 #include "gc/shared/cardTable.hpp"
32 #include "gc/shared/cardTableModRefBS.hpp"
33 #include "gc/shared/collectedHeap.hpp"
34 #include "memory/resourceArea.hpp"
35 #include "opto/addnode.hpp"
36 #include "opto/castnode.hpp"
37 #include "opto/convertnode.hpp"
38 #include "opto/graphKit.hpp"
39 #include "opto/idealKit.hpp"
40 #include "opto/intrinsicnode.hpp"
41 #include "opto/locknode.hpp"
42 #include "opto/machnode.hpp"
43 #include "opto/opaquenode.hpp"
44 #include "opto/parse.hpp"
45 #include "opto/rootnode.hpp"
46 #include "opto/runtime.hpp"
47 #include "runtime/deoptimization.hpp"

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

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

4331         // load the original value of the card                                                                                       
4332         Node* card_val = __ load(__ ctrl(), card_adr, TypeInt::INT, T_BYTE, Compile::AliasIdxRaw);                                   
4333 
4334         __ if_then(card_val, BoolTest::ne, young_card); {                                                                            
4335           sync_kit(ideal);                                                                                                           
4336           // Use Op_MemBarVolatile to achieve the effect of a StoreLoad barrier.                                                     
4337           insert_mem_bar(Op_MemBarVolatile, oop_store);                                                                              
4338           __ sync_kit(this);                                                                                                         
4339 
4340           Node* card_val_reload = __ load(__ ctrl(), card_adr, TypeInt::INT, T_BYTE, Compile::AliasIdxRaw);                          
4341           __ if_then(card_val_reload, BoolTest::ne, dirty_card); {                                                                   
4342             g1_mark_card(ideal, card_adr, oop_store, alias_idx, index, index_adr, buffer, tf);                                       
4343           } __ end_if();                                                                                                             
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 G1SATBCardTableModRefBS::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 }                                                                                                                                    

4331         // load the original value of the card
4332         Node* card_val = __ load(__ ctrl(), card_adr, TypeInt::INT, T_BYTE, Compile::AliasIdxRaw);
4333 
4334         __ if_then(card_val, BoolTest::ne, young_card); {
4335           sync_kit(ideal);
4336           // Use Op_MemBarVolatile to achieve the effect of a StoreLoad barrier.
4337           insert_mem_bar(Op_MemBarVolatile, oop_store);
4338           __ sync_kit(this);
4339 
4340           Node* card_val_reload = __ load(__ ctrl(), card_adr, TypeInt::INT, T_BYTE, Compile::AliasIdxRaw);
4341           __ if_then(card_val_reload, BoolTest::ne, dirty_card); {
4342             g1_mark_card(ideal, card_adr, oop_store, alias_idx, index, index_adr, buffer, tf);
4343           } __ end_if();
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 }
< prev index next >