1.1 --- a/src/share/vm/oops/method.cpp Mon Jul 04 14:29:23 2016 -0700 1.2 +++ b/src/share/vm/oops/method.cpp Tue Jul 05 15:18:38 2016 -0700 1.3 @@ -36,6 +36,7 @@ 1.4 #include "memory/generation.hpp" 1.5 #include "memory/heapInspection.hpp" 1.6 #include "memory/metadataFactory.hpp" 1.7 +#include "memory/metaspaceShared.hpp" 1.8 #include "memory/oopFactory.hpp" 1.9 #include "oops/constMethod.hpp" 1.10 #include "oops/methodData.hpp" 1.11 @@ -305,6 +306,33 @@ 1.12 unlink_method(); 1.13 } 1.14 1.15 +void Method::set_vtable_index(int index) { 1.16 + if (is_shared() && !MetaspaceShared::remapped_readwrite()) { 1.17 + // At runtime initialize_vtable is rerun as part of link_class_impl() 1.18 + // for a shared class loaded by the non-boot loader to obtain the loader 1.19 + // constraints based on the runtime classloaders' context. 1.20 + return; // don't write into the shared class 1.21 + } else { 1.22 + _vtable_index = index; 1.23 + } 1.24 +} 1.25 + 1.26 +void Method::set_itable_index(int index) { 1.27 + if (is_shared() && !MetaspaceShared::remapped_readwrite()) { 1.28 + // At runtime initialize_itable is rerun as part of link_class_impl() 1.29 + // for a shared class loaded by the non-boot loader to obtain the loader 1.30 + // constraints based on the runtime classloaders' context. The dumptime 1.31 + // itable index should be the same as the runtime index. 1.32 + assert(_vtable_index == itable_index_max - index, 1.33 + "archived itable index is different from runtime index"); 1.34 + return; // don’t write into the shared class 1.35 + } else { 1.36 + _vtable_index = itable_index_max - index; 1.37 + } 1.38 + assert(valid_itable_index(), ""); 1.39 +} 1.40 + 1.41 + 1.42 1.43 bool Method::was_executed_more_than(int n) { 1.44 // Invocation counter is reset when the Method* is compiled.