8143615: compactHashtable.hpp includes .inline.hpp file
authoriklam
Wed, 02 Dec 2015 18:14:54 -0800
changeset 34659 3a7071043457
parent 34656 501b8f1784c4
child 34660 f1fcd7133a95
8143615: compactHashtable.hpp includes .inline.hpp file Reviewed-by: dholmes, stefank
hotspot/src/share/vm/classfile/compactHashtable.cpp
hotspot/src/share/vm/classfile/compactHashtable.hpp
hotspot/src/share/vm/classfile/compactHashtable.inline.hpp
hotspot/src/share/vm/classfile/stringTable.cpp
hotspot/src/share/vm/classfile/symbolTable.cpp
hotspot/src/share/vm/compiler/compilerDirectives.hpp
hotspot/src/share/vm/memory/filemap.cpp
--- a/hotspot/src/share/vm/classfile/compactHashtable.cpp	Fri Dec 04 13:02:25 2015 +0100
+++ b/hotspot/src/share/vm/classfile/compactHashtable.cpp	Wed Dec 02 18:14:54 2015 -0800
@@ -23,6 +23,7 @@
  */
 
 #include "precompiled.hpp"
+#include "classfile/compactHashtable.inline.hpp"
 #include "classfile/javaClasses.hpp"
 #include "memory/metaspaceShared.hpp"
 #include "prims/jvm.h"
--- a/hotspot/src/share/vm/classfile/compactHashtable.hpp	Fri Dec 04 13:02:25 2015 +0100
+++ b/hotspot/src/share/vm/classfile/compactHashtable.hpp	Wed Dec 02 18:14:54 2015 -0800
@@ -27,8 +27,6 @@
 
 #include "classfile/stringTable.hpp"
 #include "classfile/symbolTable.hpp"
-#include "memory/allocation.inline.hpp"
-#include "oops/oop.inline.hpp"
 #include "oops/symbol.hpp"
 #include "services/diagnosticCommand.hpp"
 #include "utilities/hashtable.hpp"
@@ -117,13 +115,8 @@
     return _required_bytes;
   }
 
-  void add(unsigned int hash, Symbol* symbol) {
-    add(hash, new Entry(hash, symbol));
-  }
-
-  void add(unsigned int hash, oop string) {
-    add(hash, new Entry(hash, string));
-  }
+  inline void add(unsigned int hash, Symbol* symbol);
+  inline void add(unsigned int hash, oop string);
 
 private:
   void add(unsigned int hash, Entry* entry);
@@ -219,27 +212,10 @@
   juint* _buckets;
 
   inline Symbol* lookup_entry(CompactHashtable<Symbol*, char>* const t,
-                              juint* addr, const char* name, int len) {
-    Symbol* sym = (Symbol*)((void*)(_base_address + *addr));
-    if (sym->equals(name, len)) {
-      assert(sym->refcount() == -1, "must be shared");
-      return sym;
-    }
-
-    return NULL;
-  }
+                              juint* addr, const char* name, int len);
 
   inline oop lookup_entry(CompactHashtable<oop, char>* const t,
-                        juint* addr, const char* name, int len) {
-    narrowOop obj = (narrowOop)(*addr);
-    oop string = oopDesc::decode_heap_oop(obj);
-    if (java_lang_String::equals(string, (jchar*)name, len)) {
-      return string;
-    }
-
-    return NULL;
-  }
-
+                          juint* addr, const char* name, int len);
 public:
   CompactHashtable() {
     _entry_count = 0;
@@ -257,41 +233,7 @@
   }
 
   // Lookup an entry from the compact table
-  inline T lookup(const N* name, unsigned int hash, int len) {
-    if (_entry_count > 0) {
-      assert(!DumpSharedSpaces, "run-time only");
-      int index = hash % _bucket_count;
-      juint bucket_info = _buckets[index];
-      juint bucket_offset = BUCKET_OFFSET(bucket_info);
-      int   bucket_type = BUCKET_TYPE(bucket_info);
-      juint* bucket = _buckets + bucket_offset;
-      juint* bucket_end = _buckets;
-
-      if (bucket_type == COMPACT_BUCKET_TYPE) {
-        // the compact bucket has one entry with entry offset only
-        T res = lookup_entry(this, &bucket[0], name, len);
-        if (res != NULL) {
-          return res;
-        }
-      } else {
-        // This is a regular bucket, which has more than one
-        // entries. Each entry is a pair of entry (hash, offset).
-        // Seek until the end of the bucket.
-        bucket_end += BUCKET_OFFSET(_buckets[index + 1]);
-        while (bucket < bucket_end) {
-          unsigned int h = (unsigned int)(bucket[0]);
-          if (h == hash) {
-            T res = lookup_entry(this, &bucket[1], name, len);
-            if (res != NULL) {
-              return res;
-            }
-          }
-          bucket += 2;
-        }
-      }
-    }
-    return NULL;
-  }
+  inline T lookup(const N* name, unsigned int hash, int len);
 
   // iterate over symbols
   void symbols_do(SymbolClosure *cl);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/classfile/compactHashtable.inline.hpp	Wed Dec 02 18:14:54 2015 -0800
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_CLASSFILE_COMPACTHASHTABLE_INLINE_HPP
+#define SHARE_VM_CLASSFILE_COMPACTHASHTABLE_INLINE_HPP
+
+#include "classfile/compactHashtable.hpp"
+#include "memory/allocation.inline.hpp"
+#include "oops/oop.inline.hpp"
+
+template <class T, class N>
+inline Symbol* CompactHashtable<T, N>::lookup_entry(CompactHashtable<Symbol*, char>* const t,
+                                             juint* addr, const char* name, int len) {
+  Symbol* sym = (Symbol*)((void*)(_base_address + *addr));
+  if (sym->equals(name, len)) {
+    assert(sym->refcount() == -1, "must be shared");
+    return sym;
+  }
+
+  return NULL;
+}
+
+template <class T, class N>
+inline oop CompactHashtable<T, N>::lookup_entry(CompactHashtable<oop, char>* const t,
+                                                juint* addr, const char* name, int len) {
+  narrowOop obj = (narrowOop)(*addr);
+  oop string = oopDesc::decode_heap_oop(obj);
+  if (java_lang_String::equals(string, (jchar*)name, len)) {
+    return string;
+  }
+
+  return NULL;
+}
+
+template <class T, class N>
+inline T CompactHashtable<T,N>::lookup(const N* name, unsigned int hash, int len) {
+  if (_entry_count > 0) {
+    assert(!DumpSharedSpaces, "run-time only");
+    int index = hash % _bucket_count;
+    juint bucket_info = _buckets[index];
+    juint bucket_offset = BUCKET_OFFSET(bucket_info);
+    int   bucket_type = BUCKET_TYPE(bucket_info);
+    juint* bucket = _buckets + bucket_offset;
+    juint* bucket_end = _buckets;
+
+    if (bucket_type == COMPACT_BUCKET_TYPE) {
+      // the compact bucket has one entry with entry offset only
+      T res = lookup_entry(this, &bucket[0], name, len);
+      if (res != NULL) {
+        return res;
+      }
+    } else {
+      // This is a regular bucket, which has more than one
+      // entries. Each entry is a pair of entry (hash, offset).
+      // Seek until the end of the bucket.
+      bucket_end += BUCKET_OFFSET(_buckets[index + 1]);
+      while (bucket < bucket_end) {
+        unsigned int h = (unsigned int)(bucket[0]);
+        if (h == hash) {
+          T res = lookup_entry(this, &bucket[1], name, len);
+          if (res != NULL) {
+            return res;
+          }
+        }
+        bucket += 2;
+      }
+    }
+  }
+  return NULL;
+}
+
+inline void CompactHashtableWriter::add(unsigned int hash, Symbol* symbol) {
+  add(hash, new Entry(hash, symbol));
+}
+
+inline void CompactHashtableWriter::add(unsigned int hash, oop string) {
+  add(hash, new Entry(hash, string));
+}
+
+
+#endif // SHARE_VM_CLASSFILE_COMPACTHASHTABLE_INLINE_HPP
--- a/hotspot/src/share/vm/classfile/stringTable.cpp	Fri Dec 04 13:02:25 2015 +0100
+++ b/hotspot/src/share/vm/classfile/stringTable.cpp	Wed Dec 02 18:14:54 2015 -0800
@@ -24,7 +24,7 @@
 
 #include "precompiled.hpp"
 #include "classfile/altHashing.hpp"
-#include "classfile/compactHashtable.hpp"
+#include "classfile/compactHashtable.inline.hpp"
 #include "classfile/javaClasses.hpp"
 #include "classfile/stringTable.hpp"
 #include "classfile/systemDictionary.hpp"
--- a/hotspot/src/share/vm/classfile/symbolTable.cpp	Fri Dec 04 13:02:25 2015 +0100
+++ b/hotspot/src/share/vm/classfile/symbolTable.cpp	Wed Dec 02 18:14:54 2015 -0800
@@ -24,7 +24,7 @@
 
 #include "precompiled.hpp"
 #include "classfile/altHashing.hpp"
-#include "classfile/compactHashtable.hpp"
+#include "classfile/compactHashtable.inline.hpp"
 #include "classfile/javaClasses.hpp"
 #include "classfile/symbolTable.hpp"
 #include "classfile/systemDictionary.hpp"
--- a/hotspot/src/share/vm/compiler/compilerDirectives.hpp	Fri Dec 04 13:02:25 2015 +0100
+++ b/hotspot/src/share/vm/compiler/compilerDirectives.hpp	Wed Dec 02 18:14:54 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,6 @@
 #include "ci/ciUtilities.hpp"
 #include "compiler/methodMatcher.hpp"
 #include "compiler/compilerOracle.hpp"
-#include "oops/oop.inline.hpp"
 #include "utilities/exceptions.hpp"
 
   //      Directives flag name,    type, default value, compile command name
--- a/hotspot/src/share/vm/memory/filemap.cpp	Fri Dec 04 13:02:25 2015 +0100
+++ b/hotspot/src/share/vm/memory/filemap.cpp	Wed Dec 02 18:14:54 2015 -0800
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "classfile/classLoader.hpp"
+#include "classfile/compactHashtable.inline.hpp"
 #include "classfile/sharedClassUtil.hpp"
 #include "classfile/symbolTable.hpp"
 #include "classfile/systemDictionaryShared.hpp"