2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2017-02-15 22:59:57 -05:00
|
|
|
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* 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.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#include "classfile/altHashing.hpp"
|
2015-02-13 14:37:35 +01:00
|
|
|
#include "classfile/javaClasses.inline.hpp"
|
2016-04-04 12:57:48 -04:00
|
|
|
#include "memory/resourceArea.hpp"
|
2018-03-15 21:24:10 +01:00
|
|
|
#include "oops/access.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "oops/oop.inline.hpp"
|
2015-02-18 08:57:29 +01:00
|
|
|
#include "oops/verifyOopClosure.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "runtime/handles.inline.hpp"
|
2012-11-27 14:20:21 +01:00
|
|
|
#include "runtime/thread.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "utilities/copy.hpp"
|
2017-08-14 14:32:17 -04:00
|
|
|
#if INCLUDE_ALL_GCS
|
|
|
|
#include "gc/g1/g1Allocator.inline.hpp"
|
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
bool always_do_update_barrier = false;
|
|
|
|
|
|
|
|
void oopDesc::print_on(outputStream* st) const {
|
|
|
|
if (this == NULL) {
|
|
|
|
st->print_cr("NULL");
|
|
|
|
} else {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
klass()->oop_print_on(oop(this), st);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void oopDesc::print_address_on(outputStream* st) const {
|
2016-03-24 13:25:10 -04:00
|
|
|
st->print("{" INTPTR_FORMAT "}", p2i(this));
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void oopDesc::print() { print_on(tty); }
|
|
|
|
|
|
|
|
void oopDesc::print_address() { print_address_on(tty); }
|
|
|
|
|
|
|
|
char* oopDesc::print_string() {
|
2010-01-08 13:47:01 -08:00
|
|
|
stringStream st;
|
|
|
|
print_on(&st);
|
|
|
|
return st.as_string();
|
|
|
|
}
|
|
|
|
|
|
|
|
void oopDesc::print_value() {
|
|
|
|
print_value_on(tty);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
char* oopDesc::print_value_string() {
|
2010-01-08 13:47:01 -08:00
|
|
|
char buf[100];
|
|
|
|
stringStream st(buf, sizeof(buf));
|
|
|
|
print_value_on(&st);
|
|
|
|
return st.as_string();
|
|
|
|
}
|
|
|
|
|
|
|
|
void oopDesc::print_value_on(outputStream* st) const {
|
|
|
|
oop obj = oop(this);
|
|
|
|
if (this == NULL) {
|
|
|
|
st->print("NULL");
|
|
|
|
} else if (java_lang_String::is_instance(obj)) {
|
|
|
|
java_lang_String::print(obj, st);
|
2016-03-24 13:25:10 -04:00
|
|
|
print_address_on(st);
|
2010-01-08 13:47:01 -08:00
|
|
|
} else {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
klass()->oop_print_value_on(obj, st);
|
2010-01-08 13:47:01 -08:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void oopDesc::verify_on(outputStream* st) {
|
|
|
|
if (this != NULL) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
klass()->oop_verify_on(this, st);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void oopDesc::verify() {
|
|
|
|
verify_on(tty);
|
|
|
|
}
|
|
|
|
|
|
|
|
intptr_t oopDesc::slow_identity_hash() {
|
|
|
|
// slow case; we have to acquire the micro lock in order to locate the header
|
2017-02-15 22:59:57 -05:00
|
|
|
Thread* THREAD = Thread::current();
|
2007-12-01 00:00:00 +00:00
|
|
|
ResetNoHandleMark rnm; // Might be called from LEAF/QUICK ENTRY
|
2017-02-15 22:59:57 -05:00
|
|
|
HandleMark hm(THREAD);
|
|
|
|
Handle object(THREAD, this);
|
2007-12-01 00:00:00 +00:00
|
|
|
return ObjectSynchronizer::identity_hash_value_for(object);
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// When String table needs to rehash
|
2014-02-10 21:29:14 -08:00
|
|
|
unsigned int oopDesc::new_hash(juint seed) {
|
2013-04-29 16:13:57 -04:00
|
|
|
EXCEPTION_MARK;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
ResourceMark rm;
|
|
|
|
int length;
|
2013-04-29 16:13:57 -04:00
|
|
|
jchar* chars = java_lang_String::as_unicode_string(this, length, THREAD);
|
|
|
|
if (chars != NULL) {
|
|
|
|
// Use alternate hashing algorithm on the string
|
|
|
|
return AltHashing::murmur3_32(seed, chars, length);
|
|
|
|
} else {
|
2013-04-30 11:56:52 -07:00
|
|
|
vm_exit_out_of_memory(length, OOM_MALLOC_ERROR, "unable to create Unicode strings for String table rehash");
|
2013-04-29 16:13:57 -04:00
|
|
|
return 0;
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2017-08-23 14:52:55 -04:00
|
|
|
// used only for asserts and guarantees
|
|
|
|
bool oopDesc::is_oop(oop obj, bool ignore_mark_word) {
|
|
|
|
if (!check_obj_alignment(obj)) return false;
|
|
|
|
if (!Universe::heap()->is_in_reserved(obj)) return false;
|
|
|
|
// obj is aligned and accessible in heap
|
|
|
|
if (Universe::heap()->is_in_reserved(obj->klass_or_null())) return false;
|
|
|
|
|
|
|
|
// Header verification: the mark is typically non-NULL. If we're
|
|
|
|
// at a safepoint, it must not be null.
|
|
|
|
// Outside of a safepoint, the header could be changing (for example,
|
|
|
|
// another thread could be inflating a lock on this object).
|
|
|
|
if (ignore_mark_word) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (obj->mark() != NULL) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return !SafepointSynchronize::is_at_safepoint();
|
|
|
|
}
|
|
|
|
|
|
|
|
// used only for asserts and guarantees
|
|
|
|
bool oopDesc::is_oop_or_null(oop obj, bool ignore_mark_word) {
|
|
|
|
return obj == NULL ? true : is_oop(obj, ignore_mark_word);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef PRODUCT
|
|
|
|
// used only for asserts
|
|
|
|
bool oopDesc::is_unlocked_oop() const {
|
|
|
|
if (!Universe::heap()->is_in_reserved(this)) return false;
|
|
|
|
return mark()->is_unlocked();
|
|
|
|
}
|
|
|
|
#endif // PRODUCT
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
VerifyOopClosure VerifyOopClosure::verify_oop;
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
|
2015-02-18 08:57:29 +01:00
|
|
|
template <class T> void VerifyOopClosure::do_oop_work(T* p) {
|
2018-03-15 21:24:10 +01:00
|
|
|
oop obj = RawAccess<>::oop_load(p);
|
2017-08-23 14:52:55 -04:00
|
|
|
guarantee(oopDesc::is_oop_or_null(obj), "invalid oop: " INTPTR_FORMAT, p2i((oopDesc*) obj));
|
2015-02-18 08:57:29 +01:00
|
|
|
}
|
|
|
|
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
void VerifyOopClosure::do_oop(oop* p) { VerifyOopClosure::do_oop_work(p); }
|
|
|
|
void VerifyOopClosure::do_oop(narrowOop* p) { VerifyOopClosure::do_oop_work(p); }
|
2015-02-13 14:37:35 +01:00
|
|
|
|
|
|
|
// type test operations that doesn't require inclusion of oop.inline.hpp.
|
|
|
|
bool oopDesc::is_instance_noinline() const { return is_instance(); }
|
|
|
|
bool oopDesc::is_array_noinline() const { return is_array(); }
|
|
|
|
bool oopDesc::is_objArray_noinline() const { return is_objArray(); }
|
|
|
|
bool oopDesc::is_typeArray_noinline() const { return is_typeArray(); }
|
|
|
|
|
|
|
|
bool oopDesc::has_klass_gap() {
|
|
|
|
// Only has a klass gap when compressed class pointers are used.
|
|
|
|
return UseCompressedClassPointers;
|
|
|
|
}
|
2017-08-14 14:32:17 -04:00
|
|
|
|
2017-11-20 13:07:44 +01:00
|
|
|
oop oopDesc::obj_field_acquire(int offset) const { return HeapAccess<MO_ACQUIRE>::oop_load_at(as_oop(), offset); }
|
|
|
|
|
|
|
|
void oopDesc::obj_field_put_raw(int offset, oop value) { RawAccess<>::oop_store_at(as_oop(), offset, value); }
|
|
|
|
void oopDesc::release_obj_field_put(int offset, oop value) { HeapAccess<MO_RELEASE>::oop_store_at(as_oop(), offset, value); }
|
|
|
|
void oopDesc::obj_field_put_volatile(int offset, oop value) { HeapAccess<MO_SEQ_CST>::oop_store_at(as_oop(), offset, value); }
|
|
|
|
|
|
|
|
address oopDesc::address_field(int offset) const { return HeapAccess<>::load_at(as_oop(), offset); }
|
|
|
|
address oopDesc::address_field_acquire(int offset) const { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); }
|
|
|
|
|
|
|
|
void oopDesc::address_field_put(int offset, address value) { HeapAccess<>::store_at(as_oop(), offset, value); }
|
|
|
|
void oopDesc::release_address_field_put(int offset, address value) { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); }
|
|
|
|
|
|
|
|
Metadata* oopDesc::metadata_field(int offset) const { return HeapAccess<>::load_at(as_oop(), offset); }
|
|
|
|
void oopDesc::metadata_field_put(int offset, Metadata* value) { HeapAccess<>::store_at(as_oop(), offset, value); }
|
|
|
|
|
|
|
|
Metadata* oopDesc::metadata_field_acquire(int offset) const { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); }
|
|
|
|
void oopDesc::release_metadata_field_put(int offset, Metadata* value) { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); }
|
|
|
|
|
|
|
|
jbyte oopDesc::byte_field_acquire(int offset) const { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); }
|
|
|
|
void oopDesc::release_byte_field_put(int offset, jbyte value) { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); }
|
|
|
|
|
|
|
|
jchar oopDesc::char_field_acquire(int offset) const { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); }
|
|
|
|
void oopDesc::release_char_field_put(int offset, jchar value) { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); }
|
|
|
|
|
|
|
|
jboolean oopDesc::bool_field_acquire(int offset) const { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); }
|
|
|
|
void oopDesc::release_bool_field_put(int offset, jboolean value) { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, jboolean(value & 1)); }
|
|
|
|
|
|
|
|
jint oopDesc::int_field_acquire(int offset) const { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); }
|
|
|
|
void oopDesc::release_int_field_put(int offset, jint value) { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); }
|
|
|
|
|
|
|
|
jshort oopDesc::short_field_acquire(int offset) const { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); }
|
|
|
|
void oopDesc::release_short_field_put(int offset, jshort value) { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); }
|
|
|
|
|
|
|
|
jlong oopDesc::long_field_acquire(int offset) const { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); }
|
|
|
|
void oopDesc::release_long_field_put(int offset, jlong value) { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); }
|
|
|
|
|
|
|
|
jfloat oopDesc::float_field_acquire(int offset) const { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); }
|
|
|
|
void oopDesc::release_float_field_put(int offset, jfloat value) { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); }
|
|
|
|
|
|
|
|
jdouble oopDesc::double_field_acquire(int offset) const { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); }
|
|
|
|
void oopDesc::release_double_field_put(int offset, jdouble value) { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); }
|
|
|
|
|
2017-08-14 14:32:17 -04:00
|
|
|
#if INCLUDE_CDS_JAVA_HEAP
|
|
|
|
bool oopDesc::is_archive_object(oop p) {
|
|
|
|
return (p == NULL) ? false : G1ArchiveAllocator::is_archive_object(p);
|
|
|
|
}
|
|
|
|
#endif
|