Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
7b61dfe4
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看板
提交
7b61dfe4
编写于
3月 25, 2013
作者:
T
twisti
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7198429: need checked categorization of caller-sensitive methods in the JDK
Reviewed-by: kvn, jrose
上级
e88384a3
变更
18
展开全部
隐藏空白更改
内联
并排
Showing
18 changed file
with
407 addition
and
299 deletion
+407
-299
src/share/vm/ci/ciMethod.cpp
src/share/vm/ci/ciMethod.cpp
+11
-0
src/share/vm/ci/ciMethod.hpp
src/share/vm/ci/ciMethod.hpp
+6
-2
src/share/vm/classfile/classFileParser.cpp
src/share/vm/classfile/classFileParser.cpp
+9
-2
src/share/vm/classfile/classFileParser.hpp
src/share/vm/classfile/classFileParser.hpp
+1
-0
src/share/vm/classfile/classLoaderData.cpp
src/share/vm/classfile/classLoaderData.cpp
+7
-0
src/share/vm/classfile/classLoaderData.hpp
src/share/vm/classfile/classLoaderData.hpp
+1
-0
src/share/vm/classfile/javaClasses.hpp
src/share/vm/classfile/javaClasses.hpp
+8
-7
src/share/vm/classfile/systemDictionary.cpp
src/share/vm/classfile/systemDictionary.cpp
+11
-0
src/share/vm/classfile/systemDictionary.hpp
src/share/vm/classfile/systemDictionary.hpp
+7
-2
src/share/vm/classfile/vmSymbols.hpp
src/share/vm/classfile/vmSymbols.hpp
+6
-2
src/share/vm/oops/method.cpp
src/share/vm/oops/method.cpp
+29
-3
src/share/vm/oops/method.hpp
src/share/vm/oops/method.hpp
+19
-14
src/share/vm/opto/library_call.cpp
src/share/vm/opto/library_call.cpp
+49
-107
src/share/vm/prims/jvm.cpp
src/share/vm/prims/jvm.cpp
+62
-5
src/share/vm/prims/methodHandles.cpp
src/share/vm/prims/methodHandles.cpp
+16
-9
src/share/vm/prims/unsafe.cpp
src/share/vm/prims/unsafe.cpp
+146
-115
src/share/vm/runtime/vframe.cpp
src/share/vm/runtime/vframe.cpp
+18
-31
src/share/vm/runtime/vframe.hpp
src/share/vm/runtime/vframe.hpp
+1
-0
未找到文件。
src/share/vm/ci/ciMethod.cpp
浏览文件 @
7b61dfe4
...
@@ -790,6 +790,17 @@ int ciMethod::scale_count(int count, float prof_factor) {
...
@@ -790,6 +790,17 @@ int ciMethod::scale_count(int count, float prof_factor) {
return
count
;
return
count
;
}
}
// ------------------------------------------------------------------
// ciMethod::is_special_get_caller_class_method
//
bool
ciMethod
::
is_ignored_by_security_stack_walk
()
const
{
check_is_loaded
();
VM_ENTRY_MARK
;
return
get_Method
()
->
is_ignored_by_security_stack_walk
();
}
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// invokedynamic support
// invokedynamic support
...
...
src/share/vm/ci/ciMethod.hpp
浏览文件 @
7b61dfe4
...
@@ -166,8 +166,9 @@ class ciMethod : public ciMetadata {
...
@@ -166,8 +166,9 @@ class ciMethod : public ciMetadata {
// Code size for inlining decisions.
// Code size for inlining decisions.
int
code_size_for_inlining
();
int
code_size_for_inlining
();
bool
force_inline
()
{
return
get_Method
()
->
force_inline
();
}
bool
caller_sensitive
()
{
return
get_Method
()
->
caller_sensitive
();
}
bool
dont_inline
()
{
return
get_Method
()
->
dont_inline
();
}
bool
force_inline
()
{
return
get_Method
()
->
force_inline
();
}
bool
dont_inline
()
{
return
get_Method
()
->
dont_inline
();
}
int
comp_level
();
int
comp_level
();
int
highest_osr_comp_level
();
int
highest_osr_comp_level
();
...
@@ -264,6 +265,9 @@ class ciMethod : public ciMetadata {
...
@@ -264,6 +265,9 @@ class ciMethod : public ciMetadata {
int
instructions_size
();
int
instructions_size
();
int
scale_count
(
int
count
,
float
prof_factor
=
1.
);
// make MDO count commensurate with IIC
int
scale_count
(
int
count
,
float
prof_factor
=
1.
);
// make MDO count commensurate with IIC
// Stack walking support
bool
is_ignored_by_security_stack_walk
()
const
;
// JSR 292 support
// JSR 292 support
bool
is_method_handle_intrinsic
()
const
;
bool
is_method_handle_intrinsic
()
const
;
bool
is_compiled_lambda_form
()
const
;
bool
is_compiled_lambda_form
()
const
;
...
...
src/share/vm/classfile/classFileParser.cpp
浏览文件 @
7b61dfe4
...
@@ -1735,9 +1735,14 @@ ClassFileParser::AnnotationCollector::annotation_index(ClassLoaderData* loader_d
...
@@ -1735,9 +1735,14 @@ ClassFileParser::AnnotationCollector::annotation_index(ClassLoaderData* loader_d
Symbol
*
name
)
{
Symbol
*
name
)
{
vmSymbols
::
SID
sid
=
vmSymbols
::
find_sid
(
name
);
vmSymbols
::
SID
sid
=
vmSymbols
::
find_sid
(
name
);
// Privileged code can use all annotations. Other code silently drops some.
// Privileged code can use all annotations. Other code silently drops some.
bool
privileged
=
loader_data
->
is_the_null_class_loader_data
()
||
const
bool
privileged
=
loader_data
->
is_the_null_class_loader_data
()
||
loader_data
->
is_anonymous
();
loader_data
->
is_ext_class_loader_data
()
||
loader_data
->
is_anonymous
();
switch
(
sid
)
{
switch
(
sid
)
{
case
vmSymbols
::
VM_SYMBOL_ENUM_NAME
(
sun_reflect_CallerSensitive_signature
):
if
(
_location
!=
_in_method
)
break
;
// only allow for methods
if
(
!
privileged
)
break
;
// only allow in privileged code
return
_method_CallerSensitive
;
case
vmSymbols
::
VM_SYMBOL_ENUM_NAME
(
java_lang_invoke_ForceInline_signature
):
case
vmSymbols
::
VM_SYMBOL_ENUM_NAME
(
java_lang_invoke_ForceInline_signature
):
if
(
_location
!=
_in_method
)
break
;
// only allow for methods
if
(
_location
!=
_in_method
)
break
;
// only allow for methods
if
(
!
privileged
)
break
;
// only allow in privileged code
if
(
!
privileged
)
break
;
// only allow in privileged code
...
@@ -1775,6 +1780,8 @@ ClassFileParser::FieldAnnotationCollector::~FieldAnnotationCollector() {
...
@@ -1775,6 +1780,8 @@ ClassFileParser::FieldAnnotationCollector::~FieldAnnotationCollector() {
}
}
void
ClassFileParser
::
MethodAnnotationCollector
::
apply_to
(
methodHandle
m
)
{
void
ClassFileParser
::
MethodAnnotationCollector
::
apply_to
(
methodHandle
m
)
{
if
(
has_annotation
(
_method_CallerSensitive
))
m
->
set_caller_sensitive
(
true
);
if
(
has_annotation
(
_method_ForceInline
))
if
(
has_annotation
(
_method_ForceInline
))
m
->
set_force_inline
(
true
);
m
->
set_force_inline
(
true
);
if
(
has_annotation
(
_method_DontInline
))
if
(
has_annotation
(
_method_DontInline
))
...
...
src/share/vm/classfile/classFileParser.hpp
浏览文件 @
7b61dfe4
...
@@ -119,6 +119,7 @@ class ClassFileParser VALUE_OBJ_CLASS_SPEC {
...
@@ -119,6 +119,7 @@ class ClassFileParser VALUE_OBJ_CLASS_SPEC {
enum
Location
{
_in_field
,
_in_method
,
_in_class
};
enum
Location
{
_in_field
,
_in_method
,
_in_class
};
enum
ID
{
enum
ID
{
_unknown
=
0
,
_unknown
=
0
,
_method_CallerSensitive
,
_method_ForceInline
,
_method_ForceInline
,
_method_DontInline
,
_method_DontInline
,
_method_LambdaForm_Compiled
,
_method_LambdaForm_Compiled
,
...
...
src/share/vm/classfile/classLoaderData.cpp
浏览文件 @
7b61dfe4
...
@@ -321,6 +321,13 @@ ClassLoaderData::~ClassLoaderData() {
...
@@ -321,6 +321,13 @@ ClassLoaderData::~ClassLoaderData() {
}
}
}
}
/**
* Returns true if this class loader data is for the extension class loader.
*/
bool
ClassLoaderData
::
is_ext_class_loader_data
()
const
{
return
SystemDictionary
::
is_ext_class_loader
(
class_loader
());
}
Metaspace
*
ClassLoaderData
::
metaspace_non_null
()
{
Metaspace
*
ClassLoaderData
::
metaspace_non_null
()
{
assert
(
!
DumpSharedSpaces
,
"wrong metaspace!"
);
assert
(
!
DumpSharedSpaces
,
"wrong metaspace!"
);
// If the metaspace has not been allocated, create a new one. Might want
// If the metaspace has not been allocated, create a new one. Might want
...
...
src/share/vm/classfile/classLoaderData.hpp
浏览文件 @
7b61dfe4
...
@@ -191,6 +191,7 @@ class ClassLoaderData : public CHeapObj<mtClass> {
...
@@ -191,6 +191,7 @@ class ClassLoaderData : public CHeapObj<mtClass> {
bool
is_the_null_class_loader_data
()
const
{
bool
is_the_null_class_loader_data
()
const
{
return
this
==
_the_null_class_loader_data
;
return
this
==
_the_null_class_loader_data
;
}
}
bool
is_ext_class_loader_data
()
const
;
// The Metaspace is created lazily so may be NULL. This
// The Metaspace is created lazily so may be NULL. This
// method will allocate a Metaspace if needed.
// method will allocate a Metaspace if needed.
...
...
src/share/vm/classfile/javaClasses.hpp
浏览文件 @
7b61dfe4
...
@@ -1050,15 +1050,16 @@ class java_lang_invoke_MemberName: AllStatic {
...
@@ -1050,15 +1050,16 @@ class java_lang_invoke_MemberName: AllStatic {
// Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants):
// Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants):
enum
{
enum
{
MN_IS_METHOD
=
0x00010000
,
// method (not constructor)
MN_IS_METHOD
=
0x00010000
,
// method (not constructor)
MN_IS_CONSTRUCTOR
=
0x00020000
,
// constructor
MN_IS_CONSTRUCTOR
=
0x00020000
,
// constructor
MN_IS_FIELD
=
0x00040000
,
// field
MN_IS_FIELD
=
0x00040000
,
// field
MN_IS_TYPE
=
0x00080000
,
// nested type
MN_IS_TYPE
=
0x00080000
,
// nested type
MN_CALLER_SENSITIVE
=
0x00100000
,
// @CallerSensitive annotation detected
MN_REFERENCE_KIND_SHIFT
=
24
,
// refKind
MN_REFERENCE_KIND_SHIFT
=
24
,
// refKind
MN_REFERENCE_KIND_MASK
=
0x0F000000
>>
MN_REFERENCE_KIND_SHIFT
,
MN_REFERENCE_KIND_MASK
=
0x0F000000
>>
MN_REFERENCE_KIND_SHIFT
,
// The SEARCH_* bits are not for MN.flags but for the matchFlags argument of MHN.getMembers:
// The SEARCH_* bits are not for MN.flags but for the matchFlags argument of MHN.getMembers:
MN_SEARCH_SUPERCLASSES
=
0x00100000
,
// walk super classes
MN_SEARCH_SUPERCLASSES
=
0x00100000
,
// walk super classes
MN_SEARCH_INTERFACES
=
0x00200000
// walk implemented interfaces
MN_SEARCH_INTERFACES
=
0x00200000
// walk implemented interfaces
};
};
// Accessors for code generation:
// Accessors for code generation:
...
...
src/share/vm/classfile/systemDictionary.cpp
浏览文件 @
7b61dfe4
...
@@ -146,6 +146,17 @@ bool SystemDictionary::is_parallelDefine(Handle class_loader) {
...
@@ -146,6 +146,17 @@ bool SystemDictionary::is_parallelDefine(Handle class_loader) {
}
}
return
false
;
return
false
;
}
}
/**
* Returns true if the passed class loader is the extension class loader.
*/
bool
SystemDictionary
::
is_ext_class_loader
(
Handle
class_loader
)
{
if
(
class_loader
.
is_null
())
{
return
false
;
}
return
(
class_loader
->
klass
()
->
name
()
==
vmSymbols
::
sun_misc_Launcher_ExtClassLoader
());
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Resolving of classes
// Resolving of classes
...
...
src/share/vm/classfile/systemDictionary.hpp
浏览文件 @
7b61dfe4
...
@@ -106,6 +106,7 @@ class SymbolPropertyTable;
...
@@ -106,6 +106,7 @@ class SymbolPropertyTable;
do_klass(ThreadDeath_klass, java_lang_ThreadDeath, Pre ) \
do_klass(ThreadDeath_klass, java_lang_ThreadDeath, Pre ) \
do_klass(Exception_klass, java_lang_Exception, Pre ) \
do_klass(Exception_klass, java_lang_Exception, Pre ) \
do_klass(RuntimeException_klass, java_lang_RuntimeException, Pre ) \
do_klass(RuntimeException_klass, java_lang_RuntimeException, Pre ) \
do_klass(SecurityManager_klass, java_lang_SecurityManager, Pre ) \
do_klass(ProtectionDomain_klass, java_security_ProtectionDomain, Pre ) \
do_klass(ProtectionDomain_klass, java_security_ProtectionDomain, Pre ) \
do_klass(AccessControlContext_klass, java_security_AccessControlContext, Pre ) \
do_klass(AccessControlContext_klass, java_security_AccessControlContext, Pre ) \
do_klass(ClassNotFoundException_klass, java_lang_ClassNotFoundException, Pre ) \
do_klass(ClassNotFoundException_klass, java_lang_ClassNotFoundException, Pre ) \
...
@@ -138,13 +139,14 @@ class SymbolPropertyTable;
...
@@ -138,13 +139,14 @@ class SymbolPropertyTable;
/* NOTE: needed too early in bootstrapping process to have checks based on JDK version */
\
/* NOTE: needed too early in bootstrapping process to have checks based on JDK version */
\
/* Universe::is_gte_jdk14x_version() is not set up by this point. */
\
/* Universe::is_gte_jdk14x_version() is not set up by this point. */
\
/* It's okay if this turns out to be NULL in non-1.4 JDKs. */
\
/* It's okay if this turns out to be NULL in non-1.4 JDKs. */
\
do_klass(lambda_MagicLambdaImpl_klass, java_lang_invoke_MagicLambdaImpl,
Opt
) \
do_klass(lambda_MagicLambdaImpl_klass, java_lang_invoke_MagicLambdaImpl,
Opt
) \
do_klass(reflect_MagicAccessorImpl_klass, sun_reflect_MagicAccessorImpl, Opt ) \
do_klass(reflect_MagicAccessorImpl_klass, sun_reflect_MagicAccessorImpl, Opt ) \
do_klass(reflect_MethodAccessorImpl_klass, sun_reflect_MethodAccessorImpl, Opt_Only_JDK14NewRef) \
do_klass(reflect_MethodAccessorImpl_klass, sun_reflect_MethodAccessorImpl, Opt_Only_JDK14NewRef) \
do_klass(reflect_ConstructorAccessorImpl_klass, sun_reflect_ConstructorAccessorImpl, Opt_Only_JDK14NewRef) \
do_klass(reflect_ConstructorAccessorImpl_klass, sun_reflect_ConstructorAccessorImpl, Opt_Only_JDK14NewRef) \
do_klass(reflect_DelegatingClassLoader_klass, sun_reflect_DelegatingClassLoader, Opt ) \
do_klass(reflect_DelegatingClassLoader_klass, sun_reflect_DelegatingClassLoader, Opt ) \
do_klass(reflect_ConstantPool_klass, sun_reflect_ConstantPool, Opt_Only_JDK15 ) \
do_klass(reflect_ConstantPool_klass, sun_reflect_ConstantPool, Opt_Only_JDK15 ) \
do_klass(reflect_UnsafeStaticFieldAccessorImpl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt_Only_JDK15 ) \
do_klass(reflect_UnsafeStaticFieldAccessorImpl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt_Only_JDK15 ) \
do_klass(reflect_CallerSensitive_klass, sun_reflect_CallerSensitive, Opt ) \
\
\
/* support for dynamic typing; it's OK if these are NULL in earlier JDKs */
\
/* support for dynamic typing; it's OK if these are NULL in earlier JDKs */
\
do_klass(MethodHandle_klass, java_lang_invoke_MethodHandle, Pre_JSR292 ) \
do_klass(MethodHandle_klass, java_lang_invoke_MethodHandle, Pre_JSR292 ) \
...
@@ -628,12 +630,15 @@ private:
...
@@ -628,12 +630,15 @@ private:
static
bool
is_parallelCapable
(
Handle
class_loader
);
static
bool
is_parallelCapable
(
Handle
class_loader
);
static
bool
is_parallelDefine
(
Handle
class_loader
);
static
bool
is_parallelDefine
(
Handle
class_loader
);
public:
static
bool
is_ext_class_loader
(
Handle
class_loader
);
private:
static
Klass
*
find_shared_class
(
Symbol
*
class_name
);
static
Klass
*
find_shared_class
(
Symbol
*
class_name
);
// Setup link to hierarchy
// Setup link to hierarchy
static
void
add_to_hierarchy
(
instanceKlassHandle
k
,
TRAPS
);
static
void
add_to_hierarchy
(
instanceKlassHandle
k
,
TRAPS
);
private:
// We pass in the hashtable index so we can calculate it outside of
// We pass in the hashtable index so we can calculate it outside of
// the SystemDictionary_lock.
// the SystemDictionary_lock.
...
...
src/share/vm/classfile/vmSymbols.hpp
浏览文件 @
7b61dfe4
...
@@ -91,6 +91,7 @@
...
@@ -91,6 +91,7 @@
template(java_lang_StringBuffer, "java/lang/StringBuffer") \
template(java_lang_StringBuffer, "java/lang/StringBuffer") \
template(java_lang_StringBuilder, "java/lang/StringBuilder") \
template(java_lang_StringBuilder, "java/lang/StringBuilder") \
template(java_lang_CharSequence, "java/lang/CharSequence") \
template(java_lang_CharSequence, "java/lang/CharSequence") \
template(java_lang_SecurityManager, "java/lang/SecurityManager") \
template(java_security_AccessControlContext, "java/security/AccessControlContext") \
template(java_security_AccessControlContext, "java/security/AccessControlContext") \
template(java_security_ProtectionDomain, "java/security/ProtectionDomain") \
template(java_security_ProtectionDomain, "java/security/ProtectionDomain") \
template(java_io_OutputStream, "java/io/OutputStream") \
template(java_io_OutputStream, "java/io/OutputStream") \
...
@@ -211,6 +212,8 @@
...
@@ -211,6 +212,8 @@
template(sun_reflect_SerializationConstructorAccessorImpl, "sun/reflect/SerializationConstructorAccessorImpl") \
template(sun_reflect_SerializationConstructorAccessorImpl, "sun/reflect/SerializationConstructorAccessorImpl") \
template(sun_reflect_DelegatingClassLoader, "sun/reflect/DelegatingClassLoader") \
template(sun_reflect_DelegatingClassLoader, "sun/reflect/DelegatingClassLoader") \
template(sun_reflect_Reflection, "sun/reflect/Reflection") \
template(sun_reflect_Reflection, "sun/reflect/Reflection") \
template(sun_reflect_CallerSensitive, "sun/reflect/CallerSensitive") \
template(sun_reflect_CallerSensitive_signature, "Lsun/reflect/CallerSensitive;") \
template(checkedExceptions_name, "checkedExceptions") \
template(checkedExceptions_name, "checkedExceptions") \
template(clazz_name, "clazz") \
template(clazz_name, "clazz") \
template(exceptionTypes_name, "exceptionTypes") \
template(exceptionTypes_name, "exceptionTypes") \
...
@@ -343,6 +346,7 @@
...
@@ -343,6 +346,7 @@
template(contextClassLoader_name, "contextClassLoader") \
template(contextClassLoader_name, "contextClassLoader") \
template(inheritedAccessControlContext_name, "inheritedAccessControlContext") \
template(inheritedAccessControlContext_name, "inheritedAccessControlContext") \
template(isPrivileged_name, "isPrivileged") \
template(isPrivileged_name, "isPrivileged") \
template(getClassContext_name, "getClassContext") \
template(wait_name, "wait") \
template(wait_name, "wait") \
template(checkPackageAccess_name, "checkPackageAccess") \
template(checkPackageAccess_name, "checkPackageAccess") \
template(stackSize_name, "stackSize") \
template(stackSize_name, "stackSize") \
...
@@ -463,6 +467,7 @@
...
@@ -463,6 +467,7 @@
template(void_classloader_signature, "()Ljava/lang/ClassLoader;") \
template(void_classloader_signature, "()Ljava/lang/ClassLoader;") \
template(void_object_signature, "()Ljava/lang/Object;") \
template(void_object_signature, "()Ljava/lang/Object;") \
template(void_class_signature, "()Ljava/lang/Class;") \
template(void_class_signature, "()Ljava/lang/Class;") \
template(void_class_array_signature, "()[Ljava/lang/Class;") \
template(void_string_signature, "()Ljava/lang/String;") \
template(void_string_signature, "()Ljava/lang/String;") \
template(object_array_object_signature, "([Ljava/lang/Object;)Ljava/lang/Object;") \
template(object_array_object_signature, "([Ljava/lang/Object;)Ljava/lang/Object;") \
template(object_object_array_object_signature, "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;")\
template(object_object_array_object_signature, "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;")\
...
@@ -705,9 +710,8 @@
...
@@ -705,9 +710,8 @@
do_intrinsic(_getLength, java_lang_reflect_Array, getLength_name, object_int_signature, F_SN) \
do_intrinsic(_getLength, java_lang_reflect_Array, getLength_name, object_int_signature, F_SN) \
do_name( getLength_name, "getLength") \
do_name( getLength_name, "getLength") \
\
\
do_intrinsic(_getCallerClass, sun_reflect_Reflection, getCallerClass_name,
getCallerClass_signature,
F_SN) \
do_intrinsic(_getCallerClass, sun_reflect_Reflection, getCallerClass_name,
void_class_signature,
F_SN) \
do_name( getCallerClass_name, "getCallerClass") \
do_name( getCallerClass_name, "getCallerClass") \
do_signature(getCallerClass_signature, "(I)Ljava/lang/Class;") \
\
\
do_intrinsic(_newArray, java_lang_reflect_Array, newArray_name, newArray_signature, F_SN) \
do_intrinsic(_newArray, java_lang_reflect_Array, newArray_name, newArray_signature, F_SN) \
do_name( newArray_name, "newArray") \
do_name( newArray_name, "newArray") \
...
...
src/share/vm/oops/method.cpp
浏览文件 @
7b61dfe4
...
@@ -967,6 +967,32 @@ bool Method::should_not_be_cached() const {
...
@@ -967,6 +967,32 @@ bool Method::should_not_be_cached() const {
return
false
;
return
false
;
}
}
/**
* Returns true if this is one of the specially treated methods for
* security related stack walks (like Reflection.getCallerClass).
*/
bool
Method
::
is_ignored_by_security_stack_walk
()
const
{
const
bool
use_new_reflection
=
JDK_Version
::
is_gte_jdk14x_version
()
&&
UseNewReflection
;
assert
(
intrinsic_id
()
!=
vmIntrinsics
::
_invoke
||
Universe
::
reflect_invoke_cache
()
->
is_same_method
((
Method
*
)
this
),
"sanity"
);
if
(
intrinsic_id
()
==
vmIntrinsics
::
_invoke
)
{
// This is Method.invoke() -- ignore it
return
true
;
}
if
(
use_new_reflection
&&
method_holder
()
->
is_subclass_of
(
SystemDictionary
::
reflect_MethodAccessorImpl_klass
()))
{
// This is an auxilary frame -- ignore it
return
true
;
}
if
(
is_method_handle_intrinsic
()
||
is_compiled_lambda_form
())
{
// This is an internal adapter frame for method handles -- ignore it
return
true
;
}
return
false
;
}
// Constant pool structure for invoke methods:
// Constant pool structure for invoke methods:
enum
{
enum
{
_imcp_invoke_name
=
1
,
// utf8: 'invokeExact', etc.
_imcp_invoke_name
=
1
,
// utf8: 'invokeExact', etc.
...
@@ -1178,13 +1204,13 @@ vmSymbols::SID Method::klass_id_for_intrinsics(Klass* holder) {
...
@@ -1178,13 +1204,13 @@ vmSymbols::SID Method::klass_id_for_intrinsics(Klass* holder) {
// because we are not loading from core libraries
// because we are not loading from core libraries
// exception: the AES intrinsics come from lib/ext/sunjce_provider.jar
// exception: the AES intrinsics come from lib/ext/sunjce_provider.jar
// which does not use the class default class loader so we check for its loader here
// which does not use the class default class loader so we check for its loader here
if
((
InstanceKlass
::
cast
(
holder
)
->
class_loader
()
!=
NULL
)
&&
InstanceKlass
*
ik
=
InstanceKlass
::
cast
(
holder
);
InstanceKlass
::
cast
(
holder
)
->
class_loader
()
->
klass
()
->
name
()
!=
vmSymbols
::
sun_misc_Launcher_ExtClassLoader
(
))
{
if
((
ik
->
class_loader
()
!=
NULL
)
&&
!
SystemDictionary
::
is_ext_class_loader
(
ik
->
class_loader
()
))
{
return
vmSymbols
::
NO_SID
;
// regardless of name, no intrinsics here
return
vmSymbols
::
NO_SID
;
// regardless of name, no intrinsics here
}
}
// see if the klass name is well-known:
// see if the klass name is well-known:
Symbol
*
klass_name
=
InstanceKlass
::
cast
(
holder
)
->
name
();
Symbol
*
klass_name
=
ik
->
name
();
return
vmSymbols
::
find_sid
(
klass_name
);
return
vmSymbols
::
find_sid
(
klass_name
);
}
}
...
...
src/share/vm/oops/method.hpp
浏览文件 @
7b61dfe4
...
@@ -118,11 +118,12 @@ class Method : public Metadata {
...
@@ -118,11 +118,12 @@ class Method : public Metadata {
#endif
#endif
u2
_method_size
;
// size of this object
u2
_method_size
;
// size of this object
u1
_intrinsic_id
;
// vmSymbols::intrinsic_id (0 == _none)
u1
_intrinsic_id
;
// vmSymbols::intrinsic_id (0 == _none)
u1
_jfr_towrite
:
1
,
// Flags
u1
_jfr_towrite
:
1
,
// Flags
_force_inline
:
1
,
_caller_sensitive
:
1
,
_hidden
:
1
,
_force_inline
:
1
,
_dont_inline
:
1
,
_hidden
:
1
,
:
4
;
_dont_inline
:
1
,
:
3
;
u2
_interpreter_throwout_count
;
// Count of times method was exited via exception while interpreting
u2
_interpreter_throwout_count
;
// Count of times method was exited via exception while interpreting
u2
_number_of_breakpoints
;
// fullspeed debugging support
u2
_number_of_breakpoints
;
// fullspeed debugging support
InvocationCounter
_invocation_counter
;
// Incremented before each activation of the method - used to trigger frequency-based optimizations
InvocationCounter
_invocation_counter
;
// Incremented before each activation of the method - used to trigger frequency-based optimizations
...
@@ -618,6 +619,9 @@ class Method : public Metadata {
...
@@ -618,6 +619,9 @@ class Method : public Metadata {
// Reflection support
// Reflection support
bool
is_overridden_in
(
Klass
*
k
)
const
;
bool
is_overridden_in
(
Klass
*
k
)
const
;
// Stack walking support
bool
is_ignored_by_security_stack_walk
()
const
;
// JSR 292 support
// JSR 292 support
bool
is_method_handle_intrinsic
()
const
;
// MethodHandles::is_signature_polymorphic_intrinsic(intrinsic_id)
bool
is_method_handle_intrinsic
()
const
;
// MethodHandles::is_signature_polymorphic_intrinsic(intrinsic_id)
bool
is_compiled_lambda_form
()
const
;
// intrinsic_id() == vmIntrinsics::_compiledLambdaForm
bool
is_compiled_lambda_form
()
const
;
// intrinsic_id() == vmIntrinsics::_compiledLambdaForm
...
@@ -705,15 +709,16 @@ class Method : public Metadata {
...
@@ -705,15 +709,16 @@ class Method : public Metadata {
void
init_intrinsic_id
();
// updates from _none if a match
void
init_intrinsic_id
();
// updates from _none if a match
static
vmSymbols
::
SID
klass_id_for_intrinsics
(
Klass
*
holder
);
static
vmSymbols
::
SID
klass_id_for_intrinsics
(
Klass
*
holder
);
bool
jfr_towrite
()
{
return
_jfr_towrite
;
}
bool
jfr_towrite
()
{
return
_jfr_towrite
;
}
void
set_jfr_towrite
(
bool
towrite
)
{
_jfr_towrite
=
towrite
;
}
void
set_jfr_towrite
(
bool
x
)
{
_jfr_towrite
=
x
;
}
bool
caller_sensitive
()
{
return
_caller_sensitive
;
}
bool
force_inline
()
{
return
_force_inline
;
}
void
set_caller_sensitive
(
bool
x
)
{
_caller_sensitive
=
x
;
}
void
set_force_inline
(
bool
x
)
{
_force_inline
=
x
;
}
bool
force_inline
()
{
return
_force_inline
;
}
bool
dont_inline
()
{
return
_dont_inline
;
}
void
set_force_inline
(
bool
x
)
{
_force_inline
=
x
;
}
void
set_dont_inline
(
bool
x
)
{
_dont_inline
=
x
;
}
bool
dont_inline
()
{
return
_dont_inline
;
}
bool
is_hidden
()
{
return
_hidden
;
}
void
set_dont_inline
(
bool
x
)
{
_dont_inline
=
x
;
}
void
set_hidden
(
bool
x
)
{
_hidden
=
x
;
}
bool
is_hidden
()
{
return
_hidden
;
}
void
set_hidden
(
bool
x
)
{
_hidden
=
x
;
}
ConstMethod
::
MethodType
method_type
()
const
{
ConstMethod
::
MethodType
method_type
()
const
{
return
_constMethod
->
method_type
();
return
_constMethod
->
method_type
();
}
}
...
...
src/share/vm/opto/library_call.cpp
浏览文件 @
7b61dfe4
...
@@ -231,7 +231,6 @@ class LibraryCallKit : public GraphKit {
...
@@ -231,7 +231,6 @@ class LibraryCallKit : public GraphKit {
void
copy_to_clone
(
Node
*
obj
,
Node
*
alloc_obj
,
Node
*
obj_size
,
bool
is_array
,
bool
card_mark
);
void
copy_to_clone
(
Node
*
obj
,
Node
*
alloc_obj
,
Node
*
obj_size
,
bool
is_array
,
bool
card_mark
);
bool
inline_native_clone
(
bool
is_virtual
);
bool
inline_native_clone
(
bool
is_virtual
);
bool
inline_native_Reflection_getCallerClass
();
bool
inline_native_Reflection_getCallerClass
();
bool
is_method_invoke_or_aux_frame
(
JVMState
*
jvms
);
// Helper function for inlining native object hash method
// Helper function for inlining native object hash method
bool
inline_native_hashcode
(
bool
is_virtual
,
bool
is_static
);
bool
inline_native_hashcode
(
bool
is_virtual
,
bool
is_static
);
bool
inline_native_getClass
();
bool
inline_native_getClass
();
...
@@ -393,7 +392,7 @@ CallGenerator* Compile::make_vm_intrinsic(ciMethod* m, bool is_virtual) {
...
@@ -393,7 +392,7 @@ CallGenerator* Compile::make_vm_intrinsic(ciMethod* m, bool is_virtual) {
case
vmIntrinsics
::
_getCallerClass
:
case
vmIntrinsics
::
_getCallerClass
:
if
(
!
UseNewReflection
)
return
NULL
;
if
(
!
UseNewReflection
)
return
NULL
;
if
(
!
InlineReflectionGetCallerClass
)
return
NULL
;
if
(
!
InlineReflectionGetCallerClass
)
return
NULL
;
if
(
!
JDK_Version
::
is_gte_jdk14x_version
()
)
return
NULL
;
if
(
SystemDictionary
::
reflect_CallerSensitive_klass
()
==
NULL
)
return
NULL
;
break
;
break
;
case
vmIntrinsics
::
_bitCount_i
:
case
vmIntrinsics
::
_bitCount_i
:
...
@@ -3872,13 +3871,13 @@ bool LibraryCallKit::inline_native_getClass() {
...
@@ -3872,13 +3871,13 @@ bool LibraryCallKit::inline_native_getClass() {
}
}
//-----------------inline_native_Reflection_getCallerClass---------------------
//-----------------inline_native_Reflection_getCallerClass---------------------
// public static native Class<?> sun.reflect.Reflection.getCallerClass(
int realFramesToSkip
);
// public static native Class<?> sun.reflect.Reflection.getCallerClass();
//
//
// In the presence of deep enough inlining, getCallerClass() becomes a no-op.
// In the presence of deep enough inlining, getCallerClass() becomes a no-op.
//
//
// NOTE
that this code must perform the same logic a
s
// NOTE
: This code must perform the same logic as JVM_GetCallerClas
s
//
vframeStream::security_get_caller_frame in that it must skip
//
in that it must skip particular security frames and checks for
//
Method.invoke() and auxiliary frame
s.
//
caller sensitive method
s.
bool
LibraryCallKit
::
inline_native_Reflection_getCallerClass
()
{
bool
LibraryCallKit
::
inline_native_Reflection_getCallerClass
()
{
#ifndef PRODUCT
#ifndef PRODUCT
if
((
PrintIntrinsics
||
PrintInlining
||
PrintOptoInlining
)
&&
Verbose
)
{
if
((
PrintIntrinsics
||
PrintInlining
||
PrintOptoInlining
)
&&
Verbose
)
{
...
@@ -3886,35 +3885,6 @@ bool LibraryCallKit::inline_native_Reflection_getCallerClass() {
...
@@ -3886,35 +3885,6 @@ bool LibraryCallKit::inline_native_Reflection_getCallerClass() {
}
}
#endif
#endif
Node
*
caller_depth_node
=
argument
(
0
);
// The depth value must be a constant in order for the runtime call
// to be eliminated.
const
TypeInt
*
caller_depth_type
=
_gvn
.
type
(
caller_depth_node
)
->
isa_int
();
if
(
caller_depth_type
==
NULL
||
!
caller_depth_type
->
is_con
())
{
#ifndef PRODUCT
if
((
PrintIntrinsics
||
PrintInlining
||
PrintOptoInlining
)
&&
Verbose
)
{
tty
->
print_cr
(
" Bailing out because caller depth was not a constant"
);
}
#endif
return
false
;
}
// Note that the JVM state at this point does not include the
// getCallerClass() frame which we are trying to inline. The
// semantics of getCallerClass(), however, are that the "first"
// frame is the getCallerClass() frame, so we subtract one from the
// requested depth before continuing. We don't inline requests of
// getCallerClass(0).
int
caller_depth
=
caller_depth_type
->
get_con
()
-
1
;
if
(
caller_depth
<
0
)
{
#ifndef PRODUCT
if
((
PrintIntrinsics
||
PrintInlining
||
PrintOptoInlining
)
&&
Verbose
)
{
tty
->
print_cr
(
" Bailing out because caller depth was %d"
,
caller_depth
);
}
#endif
return
false
;
}
if
(
!
jvms
()
->
has_method
())
{
if
(
!
jvms
()
->
has_method
())
{
#ifndef PRODUCT
#ifndef PRODUCT
if
((
PrintIntrinsics
||
PrintInlining
||
PrintOptoInlining
)
&&
Verbose
)
{
if
((
PrintIntrinsics
||
PrintInlining
||
PrintOptoInlining
)
&&
Verbose
)
{
...
@@ -3923,95 +3893,67 @@ bool LibraryCallKit::inline_native_Reflection_getCallerClass() {
...
@@ -3923,95 +3893,67 @@ bool LibraryCallKit::inline_native_Reflection_getCallerClass() {
#endif
#endif
return
false
;
return
false
;
}
}
int
_depth
=
jvms
()
->
depth
();
// cache call chain depth
// Walk back up the JVM state to find the caller at the required
// Walk back up the JVM state to find the caller at the required
// depth. NOTE that this code must perform the same logic as
// depth.
// vframeStream::security_get_caller_frame in that it must skip
JVMState
*
caller_jvms
=
jvms
();
// Method.invoke() and auxiliary frames. Note also that depth is
// 1-based (1 is the bottom of the inlining).
// Cf. JVM_GetCallerClass
int
inlining_depth
=
_depth
;
// NOTE: Start the loop at depth 1 because the current JVM state does
JVMState
*
caller_jvms
=
NULL
;
// not include the Reflection.getCallerClass() frame.
for
(
int
n
=
1
;
caller_jvms
!=
NULL
;
caller_jvms
=
caller_jvms
->
caller
(),
n
++
)
{
if
(
inlining_depth
>
0
)
{
ciMethod
*
m
=
caller_jvms
->
method
();
caller_jvms
=
jvms
();
switch
(
n
)
{
assert
(
caller_jvms
=
jvms
()
->
of_depth
(
inlining_depth
),
"inlining_depth == our depth"
);
case
0
:
do
{
fatal
(
"current JVM state does not include the Reflection.getCallerClass frame"
);
// The following if-tests should be performed in this order
break
;
if
(
is_method_invoke_or_aux_frame
(
caller_jvms
))
{
case
1
:
// Skip a Method.invoke() or auxiliary frame
// Frame 0 and 1 must be caller sensitive (see JVM_GetCallerClass).
}
else
if
(
caller_depth
>
0
)
{
if
(
!
m
->
caller_sensitive
())
{
// Skip real frame
#ifndef PRODUCT
--
caller_depth
;
if
((
PrintIntrinsics
||
PrintInlining
||
PrintOptoInlining
)
&&
Verbose
)
{
}
else
{
tty
->
print_cr
(
" Bailing out: CallerSensitive annotation expected at frame %d"
,
n
);
// We're done: reached desired caller after skipping.
}
break
;
#endif
return
false
;
// bail-out; let JVM_GetCallerClass do the work
}
}
caller_jvms
=
caller_jvms
->
caller
();
break
;
--
inlining_depth
;
default:
}
while
(
inlining_depth
>
0
);
if
(
!
m
->
is_ignored_by_security_stack_walk
())
{
}
// We have reached the desired frame; return the holder class.
// Acquire method holder as java.lang.Class and push as constant.
ciInstanceKlass
*
caller_klass
=
caller_jvms
->
method
()
->
holder
();
ciInstance
*
caller_mirror
=
caller_klass
->
java_mirror
();
set_result
(
makecon
(
TypeInstPtr
::
make
(
caller_mirror
)));
if
(
inlining_depth
==
0
)
{
#ifndef PRODUCT
#ifndef PRODUCT
if
((
PrintIntrinsics
||
PrintInlining
||
PrintOptoInlining
)
&&
Verbose
)
{
if
((
PrintIntrinsics
||
PrintInlining
||
PrintOptoInlining
)
&&
Verbose
)
{
tty
->
print_cr
(
" Bailing out because caller depth (%d) exceeded inlining depth (%d)"
,
caller_depth_type
->
get_con
(),
_depth
);
tty
->
print_cr
(
" Succeeded: caller = %d) %s.%s, JVMS depth = %d"
,
n
,
caller_klass
->
name
()
->
as_utf8
(),
caller_jvms
->
method
()
->
name
()
->
as_utf8
(),
jvms
()
->
depth
());
tty
->
print_cr
(
" JVM state at this point:"
);
tty
->
print_cr
(
" JVM state at this point:"
);
for
(
int
i
=
_depth
;
i
>=
1
;
i
--
)
{
for
(
int
i
=
jvms
()
->
depth
(),
n
=
1
;
i
>=
1
;
i
--
,
n
++
)
{
ciMethod
*
m
=
jvms
()
->
of_depth
(
i
)
->
method
();
ciMethod
*
m
=
jvms
()
->
of_depth
(
i
)
->
method
();
tty
->
print_cr
(
" %d) %s.%s"
,
i
,
m
->
holder
()
->
name
()
->
as_utf8
(),
m
->
name
()
->
as_utf8
());
tty
->
print_cr
(
" %d) %s.%s"
,
n
,
m
->
holder
()
->
name
()
->
as_utf8
(),
m
->
name
()
->
as_utf8
());
}
}
#endif
return
true
;
}
}
break
;
}
}
#endif
return
false
;
// Reached end of inlining
}
}
// Acquire method holder as java.lang.Class
ciInstanceKlass
*
caller_klass
=
caller_jvms
->
method
()
->
holder
();
ciInstance
*
caller_mirror
=
caller_klass
->
java_mirror
();
// Push this as a constant
set_result
(
makecon
(
TypeInstPtr
::
make
(
caller_mirror
)));
#ifndef PRODUCT
#ifndef PRODUCT
if
((
PrintIntrinsics
||
PrintInlining
||
PrintOptoInlining
)
&&
Verbose
)
{
if
((
PrintIntrinsics
||
PrintInlining
||
PrintOptoInlining
)
&&
Verbose
)
{
tty
->
print_cr
(
"
Succeeded: caller = %s.%s, caller depth = %d, depth = %d"
,
caller_klass
->
name
()
->
as_utf8
(),
caller_jvms
->
method
()
->
name
()
->
as_utf8
(),
caller_depth_type
->
get_con
(),
_depth
);
tty
->
print_cr
(
"
Bailing out because caller depth exceeded inlining depth = %d"
,
jvms
()
->
depth
()
);
tty
->
print_cr
(
" JVM state at this point:"
);
tty
->
print_cr
(
" JVM state at this point:"
);
for
(
int
i
=
_depth
;
i
>=
1
;
i
--
)
{
for
(
int
i
=
jvms
()
->
depth
(),
n
=
1
;
i
>=
1
;
i
--
,
n
++
)
{
ciMethod
*
m
=
jvms
()
->
of_depth
(
i
)
->
method
();
ciMethod
*
m
=
jvms
()
->
of_depth
(
i
)
->
method
();
tty
->
print_cr
(
" %d) %s.%s"
,
i
,
m
->
holder
()
->
name
()
->
as_utf8
(),
m
->
name
()
->
as_utf8
());
tty
->
print_cr
(
" %d) %s.%s"
,
n
,
m
->
holder
()
->
name
()
->
as_utf8
(),
m
->
name
()
->
as_utf8
());
}
}
}
}
#endif
#endif
return
true
;
}
// Helper routine for above
bool
LibraryCallKit
::
is_method_invoke_or_aux_frame
(
JVMState
*
jvms
)
{
ciMethod
*
method
=
jvms
->
method
();
// Is this the Method.invoke method itself?
if
(
method
->
intrinsic_id
()
==
vmIntrinsics
::
_invoke
)
return
true
;
// Is this a helper, defined somewhere underneath MethodAccessorImpl.
ciKlass
*
k
=
method
->
holder
();
if
(
k
->
is_instance_klass
())
{
ciInstanceKlass
*
ik
=
k
->
as_instance_klass
();
for
(;
ik
!=
NULL
;
ik
=
ik
->
super
())
{
if
(
ik
->
name
()
==
ciSymbol
::
sun_reflect_MethodAccessorImpl
()
&&
ik
==
env
()
->
find_system_klass
(
ik
->
name
()))
{
return
true
;
}
}
}
else
if
(
method
->
is_method_handle_intrinsic
()
||
method
->
is_compiled_lambda_form
())
{
// This is an internal adapter frame from the MethodHandleCompiler -- skip it
return
true
;
}
return
false
;
return
false
;
// bail-out; let JVM_GetCallerClass do the work
}
}
bool
LibraryCallKit
::
inline_fp_conversions
(
vmIntrinsics
::
ID
id
)
{
bool
LibraryCallKit
::
inline_fp_conversions
(
vmIntrinsics
::
ID
id
)
{
...
...
src/share/vm/prims/jvm.cpp
浏览文件 @
7b61dfe4
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
#include "classfile/systemDictionary.hpp"
#include "classfile/systemDictionary.hpp"
#include "classfile/vmSymbols.hpp"
#include "classfile/vmSymbols.hpp"
#include "gc_interface/collectedHeap.inline.hpp"
#include "gc_interface/collectedHeap.inline.hpp"
#include "interpreter/bytecode.hpp"
#include "memory/oopFactory.hpp"
#include "memory/oopFactory.hpp"
#include "memory/universe.inline.hpp"
#include "memory/universe.inline.hpp"
#include "oops/fieldStreams.hpp"
#include "oops/fieldStreams.hpp"
...
@@ -665,8 +666,51 @@ JVM_END
...
@@ -665,8 +666,51 @@ JVM_END
JVM_ENTRY
(
jclass
,
JVM_GetCallerClass
(
JNIEnv
*
env
,
int
depth
))
JVM_ENTRY
(
jclass
,
JVM_GetCallerClass
(
JNIEnv
*
env
,
int
depth
))
JVMWrapper
(
"JVM_GetCallerClass"
);
JVMWrapper
(
"JVM_GetCallerClass"
);
Klass
*
k
=
thread
->
security_get_caller_class
(
depth
);
return
(
k
==
NULL
)
?
NULL
:
(
jclass
)
JNIHandles
::
make_local
(
env
,
k
->
java_mirror
());
// Pre-JDK 8 and early builds of JDK 8 don't have a CallerSensitive annotation.
if
(
SystemDictionary
::
reflect_CallerSensitive_klass
()
==
NULL
)
{
Klass
*
k
=
thread
->
security_get_caller_class
(
depth
);
return
(
k
==
NULL
)
?
NULL
:
(
jclass
)
JNIHandles
::
make_local
(
env
,
k
->
java_mirror
());
}
else
{
// Basic handshaking with Java_sun_reflect_Reflection_getCallerClass
assert
(
depth
==
-
1
,
"wrong handshake depth"
);
}
// Getting the class of the caller frame.
//
// The call stack at this point looks something like this:
//
// [0] [ @CallerSensitive public sun.reflect.Reflection.getCallerClass ]
// [1] [ @CallerSensitive API.method ]
// [.] [ (skipped intermediate frames) ]
// [n] [ caller ]
vframeStream
vfst
(
thread
);
// Cf. LibraryCallKit::inline_native_Reflection_getCallerClass
for
(
int
n
=
0
;
!
vfst
.
at_end
();
vfst
.
security_next
(),
n
++
)
{
Method
*
m
=
vfst
.
method
();
assert
(
m
!=
NULL
,
"sanity"
);
switch
(
n
)
{
case
0
:
// This must only be called from Reflection.getCallerClass
if
(
m
->
intrinsic_id
()
!=
vmIntrinsics
::
_getCallerClass
)
{
THROW_MSG_NULL
(
vmSymbols
::
java_lang_InternalError
(),
"JVM_GetCallerClass must only be called from Reflection.getCallerClass"
);
}
// fall-through
case
1
:
// Frame 0 and 1 must be caller sensitive.
if
(
!
m
->
caller_sensitive
())
{
THROW_MSG_NULL
(
vmSymbols
::
java_lang_InternalError
(),
err_msg
(
"CallerSensitive annotation expected at frame %d"
,
n
));
}
break
;
default:
if
(
!
m
->
is_ignored_by_security_stack_walk
())
{
// We have reached the desired frame; return the holder class.
return
(
jclass
)
JNIHandles
::
make_local
(
env
,
m
->
method_holder
()
->
java_mirror
());
}
break
;
}
}
return
NULL
;
JVM_END
JVM_END
...
@@ -3160,11 +3204,24 @@ JVM_ENTRY(jobjectArray, JVM_GetClassContext(JNIEnv *env))
...
@@ -3160,11 +3204,24 @@ JVM_ENTRY(jobjectArray, JVM_GetClassContext(JNIEnv *env))
KlassLink
*
first
=
NULL
;
KlassLink
*
first
=
NULL
;
KlassLink
*
last
=
NULL
;
KlassLink
*
last
=
NULL
;
int
depth
=
0
;
int
depth
=
0
;
vframeStream
vfst
(
thread
);
for
(
vframeStream
vfst
(
thread
);
!
vfst
.
at_end
();
vfst
.
security_get_caller_frame
(
1
))
{
if
(
SystemDictionary
::
reflect_CallerSensitive_klass
()
!=
NULL
)
{
// This must only be called from SecurityManager.getClassContext
Method
*
m
=
vfst
.
method
();
if
(
!
(
m
->
method_holder
()
==
SystemDictionary
::
SecurityManager_klass
()
&&
m
->
name
()
==
vmSymbols
::
getClassContext_name
()
&&
m
->
signature
()
==
vmSymbols
::
void_class_array_signature
()))
{
THROW_MSG_NULL
(
vmSymbols
::
java_lang_InternalError
(),
"JVM_GetClassContext must only be called from SecurityManager.getClassContext"
);
}
}
// Collect method holders
for
(;
!
vfst
.
at_end
();
vfst
.
security_next
())
{
Method
*
m
=
vfst
.
method
();
// Native frames are not returned
// Native frames are not returned
if
(
!
vfst
.
method
()
->
is_native
())
{
if
(
!
m
->
is_ignored_by_security_stack_walk
()
&&
!
m
->
is_native
())
{
Klass
*
holder
=
vfst
.
method
()
->
method_holder
();
Klass
*
holder
=
m
->
method_holder
();
assert
(
holder
->
is_klass
(),
"just checking"
);
assert
(
holder
->
is_klass
(),
"just checking"
);
depth
++
;
depth
++
;
KlassLink
*
l
=
new
KlassLink
(
KlassHandle
(
thread
,
holder
));
KlassLink
*
l
=
new
KlassLink
(
KlassHandle
(
thread
,
holder
));
...
...
src/share/vm/prims/methodHandles.cpp
浏览文件 @
7b61dfe4
...
@@ -105,14 +105,15 @@ void MethodHandles::set_enabled(bool z) {
...
@@ -105,14 +105,15 @@ void MethodHandles::set_enabled(bool z) {
// import java_lang_invoke_MemberName.*
// import java_lang_invoke_MemberName.*
enum
{
enum
{
IS_METHOD
=
java_lang_invoke_MemberName
::
MN_IS_METHOD
,
IS_METHOD
=
java_lang_invoke_MemberName
::
MN_IS_METHOD
,
IS_CONSTRUCTOR
=
java_lang_invoke_MemberName
::
MN_IS_CONSTRUCTOR
,
IS_CONSTRUCTOR
=
java_lang_invoke_MemberName
::
MN_IS_CONSTRUCTOR
,
IS_FIELD
=
java_lang_invoke_MemberName
::
MN_IS_FIELD
,
IS_FIELD
=
java_lang_invoke_MemberName
::
MN_IS_FIELD
,
IS_TYPE
=
java_lang_invoke_MemberName
::
MN_IS_TYPE
,
IS_TYPE
=
java_lang_invoke_MemberName
::
MN_IS_TYPE
,
CALLER_SENSITIVE
=
java_lang_invoke_MemberName
::
MN_CALLER_SENSITIVE
,
REFERENCE_KIND_SHIFT
=
java_lang_invoke_MemberName
::
MN_REFERENCE_KIND_SHIFT
,
REFERENCE_KIND_SHIFT
=
java_lang_invoke_MemberName
::
MN_REFERENCE_KIND_SHIFT
,
REFERENCE_KIND_MASK
=
java_lang_invoke_MemberName
::
MN_REFERENCE_KIND_MASK
,
REFERENCE_KIND_MASK
=
java_lang_invoke_MemberName
::
MN_REFERENCE_KIND_MASK
,
SEARCH_SUPERCLASSES
=
java_lang_invoke_MemberName
::
MN_SEARCH_SUPERCLASSES
,
SEARCH_SUPERCLASSES
=
java_lang_invoke_MemberName
::
MN_SEARCH_SUPERCLASSES
,
SEARCH_INTERFACES
=
java_lang_invoke_MemberName
::
MN_SEARCH_INTERFACES
,
SEARCH_INTERFACES
=
java_lang_invoke_MemberName
::
MN_SEARCH_INTERFACES
,
ALL_KINDS
=
IS_METHOD
|
IS_CONSTRUCTOR
|
IS_FIELD
|
IS_TYPE
ALL_KINDS
=
IS_METHOD
|
IS_CONSTRUCTOR
|
IS_FIELD
|
IS_TYPE
};
};
...
@@ -207,10 +208,15 @@ oop MethodHandles::init_method_MemberName(oop mname_oop, Method* m, bool do_disp
...
@@ -207,10 +208,15 @@ oop MethodHandles::init_method_MemberName(oop mname_oop, Method* m, bool do_disp
vmindex
=
m
->
vtable_index
();
vmindex
=
m
->
vtable_index
();
}
}
java_lang_invoke_MemberName
::
set_flags
(
mname_oop
,
flags
);
// @CallerSensitive annotation detected
if
(
m
->
caller_sensitive
())
{
flags
|=
CALLER_SENSITIVE
;
}
java_lang_invoke_MemberName
::
set_flags
(
mname_oop
,
flags
);
java_lang_invoke_MemberName
::
set_vmtarget
(
mname_oop
,
m
);
java_lang_invoke_MemberName
::
set_vmtarget
(
mname_oop
,
m
);
java_lang_invoke_MemberName
::
set_vmindex
(
mname_oop
,
vmindex
);
// vtable/itable index
java_lang_invoke_MemberName
::
set_vmindex
(
mname_oop
,
vmindex
);
// vtable/itable index
java_lang_invoke_MemberName
::
set_clazz
(
mname_oop
,
receiver_limit
->
java_mirror
());
java_lang_invoke_MemberName
::
set_clazz
(
mname_oop
,
receiver_limit
->
java_mirror
());
// Note: name and type can be lazily computed by resolve_MemberName,
// Note: name and type can be lazily computed by resolve_MemberName,
// if Java code needs them as resolved String and MethodType objects.
// if Java code needs them as resolved String and MethodType objects.
// The clazz must be eagerly stored, because it provides a GC
// The clazz must be eagerly stored, because it provides a GC
...
@@ -940,6 +946,7 @@ JVM_END
...
@@ -940,6 +946,7 @@ JVM_END
template(java_lang_invoke_MemberName,MN_IS_CONSTRUCTOR) \
template(java_lang_invoke_MemberName,MN_IS_CONSTRUCTOR) \
template(java_lang_invoke_MemberName,MN_IS_FIELD) \
template(java_lang_invoke_MemberName,MN_IS_FIELD) \
template(java_lang_invoke_MemberName,MN_IS_TYPE) \
template(java_lang_invoke_MemberName,MN_IS_TYPE) \
template(java_lang_invoke_MemberName,MN_CALLER_SENSITIVE) \
template(java_lang_invoke_MemberName,MN_SEARCH_SUPERCLASSES) \
template(java_lang_invoke_MemberName,MN_SEARCH_SUPERCLASSES) \
template(java_lang_invoke_MemberName,MN_SEARCH_INTERFACES) \
template(java_lang_invoke_MemberName,MN_SEARCH_INTERFACES) \
template(java_lang_invoke_MemberName,MN_REFERENCE_KIND_SHIFT) \
template(java_lang_invoke_MemberName,MN_REFERENCE_KIND_SHIFT) \
...
...
src/share/vm/prims/unsafe.cpp
浏览文件 @
7b61dfe4
此差异已折叠。
点击以展开。
src/share/vm/runtime/vframe.cpp
浏览文件 @
7b61dfe4
...
@@ -391,40 +391,27 @@ vframeStream::vframeStream(JavaThread* thread, frame top_frame,
...
@@ -391,40 +391,27 @@ vframeStream::vframeStream(JavaThread* thread, frame top_frame,
// Step back n frames, skip any pseudo frames in between.
// Step back n frames, skip any pseudo frames in between.
// This function is used in Class.forName, Class.newInstance, Method.Invoke,
// This function is used in Class.forName, Class.newInstance, Method.Invoke,
// AccessController.doPrivileged.
// AccessController.doPrivileged.
//
// NOTE that in JDK 1.4 this has been exposed to Java as
// sun.reflect.Reflection.getCallerClass(), which can be inlined.
// Inlined versions must match this routine's logic.
// Native method prefixing logic does not need to match since
// the method names don't match and inlining will not occur.
// See, for example,
// Parse::inline_native_Reflection_getCallerClass in
// opto/library_call.cpp.
void
vframeStreamCommon
::
security_get_caller_frame
(
int
depth
)
{
void
vframeStreamCommon
::
security_get_caller_frame
(
int
depth
)
{
bool
use_new_reflection
=
JDK_Version
::
is_gte_jdk14x_version
()
&&
UseNewReflection
;
assert
(
depth
>=
0
,
err_msg
(
"invalid depth: %d"
,
depth
));
for
(
int
n
=
0
;
!
at_end
();
security_next
())
{
while
(
!
at_end
())
{
if
(
!
method
()
->
is_ignored_by_security_stack_walk
())
{
if
(
Universe
::
reflect_invoke_cache
()
->
is_same_method
(
method
()))
{
if
(
n
==
depth
)
{
// This is Method.invoke() -- skip it
// We have reached the desired depth; return.
}
else
if
(
use_new_reflection
&&
return
;
method
()
->
method_holder
()
->
is_subclass_of
(
SystemDictionary
::
reflect_MethodAccessorImpl_klass
()))
{
// This is an auxilary frame -- skip it
}
else
if
(
method
()
->
is_method_handle_intrinsic
()
||
method
()
->
is_compiled_lambda_form
())
{
// This is an internal adapter frame for method handles -- skip it
}
else
{
// This is non-excluded frame, we need to count it against the depth
if
(
depth
--
<=
0
)
{
// we have reached the desired depth, we are done
break
;
}
}
n
++
;
// this is a non-skipped frame; count it against the depth
}
}
if
(
method
()
->
is_prefixed_native
())
{
}
skip_prefixed_method_and_wrappers
();
// NOTE: At this point there were not enough frames on the stack
}
else
{
// to walk to depth. Callers of this method have to check for at_end.
next
();
}
}
void
vframeStreamCommon
::
security_next
()
{
if
(
method
()
->
is_prefixed_native
())
{
skip_prefixed_method_and_wrappers
();
// calls next()
}
else
{
next
();
}
}
}
}
...
...
src/share/vm/runtime/vframe.hpp
浏览文件 @
7b61dfe4
...
@@ -336,6 +336,7 @@ class vframeStreamCommon : StackObj {
...
@@ -336,6 +336,7 @@ class vframeStreamCommon : StackObj {
_frame
=
_frame
.
sender
(
&
_reg_map
);
_frame
=
_frame
.
sender
(
&
_reg_map
);
}
while
(
!
fill_from_frame
());
}
while
(
!
fill_from_frame
());
}
}
void
security_next
();
bool
at_end
()
const
{
return
_mode
==
at_end_mode
;
}
bool
at_end
()
const
{
return
_mode
==
at_end_mode
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录