< prev index next >

src/share/vm/oops/oop.hpp

Print this page
rev 7183 : autospecialized oop_iterate using SFINAE and templates


  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 "memory/specialized_oop_closures.hpp"
  31 #include "oops/metadata.hpp"
  32 #include "utilities/macros.hpp"
  33 #include "utilities/top.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 // store into oop with store check
  43 template <class T> void oop_store(T* p, oop v);
  44 template <class T> void oop_store(volatile T* p, oop v);
  45 
  46 extern bool always_do_update_barrier;
  47 
  48 // Forward declarations.
  49 class OopClosure;
  50 class ScanClosure;
  51 class FastScanClosure;
  52 class FilteringClosure;
  53 class BarrierSet;


 319   oop forward_to_atomic(oop p);
 320 #endif // INCLUDE_ALL_GCS
 321 
 322   oop forwardee() const;
 323 
 324   // Age of object during scavenge
 325   uint age() const;
 326   void incr_age();
 327 
 328   // Adjust all pointers in this object to point at it's forwarded location and
 329   // return the size of this oop.  This is used by the MarkSweep collector.
 330   int adjust_pointers();
 331 
 332   // mark-sweep support
 333   void follow_body(int begin, int end);
 334 
 335   // Fast access to barrier set
 336   static BarrierSet* bs()            { return _bs; }
 337   static void set_bs(BarrierSet* bs) { _bs = bs; }
 338 






















 339   // iterators, returns size of object

 340 #define OOP_ITERATE_DECL(OopClosureType, nv_suffix)                      \
 341   int oop_iterate(OopClosureType* blk);                                  \
 342   int oop_iterate(OopClosureType* blk, MemRegion mr);  // Only in mr.
 343 
 344   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_ITERATE_DECL)
 345   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_ITERATE_DECL)
 346 
 347 #if INCLUDE_ALL_GCS
 348 
 349 #define OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix)            \
 350   int oop_iterate_backwards(OopClosureType* blk);
 351 
 352   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_ITERATE_BACKWARDS_DECL)
 353   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_ITERATE_BACKWARDS_DECL)
 354 #endif
 355 
 356   int oop_iterate_no_header(OopClosure* bk);



 357   int oop_iterate_no_header(OopClosure* bk, MemRegion mr);
 358 
 359   // identity hash; returns the identity hash key (computes it if necessary)
 360   // NOTE with the introduction of UseBiasedLocking that identity_hash() might reach a
 361   // safepoint if called on a biased object. Calling code must be aware of that.
 362   intptr_t identity_hash();
 363   intptr_t slow_identity_hash();
 364 
 365   // Alternate hashing code if string table is rehashed
 366   unsigned int new_hash(juint seed);
 367 
 368   // marks are forwarded to stack when object is locked
 369   bool     has_displaced_mark() const;
 370   markOop  displaced_mark() const;
 371   void     set_displaced_mark(markOop m);
 372 
 373   // for code generation
 374   static int mark_offset_in_bytes()    { return offset_of(oopDesc, _mark); }
 375   static int klass_offset_in_bytes()   { return offset_of(oopDesc, _metadata._klass); }
 376   static int klass_gap_offset_in_bytes();


  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 "memory/specialized_oop_closures.inline.hpp"
  31 #include "oops/metadata.hpp"
  32 #include "utilities/macros.hpp"
  33 #include "utilities/top.hpp"
  34 #include "utilities/templateIdioms.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 // store into oop with store check
  44 template <class T> void oop_store(T* p, oop v);
  45 template <class T> void oop_store(volatile T* p, oop v);
  46 
  47 extern bool always_do_update_barrier;
  48 
  49 // Forward declarations.
  50 class OopClosure;
  51 class ScanClosure;
  52 class FastScanClosure;
  53 class FilteringClosure;
  54 class BarrierSet;


 320   oop forward_to_atomic(oop p);
 321 #endif // INCLUDE_ALL_GCS
 322 
 323   oop forwardee() const;
 324 
 325   // Age of object during scavenge
 326   uint age() const;
 327   void incr_age();
 328 
 329   // Adjust all pointers in this object to point at it's forwarded location and
 330   // return the size of this oop.  This is used by the MarkSweep collector.
 331   int adjust_pointers();
 332 
 333   // mark-sweep support
 334   void follow_body(int begin, int end);
 335 
 336   // Fast access to barrier set
 337   static BarrierSet* bs()            { return _bs; }
 338   static void set_bs(BarrierSet* bs) { _bs = bs; }
 339 
 340 private:
 341   // Dispatch member functions to oop closures
 342 
 343   template <class OopClosureType>
 344   typename enable_if<is_kind_of<ExtendedOopClosure, OopClosureType>::value, void>::type
 345   do_metadata_if_applicable(OopClosureType *cl);
 346 
 347   template <class OopClosureType>
 348   typename enable_if<!is_kind_of<ExtendedOopClosure, OopClosureType>::value, void>::type
 349   do_metadata_if_applicable(OopClosureType *cl);
 350 
 351   template <class OopClosureType>
 352   int oop_iterate_dispatch_tag(OopClosureType *blk, DispatchTag tag);
 353 
 354   template <class OopClosureType>
 355   int oop_iterate_internal(OopClosureType *blk);
 356 
 357 public:
 358   template <class OopClosureType>
 359   typename enable_if<is_kind_of<ExtendedOopClosure, OopClosureType>::value, int>::type
 360   oop_iterate(OopClosureType *blk);
 361 
 362   // iterators, returns size of object
 363 
 364 #define OOP_ITERATE_DECL(OopClosureType, nv_suffix)                      \
 365   int oop_iterate(OopClosureType* blk);                                  \
 366   int oop_iterate(OopClosureType* blk, MemRegion mr);  // Only in mr.
 367 
 368   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_ITERATE_DECL)
 369   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_ITERATE_DECL)
 370 
 371 #if INCLUDE_ALL_GCS
 372 
 373 #define OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix)            \
 374   int oop_iterate_backwards(OopClosureType* blk);
 375 
 376   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_ITERATE_BACKWARDS_DECL)
 377   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_ITERATE_BACKWARDS_DECL)
 378 #endif
 379 
 380   template <class OopClosureType>
 381   typename enable_if<is_kind_of<OopClosure, OopClosureType>::value, int>::type
 382   oop_iterate_no_header(OopClosureType* bk);
 383   
 384   int oop_iterate_no_header(OopClosure* bk, MemRegion mr);
 385 
 386   // identity hash; returns the identity hash key (computes it if necessary)
 387   // NOTE with the introduction of UseBiasedLocking that identity_hash() might reach a
 388   // safepoint if called on a biased object. Calling code must be aware of that.
 389   intptr_t identity_hash();
 390   intptr_t slow_identity_hash();
 391 
 392   // Alternate hashing code if string table is rehashed
 393   unsigned int new_hash(juint seed);
 394 
 395   // marks are forwarded to stack when object is locked
 396   bool     has_displaced_mark() const;
 397   markOop  displaced_mark() const;
 398   void     set_displaced_mark(markOop m);
 399 
 400   // for code generation
 401   static int mark_offset_in_bytes()    { return offset_of(oopDesc, _mark); }
 402   static int klass_offset_in_bytes()   { return offset_of(oopDesc, _metadata._klass); }
 403   static int klass_gap_offset_in_bytes();
< prev index next >