1 /*
2 * Copyright (c) 1997, 2017, 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 *
1023 }
1024 #endif // INCLUDE_JVMTI
1025
1026 // CDS/RedefineClasses support - clear vtables so they can be reinitialized
1027 void klassVtable::clear_vtable() {
1028 for (int i = 0; i < _length; i++) table()[i].clear();
1029 }
1030
1031 bool klassVtable::is_initialized() {
1032 return _length == 0 || table()[0].method() != NULL;
1033 }
1034
1035 //-----------------------------------------------------------------------------------------
1036 // Itable code
1037
1038 // Initialize a itableMethodEntry
1039 void itableMethodEntry::initialize(Method* m) {
1040 if (m == NULL) return;
1041
1042 #ifdef ASSERT
1043 if (MetaspaceShared::is_in_shared_space((void*)&_method) &&
1044 !MetaspaceShared::remapped_readwrite()) {
1045 // At runtime initialize_itable is rerun as part of link_class_impl()
1046 // for a shared class loaded by the non-boot loader.
1047 // The dumptime itable method entry should be the same as the runtime entry.
1048 assert(_method == m, "sanity");
1049 }
1050 #endif
1051 _method = m;
1052 }
1053
1054 klassItable::klassItable(InstanceKlass* klass) {
1055 _klass = klass;
1056
1057 if (klass->itable_length() > 0) {
1058 itableOffsetEntry* offset_entry = (itableOffsetEntry*)klass->start_of_itable();
1059 if (offset_entry != NULL && offset_entry->interface_klass() != NULL) { // Check that itable is initialized
1060 // First offset entry points to the first method_entry
1061 intptr_t* method_entry = (intptr_t *)(((address)klass) + offset_entry->offset());
1062 intptr_t* end = klass->end_of_itable();
1063
|
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 *
1023 }
1024 #endif // INCLUDE_JVMTI
1025
1026 // CDS/RedefineClasses support - clear vtables so they can be reinitialized
1027 void klassVtable::clear_vtable() {
1028 for (int i = 0; i < _length; i++) table()[i].clear();
1029 }
1030
1031 bool klassVtable::is_initialized() {
1032 return _length == 0 || table()[0].method() != NULL;
1033 }
1034
1035 //-----------------------------------------------------------------------------------------
1036 // Itable code
1037
1038 // Initialize a itableMethodEntry
1039 void itableMethodEntry::initialize(Method* m) {
1040 if (m == NULL) return;
1041
1042 #ifdef ASSERT
1043 if (MetaspaceShared::is_in_shared_metaspace((void*)&_method) &&
1044 !MetaspaceShared::remapped_readwrite()) {
1045 // At runtime initialize_itable is rerun as part of link_class_impl()
1046 // for a shared class loaded by the non-boot loader.
1047 // The dumptime itable method entry should be the same as the runtime entry.
1048 assert(_method == m, "sanity");
1049 }
1050 #endif
1051 _method = m;
1052 }
1053
1054 klassItable::klassItable(InstanceKlass* klass) {
1055 _klass = klass;
1056
1057 if (klass->itable_length() > 0) {
1058 itableOffsetEntry* offset_entry = (itableOffsetEntry*)klass->start_of_itable();
1059 if (offset_entry != NULL && offset_entry->interface_klass() != NULL) { // Check that itable is initialized
1060 // First offset entry points to the first method_entry
1061 intptr_t* method_entry = (intptr_t *)(((address)klass) + offset_entry->offset());
1062 intptr_t* end = klass->end_of_itable();
1063
|