src/share/vm/classfile/symbolTable.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 







  25 // The symbol table holds all symbolOops and corresponding interned strings.
  26 // symbolOops and literal strings should be canonicalized.
  27 //
  28 // The interned strings are created lazily.
  29 //
  30 // It is implemented as an open hash table with a fixed number of buckets.
  31 //
  32 // %note:
  33 //  - symbolTableEntrys are allocated in blocks to reduce the space overhead.
  34 
  35 class BoolObjectClosure;
  36 
  37 
  38 class SymbolTable : public Hashtable {
  39   friend class VMStructs;
  40 
  41 private:
  42   // The symbol table
  43   static SymbolTable* _the_table;
  44 


 205 
 206   // Interning
 207   static oop intern(symbolOop symbol, TRAPS);
 208   static oop intern(oop string, TRAPS);
 209   static oop intern(const char *utf8_string, TRAPS);
 210 
 211   // Debugging
 212   static void verify();
 213 
 214   // Sharing
 215   static void copy_buckets(char** top, char*end) {
 216     the_table()->Hashtable::copy_buckets(top, end);
 217   }
 218   static void copy_table(char** top, char*end) {
 219     the_table()->Hashtable::copy_table(top, end);
 220   }
 221   static void reverse() {
 222     ((BasicHashtable*)the_table())->reverse();
 223   }
 224 };


   1 /*
   2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP
  26 #define SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP
  27 
  28 #include "memory/allocation.inline.hpp"
  29 #include "oops/symbolOop.hpp"
  30 #include "utilities/hashtable.hpp"
  31 
  32 // The symbol table holds all symbolOops and corresponding interned strings.
  33 // symbolOops and literal strings should be canonicalized.
  34 //
  35 // The interned strings are created lazily.
  36 //
  37 // It is implemented as an open hash table with a fixed number of buckets.
  38 //
  39 // %note:
  40 //  - symbolTableEntrys are allocated in blocks to reduce the space overhead.
  41 
  42 class BoolObjectClosure;
  43 
  44 
  45 class SymbolTable : public Hashtable {
  46   friend class VMStructs;
  47 
  48 private:
  49   // The symbol table
  50   static SymbolTable* _the_table;
  51 


 212 
 213   // Interning
 214   static oop intern(symbolOop symbol, TRAPS);
 215   static oop intern(oop string, TRAPS);
 216   static oop intern(const char *utf8_string, TRAPS);
 217 
 218   // Debugging
 219   static void verify();
 220 
 221   // Sharing
 222   static void copy_buckets(char** top, char*end) {
 223     the_table()->Hashtable::copy_buckets(top, end);
 224   }
 225   static void copy_table(char** top, char*end) {
 226     the_table()->Hashtable::copy_table(top, end);
 227   }
 228   static void reverse() {
 229     ((BasicHashtable*)the_table())->reverse();
 230   }
 231 };
 232 
 233 #endif // SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP