src/hotspot/share/classfile/compactHashtable.inline.hpp
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 37995 hotspot/src/share/vm/classfile/compactHashtable.inline.hpp@92aec042a43b
child 49592 77fb0be7d19f
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34659
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
     1
/*
37995
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 34659
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
34659
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
     4
 *
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
     7
 * published by the Free Software Foundation.
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
     8
 *
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    13
 * accompanied this code).
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    14
 *
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    18
 *
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    21
 * questions.
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    22
 *
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    23
 */
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    24
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    25
#ifndef SHARE_VM_CLASSFILE_COMPACTHASHTABLE_INLINE_HPP
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    26
#define SHARE_VM_CLASSFILE_COMPACTHASHTABLE_INLINE_HPP
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    27
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    28
#include "classfile/compactHashtable.hpp"
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    29
#include "memory/allocation.inline.hpp"
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    30
#include "oops/oop.inline.hpp"
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    31
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    32
template <class T, class N>
37995
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 34659
diff changeset
    33
inline Symbol* CompactHashtable<T, N>::decode_entry(CompactHashtable<Symbol*, char>* const t,
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 34659
diff changeset
    34
                                                    u4 offset, const char* name, int len) {
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 34659
diff changeset
    35
  Symbol* sym = (Symbol*)(_base_address + offset);
34659
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    36
  if (sym->equals(name, len)) {
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    37
    assert(sym->refcount() == -1, "must be shared");
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    38
    return sym;
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    39
  }
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    40
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    41
  return NULL;
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    42
}
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    43
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    44
template <class T, class N>
37995
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 34659
diff changeset
    45
inline oop CompactHashtable<T, N>::decode_entry(CompactHashtable<oop, char>* const t,
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 34659
diff changeset
    46
                                                u4 offset, const char* name, int len) {
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 34659
diff changeset
    47
  narrowOop obj = (narrowOop)offset;
34659
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    48
  oop string = oopDesc::decode_heap_oop(obj);
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    49
  if (java_lang_String::equals(string, (jchar*)name, len)) {
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    50
    return string;
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    51
  }
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    52
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    53
  return NULL;
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    54
}
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    55
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    56
template <class T, class N>
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    57
inline T CompactHashtable<T,N>::lookup(const N* name, unsigned int hash, int len) {
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    58
  if (_entry_count > 0) {
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    59
    int index = hash % _bucket_count;
37995
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 34659
diff changeset
    60
    u4 bucket_info = _buckets[index];
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 34659
diff changeset
    61
    u4 bucket_offset = BUCKET_OFFSET(bucket_info);
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 34659
diff changeset
    62
    int bucket_type = BUCKET_TYPE(bucket_info);
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 34659
diff changeset
    63
    u4* entry = _entries + bucket_offset;
34659
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    64
37995
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 34659
diff changeset
    65
    if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 34659
diff changeset
    66
      T res = decode_entry(this, entry[0], name, len);
34659
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    67
      if (res != NULL) {
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    68
        return res;
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    69
      }
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    70
    } else {
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    71
      // This is a regular bucket, which has more than one
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    72
      // entries. Each entry is a pair of entry (hash, offset).
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    73
      // Seek until the end of the bucket.
37995
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 34659
diff changeset
    74
      u4* entry_max = _entries + BUCKET_OFFSET(_buckets[index + 1]);
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 34659
diff changeset
    75
      while (entry < entry_max) {
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 34659
diff changeset
    76
        unsigned int h = (unsigned int)(entry[0]);
34659
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    77
        if (h == hash) {
37995
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 34659
diff changeset
    78
          T res = decode_entry(this, entry[1], name, len);
34659
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    79
          if (res != NULL) {
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    80
            return res;
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    81
          }
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    82
        }
37995
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 34659
diff changeset
    83
        entry += 2;
34659
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    84
      }
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    85
    }
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    86
  }
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    87
  return NULL;
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    88
}
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    89
3a7071043457 8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
diff changeset
    90
#endif // SHARE_VM_CLASSFILE_COMPACTHASHTABLE_INLINE_HPP