src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.cpp

changeset 9487
3fa12c91c20a
parent 9327
f96fcd9e1e1b
child 9572
624a0741915c
     1.1 --- a/src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.cpp	Thu Sep 20 16:05:22 2018 +0200
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.cpp	Wed Sep 26 04:31:35 2018 -0400
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -76,10 +76,16 @@
    1.11    static size_t static_mem_size() {
    1.12      return sizeof(_purge_list);
    1.13    }
    1.14 +
    1.15 +  size_t mem_size();
    1.16  };
    1.17  
    1.18  CodeRootSetTable* volatile CodeRootSetTable::_purge_list = NULL;
    1.19  
    1.20 +size_t CodeRootSetTable::mem_size() {
    1.21 +  return sizeof(CodeRootSetTable) + (entry_size() * number_of_entries()) + (sizeof(HashtableBucket<mtGC>) * table_size());
    1.22 +}
    1.23 +
    1.24  CodeRootSetTable::Entry* CodeRootSetTable::new_entry(nmethod* nm) {
    1.25    unsigned int hash = compute_hash(nm);
    1.26    Entry* entry = (Entry*) new_entry_free_list();
    1.27 @@ -232,7 +238,6 @@
    1.28    OrderAccess::release_store_ptr(&_table, temp);
    1.29  }
    1.30  
    1.31 -
    1.32  void G1CodeRootSet::purge() {
    1.33    CodeRootSetTable::purge();
    1.34  }
    1.35 @@ -247,12 +252,13 @@
    1.36      allocate_small_table();
    1.37    }
    1.38    added = _table->add(method);
    1.39 -  if (_length == Threshold) {
    1.40 -    move_to_large();
    1.41 -  }
    1.42    if (added) {
    1.43 +    if (_length == Threshold) {
    1.44 +      move_to_large();
    1.45 +    }
    1.46      ++_length;
    1.47    }
    1.48 +  assert(_length == (size_t)_table->number_of_entries(), "sizes should match");
    1.49  }
    1.50  
    1.51  bool G1CodeRootSet::remove(nmethod* method) {
    1.52 @@ -266,11 +272,13 @@
    1.53        clear();
    1.54      }
    1.55    }
    1.56 +  assert((_length == 0 && _table == NULL) ||
    1.57 +         (_length == (size_t)_table->number_of_entries()), "sizes should match");
    1.58    return removed;
    1.59  }
    1.60  
    1.61  bool G1CodeRootSet::contains(nmethod* method) {
    1.62 -  CodeRootSetTable* table = load_acquire_table();
    1.63 +  CodeRootSetTable* table = load_acquire_table(); // contains() may be called outside of lock, so ensure mem sync.
    1.64    if (table != NULL) {
    1.65      return table->contains(method);
    1.66    }
    1.67 @@ -284,8 +292,7 @@
    1.68  }
    1.69  
    1.70  size_t G1CodeRootSet::mem_size() {
    1.71 -  return sizeof(*this) +
    1.72 -      (_table != NULL ? sizeof(CodeRootSetTable) + _table->entry_size() * _length : 0);
    1.73 +  return sizeof(*this) + (_table != NULL ? _table->mem_size() : 0);
    1.74  }
    1.75  
    1.76  void G1CodeRootSet::nmethods_do(CodeBlobClosure* blk) const {

mercurial