src/hotspot/share/memory/metaspace/metabase.hpp
author gziemski
Wed, 08 May 2019 11:11:50 -0500
changeset 54764 865ec913f916
parent 53244 9807daeb47c4
permissions -rw-r--r--
8185525: Add JFR event for DictionarySizes Summary: Added TableStatistics event Reviewed-by: egahlin, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50193
diff changeset
     2
 * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
     4
 *
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
     7
 * published by the Free Software Foundation.
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
     8
 *
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    13
 * accompanied this code).
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    14
 *
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    18
 *
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    21
 * questions.
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    22
 *
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    23
 */
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    24
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    25
#ifndef SHARE_MEMORY_METASPACE_METABASE_HPP
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    26
#define SHARE_MEMORY_METASPACE_METABASE_HPP
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    27
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    28
#include "utilities/globalDefinitions.hpp"
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    29
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    30
namespace metaspace {
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    31
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    32
// Super class of Metablock and Metachunk to allow them to
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    33
// be put on the FreeList and in the BinaryTreeDictionary.
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    34
template <class T>
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    35
class Metabase {
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    36
  size_t _word_size;
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    37
  T*     _next;
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    38
  T*     _prev;
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    39
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    40
 protected:
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    41
  Metabase(size_t word_size) : _word_size(word_size), _next(NULL), _prev(NULL) {}
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    42
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    43
 public:
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    44
  T* next() const         { return _next; }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    45
  T* prev() const         { return _prev; }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    46
  void set_next(T* v)     { _next = v; assert(v != this, "Boom");}
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    47
  void set_prev(T* v)     { _prev = v; assert(v != this, "Boom");}
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    48
  void clear_next()       { set_next(NULL); }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    49
  void clear_prev()       { set_prev(NULL); }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    50
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    51
  size_t size() const volatile { return _word_size; }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    52
  void set_size(size_t v) { _word_size = v; }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    53
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    54
  void link_next(T* ptr)  { set_next(ptr); }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    55
  void link_prev(T* ptr)  { set_prev(ptr); }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    56
  void link_after(T* ptr) {
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    57
    link_next(ptr);
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    58
    if (ptr != NULL) ptr->link_prev((T*)this);
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    59
  }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    60
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    61
  uintptr_t* end() const        { return ((uintptr_t*) this) + size(); }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    62
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    63
  bool cantCoalesce() const     { return false; }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    64
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    65
  // Debug support
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    66
#ifdef ASSERT
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    67
  void* prev_addr() const { return (void*)&_prev; }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    68
  void* next_addr() const { return (void*)&_next; }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    69
  void* size_addr() const { return (void*)&_word_size; }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    70
#endif
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    71
  bool verify_chunk_in_free_list(T* tc) const { return true; }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    72
  bool verify_par_locked() { return true; }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    73
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    74
  void assert_is_mangled() const {/* Don't check "\*/}
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    75
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    76
  bool is_free()                 { return true; }
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    77
};
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    78
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    79
} // namespace metaspace
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents:
diff changeset
    80
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50193
diff changeset
    81
#endif // SHARE_MEMORY_METASPACE_METABASE_HPP