2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2018-05-26 03:11:50 -04:00
|
|
|
* Copyright (c) 1997, 2018, 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"
|
|
|
|
#include "classfile/javaClasses.hpp"
|
|
|
|
#include "classfile/systemDictionary.hpp"
|
2015-04-02 10:04:27 +02:00
|
|
|
#include "oops/instanceRefKlass.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "oops/oop.inline.hpp"
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-09-07 12:04:16 -04:00
|
|
|
void InstanceRefKlass::update_nonstatic_oop_maps(Klass* k) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Clear the nonstatic oop-map entries corresponding to referent
|
2018-05-26 03:11:50 -04:00
|
|
|
// and discovered fields. They are treated specially by the
|
2007-12-01 00:00:00 +00:00
|
|
|
// garbage collector.
|
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
|
|
|
InstanceKlass* ik = InstanceKlass::cast(k);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Check that we have the right class
|
|
|
|
debug_only(static bool first_time = true);
|
2010-01-06 14:22:39 -08:00
|
|
|
assert(k == SystemDictionary::Reference_klass() && first_time,
|
2007-12-01 00:00:00 +00:00
|
|
|
"Invalid update of maps");
|
|
|
|
debug_only(first_time = false);
|
2009-08-11 15:37:23 -07:00
|
|
|
assert(ik->nonstatic_oop_map_count() == 1, "just checking");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
OopMapBlock* map = ik->start_of_nonstatic_oop_maps();
|
|
|
|
|
2018-05-26 03:11:50 -04:00
|
|
|
#ifdef ASSERT
|
|
|
|
// Verify fields are in the expected places.
|
|
|
|
int referent_offset = java_lang_ref_Reference::referent_offset;
|
|
|
|
int queue_offset = java_lang_ref_Reference::queue_offset;
|
|
|
|
int next_offset = java_lang_ref_Reference::next_offset;
|
|
|
|
int discovered_offset = java_lang_ref_Reference::discovered_offset;
|
|
|
|
assert(referent_offset < queue_offset, "just checking");
|
|
|
|
assert(queue_offset < next_offset, "just checking");
|
|
|
|
assert(next_offset < discovered_offset, "just checking");
|
|
|
|
const unsigned int count =
|
|
|
|
1 + ((discovered_offset - referent_offset) / heapOopSize);
|
|
|
|
assert(count == 4, "just checking");
|
|
|
|
#endif // ASSERT
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2018-05-26 03:11:50 -04:00
|
|
|
// Updated map starts at "queue", covers "queue" and "next".
|
|
|
|
const int new_offset = java_lang_ref_Reference::queue_offset;
|
|
|
|
const unsigned int new_count = 2; // queue and next
|
|
|
|
|
|
|
|
// Verify existing map is as expected, and update if needed.
|
2007-12-01 00:00:00 +00:00
|
|
|
if (UseSharedSpaces) {
|
2018-05-26 03:11:50 -04:00
|
|
|
assert(map->offset() == new_offset, "just checking");
|
|
|
|
assert(map->count() == new_count, "just checking");
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
2018-05-26 03:11:50 -04:00
|
|
|
assert(map->offset() == referent_offset, "just checking");
|
|
|
|
assert(map->count() == count, "just checking");
|
|
|
|
map->set_offset(new_offset);
|
|
|
|
map->set_count(new_count);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Verification
|
|
|
|
|
2012-09-07 12:04:16 -04:00
|
|
|
void InstanceRefKlass::oop_verify_on(oop obj, outputStream* st) {
|
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
|
|
|
InstanceKlass::oop_verify_on(obj, st);
|
2007-12-01 00:00:00 +00:00
|
|
|
// Verify referent field
|
|
|
|
oop referent = java_lang_ref_Reference::referent(obj);
|
|
|
|
if (referent != NULL) {
|
2017-08-23 14:52:55 -04:00
|
|
|
guarantee(oopDesc::is_oop(referent), "referent field heap failed");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2018-05-26 03:11:50 -04:00
|
|
|
// Additional verification for next field, which must be a Reference or null
|
2007-12-01 00:00:00 +00:00
|
|
|
oop next = java_lang_ref_Reference::next(obj);
|
|
|
|
if (next != NULL) {
|
2017-08-23 14:52:55 -04:00
|
|
|
guarantee(oopDesc::is_oop(next), "next field should be an oop");
|
2015-10-28 09:47:23 -04:00
|
|
|
guarantee(next->is_instance(), "next field should be an instance");
|
|
|
|
guarantee(InstanceKlass::cast(next->klass())->is_reference_instance_klass(), "next field verify failed");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|