Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
671d00ce
D
dragonwell8_hotspot
项目概览
openanolis
/
dragonwell8_hotspot
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_hotspot
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
671d00ce
编写于
8月 29, 2014
作者:
M
mgerdin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8056084: Refactor Hashtable to allow implementations without rehashing support
Reviewed-by: gziemski, jmasa, brutisso, coleenp, tschatzl
上级
8dd4a007
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
61 addition
and
41 deletion
+61
-41
src/share/vm/classfile/symbolTable.cpp
src/share/vm/classfile/symbolTable.cpp
+2
-2
src/share/vm/classfile/symbolTable.hpp
src/share/vm/classfile/symbolTable.hpp
+6
-6
src/share/vm/utilities/hashtable.cpp
src/share/vm/utilities/hashtable.cpp
+27
-23
src/share/vm/utilities/hashtable.hpp
src/share/vm/utilities/hashtable.hpp
+26
-10
未找到文件。
src/share/vm/classfile/symbolTable.cpp
浏览文件 @
671d00ce
...
...
@@ -205,7 +205,7 @@ Symbol* SymbolTable::lookup(int index, const char* name,
}
}
// If the bucket size is too deep check if this hash code is insufficient.
if
(
count
>=
BasicHashtable
<
mtSymbol
>::
rehash_count
&&
!
needs_rehashing
())
{
if
(
count
>=
rehash_count
&&
!
needs_rehashing
())
{
_needs_rehashing
=
check_rehash_table
(
count
);
}
return
NULL
;
...
...
@@ -656,7 +656,7 @@ oop StringTable::lookup(int index, jchar* name,
}
}
// If the bucket size is too deep check if this hash code is insufficient.
if
(
count
>=
BasicHashtable
<
mtSymbol
>::
rehash_count
&&
!
needs_rehashing
())
{
if
(
count
>=
rehash_count
&&
!
needs_rehashing
())
{
_needs_rehashing
=
check_rehash_table
(
count
);
}
return
NULL
;
...
...
src/share/vm/classfile/symbolTable.hpp
浏览文件 @
671d00ce
...
...
@@ -74,7 +74,7 @@ class TempNewSymbol : public StackObj {
operator
Symbol
*
()
{
return
_temp
;
}
};
class
SymbolTable
:
public
Hashtable
<
Symbol
*
,
mtSymbol
>
{
class
SymbolTable
:
public
Rehashable
Hashtable
<
Symbol
*
,
mtSymbol
>
{
friend
class
VMStructs
;
friend
class
ClassFileParser
;
...
...
@@ -110,10 +110,10 @@ private:
Symbol
*
lookup
(
int
index
,
const
char
*
name
,
int
len
,
unsigned
int
hash
);
SymbolTable
()
:
Hashtable
<
Symbol
*
,
mtSymbol
>
(
SymbolTableSize
,
sizeof
(
HashtableEntry
<
Symbol
*
,
mtSymbol
>
))
{}
:
Rehashable
Hashtable
<
Symbol
*
,
mtSymbol
>
(
SymbolTableSize
,
sizeof
(
HashtableEntry
<
Symbol
*
,
mtSymbol
>
))
{}
SymbolTable
(
HashtableBucket
<
mtSymbol
>*
t
,
int
number_of_entries
)
:
Hashtable
<
Symbol
*
,
mtSymbol
>
(
SymbolTableSize
,
sizeof
(
HashtableEntry
<
Symbol
*
,
mtSymbol
>
),
t
,
:
Rehashable
Hashtable
<
Symbol
*
,
mtSymbol
>
(
SymbolTableSize
,
sizeof
(
HashtableEntry
<
Symbol
*
,
mtSymbol
>
),
t
,
number_of_entries
)
{}
// Arena for permanent symbols (null class loader) that are never unloaded
...
...
@@ -252,7 +252,7 @@ public:
static
int
parallel_claimed_index
()
{
return
_parallel_claimed_idx
;
}
};
class
StringTable
:
public
Hashtable
<
oop
,
mtSymbol
>
{
class
StringTable
:
public
Rehashable
Hashtable
<
oop
,
mtSymbol
>
{
friend
class
VMStructs
;
private:
...
...
@@ -278,11 +278,11 @@ private:
// in the range [start_idx, end_idx).
static
void
buckets_unlink_or_oops_do
(
BoolObjectClosure
*
is_alive
,
OopClosure
*
f
,
int
start_idx
,
int
end_idx
,
int
*
processed
,
int
*
removed
);
StringTable
()
:
Hashtable
<
oop
,
mtSymbol
>
((
int
)
StringTableSize
,
StringTable
()
:
Rehashable
Hashtable
<
oop
,
mtSymbol
>
((
int
)
StringTableSize
,
sizeof
(
HashtableEntry
<
oop
,
mtSymbol
>
))
{}
StringTable
(
HashtableBucket
<
mtSymbol
>*
t
,
int
number_of_entries
)
:
Hashtable
<
oop
,
mtSymbol
>
((
int
)
StringTableSize
,
sizeof
(
HashtableEntry
<
oop
,
mtSymbol
>
),
t
,
:
Rehashable
Hashtable
<
oop
,
mtSymbol
>
((
int
)
StringTableSize
,
sizeof
(
HashtableEntry
<
oop
,
mtSymbol
>
),
t
,
number_of_entries
)
{}
public:
// The string table
...
...
src/share/vm/utilities/hashtable.cpp
浏览文件 @
671d00ce
...
...
@@ -36,21 +36,22 @@
#include "utilities/numberSeq.hpp"
// This is a generic hashtable, designed to be used for the symbol
// and string tables.
//
// It is implemented as an open hash table with a fixed number of buckets.
//
// %note:
// - HashtableEntrys are allocated in blocks to reduce the space overhead.
template
<
MEMFLAGS
F
>
BasicHashtableEntry
<
F
>*
BasicHashtable
<
F
>::
new_entry
(
unsigned
int
hashValue
)
{
BasicHashtableEntry
<
F
>*
entry
;
// This hashtable is implemented as an open hash table with a fixed number of buckets.
if
(
_free_list
)
{
template
<
MEMFLAGS
F
>
BasicHashtableEntry
<
F
>*
BasicHashtable
<
F
>::
new_entry_free_list
()
{
BasicHashtableEntry
<
F
>*
entry
=
NULL
;
if
(
_free_list
!=
NULL
)
{
entry
=
_free_list
;
_free_list
=
_free_list
->
next
();
}
else
{
}
return
entry
;
}
// HashtableEntrys are allocated in blocks to reduce the space overhead.
template
<
MEMFLAGS
F
>
BasicHashtableEntry
<
F
>*
BasicHashtable
<
F
>::
new_entry
(
unsigned
int
hashValue
)
{
BasicHashtableEntry
<
F
>*
entry
=
new_entry_free_list
();
if
(
entry
==
NULL
)
{
if
(
_first_free_entry
+
_entry_size
>=
_end_block
)
{
int
block_size
=
MIN2
(
512
,
MAX2
((
int
)
_table_size
/
2
,
(
int
)
_number_of_entries
));
int
len
=
_entry_size
*
block_size
;
...
...
@@ -83,9 +84,9 @@ template <class T, MEMFLAGS F> HashtableEntry<T, F>* Hashtable<T, F>::new_entry(
// This is somewhat an arbitrary heuristic but if one bucket gets to
// rehash_count which is currently 100, there's probably something wrong.
template
<
MEMFLAGS
F
>
bool
BasicHashtable
<
F
>::
check_rehash_table
(
int
count
)
{
assert
(
table_size
()
!=
0
,
"underflow"
);
if
(
count
>
(((
double
)
number_of_entries
()
/
(
double
)
table_size
())
*
rehash_multiple
))
{
template
<
class
T
,
MEMFLAGS
F
>
bool
RehashableHashtable
<
T
,
F
>::
check_rehash_table
(
int
count
)
{
assert
(
t
his
->
t
able_size
()
!=
0
,
"underflow"
);
if
(
count
>
(((
double
)
this
->
number_of_entries
()
/
(
double
)
this
->
table_size
())
*
rehash_multiple
))
{
// Set a flag for the next safepoint, which should be at some guaranteed
// safepoint interval.
return
true
;
...
...
@@ -93,13 +94,13 @@ template <MEMFLAGS F> bool BasicHashtable<F>::check_rehash_table(int count) {
return
false
;
}
template
<
class
T
,
MEMFLAGS
F
>
juint
Hashtable
<
T
,
F
>::
_seed
=
0
;
template
<
class
T
,
MEMFLAGS
F
>
juint
Rehashable
Hashtable
<
T
,
F
>::
_seed
=
0
;
// Create a new table and using alternate hash code, populate the new table
// with the existing elements. This can be used to change the hash code
// and could in the future change the size of the table.
template
<
class
T
,
MEMFLAGS
F
>
void
Hashtable
<
T
,
F
>::
move_to
(
Hashtable
<
T
,
F
>*
new_table
)
{
template
<
class
T
,
MEMFLAGS
F
>
void
RehashableHashtable
<
T
,
F
>::
move_to
(
Rehashable
Hashtable
<
T
,
F
>*
new_table
)
{
// Initialize the global seed for hashing.
_seed
=
AltHashing
::
compute_seed
();
...
...
@@ -109,7 +110,7 @@ template <class T, MEMFLAGS F> void Hashtable<T, F>::move_to(Hashtable<T, F>* ne
// Iterate through the table and create a new entry for the new table
for
(
int
i
=
0
;
i
<
new_table
->
table_size
();
++
i
)
{
for
(
HashtableEntry
<
T
,
F
>*
p
=
bucket
(
i
);
p
!=
NULL
;
)
{
for
(
HashtableEntry
<
T
,
F
>*
p
=
this
->
bucket
(
i
);
p
!=
NULL
;
)
{
HashtableEntry
<
T
,
F
>*
next
=
p
->
next
();
T
string
=
p
->
literal
();
// Use alternate hashing algorithm on the symbol in the first table
...
...
@@ -238,11 +239,11 @@ template <class T, MEMFLAGS F> void Hashtable<T, F>::reverse(void* boundary) {
}
}
template
<
class
T
,
MEMFLAGS
F
>
int
Hashtable
<
T
,
F
>::
literal_size
(
Symbol
*
symbol
)
{
template
<
class
T
,
MEMFLAGS
F
>
int
Rehashable
Hashtable
<
T
,
F
>::
literal_size
(
Symbol
*
symbol
)
{
return
symbol
->
size
()
*
HeapWordSize
;
}
template
<
class
T
,
MEMFLAGS
F
>
int
Hashtable
<
T
,
F
>::
literal_size
(
oop
oop
)
{
template
<
class
T
,
MEMFLAGS
F
>
int
Rehashable
Hashtable
<
T
,
F
>::
literal_size
(
oop
oop
)
{
// NOTE: this would over-count if (pre-JDK8) java_lang_Class::has_offset_field() is true,
// and the String.value array is shared by several Strings. However, starting from JDK8,
// the String.value array is not shared anymore.
...
...
@@ -255,12 +256,12 @@ template <class T, MEMFLAGS F> int Hashtable<T, F>::literal_size(oop oop) {
// Note: if you create a new subclass of Hashtable<MyNewType, F>, you will need to
// add a new function Hashtable<T, F>::literal_size(MyNewType lit)
template
<
class
T
,
MEMFLAGS
F
>
void
Hashtable
<
T
,
F
>::
dump_table
(
outputStream
*
st
,
const
char
*
table_name
)
{
template
<
class
T
,
MEMFLAGS
F
>
void
Rehashable
Hashtable
<
T
,
F
>::
dump_table
(
outputStream
*
st
,
const
char
*
table_name
)
{
NumberSeq
summary
;
int
literal_bytes
=
0
;
for
(
int
i
=
0
;
i
<
this
->
table_size
();
++
i
)
{
int
count
=
0
;
for
(
HashtableEntry
<
T
,
F
>*
e
=
bucket
(
i
);
for
(
HashtableEntry
<
T
,
F
>*
e
=
this
->
bucket
(
i
);
e
!=
NULL
;
e
=
e
->
next
())
{
count
++
;
literal_bytes
+=
literal_size
(
e
->
literal
());
...
...
@@ -270,7 +271,7 @@ template <class T, MEMFLAGS F> void Hashtable<T, F>::dump_table(outputStream* st
double
num_buckets
=
summary
.
num
();
double
num_entries
=
summary
.
sum
();
int
bucket_bytes
=
(
int
)
num_buckets
*
sizeof
(
bucket
(
0
)
);
int
bucket_bytes
=
(
int
)
num_buckets
*
sizeof
(
HashtableBucket
<
F
>
);
int
entry_bytes
=
(
int
)
num_entries
*
sizeof
(
HashtableEntry
<
T
,
F
>
);
int
total_bytes
=
literal_bytes
+
bucket_bytes
+
entry_bytes
;
...
...
@@ -353,11 +354,14 @@ template <MEMFLAGS F> void BasicHashtable<F>::verify_lookup_length(double load)
#endif
// Explicitly instantiate these types
template
class
Hashtable
<
ConstantPool
*
,
mtClass
>;
template
class
RehashableHashtable
<
Symbol
*
,
mtSymbol
>;
template
class
RehashableHashtable
<
oopDesc
*
,
mtSymbol
>;
template
class
Hashtable
<
Symbol
*
,
mtSymbol
>;
template
class
Hashtable
<
Klass
*
,
mtClass
>;
template
class
Hashtable
<
oop
,
mtClass
>;
#if defined(SOLARIS) || defined(CHECK_UNHANDLED_OOPS)
template
class
Hashtable
<
oop
,
mtSymbol
>;
template
class
RehashableHashtable
<
oop
,
mtSymbol
>;
#endif // SOLARIS || CHECK_UNHANDLED_OOPS
template
class
Hashtable
<
oopDesc
*
,
mtSymbol
>;
template
class
Hashtable
<
Symbol
*
,
mtClass
>;
...
...
src/share/vm/utilities/hashtable.hpp
浏览文件 @
671d00ce
...
...
@@ -178,11 +178,6 @@ protected:
void
verify_lookup_length
(
double
load
);
#endif
enum
{
rehash_count
=
100
,
rehash_multiple
=
60
};
void
initialize
(
int
table_size
,
int
entry_size
,
int
number_of_entries
);
// Accessor
...
...
@@ -194,12 +189,12 @@ protected:
// The following method is not MT-safe and must be done under lock.
BasicHashtableEntry
<
F
>**
bucket_addr
(
int
i
)
{
return
_buckets
[
i
].
entry_addr
();
}
// Attempt to get an entry from the free list
BasicHashtableEntry
<
F
>*
new_entry_free_list
();
// Table entry management
BasicHashtableEntry
<
F
>*
new_entry
(
unsigned
int
hashValue
);
// Check that the table is unbalanced
bool
check_rehash_table
(
int
count
);
// Used when moving the entry to another table
// Clean up links, but do not add to free_list
void
unlink_entry
(
BasicHashtableEntry
<
F
>*
entry
)
{
...
...
@@ -277,8 +272,30 @@ protected:
return
(
HashtableEntry
<
T
,
F
>**
)
BasicHashtable
<
F
>::
bucket_addr
(
i
);
}
};
template
<
class
T
,
MEMFLAGS
F
>
class
RehashableHashtable
:
public
Hashtable
<
T
,
F
>
{
protected:
enum
{
rehash_count
=
100
,
rehash_multiple
=
60
};
// Check that the table is unbalanced
bool
check_rehash_table
(
int
count
);
public:
RehashableHashtable
(
int
table_size
,
int
entry_size
)
:
Hashtable
<
T
,
F
>
(
table_size
,
entry_size
)
{
}
RehashableHashtable
(
int
table_size
,
int
entry_size
,
HashtableBucket
<
F
>*
buckets
,
int
number_of_entries
)
:
Hashtable
<
T
,
F
>
(
table_size
,
entry_size
,
buckets
,
number_of_entries
)
{
}
// Function to move these elements into the new table.
void
move_to
(
Hashtable
<
T
,
F
>*
new_table
);
void
move_to
(
Rehashable
Hashtable
<
T
,
F
>*
new_table
);
static
bool
use_alternate_hashcode
()
{
return
_seed
!=
0
;
}
static
juint
seed
()
{
return
_seed
;
}
...
...
@@ -292,7 +309,6 @@ protected:
static
int
literal_size
(
ConstantPool
*
cp
)
{
Unimplemented
();
return
0
;}
static
int
literal_size
(
Klass
*
k
)
{
Unimplemented
();
return
0
;}
public:
void
dump_table
(
outputStream
*
st
,
const
char
*
table_name
);
private:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录