Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit aa79ad0

Browse files
Crema: detect caller sensitive methods
1 parent 7efc385 commit aa79ad0

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

‎substratevm/src/com.oracle.svm.interpreter.metadata/src/com/oracle/svm/interpreter/metadata/InterpreterResolvedJavaMethod.java‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
package com.oracle.svm.interpreter.metadata;
2626

27+
import static com.oracle.svm.espresso.classfile.Constants.ACC_CALLER_SENSITIVE;
2728
import static com.oracle.svm.espresso.classfile.Constants.ACC_FINAL;
2829
import static com.oracle.svm.espresso.classfile.Constants.ACC_NATIVE;
2930
import static com.oracle.svm.espresso.classfile.Constants.ACC_SIGNATURE_POLYMORPHIC;
@@ -42,6 +43,7 @@
4243
import java.util.Set;
4344
import java.util.function.Function;
4445

46+
import org.graalvm.nativeimage.AnnotationAccess;
4547
import org.graalvm.nativeimage.Platform;
4648
import org.graalvm.nativeimage.Platforms;
4749

@@ -63,6 +65,7 @@
6365
import com.oracle.svm.espresso.shared.meta.SignaturePolymorphicIntrinsic;
6466
import com.oracle.svm.espresso.shared.vtable.PartialMethod;
6567
import com.oracle.svm.interpreter.metadata.serialization.VisibleForSerialization;
68+
import com.oracle.svm.util.ReflectionUtil;
6669

6770
import jdk.graal.compiler.word.Word;
6871
import jdk.vm.ci.meta.Constant;
@@ -80,6 +83,9 @@
8083
* also abstract methods for vtable calls.
8184
*/
8285
public class InterpreterResolvedJavaMethod implements ResolvedJavaMethod, CremaMethodAccess, ResolvedMember {
86+
@Platforms(Platform.HOSTED_ONLY.class)//
87+
@SuppressWarnings("unchecked") //
88+
private static final Class<? extends Annotation> CALLER_SENSITIVE_CLASS = (Class<? extends Annotation>) ReflectionUtil.lookupClass("jdk.internal.reflect.CallerSensitive");
8389
/**
8490
* This flag denotes a method that was originally native but was substituted by a non-native
8591
* method.
@@ -305,9 +311,16 @@ private static int createFlags(int modifiers, InterpreterResolvedObjectType decl
305311
if (isSubstitutedNative) {
306312
newModifiers |= ACC_SUBSTITUTED_NATIVE;
307313
}
314+
if (AnnotationAccess.isAnnotationPresent(originalMethod, CALLER_SENSITIVE_CLASS)) {
315+
newModifiers |= ACC_CALLER_SENSITIVE;
316+
}
308317
return newModifiers;
309318
}
310319

320+
public final boolean isCallerSensitive() {
321+
return (flags & ACC_CALLER_SENSITIVE) != 0;
322+
}
323+
311324
@Override
312325
public final boolean isDeclaredSignaturePolymorphic() {
313326
// Note: might not be true for the instantiation of polymorphic signature intrinsics.

‎substratevm/src/com.oracle.svm.interpreter/src/com/oracle/svm/interpreter/CremaSupportImpl.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
package com.oracle.svm.interpreter;
2626

27+
import static com.oracle.svm.core.methodhandles.Target_java_lang_invoke_MethodHandleNatives_Constants.MN_CALLER_SENSITIVE;
2728
import static com.oracle.svm.core.methodhandles.Target_java_lang_invoke_MethodHandleNatives_Constants.MN_IS_CONSTRUCTOR;
2829
import static com.oracle.svm.core.methodhandles.Target_java_lang_invoke_MethodHandleNatives_Constants.MN_IS_FIELD;
2930
import static com.oracle.svm.core.methodhandles.Target_java_lang_invoke_MethodHandleNatives_Constants.MN_IS_METHOD;
@@ -850,7 +851,9 @@ private static void plantResolvedMethod(Target_java_lang_invoke_MemberName mn,
850851
private static int getMethodFlags(ResolvedCall<InterpreterResolvedJavaType, InterpreterResolvedJavaMethod, InterpreterResolvedJavaField> resolvedCall) {
851852
InterpreterResolvedJavaMethod resolvedMethod = resolvedCall.getResolvedMethod();
852853
int flags = resolvedMethod.getModifiers();
853-
// MN_CALLER_SENSITIVE should be added for caller-sensitive methods GR-68603
854+
if (resolvedMethod.isCallerSensitive()) {
855+
flags |= MN_CALLER_SENSITIVE;
856+
}
854857
if (resolvedMethod.isConstructor() || resolvedMethod.isClassInitializer()) {
855858
flags |= MN_IS_CONSTRUCTOR;
856859
flags |= (REF_newInvokeSpecial << MN_REFERENCE_KIND_SHIFT);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /