1 /*
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
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 *
180 set_secondary_supers(NULL);
181 set_secondary_super_cache(NULL);
182 _primary_supers[0] = k;
183 set_super_check_offset(in_bytes(primary_supers_offset()));
184
185 // The constructor is used from init_self_patching_vtbl_list,
186 // which doesn't zero out the memory before calling the constructor.
187 // Need to set the field explicitly to not hit an assert that the field
188 // should be NULL before setting it.
189 _java_mirror = NULL;
190
191 set_modifier_flags(0);
192 set_layout_helper(Klass::_lh_neutral_value);
193 set_name(NULL);
194 AccessFlags af;
195 af.set_flags(0);
196 set_access_flags(af);
197 set_subklass(NULL);
198 set_next_sibling(NULL);
199 set_next_link(NULL);
200 TRACE_INIT_ID(this);
201
202 set_prototype_header(markOopDesc::prototype());
203 set_biased_lock_revocation_count(0);
204 set_last_biased_lock_bulk_revocation_time(0);
205
206 // The klass doesn't have any references at this point.
207 clear_modified_oops();
208 clear_accumulated_modified_oops();
209 _shared_class_path_index = -1;
210 }
211
212 jint Klass::array_layout_helper(BasicType etype) {
213 assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
214 // Note that T_ARRAY is not allowed here.
215 int hsize = arrayOopDesc::base_offset_in_bytes(etype);
216 int esize = type2aelembytes(etype);
217 bool isobj = (etype == T_OBJECT);
218 int tag = isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
219 int lh = array_layout_helper(tag, hsize, etype, exact_log2(esize));
220
507 klass_update_barrier_set_pre(p, v);
508 *p = v;
509 klass_update_barrier_set(v);
510 }
511 }
512
513 void Klass::klass_oop_store(volatile oop* p, oop v) {
514 assert(!Universe::heap()->is_in_reserved((void*)p), "Should store pointer into metadata");
515 assert(v == NULL || Universe::heap()->is_in_reserved((void*)v), "Should store pointer to an object");
516
517 klass_update_barrier_set_pre((oop*)p, v); // Cast away volatile.
518 OrderAccess::release_store_ptr(p, v);
519 klass_update_barrier_set(v);
520 }
521
522 void Klass::oops_do(OopClosure* cl) {
523 cl->do_oop(&_java_mirror);
524 }
525
526 void Klass::remove_unshareable_info() {
527 assert (DumpSharedSpaces, "only called for DumpSharedSpaces");
528
529 set_subklass(NULL);
530 set_next_sibling(NULL);
531 // Clear the java mirror
532 set_java_mirror(NULL);
533 set_next_link(NULL);
534
535 // Null out class_loader_data because we don't share that yet.
536 set_class_loader_data(NULL);
537 }
538
539 void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
540 TRACE_INIT_ID(this);
541 // If an exception happened during CDS restore, some of these fields may already be
542 // set. We leave the class on the CLD list, even if incomplete so that we don't
543 // modify the CLD list outside a safepoint.
544 if (class_loader_data() == NULL) {
545 // Restore class_loader_data
546 set_class_loader_data(loader_data);
547
548 // Add to class loader list first before creating the mirror
549 // (same order as class file parsing)
550 loader_data->add_class(this);
551 }
552
553 // Recreate the class mirror.
554 // Only recreate it if not present. A previous attempt to restore may have
555 // gotten an OOM later but keep the mirror if it was created.
556 if (java_mirror() == NULL) {
557 java_lang_Class::create_mirror(this, class_loader(), protection_domain, CHECK);
558 }
559 }
560
|
1 /*
2 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
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 *
180 set_secondary_supers(NULL);
181 set_secondary_super_cache(NULL);
182 _primary_supers[0] = k;
183 set_super_check_offset(in_bytes(primary_supers_offset()));
184
185 // The constructor is used from init_self_patching_vtbl_list,
186 // which doesn't zero out the memory before calling the constructor.
187 // Need to set the field explicitly to not hit an assert that the field
188 // should be NULL before setting it.
189 _java_mirror = NULL;
190
191 set_modifier_flags(0);
192 set_layout_helper(Klass::_lh_neutral_value);
193 set_name(NULL);
194 AccessFlags af;
195 af.set_flags(0);
196 set_access_flags(af);
197 set_subklass(NULL);
198 set_next_sibling(NULL);
199 set_next_link(NULL);
200
201 set_prototype_header(markOopDesc::prototype());
202 set_biased_lock_revocation_count(0);
203 set_last_biased_lock_bulk_revocation_time(0);
204
205 // The klass doesn't have any references at this point.
206 clear_modified_oops();
207 clear_accumulated_modified_oops();
208 _shared_class_path_index = -1;
209 }
210
211 jint Klass::array_layout_helper(BasicType etype) {
212 assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
213 // Note that T_ARRAY is not allowed here.
214 int hsize = arrayOopDesc::base_offset_in_bytes(etype);
215 int esize = type2aelembytes(etype);
216 bool isobj = (etype == T_OBJECT);
217 int tag = isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
218 int lh = array_layout_helper(tag, hsize, etype, exact_log2(esize));
219
506 klass_update_barrier_set_pre(p, v);
507 *p = v;
508 klass_update_barrier_set(v);
509 }
510 }
511
512 void Klass::klass_oop_store(volatile oop* p, oop v) {
513 assert(!Universe::heap()->is_in_reserved((void*)p), "Should store pointer into metadata");
514 assert(v == NULL || Universe::heap()->is_in_reserved((void*)v), "Should store pointer to an object");
515
516 klass_update_barrier_set_pre((oop*)p, v); // Cast away volatile.
517 OrderAccess::release_store_ptr(p, v);
518 klass_update_barrier_set(v);
519 }
520
521 void Klass::oops_do(OopClosure* cl) {
522 cl->do_oop(&_java_mirror);
523 }
524
525 void Klass::remove_unshareable_info() {
526 TRACE_REMOVE_ID(this);
527 assert (DumpSharedSpaces, "only called for DumpSharedSpaces");
528
529 set_subklass(NULL);
530 set_next_sibling(NULL);
531 // Clear the java mirror
532 set_java_mirror(NULL);
533 set_next_link(NULL);
534
535 // Null out class_loader_data because we don't share that yet.
536 set_class_loader_data(NULL);
537 }
538
539 void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
540 TRACE_RESTORE_ID(this);
541 // If an exception happened during CDS restore, some of these fields may already be
542 // set. We leave the class on the CLD list, even if incomplete so that we don't
543 // modify the CLD list outside a safepoint.
544 if (class_loader_data() == NULL) {
545 // Restore class_loader_data
546 set_class_loader_data(loader_data);
547
548 // Add to class loader list first before creating the mirror
549 // (same order as class file parsing)
550 loader_data->add_class(this);
551 }
552
553 // Recreate the class mirror.
554 // Only recreate it if not present. A previous attempt to restore may have
555 // gotten an OOM later but keep the mirror if it was created.
556 if (java_mirror() == NULL) {
557 java_lang_Class::create_mirror(this, class_loader(), protection_domain, CHECK);
558 }
559 }
560
|