Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
0bb98b6c
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看板
提交
0bb98b6c
编写于
10月 22, 2018
作者:
D
dbuck
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8155635: C2: Mixed unsafe accesses break alias analysis
Reviewed-by: kvn
上级
107f519f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
112 addition
and
41 deletion
+112
-41
src/share/vm/opto/compile.cpp
src/share/vm/opto/compile.cpp
+17
-10
src/share/vm/opto/library_call.cpp
src/share/vm/opto/library_call.cpp
+9
-30
src/share/vm/opto/type.cpp
src/share/vm/opto/type.cpp
+8
-1
src/share/vm/opto/type.hpp
src/share/vm/opto/type.hpp
+2
-0
test/compiler/unsafe/MixedUnsafeStoreObject.java
test/compiler/unsafe/MixedUnsafeStoreObject.java
+76
-0
未找到文件。
src/share/vm/opto/compile.cpp
浏览文件 @
0bb98b6c
...
...
@@ -1680,16 +1680,23 @@ Compile::AliasType* Compile::find_alias_type(const TypePtr* adr_type, bool no_cr
const
TypePtr
*
flat
=
flatten_alias_type
(
adr_type
);
#ifdef ASSERT
assert
(
flat
==
flatten_alias_type
(
flat
),
"idempotent"
);
assert
(
flat
!=
TypePtr
::
BOTTOM
,
"cannot alias-analyze an untyped ptr"
);
if
(
flat
->
isa_oopptr
()
&&
!
flat
->
isa_klassptr
())
{
const
TypeOopPtr
*
foop
=
flat
->
is_oopptr
();
// Scalarizable allocations have exact klass always.
bool
exact
=
!
foop
->
klass_is_exact
()
||
foop
->
is_known_instance
();
const
TypePtr
*
xoop
=
foop
->
cast_to_exactness
(
exact
)
->
is_ptr
();
assert
(
foop
==
flatten_alias_type
(
xoop
),
"exactness must not affect alias type"
);
}
assert
(
flat
==
flatten_alias_type
(
flat
),
"exact bit doesn't matter"
);
{
ResourceMark
rm
;
assert
(
flat
==
flatten_alias_type
(
flat
),
err_msg
(
"not idempotent: adr_type = %s; flat = %s => %s"
,
Type
::
str
(
adr_type
),
Type
::
str
(
flat
),
Type
::
str
(
flatten_alias_type
(
flat
))));
assert
(
flat
!=
TypePtr
::
BOTTOM
,
err_msg
(
"cannot alias-analyze an untyped ptr: adr_type = %s"
,
Type
::
str
(
adr_type
)));
if
(
flat
->
isa_oopptr
()
&&
!
flat
->
isa_klassptr
())
{
const
TypeOopPtr
*
foop
=
flat
->
is_oopptr
();
// Scalarizable allocations have exact klass always.
bool
exact
=
!
foop
->
klass_is_exact
()
||
foop
->
is_known_instance
();
const
TypePtr
*
xoop
=
foop
->
cast_to_exactness
(
exact
)
->
is_ptr
();
assert
(
foop
==
flatten_alias_type
(
xoop
),
err_msg
(
"exactness must not affect alias type: foop = %s; xoop = %s"
,
Type
::
str
(
foop
),
Type
::
str
(
xoop
)));
}
}
#endif
int
idx
=
AliasIdxTop
;
...
...
src/share/vm/opto/library_call.cpp
浏览文件 @
0bb98b6c
/*
* Copyright (c) 1999, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 201
8
, Oracle and/or its affiliates. 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
...
...
@@ -2544,8 +2544,8 @@ const TypeOopPtr* LibraryCallKit::sharpen_unsafe_type(Compile::AliasType* alias_
#ifndef PRODUCT
if
(
C
->
print_intrinsics
()
||
C
->
print_inlining
())
{
tty
->
print
(
" from base type:
"
);
adr_type
->
dump
();
tty
->
print
(
" sharpened value: "
);
tjp
->
dump
();
tty
->
print
(
" from base type:
"
);
adr_type
->
dump
();
tty
->
cr
();
tty
->
print
(
" sharpened value: "
);
tjp
->
dump
();
tty
->
cr
();
}
#endif
// Sharpen the value type.
...
...
@@ -2632,6 +2632,9 @@ bool LibraryCallKit::inline_unsafe_access(bool is_native_ptr, bool is_store, Bas
// Can base be NULL? Otherwise, always on-heap access.
bool
can_access_non_heap
=
TypePtr
::
NULL_PTR
->
higher_equal
(
_gvn
.
type
(
heap_base_oop
));
if
(
can_access_non_heap
&&
type
==
T_OBJECT
)
{
return
false
;
// off-heap oop accesses are not supported
}
const
TypePtr
*
adr_type
=
_gvn
.
type
(
adr
)
->
isa_ptr
();
...
...
@@ -2776,34 +2779,10 @@ bool LibraryCallKit::inline_unsafe_access(bool is_native_ptr, bool is_store, Bas
}
MemNode
::
MemOrd
mo
=
is_volatile
?
MemNode
::
release
:
MemNode
::
unordered
;
if
(
type
!
=
T_OBJECT
)
{
(
void
)
store_
to_memory
(
control
(),
adr
,
val
,
type
,
adr_type
,
mo
,
is_volatile
,
unaligned
,
mismatched
);
if
(
type
=
=
T_OBJECT
)
{
(
void
)
store_
oop_to_unknown
(
control
(),
heap_base_oop
,
adr
,
adr_type
,
val
,
type
,
mo
,
mismatched
);
}
else
{
// Possibly an oop being stored to Java heap or native memory
if
(
!
can_access_non_heap
)
{
// oop to Java heap.
(
void
)
store_oop_to_unknown
(
control
(),
heap_base_oop
,
adr
,
adr_type
,
val
,
type
,
mo
,
mismatched
);
}
else
{
// We can't tell at compile time if we are storing in the Java heap or outside
// of it. So we need to emit code to conditionally do the proper type of
// store.
IdealKit
ideal
(
this
);
#define __ ideal.
// QQQ who knows what probability is here??
__
if_then
(
heap_base_oop
,
BoolTest
::
ne
,
null
(),
PROB_UNLIKELY
(
0.999
));
{
// Sync IdealKit and graphKit.
sync_kit
(
ideal
);
Node
*
st
=
store_oop_to_unknown
(
control
(),
heap_base_oop
,
adr
,
adr_type
,
val
,
type
,
mo
,
mismatched
);
// Update IdealKit memory.
__
sync_kit
(
this
);
}
__
else_
();
{
__
store
(
__
ctrl
(),
adr
,
val
,
type
,
alias_type
->
index
(),
mo
,
is_volatile
,
mismatched
);
}
__
end_if
();
// Final sync IdealKit and GraphKit.
final_sync
(
ideal
);
#undef __
}
(
void
)
store_to_memory
(
control
(),
adr
,
val
,
type
,
adr_type
,
mo
,
is_volatile
,
unaligned
,
mismatched
);
}
}
...
...
src/share/vm/opto/type.cpp
浏览文件 @
0bb98b6c
/*
* Copyright (c) 1997, 201
7
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
8
, Oracle and/or its affiliates. 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
...
...
@@ -885,6 +885,13 @@ void Type::dump_on(outputStream *st) const {
st
->
print
(
" [narrowklass]"
);
}
}
//-----------------------------------------------------------------------------
const
char
*
Type
::
str
(
const
Type
*
t
)
{
stringStream
ss
;
t
->
dump_on
(
&
ss
);
return
ss
.
as_string
();
}
#endif
//------------------------------singleton--------------------------------------
...
...
src/share/vm/opto/type.hpp
浏览文件 @
0bb98b6c
...
...
@@ -358,6 +358,8 @@ public:
}
virtual
void
dump2
(
Dict
&
d
,
uint
depth
,
outputStream
*
st
)
const
;
static
void
dump_stats
();
static
const
char
*
str
(
const
Type
*
t
);
#endif
void
typerr
(
const
Type
*
t
)
const
;
// Mixing types error
...
...
test/compiler/unsafe/MixedUnsafeStoreObject.java
0 → 100644
浏览文件 @
0bb98b6c
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. 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 8155635
* @library /testlibrary
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -Xbatch -XX:-TieredCompilation compiler.unsafe.MixedUnsafeStoreObject
* @run main/othervm -Xbatch compiler.unsafe.MixedUnsafeStoreObject
* @comment Testcase currently only known to reproduce when run with -XX:+UseG1GC.
*/
package
compiler.unsafe
;
import
sun.misc.Unsafe
;
import
com.oracle.java.testlibrary.Utils
;
public
class
MixedUnsafeStoreObject
{
static
final
Unsafe
UNSAFE
=
Utils
.
getUnsafe
();
static
final
long
F_OFFSET
;
static
{
try
{
F_OFFSET
=
UNSAFE
.
objectFieldOffset
(
T
.
class
.
getDeclaredField
(
"f"
));
}
catch
(
Exception
e
)
{
throw
new
Error
(
e
);
}
}
static
class
T
{
Object
f
;
}
public
static
void
testFieldInstanceObject
(
Object
t
)
{
for
(
int
c
=
0
;
c
<
20000
;
c
++)
{
// trigger OSR compilation
// java/lang/Object+12 *
// _base = InstPtr, _ptr = BotPTR, _field = NULL, mismatched = true
UNSAFE
.
putObject
(
t
,
F_OFFSET
,
"foo"
);
}
}
public
static
void
testFieldInstanceT
(
T
t
)
{
for
(
int
c
=
0
;
c
<
20000
;
c
++)
{
// trigger OSR compilation
// ...$T+12 *
// _base = InstPtr, _ptr = BotPTR, _field = T.f, mismatched = false
UNSAFE
.
putObject
(
t
,
F_OFFSET
,
"foo"
);
}
}
public
static
void
main
(
String
[]
args
)
{
testFieldInstanceObject
(
new
T
());
testFieldInstanceT
(
new
T
());
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录