Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
f0b94cb4
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看板
提交
f0b94cb4
编写于
1月 18, 2019
作者:
S
shade
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8217315: Proper units should print more significant digits
Reviewed-by: stuefe, tschatzl
上级
21295a8f
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
76 addition
and
6 deletion
+76
-6
src/share/vm/prims/jni.cpp
src/share/vm/prims/jni.cpp
+1
-0
src/share/vm/utilities/globalDefinitions.cpp
src/share/vm/utilities/globalDefinitions.cpp
+63
-0
src/share/vm/utilities/globalDefinitions.hpp
src/share/vm/utilities/globalDefinitions.hpp
+12
-6
未找到文件。
src/share/vm/prims/jni.cpp
浏览文件 @
f0b94cb4
...
...
@@ -5121,6 +5121,7 @@ void execute_internal_vm_tests() {
run_unit_test
(
TestMetachunk_test
());
run_unit_test
(
TestVirtualSpaceNode_test
());
run_unit_test
(
GlobalDefinitions
::
test_globals
());
run_unit_test
(
GlobalDefinitions
::
test_proper_unit
());
run_unit_test
(
GCTimerAllTest
::
all
());
run_unit_test
(
arrayOopDesc
::
test_max_array_length
());
run_unit_test
(
CollectedHeap
::
test_is_in
());
...
...
src/share/vm/utilities/globalDefinitions.cpp
浏览文件 @
f0b94cb4
...
...
@@ -384,4 +384,67 @@ void GlobalDefinitions::test_globals() {
}
}
#define EXPECT_EQ(expected, actual) \
assert(expected == actual, "Test failed");
#define EXPECT_STREQ(expected, actual) \
assert(strcmp(expected, actual) == 0, "Test failed");
void
GlobalDefinitions
::
test_proper_unit
()
{
EXPECT_EQ
(
0u
,
byte_size_in_proper_unit
(
0u
));
EXPECT_STREQ
(
"B"
,
proper_unit_for_byte_size
(
0u
));
EXPECT_EQ
(
1u
,
byte_size_in_proper_unit
(
1u
));
EXPECT_STREQ
(
"B"
,
proper_unit_for_byte_size
(
1u
));
EXPECT_EQ
(
1023u
,
byte_size_in_proper_unit
(
K
-
1
));
EXPECT_STREQ
(
"B"
,
proper_unit_for_byte_size
(
K
-
1
));
EXPECT_EQ
(
1024u
,
byte_size_in_proper_unit
(
K
));
EXPECT_STREQ
(
"B"
,
proper_unit_for_byte_size
(
K
));
EXPECT_EQ
(
1025u
,
byte_size_in_proper_unit
(
K
+
1
));
EXPECT_STREQ
(
"B"
,
proper_unit_for_byte_size
(
K
+
1
));
EXPECT_EQ
(
51200u
,
byte_size_in_proper_unit
(
50
*
K
));
EXPECT_STREQ
(
"B"
,
proper_unit_for_byte_size
(
50
*
K
));
EXPECT_EQ
(
1023u
,
byte_size_in_proper_unit
(
M
-
1
));
EXPECT_STREQ
(
"K"
,
proper_unit_for_byte_size
(
M
-
1
));
EXPECT_EQ
(
1024u
,
byte_size_in_proper_unit
(
M
));
EXPECT_STREQ
(
"K"
,
proper_unit_for_byte_size
(
M
));
EXPECT_EQ
(
1024u
,
byte_size_in_proper_unit
(
M
+
1
));
EXPECT_STREQ
(
"K"
,
proper_unit_for_byte_size
(
M
+
1
));
EXPECT_EQ
(
1025u
,
byte_size_in_proper_unit
(
M
+
K
));
EXPECT_STREQ
(
"K"
,
proper_unit_for_byte_size
(
M
+
K
));
EXPECT_EQ
(
51200u
,
byte_size_in_proper_unit
(
50
*
M
));
EXPECT_STREQ
(
"K"
,
proper_unit_for_byte_size
(
50
*
M
));
#ifdef _LP64
EXPECT_EQ
(
1023u
,
byte_size_in_proper_unit
(
G
-
1
));
EXPECT_STREQ
(
"M"
,
proper_unit_for_byte_size
(
G
-
1
));
EXPECT_EQ
(
1024u
,
byte_size_in_proper_unit
(
G
));
EXPECT_STREQ
(
"M"
,
proper_unit_for_byte_size
(
G
));
EXPECT_EQ
(
1024u
,
byte_size_in_proper_unit
(
G
+
1
));
EXPECT_STREQ
(
"M"
,
proper_unit_for_byte_size
(
G
+
1
));
EXPECT_EQ
(
1024u
,
byte_size_in_proper_unit
(
G
+
K
));
EXPECT_STREQ
(
"M"
,
proper_unit_for_byte_size
(
G
+
K
));
EXPECT_EQ
(
1025u
,
byte_size_in_proper_unit
(
G
+
M
));
EXPECT_STREQ
(
"M"
,
proper_unit_for_byte_size
(
G
+
M
));
EXPECT_EQ
(
51200u
,
byte_size_in_proper_unit
(
50
*
G
));
EXPECT_STREQ
(
"M"
,
proper_unit_for_byte_size
(
50
*
G
));
#endif
}
#undef EXPECT_EQ
#undef EXPECT_STREQ
#endif // PRODUCT
src/share/vm/utilities/globalDefinitions.hpp
浏览文件 @
f0b94cb4
...
...
@@ -211,15 +211,20 @@ const int NANOUNITS = 1000000000; // nano units per base unit
const
jlong
NANOSECS_PER_SEC
=
CONST64
(
1000000000
);
const
jint
NANOSECS_PER_MILLISEC
=
1000000
;
// Proper units routines try to maintain at least three significant digits.
// In worst case, it would print five significant digits with lower prefix.
// G is close to MAX_SIZE on 32-bit platforms, so its product can easily overflow,
// and therefore we need to be careful.
inline
const
char
*
proper_unit_for_byte_size
(
size_t
s
)
{
#ifdef _LP64
if
(
s
>=
10
*
G
)
{
if
(
s
>=
10
0
*
G
)
{
return
"G"
;
}
#endif
if
(
s
>=
10
*
M
)
{
if
(
s
>=
10
0
*
M
)
{
return
"M"
;
}
else
if
(
s
>=
10
*
K
)
{
}
else
if
(
s
>=
10
0
*
K
)
{
return
"K"
;
}
else
{
return
"B"
;
...
...
@@ -229,13 +234,13 @@ inline const char* proper_unit_for_byte_size(size_t s) {
template
<
class
T
>
inline
T
byte_size_in_proper_unit
(
T
s
)
{
#ifdef _LP64
if
(
s
>=
10
*
G
)
{
if
(
s
>=
10
0
*
G
)
{
return
(
T
)(
s
/
G
);
}
#endif
if
(
s
>=
10
*
M
)
{
if
(
s
>=
10
0
*
M
)
{
return
(
T
)(
s
/
M
);
}
else
if
(
s
>=
10
*
K
)
{
}
else
if
(
s
>=
10
0
*
K
)
{
return
(
T
)(
s
/
K
);
}
else
{
return
s
;
...
...
@@ -1486,6 +1491,7 @@ static inline void* dereference_vptr(const void* addr) {
class
GlobalDefinitions
{
public:
static
void
test_globals
();
static
void
test_proper_unit
();
};
#endif // PRODUCT
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录