use of com.oracle.svm.core.annotate.Uninterruptible in project graal by oracle.
the class LinuxSubstitutions method nanoTime.
@Substitute
@Uninterruptible(reason = "Does basic math after a simple system call")
private static long nanoTime() {
timespec timespec = StackValue.get(SizeOf.get(timespec.class));
if (clock_gettime(CLOCK_MONOTONIC(), timespec) == 0) {
return timespec.tv_sec() * 1_000_000_000L + timespec.tv_nsec();
} else {
/* High precision time is not available, fall back to low precision. */
timeval timeval = StackValue.get(SizeOf.get(timeval.class));
timezone timezone = WordFactory.nullPointer();
gettimeofday(timeval, timezone);
return timeval.tv_sec() * 1_000_000_000L + timeval.tv_usec() * 1_000L;
}
}
use of com.oracle.svm.core.annotate.Uninterruptible in project graal by oracle.
the class PthreadConditionUtils method deadlineTimespecToDelayNanos.
@Uninterruptible(reason = "Called from uninterruptible code.")
public static long deadlineTimespecToDelayNanos(Time.timespec deadlineTimespec) {
timespec currentTimespec = StackValue.get(SizeOf.get(timespec.class));
getAbsoluteTimeNanos(currentTimespec);
return TimeUtils.addOrMaxValue(deadlineTimespec.tv_nsec() - currentTimespec.tv_nsec(), TimeUtils.secondsToNanos((deadlineTimespec.tv_sec() - currentTimespec.tv_sec())));
}
use of com.oracle.svm.core.annotate.Uninterruptible in project graal by oracle.
the class PthreadConditionUtils method delayNanosToDeadlineTimespec.
/**
* Turn a delay in nanoseconds into a deadline in a Time.timespec.
*/
@Uninterruptible(reason = "Called from uninterruptible code.")
public static void delayNanosToDeadlineTimespec(long delayNanos, Time.timespec result) {
timespec currentTimespec = StackValue.get(SizeOf.get(timespec.class));
getAbsoluteTimeNanos(currentTimespec);
assert delayNanos >= 0;
long sec = TimeUtils.addOrMaxValue(currentTimespec.tv_sec(), TimeUtils.divideNanosToSeconds(delayNanos));
long nsec = currentTimespec.tv_nsec() + TimeUtils.remainderNanosToSeconds(delayNanos);
if (nsec > TimeUtils.nanosPerSecond) {
sec = TimeUtils.addOrMaxValue(sec, 1);
nsec -= TimeUtils.nanosPerSecond;
}
assert nsec < TimeUtils.nanosPerSecond;
result.set_tv_sec(sec);
result.set_tv_nsec(nsec);
}
use of com.oracle.svm.core.annotate.Uninterruptible in project graal by oracle.
the class MemoryUtil method fillToMemoryAtomic.
@Uninterruptible(reason = "Arguments may be managed objects")
public static void fillToMemoryAtomic(Pointer to, UnsignedWord size, byte value) {
UnsignedWord bits = to.or(size);
if (bits.unsignedRemainder(8).equal(0)) {
// zero-extend
long fill = value & 0xffL;
if (fill != 0) {
fill += fill << 8;
fill += fill << 16;
fill += fill << 32;
}
for (UnsignedWord offset = WordFactory.zero(); offset.belowThan(size); offset = offset.add(8)) {
to.writeLong(offset, fill);
}
} else if (bits.unsignedRemainder(4).equal(0)) {
// zero-extend
int fill = value & 0xff;
if (fill != 0) {
fill += fill << 8;
fill += fill << 16;
}
for (UnsignedWord offset = WordFactory.zero(); offset.belowThan(size); offset = offset.add(4)) {
to.writeInt(offset, fill);
}
} else if (bits.unsignedRemainder(2).equal(0)) {
// zero-extend
short fill = (short) (value & 0xff);
if (fill != 0) {
fill += fill << 8;
}
for (UnsignedWord offset = WordFactory.zero(); offset.belowThan(size); offset = offset.add(2)) {
to.writeShort(offset, fill);
}
} else {
byte fill = value;
for (UnsignedWord offset = WordFactory.zero(); offset.belowThan(size); offset = offset.add(1)) {
to.writeByte(offset, fill);
}
}
}
use of com.oracle.svm.core.annotate.Uninterruptible in project graal by oracle.
the class CEntryPointNativeFunctions method createIsolate.
@Uninterruptible(reason = UNINTERRUPTIBLE_REASON)
@CEntryPoint(name = "create_isolate", documentation = { "Create a new isolate, considering the passed parameters (which may be NULL).", "Returns 0 on success, or a non-zero value on failure.", "On success, the current thread is attached to the created isolate, and the", "address of the isolate structure is written to the passed pointer." })
@CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class, nameTransformation = NameTransformation.class)
public static int createIsolate(CEntryPointCreateIsolateParameters params, IsolatePointer isolate) {
int result = CEntryPointActions.enterCreateIsolate(params);
if (result == 0) {
isolate.write(CEntryPointContext.getCurrentIsolate());
result = CEntryPointActions.leave();
}
return result;
}
Aggregations