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()]);
}
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;
}
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;
}
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;
}
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;
}
Aggregations