< prev index next >

src/hotspot/share/oops/oop.hpp

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_OOP_HPP
  26 #define SHARE_VM_OOPS_OOP_HPP
  27 
  28 #include "gc/shared/barrierSet.hpp"
  29 #include "memory/iterator.hpp"
  30 #include "memory/memRegion.hpp"
  31 #include "oops/access.hpp"
  32 #include "oops/metadata.hpp"
  33 #include "runtime/atomic.hpp"
  34 #include "utilities/macros.hpp"
  35 
  36 // oopDesc is the top baseclass for objects classes. The {name}Desc classes describe
  37 // the format of Java objects so the fields can be accessed from C++.
  38 // oopDesc is abstract.
  39 // (see oopHierarchy for complete oop class hierarchy)
  40 //
  41 // no virtual functions allowed
  42 
  43 extern bool always_do_update_barrier;
  44 
  45 // Forward declarations.
  46 class OopClosure;
  47 class ScanClosure;
  48 class FastScanClosure;


 136   template <class T> inline T* obj_field_addr_raw(int offset) const;
 137 
 138   template <typename T> inline size_t field_offset(T* p) const;
 139 
 140   // Standard compare function returns negative value if o1 < o2
 141   //                                   0              if o1 == o2
 142   //                                   positive value if o1 > o2
 143   inline static int  compare(oop o1, oop o2) {
 144     void* o1_addr = (void*)o1;
 145     void* o2_addr = (void*)o2;
 146     if (o1_addr < o2_addr) {
 147       return -1;
 148     } else if (o1_addr > o2_addr) {
 149       return 1;
 150     } else {
 151       return 0;
 152     }
 153   }
 154 
 155   inline static bool equals(oop o1, oop o2) { return Access<>::equals(o1, o2); }
 156 
 157   inline static bool safe_equals(oop o1, oop o2) {
 158 #ifdef ASSERT
 159     BarrierSet::barrier_set()->verify_safe_oop(o1);
 160     BarrierSet::barrier_set()->verify_safe_oop(o2);
 161 #endif
 162     return unsafe_equals(o1, o2);
 163   }
 164 
 165   inline static bool unsafe_equals(oop o1, oop o2) {
 166 #ifdef CHECK_UNHANDLED_OOPS
 167     return o1.obj() == o2.obj();
 168 #else
 169     return o1 == o2;
 170 #endif
 171   }
 172 
 173   // Access to fields in a instanceOop through these methods.
 174   template <DecoratorSet decorator>
 175   oop obj_field_access(int offset) const;
 176   oop obj_field(int offset) const;
 177   void obj_field_put(int offset, oop value);
 178   void obj_field_put_raw(int offset, oop value);
 179   void obj_field_put_volatile(int offset, oop value);
 180 
 181   Metadata* metadata_field(int offset) const;
 182   void metadata_field_put(int offset, Metadata* value);
 183 




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

  28 #include "memory/iterator.hpp"
  29 #include "memory/memRegion.hpp"
  30 #include "oops/access.hpp"
  31 #include "oops/metadata.hpp"
  32 #include "runtime/atomic.hpp"
  33 #include "utilities/macros.hpp"
  34 
  35 // oopDesc is the top baseclass for objects classes. The {name}Desc classes describe
  36 // the format of Java objects so the fields can be accessed from C++.
  37 // oopDesc is abstract.
  38 // (see oopHierarchy for complete oop class hierarchy)
  39 //
  40 // no virtual functions allowed
  41 
  42 extern bool always_do_update_barrier;
  43 
  44 // Forward declarations.
  45 class OopClosure;
  46 class ScanClosure;
  47 class FastScanClosure;


 135   template <class T> inline T* obj_field_addr_raw(int offset) const;
 136 
 137   template <typename T> inline size_t field_offset(T* p) const;
 138 
 139   // Standard compare function returns negative value if o1 < o2
 140   //                                   0              if o1 == o2
 141   //                                   positive value if o1 > o2
 142   inline static int  compare(oop o1, oop o2) {
 143     void* o1_addr = (void*)o1;
 144     void* o2_addr = (void*)o2;
 145     if (o1_addr < o2_addr) {
 146       return -1;
 147     } else if (o1_addr > o2_addr) {
 148       return 1;
 149     } else {
 150       return 0;
 151     }
 152   }
 153 
 154   inline static bool equals(oop o1, oop o2) { return Access<>::equals(o1, o2); }








 155 
 156   inline static bool unsafe_equals(oop o1, oop o2) {
 157 #ifdef CHECK_UNHANDLED_OOPS
 158     return o1.obj() == o2.obj();
 159 #else
 160     return o1 == o2;
 161 #endif
 162   }
 163 
 164   // Access to fields in a instanceOop through these methods.
 165   template <DecoratorSet decorator>
 166   oop obj_field_access(int offset) const;
 167   oop obj_field(int offset) const;
 168   void obj_field_put(int offset, oop value);
 169   void obj_field_put_raw(int offset, oop value);
 170   void obj_field_put_volatile(int offset, oop value);
 171 
 172   Metadata* metadata_field(int offset) const;
 173   void metadata_field_put(int offset, Metadata* value);
 174 


< prev index next >