< prev index next >

src/hotspot/share/oops/oop.cpp

Print this page

 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 #include "precompiled.hpp"
 26 #include "classfile/altHashing.hpp"
 27 #include "classfile/javaClasses.inline.hpp"
 28 #include "gc/shared/collectedHeap.inline.hpp"
 29 #include "gc/shared/gc_globals.hpp"
 30 #include "memory/resourceArea.hpp"
 31 #include "memory/universe.hpp"
 32 #include "oops/access.inline.hpp"
 33 #include "oops/compressedOops.inline.hpp"
 34 #include "oops/oop.inline.hpp"
 35 #include "oops/verifyOopClosure.hpp"
 36 #include "runtime/handles.inline.hpp"

 37 #include "runtime/thread.inline.hpp"
 38 #include "utilities/copy.hpp"
 39 #include "utilities/macros.hpp"
 40 
 41 void oopDesc::print_on(outputStream* st) const {
 42   klass()->oop_print_on(const_cast<oopDesc*>(this), st);
 43 }
 44 
 45 void oopDesc::print_address_on(outputStream* st) const {
 46   st->print("{" INTPTR_FORMAT "}", p2i(this));
 47 
 48 }
 49 
 50 void oopDesc::print()         { print_on(tty);         }
 51 
 52 void oopDesc::print_address() { print_address_on(tty); }
 53 
 54 char* oopDesc::print_string() {
 55   stringStream st;
 56   print_on(&st);

156   if (UseCompressedClassPointers) {
157     narrowKlass narrow_klass = obj->_metadata._compressed_klass;
158     if (narrow_klass == 0) return NULL;
159     return (void*)CompressedKlassPointers::decode_raw(narrow_klass);
160   } else {
161     return obj->_metadata._klass;
162   }
163 }
164 
165 void* oopDesc::load_oop_raw(oop obj, int offset) {
166   uintptr_t addr = (uintptr_t)(void*)obj + (uint)offset;
167   if (UseCompressedOops) {
168     narrowOop narrow_oop = *(narrowOop*)addr;
169     if (CompressedOops::is_null(narrow_oop)) return NULL;
170     return (void*)CompressedOops::decode_raw(narrow_oop);
171   } else {
172     return *(void**)addr;
173   }
174 }
175 





