< prev index next >

src/hotspot/share/c1/c1_LIRGenerator.cpp

BarrierSetC1_v3

BarrierSetC1_v2

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 "c1/c1_Compilation.hpp"                                                                                                     
26 #include "c1/c1_Defs.hpp"                                                                                                            
27 #include "c1/c1_FrameMap.hpp"                                                                                                        
28 #include "c1/c1_Instruction.hpp"                                                                                                     
29 #include "c1/c1_LIRAssembler.hpp"                                                                                                    
30 #include "c1/c1_LIRGenerator.hpp"                                                                                                    
31 #include "c1/c1_ValueStack.hpp"                                                                                                      
32 #include "ci/ciArrayKlass.hpp"                                                                                                       
33 #include "ci/ciInstance.hpp"                                                                                                         
34 #include "ci/ciObjArray.hpp"                                                                                                         
35 #include "ci/ciUtilities.hpp"                                                                                                        
36 #include "gc/shared/cardTable.hpp"                                                                                                   
37 #include "gc/shared/c1/cardTableBarrierSetC1.hpp"                                                                                    
38 #include "gc/shared/c1/barrierSetC1.hpp"                                                                                             
39 #include "gc/shared/c1/modRefBarrierSetC1.hpp"                                                                                       
40 #include "runtime/arguments.hpp"                                                                                                     
41 #include "runtime/sharedRuntime.hpp"                                                                                                 
42 #include "runtime/stubRoutines.hpp"                                                                                                  
43 #include "runtime/vm_version.hpp"                                                                                                    
44 #include "utilities/bitMap.inline.hpp"                                                                                               
45 #include "utilities/macros.hpp"                                                                                                      
46 #ifdef TRACE_HAVE_INTRINSICS                                                                                                         
47 #include "trace/traceMacros.hpp"                                                                                                     
48 #endif                                                                                                                               
49 
50 #ifdef ASSERT                                                                                                                        
51 #define __ gen()->lir(__FILE__, __LINE__)->                                                                                          
52 #else                                                                                                                                
53 #define __ gen()->lir()->                                                                                                            
54 #endif                                                                                                                               
55 
56 #ifndef PATCHED_ADDR                                                                                                                 
57 #define PATCHED_ADDR  (max_jint)                                                                                                     
58 #endif                                                                                                                               

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 "c1/c1_Compilation.hpp"
26 #include "c1/c1_Defs.hpp"
27 #include "c1/c1_FrameMap.hpp"
28 #include "c1/c1_Instruction.hpp"
29 #include "c1/c1_LIRAssembler.hpp"
30 #include "c1/c1_LIRGenerator.hpp"
31 #include "c1/c1_ValueStack.hpp"
32 #include "ci/ciArrayKlass.hpp"
33 #include "ci/ciInstance.hpp"
34 #include "ci/ciObjArray.hpp"
35 #include "ci/ciUtilities.hpp"
36 #include "gc/shared/barrierSet.hpp"

37 #include "gc/shared/c1/barrierSetC1.hpp"

38 #include "runtime/arguments.hpp"
39 #include "runtime/sharedRuntime.hpp"
40 #include "runtime/stubRoutines.hpp"
41 #include "runtime/vm_version.hpp"
42 #include "utilities/bitMap.inline.hpp"
43 #include "utilities/macros.hpp"
44 #ifdef TRACE_HAVE_INTRINSICS
45 #include "trace/traceMacros.hpp"
46 #endif
47 
48 #ifdef ASSERT
49 #define __ gen()->lir(__FILE__, __LINE__)->
50 #else
51 #define __ gen()->lir()->
52 #endif
53 
54 #ifndef PATCHED_ADDR
55 #define PATCHED_ADDR  (max_jint)
56 #endif

