oop.hpp revision 579
/*
* Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*
*/
// oopDesc is the top baseclass for objects classes. The {name}Desc classes describe
// the format of Java objects so the fields can be accessed from C++.
// oopDesc is abstract.
// (see oopHierarchy for complete oop class hierarchy)
//
// no virtual functions allowed
// store into oop with store check
// store into oop without store check
template <class T> void oop_store_without_check(T* p, oop v);
template <class T> void oop_store_without_check(volatile T* p, oop v);
extern bool always_do_update_barrier;
// Forward declarations.
class OopClosure;
class ScanClosure;
class FastScanClosure;
class FilteringClosure;
class BarrierSet;
class CMSIsAliveClosure;
class PSPromotionManager;
class ParCompactionManager;
class oopDesc {
friend class VMStructs;
private:
union _metadata {
} _metadata;
// Fast access to barrier set. Must be initialized.
static BarrierSet* _bs;
public:
void release_set_mark(markOop m);
// Used only to re-initialize the mark word (e.g., of promoted
// objects during a GC) -- requires a valid klass pointer
void init_mark();
klassOop klass_or_null() const volatile;
oop* klass_addr();
// For klass field compression
int klass_gap() const;
void set_klass_gap(int z);
// For when the klass pointer is being used as a linked list "next" field.
void set_klass_to_list_ptr(oop k);
// size of object header, aligned to platform wordSize
// Returns whether this is an instance of k or an instance of a subclass of k
// Returns the actual oop size of the object
int size();
// Sometimes (for complicated concurrency-related reasons), it is useful
// to be able to figure out the size of an object knowing its klass.
// Some perm gen objects are not parseble immediately after
// installation of their klass pointer.
bool is_parsable();
// Some perm gen objects that have been allocated and initialized
// can be changed by the VM when not at a safe point (class rededfinition
// is an example). Such objects should not be examined by the
// concurrent processing of a garbage collector if is_conc_safe()
// returns false.
bool is_conc_safe();
// type test operations (inlined in oop.inline.h)
bool is_instance() const;
bool is_instanceRef() const;
bool is_array() const;
bool is_objArray() const;
bool is_symbol() const;
bool is_klass() const;
bool is_thread() const;
bool is_method() const;
bool is_constMethod() const;
bool is_methodData() const;
bool is_constantPool() const;
bool is_constantPoolCache() const;
bool is_typeArray() const;
bool is_javaArray() const;
bool is_compiledICHolder() const;
private:
// field addresses in oop
void* field_base(int offset) const;
public:
// Need this as public for garbage collection.
template <class T> T* obj_field_addr(int offset) const;
// Oop encoding heap max
static const uint64_t OopEncodingHeapMax =
// Decode an oop pointer from a narrowOop if compressed.
// These are overloaded for oop and narrowOop as are the other functions
// below so that they can be called in template functions.
// Encode an oop pointer to a narrow oop. The or_null versions accept
// null oop pointer, others do not in order to eliminate the
// null checking branches.
// Load an oop out of the Java heap
// Load an oop out of Java heap and decode it to an uncompressed oop.
// Store an oop into the heap.
// Encode oop if UseCompressedOops and store into the heap.
// Access to fields in a instanceOop through these methods.
// printing functions for VM debugging
// printing on default output stream
void print();
void print_value();
void print_address();
// return the print strings
char* print_string();
char* print_value_string();
// verification operations
void verify();
// tells whether this oop is partially constructed (gc during class loading)
bool partially_loaded();
void set_partially_loaded();
// locking operations
bool is_locked() const;
bool is_unlocked() const;
bool has_bias_pattern() const;
// asserts
bool is_oop(bool ignore_mark_word = false) const;
bool is_oop_or_null(bool ignore_mark_word = false) const;
#ifndef PRODUCT
bool is_unlocked_oop() const;
#endif
// garbage collection
bool is_gc_marked() const;
// Apply "MarkSweep::mark_and_push" to (the address of) every non-NULL
// reference field in "this".
void follow_contents(void);
void follow_header(void);
#ifndef SERIALGC
// Parallel Scavenge
// Parallel Old
#endif // SERIALGC
bool is_perm() const;
bool is_perm_or_null() const;
bool is_shared() const;
bool is_shared_readonly() const;
bool is_shared_readwrite() const;
// Forward pointer operations for scavenge
bool is_forwarded() const;
void forward_to(oop p);
#ifndef SERIALGC
// Like "forward_to", but inserts the forwarding pointer atomically.
// Exactly one thread succeeds in inserting the forwarding pointer, and
// this call returns "NULL" for that thread; any other thread has the
// value of the forwarding pointer returned and does not modify "this".
#endif // SERIALGC
// Age of object during scavenge
int age() const;
void incr_age();
// Adjust all pointers in this object to point at it's forwarded location and
// return the size of this oop. This is used by the MarkSweep collector.
int adjust_pointers();
void adjust_header();
#ifndef SERIALGC
// Parallel old
void update_header();
#endif // SERIALGC
// mark-sweep support
// Fast access to barrier set
// iterators, returns size of object
#ifndef SERIALGC
#endif
// identity hash; returns the identity hash key (computes it if necessary)
// NOTE with the introduction of UseBiasedLocking that identity_hash() might reach a
// safepoint if called on a biased object. Calling code must be aware of that.
// marks are forwarded to stack when object is locked
bool has_displaced_mark() const;
markOop displaced_mark() const;
void set_displaced_mark(markOop m);
// for code generation
static int klass_gap_offset_in_bytes();
};