src/share/vm/classfile/symbolTable.cpp

changeset 4037
da91efe96a93
parent 3904
ace99a6ffc83
child 4335
2aa953165ade
     1.1 --- a/src/share/vm/classfile/symbolTable.cpp	Fri Aug 31 16:39:35 2012 -0700
     1.2 +++ b/src/share/vm/classfile/symbolTable.cpp	Sat Sep 01 13:25:18 2012 -0400
     1.3 @@ -48,15 +48,19 @@
     1.4    assert (len <= Symbol::max_length(), "should be checked by caller");
     1.5  
     1.6    Symbol* sym;
     1.7 -  // Allocate symbols in the C heap when dumping shared spaces in case there
     1.8 -  // are temporary symbols we can remove.
     1.9 -  if (c_heap || DumpSharedSpaces) {
    1.10 +
    1.11 +  if (c_heap) {
    1.12      // refcount starts as 1
    1.13 +    assert(!DumpSharedSpaces, "never allocate to C heap");
    1.14      sym = new (len, THREAD) Symbol(name, len, 1);
    1.15 +    assert(sym != NULL, "new should call vm_exit_out_of_memory if C_HEAP is exhausted");
    1.16 +  } else {
    1.17 +    if (DumpSharedSpaces) {
    1.18 +      sym = new (len, ClassLoaderData::the_null_class_loader_data(), THREAD) Symbol(name, len, -1);
    1.19    } else {
    1.20      sym = new (len, arena(), THREAD) Symbol(name, len, -1);
    1.21    }
    1.22 -  assert(sym != NULL, "new should call vm_exit_out_of_memory if C_HEAP is exhausted");
    1.23 +  }
    1.24    return sym;
    1.25  }
    1.26  
    1.27 @@ -102,7 +106,7 @@
    1.28          break;
    1.29        }
    1.30        Symbol* s = entry->literal();
    1.31 -      memory_total += s->object_size();
    1.32 +      memory_total += s->size();
    1.33        total++;
    1.34        assert(s != NULL, "just checking");
    1.35        // If reference count is zero, remove.
    1.36 @@ -302,7 +306,7 @@
    1.37    }
    1.38  }
    1.39  
    1.40 -void SymbolTable::add(Handle class_loader, constantPoolHandle cp,
    1.41 +void SymbolTable::add(ClassLoaderData* loader_data, constantPoolHandle cp,
    1.42                        int names_count,
    1.43                        const char** names, int* lengths, int* cp_indices,
    1.44                        unsigned int* hashValues, TRAPS) {
    1.45 @@ -310,13 +314,13 @@
    1.46    MutexLocker ml(SymbolTable_lock, THREAD);
    1.47  
    1.48    SymbolTable* table = the_table();
    1.49 -  bool added = table->basic_add(class_loader, cp, names_count, names, lengths,
    1.50 +  bool added = table->basic_add(loader_data, cp, names_count, names, lengths,
    1.51                                  cp_indices, hashValues, CHECK);
    1.52    if (!added) {
    1.53      // do it the hard way
    1.54      for (int i=0; i<names_count; i++) {
    1.55        int index = table->hash_to_index(hashValues[i]);
    1.56 -      bool c_heap = class_loader() != NULL;
    1.57 +      bool c_heap = !loader_data->is_the_null_class_loader_data();
    1.58        Symbol* sym = table->basic_add(index, (u1*)names[i], lengths[i], hashValues[i], c_heap, CHECK);
    1.59        cp->symbol_at_put(cp_indices[i], sym);
    1.60      }
    1.61 @@ -383,7 +387,7 @@
    1.62  
    1.63  // This version of basic_add adds symbols in batch from the constant pool
    1.64  // parsing.
    1.65 -bool SymbolTable::basic_add(Handle class_loader, constantPoolHandle cp,
    1.66 +bool SymbolTable::basic_add(ClassLoaderData* loader_data, constantPoolHandle cp,
    1.67                              int names_count,
    1.68                              const char** names, int* lengths,
    1.69                              int* cp_indices, unsigned int* hashValues,
    1.70 @@ -421,7 +425,7 @@
    1.71      } else {
    1.72        // Create a new symbol.  The null class loader is never unloaded so these
    1.73        // are allocated specially in a permanent arena.
    1.74 -      bool c_heap = class_loader() != NULL;
    1.75 +      bool c_heap = !loader_data->is_the_null_class_loader_data();
    1.76        Symbol* sym = allocate_symbol((const u1*)names[i], lengths[i], c_heap, CHECK_(false));
    1.77        assert(sym->equals(names[i], lengths[i]), "symbol must be properly initialized");  // why wouldn't it be???
    1.78        HashtableEntry<Symbol*, mtSymbol>* entry = new_entry(hashValue, sym);
    1.79 @@ -490,7 +494,7 @@
    1.80    for (i = 0; i < the_table()->table_size(); i++) {
    1.81      HashtableEntry<Symbol*, mtSymbol>* p = the_table()->bucket(i);
    1.82      for ( ; p != NULL; p = p->next()) {
    1.83 -      memory_total += p->literal()->object_size();
    1.84 +      memory_total += p->literal()->size();
    1.85        count++;
    1.86        int counter = p->literal()->utf8_length();
    1.87        total += counter;
    1.88 @@ -695,10 +699,10 @@
    1.89  
    1.90    Handle string;
    1.91    // try to reuse the string if possible
    1.92 -  if (!string_or_null.is_null() && (!JavaObjectsInPerm || string_or_null()->is_perm())) {
    1.93 +  if (!string_or_null.is_null()) {
    1.94      string = string_or_null;
    1.95    } else {
    1.96 -    string = java_lang_String::create_tenured_from_unicode(name, len, CHECK_NULL);
    1.97 +    string = java_lang_String::create_from_unicode(name, len, CHECK_NULL);
    1.98    }
    1.99  
   1.100    // Grab the StringTable_lock before getting the_table() because it could
   1.101 @@ -797,7 +801,6 @@
   1.102      for ( ; p != NULL; p = p->next()) {
   1.103        oop s = p->literal();
   1.104        guarantee(s != NULL, "interned string is NULL");
   1.105 -      guarantee(s->is_perm() || !JavaObjectsInPerm, "interned string not in permspace");
   1.106        unsigned int h = java_lang_String::hash_string(s);
   1.107        guarantee(p->hash() == h, "broken hash in string table entry");
   1.108        guarantee(the_table()->hash_to_index(h) == i,

mercurial