1221 // Examble: ref.get()                                                                                                                
1222 // Combination of LoadField and g1 pre-write barrier                                                                                 
1223 void LIRGenerator::do_Reference_get(Intrinsic* x) {                                                                                  
1224 
1225   const int referent_offset = java_lang_ref_Reference::referent_offset;                                                              
1226   guarantee(referent_offset > 0, "referent offset not initialized");                                                                 
1227 
1228   assert(x->number_of_arguments() == 1, "wrong type");                                                                               
1229 
1230   LIRItem reference(x->argument_at(0), this);                                                                                        
1231   reference.load_item();                                                                                                             
1232 
1233   // need to perform the null check on the reference objecy                                                                          
1234   CodeEmitInfo* info = NULL;                                                                                                         
1235   if (x->needs_null_check()) {                                                                                                       
1236     info = state_for(x);                                                                                                             
1237   }                                                                                                                                  
1238 
1239   LIR_Opr result = rlock_result(x, T_OBJECT);                                                                                        
1240   access_load_at(IN_HEAP | ON_WEAK_OOP_REF, T_OBJECT,                                                                                
1241                  reference, LIR_OprFact::intConst(referent_offset), result,                                                          
1242                  NULL, NULL);                                                                                                        
1243 }                                                                                                                                    
1244 
1245 // Example: clazz.isInstance(object)                                                                                                 
1246 void LIRGenerator::do_isInstance(Intrinsic* x) {                                                                                     
1247   assert(x->number_of_arguments() == 2, "wrong type");                                                                               
1248 
1249   // TODO could try to substitute this node with an equivalent InstanceOf                                                            
1250   // if clazz is known to be a constant Class. This will pick up newly found                                                         
1251   // constants after HIR construction. I'll leave this to a future change.                                                           
1252 
1253   // as a first cut, make a simple leaf call to runtime to stay platform independent.                                                
1254   // could follow the aastore example in a future change.                                                                            
1255 
1256   LIRItem clazz(x->argument_at(0), this);                                                                                            
1257   LIRItem object(x->argument_at(1), this);                                                                                           
1258   clazz.load_item();                                                                                                                 
1259   object.load_item();                                                                                                                
1260   LIR_Opr result = rlock_result(x);                                                                                                  
1261 

1219 // Examble: ref.get()
1220 // Combination of LoadField and g1 pre-write barrier
1221 void LIRGenerator::do_Reference_get(Intrinsic* x) {
1222 
1223   const int referent_offset = java_lang_ref_Reference::referent_offset;
1224   guarantee(referent_offset > 0, "referent offset not initialized");
1225 
1226   assert(x->number_of_arguments() == 1, "wrong type");
1227 
1228   LIRItem reference(x->argument_at(0), this);
1229   reference.load_item();
1230 
1231   // need to perform the null check on the reference objecy
1232   CodeEmitInfo* info = NULL;
1233   if (x->needs_null_check()) {
1234     info = state_for(x);
1235   }
1236 
1237   LIR_Opr result = rlock_result(x, T_OBJECT);
1238   access_load_at(IN_HEAP | ON_WEAK_OOP_REF, T_OBJECT,
1239                  reference, LIR_OprFact::intConst(referent_offset), result);

1240 }
1241 
1242 // Example: clazz.isInstance(object)
1243 void LIRGenerator::do_isInstance(Intrinsic* x) {
1244   assert(x->number_of_arguments() == 2, "wrong type");
1245 
1246   // TODO could try to substitute this node with an equivalent InstanceOf
1247   // if clazz is known to be a constant Class. This will pick up newly found
1248   // constants after HIR construction. I'll leave this to a future change.
1249 
1250   // as a first cut, make a simple leaf call to runtime to stay platform independent.
1251   // could follow the aastore example in a future change.
1252 
1253   LIRItem clazz(x->argument_at(0), this);
1254   LIRItem object(x->argument_at(1), this);
1255   clazz.load_item();
1256   object.load_item();
1257   LIR_Opr result = rlock_result(x);
1258 

1435   _reg_for_constants.append(result);                                                                                                 
1436   return result;                                                                                                                     
1437 }                                                                                                                                    
1438 
1439 //------------------------field access--------------------------------------                                                         
1440 
1441 void LIRGenerator::do_CompareAndSwap(Intrinsic* x, ValueType* type) {                                                                
1442   assert(x->number_of_arguments() == 4, "wrong type");                                                                               
1443   LIRItem obj   (x->argument_at(0), this);  // object                                                                                
1444   LIRItem offset(x->argument_at(1), this);  // offset of field                                                                       
1445   LIRItem cmp   (x->argument_at(2), this);  // value to compare with field                                                           
1446   LIRItem val   (x->argument_at(3), this);  // replace field with val if matches cmp                                                 
1447   assert(obj.type()->tag() == objectTag, "invalid type");                                                                            
1448 
1449   // In 64bit the type can be long, sparc doesn't have this assert                                                                   
1450   // assert(offset.type()->tag() == intTag, "invalid type");                                                                         
1451 
1452   assert(cmp.type()->tag() == type->tag(), "invalid type");                                                                          
1453   assert(val.type()->tag() == type->tag(), "invalid type");                                                                          
1454 
1455   DecoratorSet decorators = IN_HEAP | MO_SEQ_CST;                                                                                    
1456   LIR_Opr result = access_atomic_cmpxchg_at(decorators, as_BasicType(type),                                                          
1457                                             obj, offset, cmp, val);                                                                  
1458   set_result(x, result);                                                                                                             
1459 }                                                                                                                                    
1460 
1461 // Comment copied form templateTable_i486.cpp                                                                                        
1462 // ----------------------------------------------------------------------------                                                      
1463 // Volatile variables demand their effects be made known to all CPU's in                                                             
1464 // order.  Store buffers on most chips allow reads & writes to reorder; the                                                          
1465 // JMM's ReadAfterWrite.java test fails in -Xint mode without some kind of                                                           
1466 // memory barrier (i.e., it's not sufficient that the interpreter does not                                                           
1467 // reorder volatile references, the hardware also must not reorder them).                                                            
1468 //                                                                                                                                   
1469 // According to the new Java Memory Model (JMM):                                                                                     
1470 // (1) All volatiles are serialized wrt to each other.                                                                               
1471 // ALSO reads & writes act as aquire & release, so:                                                                                  
1472 // (2) A read cannot let unrelated NON-volatile memory refs that happen after                                                        
1473 // the read float up to before the read.  It's OK for non-volatile memory refs                                                       
1474 // that happen before the volatile read to float down below it.                                                                      
1475 // (3) Similar a volatile write cannot let unrelated NON-volatile memory refs                                                        

1432   _reg_for_constants.append(result);
1433   return result;
1434 }
1435 
1436 //------------------------field access--------------------------------------
1437 
1438 void LIRGenerator::do_CompareAndSwap(Intrinsic* x, ValueType* type) {
1439   assert(x->number_of_arguments() == 4, "wrong type");
1440   LIRItem obj   (x->argument_at(0), this);  // object
1441   LIRItem offset(x->argument_at(1), this);  // offset of field
1442   LIRItem cmp   (x->argument_at(2), this);  // value to compare with field
1443   LIRItem val   (x->argument_at(3), this);  // replace field with val if matches cmp
1444   assert(obj.type()->tag() == objectTag, "invalid type");
1445 
1446   // In 64bit the type can be long, sparc doesn't have this assert
1447   // assert(offset.type()->tag() == intTag, "invalid type");
1448 
1449   assert(cmp.type()->tag() == type->tag(), "invalid type");
1450   assert(val.type()->tag() == type->tag(), "invalid type");
1451 
1452   LIR_Opr result = access_atomic_cmpxchg_at(IN_HEAP, as_BasicType(type),

1453                                             obj, offset, cmp, val);
1454   set_result(x, result);
1455 }
1456 
1457 // Comment copied form templateTable_i486.cpp
1458 // ----------------------------------------------------------------------------
1459 // Volatile variables demand their effects be made known to all CPU's in
1460 // order.  Store buffers on most chips allow reads & writes to reorder; the
1461 // JMM's ReadAfterWrite.java test fails in -Xint mode without some kind of
1462 // memory barrier (i.e., it's not sufficient that the interpreter does not
1463 // reorder volatile references, the hardware also must not reorder them).
1464 //
1465 // According to the new Java Memory Model (JMM):
1466 // (1) All volatiles are serialized wrt to each other.
1467 // ALSO reads & writes act as aquire & release, so:
1468 // (2) A read cannot let unrelated NON-volatile memory refs that happen after
1469 // the read float up to before the read.  It's OK for non-volatile memory refs
1470 // that happen before the volatile read to float down below it.
1471 // (3) Similar a volatile write cannot let unrelated NON-volatile memory refs

