src/share/vm/classfile/symbolTable.cpp

changeset 5277
01522ca68fc7
parent 5196
8dbc025ff709
child 5743
63147986a428
child 5769
2c022e432e10
     1.1 --- a/src/share/vm/classfile/symbolTable.cpp	Fri Jun 14 08:02:32 2013 +0200
     1.2 +++ b/src/share/vm/classfile/symbolTable.cpp	Tue Jun 18 12:31:07 2013 -0700
     1.3 @@ -598,6 +598,8 @@
     1.4  
     1.5  bool StringTable::_needs_rehashing = false;
     1.6  
     1.7 +volatile int StringTable::_parallel_claimed_idx = 0;
     1.8 +
     1.9  // Pick hashing algorithm
    1.10  unsigned int StringTable::hash_string(const jchar* s, int len) {
    1.11    return use_alternate_hashcode() ? AltHashing::murmur3_32(seed(), s, len) :
    1.12 @@ -761,8 +763,18 @@
    1.13    }
    1.14  }
    1.15  
    1.16 -void StringTable::oops_do(OopClosure* f) {
    1.17 -  for (int i = 0; i < the_table()->table_size(); ++i) {
    1.18 +void StringTable::buckets_do(OopClosure* f, int start_idx, int end_idx) {
    1.19 +  const int limit = the_table()->table_size();
    1.20 +
    1.21 +  assert(0 <= start_idx && start_idx <= limit,
    1.22 +         err_msg("start_idx (" INT32_FORMAT ") oob?", start_idx));
    1.23 +  assert(0 <= end_idx && end_idx <= limit,
    1.24 +         err_msg("end_idx (" INT32_FORMAT ") oob?", end_idx));
    1.25 +  assert(start_idx <= end_idx,
    1.26 +         err_msg("Ordering: start_idx=" INT32_FORMAT", end_idx=" INT32_FORMAT,
    1.27 +                 start_idx, end_idx));
    1.28 +
    1.29 +  for (int i = start_idx; i < end_idx; i += 1) {
    1.30      HashtableEntry<oop, mtSymbol>* entry = the_table()->bucket(i);
    1.31      while (entry != NULL) {
    1.32        assert(!entry->is_shared(), "CDS not used for the StringTable");
    1.33 @@ -774,6 +786,27 @@
    1.34    }
    1.35  }
    1.36  
    1.37 +void StringTable::oops_do(OopClosure* f) {
    1.38 +  buckets_do(f, 0, the_table()->table_size());
    1.39 +}
    1.40 +
    1.41 +void StringTable::possibly_parallel_oops_do(OopClosure* f) {
    1.42 +  const int ClaimChunkSize = 32;
    1.43 +  const int limit = the_table()->table_size();
    1.44 +
    1.45 +  for (;;) {
    1.46 +    // Grab next set of buckets to scan
    1.47 +    int start_idx = Atomic::add(ClaimChunkSize, &_parallel_claimed_idx) - ClaimChunkSize;
    1.48 +    if (start_idx >= limit) {
    1.49 +      // End of table
    1.50 +      break;
    1.51 +    }
    1.52 +
    1.53 +    int end_idx = MIN2(limit, start_idx + ClaimChunkSize);
    1.54 +    buckets_do(f, start_idx, end_idx);
    1.55 +  }
    1.56 +}
    1.57 +
    1.58  void StringTable::verify() {
    1.59    for (int i = 0; i < the_table()->table_size(); ++i) {
    1.60      HashtableEntry<oop, mtSymbol>* p = the_table()->bucket(i);

mercurial