Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
ffed2ce6
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看板
提交
ffed2ce6
编写于
5月 15, 2012
作者:
M
mikael
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7158457: division by zero in adaptiveweightedaverage
Summary: Add ceiling to AdaptiveWeightedAverage Reviewed-by: ysr, iveresov
上级
d524aa32
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
24 addition
and
8 deletion
+24
-8
src/share/vm/gc_implementation/shared/gcUtil.cpp
src/share/vm/gc_implementation/shared/gcUtil.cpp
+9
-5
src/share/vm/gc_implementation/shared/gcUtil.hpp
src/share/vm/gc_implementation/shared/gcUtil.hpp
+15
-3
未找到文件。
src/share/vm/gc_implementation/shared/gcUtil.cpp
浏览文件 @
ffed2ce6
...
...
@@ -31,9 +31,15 @@ float AdaptiveWeightedAverage::compute_adaptive_average(float new_sample,
float
average
)
{
// We smooth the samples by not using weight() directly until we've
// had enough data to make it meaningful. We'd like the first weight
// used to be 1, the second to be 1/2, etc until we have 100/weight
// samples.
unsigned
count_weight
=
100
/
count
();
// used to be 1, the second to be 1/2, etc until we have
// OLD_THRESHOLD/weight samples.
unsigned
count_weight
=
0
;
// Avoid division by zero if the counter wraps (7158457)
if
(
!
is_old
())
{
count_weight
=
OLD_THRESHOLD
/
count
();
}
unsigned
adaptive_weight
=
(
MAX2
(
weight
(),
count_weight
));
float
new_avg
=
exp_avg
(
average
,
new_sample
,
adaptive_weight
);
...
...
@@ -43,8 +49,6 @@ float AdaptiveWeightedAverage::compute_adaptive_average(float new_sample,
void
AdaptiveWeightedAverage
::
sample
(
float
new_sample
)
{
increment_count
();
assert
(
count
()
!=
0
,
"Wraparound -- history would be incorrectly discarded"
);
// Compute the new weighted average
float
new_avg
=
compute_adaptive_average
(
new_sample
,
average
());
...
...
src/share/vm/gc_implementation/shared/gcUtil.hpp
浏览文件 @
ffed2ce6
...
...
@@ -50,11 +50,20 @@ class AdaptiveWeightedAverage : public CHeapObj {
unsigned
_weight
;
// The weight used to smooth the averages
// A higher weight favors the most
// recent data.
bool
_is_old
;
// Has enough historical data
const
static
unsigned
OLD_THRESHOLD
=
100
;
protected:
float
_last_sample
;
// The last value sampled.
void
increment_count
()
{
_sample_count
++
;
}
void
increment_count
()
{
_sample_count
++
;
if
(
!
_is_old
&&
_sample_count
>
OLD_THRESHOLD
)
{
_is_old
=
true
;
}
}
void
set_average
(
float
avg
)
{
_average
=
avg
;
}
// Helper function, computes an adaptive weighted average
...
...
@@ -64,13 +73,15 @@ class AdaptiveWeightedAverage : public CHeapObj {
public:
// Input weight must be between 0 and 100
AdaptiveWeightedAverage
(
unsigned
weight
,
float
avg
=
0.0
)
:
_average
(
avg
),
_sample_count
(
0
),
_weight
(
weight
),
_last_sample
(
0.0
)
{
_average
(
avg
),
_sample_count
(
0
),
_weight
(
weight
),
_last_sample
(
0.0
),
_is_old
(
false
)
{
}
void
clear
()
{
_average
=
0
;
_sample_count
=
0
;
_last_sample
=
0
;
_is_old
=
false
;
}
// Useful for modifying static structures after startup.
...
...
@@ -85,6 +96,7 @@ class AdaptiveWeightedAverage : public CHeapObj {
unsigned
weight
()
const
{
return
_weight
;
}
unsigned
count
()
const
{
return
_sample_count
;
}
float
last_sample
()
const
{
return
_last_sample
;
}
bool
is_old
()
const
{
return
_is_old
;
}
// Update data with a new sample.
void
sample
(
float
new_sample
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录