use of org.graalvm.compiler.word.Word in project graal by oracle.
the class CreateExceptionStub method createException.
protected static Object createException(Register threadRegister, Class<? extends Throwable> exception, KlassPointer objKlass, KlassPointer targetKlass) {
Word thread = registerAsWord(threadRegister);
throwClassCastException(THROW_CLASS_CAST_EXCEPTION, thread, classAsCString(exception), objKlass, targetKlass);
return clearPendingException(thread);
}
use of org.graalvm.compiler.word.Word in project graal by oracle.
the class ExceptionHandlerStub method exceptionHandler.
@Snippet
private static void exceptionHandler(Object exception, Word exceptionPc, @ConstantParameter Register threadRegister, @ConstantParameter OptionValues options) {
Word thread = registerAsWord(threadRegister);
checkNoExceptionInThread(thread, assertionsEnabled(INJECTED_VMCONFIG));
checkExceptionNotNull(assertionsEnabled(INJECTED_VMCONFIG), exception);
writeExceptionOop(thread, exception);
writeExceptionPc(thread, exceptionPc);
if (logging(options)) {
printf("handling exception %p (", Word.objectToTrackedPointer(exception).rawValue());
decipher(Word.objectToTrackedPointer(exception).rawValue());
printf(") at %p (", exceptionPc.rawValue());
decipher(exceptionPc.rawValue());
printf(")\n");
}
// patch throwing pc into return address so that deoptimization finds the right debug info
patchReturnAddress(exceptionPc);
Word handlerPc = exceptionHandlerForPc(EXCEPTION_HANDLER_FOR_PC, thread);
if (logging(options)) {
printf("handler for exception %p at %p is at %p (", Word.objectToTrackedPointer(exception).rawValue(), exceptionPc.rawValue(), handlerPc.rawValue());
decipher(handlerPc.rawValue());
printf(")\n");
}
// patch the return address so that this stub returns to the exception handler
jumpToExceptionHandler(handlerPc);
}
use of org.graalvm.compiler.word.Word in project graal by oracle.
the class CreateExceptionStub method createException.
protected static Object createException(Register threadRegister, Class<? extends Throwable> exception, Word message) {
Word thread = registerAsWord(threadRegister);
throwAndPostJvmtiException(THROW_AND_POST_JVMTI_EXCEPTION, thread, classAsCString(exception), message);
return clearPendingException(thread);
}
use of org.graalvm.compiler.word.Word in project graal by oracle.
the class PosixCEntryPointSnippets method enterSnippet.
@Snippet
public static int enterSnippet(IsolateThread thread) {
Isolate isolate;
if (MultiThreaded.getValue()) {
if (thread.isNull()) {
return Errors.NULL_ARGUMENT;
}
writeCurrentVMThread(thread);
isolate = PosixVMThreads.IsolateTL.get(thread);
} else {
// single-threaded
if (SpawnIsolates.getValue()) {
if (thread.isNull()) {
return Errors.NULL_ARGUMENT;
}
} else if (!thread.equal(CEntryPointSetup.SINGLE_THREAD_SENTINEL)) {
return Errors.UNATTACHED_THREAD;
}
isolate = (Isolate) ((Word) thread).subtract(CEntryPointSetup.SINGLE_ISOLATE_TO_SINGLE_THREAD_ADDEND);
}
if (UseHeapBaseRegister.getValue()) {
setHeapBase(PosixIsolates.getHeapBase(isolate));
}
if (MultiThreaded.getValue()) {
Safepoint.transitionNativeToJava();
}
return Errors.NO_ERROR;
}
use of org.graalvm.compiler.word.Word in project graal by oracle.
the class SubstrateMemoryAccessProviderImpl method readObjectConstant.
private static JavaConstant readObjectConstant(Constant baseConstant, long displacement, boolean requireCompressed) {
SignedWord offset = WordFactory.signed(displacement);
if (baseConstant instanceof SubstrateObjectConstant) {
// always compressed (if enabled)
assert !requireCompressed || ReferenceAccess.singleton().haveCompressedReferences();
Object baseObject = ((SubstrateObjectConstant) baseConstant).getObject();
assert baseObject != null : "SubstrateObjectConstant does not wrap null value";
Object rawValue = BarrieredAccess.readObject(baseObject, offset);
return SubstrateObjectConstant.forObject(rawValue, requireCompressed);
}
if (baseConstant instanceof PrimitiveConstant) {
// never compressed
assert !requireCompressed;
PrimitiveConstant prim = (PrimitiveConstant) baseConstant;
if (!prim.getJavaKind().isNumericInteger()) {
return null;
}
Word baseAddress = WordFactory.unsigned(prim.asLong());
if (baseAddress.equal(0)) {
return null;
}
Word address = baseAddress.add(offset);
Object rawValue = ReferenceAccess.singleton().readObjectAt(address, false);
return SubstrateObjectConstant.forObject(rawValue, false);
}
return null;
}
Aggregations