Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
5bc456a8
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5bc456a8
编写于
10月 18, 2010
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
4837564: (bf) Please make DirectByteBuffer performance enhancements
Reviewed-by: chegar
上级
dad4def2
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
27 addition
and
17 deletion
+27
-17
src/share/classes/java/nio/Direct-X-Buffer.java.template
src/share/classes/java/nio/Direct-X-Buffer.java.template
+4
-2
src/share/classes/sun/misc/VM.java
src/share/classes/sun/misc/VM.java
+16
-0
test/java/nio/Buffer/LimitDirectMemory.sh
test/java/nio/Buffer/LimitDirectMemory.sh
+7
-15
未找到文件。
src/share/classes/java/nio/Direct-X-Buffer.java.template
浏览文件 @
5bc456a8
...
@@ -29,6 +29,7 @@ package java.nio;
...
@@ -29,6 +29,7 @@ package java.nio;
import
sun
.
misc
.
Cleaner
;
import
sun
.
misc
.
Cleaner
;
import
sun
.
misc
.
Unsafe
;
import
sun
.
misc
.
Unsafe
;
import
sun
.
misc
.
VM
;
import
sun
.
nio
.
ch
.
DirectBuffer
;
import
sun
.
nio
.
ch
.
DirectBuffer
;
...
@@ -114,8 +115,9 @@ class Direct$Type$Buffer$RW$$BO$
...
@@ -114,8 +115,9 @@ class Direct$Type$Buffer$RW$$BO$
Direct
$
Type
$
Buffer
$
RW
$(
int
cap
)
{
//
package
-
private
Direct
$
Type
$
Buffer
$
RW
$(
int
cap
)
{
//
package
-
private
#
if
[
rw
]
#
if
[
rw
]
super
(-
1
,
0
,
cap
,
cap
,
false
);
super
(-
1
,
0
,
cap
,
cap
,
false
);
boolean
pa
=
VM
.
isDirectMemoryPageAligned
();
int
ps
=
Bits
.
pageSize
();
int
ps
=
Bits
.
pageSize
();
int
size
=
cap
+
ps
;
long
size
=
Math
.
max
(
1L
,
(
long
)
cap
+
(
pa
?
ps
:
0
))
;
Bits
.
reserveMemory
(
size
,
cap
);
Bits
.
reserveMemory
(
size
,
cap
);
long
base
=
0
;
long
base
=
0
;
...
@@ -126,7 +128,7 @@ class Direct$Type$Buffer$RW$$BO$
...
@@ -126,7 +128,7 @@ class Direct$Type$Buffer$RW$$BO$
throw
x
;
throw
x
;
}
}
unsafe
.
setMemory
(
base
,
size
,
(
byte
)
0
);
unsafe
.
setMemory
(
base
,
size
,
(
byte
)
0
);
if
(
base
%
ps
!= 0
) {
if
(
pa
&&
(
base
%
ps
!= 0)
) {
//
Round
up
to
page
boundary
//
Round
up
to
page
boundary
address
=
base
+
ps
-
(
base
&
(
ps
-
1
));
address
=
base
+
ps
-
(
base
&
(
ps
-
1
));
}
else
{
}
else
{
...
...
src/share/classes/sun/misc/VM.java
浏览文件 @
5bc456a8
...
@@ -178,6 +178,17 @@ public class VM {
...
@@ -178,6 +178,17 @@ public class VM {
return
directMemory
;
return
directMemory
;
}
}
// User-controllable flag that determines if direct buffers should be page
// aligned. The "-XX:+PageAlignDirectMemory" option can be used to force
// buffers, allocated by ByteBuffer.allocateDirect, to be page aligned.
private
static
boolean
pageAlignDirectMemory
;
// Returns {@code true} if the direct buffers should be page aligned. This
// variable is initialized by saveAndRemoveProperties.
public
static
boolean
isDirectMemoryPageAligned
()
{
return
pageAlignDirectMemory
;
}
// A user-settable boolean to determine whether ClassLoader.loadClass should
// A user-settable boolean to determine whether ClassLoader.loadClass should
// accept array syntax. This value may be changed during VM initialization
// accept array syntax. This value may be changed during VM initialization
// via the system property "sun.lang.ClassLoader.allowArraySyntax".
// via the system property "sun.lang.ClassLoader.allowArraySyntax".
...
@@ -252,6 +263,11 @@ public class VM {
...
@@ -252,6 +263,11 @@ public class VM {
}
}
}
}
// Check if direct buffers should be page aligned
s
=
(
String
)
props
.
remove
(
"sun.nio.PageAlignDirectMemory"
);
if
(
"true"
.
equals
(
s
))
pageAlignDirectMemory
=
true
;
// Set a boolean to determine whether ClassLoader.loadClass accepts
// Set a boolean to determine whether ClassLoader.loadClass accepts
// array syntax. This value is controlled by the system property
// array syntax. This value is controlled by the system property
// "sun.lang.ClassLoader.allowArraySyntax".
// "sun.lang.ClassLoader.allowArraySyntax".
...
...
test/java/nio/Buffer/LimitDirectMemory.sh
浏览文件 @
5bc456a8
...
@@ -30,18 +30,7 @@
...
@@ -30,18 +30,7 @@
# @build LimitDirectMemory
# @build LimitDirectMemory
# @run shell LimitDirectMemory.sh
# @run shell LimitDirectMemory.sh
# set platform-dependent variable
TMP1
=
tmp_
$$
OS
=
`
uname
-s
`
case
"
$OS
"
in
SunOS
|
Linux
)
TMP
=
/tmp
;;
Windows
*
)
TMP
=
"c:/temp"
;;
*
)
echo
"Unrecognized system!"
exit
1
;
;;
esac
TMP1
=
${
TMP
}
/tmp1_
$$
runTest
()
{
runTest
()
{
echo
"Testing:
$*
"
echo
"Testing:
$*
"
...
@@ -82,18 +71,21 @@ runTest -XX:MaxDirectMemorySize=65M -cp ${TESTCLASSES} \
...
@@ -82,18 +71,21 @@ runTest -XX:MaxDirectMemorySize=65M -cp ${TESTCLASSES} \
# Exactly the default amount of memory is available.
# Exactly the default amount of memory is available.
runTest
-cp
${
TESTCLASSES
}
LimitDirectMemory
false
10 1
runTest
-cp
${
TESTCLASSES
}
LimitDirectMemory
false
10 1
runTest
-cp
${
TESTCLASSES
}
LimitDirectMemory
false
0 DEFAULT
runTest
-
Xmx64m
-
cp
${
TESTCLASSES
}
LimitDirectMemory
false
0 DEFAULT
runTest
-cp
${
TESTCLASSES
}
LimitDirectMemory
true
0 DEFAULT+1
runTest
-
Xmx64m
-
cp
${
TESTCLASSES
}
LimitDirectMemory
true
0 DEFAULT+1
# We should be able to eliminate direct memory allocation entirely.
# We should be able to eliminate direct memory allocation entirely.
runTest
-XX
:MaxDirectMemorySize
=
0
-cp
${
TESTCLASSES
}
LimitDirectMemory
true
0 1
runTest
-XX
:MaxDirectMemorySize
=
0
-cp
${
TESTCLASSES
}
LimitDirectMemory
true
0 1
# Setting the system property should not work so we should be able to allocate
# Setting the system property should not work so we should be able to allocate
# the default amount.
# the default amount.
runTest
-Dsun
.nio.MaxDirectMemorySize
=
1K
-cp
${
TESTCLASSES
}
\
runTest
-Dsun
.nio.MaxDirectMemorySize
=
1K
-
Xmx64m
-
cp
${
TESTCLASSES
}
\
LimitDirectMemory
false
DEFAULT-1 DEFAULT/2
LimitDirectMemory
false
DEFAULT-1 DEFAULT/2
# Various bad values fail to launch the VM.
# Various bad values fail to launch the VM.
launchFail foo
launchFail foo
launchFail 10kmt
launchFail 10kmt
launchFail
-1
launchFail
-1
# Clean-up
rm
${
TMP1
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录