Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
4df056de
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看板
提交
4df056de
编写于
4月 30, 2013
作者:
S
sla
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
13ca7af1
5ef40fda
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
126 addition
and
45 deletion
+126
-45
src/os/bsd/vm/os_bsd.cpp
src/os/bsd/vm/os_bsd.cpp
+4
-3
src/os/linux/vm/os_linux.cpp
src/os/linux/vm/os_linux.cpp
+4
-3
src/share/vm/classfile/classFileParser.cpp
src/share/vm/classfile/classFileParser.cpp
+4
-22
src/share/vm/classfile/javaClasses.cpp
src/share/vm/classfile/javaClasses.cpp
+8
-4
src/share/vm/classfile/javaClasses.hpp
src/share/vm/classfile/javaClasses.hpp
+1
-1
src/share/vm/classfile/symbolTable.cpp
src/share/vm/classfile/symbolTable.cpp
+1
-1
src/share/vm/memory/allocation.hpp
src/share/vm/memory/allocation.hpp
+3
-0
src/share/vm/oops/oop.cpp
src/share/vm/oops/oop.cpp
+10
-4
src/share/vm/prims/whitebox.cpp
src/share/vm/prims/whitebox.cpp
+10
-7
test/runtime/memory/ReserveMemory.java
test/runtime/memory/ReserveMemory.java
+78
-0
test/testlibrary/whitebox/sun/hotspot/WhiteBox.java
test/testlibrary/whitebox/sun/hotspot/WhiteBox.java
+3
-0
未找到文件。
src/os/bsd/vm/os_bsd.cpp
浏览文件 @
4df056de
...
...
@@ -2080,9 +2080,10 @@ static char* anon_mmap(char* requested_addr, size_t bytes, bool fixed) {
flags
|=
MAP_FIXED
;
}
// Map uncommitted pages PROT_READ and PROT_WRITE, change access
// to PROT_EXEC if executable when we commit the page.
addr
=
(
char
*
)
::
mmap
(
requested_addr
,
bytes
,
PROT_READ
|
PROT_WRITE
,
// Map reserved/uncommitted pages PROT_NONE so we fail early if we
// touch an uncommitted page. Otherwise, the read/write might
// succeed if we have enough swap space to back the physical page.
addr
=
(
char
*
)
::
mmap
(
requested_addr
,
bytes
,
PROT_NONE
,
flags
,
-
1
,
0
);
if
(
addr
!=
MAP_FAILED
)
{
...
...
src/os/linux/vm/os_linux.cpp
浏览文件 @
4df056de
...
...
@@ -2906,9 +2906,10 @@ static char* anon_mmap(char* requested_addr, size_t bytes, bool fixed) {
flags
|=
MAP_FIXED
;
}
// Map uncommitted pages PROT_READ and PROT_WRITE, change access
// to PROT_EXEC if executable when we commit the page.
addr
=
(
char
*
)
::
mmap
(
requested_addr
,
bytes
,
PROT_READ
|
PROT_WRITE
,
// Map reserved/uncommitted pages PROT_NONE so we fail early if we
// touch an uncommitted page. Otherwise, the read/write might
// succeed if we have enough swap space to back the physical page.
addr
=
(
char
*
)
::
mmap
(
requested_addr
,
bytes
,
PROT_NONE
,
flags
,
-
1
,
0
);
if
(
addr
!=
MAP_FAILED
)
{
...
...
src/share/vm/classfile/classFileParser.cpp
浏览文件 @
4df056de
...
...
@@ -2027,7 +2027,6 @@ methodHandle ClassFileParser::parse_method(bool is_interface,
u2
method_parameters_length
=
0
;
u1
*
method_parameters_data
=
NULL
;
bool
method_parameters_seen
=
false
;
bool
method_parameters_four_byte_flags
;
bool
parsed_code_attribute
=
false
;
bool
parsed_checked_exceptions_attribute
=
false
;
bool
parsed_stackmap_attribute
=
false
;
...
...
@@ -2241,26 +2240,14 @@ methodHandle ClassFileParser::parse_method(bool is_interface,
}
method_parameters_seen
=
true
;
method_parameters_length
=
cfs
->
get_u1_fast
();
// Track the actual size (note: this is written for clarity; a
// decent compiler will CSE and constant-fold this into a single
// expression)
// Use the attribute length to figure out the size of flags
if
(
method_attribute_length
==
(
method_parameters_length
*
6u
)
+
1u
)
{
method_parameters_four_byte_flags
=
true
;
}
else
if
(
method_attribute_length
==
(
method_parameters_length
*
4u
)
+
1u
)
{
method_parameters_four_byte_flags
=
false
;
}
else
{
if
(
method_attribute_length
!=
(
method_parameters_length
*
4u
)
+
1u
)
{
classfile_parse_error
(
"Invalid MethodParameters method attribute length %u in class file"
,
method_attribute_length
,
CHECK_
(
nullHandle
));
}
method_parameters_data
=
cfs
->
get_u1_buffer
();
cfs
->
skip_u2_fast
(
method_parameters_length
);
if
(
method_parameters_four_byte_flags
)
{
cfs
->
skip_u4_fast
(
method_parameters_length
);
}
else
{
cfs
->
skip_u2_fast
(
method_parameters_length
);
}
// ignore this attribute if it cannot be reflected
if
(
!
SystemDictionary
::
Parameter_klass_loaded
())
method_parameters_length
=
0
;
...
...
@@ -2423,15 +2410,10 @@ methodHandle ClassFileParser::parse_method(bool is_interface,
for
(
int
i
=
0
;
i
<
method_parameters_length
;
i
++
)
{
elem
[
i
].
name_cp_index
=
Bytes
::
get_Java_u2
(
method_parameters_data
);
method_parameters_data
+=
2
;
if
(
method_parameters_four_byte_flags
)
{
elem
[
i
].
flags
=
Bytes
::
get_Java_u4
(
method_parameters_data
);
method_parameters_data
+=
4
;
}
else
{
elem
[
i
].
flags
=
Bytes
::
get_Java_u2
(
method_parameters_data
);
method_parameters_data
+=
2
;
}
}
}
// Copy checked exceptions
if
(
checked_exceptions_length
>
0
)
{
...
...
src/share/vm/classfile/javaClasses.cpp
浏览文件 @
4df056de
...
...
@@ -315,15 +315,19 @@ Handle java_lang_String::char_converter(Handle java_string, jchar from_char, jch
return
string
;
}
jchar
*
java_lang_String
::
as_unicode_string
(
oop
java_string
,
int
&
length
)
{
jchar
*
java_lang_String
::
as_unicode_string
(
oop
java_string
,
int
&
length
,
TRAPS
)
{
typeArrayOop
value
=
java_lang_String
::
value
(
java_string
);
int
offset
=
java_lang_String
::
offset
(
java_string
);
length
=
java_lang_String
::
length
(
java_string
);
jchar
*
result
=
NEW_RESOURCE_ARRAY
(
jchar
,
length
);
jchar
*
result
=
NEW_RESOURCE_ARRAY_RETURN_NULL
(
jchar
,
length
);
if
(
result
!=
NULL
)
{
for
(
int
index
=
0
;
index
<
length
;
index
++
)
{
result
[
index
]
=
value
->
char_at
(
index
+
offset
);
}
}
else
{
THROW_MSG_0
(
vmSymbols
::
java_lang_OutOfMemoryError
(),
"could not allocate Unicode string"
);
}
return
result
;
}
...
...
src/share/vm/classfile/javaClasses.hpp
浏览文件 @
4df056de
...
...
@@ -153,7 +153,7 @@ class java_lang_String : AllStatic {
static
char
*
as_utf8_string
(
oop
java_string
,
char
*
buf
,
int
buflen
);
static
char
*
as_utf8_string
(
oop
java_string
,
int
start
,
int
len
);
static
char
*
as_platform_dependent_str
(
Handle
java_string
,
TRAPS
);
static
jchar
*
as_unicode_string
(
oop
java_string
,
int
&
length
);
static
jchar
*
as_unicode_string
(
oop
java_string
,
int
&
length
,
TRAPS
);
// produce an ascii string with all other values quoted using \u####
static
char
*
as_quoted_ascii
(
oop
java_string
);
...
...
src/share/vm/classfile/symbolTable.cpp
浏览文件 @
4df056de
...
...
@@ -735,7 +735,7 @@ oop StringTable::intern(oop string, TRAPS)
ResourceMark
rm
(
THREAD
);
int
length
;
Handle
h_string
(
THREAD
,
string
);
jchar
*
chars
=
java_lang_String
::
as_unicode_string
(
string
,
length
);
jchar
*
chars
=
java_lang_String
::
as_unicode_string
(
string
,
length
,
CHECK_NULL
);
oop
result
=
intern
(
h_string
,
chars
,
length
,
CHECK_NULL
);
return
result
;
}
...
...
src/share/vm/memory/allocation.hpp
浏览文件 @
4df056de
...
...
@@ -539,6 +539,9 @@ class ResourceObj ALLOCATION_SUPER_CLASS_SPEC {
#define NEW_RESOURCE_ARRAY(type, size)\
(type*) resource_allocate_bytes((size) * sizeof(type))
#define NEW_RESOURCE_ARRAY_RETURN_NULL(type, size)\
(type*) resource_allocate_bytes((size) * sizeof(type), AllocFailStrategy::RETURN_NULL)
#define NEW_RESOURCE_ARRAY_IN_THREAD(thread, type, size)\
(type*) resource_allocate_bytes(thread, (size) * sizeof(type))
...
...
src/share/vm/oops/oop.cpp
浏览文件 @
4df056de
/*
* Copyright (c) 1997, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
3
, 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
...
...
@@ -103,11 +103,17 @@ intptr_t oopDesc::slow_identity_hash() {
// When String table needs to rehash
unsigned
int
oopDesc
::
new_hash
(
jint
seed
)
{
EXCEPTION_MARK
;
ResourceMark
rm
;
int
length
;
jchar
*
chars
=
java_lang_String
::
as_unicode_string
(
this
,
length
);
jchar
*
chars
=
java_lang_String
::
as_unicode_string
(
this
,
length
,
THREAD
);
if
(
chars
!=
NULL
)
{
// Use alternate hashing algorithm on the string
return
AltHashing
::
murmur3_32
(
seed
,
chars
,
length
);
}
else
{
vm_exit_out_of_memory
(
length
,
"unable to create Unicode strings for String table rehash"
);
return
0
;
}
}
VerifyOopClosure
VerifyOopClosure
::
verify_oop
;
...
...
src/share/vm/prims/whitebox.cpp
浏览文件 @
4df056de
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
2013,
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
...
...
@@ -310,12 +310,8 @@ WB_END
WB_ENTRY
(
jboolean
,
WB_IsInStringTable
(
JNIEnv
*
env
,
jobject
o
,
jstring
javaString
))
ResourceMark
rm
(
THREAD
);
int
len
;
jchar
*
name
=
java_lang_String
::
as_unicode_string
(
JNIHandles
::
resolve
(
javaString
),
len
);
oop
found_string
=
StringTable
::
the_table
()
->
lookup
(
name
,
len
);
if
(
found_string
==
NULL
)
{
return
false
;
}
return
true
;
jchar
*
name
=
java_lang_String
::
as_unicode_string
(
JNIHandles
::
resolve
(
javaString
),
len
,
CHECK_false
);
return
(
StringTable
::
lookup
(
name
,
len
)
!=
NULL
);
WB_END
...
...
@@ -324,6 +320,11 @@ WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o))
Universe
::
heap
()
->
collect
(
GCCause
::
_last_ditch_collection
);
WB_END
WB_ENTRY
(
jlong
,
WB_ReserveMemory
(
JNIEnv
*
env
,
jobject
o
,
jlong
size
))
return
(
jlong
)
os
::
reserve_memory
(
size
,
NULL
,
0
);
WB_END
//Some convenience methods to deal with objects from java
int
WhiteBox
::
offset_for_field
(
const
char
*
field_name
,
oop
object
,
Symbol
*
signature_symbol
)
{
...
...
@@ -425,6 +426,8 @@ static JNINativeMethod methods[] = {
CC
"(Ljava/lang/reflect/Executable;)V"
,
(
void
*
)
&
WB_ClearMethodState
},
{
CC
"isInStringTable"
,
CC
"(Ljava/lang/String;)Z"
,
(
void
*
)
&
WB_IsInStringTable
},
{
CC
"fullGC"
,
CC
"()V"
,
(
void
*
)
&
WB_FullGC
},
{
CC
"reserveMemory"
,
CC
"(J)J"
,
(
void
*
)
&
WB_ReserveMemory
},
};
#undef CC
...
...
test/runtime/memory/ReserveMemory.java
0 → 100644
浏览文件 @
4df056de
/*
* Copyright (c) 2013, 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
* @key regression
* @bug 8012015
* @summary Make sure reserved (but uncommitted) memory is not accessible
* @library /testlibrary /testlibrary/whitebox
* @build ReserveMemory
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main ReserveMemory
*/
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"
);
}
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
);
throw
new
Exception
(
"Read of reserved/uncommitted memory unexpectedly succeeded, expected crash!"
);
}
ProcessBuilder
pb
=
ProcessTools
.
createJavaProcessBuilder
(
"-Xbootclasspath/a:."
,
"-XX:+UnlockDiagnosticVMOptions"
,
"-XX:+WhiteBoxAPI"
,
"ReserveMemory"
,
"test"
);
OutputAnalyzer
output
=
new
OutputAnalyzer
(
pb
.
start
());
if
(
isWindows
())
{
output
.
shouldContain
(
"EXCEPTION_ACCESS_VIOLATION"
);
}
else
{
output
.
shouldContain
(
"SIGSEGV"
);
}
}
}
test/testlibrary/whitebox/sun/hotspot/WhiteBox.java
浏览文件 @
4df056de
...
...
@@ -111,6 +111,9 @@ public class WhiteBox {
// Intered strings
public
native
boolean
isInStringTable
(
String
str
);
// Memory
public
native
long
reserveMemory
(
long
size
);
// force Full GC
public
native
void
fullGC
();
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录