Search in sources :

Example 26 with Substitute

use of com.oracle.svm.core.annotate.Substitute in project graal by oracle.

the class DynamicHub method getDeclaredAnnotations.

@Substitute
@Override
public Annotation[] getDeclaredAnnotations() {
    Map<Annotation, Void> superAnnotations = new IdentityHashMap<>();
    if (getSuperHub() != null) {
        for (Annotation annotation : getSuperHub().getAnnotations()) {
            superAnnotations.put(annotation, null);
        }
    }
    ArrayList<Annotation> annotations = new ArrayList<>();
    for (Annotation annotation : getAnnotations()) {
        if (!superAnnotations.containsKey(annotation)) {
            annotations.add(annotation);
        }
    }
    return annotations.toArray(new Annotation[annotations.size()]);
}
Also used : IdentityHashMap(java.util.IdentityHashMap) ArrayList(java.util.ArrayList) Annotation(java.lang.annotation.Annotation) Substitute(com.oracle.svm.core.annotate.Substitute)

Example 27 with Substitute

use of com.oracle.svm.core.annotate.Substitute in project graal by oracle.

the class JavaLangSubstitutions method identityHashCode.

@Substitute
private static int identityHashCode(Object obj) {
    if (obj == null) {
        return 0;
    }
    DynamicHub hub = KnownIntrinsics.readHub(obj);
    int hashCodeOffset = hub.getHashCodeOffset();
    if (hashCodeOffset == 0) {
        throw VMError.shouldNotReachHere("identityHashCode called on illegal object");
    }
    UnsignedWord hashCodeOffsetWord = WordFactory.unsigned(hashCodeOffset);
    int hashCode = ObjectAccess.readInt(obj, hashCodeOffsetWord);
    if (hashCode != 0) {
        return hashCode;
    }
    /* On the first invocation for an object create a new hash code. */
    hashCode = IdentityHashCodeSupport.generateHashCode();
    if (!UnsafeAccess.UNSAFE.compareAndSwapInt(obj, hashCodeOffset, 0, hashCode)) {
        /* We lost the race, so there now must be a hash code installed from another thread. */
        hashCode = ObjectAccess.readInt(obj, hashCodeOffsetWord);
    }
    VMError.guarantee(hashCode != 0, "Missing identity hash code");
    return hashCode;
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) DynamicHub(com.oracle.svm.core.hub.DynamicHub) Substitute(com.oracle.svm.core.annotate.Substitute)

Example 28 with Substitute

use of com.oracle.svm.core.annotate.Substitute in project graal by oracle.

the class JavaLangSubstitutions method fillInStackTrace.

@Substitute
@NeverInline("Prevent inlining in Truffle compilations")
private Object fillInStackTrace() {
    Pointer sp = KnownIntrinsics.readCallerStackPointer();
    CodePointer ip = KnownIntrinsics.readReturnAddress();
    StackTraceBuilder stackTraceBuilder = new StackTraceBuilder();
    JavaStackWalker.walkCurrentThread(sp, ip, stackTraceBuilder);
    this.stackTrace = stackTraceBuilder.getTrace();
    return this;
}
Also used : CodePointer(org.graalvm.nativeimage.c.function.CodePointer) Pointer(org.graalvm.word.Pointer) CodePointer(org.graalvm.nativeimage.c.function.CodePointer) NeverInline(com.oracle.svm.core.annotate.NeverInline) Substitute(com.oracle.svm.core.annotate.Substitute)

Example 29 with Substitute

use of com.oracle.svm.core.annotate.Substitute in project graal by oracle.

the class SecuritySubstitutions method getContext.

@Substitute
private static AccessControlContext getContext() {
    AccessControlContext result = new AccessControlContext(new ProtectionDomain[0]);
    KnownIntrinsics.unsafeCast(result, Target_java_security_AccessControlContext.class).isPrivileged = true;
    return result;
}
Also used : AccessControlContext(java.security.AccessControlContext) Substitute(com.oracle.svm.core.annotate.Substitute)

Example 30 with Substitute

use of com.oracle.svm.core.annotate.Substitute in project graal by oracle.

the class CharsetSubstitutions method lookup.

@Substitute
private static Charset lookup(String charsetName) {
    if (charsetName == null) {
        throw new IllegalArgumentException("Null charset name");
    }
    Map<String, Charset> charsets = ImageSingletons.lookup(LocalizationSupport.class).charsets;
    String lowerCaseName = Target_sun_nio_cs_FastCharsetProvider.toLower(charsetName);
    Charset result = charsets.get(lowerCaseName);
    if (result == null) {
        /* Only need to check the name if we didn't find a charset for it */
        checkName(charsetName);
    }
    return result;
}
Also used : Charset(java.nio.charset.Charset) Substitute(com.oracle.svm.core.annotate.Substitute)

Aggregations

Substitute (com.oracle.svm.core.annotate.Substitute)69 CCharPointer (org.graalvm.nativeimage.c.type.CCharPointer)18 SocketException (java.net.SocketException)11 IOException (java.io.IOException)10 CIntPointer (org.graalvm.nativeimage.c.type.CIntPointer)10 PinnedObject (org.graalvm.nativeimage.PinnedObject)9 Util_java_io_FileDescriptor (com.oracle.svm.core.posix.PosixOSInterface.Util_java_io_FileDescriptor)8 FileDescriptor (java.io.FileDescriptor)8 CCharPointerHolder (org.graalvm.nativeimage.c.type.CTypeConversion.CCharPointerHolder)8 ServerSocket (java.net.ServerSocket)7 Socket (com.oracle.svm.core.posix.headers.Socket)6 NativeTruffleContext (com.oracle.svm.truffle.nfi.NativeAPI.NativeTruffleContext)6 SignedWord (org.graalvm.word.SignedWord)6 InterruptedIOException (java.io.InterruptedIOException)5 Time.timeval (com.oracle.svm.core.posix.headers.Time.timeval)4 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)3 Stat.fstat (com.oracle.svm.core.posix.headers.Stat.fstat)3 Stat.stat (com.oracle.svm.core.posix.headers.Stat.stat)3 Time.timezone (com.oracle.svm.core.posix.headers.Time.timezone)3 LibFFI.ffi_cif (com.oracle.svm.truffle.nfi.libffi.LibFFI.ffi_cif)3