8176705: Remove static functions in InstanceKlass
authorhseigel
Tue, 21 Mar 2017 11:25:18 -0400
changeset 46341 4c676683bdb9
parent 46340 9c2be834d6e3
child 46342 c871e0f8b02a
child 46367 6e532778cb35
8176705: Remove static functions in InstanceKlass Summary: Change static functions to instance functions and remove their 'this_k' parameters. Reviewed-by: dholmes, mgerdin, iklam
hotspot/src/share/vm/oops/instanceKlass.cpp
hotspot/src/share/vm/oops/instanceKlass.hpp
hotspot/src/share/vm/oops/method.hpp
hotspot/src/share/vm/prims/jvm.cpp
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp	Tue Mar 21 11:21:11 2017 +0100
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp	Tue Mar 21 11:25:18 2017 -0400
@@ -88,36 +88,36 @@
 #define HOTSPOT_CLASS_INITIALIZATION_clinit HOTSPOT_CLASS_INITIALIZATION_CLINIT
 #define HOTSPOT_CLASS_INITIALIZATION_error HOTSPOT_CLASS_INITIALIZATION_ERROR
 #define HOTSPOT_CLASS_INITIALIZATION_end HOTSPOT_CLASS_INITIALIZATION_END
-#define DTRACE_CLASSINIT_PROBE(type, clss, thread_type)          \
+#define DTRACE_CLASSINIT_PROBE(type, thread_type)                \
   {                                                              \
     char* data = NULL;                                           \
     int len = 0;                                                 \
-    Symbol* name = (clss)->name();                               \
-    if (name != NULL) {                                          \
-      data = (char*)name->bytes();                               \
-      len = name->utf8_length();                                 \
+    Symbol* clss_name = name();                                  \
+    if (clss_name != NULL) {                                     \
+      data = (char*)clss_name->bytes();                          \
+      len = clss_name->utf8_length();                            \
     }                                                            \
     HOTSPOT_CLASS_INITIALIZATION_##type(                         \
-      data, len, (clss)->class_loader(), thread_type);           \
+      data, len, class_loader(), thread_type);                   \
   }
 
-#define DTRACE_CLASSINIT_PROBE_WAIT(type, clss, thread_type, wait) \
+#define DTRACE_CLASSINIT_PROBE_WAIT(type, thread_type, wait)     \
   {                                                              \
     char* data = NULL;                                           \
     int len = 0;                                                 \
-    Symbol* name = (clss)->name();                               \
-    if (name != NULL) {                                          \
-      data = (char*)name->bytes();                               \
-      len = name->utf8_length();                                 \
+    Symbol* clss_name = name();                                  \
+    if (clss_name != NULL) {                                     \
+      data = (char*)clss_name->bytes();                          \
+      len = clss_name->utf8_length();                            \
     }                                                            \
     HOTSPOT_CLASS_INITIALIZATION_##type(                         \
-      data, len, (clss)->class_loader(), thread_type, wait);     \
+      data, len, class_loader(), thread_type, wait);             \
   }
 
 #else //  ndef DTRACE_ENABLED
 
-#define DTRACE_CLASSINIT_PROBE(type, clss, thread_type)
-#define DTRACE_CLASSINIT_PROBE_WAIT(type, clss, thread_type, wait)
+#define DTRACE_CLASSINIT_PROBE(type, thread_type)
+#define DTRACE_CLASSINIT_PROBE_WAIT(type, thread_type, wait)
 
 #endif //  ndef DTRACE_ENABLED
 
@@ -385,14 +385,14 @@
     if (this->class_initializer() != NULL) return;
 
     // abort if it is java.lang.Object (initialization is handled in genesis)
-    Klass* super = this->super();
-    if (super == NULL) return;
+    Klass* super_klass = super();
+    if (super_klass == NULL) return;
 
     // abort if the super class should be initialized
-    if (!InstanceKlass::cast(super)->is_initialized()) return;
+    if (!InstanceKlass::cast(super_klass)->is_initialized()) return;
 
     // call body to expose the this pointer
-    eager_initialize_impl(this);
+    eager_initialize_impl();
   }
 }
 
@@ -431,17 +431,17 @@
   assert(!is_not_initialized(), "class must be initialized now");
 }
 
