src/share/vm/utilities/hashtable.cpp

changeset 8766
ce9a710b0f63
parent 7208
7baf47cb97cb
child 8856
ac27a9c85bea
child 9614
bb44c0e88235
     1.1 --- a/src/share/vm/utilities/hashtable.cpp	Fri May 05 06:07:11 2017 -0700
     1.2 +++ b/src/share/vm/utilities/hashtable.cpp	Mon May 15 12:20:15 2017 +0200
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2003, 2017, 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 @@ -172,6 +172,35 @@
    1.11    }
    1.12  }
    1.13  
    1.14 +template <MEMFLAGS F> void BasicHashtable<F>::BucketUnlinkContext::free_entry(BasicHashtableEntry<F>* entry) {
    1.15 +  entry->set_next(_removed_head);
    1.16 +  _removed_head = entry;
    1.17 +  if (_removed_tail == NULL) {
    1.18 +    _removed_tail = entry;
    1.19 +  }
    1.20 +  _num_removed++;
    1.21 +}
    1.22 +
    1.23 +template <MEMFLAGS F> void BasicHashtable<F>::bulk_free_entries(BucketUnlinkContext* context) {
    1.24 +  if (context->_num_removed == 0) {
    1.25 +    assert(context->_removed_head == NULL && context->_removed_tail == NULL,
    1.26 +           err_msg("Zero entries in the unlink context, but elements linked from " PTR_FORMAT " to " PTR_FORMAT,
    1.27 +                   p2i(context->_removed_head), p2i(context->_removed_tail)));
    1.28 +    return;
    1.29 +  }
    1.30 +
    1.31 +  // MT-safe add of the list of BasicHashTableEntrys from the context to the free list.
    1.32 +  BasicHashtableEntry<F>* current = _free_list;
    1.33 +  while (true) {
    1.34 +    context->_removed_tail->set_next(current);
    1.35 +    BasicHashtableEntry<F>* old = (BasicHashtableEntry<F>*)Atomic::cmpxchg_ptr(context->_removed_head, &_free_list, current);
    1.36 +    if (old == current) {
    1.37 +      break;
    1.38 +    }
    1.39 +    current = old;
    1.40 +  }
    1.41 +  Atomic::add(-context->_num_removed, &_number_of_entries);
    1.42 +}
    1.43  
    1.44  // Copy the table to the shared space.
    1.45  

mercurial