< prev index next >

src/hotspot/share/oops/markWord.hpp

Print this page




 235     return (mask_bits(value(), biased_lock_mask_in_place) == unlocked_value);
 236   }
 237   bool is_marked()   const {
 238     return (mask_bits(value(), lock_mask_in_place) == marked_value);
 239   }
 240   bool is_neutral()  const { return (mask_bits(value(), biased_lock_mask_in_place) == unlocked_value); }
 241 
 242   // Special temporary state of the markWord while being inflated.
 243   // Code that looks at mark outside a lock need to take this into account.
 244   bool is_being_inflated() const { return (value() == 0); }
 245 
 246   // Distinguished markword value - used when inflating over
 247   // an existing stacklock.  0 indicates the markword is "BUSY".
 248   // Lockword mutators that use a LD...CAS idiom should always
 249   // check for and avoid overwriting a 0 value installed by some
 250   // other thread.  (They should spin or block instead.  The 0 value
 251   // is transient and *should* be short-lived).
 252   static markWord INFLATING() { return zero(); }    // inflate-in-progress
 253 
 254   // Should this header be preserved during GC?
 255   inline bool must_be_preserved(oop obj_containing_mark) const;
 256   inline bool must_be_preserved_with_bias(oop obj_containing_mark) const;
 257 
 258   // Should this header (including its age bits) be preserved in the
 259   // case of a promotion failure during scavenge?
 260   // Note that we special case this situation. We want to avoid
 261   // calling BiasedLocking::preserve_marks()/restore_marks() (which
 262   // decrease the number of mark words that need to be preserved
 263   // during GC) during each scavenge. During scavenges in which there
 264   // is no promotion failure, we actually don't need to call the above
 265   // routines at all, since we don't mutate and re-initialize the
 266   // marks of promoted objects using init_mark(). However, during
 267   // scavenges which result in promotion failure, we do re-initialize
 268   // the mark words of objects, meaning that we should have called
 269   // these mark word preservation routines. Currently there's no good
 270   // place in which to call them in any of the scavengers (although
 271   // guarded by appropriate locks we could make one), but the
 272   // observation is that promotion failures are quite rare and
 273   // reducing the number of mark words preserved during them isn't a
 274   // high priority.
 275   inline bool must_be_preserved_for_promotion_failure(oop obj_containing_mark) const;
 276   inline bool must_be_preserved_with_bias_for_promotion_failure(oop obj_containing_mark) const;
 277 
 278   // Should this header be preserved during a scavenge where CMS is
 279   // the old generation?
 280   // (This is basically the same body as must_be_preserved_for_promotion_failure(),
 281   // but takes the Klass* as argument instead)
 282   inline bool must_be_preserved_for_cms_scavenge(Klass* klass_of_obj_containing_mark) const;
 283   inline bool must_be_preserved_with_bias_for_cms_scavenge(Klass* klass_of_obj_containing_mark) const;
 284 
 285   // WARNING: The following routines are used EXCLUSIVELY by
 286   // synchronization functions. They are not really gc safe.
 287   // They must get updated if markWord layout get changed.
 288   markWord set_unlocked() const {
 289     return markWord(value() | unlocked_value);
 290   }
 291   bool has_locker() const {
 292     return ((value() & lock_mask_in_place) == locked_value);
 293   }
 294   BasicLock* locker() const {
 295     assert(has_locker(), "check");
 296     return (BasicLock*) value();
 297   }
 298   bool has_monitor() const {
 299     return ((value() & monitor_value) != 0);
 300   }
 301   ObjectMonitor* monitor() const {
 302     assert(has_monitor(), "check");
 303     // Use xor instead of &~ to provide one extra tag-bit check.


 355     assert((v & ~age_mask) == 0, "shouldn't overflow age field");
 356     return markWord((value() & ~age_mask_in_place) | (((uintptr_t)v & age_mask) << age_shift));
 357   }
 358   markWord incr_age()      const { return age() == max_age ? markWord(_value) : set_age(age() + 1); }
 359 
 360   // hash operations
 361   intptr_t hash() const {
 362     return mask_bits(value() >> hash_shift, hash_mask);
 363   }
 364 
 365   bool has_no_hash() const {
 366     return hash() == no_hash;
 367   }
 368 
 369   // Prototype mark for initialization
 370   static markWord prototype() {
 371     return markWord( no_hash_in_place | no_lock_in_place );
 372   }
 373 
 374   // Helper function for restoration of unmarked mark oops during GC
 375   static inline markWord prototype_for_object(oop obj);
 376 
 377   // Debugging
 378   void print_on(outputStream* st) const;
 379 
 380   // Prepare address of oop for placement into mark
 381   inline static markWord encode_pointer_as_mark(void* p) { return from_pointer(p).set_marked(); }
 382 
 383   // Recover address of oop from encoded form used in mark
 384   inline void* decode_pointer() { if (UseBiasedLocking && has_bias_pattern()) return NULL; return (void*)clear_lock_bits().value(); }
 385 
 386   // These markWords indicate cms free chunk blocks and not objects.
 387   // In 64 bit, the markWord is set to distinguish them from oops.
 388   // These are defined in 32 bit mode for vmStructs.
 389   const static uintptr_t cms_free_chunk_pattern  = 0x1;
 390 
 391   // Constants for the size field.
 392   enum { size_shift                = cms_shift + cms_bits,
 393          size_bits                 = 35    // need for compressed oops 32G
 394        };
 395   // These values are too big for Win64




 235     return (mask_bits(value(), biased_lock_mask_in_place) == unlocked_value);
 236   }
 237   bool is_marked()   const {
 238     return (mask_bits(value(), lock_mask_in_place) == marked_value);
 239   }
 240   bool is_neutral()  const { return (mask_bits(value(), biased_lock_mask_in_place) == unlocked_value); }
 241 
 242   // Special temporary state of the markWord while being inflated.
 243   // Code that looks at mark outside a lock need to take this into account.
 244   bool is_being_inflated() const { return (value() == 0); }
 245 
 246   // Distinguished markword value - used when inflating over
 247   // an existing stacklock.  0 indicates the markword is "BUSY".
 248   // Lockword mutators that use a LD...CAS idiom should always
 249   // check for and avoid overwriting a 0 value installed by some
 250   // other thread.  (They should spin or block instead.  The 0 value
 251   // is transient and *should* be short-lived).
 252   static markWord INFLATING() { return zero(); }    // inflate-in-progress
 253 
 254   // Should this header be preserved during GC?
 255   template <typename KlassProxy>
 256   inline bool must_be_preserved(KlassProxy klass) const;
 257 
 258   // Should this header (including its age bits) be preserved in the
 259   // case of a promotion failure during scavenge?
 260   // Note that we special case this situation. We want to avoid
 261   // calling BiasedLocking::preserve_marks()/restore_marks() (which
 262   // decrease the number of mark words that need to be preserved
 263   // during GC) during each scavenge. During scavenges in which there
 264   // is no promotion failure, we actually don't need to call the above
 265   // routines at all, since we don't mutate and re-initialize the
 266   // marks of promoted objects using init_mark(). However, during
 267   // scavenges which result in promotion failure, we do re-initialize
 268   // the mark words of objects, meaning that we should have called
 269   // these mark word preservation routines. Currently there's no good
 270   // place in which to call them in any of the scavengers (although
 271   // guarded by appropriate locks we could make one), but the
 272   // observation is that promotion failures are quite rare and
 273   // reducing the number of mark words preserved during them isn't a
 274   // high priority.
 275   template <typename KlassProxy>
 276   inline bool must_be_preserved_for_promotion_failure(KlassProxy klass) const;
 277 
 278   // Should this header be preserved during a scavenge where CMS is
 279   // the old generation?
 280   // (This is basically the same body as must_be_preserved_for_promotion_failure(),
 281   // but takes the Klass* as argument instead)
 282   inline bool must_be_preserved_for_cms_scavenge(Klass* klass_of_obj_containing_mark) const;

 283 
 284   // WARNING: The following routines are used EXCLUSIVELY by
 285   // synchronization functions. They are not really gc safe.
 286   // They must get updated if markWord layout get changed.
 287   markWord set_unlocked() const {
 288     return markWord(value() | unlocked_value);
 289   }
 290   bool has_locker() const {
 291     return ((value() & lock_mask_in_place) == locked_value);
 292   }
 293   BasicLock* locker() const {
 294     assert(has_locker(), "check");
 295     return (BasicLock*) value();
 296   }
 297   bool has_monitor() const {
 298     return ((value() & monitor_value) != 0);
 299   }
 300   ObjectMonitor* monitor() const {
 301     assert(has_monitor(), "check");
 302     // Use xor instead of &~ to provide one extra tag-bit check.


 354     assert((v & ~age_mask) == 0, "shouldn't overflow age field");
 355     return markWord((value() & ~age_mask_in_place) | (((uintptr_t)v & age_mask) << age_shift));
 356   }
 357   markWord incr_age()      const { return age() == max_age ? markWord(_value) : set_age(age() + 1); }
 358 
 359   // hash operations
 360   intptr_t hash() const {
 361     return mask_bits(value() >> hash_shift, hash_mask);
 362   }
 363 
 364   bool has_no_hash() const {
 365     return hash() == no_hash;
 366   }
 367 
 368   // Prototype mark for initialization
 369   static markWord prototype() {
 370     return markWord( no_hash_in_place | no_lock_in_place );
 371   }
 372 
 373   // Helper function for restoration of unmarked mark oops during GC
 374   static inline markWord prototype_for_klass(const Klass* klass);
 375 
 376   // Debugging
 377   void print_on(outputStream* st) const;
 378 
 379   // Prepare address of oop for placement into mark
 380   inline static markWord encode_pointer_as_mark(void* p) { return from_pointer(p).set_marked(); }
 381 
 382   // Recover address of oop from encoded form used in mark
 383   inline void* decode_pointer() { if (UseBiasedLocking && has_bias_pattern()) return NULL; return (void*)clear_lock_bits().value(); }
 384 
 385   // These markWords indicate cms free chunk blocks and not objects.
 386   // In 64 bit, the markWord is set to distinguish them from oops.
 387   // These are defined in 32 bit mode for vmStructs.
 388   const static uintptr_t cms_free_chunk_pattern  = 0x1;
 389 
 390   // Constants for the size field.
 391   enum { size_shift                = cms_shift + cms_bits,
 392          size_bits                 = 35    // need for compressed oops 32G
 393        };
 394   // These values are too big for Win64


< prev index next >