1532   }                                                                                                                                  
1533 #endif                                                                                                                               
1534 
1535   if (x->needs_null_check() &&                                                                                                       
1536       (needs_patching ||                                                                                                             
1537        MacroAssembler::needs_explicit_null_check(x->offset()))) {                                                                    
1538     // Emit an explicit null check because the offset is too large.                                                                  
1539     // If the class is not loaded and the object is NULL, we need to deoptimize to throw a                                           
1540     // NoClassDefFoundError in the interpreter instead of an implicit NPE from compiled code.                                        
1541     __ null_check(object.result(), new CodeEmitInfo(info), /* deoptimize */ needs_patching);                                         
1542   }                                                                                                                                  
1543 
1544   DecoratorSet decorators = IN_HEAP;                                                                                                 
1545   if (is_volatile) {                                                                                                                 
1546     decorators |= MO_SEQ_CST;                                                                                                        
1547   }                                                                                                                                  
1548   if (needs_patching) {                                                                                                              
1549     decorators |= C1_NEEDS_PATCHING;                                                                                                 
1550   }                                                                                                                                  
1551 
1552   access_store_at(decorators, field_type, object, LIR_OprFact::intConst(x->offset()), value.result(), info ? new CodeEmitInfo(info) :
                                                                                                                                     
1553 }                                                                                                                                    
1554 
1555 void LIRGenerator::do_StoreIndexed(StoreIndexed* x) {                                                                                
1556   assert(x->is_pinned(),"");                                                                                                         
1557   bool needs_range_check = x->compute_needs_range_check();                                                                           
1558   bool use_length = x->length() != NULL;                                                                                             
1559   bool obj_store = x->elt_type() == T_ARRAY || x->elt_type() == T_OBJECT;                                                            
1560   bool needs_store_check = obj_store && (x->value()->as_Constant() == NULL ||                                                        
1561                                          !get_jobject_constant(x->value())->is_null_object() ||                                      
1562                                          x->should_profile());                                                                       
1563 
1564   LIRItem array(x->array(), this);                                                                                                   
1565   LIRItem index(x->index(), this);                                                                                                   
1566   LIRItem value(x->value(), this);                                                                                                   
1567   LIRItem length(this);                                                                                                              
1568 
1569   array.load_item();                                                                                                                 
1570   index.load_nonconstant();                                                                                                          
1571 

1528   }
1529 #endif
1530 
1531   if (x->needs_null_check() &&
1532       (needs_patching ||
1533        MacroAssembler::needs_explicit_null_check(x->offset()))) {
1534     // Emit an explicit null check because the offset is too large.
1535     // If the class is not loaded and the object is NULL, we need to deoptimize to throw a
1536     // NoClassDefFoundError in the interpreter instead of an implicit NPE from compiled code.
1537     __ null_check(object.result(), new CodeEmitInfo(info), /* deoptimize */ needs_patching);
1538   }
1539 
1540   DecoratorSet decorators = IN_HEAP;
1541   if (is_volatile) {
1542     decorators |= MO_SEQ_CST;
1543   }
1544   if (needs_patching) {
1545     decorators |= C1_NEEDS_PATCHING;
1546   }
1547 
1548   access_store_at(decorators, field_type, object, LIR_OprFact::intConst(x->offset()),
1549                   value.result(), info != NULL ? new CodeEmitInfo(info) : NULL, info);
1550 }
1551 
1552 void LIRGenerator::do_StoreIndexed(StoreIndexed* x) {
1553   assert(x->is_pinned(),"");
1554   bool needs_range_check = x->compute_needs_range_check();
1555   bool use_length = x->length() != NULL;
1556   bool obj_store = x->elt_type() == T_ARRAY || x->elt_type() == T_OBJECT;
1557   bool needs_store_check = obj_store && (x->value()->as_Constant() == NULL ||
1558                                          !get_jobject_constant(x->value())->is_null_object() ||
1559                                          x->should_profile());
1560 
1561   LIRItem array(x->array(), this);
1562   LIRItem index(x->index(), this);
1563   LIRItem value(x->value(), this);
1564   LIRItem length(this);
1565 
1566   array.load_item();
1567   index.load_nonconstant();
1568 

1595     if (use_length) {                                                                                                                
1596       __ cmp(lir_cond_belowEqual, length.result(), index.result());                                                                  
1597       __ branch(lir_cond_belowEqual, T_INT, new RangeCheckStub(range_check_info, index.result()));                                   
1598     } else {                                                                                                                         
1599       array_range_check(array.result(), index.result(), null_check_info, range_check_info);                                          
1600       // range_check also does the null check                                                                                        
1601       null_check_info = NULL;                                                                                                        
1602     }                                                                                                                                
1603   }                                                                                                                                  
1604 
1605   if (GenerateArrayStoreCheck && needs_store_check) {                                                                                
1606     CodeEmitInfo* store_check_info = new CodeEmitInfo(range_check_info);                                                             
1607     array_store_check(value.result(), array.result(), store_check_info, x->profiled_method(), x->profiled_bci());                    
1608   }                                                                                                                                  
1609 
1610   DecoratorSet decorators = IN_HEAP | IN_HEAP_ARRAY;                                                                                 
1611   if (x->check_boolean()) {                                                                                                          
1612     decorators |= C1_MASK_BOOLEAN;                                                                                                   
1613   }                                                                                                                                  
1614 
1615   access_store_at(decorators, x->elt_type(), array, index.result(), value.result(), NULL, null_check_info);                          
                                                                                                                                     
