< prev index next >

src/hotspot/share/oops/oop.cpp

Print this page




   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 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 "memory/resourceArea.hpp"

  29 #include "oops/oop.inline.hpp"
  30 #include "oops/verifyOopClosure.hpp"
  31 #include "runtime/handles.inline.hpp"
  32 #include "runtime/thread.inline.hpp"
  33 #include "utilities/copy.hpp"
  34 #if INCLUDE_ALL_GCS
  35 #include "gc/g1/g1Allocator.inline.hpp"
  36 #endif
  37 
  38 bool always_do_update_barrier = false;
  39 
  40 void oopDesc::print_on(outputStream* st) const {
  41   if (this == NULL) {
  42     st->print_cr("NULL");
  43   } else {
  44     klass()->oop_print_on(oop(this), st);
  45   }
  46 }
  47 
  48 void oopDesc::print_address_on(outputStream* st) const {


 138   }
 139   return !SafepointSynchronize::is_at_safepoint();
 140 }
 141 
 142 // used only for asserts and guarantees
 143 bool oopDesc::is_oop_or_null(oop obj, bool ignore_mark_word) {
 144   return obj == NULL ? true : is_oop(obj, ignore_mark_word);
 145 }
 146 
 147 #ifndef PRODUCT
 148 // used only for asserts
 149 bool oopDesc::is_unlocked_oop() const {
 150   if (!Universe::heap()->is_in_reserved(this)) return false;
 151   return mark()->is_unlocked();
 152 }
 153 #endif // PRODUCT
 154 
 155 VerifyOopClosure VerifyOopClosure::verify_oop;
 156 
 157 template <class T> void VerifyOopClosure::do_oop_work(T* p) {
 158   oop obj = oopDesc::load_decode_heap_oop(p);
 159   guarantee(oopDesc::is_oop_or_null(obj), "invalid oop: " INTPTR_FORMAT, p2i((oopDesc*) obj));
 160 }
 161 
 162 void VerifyOopClosure::do_oop(oop* p)       { VerifyOopClosure::do_oop_work(p); }
 163 void VerifyOopClosure::do_oop(narrowOop* p) { VerifyOopClosure::do_oop_work(p); }
 164 
 165 // type test operations that doesn't require inclusion of oop.inline.hpp.
 166 bool oopDesc::is_instance_noinline()          const { return is_instance();            }
 167 bool oopDesc::is_array_noinline()             const { return is_array();               }
 168 bool oopDesc::is_objArray_noinline()          const { return is_objArray();            }
 169 bool oopDesc::is_typeArray_noinline()         const { return is_typeArray();           }
 170 
 171 bool oopDesc::has_klass_gap() {
 172   // Only has a klass gap when compressed class pointers are used.
 173   return UseCompressedClassPointers;
 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); }




   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 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 "memory/resourceArea.hpp"
  29 #include "oops/access.inline.hpp"
  30 #include "oops/oop.inline.hpp"
  31 #include "oops/verifyOopClosure.hpp"
  32 #include "runtime/handles.inline.hpp"
  33 #include "runtime/thread.inline.hpp"
  34 #include "utilities/copy.hpp"
  35 #if INCLUDE_ALL_GCS
  36 #include "gc/g1/g1Allocator.inline.hpp"
  37 #endif
  38 
  39 bool always_do_update_barrier = false;
  40 
  41 void oopDesc::print_on(outputStream* st) const {
  42   if (this == NULL) {
  43     st->print_cr("NULL");
  44   } else {
  45     klass()->oop_print_on(oop(this), st);
  46   }
  47 }
  48 
  49 void oopDesc::print_address_on(outputStream* st) const {


 139   }
 140   return !SafepointSynchronize::is_at_safepoint();
 141 }
 142 
 143 // used only for asserts and guarantees
 144 bool oopDesc::is_oop_or_null(oop obj, bool ignore_mark_word) {
 145   return obj == NULL ? true : is_oop(obj, ignore_mark_word);
 146 }
 147 
 148 #ifndef PRODUCT
 149 // used only for asserts
 150 bool oopDesc::is_unlocked_oop() const {
 151   if (!Universe::heap()->is_in_reserved(this)) return false;
 152   return mark()->is_unlocked();
 153 }
 154 #endif // PRODUCT
 155 
 156 VerifyOopClosure VerifyOopClosure::verify_oop;
 157 
 158 template <class T> void VerifyOopClosure::do_oop_work(T* p) {
 159   oop obj = RawAccess<>::oop_load(p);
 160   guarantee(oopDesc::is_oop_or_null(obj), "invalid oop: " INTPTR_FORMAT, p2i((oopDesc*) obj));
 161 }
 162 
 163 void VerifyOopClosure::do_oop(oop* p)       { VerifyOopClosure::do_oop_work(p); }
 164 void VerifyOopClosure::do_oop(narrowOop* p) { VerifyOopClosure::do_oop_work(p); }
 165 
 166 // type test operations that doesn't require inclusion of oop.inline.hpp.
 167 bool oopDesc::is_instance_noinline()          const { return is_instance();            }
 168 bool oopDesc::is_array_noinline()             const { return is_array();               }
 169 bool oopDesc::is_objArray_noinline()          const { return is_objArray();            }
 170 bool oopDesc::is_typeArray_noinline()         const { return is_typeArray();           }
 171 
 172 bool oopDesc::has_klass_gap() {
 173   // Only has a klass gap when compressed class pointers are used.
 174   return UseCompressedClassPointers;
 175 }
 176 
 177 oop oopDesc::obj_field_acquire(int offset) const                      { return HeapAccess<MO_ACQUIRE>::oop_load_at(as_oop(), offset); }
 178 
 179 void oopDesc::obj_field_put_raw(int offset, oop value)                { RawAccess<>::oop_store_at(as_oop(), offset, value); }


< prev index next >