src/share/vm/oops/oop.hpp

Wed, 05 Dec 2007 09:00:00 -0800

author
dcubed
date
Wed, 05 Dec 2007 09:00:00 -0800
changeset 451
f8236e79048a
parent 435
a61af66fc99e
child 548
ba764ed4b6f2
permissions
-rw-r--r--

6664627: Merge changes made only in hotspot 11 forward to jdk 7
Reviewed-by: jcoomes

     1 /*
     2  * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 // oopDesc is the top baseclass for objects classes.  The {name}Desc classes describe
    26 // the format of Java objects so the fields can be accessed from C++.
    27 // oopDesc is abstract.
    28 // (see oopHierarchy for complete oop class hierarchy)
    29 //
    30 // no virtual functions allowed
    32 // store into oop with store check
    33 void oop_store(oop* p, oop v);
    34 void oop_store(volatile oop* p, oop v);
    36 // store into oop without store check
    37 void oop_store_without_check(oop* p, oop v);
    38 void oop_store_without_check(volatile oop* p, oop v);
    41 extern bool always_do_update_barrier;
    43 // Forward declarations.
    44 class OopClosure;
    45 class ScanClosure;
    46 class FastScanClosure;
    47 class FilteringClosure;
    48 class BarrierSet;
    49 class CMSIsAliveClosure;
    51 class PSPromotionManager;
    52 class ParCompactionManager;
    54 class oopDesc {
    55   friend class VMStructs;
    56  private:
    57   volatile markOop  _mark;
    58   klassOop _klass;
    60   // Fast access to barrier set.  Must be initialized.
    61   static BarrierSet* _bs;
    63  public:
    64   markOop  mark() const         { return _mark; }
    65   markOop* mark_addr() const    { return (markOop*) &_mark; }
    67   void set_mark(volatile markOop m)      { _mark = m;   }
    69   void    release_set_mark(markOop m);
    70   markOop cas_set_mark(markOop new_mark, markOop old_mark);
    72   // Used only to re-initialize the mark word (e.g., of promoted
    73   // objects during a GC) -- requires a valid klass pointer
    74   void init_mark();
    76   klassOop klass() const        { return _klass; }
    77   oop* klass_addr() const       { return (oop*) &_klass; }
    79   void set_klass(klassOop k);
    80   // For when the klass pointer is being used as a linked list "next" field.
    81   void set_klass_to_list_ptr(oop k);
    83   // size of object header
    84   static int header_size()      { return sizeof(oopDesc)/HeapWordSize; }
    85   static int header_size_in_bytes() { return sizeof(oopDesc); }
    87   Klass* blueprint() const;
    89   // Returns whether this is an instance of k or an instance of a subclass of k
    90   bool is_a(klassOop k)  const;
    92   // Returns the actual oop size of the object
    93   int size();
    95   // Sometimes (for complicated concurrency-related reasons), it is useful
    96   // to be able to figure out the size of an object knowing its klass.
    97   int size_given_klass(Klass* klass);
    99   // Some perm gen objects are not parseble immediately after
   100   // installation of their klass pointer.
   101   bool is_parsable();
   103   // type test operations (inlined in oop.inline.h)
   104   bool is_instance()           const;
   105   bool is_instanceRef()        const;
   106   bool is_array()              const;
   107   bool is_objArray()           const;
   108   bool is_symbol()             const;
   109   bool is_klass()              const;
   110   bool is_thread()             const;
   111   bool is_method()             const;
   112   bool is_constMethod()        const;
   113   bool is_methodData()         const;
   114   bool is_constantPool()       const;
   115   bool is_constantPoolCache()  const;
   116   bool is_typeArray()          const;
   117   bool is_javaArray()          const;
   118   bool is_compiledICHolder()   const;
   120  private:
   121   // field addresses in oop
   122   // byte/char/bool/short fields are always stored as full words
   123   void*     field_base(int offset)        const;
   125   jbyte*    byte_field_addr(int offset)   const;
   126   jchar*    char_field_addr(int offset)   const;
   127   jboolean* bool_field_addr(int offset)   const;
   128   jint*     int_field_addr(int offset)    const;
   129   jshort*   short_field_addr(int offset)  const;
   130   jlong*    long_field_addr(int offset)   const;
   131   jfloat*   float_field_addr(int offset)  const;
   132   jdouble*  double_field_addr(int offset) const;
   134  public:
   135   // need this as public for garbage collection
   136   oop* obj_field_addr(int offset) const;
   138   oop obj_field(int offset) const;
   139   void obj_field_put(int offset, oop value);
   141   jbyte byte_field(int offset) const;
   142   void byte_field_put(int offset, jbyte contents);
   144   jchar char_field(int offset) const;
   145   void char_field_put(int offset, jchar contents);
   147   jboolean bool_field(int offset) const;
   148   void bool_field_put(int offset, jboolean contents);
   150   jint int_field(int offset) const;
   151   void int_field_put(int offset, jint contents);
   153   jshort short_field(int offset) const;
   154   void short_field_put(int offset, jshort contents);
   156   jlong long_field(int offset) const;
   157   void long_field_put(int offset, jlong contents);
   159   jfloat float_field(int offset) const;
   160   void float_field_put(int offset, jfloat contents);
   162   jdouble double_field(int offset) const;
   163   void double_field_put(int offset, jdouble contents);
   165   oop obj_field_acquire(int offset) const;
   166   void release_obj_field_put(int offset, oop value);
   168   jbyte byte_field_acquire(int offset) const;
   169   void release_byte_field_put(int offset, jbyte contents);
   171   jchar char_field_acquire(int offset) const;
   172   void release_char_field_put(int offset, jchar contents);
   174   jboolean bool_field_acquire(int offset) const;
   175   void release_bool_field_put(int offset, jboolean contents);
   177   jint int_field_acquire(int offset) const;
   178   void release_int_field_put(int offset, jint contents);
   180   jshort short_field_acquire(int offset) const;
   181   void release_short_field_put(int offset, jshort contents);
   183   jlong long_field_acquire(int offset) const;
   184   void release_long_field_put(int offset, jlong contents);
   186   jfloat float_field_acquire(int offset) const;
   187   void release_float_field_put(int offset, jfloat contents);
   189   jdouble double_field_acquire(int offset) const;
   190   void release_double_field_put(int offset, jdouble contents);
   192   // printing functions for VM debugging
   193   void print_on(outputStream* st) const;         // First level print
   194   void print_value_on(outputStream* st) const;   // Second level print.
   195   void print_address_on(outputStream* st) const; // Address printing
   197   // printing on default output stream
   198   void print();
   199   void print_value();
   200   void print_address();
   202   // return the print strings
   203   char* print_string();
   204   char* print_value_string();
   206   // verification operations
   207   void verify_on(outputStream* st);
   208   void verify();
   209   void verify_old_oop(oop* p, bool allow_dirty);
   211   // tells whether this oop is partially constructed (gc during class loading)
   212   bool partially_loaded();
   213   void set_partially_loaded();
   215   // locking operations
   216   bool is_locked()   const;
   217   bool is_unlocked() const;
   218   bool has_bias_pattern() const;
   220   // asserts
   221   bool is_oop(bool ignore_mark_word = false) const;
   222   bool is_oop_or_null(bool ignore_mark_word = false) const;
   223 #ifndef PRODUCT
   224   bool is_unlocked_oop() const;
   225 #endif
   227   // garbage collection
   228   bool is_gc_marked() const;
   229   // Apply "MarkSweep::mark_and_push" to (the address of) every non-NULL
   230   // reference field in "this".
   231   void follow_contents();
   232   void follow_header();
   234 #ifndef SERIALGC
   235   // Parallel Scavenge
   236   void copy_contents(PSPromotionManager* pm);
   237   void push_contents(PSPromotionManager* pm);
   239   // Parallel Old
   240   void update_contents(ParCompactionManager* cm);
   241   void update_contents(ParCompactionManager* cm,
   242                        HeapWord* begin_limit,
   243                        HeapWord* end_limit);
   244   void update_contents(ParCompactionManager* cm,
   245                        klassOop old_klass,
   246                        HeapWord* begin_limit,
   247                        HeapWord* end_limit);
   249   void follow_contents(ParCompactionManager* cm);
   250   void follow_header(ParCompactionManager* cm);
   251 #endif // SERIALGC
   253   bool is_perm() const;
   254   bool is_perm_or_null() const;
   255   bool is_shared() const;
   256   bool is_shared_readonly() const;
   257   bool is_shared_readwrite() const;
   259   // Forward pointer operations for scavenge
   260   bool is_forwarded() const;
   262   void forward_to(oop p);
   263   bool cas_forward_to(oop p, markOop compare);
   265 #ifndef SERIALGC
   266   // Like "forward_to", but inserts the forwarding pointer atomically.
   267   // Exactly one thread succeeds in inserting the forwarding pointer, and
   268   // this call returns "NULL" for that thread; any other thread has the
   269   // value of the forwarding pointer returned and does not modify "this".
   270   oop forward_to_atomic(oop p);
   271 #endif // SERIALGC
   273   oop forwardee() const;
   275   // Age of object during scavenge
   276   int age() const;
   277   void incr_age();
   279   // Adjust all pointers in this object to point at it's forwarded location and
   280   // return the size of this oop.  This is used by the MarkSweep collector.
   281   int adjust_pointers();
   282   void adjust_header();
   284 #ifndef SERIALGC
   285   // Parallel old
   286   void update_header();
   287   void update_header(HeapWord* beg_addr, HeapWord* end_addr);
   288 #endif // SERIALGC
   290   // mark-sweep support
   291   void follow_body(int begin, int end);
   293   // Fast access to barrier set
   294   static BarrierSet* bs()            { return _bs; }
   295   static void set_bs(BarrierSet* bs) { _bs = bs; }
   297   // iterators, returns size of object
   298 #define OOP_ITERATE_DECL(OopClosureType, nv_suffix)                             \
   299   int oop_iterate(OopClosureType* blk);                                  \
   300   int oop_iterate(OopClosureType* blk, MemRegion mr);  // Only in mr.
   302   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_ITERATE_DECL)
   303   ALL_OOP_OOP_ITERATE_CLOSURES_3(OOP_ITERATE_DECL)
   305   void oop_iterate_header(OopClosure* blk);
   306   void oop_iterate_header(OopClosure* blk, MemRegion mr);
   308   // identity hash; returns the identity hash key (computes it if necessary)
   309   // NOTE with the introduction of UseBiasedLocking that identity_hash() might reach a
   310   // safepoint if called on a biased object. Calling code must be aware of that.
   311   intptr_t identity_hash();
   312   intptr_t slow_identity_hash();
   314   // marks are forwarded to stack when object is locked
   315   bool     has_displaced_mark() const;
   316   markOop  displaced_mark() const;
   317   void     set_displaced_mark(markOop m);
   319   // for code generation
   320   static int klass_offset_in_bytes()   { return offset_of(oopDesc, _klass); }
   321   static int mark_offset_in_bytes()    { return offset_of(oopDesc, _mark); }
   322 };

mercurial