Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
fe0330ea
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看板
提交
fe0330ea
编写于
3月 27, 2014
作者:
I
iignatyev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8038240: new WB API to get nmethod
Reviewed-by: morris, kvn
上级
2d48c8a5
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
169 addition
and
6 deletion
+169
-6
src/share/vm/prims/whitebox.cpp
src/share/vm/prims/whitebox.cpp
+41
-1
src/share/vm/prims/whitebox.hpp
src/share/vm/prims/whitebox.hpp
+1
-3
test/compiler/whitebox/CompilerWhiteBoxTest.java
test/compiler/whitebox/CompilerWhiteBoxTest.java
+3
-1
test/compiler/whitebox/GetNMethodTest.java
test/compiler/whitebox/GetNMethodTest.java
+71
-0
test/testlibrary/whitebox/sun/hotspot/WhiteBox.java
test/testlibrary/whitebox/sun/hotspot/WhiteBox.java
+2
-1
test/testlibrary/whitebox/sun/hotspot/code/NMethod.java
test/testlibrary/whitebox/sun/hotspot/code/NMethod.java
+51
-0
未找到文件。
src/share/vm/prims/whitebox.cpp
浏览文件 @
fe0330ea
/*
* Copyright (c) 2012, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 201
4
, 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
...
...
@@ -510,6 +510,44 @@ WB_ENTRY(jstring, WB_GetCPUFeatures(JNIEnv* env, jobject o))
return
features_string
;
WB_END
WB_ENTRY
(
jobjectArray
,
WB_GetNMethod
(
JNIEnv
*
env
,
jobject
o
,
jobject
method
,
jboolean
is_osr
))
ResourceMark
rm
(
THREAD
);
jmethodID
jmid
=
reflected_method_to_jmid
(
thread
,
env
,
method
);
CHECK_JNI_EXCEPTION_
(
env
,
NULL
);
methodHandle
mh
(
THREAD
,
Method
::
checked_resolve_jmethod_id
(
jmid
));
nmethod
*
code
=
is_osr
?
mh
->
lookup_osr_nmethod_for
(
InvocationEntryBci
,
CompLevel_none
,
false
)
:
mh
->
code
();
jobjectArray
result
=
NULL
;
if
(
code
==
NULL
)
{
return
result
;
}
int
insts_size
=
code
->
insts_size
();
ThreadToNativeFromVM
ttn
(
thread
);
jclass
clazz
=
env
->
FindClass
(
vmSymbols
::
java_lang_Object
()
->
as_C_string
());
CHECK_JNI_EXCEPTION_
(
env
,
NULL
);
result
=
env
->
NewObjectArray
(
2
,
clazz
,
NULL
);
if
(
result
==
NULL
)
{
return
result
;
}
clazz
=
env
->
FindClass
(
vmSymbols
::
java_lang_Integer
()
->
as_C_string
());
CHECK_JNI_EXCEPTION_
(
env
,
NULL
);
jmethodID
constructor
=
env
->
GetMethodID
(
clazz
,
vmSymbols
::
object_initializer_name
()
->
as_C_string
(),
vmSymbols
::
int_void_signature
()
->
as_C_string
());
CHECK_JNI_EXCEPTION_
(
env
,
NULL
);
jobject
obj
=
env
->
NewObject
(
clazz
,
constructor
,
code
->
comp_level
());
CHECK_JNI_EXCEPTION_
(
env
,
NULL
);
env
->
SetObjectArrayElement
(
result
,
0
,
obj
);
jbyteArray
insts
=
env
->
NewByteArray
(
insts_size
);
CHECK_JNI_EXCEPTION_
(
env
,
NULL
);
env
->
SetByteArrayRegion
(
insts
,
0
,
insts_size
,
(
jbyte
*
)
code
->
insts_begin
());
env
->
SetObjectArrayElement
(
result
,
1
,
insts
);
return
result
;
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
)
{
...
...
@@ -622,6 +660,8 @@ static JNINativeMethod methods[] = {
{
CC
"fullGC"
,
CC
"()V"
,
(
void
*
)
&
WB_FullGC
},
{
CC
"readReservedMemory"
,
CC
"()V"
,
(
void
*
)
&
WB_ReadReservedMemory
},
{
CC
"getCPUFeatures"
,
CC
"()Ljava/lang/String;"
,
(
void
*
)
&
WB_GetCPUFeatures
},
{
CC
"getNMethod"
,
CC
"(Ljava/lang/reflect/Executable;Z)[Ljava/lang/Object;"
,
(
void
*
)
&
WB_GetNMethod
},
};
#undef CC
...
...
src/share/vm/prims/whitebox.hpp
浏览文件 @
fe0330ea
/*
* Copyright (c) 2012, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 201
4
, 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
...
...
@@ -40,7 +40,6 @@
do { \
JavaThread* THREAD = JavaThread::thread_from_jni_environment(env); \
if (HAS_PENDING_EXCEPTION) { \
CLEAR_PENDING_EXCEPTION; \
return(value); \
} \
} while (0)
...
...
@@ -49,7 +48,6 @@
do { \
JavaThread* THREAD = JavaThread::thread_from_jni_environment(env); \
if (HAS_PENDING_EXCEPTION) { \
CLEAR_PENDING_EXCEPTION; \
return; \
} \
} while (0)
...
...
test/compiler/whitebox/CompilerWhiteBoxTest.java
浏览文件 @
fe0330ea
...
...
@@ -24,6 +24,7 @@
import
com.sun.management.HotSpotDiagnosticMXBean
;
import
com.sun.management.VMOption
;
import
sun.hotspot.WhiteBox
;
import
sun.hotspot.code.NMethod
;
import
sun.management.ManagementFactoryHelper
;
import
java.lang.reflect.Constructor
;
...
...
@@ -255,7 +256,8 @@ public abstract class CompilerWhiteBoxTest {
}
protected
final
int
getCompLevel
()
{
return
WHITE_BOX
.
getMethodCompilationLevel
(
method
,
testCase
.
isOsr
());
NMethod
nm
=
NMethod
.
get
(
method
,
testCase
.
isOsr
());
return
nm
==
null
?
COMP_LEVEL_NONE
:
nm
.
comp_level
;
}
protected
final
boolean
isCompilable
()
{
...
...
test/compiler/whitebox/GetNMethodTest.java
0 → 100644
浏览文件 @
fe0330ea
/*
* Copyright (c) 2014, 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.
*
*/
import
sun.hotspot.code.NMethod
;
/*
* @test GetNMethodTest
* @bug 8038240
* @library /testlibrary /testlibrary/whitebox
* @build GetNMethodTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* GetNMethodTest
* @summary testing of WB::getNMethod()
* @author igor.ignatyev@oracle.com
*/
public
class
GetNMethodTest
extends
CompilerWhiteBoxTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
CompilerWhiteBoxTest
.
main
(
GetNMethodTest:
:
new
,
args
);
}
private
GetNMethodTest
(
TestCase
testCase
)
{
super
(
testCase
);
// to prevent inlining of #method
WHITE_BOX
.
testSetDontInlineMethod
(
method
,
true
);
}
@Override
protected
void
test
()
throws
Exception
{
checkNotCompiled
();
compile
();
checkCompiled
();
NMethod
nmethod
=
NMethod
.
get
(
method
,
testCase
.
isOsr
());
if
(
IS_VERBOSE
)
{
System
.
out
.
println
(
"nmethod = "
+
nmethod
);
}
if
(
nmethod
==
null
)
{
throw
new
RuntimeException
(
"nmethod of compiled method is null"
);
}
if
(
nmethod
.
insts
.
length
==
0
)
{
throw
new
RuntimeException
(
"compiled method's instructions is empty"
);
}
deoptimize
();
checkNotCompiled
();
nmethod
=
NMethod
.
get
(
method
,
testCase
.
isOsr
());
if
(
nmethod
!=
null
)
{
throw
new
RuntimeException
(
"nmethod of non-compiled method isn't null"
);
}
}
}
test/testlibrary/whitebox/sun/hotspot/WhiteBox.java
浏览文件 @
fe0330ea
/*
* Copyright (c) 2012, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 201
4
, 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
...
...
@@ -135,6 +135,7 @@ public class WhiteBox {
public
native
boolean
enqueueMethodForCompilation
(
Executable
method
,
int
compLevel
,
int
entry_bci
);
public
native
void
clearMethodState
(
Executable
method
);
public
native
int
getMethodEntryBci
(
Executable
method
);
public
native
Object
[]
getNMethod
(
Executable
method
,
boolean
isOsr
);
// Intered strings
public
native
boolean
isInStringTable
(
String
str
);
...
...
test/testlibrary/whitebox/sun/hotspot/code/NMethod.java
0 → 100644
浏览文件 @
fe0330ea
/*
* Copyright (c) 2014, 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.
*
*/
package
sun.hotspot.code
;
import
java.lang.reflect.Executable
;
import
sun.hotspot.WhiteBox
;
public
class
NMethod
{
private
static
final
WhiteBox
wb
=
WhiteBox
.
getWhiteBox
();
public
static
NMethod
get
(
Executable
method
,
boolean
isOsr
)
{
Object
[]
obj
=
wb
.
getNMethod
(
method
,
isOsr
);
return
obj
==
null
?
null
:
new
NMethod
(
obj
);
}
private
NMethod
(
Object
[]
obj
)
{
assert
obj
.
length
==
2
;
comp_level
=
(
Integer
)
obj
[
0
];
insts
=
(
byte
[])
obj
[
1
];
}
public
byte
[]
insts
;
public
int
comp_level
;
@Override
public
String
toString
()
{
return
"NMethod{"
+
"insts="
+
insts
+
", comp_level="
+
comp_level
+
'}'
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录