oop MemberNameTable::find_or_add_member_name(jweak mem_name_wref) {
  assert_locked_or_safepoint(MemberNameTable_lock);
  oop new_mem_name = JNIHandles::resolve(mem_name_wref);

  // Find matching member name in the list.
  // This is linear because these are short lists.
  int len = this->length();
  int new_index = len;
  for (int idx = 0; idx < len; idx++) {
    oop mname = JNIHandles::resolve(this->at(idx));
    if (mname == NULL) {
      new_index = idx;
      continue;
    }
    if (java_lang_invoke_MemberName::equals(new_mem_name, mname)) {
      JNIHandles::destroy_weak_global(mem_name_wref);
      return mname;
    }
  }

  if (new_index < len) {
    assert(JNIHandles::resolve(this->at(new_index)) == NULL, "sanity");
    // destroy the old handle
    JNIHandles::destroy_weak_global(this->at(new_index));
  }

  // Not found, push the new one, or reuse empty slot
  this->at_put_grow(new_index, mem_name_wref);
  return new_mem_name;
}
oop MemberNameTable::find_or_add_member_name(jweak mem_name_wref) {
  assert_locked_or_safepoint(MemberNameTable_lock);
  oop new_mem_name = JNIHandles::resolve(mem_name_wref);

   
   
  int len = this->length();
  int new_index = len;
  for (int idx = 0; idx < len; idx++) {
    oop mname = JNIHandles::resolve(this->at(idx));
    if (mname == NULL) {
      new_index = idx;
      continue;
    }
    if (java_lang_invoke_MemberName::equals(new_mem_name, mname)) {
      JNIHandles::destroy_weak_global(mem_name_wref);
      return mname;
    }
  }

  if (new_index < len) {
    assert(JNIHandles::resolve(this->at(new_index)) == NULL, "sanity");
     
    JNIHandles::destroy_weak_global(this->at(new_index));
  }

   
  this->at_put_grow(new_index, mem_name_wref);
  return new_mem_name;
}