use of com.oracle.truffle.espresso.impl.Klass in project graal by oracle.
the class EspressoInterop method fitsInLong.
@ExportMessage
static boolean fitsInLong(StaticObject receiver) {
receiver.checkNotForeign();
if (isNull(receiver)) {
return false;
}
Klass klass = receiver.getKlass();
if (isAtMostLong(klass)) {
return true;
}
Meta meta = klass.getMeta();
if (klass == meta.java_lang_Float) {
float content = meta.java_lang_Float_value.getFloat(receiver);
return inSafeIntegerRange(content) && !isNegativeZero(content) && (long) content == content;
}
if (klass == meta.java_lang_Double) {
double content = meta.java_lang_Double_value.getDouble(receiver);
return inSafeIntegerRange(content) && !isNegativeZero(content) && (long) content == content;
}
return false;
}
use of com.oracle.truffle.espresso.impl.Klass in project graal by oracle.
the class EspressoInterop method fitsInInt.
@ExportMessage
static boolean fitsInInt(StaticObject receiver) {
receiver.checkNotForeign();
if (isNull(receiver)) {
return false;
}
Klass klass = receiver.getKlass();
if (isAtMostInt(klass)) {
return true;
}
Meta meta = klass.getMeta();
if (klass == meta.java_lang_Long) {
long content = meta.java_lang_Long_value.getLong(receiver);
return (int) content == content;
}
if (klass == meta.java_lang_Float) {
float content = meta.java_lang_Float_value.getFloat(receiver);
return inSafeIntegerRange(content) && !isNegativeZero(content) && (int) content == content;
}
if (klass == meta.java_lang_Double) {
double content = meta.java_lang_Double_value.getDouble(receiver);
return (int) content == content && !isNegativeZero(content);
}
return false;
}
use of com.oracle.truffle.espresso.impl.Klass in project graal by oracle.
the class EspressoInterop method fitsInDouble.
@ExportMessage
static boolean fitsInDouble(StaticObject receiver) {
receiver.checkNotForeign();
if (isNull(receiver)) {
return false;
}
Klass klass = receiver.getKlass();
Meta meta = klass.getMeta();
if (isAtMostInt(klass) || klass == meta.java_lang_Double) {
return true;
}
if (klass == meta.java_lang_Long) {
long content = meta.java_lang_Long_value.getLong(receiver);
double doubleContent = content;
return (long) doubleContent == content;
}
if (klass == meta.java_lang_Float) {
float content = meta.java_lang_Float_value.getFloat(receiver);
return !Float.isFinite(content) || (double) content == content;
}
return false;
}
use of com.oracle.truffle.espresso.impl.Klass in project graal by oracle.
the class Target_java_lang_Class method getSuperclass.
@Substitution(hasReceiver = true)
@JavaType(Class.class)
public static StaticObject getSuperclass(@JavaType(Class.class) StaticObject self, @Inject Meta meta) {
Klass k = self.getMirrorKlass(meta);
if (k.isInterface()) {
return StaticObject.NULL;
}
Klass superclass = k.getSuperKlass();
if (superclass == null) {
return StaticObject.NULL;
}
return superclass.mirror();
}
use of com.oracle.truffle.espresso.impl.Klass in project graal by oracle.
the class Target_sun_misc_Unsafe method defineClass.
@TruffleBoundary
@Substitution(hasReceiver = true, nameProvider = SharedUnsafeAppend0.class)
@JavaType(Class.class)
public static StaticObject defineClass(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(String.class) StaticObject name, @JavaType(byte[].class) StaticObject guestBuf, int offset, int len, @JavaType(ClassLoader.class) StaticObject loader, @JavaType(ProtectionDomain.class) StaticObject pd, @Inject Meta meta) {
byte[] buf = guestBuf.unwrap();
byte[] bytes = Arrays.copyOfRange(buf, offset, len);
Klass klass = meta.getRegistries().defineKlass(meta.getTypes().fromClassGetName(meta.toHostString(name)), bytes, loader, new ClassRegistry.ClassDefinitionInfo(pd));
return klass.mirror();
}
Aggregations