-void InstanceKlass::eager_initialize_impl(InstanceKlass* this_k) {
+void InstanceKlass::eager_initialize_impl() {
   EXCEPTION_MARK;
   HandleMark hm(THREAD);
-  Handle init_lock(THREAD, this_k->init_lock());
-  ObjectLocker ol(init_lock, THREAD, init_lock() != NULL);
+  Handle h_init_lock(THREAD, init_lock());
+  ObjectLocker ol(h_init_lock, THREAD, init_lock() != NULL);
 
   // abort if someone beat us to the initialization
-  if (!this_k->is_not_initialized()) return;  // note: not equivalent to is_initialized()
-
-  ClassState old_state = this_k->init_state();
-  link_class_impl(this_k, true, THREAD);
+  if (!is_not_initialized()) return;  // note: not equivalent to is_initialized()
+
+  ClassState old_state = init_state();
+  link_class_impl(true, THREAD);
   if (HAS_PENDING_EXCEPTION) {
     CLEAR_PENDING_EXCEPTION;
     // Abort if linking the class throws an exception.
@@ -449,16 +449,16 @@
     // Use a test to avoid redundantly resetting the state if there's
     // no change.  Set_init_state() asserts that state changes make
     // progress, whereas here we might just be spinning in place.
-    if( old_state != this_k->_init_state )
-      this_k->set_init_state (old_state);
+    if (old_state != _init_state)
+      set_init_state(old_state);
   } else {
     // linking successfull, mark class as initialized
-    this_k->set_init_state (fully_initialized);
-    this_k->fence_and_clear_init_lock();
+    set_init_state(fully_initialized);
+    fence_and_clear_init_lock();
     // trace
     if (log_is_enabled(Info, class, init)) {
       ResourceMark rm(THREAD);
-      log_info(class, init)("[Initialized %s without side effects]", this_k->external_name());
+      log_info(class, init)("[Initialized %s without side effects]", external_name());
     }
   }
 }
@@ -469,7 +469,7 @@
 // Note: implementation moved to static method to expose the this pointer.
 void InstanceKlass::initialize(TRAPS) {
   if (this->should_be_initialized()) {
-    initialize_impl(this, CHECK);
+    initialize_impl(CHECK);
     // Note: at this point the class may be initialized
     //       OR it may be in the state of being initialized
     //       in case of recursive initialization!
@@ -479,12 +479,11 @@
 }
 
 
-bool InstanceKlass::verify_code(
-    InstanceKlass* this_k, bool throw_verifyerror, TRAPS) {
+bool InstanceKlass::verify_code(bool throw_verifyerror, TRAPS) {
   // 1) Verify the bytecodes
   Verifier::Mode mode =
     throw_verifyerror ? Verifier::ThrowException : Verifier::NoException;
-  return Verifier::verify(this_k, mode, this_k->should_verify_class(), THREAD);
+  return Verifier::verify(this, mode, should_verify_class(), THREAD);
 }
 
 
@@ -499,7 +498,7 @@
 void InstanceKlass::link_class(TRAPS) {
   assert(is_loaded(), "must be loaded");
   if (!is_linked()) {
-    link_class_impl(this, true, CHECK);
+    link_class_impl(true, CHECK);
   }
 }
 
@@ -508,14 +507,13 @@
 bool InstanceKlass::link_class_or_fail(TRAPS) {
   assert(is_loaded(), "must be loaded");
   if (!is_linked()) {
-    link_class_impl(this, false, CHECK_false);
+    link_class_impl(false, CHECK_false);
   }
   return is_linked();
 }
 
-bool InstanceKlass::link_class_impl(
-    InstanceKlass* this_k, bool throw_verifyerror, TRAPS) {
-  if (DumpSharedSpaces && this_k->is_in_error_state()) {
+bool InstanceKlass::link_class_impl(bool throw_verifyerror, TRAPS) {
+  if (DumpSharedSpaces && is_in_error_state()) {
     // This is for CDS dumping phase only -- we use the in_error_state to indicate that
     // the class has failed verification. Throwing the NoClassDefFoundError here is just
     // a convenient way to stop repeat attempts to verify the same (bad) class.
@@ -524,11 +522,10 @@
     // if we are executing Java code. This is not a problem for CDS dumping phase since
     // it doesn't execute any Java code.
     ResourceMark rm(THREAD);
-    THROW_MSG_(vmSymbols::java_lang_NoClassDefFoundError(),
-               this_k->external_name(), false);
+    THROW_MSG_(vmSymbols::java_lang_NoClassDefFoundError(), external_name(), false);
   }
   // return if already verified
-  if (this_k->is_linked()) {
+  if (is_linked()) {
     return true;
   }
 
@@ -538,34 +535,34 @@
   JavaThread* jt = (JavaThread*)THREAD;
 
   // link super class before linking this class
-  Klass* super = this_k->super();
-  if (super != NULL) {
-    if (super->is_interface()) {  // check if super class is an interface
+  Klass* super_klass = super();
+  if (super_klass != NULL) {
+    if (super_klass->is_interface()) {  // check if super class is an interface
       ResourceMark rm(THREAD);
       Exceptions::fthrow(
         THREAD_AND_LOCATION,
         vmSymbols::java_lang_IncompatibleClassChangeError(),
         "class %s has interface %s as super class",
-        this_k->external_name(),
-        super->external_name()
+        external_name(),
+        super_klass->external_name()
       );
       return false;
     }
 
-    InstanceKlass* ik_super = InstanceKlass::cast(super);
-    link_class_impl(ik_super, throw_verifyerror, CHECK_false);
+    InstanceKlass* ik_super = InstanceKlass::cast(super_klass);
+    ik_super->link_class_impl(throw_verifyerror, CHECK_false);
   }
 
   // link all interfaces implemented by this class before linking this class
-  Array<Klass*>* interfaces = this_k->local_interfaces();
+  Array<Klass*>* interfaces = local_interfaces();
   int num_interfaces = interfaces->length();
   for (int index = 0; index < num_interfaces; index++) {
     InstanceKlass* interk = InstanceKlass::cast(interfaces->at(index));
-    link_class_impl(interk, throw_verifyerror, CHECK_false);
+    interk->link_class_impl(throw_verifyerror, CHECK_false);
   }
 
   // in case the class is linked in the process of linking its superclasses
-  if (this_k->is_linked()) {
+  if (is_linked()) {
     return true;
   }
 
@@ -581,17 +578,17 @@
   // verification & rewriting
   {
     HandleMark hm(THREAD);
-    Handle init_lock(THREAD, this_k->init_lock());
-    ObjectLocker ol(init_lock, THREAD, init_lock() != NULL);
+    Handle h_init_lock(THREAD, init_lock());
+    ObjectLocker ol(h_init_lock, THREAD, init_lock() != NULL);
     // rewritten will have been set if loader constraint error found
     // on an earlier link attempt
     // don't verify or rewrite if already rewritten
     //
 
-    if (!this_k->is_linked()) {
-      if (!this_k->is_rewritten()) {
+    if (!is_linked()) {
+      if (!is_rewritten()) {
         {
-          bool verify_ok = verify_code(this_k, throw_verifyerror, THREAD);
+          bool verify_ok = verify_code(throw_verifyerror, THREAD);
           if (!verify_ok) {
             return false;
           }
@@ -600,18 +597,18 @@
         // Just in case a side-effect of verify linked this class already
         // (which can sometimes happen since the verifier loads classes
         // using custom class loaders, which are free to initialize things)
-        if (this_k->is_linked()) {
+        if (is_linked()) {
           return true;
         }
 
         // also sets rewritten
-        this_k->rewrite_class(CHECK_false);
-      } else if (this_k->is_shared()) {
-        SystemDictionaryShared::check_verification_constraints(this_k, CHECK_false);
+        rewrite_class(CHECK_false);
+      } else if (is_shared()) {
+        SystemDictionaryShared::check_verification_constraints(this, CHECK_false);
       }
 
       // relocate jsrs and link methods after they are all rewritten
-      this_k->link_methods(CHECK_false);
+      link_methods(CHECK_false);
 
       // Initialize the vtable and interface table after
       // methods have been rewritten since rewrite may
@@ -620,26 +617,26 @@
       //
       // initialize_vtable and initialize_itable need to be rerun for
       // a shared class if the class is not loaded by the NULL classloader.
-      ClassLoaderData * loader_data = this_k->class_loader_data();
-      if (!(this_k->is_shared() &&
+      ClassLoaderData * loader_data = class_loader_data();
+      if (!(is_shared() &&
             loader_data->is_the_null_class_loader_data())) {
         ResourceMark rm(THREAD);
-        this_k->vtable()->initialize_vtable(true, CHECK_false);
-        this_k->itable()->initialize_itable(true, CHECK_false);
+        vtable()->initialize_vtable(true, CHECK_false);
+        itable()->initialize_itable(true, CHECK_false);
       }
 #ifdef ASSERT
       else {
         ResourceMark rm(THREAD);
-        this_k->vtable()->verify(tty, true);
+        vtable()->verify(tty, true);
         // In case itable verification is ever added.
-        // this_k->itable()->verify(tty, true);
+        // itable()->verify(tty, true);
       }
 #endif
-      this_k->set_init_state(linked);
+      set_init_state(linked);
       if (JvmtiExport::should_post_class_prepare()) {
         Thread *thread = THREAD;
         assert(thread->is_Java_thread(), "thread->is_Java_thread()");
-        JvmtiExport::post_class_prepare((JavaThread *) thread, this_k);
+        JvmtiExport::post_class_prepare((JavaThread *) thread, this);
       }
     }
   }
@@ -674,17 +671,17 @@
 }
 
 // Eagerly initialize superinterfaces that declare default methods (concrete instance: any access)
-void InstanceKlass::initialize_super_interfaces(InstanceKlass* this_k, TRAPS) {
-  assert (this_k->has_nonstatic_concrete_methods(), "caller should have checked this");
-  for (int i = 0; i < this_k->local_interfaces()->length(); ++i) {
-    Klass* iface = this_k->local_interfaces()->at(i);
+void InstanceKlass::initialize_super_interfaces(TRAPS) {
+  assert (has_nonstatic_concrete_methods(), "caller should have checked this");
+  for (int i = 0; i < local_interfaces()->length(); ++i) {
+    Klass* iface = local_interfaces()->at(i);
     InstanceKlass* ik = InstanceKlass::cast(iface);
 
     // Initialization is depth first search ie. we start with top of the inheritance tree
     // has_nonstatic_concrete_methods drives searching superinterfaces since it
     // means has_nonstatic_concrete_methods in its superinterface hierarchy
     if (ik->has_nonstatic_concrete_methods()) {
-      ik->initialize_super_interfaces(ik, CHECK);
+      ik->initialize_super_interfaces(CHECK);
     }
 
     // Only initialize() interfaces that "declare" concrete methods.
@@ -694,22 +691,22 @@
   }
 }
 
-void InstanceKlass::initialize_impl(InstanceKlass* this_k, TRAPS) {
+void InstanceKlass::initialize_impl(TRAPS) {
   HandleMark hm(THREAD);
 
   // Make sure klass is linked (verified) before initialization
   // A class could already be verified, since it has been reflected upon.
-  this_k->link_class(CHECK);
-
-  DTRACE_CLASSINIT_PROBE(required, this_k, -1);
+  link_class(CHECK);
+
+  DTRACE_CLASSINIT_PROBE(required, -1);
 
   bool wait = false;
 
   // refer to the JVM book page 47 for description of steps
   // Step 1
   {
-    Handle init_lock(THREAD, this_k->init_lock());
-    ObjectLocker ol(init_lock, THREAD, init_lock() != NULL);
+    Handle h_init_lock(THREAD, init_lock());
+    ObjectLocker ol(h_init_lock, THREAD, init_lock() != NULL);
 
     Thread *self = THREAD; // it's passed the current thread
 
@@ -717,29 +714,29 @@
     // If we were to use wait() instead of waitInterruptibly() then
     // we might end up throwing IE from link/symbol resolution sites
     // that aren't expected to throw.  This would wreak havoc.  See 6320309.
-    while(this_k->is_being_initialized() && !this_k->is_reentrant_initialization(self)) {
+    while(is_being_initialized() && !is_reentrant_initialization(self)) {
         wait = true;
       ol.waitUninterruptibly(CHECK);
     }
 
     // Step 3
-    if (this_k->is_being_initialized() && this_k->is_reentrant_initialization(self)) {
-      DTRACE_CLASSINIT_PROBE_WAIT(recursive, this_k, -1,wait);
+    if (is_being_initialized() && is_reentrant_initialization(self)) {
+      DTRACE_CLASSINIT_PROBE_WAIT(recursive, -1, wait);
       return;
     }
 
     // Step 4
-    if (this_k->is_initialized()) {
-      DTRACE_CLASSINIT_PROBE_WAIT(concurrent, this_k, -1,wait);
+    if (is_initialized()) {
+      DTRACE_CLASSINIT_PROBE_WAIT(concurrent, -1, wait);
       return;
     }
 
     // Step 5
-    if (this_k->is_in_error_state()) {
-      DTRACE_CLASSINIT_PROBE_WAIT(erroneous, this_k, -1,wait);
+    if (is_in_error_state()) {
+      DTRACE_CLASSINIT_PROBE_WAIT(erroneous, -1, wait);
       ResourceMark rm(THREAD);
       const char* desc = "Could not initialize class ";
-      const char* className = this_k->external_name();
+      const char* className = external_name();
       size_t msglen = strlen(desc) + strlen(className) + 1;
       char* message = NEW_RESOURCE_ARRAY(char, msglen);
       if (NULL == message) {
@@ -752,15 +749,15 @@
     }
 
     // Step 6
-    this_k->set_init_state(being_initialized);
-    this_k->set_init_thread(self);
+    set_init_state(being_initialized);
+    set_init_thread(self);
   }
 
   // Step 7
   // Next, if C is a class rather than an interface, initialize it's super class and super
   // interfaces.
-  if (!this_k->is_interface()) {
-    Klass* super_klass = this_k->super();
+  if (!is_interface()) {
+    Klass* super_klass = super();
     if (super_klass != NULL && super_klass->should_be_initialized()) {
       super_klass->initialize(THREAD);
     }
@@ -768,8 +765,8 @@
     // the initialization of C triggers initialization of its super interfaces.
     // Only need to recurse if has_nonstatic_concrete_methods which includes declaring and
     // having a superinterface that declares, non-static, concrete methods
-    if (!HAS_PENDING_EXCEPTION && this_k->has_nonstatic_concrete_methods()) {
-      this_k->initialize_super_interfaces(this_k, THREAD);
+    if (!HAS_PENDING_EXCEPTION && has_nonstatic_concrete_methods()) {
+      initialize_super_interfaces(THREAD);
     }
 
     // If any exceptions, complete abruptly, throwing the same exception as above.
@@ -779,23 +776,23 @@
       {
         EXCEPTION_MARK;
         // Locks object, set state, and notify all waiting threads
-        this_k->set_initialization_state_and_notify(initialization_error, THREAD);
+        set_initialization_state_and_notify(initialization_error, THREAD);
         CLEAR_PENDING_EXCEPTION;
       }
-      DTRACE_CLASSINIT_PROBE_WAIT(super__failed, this_k, -1,wait);
+      DTRACE_CLASSINIT_PROBE_WAIT(super__failed, -1, wait);
       THROW_OOP(e());
     }
   }
 
 
   // Look for aot compiled methods for this klass, including class initializer.
-  AOTLoader::load_for_klass(this_k, THREAD);
+  AOTLoader::load_for_klass(this, THREAD);
 
   // Step 8
   {
     assert(THREAD->is_Java_thread(), "non-JavaThread in initialize_impl");
     JavaThread* jt = (JavaThread*)THREAD;
-    DTRACE_CLASSINIT_PROBE_WAIT(clinit, this_k, -1,wait);
+    DTRACE_CLASSINIT_PROBE_WAIT(clinit, -1, wait);
     // Timer includes any side effects of class initialization (resolution,
     // etc), but not recursive entry into call_class_initializer().
     PerfClassTraceTime timer(ClassLoader::perf_class_init_time(),
@@ -804,14 +801,14 @@
                              jt->get_thread_stat()->perf_recursion_counts_addr(),
                              jt->get_thread_stat()->perf_timers_addr(),
                              PerfClassTraceTime::CLASS_CLINIT);
-    this_k->call_class_initializer(THREAD);
+    call_class_initializer(THREAD);
   }
 
   // Step 9
   if (!HAS_PENDING_EXCEPTION) {
-    this_k->set_initialization_state_and_notify(fully_initialized, CHECK);
+    set_initialization_state_and_notify(fully_initialized, CHECK);
     { ResourceMark rm(THREAD);
-      debug_only(this_k->vtable()->verify(tty, true);)
+      debug_only(vtable()->verify(tty, true);)
     }
   }
   else {
@@ -823,13 +820,13 @@
     JvmtiExport::clear_detected_exception((JavaThread*)THREAD);
     {
       EXCEPTION_MARK;
-      this_k->set_initialization_state_and_notify(initialization_error, THREAD);
+      set_initialization_state_and_notify(initialization_error, THREAD);
       CLEAR_PENDING_EXCEPTION;   // ignore any exception thrown, class initialization error is thrown below
       // JVMTI has already reported the pending exception
       // JVMTI internal flag reset is needed in order to report ExceptionInInitializerError
       JvmtiExport::clear_detected_exception((JavaThread*)THREAD);
     }
-    DTRACE_CLASSINIT_PROBE_WAIT(error, this_k, -1,wait);
+    DTRACE_CLASSINIT_PROBE_WAIT(error, -1, wait);
     if (e->is_a(SystemDictionary::Error_klass())) {
       THROW_OOP(e());
     } else {
@@ -839,25 +836,20 @@
                 &args);
     }
   }
-  DTRACE_CLASSINIT_PROBE_WAIT(end, this_k, -1,wait);
-}
-
-
-// Note: implementation moved to static method to expose the this pointer.
-void InstanceKlass::set_initialization_state_and_notify(ClassState state, TRAPS) {
-  set_initialization_state_and_notify_impl(this, state, CHECK);
+  DTRACE_CLASSINIT_PROBE_WAIT(end, -1, wait);
 }
 
-void InstanceKlass::set_initialization_state_and_notify_impl(InstanceKlass* this_k, ClassState state, TRAPS) {
-  Handle init_lock(THREAD, this_k->init_lock());
+
+void InstanceKlass::set_initialization_state_and_notify(ClassState state, TRAPS) {
+  Handle h_init_lock(THREAD, init_lock());
   if (init_lock() != NULL) {
-    ObjectLocker ol(init_lock, THREAD);
-    this_k->set_init_state(state);
-    this_k->fence_and_clear_init_lock();
+    ObjectLocker ol(h_init_lock, THREAD);
+    set_init_state(state);
+    fence_and_clear_init_lock();
     ol.notify_all(CHECK);
   } else {
     assert(init_lock() != NULL, "The initialization state should never be set twice");
-    this_k->set_init_state(state);
+    set_init_state(state);
   }
 }
 
@@ -1037,12 +1029,8 @@
 }
 
 Klass* InstanceKlass::array_klass_impl(bool or_null, int n, TRAPS) {
-  return array_klass_impl(this, or_null, n, THREAD);
-}
-
-Klass* InstanceKlass::array_klass_impl(InstanceKlass* this_k, bool or_null, int n, TRAPS) {
   // Need load-acquire for lock-free read
-  if (this_k->array_klasses_acquire() == NULL) {
+  if (array_klasses_acquire() == NULL) {
     if (or_null) return NULL;
 
     ResourceMark rm;
@@ -1053,15 +1041,15 @@
       MutexLocker ma(MultiArray_lock, THREAD);
 
       // Check if update has already taken place
-      if (this_k->array_klasses() == NULL) {
-        Klass*    k = ObjArrayKlass::allocate_objArray_klass(this_k->class_loader_data(), 1, this_k, CHECK_NULL);
+      if (array_klasses() == NULL) {
+        Klass*    k = ObjArrayKlass::allocate_objArray_klass(class_loader_data(), 1, this, CHECK_NULL);
         // use 'release' to pair with lock-free load
-        this_k->release_set_array_klasses(k);
+        release_set_array_klasses(k);
       }
     }
   }
   // _this will always be set at this point
-  ObjArrayKlass* oak = (ObjArrayKlass*)this_k->array_klasses();
+  ObjArrayKlass* oak = (ObjArrayKlass*)array_klasses();
   if (or_null) {
     return oak->array_klass_or_null(n);
   }
@@ -1072,11 +1060,7 @@
   return array_klass_impl(or_null, 1, THREAD);
 }
 
-void InstanceKlass::call_class_initializer(TRAPS) {
-  call_class_initializer_impl(this, THREAD);
-}
-
-static int call_class_initializer_impl_counter = 0;   // for debugging
+static int call_class_initializer_counter = 0;   // for debugging
 
 Method* InstanceKlass::class_initializer() const {
   Method* clinit = find_method(
@@ -1087,22 +1071,22 @@
   return NULL;
 }
 
-void InstanceKlass::call_class_initializer_impl(InstanceKlass* this_k, TRAPS) {
+void InstanceKlass::call_class_initializer(TRAPS) {
   if (ReplayCompiles &&
       (ReplaySuppressInitializers == 1 ||
-       ReplaySuppressInitializers >= 2 && this_k->class_loader() != NULL)) {
+       ReplaySuppressInitializers >= 2 && class_loader() != NULL)) {
     // Hide the existence of the initializer for the purpose of replaying the compile
     return;
   }
 
-  methodHandle h_method(THREAD, this_k->class_initializer());
-  assert(!this_k->is_initialized(), "we cannot initialize twice");
+  methodHandle h_method(THREAD, class_initializer());
+  assert(!is_initialized(), "we cannot initialize twice");
   if (log_is_enabled(Info, class, init)) {
     ResourceMark rm;
     outputStream* log = Log(class, init)::info_stream();
-    log->print("%d Initializing ", call_class_initializer_impl_counter++);
-    this_k->name()->print_value_on(log);
-    log->print_cr("%s (" INTPTR_FORMAT ")", h_method() == NULL ? "(no method)" : "", p2i(this_k));
+    log->print("%d Initializing ", call_class_initializer_counter++);
+    name()->print_value_on(log);
+    log->print_cr("%s (" INTPTR_FORMAT ")", h_method() == NULL ? "(no method)" : "", p2i(this));
   }
   if (h_method() != NULL) {
     JavaCallArguments args; // No arguments
@@ -1253,13 +1237,7 @@
 
 
 void InstanceKlass::do_local_static_fields(void f(fieldDescriptor*, Handle, TRAPS), Handle mirror, TRAPS) {
-  do_local_static_fields_impl(this, f, mirror, CHECK);
-}
-
-
-void InstanceKlass::do_local_static_fields_impl(InstanceKlass* this_k,
-                             void f(fieldDescriptor* fd, Handle, TRAPS), Handle mirror, TRAPS) {
-  for (JavaFieldStream fs(this_k); !fs.done(); fs.next()) {
+  for (JavaFieldStream fs(this); !fs.done(); fs.next()) {
     if (fs.access_flags().is_static()) {
       fieldDescriptor& fd = fs.field_descriptor();
       f(&fd, mirror, CHECK);
@@ -1618,14 +1596,14 @@
 }
 
 /* jni_id_for_impl for jfieldIds only */
-JNIid* InstanceKlass::jni_id_for_impl(InstanceKlass* this_k, int offset) {
+JNIid* InstanceKlass::jni_id_for_impl(int offset) {
   MutexLocker ml(JfieldIdCreation_lock);
   // Retry lookup after we got the lock
-  JNIid* probe = this_k->jni_ids() == NULL ? NULL : this_k->jni_ids()->find(offset);
+  JNIid* probe = jni_ids() == NULL ? NULL : jni_ids()->find(offset);
   if (probe == NULL) {
     // Slow case, allocate new static field identifier
-    probe = new JNIid(this_k, offset, this_k->jni_ids());
-    this_k->set_jni_ids(probe);
+    probe = new JNIid(this, offset, jni_ids());
+    set_jni_ids(probe);
   }
   return probe;
 }
@@ -1635,7 +1613,7 @@
 JNIid* InstanceKlass::jni_id_for(int offset) {
   JNIid* probe = jni_ids() == NULL ? NULL : jni_ids()->find(offset);
   if (probe == NULL) {
-    probe = jni_id_for_impl(this, offset);
+    probe = jni_id_for_impl(offset);
   }
   return probe;
 }
@@ -1673,9 +1651,9 @@
 // locking has to be done very carefully to avoid deadlocks
 // and/or other cache consistency problems.
 //
-jmethodID InstanceKlass::get_jmethod_id(InstanceKlass* ik, const methodHandle& method_h) {
+jmethodID InstanceKlass::get_jmethod_id(const methodHandle& method_h) {
   size_t idnum = (size_t)method_h->method_idnum();
-  jmethodID* jmeths = ik->methods_jmethod_ids_acquire();
+  jmethodID* jmeths = methods_jmethod_ids_acquire();
   size_t length = 0;
   jmethodID id = NULL;
 
@@ -1699,7 +1677,7 @@
 
   if (jmeths != NULL) {
     // the cache already exists
-    if (!ik->idnum_can_increment()) {
+    if (!idnum_can_increment()) {
       // the cache can't grow so we can just get the current values
       get_jmethod_id_length_value(jmeths, idnum, &length, &id);
     } else {
@@ -1733,7 +1711,7 @@
     jmethodID* new_jmeths = NULL;
     if (length <= idnum) {
       // allocate a new cache that might be used
-      size_t size = MAX2(idnum+1, (size_t)ik->idnum_allocated_count());
+      size_t size = MAX2(idnum+1, (size_t)idnum_allocated_count());
       new_jmeths = NEW_C_HEAP_ARRAY(jmethodID, size+1, mtClass);
       memset(new_jmeths, 0, (size+1)*sizeof(jmethodID));
       // cache size is stored in element[0], other elements offset by one
@@ -1744,23 +1722,23 @@
     jmethodID new_id = NULL;
     if (method_h->is_old() && !method_h->is_obsolete()) {
       // The method passed in is old (but not obsolete), we need to use the current version
-      Method* current_method = ik->method_with_idnum((int)idnum);
+      Method* current_method = method_with_idnum((int)idnum);
       assert(current_method != NULL, "old and but not obsolete, so should exist");
-      new_id = Method::make_jmethod_id(ik->class_loader_data(), current_method);
+      new_id = Method::make_jmethod_id(class_loader_data(), current_method);
     } else {
       // It is the current version of the method or an obsolete method,
       // use the version passed in
-      new_id = Method::make_jmethod_id(ik->class_loader_data(), method_h());
+      new_id = Method::make_jmethod_id(class_loader_data(), method_h());
     }
 
     if (Threads::number_of_threads() == 0 ||
         SafepointSynchronize::is_at_safepoint()) {
       // we're single threaded or at a safepoint - no locking needed
-      id = get_jmethod_id_fetch_or_update(ik, idnum, new_id, new_jmeths,
+      id = get_jmethod_id_fetch_or_update(idnum, new_id, new_jmeths,
                                           &to_dealloc_id, &to_dealloc_jmeths);
     } else {
       MutexLocker ml(JmethodIdCreation_lock);
-      id = get_jmethod_id_fetch_or_update(ik, idnum, new_id, new_jmeths,
+      id = get_jmethod_id_fetch_or_update(idnum, new_id, new_jmeths,
                                           &to_dealloc_id, &to_dealloc_jmeths);
     }
 
@@ -1771,7 +1749,7 @@
     }
     // free up the new ID since it wasn't needed
     if (to_dealloc_id != NULL) {
-      Method::destroy_jmethod_id(ik->class_loader_data(), to_dealloc_id);
+      Method::destroy_jmethod_id(class_loader_data(), to_dealloc_id);
     }
   }
   return id;
@@ -1803,7 +1781,7 @@
 // the VMThread or have cache consistency issues.
 //
 jmethodID InstanceKlass::get_jmethod_id_fetch_or_update(
-            InstanceKlass* ik, size_t idnum, jmethodID new_id,
+            size_t idnum, jmethodID new_id,
             jmethodID* new_jmeths, jmethodID* to_dealloc_id_p,
             jmethodID** to_dealloc_jmeths_p) {
   assert(new_id != NULL, "sanity check");
@@ -1814,7 +1792,7 @@
          JmethodIdCreation_lock->owned_by_self(), "sanity check");
 
   // reacquire the cache - we are locked, single threaded or at a safepoint
-  jmethodID* jmeths = ik->methods_jmethod_ids_acquire();
+  jmethodID* jmeths = methods_jmethod_ids_acquire();
   jmethodID  id     = NULL;
   size_t     length = 0;
 
@@ -1827,7 +1805,7 @@
       }
       *to_dealloc_jmeths_p = jmeths;  // save old cache for later delete
     }
-    ik->release_set_methods_jmethod_ids(jmeths = new_jmeths);
+    release_set_methods_jmethod_ids(jmeths = new_jmeths);
   } else {
     // fetch jmethodID (if any) from the existing cache
     id = jmeths[idnum+1];
@@ -2435,13 +2413,6 @@
    return(is_same_class_package(targetclassloader(), targetclassname));
 }
 
-/* defined for now in jvm.cpp, for historical reasons *--
-Klass* InstanceKlass::compute_enclosing_class_impl(InstanceKlass* self,
-                                                     Symbol*& simple_name_result, TRAPS) {
-  ...
-}
-*/
-
 // Only boot and platform class loaders can define classes in "java/" packages.
 void InstanceKlass::check_prohibited_package(Symbol* class_name,
                                              Handle class_loader,
@@ -2467,29 +2438,27 @@
 }
 
 // tell if two classes have the same enclosing class (at package level)
-bool InstanceKlass::is_same_package_member_impl(const InstanceKlass* class1,
-                                                const Klass* class2,
-                                                TRAPS) {
-  if (class2 == class1) return true;
+bool InstanceKlass::is_same_package_member(const Klass* class2, TRAPS) const {
+  if (class2 == this) return true;
   if (!class2->is_instance_klass())  return false;
 
   // must be in same package before we try anything else
-  if (!class1->is_same_class_package(class2))
+  if (!is_same_class_package(class2))
     return false;
 
-  // As long as there is an outer1.getEnclosingClass,
+  // As long as there is an outer_this.getEnclosingClass,
   // shift the search outward.
-  const InstanceKlass* outer1 = class1;
+  const InstanceKlass* outer_this = this;
   for (;;) {
-    // As we walk along, look for equalities between outer1 and class2.
-    // Eventually, the walks will terminate as outer1 stops
+    // As we walk along, look for equalities between outer_this and class2.
+    // Eventually, the walks will terminate as outer_this stops
     // at the top-level class around the original class.
     bool ignore_inner_is_member;
-    const Klass* next = outer1->compute_enclosing_class(&ignore_inner_is_member,
-                                                  CHECK_false);
+    const Klass* next = outer_this->compute_enclosing_class(&ignore_inner_is_member,
+                                                            CHECK_false);
     if (next == NULL)  break;
     if (next == class2)  return true;
-    outer1 = InstanceKlass::cast(next);
+    outer_this = InstanceKlass::cast(next);
   }
 
   // Now do the same for class2.
@@ -2500,8 +2469,8 @@
                                                     CHECK_false);
     if (next == NULL)  break;
     // Might as well check the new outer against all available values.
-    if (next == class1)  return true;
-    if (next == outer1)  return true;
+    if (next == this)  return true;
+    if (next == outer_this)  return true;
     outer2 = InstanceKlass::cast(next);
   }
 
@@ -2510,16 +2479,16 @@
   return false;
 }
 
-bool InstanceKlass::find_inner_classes_attr(const InstanceKlass* k, int* ooff, int* noff, TRAPS) {
-  constantPoolHandle i_cp(THREAD, k->constants());
-  for (InnerClassesIterator iter(k); !iter.done(); iter.next()) {
+bool InstanceKlass::find_inner_classes_attr(int* ooff, int* noff, TRAPS) const {
+  constantPoolHandle i_cp(THREAD, constants());
+  for (InnerClassesIterator iter(this); !iter.done(); iter.next()) {
     int ioff = iter.inner_class_info_index();
     if (ioff != 0) {
       // Check to see if the name matches the class we're looking for
       // before attempting to find the class.
-      if (i_cp->klass_name_at_matches(k, ioff)) {
+      if (i_cp->klass_name_at_matches(this, ioff)) {
         Klass* inner_klass = i_cp->klass_at(ioff, CHECK_false);
-        if (k == inner_klass) {
+        if (this == inner_klass) {
           *ooff = iter.outer_class_info_index();
           *noff = iter.inner_name_index();
           return true;
@@ -2530,14 +2499,13 @@
   return false;
 }
 
-InstanceKlass* InstanceKlass::compute_enclosing_class_impl(const InstanceKlass* k,
-                                                           bool* inner_is_member,
-                                                           TRAPS) {
+InstanceKlass* InstanceKlass::compute_enclosing_class(bool* inner_is_member, TRAPS) const {
   InstanceKlass* outer_klass = NULL;
   *inner_is_member = false;
   int ooff = 0, noff = 0;
-  if (find_inner_classes_attr(k, &ooff, &noff, THREAD)) {
-    constantPoolHandle i_cp(THREAD, k->constants());
+  bool has_inner_classes_attr = find_inner_classes_attr(&ooff, &noff, THREAD);
+  if (has_inner_classes_attr) {
+    constantPoolHandle i_cp(THREAD, constants());
     if (ooff != 0) {
       Klass* ok = i_cp->klass_at(ooff, CHECK_NULL);
       outer_klass = InstanceKlass::cast(ok);
@@ -2545,7 +2513,7 @@
     }
     if (NULL == outer_klass) {
       // It may be anonymous; try for that.
-      int encl_method_class_idx = k->enclosing_method_class_index();
+      int encl_method_class_idx = enclosing_method_class_index();
       if (encl_method_class_idx != 0) {
         Klass* ok = i_cp->klass_at(encl_method_class_idx, CHECK_NULL);
         outer_klass = InstanceKlass::cast(ok);
@@ -2560,7 +2528,7 @@
   // Throws an exception if outer klass has not declared k as an inner klass
   // We need evidence that each klass knows about the other, or else
   // the system could allow a spoof of an inner class to gain access rights.
-  Reflection::check_for_inner_class(outer_klass, k, *inner_is_member, CHECK_NULL);
+  Reflection::check_for_inner_class(outer_klass, this, *inner_is_member, CHECK_NULL);
   return outer_klass;
 }
 
--- a/hotspot/src/share/vm/oops/instanceKlass.hpp	Tue Mar 21 11:21:11 2017 +0100
+++ b/hotspot/src/share/vm/oops/instanceKlass.hpp	Tue Mar 21 11:25:18 2017 -0400
@@ -464,16 +464,10 @@
                                     const Symbol* class_name2);
 
   // find an enclosing class
-  InstanceKlass* compute_enclosing_class(bool* inner_is_member, TRAPS) const {
-    return compute_enclosing_class_impl(this, inner_is_member, THREAD);
-  }
-  static InstanceKlass* compute_enclosing_class_impl(const InstanceKlass* self,
-                                                     bool* inner_is_member,
-                                                     TRAPS);
+  InstanceKlass* compute_enclosing_class(bool* inner_is_member, TRAPS) const;
 
-  // Find InnerClasses attribute for k and return outer_class_info_index & inner_name_index.
-  static bool find_inner_classes_attr(const InstanceKlass* k,
-                                      int* ooff, int* noff, TRAPS);
+  // Find InnerClasses attribute and return outer_class_info_index & inner_name_index.
+  bool find_inner_classes_attr(int* ooff, int* noff, TRAPS) const;
 
  private:
   // Check prohibited package ("java/" only loadable by boot or platform loaders)
@@ -482,12 +476,7 @@
                                        TRAPS);
  public:
   // tell if two classes have the same enclosing class (at package level)
-  bool is_same_package_member(const Klass* class2, TRAPS) const {
-    return is_same_package_member_impl(this, class2, THREAD);
-  }
-  static bool is_same_package_member_impl(const InstanceKlass* self,
-                                          const Klass* class2,
-                                          TRAPS);
+  bool is_same_package_member(const Klass* class2, TRAPS) const;
 
   // initialization state
   bool is_loaded() const                   { return _init_state >= loaded; }
@@ -883,10 +872,9 @@
                                     u2 method_index);
 
   // jmethodID support
-  static jmethodID get_jmethod_id(InstanceKlass* ik,
-                     const methodHandle& method_h);
-  static jmethodID get_jmethod_id_fetch_or_update(InstanceKlass* ik,
-                     size_t idnum, jmethodID new_id, jmethodID* new_jmeths,
+  jmethodID get_jmethod_id(const methodHandle& method_h);
+  jmethodID get_jmethod_id_fetch_or_update(size_t idnum,
+                     jmethodID new_id, jmethodID* new_jmeths,
                      jmethodID* to_dealloc_id_p,
                      jmethodID** to_dealloc_jmeths_p);
   static void get_jmethod_id_length_value(jmethodID* cache, size_t idnum,
@@ -1306,19 +1294,13 @@
 private:
   void fence_and_clear_init_lock();
 
-  // Static methods that are used to implement member methods where an exposed this pointer
-  // is needed due to possible GCs
-  static bool link_class_impl                           (InstanceKlass* this_k, bool throw_verifyerror, TRAPS);
-  static bool verify_code                               (InstanceKlass* this_k, bool throw_verifyerror, TRAPS);
-  static void initialize_impl                           (InstanceKlass* this_k, TRAPS);
-  static void initialize_super_interfaces               (InstanceKlass* this_k, TRAPS);
-  static void eager_initialize_impl                     (InstanceKlass* this_k);
-  static void set_initialization_state_and_notify_impl  (InstanceKlass* this_k, ClassState state, TRAPS);
-  static void call_class_initializer_impl               (InstanceKlass* this_k, TRAPS);
-  static Klass* array_klass_impl                        (InstanceKlass* this_k, bool or_null, int n, TRAPS);
-  static void do_local_static_fields_impl               (InstanceKlass* this_k, void f(fieldDescriptor* fd, Handle, TRAPS), Handle, TRAPS);
+  bool link_class_impl                           (bool throw_verifyerror, TRAPS);
+  bool verify_code                               (bool throw_verifyerror, TRAPS);
+  void initialize_impl                           (TRAPS);
+  void initialize_super_interfaces               (TRAPS);
+  void eager_initialize_impl                     ();
   /* jni_id_for_impl for jfieldID only */
-  static JNIid* jni_id_for_impl                         (InstanceKlass* this_k, int offset);
+  JNIid* jni_id_for_impl                         (int offset);
 
   // Returns the array class for the n'th dimension
   Klass* array_klass_impl(bool or_null, int n, TRAPS);
--- a/hotspot/src/share/vm/oops/method.hpp	Tue Mar 21 11:21:11 2017 +0100
+++ b/hotspot/src/share/vm/oops/method.hpp	Tue Mar 21 11:25:18 2017 -0400
@@ -811,7 +811,7 @@
   static void print_jmethod_ids(ClassLoaderData* loader_data, outputStream* out) PRODUCT_RETURN;
 
   // Get this method's jmethodID -- allocate if it doesn't exist
-  jmethodID jmethod_id()                            { return InstanceKlass::get_jmethod_id(method_holder(), this); }
+  jmethodID jmethod_id()                            { return method_holder()->get_jmethod_id(this); }
 
   // Lookup the jmethodID for this method.  Return NULL if not found.
   // NOTE that this function can be called from a signal handler
--- a/hotspot/src/share/vm/prims/jvm.cpp	Tue Mar 21 11:21:11 2017 +0100
+++ b/hotspot/src/share/vm/prims/jvm.cpp	Tue Mar 21 11:25:18 2017 -0400
@@ -1532,7 +1532,7 @@
   }
   InstanceKlass* k = InstanceKlass::cast(java_lang_Class::as_Klass(mirror));
   int ooff = 0, noff = 0;
-  if (InstanceKlass::find_inner_classes_attr(k, &ooff, &noff, THREAD)) {
+  if (k->find_inner_classes_attr(&ooff, &noff, THREAD)) {
     if (noff != 0) {
       constantPoolHandle i_cp(thread, k->constants());
       Symbol* name = i_cp->symbol_at(noff);