Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
e32a28a5
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e32a28a5
编写于
5月 21, 2013
作者:
D
dholmes
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
dc51648e
ab474abd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
18 deletion
+22
-18
src/share/vm/prims/whitebox.cpp
src/share/vm/prims/whitebox.cpp
+14
-3
test/runtime/memory/ReserveMemory.java
test/runtime/memory/ReserveMemory.java
+7
-14
test/testlibrary/whitebox/sun/hotspot/WhiteBox.java
test/testlibrary/whitebox/sun/hotspot/WhiteBox.java
+1
-1
未找到文件。
src/share/vm/prims/whitebox.cpp
浏览文件 @
e32a28a5
...
...
@@ -37,6 +37,7 @@
#include "runtime/os.hpp"
#include "utilities/debug.hpp"
#include "utilities/macros.hpp"
#include "utilities/exceptions.hpp"
#if INCLUDE_ALL_GCS
#include "gc_implementation/g1/concurrentMark.hpp"
...
...
@@ -330,8 +331,18 @@ WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o))
WB_END
WB_ENTRY
(
jlong
,
WB_ReserveMemory
(
JNIEnv
*
env
,
jobject
o
,
jlong
size
))
return
(
jlong
)
os
::
reserve_memory
(
size
,
NULL
,
0
);
WB_ENTRY
(
void
,
WB_ReadReservedMemory
(
JNIEnv
*
env
,
jobject
o
))
// static+volatile in order to force the read to happen
// (not be eliminated by the compiler)
static
char
c
;
static
volatile
char
*
p
;
p
=
os
::
reserve_memory
(
os
::
vm_allocation_granularity
(),
NULL
,
0
);
if
(
p
==
NULL
)
{
THROW_MSG
(
vmSymbols
::
java_lang_OutOfMemoryError
(),
"Failed to reserve memory"
);
}
c
=
*
p
;
WB_END
//Some convenience methods to deal with objects from java
...
...
@@ -437,7 +448,7 @@ static JNINativeMethod methods[] = {
{
CC
"isInStringTable"
,
CC
"(Ljava/lang/String;)Z"
,
(
void
*
)
&
WB_IsInStringTable
},
{
CC
"fullGC"
,
CC
"()V"
,
(
void
*
)
&
WB_FullGC
},
{
CC
"re
serveMemory"
,
CC
"(J)J"
,
(
void
*
)
&
WB_Reserve
Memory
},
{
CC
"re
adReservedMemory"
,
CC
"()V"
,
(
void
*
)
&
WB_ReadReserved
Memory
},
};
#undef CC
...
...
test/runtime/memory/ReserveMemory.java
浏览文件 @
e32a28a5
...
...
@@ -34,29 +34,20 @@
import
com.oracle.java.testlibrary.*
;
import
java.lang.reflect.Field
;
import
sun.hotspot.WhiteBox
;
import
sun.misc.Unsafe
;
public
class
ReserveMemory
{
private
static
Unsafe
getUnsafe
()
throws
Exception
{
Field
f
=
Unsafe
.
class
.
getDeclaredField
(
"theUnsafe"
);
f
.
setAccessible
(
true
);
return
(
Unsafe
)
f
.
get
(
null
);
}
private
static
boolean
isWindows
()
{
return
System
.
getProperty
(
"os.name"
).
toLowerCase
().
startsWith
(
"win"
);
}
private
static
boolean
isOsx
()
{
return
System
.
getProperty
(
"os.name"
).
toLowerCase
().
startsWith
(
"mac"
);
}
public
static
void
main
(
String
args
[])
throws
Exception
{
if
(
args
.
length
>
0
)
{
long
address
=
WhiteBox
.
getWhiteBox
().
reserveMemory
(
4096
);
System
.
out
.
println
(
"Reserved memory at address: 0x"
+
Long
.
toHexString
(
address
));
System
.
out
.
println
(
"Will now read from the address, expecting a crash!"
);
int
x
=
getUnsafe
().
getInt
(
address
);
WhiteBox
.
getWhiteBox
().
readReservedMemory
();
throw
new
Exception
(
"Read of reserved/uncommitted memory unexpectedly succeeded, expected crash!"
);
}
...
...
@@ -71,6 +62,8 @@ public class ReserveMemory {
OutputAnalyzer
output
=
new
OutputAnalyzer
(
pb
.
start
());
if
(
isWindows
())
{
output
.
shouldContain
(
"EXCEPTION_ACCESS_VIOLATION"
);
}
else
if
(
isOsx
())
{
output
.
shouldContain
(
"SIGBUS"
);
}
else
{
output
.
shouldContain
(
"SIGSEGV"
);
}
...
...
test/testlibrary/whitebox/sun/hotspot/WhiteBox.java
浏览文件 @
e32a28a5
...
...
@@ -115,7 +115,7 @@ public class WhiteBox {
public
native
boolean
isInStringTable
(
String
str
);
// Memory
public
native
long
reserveMemory
(
long
size
);
public
native
void
readReservedMemory
(
);
// force Full GC
public
native
void
fullGC
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录