176 oop oopDesc::obj_field_acquire(int offset) const                      { return HeapAccess<MO_ACQUIRE>::oop_load_at(as_oop(), offset); }
177 
178 void oopDesc::obj_field_put_raw(int offset, oop value)                { RawAccess<>::oop_store_at(as_oop(), offset, value); }
179 void oopDesc::release_obj_field_put(int offset, oop value)            { HeapAccess<MO_RELEASE>::oop_store_at(as_oop(), offset, value); }
180 void oopDesc::obj_field_put_volatile(int offset, oop value)           { HeapAccess<MO_SEQ_CST>::oop_store_at(as_oop(), offset, value); }
181 
182 address oopDesc::address_field(int offset) const                      { return *field_addr<address>(offset); }
183 address oopDesc::address_field_acquire(int offset) const              { return Atomic::load_acquire(field_addr<address>(offset)); }
184 
185 void oopDesc::address_field_put(int offset, address value)            { *field_addr<address>(offset) = value; }
186 void oopDesc::release_address_field_put(int offset, address value)    { Atomic::release_store(field_addr<address>(offset), value); }
187 
188 Metadata* oopDesc::metadata_field(int offset) const                   { return *field_addr<Metadata*>(offset); }
189 void oopDesc::metadata_field_put(int offset, Metadata* value)         { *field_addr<Metadata*>(offset) = value; }
190 
191 Metadata* oopDesc::metadata_field_acquire(int offset) const           { return Atomic::load_acquire(field_addr<Metadata*>(offset)); }
192 void oopDesc::release_metadata_field_put(int offset, Metadata* value) { Atomic::release_store(field_addr<Metadata*>(offset), value); }
193 
194 jbyte oopDesc::byte_field_acquire(int offset) const                   { return Atomic::load_acquire(field_addr<jbyte>(offset)); }
195 void oopDesc::release_byte_field_put(int offset, jbyte value)         { Atomic::release_store(field_addr<jbyte>(offset), value); }

 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 #include "precompiled.hpp"
 26 #include "classfile/altHashing.hpp"
 27 #include "classfile/javaClasses.inline.hpp"
 28 #include "gc/shared/collectedHeap.inline.hpp"
 29 #include "gc/shared/gc_globals.hpp"
 30 #include "memory/resourceArea.hpp"
 31 #include "memory/universe.hpp"
 32 #include "oops/access.inline.hpp"
 33 #include "oops/compressedOops.inline.hpp"
 34 #include "oops/oop.inline.hpp"
 35 #include "oops/verifyOopClosure.hpp"
 36 #include "runtime/handles.inline.hpp"
 37 #include "runtime/interfaceSupport.inline.hpp"
 38 #include "runtime/thread.inline.hpp"
 39 #include "utilities/copy.hpp"
 40 #include "utilities/macros.hpp"
 41 
 42 void oopDesc::print_on(outputStream* st) const {
 43   klass()->oop_print_on(const_cast<oopDesc*>(this), st);
 44 }
 45 
 46 void oopDesc::print_address_on(outputStream* st) const {
 47   st->print("{" INTPTR_FORMAT "}", p2i(this));
 48 
 49 }
 50 
 51 void oopDesc::print()         { print_on(tty);         }
 52 
 53 void oopDesc::print_address() { print_address_on(tty); }
 54 
 55 char* oopDesc::print_string() {
 56   stringStream st;
 57   print_on(&st);

157   if (UseCompressedClassPointers) {
158     narrowKlass narrow_klass = obj->_metadata._compressed_klass;
159     if (narrow_klass == 0) return NULL;
160     return (void*)CompressedKlassPointers::decode_raw(narrow_klass);
161   } else {
162     return obj->_metadata._klass;
163   }
164 }
165 
166 void* oopDesc::load_oop_raw(oop obj, int offset) {
167   uintptr_t addr = (uintptr_t)(void*)obj + (uint)offset;
168   if (UseCompressedOops) {
169     narrowOop narrow_oop = *(narrowOop*)addr;
170     if (CompressedOops::is_null(narrow_oop)) return NULL;
171     return (void*)CompressedOops::decode_raw(narrow_oop);
172   } else {
173     return *(void**)addr;
174   }
175 }
176 
177 JRT_LEAF(Klass*, oopDesc::load_klass_runtime(oopDesc* o))
178   assert(o != NULL, "null-check");
179   return oop(o)->klass();
180 JRT_END
181 
182 oop oopDesc::obj_field_acquire(int offset) const                      { return HeapAccess<MO_ACQUIRE>::oop_load_at(as_oop(), offset); }
183 
184 void oopDesc::obj_field_put_raw(int offset, oop value)                { RawAccess<>::oop_store_at(as_oop(), offset, value); }
185 void oopDesc::release_obj_field_put(int offset, oop value)            { HeapAccess<MO_RELEASE>::oop_store_at(as_oop(), offset, value); }
186 void oopDesc::obj_field_put_volatile(int offset, oop value)           { HeapAccess<MO_SEQ_CST>::oop_store_at(as_oop(), offset, value); }
187 
188 address oopDesc::address_field(int offset) const                      { return *field_addr<address>(offset); }
189 address oopDesc::address_field_acquire(int offset) const              { return Atomic::load_acquire(field_addr<address>(offset)); }
190 
191 void oopDesc::address_field_put(int offset, address value)            { *field_addr<address>(offset) = value; }
192 void oopDesc::release_address_field_put(int offset, address value)    { Atomic::release_store(field_addr<address>(offset), value); }
193 
194 Metadata* oopDesc::metadata_field(int offset) const                   { return *field_addr<Metadata*>(offset); }
195 void oopDesc::metadata_field_put(int offset, Metadata* value)         { *field_addr<Metadata*>(offset) = value; }
196 
197 Metadata* oopDesc::metadata_field_acquire(int offset) const           { return Atomic::load_acquire(field_addr<Metadata*>(offset)); }
198 void oopDesc::release_metadata_field_put(int offset, Metadata* value) { Atomic::release_store(field_addr<Metadata*>(offset), value); }
199 
200 jbyte oopDesc::byte_field_acquire(int offset) const                   { return Atomic::load_acquire(field_addr<jbyte>(offset)); }
201 void oopDesc::release_byte_field_put(int offset, jbyte value)         { Atomic::release_store(field_addr<jbyte>(offset), value); }
< prev index next >