author | egahlin |
Tue, 15 May 2018 20:24:34 +0200 | |
changeset 50113 | caf115bb98ad |
parent 49592 | 77fb0be7d19f |
child 51179 | 516acf6956a2 |
permissions | -rw-r--r-- |
34659 | 1 |
/* |
37995 | 2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
34659 | 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_COMPACTHASHTABLE_INLINE_HPP |
|
26 |
#define SHARE_VM_CLASSFILE_COMPACTHASHTABLE_INLINE_HPP |
|
27 |
||
28 |
#include "classfile/compactHashtable.hpp" |
|
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47216
diff
changeset
|
29 |
#include "classfile/javaClasses.hpp" |
34659 | 30 |
#include "memory/allocation.inline.hpp" |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47216
diff
changeset
|
31 |
#include "oops/compressedOops.inline.hpp" |
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47216
diff
changeset
|
32 |
#include "oops/oop.hpp" |
34659 | 33 |
|
34 |
template <class T, class N> |
|
37995 | 35 |
inline Symbol* CompactHashtable<T, N>::decode_entry(CompactHashtable<Symbol*, char>* const t, |
36 |
u4 offset, const char* name, int len) { |
|
37 |
Symbol* sym = (Symbol*)(_base_address + offset); |
|
34659 | 38 |
if (sym->equals(name, len)) { |
39 |
assert(sym->refcount() == -1, "must be shared"); |
|
40 |
return sym; |
|
41 |
} |
|
42 |
||
43 |
return NULL; |
|
44 |
} |
|
45 |
||
46 |
template <class T, class N> |
|
37995 | 47 |
inline oop CompactHashtable<T, N>::decode_entry(CompactHashtable<oop, char>* const t, |
48 |
u4 offset, const char* name, int len) { |
|
49 |
narrowOop obj = (narrowOop)offset; |
|
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47216
diff
changeset
|
50 |
oop string = CompressedOops::decode(obj); |
34659 | 51 |
if (java_lang_String::equals(string, (jchar*)name, len)) { |
52 |
return string; |
|
53 |
} |
|
54 |
||
55 |
return NULL; |
|
56 |
} |
|
57 |
||
58 |
template <class T, class N> |
|
59 |
inline T CompactHashtable<T,N>::lookup(const N* name, unsigned int hash, int len) { |
|
60 |
if (_entry_count > 0) { |
|
61 |
int index = hash % _bucket_count; |
|
37995 | 62 |
u4 bucket_info = _buckets[index]; |
63 |
u4 bucket_offset = BUCKET_OFFSET(bucket_info); |
|
64 |
int bucket_type = BUCKET_TYPE(bucket_info); |
|
65 |
u4* entry = _entries + bucket_offset; |
|
34659 | 66 |
|
37995 | 67 |
if (bucket_type == VALUE_ONLY_BUCKET_TYPE) { |
68 |
T res = decode_entry(this, entry[0], name, len); |
|
34659 | 69 |
if (res != NULL) { |
70 |
return res; |
|
71 |
} |
|
72 |
} else { |
|
73 |
// This is a regular bucket, which has more than one |
|
74 |
// entries. Each entry is a pair of entry (hash, offset). |
|
75 |
// Seek until the end of the bucket. |
|
37995 | 76 |
u4* entry_max = _entries + BUCKET_OFFSET(_buckets[index + 1]); |
77 |
while (entry < entry_max) { |
|
78 |
unsigned int h = (unsigned int)(entry[0]); |
|
34659 | 79 |
if (h == hash) { |
37995 | 80 |
T res = decode_entry(this, entry[1], name, len); |
34659 | 81 |
if (res != NULL) { |
82 |
return res; |
|
83 |
} |
|
84 |
} |
|
37995 | 85 |
entry += 2; |
34659 | 86 |
} |
87 |
} |
|
88 |
} |
|
89 |
return NULL; |
|
90 |
} |
|
91 |
||
92 |
#endif // SHARE_VM_CLASSFILE_COMPACTHASHTABLE_INLINE_HPP |