1616 }                                                                                                                                    
1617 
1618 void LIRGenerator::access_load_at(DecoratorSet decorators, BasicType type,                                                           
1619                                   LIRItem& base, LIR_Opr offset, LIR_Opr result,                                                     
1620                                   CodeEmitInfo* patch_info, CodeEmitInfo* load_emit_info) {                                          
1621   BarrierSetC1 *bs = BarrierSet::barrier_set()->barrier_set_c1();                                                                    
1622   bool as_raw = (decorators & AS_RAW) != 0;                                                                                          
1623   if (as_raw) {                                                                                                                      
1624     bs->BarrierSetC1::load_at(this, decorators, type,                                                                                
1625                               base, offset, result, patch_info, load_emit_info);                                                     
1626   } else {                                                                                                                           
1627     bs->load_at(this, decorators, type,                                                                                              
1628                 base, offset, result, patch_info, load_emit_info);                                                                   
1629   }                                                                                                                                  
1630 }                                                                                                                                    
1631 
1632 void LIRGenerator::access_store_at(DecoratorSet decorators, BasicType type,                                                          
1633                                    LIRItem& base, LIR_Opr offset, LIR_Opr value,                                                     
1634                                    CodeEmitInfo* patch_info, CodeEmitInfo* store_emit_info) {                                        
1635   BarrierSetC1 *bs = BarrierSet::barrier_set()->barrier_set_c1();                                                                    
1636   bool as_raw = (decorators & AS_RAW) != 0;                                                                                          
1637   if (as_raw) {                                                                                                                      
1638     bs->BarrierSetC1::store_at(this, decorators, type,                                                                               
1639                                base, offset, value, patch_info, store_emit_info);                                                    
1640   } else {                                                                                                                           
1641     bs->store_at(this, decorators, type,                                                                                             
1642                  base, offset, value, patch_info, store_emit_info);                                                                  
1643   }                                                                                                                                  
1644 }                                                                                                                                    
1645 
1646 LIR_Opr LIRGenerator::access_atomic_cmpxchg_at(DecoratorSet decorators, BasicType type,                                              
1647                                                LIRItem& base, LIRItem& offset, LIRItem& cmp_value, LIRItem& new_value) {             
1648   BarrierSetC1 *bs = BarrierSet::barrier_set()->barrier_set_c1();                                                                    
1649   bool as_raw = (decorators & AS_RAW) != 0;                                                                                          
1650   if (as_raw) {                                                                                                                      
1651     return bs->BarrierSetC1::atomic_cmpxchg_at(this, decorators, type,                                                               
1652                                                base, offset, cmp_value, new_value);                                                  
1653   } else {                                                                                                                           
1654     return bs->atomic_cmpxchg_at(this, decorators, type,                                                                             
1655                                  base, offset, cmp_value, new_value);                                                                
1656   }                                                                                                                                  
1657 }                                                                                                                                    
1658 
1659 LIR_Opr LIRGenerator::access_atomic_xchg_at(DecoratorSet decorators, BasicType type,                                                 
1660                                             LIRItem& base, LIRItem& offset, LIRItem& value) {                                        
1661   BarrierSetC1 *bs = BarrierSet::barrier_set()->barrier_set_c1();                                                                    
1662   bool as_raw = (decorators & AS_RAW) != 0;                                                                                          
1663   if (as_raw) {                                                                                                                      
1664     return bs->BarrierSetC1::atomic_xchg(this, decorators, type,                                                                     
1665                                          base, offset, value);                                                                       
1666   } else {                                                                                                                           
1667     return bs->atomic_xchg(this, decorators, type,                                                                                   
1668                            base, offset, value);                                                                                     
1669   }                                                                                                                                  
1670 }                                                                                                                                    
1671 
1672 LIR_Opr LIRGenerator::access_atomic_add_at(DecoratorSet decorators, BasicType type,                                                  
1673                                            LIRItem& base, LIRItem& offset, LIRItem& value) {                                         
1674   BarrierSetC1 *bs = BarrierSet::barrier_set()->barrier_set_c1();                                                                    
1675   bool as_raw = (decorators & AS_RAW) != 0;                                                                                          
1676   if (as_raw) {                                                                                                                      
1677     return bs->BarrierSetC1::atomic_add_at(this, decorators, type,                                                                   
1678                                            base, offset, value);                                                                     
1679   } else {                                                                                                                           
1680     return bs->atomic_add_at(this, decorators, type,                                                                                 
1681                              base, offset, value);                                                                                   
1682   }                                                                                                                                  
1683 }                                                                                                                                    
1684 
1685 void LIRGenerator::do_LoadField(LoadField* x) {                                                                                      
1686   bool needs_patching = x->needs_patching();                                                                                         
1687   bool is_volatile = x->field()->is_volatile();                                                                                      
1688   BasicType field_type = x->field_type();                                                                                            
1689 
1690   CodeEmitInfo* info = NULL;                                                                                                         
1691   if (needs_patching) {                                                                                                              
1692     assert(x->explicit_null_check() == NULL, "can't fold null check into patching field access");                                    
1693     info = state_for(x, x->state_before());                                                                                          
1694   } else if (x->needs_null_check()) {                                                                                                
1695     NullCheck* nc = x->explicit_null_check();                                                                                        
1696     if (nc == NULL) {                                                                                                                
1697       info = state_for(x);                                                                                                           
1698     } else {                                                                                                                         
1699       info = state_for(nc);                                                                                                          
1700     }                                                                                                                                

1592     if (use_length) {
1593       __ cmp(lir_cond_belowEqual, length.result(), index.result());
1594       __ branch(lir_cond_belowEqual, T_INT, new RangeCheckStub(range_check_info, index.result()));
1595     } else {
1596       array_range_check(array.result(), index.result(), null_check_info, range_check_info);
1597       // range_check also does the null check
1598       null_check_info = NULL;
1599     }
1600   }
1601 
1602   if (GenerateArrayStoreCheck && needs_store_check) {
1603     CodeEmitInfo* store_check_info = new CodeEmitInfo(range_check_info);
1604     array_store_check(value.result(), array.result(), store_check_info, x->profiled_method(), x->profiled_bci());
1605   }
1606 
1607   DecoratorSet decorators = IN_HEAP | IN_HEAP_ARRAY;
1608   if (x->check_boolean()) {
1609     decorators |= C1_MASK_BOOLEAN;
1610   }
1611 
1612   access_store_at(decorators, x->elt_type(), array, index.result(), value.result(),
1613                   NULL, null_check_info);
1614 }
1615 
1616 void LIRGenerator::access_load_at(DecoratorSet decorators, BasicType type,
1617                                   LIRItem& base, LIR_Opr offset, LIR_Opr result,
1618                                   CodeEmitInfo* patch_info, CodeEmitInfo* load_emit_info) {
1619   LIRAccess access(this, decorators, base, offset, type, patch_info, load_emit_info);
1620   if (access.is_raw()) {
1621     _barrier_set->BarrierSetC1::load_at(access, result);


1622   } else {
1623     _barrier_set->load_at(access, result);

1624   }
1625 }
1626 
1627 void LIRGenerator::access_store_at(DecoratorSet decorators, BasicType type,
1628                                    LIRItem& base, LIR_Opr offset, LIR_Opr value,
1629                                    CodeEmitInfo* patch_info, CodeEmitInfo* store_emit_info) {
1630   LIRAccess access(this, decorators, base, offset, type, patch_info, store_emit_info);
1631   if (access.is_raw()) {
1632     _barrier_set->BarrierSetC1::store_at(access, value);


1633   } else {
1634     _barrier_set->store_at(access, value);

1635   }
1636 }
1637 
1638 LIR_Opr LIRGenerator::access_atomic_cmpxchg_at(DecoratorSet decorators, BasicType type,
1639                                                LIRItem& base, LIRItem& offset, LIRItem& cmp_value, LIRItem& new_value) {
1640   // Atomic operations are SEQ_CST by default
1641   decorators |= ((decorators & MO_DECORATOR_MASK) != 0) ? MO_SEQ_CST : 0;
1642   LIRAccess access(this, decorators, base, offset, type);
1643   if (access.is_raw()) {
1644     return _barrier_set->BarrierSetC1::atomic_cmpxchg_at(access, cmp_value, new_value);
1645   } else {
1646     return _barrier_set->atomic_cmpxchg_at(access, cmp_value, new_value);

1647   }
1648 }
1649 
1650 LIR_Opr LIRGenerator::access_atomic_xchg_at(DecoratorSet decorators, BasicType type,
1651                                             LIRItem& base, LIRItem& offset, LIRItem& value) {
1652   // Atomic operations are SEQ_CST by default
1653   decorators |= ((decorators & MO_DECORATOR_MASK) != 0) ? MO_SEQ_CST : 0;
1654   LIRAccess access(this, decorators, base, offset, type);
1655   if (access.is_raw()) {
1656     return _barrier_set->BarrierSetC1::atomic_xchg(access, value);
1657   } else {
1658     return _barrier_set->atomic_xchg(access, value);

1659   }
1660 }
1661 
1662 LIR_Opr LIRGenerator::access_atomic_add_at(DecoratorSet decorators, BasicType type,
1663                                            LIRItem& base, LIRItem& offset, LIRItem& value) {
1664   // Atomic operations are SEQ_CST by default
1665   decorators |= ((decorators & MO_DECORATOR_MASK) != 0) ? MO_SEQ_CST : 0;
1666   LIRAccess access(this, decorators, base, offset, type);
1667   if (access.is_raw()) {
1668     return _barrier_set->BarrierSetC1::atomic_add_at(access, value);
1669   } else {
1670     return _barrier_set->atomic_add_at(access, value);

1671   }
1672 }
1673 
1674 void LIRGenerator::do_LoadField(LoadField* x) {
1675   bool needs_patching = x->needs_patching();
1676   bool is_volatile = x->field()->is_volatile();
1677   BasicType field_type = x->field_type();
1678 
1679   CodeEmitInfo* info = NULL;
1680   if (needs_patching) {
1681     assert(x->explicit_null_check() == NULL, "can't fold null check into patching field access");
1682     info = state_for(x, x->state_before());
1683   } else if (x->needs_null_check()) {
1684     NullCheck* nc = x->explicit_null_check();
1685     if (nc == NULL) {
1686       info = state_for(x);
1687     } else {
1688       info = state_for(nc);
1689     }

2140   LIRItem src(x->object(), this);                                                                                                    
2141   LIRItem off(x->offset(), this);                                                                                                    
2142 
2143   off.load_item();                                                                                                                   
2144   src.load_item();                                                                                                                   
2145 
2146   DecoratorSet decorators = IN_HEAP;                                                                                                 
2147 
2148   if (x->is_volatile()) {                                                                                                            
2149     decorators |= MO_SEQ_CST;                                                                                                        
2150   }                                                                                                                                  
2151   if (type == T_BOOLEAN) {                                                                                                           
2152     decorators |= C1_MASK_BOOLEAN;                                                                                                   
2153   }                                                                                                                                  
2154   if (type == T_ARRAY || type == T_OBJECT) {                                                                                         
2155     decorators |= ON_UNKNOWN_OOP_REF;                                                                                                
2156   }                                                                                                                                  
2157 
2158   LIR_Opr result = rlock_result(x, type);                                                                                            
2159   access_load_at(decorators, type,                                                                                                   
2160                  src, off.result(), result,                                                                                          
2161                  NULL, NULL);                                                                                                        
2162 }                                                                                                                                    
2163 
2164 
2165 void LIRGenerator::do_UnsafePutObject(UnsafePutObject* x) {                                                                          
2166   BasicType type = x->basic_type();                                                                                                  
2167   LIRItem src(x->object(), this);                                                                                                    
2168   LIRItem off(x->offset(), this);                                                                                                    
2169   LIRItem data(x->value(), this);                                                                                                    
2170 
2171   src.load_item();                                                                                                                   
2172   if (type == T_BOOLEAN || type == T_BYTE) {                                                                                         
2173     data.load_byte_item();                                                                                                           
2174   } else {                                                                                                                           
2175     data.load_item();                                                                                                                
2176   }                                                                                                                                  
2177   off.load_item();                                                                                                                   
2178 
2179   set_no_result(x);                                                                                                                  
2180 
2181   DecoratorSet decorators = IN_HEAP;                                                                                                 
2182   if (type == T_ARRAY || type == T_OBJECT) {                                                                                         
2183     decorators |= ON_UNKNOWN_OOP_REF;                                                                                                
2184   }                                                                                                                                  
2185   if (x->is_volatile()) {                                                                                                            
2186     decorators |= MO_SEQ_CST;                                                                                                        
2187   }                                                                                                                                  
2188   access_store_at(decorators, type, src, off.result(), data.result(), NULL, NULL);                                                   
2189 }                                                                                                                                    
2190 
2191 void LIRGenerator::do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) {                                                              
2192   BasicType type = x->basic_type();                                                                                                  
2193   LIRItem src(x->object(), this);                                                                                                    
2194   LIRItem off(x->offset(), this);                                                                                                    
2195   LIRItem value(x->value(), this);                                                                                                   
2196 
2197   DecoratorSet decorators = IN_HEAP | MO_SEQ_CST;                                                                                    
2198 
2199   if (type == T_ARRAY || type == T_OBJECT) {                                                                                         
2200     decorators |= ON_UNKNOWN_OOP_REF;                                                                                                
2201   }                                                                                                                                  
2202 
2203   LIR_Opr result;                                                                                                                    
2204   if (x->is_add()) {                                                                                                                 
2205     result = access_atomic_add_at(decorators, type, src, off, value);                                                                
2206   } else {                                                                                                                           
2207     result = access_atomic_xchg_at(decorators, type, src, off, value);                                                               

2129   LIRItem src(x->object(), this);
2130   LIRItem off(x->offset(), this);
2131 
2132   off.load_item();
2133   src.load_item();
2134 
2135   DecoratorSet decorators = IN_HEAP;
2136 
2137   if (x->is_volatile()) {
2138     decorators |= MO_SEQ_CST;
2139   }
2140   if (type == T_BOOLEAN) {
2141     decorators |= C1_MASK_BOOLEAN;
2142   }
2143   if (type == T_ARRAY || type == T_OBJECT) {
2144     decorators |= ON_UNKNOWN_OOP_REF;
2145   }
2146 
2147   LIR_Opr result = rlock_result(x, type);
2148   access_load_at(decorators, type,
2149                  src, off.result(), result);

2150 }
2151 
2152 
2153 void LIRGenerator::do_UnsafePutObject(UnsafePutObject* x) {
2154   BasicType type = x->basic_type();
2155   LIRItem src(x->object(), this);
2156   LIRItem off(x->offset(), this);
2157   LIRItem data(x->value(), this);
2158 
2159   src.load_item();
2160   if (type == T_BOOLEAN || type == T_BYTE) {
2161     data.load_byte_item();
2162   } else {
2163     data.load_item();
2164   }
2165   off.load_item();
2166 
2167   set_no_result(x);
2168 
2169   DecoratorSet decorators = IN_HEAP;
2170   if (type == T_ARRAY || type == T_OBJECT) {
2171     decorators |= ON_UNKNOWN_OOP_REF;
2172   }
2173   if (x->is_volatile()) {
2174     decorators |= MO_SEQ_CST;
2175   }
2176   access_store_at(decorators, type, src, off.result(), data.result());
2177 }
2178 
2179 void LIRGenerator::do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) {
2180   BasicType type = x->basic_type();
2181   LIRItem src(x->object(), this);
2182   LIRItem off(x->offset(), this);
2183   LIRItem value(x->value(), this);
2184 
2185   DecoratorSet decorators = IN_HEAP | MO_SEQ_CST;
2186 
2187   if (type == T_ARRAY || type == T_OBJECT) {
2188     decorators |= ON_UNKNOWN_OOP_REF;
2189   }
2190 
2191   LIR_Opr result;
2192   if (x->is_add()) {
2193     result = access_atomic_add_at(decorators, type, src, off, value);
2194   } else {
2195     result = access_atomic_xchg_at(decorators, type, src, off, value);
< prev index next >