< prev index next >

src/hotspot/share/gc/shared/c1/cardTableBarrierSetC1.cpp

BarrierSetC1_v3

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 "gc/shared/c1/cardTableBarrierSetC1.hpp"                                                                                    
26 #include "gc/shared/cardTableBarrierSet.hpp"                                                                                         
27 #include "utilities/macros.hpp"                                                                                                      
28 
29 #ifdef ASSERT                                                                                                                        
30 #define __ lir_generator->lir(__FILE__, __LINE__)->                                                                                  
31 #else                                                                                                                                
32 #define __ lir_generator->lir()->                                                                                                    
33 #endif                                                                                                                               
34 
35 void CardTableBarrierSetC1::post_barrier(LIRGenerator *lir_generator, DecoratorSet decorators,                                       
36                                          LIR_OprDesc* addr, LIR_OprDesc* new_val) {                                                  
                                                                                                                                     
37   bool in_heap = (decorators & IN_HEAP) != 0;                                                                                        
38   if (!in_heap) {                                                                                                                    
39     return;                                                                                                                          
40   }                                                                                                                                  
41 
42   BarrierSet* bs = BarrierSet::barrier_set();                                                                                        
43   CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);                                                             
44   CardTable* ct = ctbs->card_table();                                                                                                
45   assert(sizeof(*(ct->byte_map_base())) == sizeof(jbyte), "adjust this code");                                                       
46   LIR_Const* card_table_base = new LIR_Const(ct->byte_map_base());                                                                   
47   if (addr->is_address()) {                                                                                                          
48     LIR_Address* address = addr->as_address_ptr();                                                                                   
49     // ptr cannot be an object because we use this barrier for array card marks                                                      
50     // and addr can point in the middle of an array.                                                                                 
51     LIR_Opr ptr = lir_generator->new_pointer_register();                                                                             
52     if (!address->index()->is_valid() && address->disp() == 0) {                                                                     
53       __ move(address->base(), ptr);                                                                                                 
54     } else {                                                                                                                         
55       assert(address->disp() != max_jint, "lea doesn't support patched addresses!");                                                 
56       __ leal(addr, ptr);                                                                                                            
57     }                                                                                                                                
58     addr = ptr;                                                                                                                      
59   }                                                                                                                                  
60   assert(addr->is_register(), "must be a register at this point");                                                                   
61 
62 #ifdef CARDTABLEBARRIERSET_POST_BARRIER_HELPER                                                                                       
63   CardTableBarrierSet_post_barrier_helper(addr, card_table_base);                                                                    
64 #else                                                                                                                                
65   LIR_Opr tmp = lir_generator->new_pointer_register();                                                                               
66   if (TwoOperandLIRForm) {                                                                                                           
67     __ move(addr, tmp);                                                                                                              
68     __ unsigned_shift_right(tmp, CardTable::card_shift, tmp);                                                                        
69   } else {                                                                                                                           
70     __ unsigned_shift_right(addr, CardTable::card_shift, tmp);                                                                       
71   }                                                                                                                                  
72 
73   LIR_Address* card_addr;                                                                                                            
74   if (lir_generator->can_inline_as_constant(card_table_base)) {                                                                      
75     card_addr = new LIR_Address(tmp, card_table_base->as_jint(), T_BYTE);                                                            
76   } else {                                                                                                                           
77     card_addr = new LIR_Address(tmp, lir_generator->load_constant(card_table_base), T_BYTE);                                         
78   }                                                                                                                                  
79 
80   LIR_Opr dirty = LIR_OprFact::intConst(CardTable::dirty_card_val());                                                                
81   if (UseCondCardMark) {                                                                                                             
82     LIR_Opr cur_value = lir_generator->new_register(T_INT);                                                                          
83     if (ct->scanned_concurrently()) {                                                                                                
84       __ membar_storeload();                                                                                                         
85     }                                                                                                                                
86     __ move(card_addr, cur_value);                                                                                                   
87 
88     LabelObj* L_already_dirty = new LabelObj();                                                                                      
89     __ cmp(lir_cond_equal, cur_value, dirty);                                                                                        
90     __ branch(lir_cond_equal, T_BYTE, L_already_dirty->label());                                                                     
91     __ move(dirty, card_addr);                                                                                                       
92     __ branch_destination(L_already_dirty->label());                                                                                 
93   } else {                                                                                                                           
94     if (ct->scanned_concurrently()) {                                                                                                
95       __ membar_storestore();                                                                                                        
96     }                                                                                                                                
97     __ move(dirty, card_addr);                                                                                                       
98   }                                                                                                                                  
99 #endif                                                                                                                               
100 }                                                                                                                                    

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 "gc/shared/c1/cardTableBarrierSetC1.hpp"
26 #include "gc/shared/cardTableBarrierSet.hpp"
27 #include "utilities/macros.hpp"
28 
29 #ifdef ASSERT
30 #define __ gen->lir(__FILE__, __LINE__)->
31 #else
32 #define __ gen->lir()->
33 #endif
34 
35 void CardTableBarrierSetC1::post_barrier(LIRAccess& access, LIR_OprDesc* addr, LIR_OprDesc* new_val) {
36   DecoratorSet decorators = access.decorators();
37   LIRGenerator* gen = access.gen();
38   bool in_heap = (decorators & IN_HEAP) != 0;
39   if (!in_heap) {
40     return;
41   }
42 
43   BarrierSet* bs = BarrierSet::barrier_set();
44   CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);
45   CardTable* ct = ctbs->card_table();
46   assert(sizeof(*(ct->byte_map_base())) == sizeof(jbyte), "adjust this code");
47   LIR_Const* card_table_base = new LIR_Const(ct->byte_map_base());
48   if (addr->is_address()) {
49     LIR_Address* address = addr->as_address_ptr();
50     // ptr cannot be an object because we use this barrier for array card marks
51     // and addr can point in the middle of an array.
52     LIR_Opr ptr = gen->new_pointer_register();
53     if (!address->index()->is_valid() && address->disp() == 0) {
54       __ move(address->base(), ptr);
55     } else {
56       assert(address->disp() != max_jint, "lea doesn't support patched addresses!");
57       __ leal(addr, ptr);
58     }
59     addr = ptr;
60   }
61   assert(addr->is_register(), "must be a register at this point");
62 
63 #ifdef CARDTABLEBARRIERSET_POST_BARRIER_HELPER
64   CardTableBarrierSet_post_barrier_helper(addr, card_table_base);
65 #else
66   LIR_Opr tmp = gen->new_pointer_register();
67   if (TwoOperandLIRForm) {
68     __ move(addr, tmp);
69     __ unsigned_shift_right(tmp, CardTable::card_shift, tmp);
70   } else {
71     __ unsigned_shift_right(addr, CardTable::card_shift, tmp);
72   }
73 
74   LIR_Address* card_addr;
75   if (gen->can_inline_as_constant(card_table_base)) {
76     card_addr = new LIR_Address(tmp, card_table_base->as_jint(), T_BYTE);
77   } else {
78     card_addr = new LIR_Address(tmp, gen->load_constant(card_table_base), T_BYTE);
79   }
80 
81   LIR_Opr dirty = LIR_OprFact::intConst(CardTable::dirty_card_val());
82   if (UseCondCardMark) {
83     LIR_Opr cur_value = gen->new_register(T_INT);
84     if (ct->scanned_concurrently()) {
85       __ membar_storeload();
86     }
87     __ move(card_addr, cur_value);
88 
89     LabelObj* L_already_dirty = new LabelObj();
90     __ cmp(lir_cond_equal, cur_value, dirty);
91     __ branch(lir_cond_equal, T_BYTE, L_already_dirty->label());
92     __ move(dirty, card_addr);
93     __ branch_destination(L_already_dirty->label());
94   } else {
95     if (ct->scanned_concurrently()) {
96       __ membar_storestore();
97     }
98     __ move(dirty, card_addr);
99   }
100 #endif
101 }
< prev index next >