hotspot/src/share/vm/gc/g1/g1CodeCacheRemSet.hpp
author ecaspole
Mon, 21 Sep 2015 10:36:36 -0400
changeset 33093 5aa0f908f8cd
parent 30764 fec48bf5a827
child 40905 94ffc131534f
permissions -rw-r--r--
8131645: [ARM64] crash on Cavium when using G1 Summary: Add a fence when creating the CodeRootSetTable so the readers do not see invalid memory. Reviewed-by: aph, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
     1
/*
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 26422
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
     4
 *
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
     8
 *
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    14
 *
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    18
 *
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    21
 * questions.
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    22
 *
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    23
 */
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    24
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 26422
diff changeset
    25
#ifndef SHARE_VM_GC_G1_G1CODECACHEREMSET_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 26422
diff changeset
    26
#define SHARE_VM_GC_G1_G1CODECACHEREMSET_HPP
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    27
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    28
#include "memory/allocation.hpp"
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    29
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    30
class CodeBlobClosure;
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    31
class CodeRootSetTable;
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    32
class HeapRegion;
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    33
class nmethod;
24099
9c132a88935d 8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents: 23451
diff changeset
    34
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    35
// Implements storage for a set of code roots.
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    36
// All methods that modify the set are not thread-safe except if otherwise noted.
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    37
class G1CodeRootSet VALUE_OBJ_CLASS_SPEC {
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    38
  friend class G1CodeRootSetTest;
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    39
 private:
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    40
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    41
  const static size_t SmallSize = 32;
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    42
  const static size_t Threshold = 24;
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    43
  const static size_t LargeSize = 512;
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    44
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    45
  CodeRootSetTable* _table;
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    46
  CodeRootSetTable* load_acquire_table();
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    47
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    48
  size_t _length;
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    49
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    50
  void move_to_large();
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    51
  void allocate_small_table();
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    52
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    53
 public:
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    54
  G1CodeRootSet() : _table(NULL), _length(0) {}
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    55
  ~G1CodeRootSet();
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    56
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    57
  static void purge();
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    58
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    59
  static size_t static_mem_size();
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    60
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    61
  void add(nmethod* method);
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    62
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    63
  bool remove(nmethod* method);
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    64
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    65
  // Safe to call without synchronization, but may return false negatives.
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    66
  bool contains(nmethod* method);
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    67
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    68
  void clear();
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    69
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    70
  void nmethods_do(CodeBlobClosure* blk) const;
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    71
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    72
  // Remove all nmethods which no longer contain pointers into our "owner" region
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    73
  void clean(HeapRegion* owner);
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    74
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    75
  bool is_empty() {
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    76
    bool empty = length() == 0;
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    77
    assert(empty == (_table == NULL), "is empty only if table is deallocated");
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    78
    return empty;
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    79
  }
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    80
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    81
  // Length in elements
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    82
  size_t length() const { return _length; }
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    83
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    84
  // Memory size in bytes taken by this set.
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    85
  size_t mem_size();
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    86
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    87
};
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    88
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 26422
diff changeset
    89
#endif // SHARE_VM_GC_G1_G1CODECACHEREMSET_HPP