oop.hpp revision 113
0N/A/*
0N/A * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0N/A * CA 95054 USA or visit www.sun.com if you need additional information or
0N/A * have any questions.
0N/A *
0N/A */
0N/A
0N/A// oopDesc is the top baseclass for objects classes. The {name}Desc classes describe
0N/A// the format of Java objects so the fields can be accessed from C++.
0N/A// oopDesc is abstract.
0N/A// (see oopHierarchy for complete oop class hierarchy)
0N/A//
0N/A// no virtual functions allowed
0N/A
0N/A// store into oop with store check
113N/Atemplate <class T> void oop_store(T* p, oop v);
113N/Atemplate <class T> void oop_store(volatile T* p, oop v);
0N/A
0N/A// store into oop without store check
113N/Atemplate <class T> void oop_store_without_check(T* p, oop v);
113N/Atemplate <class T> void oop_store_without_check(volatile T* p, oop v);
0N/A
0N/A
0N/Aextern bool always_do_update_barrier;
0N/A
0N/A// Forward declarations.
0N/Aclass OopClosure;
0N/Aclass ScanClosure;
0N/Aclass FastScanClosure;
0N/Aclass FilteringClosure;
0N/Aclass BarrierSet;
0N/Aclass CMSIsAliveClosure;
0N/A
0N/Aclass PSPromotionManager;
0N/Aclass ParCompactionManager;
0N/A
0N/Aclass oopDesc {
0N/A friend class VMStructs;
0N/A private:
0N/A volatile markOop _mark;
113N/A union _metadata {
113N/A wideKlassOop _klass;
113N/A narrowOop _compressed_klass;
113N/A } _metadata;
0N/A
0N/A // Fast access to barrier set. Must be initialized.
0N/A static BarrierSet* _bs;
0N/A
0N/A public:
0N/A markOop mark() const { return _mark; }
0N/A markOop* mark_addr() const { return (markOop*) &_mark; }
0N/A
0N/A void set_mark(volatile markOop m) { _mark = m; }
0N/A
0N/A void release_set_mark(markOop m);
0N/A markOop cas_set_mark(markOop new_mark, markOop old_mark);
0N/A
0N/A // Used only to re-initialize the mark word (e.g., of promoted
0N/A // objects during a GC) -- requires a valid klass pointer
0N/A void init_mark();
0N/A
113N/A klassOop klass() const;
113N/A oop* klass_addr();
113N/A narrowOop* compressed_klass_addr();
0N/A
0N/A void set_klass(klassOop k);
0N/A // For when the klass pointer is being used as a linked list "next" field.
0N/A void set_klass_to_list_ptr(oop k);
0N/A
113N/A // size of object header, aligned to platform wordSize
113N/A static int header_size() { return sizeof(oopDesc)/HeapWordSize; }
0N/A
0N/A Klass* blueprint() const;
0N/A
0N/A // Returns whether this is an instance of k or an instance of a subclass of k
0N/A bool is_a(klassOop k) const;
0N/A
0N/A // Returns the actual oop size of the object
0N/A int size();
0N/A
0N/A // Sometimes (for complicated concurrency-related reasons), it is useful
0N/A // to be able to figure out the size of an object knowing its klass.
0N/A int size_given_klass(Klass* klass);
0N/A
0N/A // Some perm gen objects are not parseble immediately after
0N/A // installation of their klass pointer.
0N/A bool is_parsable();
0N/A
0N/A // type test operations (inlined in oop.inline.h)
0N/A bool is_instance() const;
0N/A bool is_instanceRef() const;
0N/A bool is_array() const;
0N/A bool is_objArray() const;
0N/A bool is_symbol() const;
0N/A bool is_klass() const;
0N/A bool is_thread() const;
0N/A bool is_method() const;
0N/A bool is_constMethod() const;
0N/A bool is_methodData() const;
0N/A bool is_constantPool() const;
0N/A bool is_constantPoolCache() const;
0N/A bool is_typeArray() const;
0N/A bool is_javaArray() const;
0N/A bool is_compiledICHolder() const;
0N/A
0N/A private:
0N/A // field addresses in oop
0N/A void* field_base(int offset) const;
0N/A
0N/A jbyte* byte_field_addr(int offset) const;
0N/A jchar* char_field_addr(int offset) const;
0N/A jboolean* bool_field_addr(int offset) const;
0N/A jint* int_field_addr(int offset) const;
0N/A jshort* short_field_addr(int offset) const;
0N/A jlong* long_field_addr(int offset) const;
0N/A jfloat* float_field_addr(int offset) const;
0N/A jdouble* double_field_addr(int offset) const;
113N/A address* address_field_addr(int offset) const;
0N/A
0N/A public:
113N/A // Need this as public for garbage collection.
113N/A template <class T> T* obj_field_addr(int offset) const;
113N/A
113N/A static bool is_null(oop obj);
113N/A static bool is_null(narrowOop obj);
113N/A
113N/A // Decode an oop pointer from a narrowOop if compressed.
113N/A // These are overloaded for oop and narrowOop as are the other functions
113N/A // below so that they can be called in template functions.
113N/A static oop decode_heap_oop_not_null(oop v);
113N/A static oop decode_heap_oop_not_null(narrowOop v);
113N/A static oop decode_heap_oop(oop v);
113N/A static oop decode_heap_oop(narrowOop v);
113N/A
113N/A // Encode an oop pointer to a narrow oop. The or_null versions accept
113N/A // null oop pointer, others do not in order to eliminate the
113N/A // null checking branches.
113N/A static narrowOop encode_heap_oop_not_null(oop v);
113N/A static narrowOop encode_heap_oop(oop v);
113N/A
113N/A // Load an oop out of the Java heap
113N/A static narrowOop load_heap_oop(narrowOop* p);
113N/A static oop load_heap_oop(oop* p);
0N/A
113N/A // Load an oop out of Java heap and decode it to an uncompressed oop.
113N/A static oop load_decode_heap_oop_not_null(narrowOop* p);
113N/A static oop load_decode_heap_oop_not_null(oop* p);
113N/A static oop load_decode_heap_oop(narrowOop* p);
113N/A static oop load_decode_heap_oop(oop* p);
113N/A
113N/A // Store an oop into the heap.
113N/A static void store_heap_oop(narrowOop* p, narrowOop v);
113N/A static void store_heap_oop(oop* p, oop v);
113N/A
113N/A // Encode oop if UseCompressedOops and store into the heap.
113N/A static void encode_store_heap_oop_not_null(narrowOop* p, oop v);
113N/A static void encode_store_heap_oop_not_null(oop* p, oop v);
113N/A static void encode_store_heap_oop(narrowOop* p, oop v);
113N/A static void encode_store_heap_oop(oop* p, oop v);
113N/A
113N/A static void release_store_heap_oop(volatile narrowOop* p, narrowOop v);
113N/A static void release_store_heap_oop(volatile oop* p, oop v);
113N/A
113N/A static void release_encode_store_heap_oop_not_null(volatile narrowOop* p, oop v);
113N/A static void release_encode_store_heap_oop_not_null(volatile oop* p, oop v);
113N/A static void release_encode_store_heap_oop(volatile narrowOop* p, oop v);
113N/A static void release_encode_store_heap_oop(volatile oop* p, oop v);
113N/A
113N/A static oop atomic_exchange_oop(oop exchange_value, volatile HeapWord *dest);
113N/A static oop atomic_compare_exchange_oop(oop exchange_value,
113N/A volatile HeapWord *dest,
113N/A oop compare_value);
113N/A
113N/A // Access to fields in a instanceOop through these methods.
0N/A oop obj_field(int offset) const;
0N/A void obj_field_put(int offset, oop value);
113N/A void obj_field_raw_put(int offset, oop value);
0N/A
0N/A jbyte byte_field(int offset) const;
0N/A void byte_field_put(int offset, jbyte contents);
0N/A
0N/A jchar char_field(int offset) const;
0N/A void char_field_put(int offset, jchar contents);
0N/A
0N/A jboolean bool_field(int offset) const;
0N/A void bool_field_put(int offset, jboolean contents);
0N/A
0N/A jint int_field(int offset) const;
0N/A void int_field_put(int offset, jint contents);
0N/A
0N/A jshort short_field(int offset) const;
0N/A void short_field_put(int offset, jshort contents);
0N/A
0N/A jlong long_field(int offset) const;
0N/A void long_field_put(int offset, jlong contents);
0N/A
0N/A jfloat float_field(int offset) const;
0N/A void float_field_put(int offset, jfloat contents);
0N/A
0N/A jdouble double_field(int offset) const;
0N/A void double_field_put(int offset, jdouble contents);
0N/A
113N/A address address_field(int offset) const;
113N/A void address_field_put(int offset, address contents);
113N/A
0N/A oop obj_field_acquire(int offset) const;
0N/A void release_obj_field_put(int offset, oop value);
0N/A
0N/A jbyte byte_field_acquire(int offset) const;
0N/A void release_byte_field_put(int offset, jbyte contents);
0N/A
0N/A jchar char_field_acquire(int offset) const;
0N/A void release_char_field_put(int offset, jchar contents);
0N/A
0N/A jboolean bool_field_acquire(int offset) const;
0N/A void release_bool_field_put(int offset, jboolean contents);
0N/A
0N/A jint int_field_acquire(int offset) const;
0N/A void release_int_field_put(int offset, jint contents);
0N/A
0N/A jshort short_field_acquire(int offset) const;
0N/A void release_short_field_put(int offset, jshort contents);
0N/A
0N/A jlong long_field_acquire(int offset) const;
0N/A void release_long_field_put(int offset, jlong contents);
0N/A
0N/A jfloat float_field_acquire(int offset) const;
0N/A void release_float_field_put(int offset, jfloat contents);
0N/A
0N/A jdouble double_field_acquire(int offset) const;
0N/A void release_double_field_put(int offset, jdouble contents);
0N/A
0N/A // printing functions for VM debugging
0N/A void print_on(outputStream* st) const; // First level print
0N/A void print_value_on(outputStream* st) const; // Second level print.
0N/A void print_address_on(outputStream* st) const; // Address printing
0N/A
0N/A // printing on default output stream
0N/A void print();
0N/A void print_value();
0N/A void print_address();
0N/A
0N/A // return the print strings
0N/A char* print_string();
0N/A char* print_value_string();
0N/A
0N/A // verification operations
0N/A void verify_on(outputStream* st);
0N/A void verify();
0N/A void verify_old_oop(oop* p, bool allow_dirty);
113N/A void verify_old_oop(narrowOop* p, bool allow_dirty);
0N/A
0N/A // tells whether this oop is partially constructed (gc during class loading)
0N/A bool partially_loaded();
0N/A void set_partially_loaded();
0N/A
0N/A // locking operations
0N/A bool is_locked() const;
0N/A bool is_unlocked() const;
0N/A bool has_bias_pattern() const;
0N/A
0N/A // asserts
0N/A bool is_oop(bool ignore_mark_word = false) const;
0N/A bool is_oop_or_null(bool ignore_mark_word = false) const;
0N/A#ifndef PRODUCT
0N/A bool is_unlocked_oop() const;
0N/A#endif
0N/A
0N/A // garbage collection
0N/A bool is_gc_marked() const;
0N/A // Apply "MarkSweep::mark_and_push" to (the address of) every non-NULL
0N/A // reference field in "this".
113N/A void follow_contents(void);
113N/A void follow_header(void);
0N/A
0N/A#ifndef SERIALGC
0N/A // Parallel Scavenge
0N/A void copy_contents(PSPromotionManager* pm);
0N/A void push_contents(PSPromotionManager* pm);
0N/A
0N/A // Parallel Old
0N/A void update_contents(ParCompactionManager* cm);
0N/A void update_contents(ParCompactionManager* cm,
0N/A HeapWord* begin_limit,
0N/A HeapWord* end_limit);
0N/A void update_contents(ParCompactionManager* cm,
0N/A klassOop old_klass,
0N/A HeapWord* begin_limit,
0N/A HeapWord* end_limit);
0N/A
0N/A void follow_contents(ParCompactionManager* cm);
0N/A void follow_header(ParCompactionManager* cm);
0N/A#endif // SERIALGC
0N/A
0N/A bool is_perm() const;
0N/A bool is_perm_or_null() const;
0N/A bool is_shared() const;
0N/A bool is_shared_readonly() const;
0N/A bool is_shared_readwrite() const;
0N/A
0N/A // Forward pointer operations for scavenge
0N/A bool is_forwarded() const;
0N/A
0N/A void forward_to(oop p);
0N/A bool cas_forward_to(oop p, markOop compare);
0N/A
0N/A#ifndef SERIALGC
0N/A // Like "forward_to", but inserts the forwarding pointer atomically.
0N/A // Exactly one thread succeeds in inserting the forwarding pointer, and
0N/A // this call returns "NULL" for that thread; any other thread has the
0N/A // value of the forwarding pointer returned and does not modify "this".
0N/A oop forward_to_atomic(oop p);
0N/A#endif // SERIALGC
0N/A
0N/A oop forwardee() const;
0N/A
0N/A // Age of object during scavenge
0N/A int age() const;
0N/A void incr_age();
0N/A
0N/A // Adjust all pointers in this object to point at it's forwarded location and
0N/A // return the size of this oop. This is used by the MarkSweep collector.
0N/A int adjust_pointers();
0N/A void adjust_header();
0N/A
0N/A#ifndef SERIALGC
0N/A // Parallel old
0N/A void update_header();
0N/A void update_header(HeapWord* beg_addr, HeapWord* end_addr);
0N/A#endif // SERIALGC
0N/A
0N/A // mark-sweep support
0N/A void follow_body(int begin, int end);
0N/A
0N/A // Fast access to barrier set
0N/A static BarrierSet* bs() { return _bs; }
0N/A static void set_bs(BarrierSet* bs) { _bs = bs; }
0N/A
0N/A // iterators, returns size of object
0N/A#define OOP_ITERATE_DECL(OopClosureType, nv_suffix) \
0N/A int oop_iterate(OopClosureType* blk); \
0N/A int oop_iterate(OopClosureType* blk, MemRegion mr); // Only in mr.
0N/A
0N/A ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_ITERATE_DECL)
0N/A ALL_OOP_OOP_ITERATE_CLOSURES_3(OOP_ITERATE_DECL)
0N/A
0N/A void oop_iterate_header(OopClosure* blk);
0N/A void oop_iterate_header(OopClosure* blk, MemRegion mr);
0N/A
0N/A // identity hash; returns the identity hash key (computes it if necessary)
0N/A // NOTE with the introduction of UseBiasedLocking that identity_hash() might reach a
0N/A // safepoint if called on a biased object. Calling code must be aware of that.
0N/A intptr_t identity_hash();
0N/A intptr_t slow_identity_hash();
0N/A
0N/A // marks are forwarded to stack when object is locked
0N/A bool has_displaced_mark() const;
0N/A markOop displaced_mark() const;
0N/A void set_displaced_mark(markOop m);
0N/A
0N/A // for code generation
0N/A static int mark_offset_in_bytes() { return offset_of(oopDesc, _mark); }
113N/A static int klass_offset_in_bytes() { return offset_of(oopDesc, _metadata._klass); }
113N/A static int klass_gap_offset_in_bytes();
0N/A};