Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
9f800b6f
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看板
提交
9f800b6f
编写于
12月 14, 2018
作者:
R
roland
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8215265: C2: range check elimination may allow illegal out of bound access
Reviewed-by: thartmann, kvn
上级
e0adff21
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
116 addition
and
6 deletion
+116
-6
src/share/vm/opto/loopTransform.cpp
src/share/vm/opto/loopTransform.cpp
+15
-5
src/share/vm/opto/loopnode.hpp
src/share/vm/opto/loopnode.hpp
+1
-1
test/compiler/rangechecks/RangeCheckEliminationScaleNotOne.java
...ompiler/rangechecks/RangeCheckEliminationScaleNotOne.java
+100
-0
未找到文件。
src/share/vm/opto/loopTransform.cpp
浏览文件 @
9f800b6f
...
...
@@ -1537,13 +1537,20 @@ bool IdealLoopTree::dominates_backedge(Node* ctrl) {
//------------------------------adjust_limit-----------------------------------
// Helper function for add_constraint().
Node
*
PhaseIdealLoop
::
adjust_limit
(
int
stride_con
,
Node
*
scale
,
Node
*
offset
,
Node
*
rc_limit
,
Node
*
loop_limit
,
Node
*
pre_ctrl
)
{
Node
*
PhaseIdealLoop
::
adjust_limit
(
int
stride_con
,
Node
*
scale
,
Node
*
offset
,
Node
*
rc_limit
,
Node
*
loop_limit
,
Node
*
pre_ctrl
,
bool
round_up
)
{
// Compute "I :: (limit-offset)/scale"
Node
*
con
=
new
(
C
)
SubINode
(
rc_limit
,
offset
);
register_new_node
(
con
,
pre_ctrl
);
Node
*
X
=
new
(
C
)
DivINode
(
0
,
con
,
scale
);
register_new_node
(
X
,
pre_ctrl
);
// When the absolute value of scale is greater than one, the integer
// division may round limit down so add one to the limit.
if
(
round_up
)
{
X
=
new
(
C
)
AddINode
(
X
,
_igvn
.
intcon
(
1
));
register_new_node
(
X
,
pre_ctrl
);
}
// Adjust loop limit
loop_limit
=
(
stride_con
>
0
)
?
(
Node
*
)(
new
(
C
)
MinINode
(
loop_limit
,
X
))
...
...
@@ -1584,7 +1591,7 @@ void PhaseIdealLoop::add_constraint( int stride_con, int scale_con, Node *offset
// (upper_limit-offset) may overflow or underflow.
// But it is fine since main loop will either have
// less iterations or will be skipped in such case.
*
main_limit
=
adjust_limit
(
stride_con
,
scale
,
offset
,
upper_limit
,
*
main_limit
,
pre_ctrl
);
*
main_limit
=
adjust_limit
(
stride_con
,
scale
,
offset
,
upper_limit
,
*
main_limit
,
pre_ctrl
,
false
);
// The underflow limit: low_limit <= scale*I+offset.
// For pre-loop compute
...
...
@@ -1620,7 +1627,8 @@ void PhaseIdealLoop::add_constraint( int stride_con, int scale_con, Node *offset
// max(pre_limit, original_limit) is used in do_range_check().
}
// Pass (-stride) to indicate pre_loop_cond = NOT(main_loop_cond);
*
pre_limit
=
adjust_limit
((
-
stride_con
),
scale
,
offset
,
low_limit
,
*
pre_limit
,
pre_ctrl
);
*
pre_limit
=
adjust_limit
((
-
stride_con
),
scale
,
offset
,
low_limit
,
*
pre_limit
,
pre_ctrl
,
scale_con
>
1
&&
stride_con
>
0
);
}
else
{
// stride_con*scale_con < 0
// For negative stride*scale pre-loop checks for overflow and
...
...
@@ -1646,7 +1654,8 @@ void PhaseIdealLoop::add_constraint( int stride_con, int scale_con, Node *offset
Node
*
plus_one
=
new
(
C
)
AddINode
(
offset
,
one
);
register_new_node
(
plus_one
,
pre_ctrl
);
// Pass (-stride) to indicate pre_loop_cond = NOT(main_loop_cond);
*
pre_limit
=
adjust_limit
((
-
stride_con
),
scale
,
plus_one
,
upper_limit
,
*
pre_limit
,
pre_ctrl
);
*
pre_limit
=
adjust_limit
((
-
stride_con
),
scale
,
plus_one
,
upper_limit
,
*
pre_limit
,
pre_ctrl
,
scale_con
<
-
1
&&
stride_con
>
0
);
if
(
low_limit
->
get_int
()
==
-
max_jint
)
{
if
(
!
RangeLimitCheck
)
return
;
...
...
@@ -1681,7 +1690,8 @@ void PhaseIdealLoop::add_constraint( int stride_con, int scale_con, Node *offset
// I > (low_limit-(offset+1))/scale
// )
*
main_limit
=
adjust_limit
(
stride_con
,
scale
,
plus_one
,
low_limit
,
*
main_limit
,
pre_ctrl
);
*
main_limit
=
adjust_limit
(
stride_con
,
scale
,
plus_one
,
low_limit
,
*
main_limit
,
pre_ctrl
,
false
);
}
}
...
...
src/share/vm/opto/loopnode.hpp
浏览文件 @
9f800b6f
...
...
@@ -959,7 +959,7 @@ public:
// loop. Scale_con, offset and limit are all loop invariant.
void
add_constraint
(
int
stride_con
,
int
scale_con
,
Node
*
offset
,
Node
*
low_limit
,
Node
*
upper_limit
,
Node
*
pre_ctrl
,
Node
**
pre_limit
,
Node
**
main_limit
);
// Helper function for add_constraint().
Node
*
adjust_limit
(
int
stride_con
,
Node
*
scale
,
Node
*
offset
,
Node
*
rc_limit
,
Node
*
loop_limit
,
Node
*
pre_ctrl
);
Node
*
adjust_limit
(
int
stride_con
,
Node
*
scale
,
Node
*
offset
,
Node
*
rc_limit
,
Node
*
loop_limit
,
Node
*
pre_ctrl
,
bool
round_up
);
// Partially peel loop up through last_peel node.
bool
partial_peel
(
IdealLoopTree
*
loop
,
Node_List
&
old_new
);
...
...
test/compiler/rangechecks/RangeCheckEliminationScaleNotOne.java
0 → 100644
浏览文件 @
9f800b6f
/*
* Copyright (c) 2018, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8215265
* @summary C2: range check elimination may allow illegal out of bound access
*
* @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:-UseLoopPredicate RangeCheckEliminationScaleNotOne
*
*/
import
java.util.Arrays
;
public
class
RangeCheckEliminationScaleNotOne
{
public
static
void
main
(
String
[]
args
)
{
{
int
[]
array
=
new
int
[
199
];
boolean
[]
flags
=
new
boolean
[
100
];
Arrays
.
fill
(
flags
,
true
);
flags
[
0
]
=
false
;
flags
[
1
]
=
false
;
for
(
int
i
=
0
;
i
<
20_000
;
i
++)
{
test1
(
100
,
array
,
0
,
flags
);
}
boolean
ex
=
false
;
try
{
test1
(
100
,
array
,
-
5
,
flags
);
}
catch
(
ArrayIndexOutOfBoundsException
aie
)
{
ex
=
true
;
}
if
(!
ex
)
{
throw
new
RuntimeException
(
"no AIOOB exception"
);
}
}
{
int
[]
array
=
new
int
[
199
];
boolean
[]
flags
=
new
boolean
[
100
];
Arrays
.
fill
(
flags
,
true
);
flags
[
0
]
=
false
;
flags
[
1
]
=
false
;
for
(
int
i
=
0
;
i
<
20_000
;
i
++)
{
test2
(
100
,
array
,
198
,
flags
);
}
boolean
ex
=
false
;
try
{
test2
(
100
,
array
,
203
,
flags
);
}
catch
(
ArrayIndexOutOfBoundsException
aie
)
{
ex
=
true
;
}
if
(!
ex
)
{
throw
new
RuntimeException
(
"no AIOOB exception"
);
}
}
}
private
static
int
test1
(
int
stop
,
int
[]
array
,
int
offset
,
boolean
[]
flags
)
{
if
(
array
==
null
)
{}
int
res
=
0
;
for
(
int
i
=
0
;
i
<
stop
;
i
++)
{
if
(
flags
[
i
])
{
res
+=
array
[
2
*
i
+
offset
];
}
}
return
res
;
}
private
static
int
test2
(
int
stop
,
int
[]
array
,
int
offset
,
boolean
[]
flags
)
{
if
(
array
==
null
)
{}
int
res
=
0
;
for
(
int
i
=
0
;
i
<
stop
;
i
++)
{
if
(
flags
[
i
])
{
res
+=
array
[-
2
*
i
+
offset
];
}
}
return
res
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录