use of org.graalvm.word.Pointer in project graal by oracle.
the class JavaStackWalker method walkThread.
@AlwaysInline("avoid virtual call to visitor")
public static boolean walkThread(IsolateThread thread, StackFrameVisitor visitor) {
JavaFrameAnchor anchor = JavaFrameAnchors.getFrameAnchor(thread);
Pointer sp = WordFactory.nullPointer();
CodePointer ip = WordFactory.nullPointer();
if (anchor.isNonNull()) {
sp = anchor.getLastJavaSP();
ip = FrameAccess.readReturnAddress(sp);
}
// always call doWalk() to invoke visitor's methods
return doWalk(anchor, sp, ip, visitor);
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class SubstrateMemoryAccessProviderImpl method readPrimitiveConstant.
@Override
public JavaConstant readPrimitiveConstant(JavaKind kind, Constant baseConstant, long displacement, int bits) {
SignedWord offset = WordFactory.signed(displacement);
long rawValue;
if (baseConstant instanceof SubstrateObjectConstant) {
Object baseObject = ((SubstrateObjectConstant) baseConstant).getObject();
assert baseObject != null : "SubstrateObjectConstant does not wrap null value";
switch(bits) {
case Byte.SIZE:
rawValue = BarrieredAccess.readByte(baseObject, offset);
break;
case Short.SIZE:
rawValue = BarrieredAccess.readShort(baseObject, offset);
break;
case Integer.SIZE:
rawValue = BarrieredAccess.readInt(baseObject, offset);
break;
case Long.SIZE:
rawValue = BarrieredAccess.readLong(baseObject, offset);
break;
default:
throw shouldNotReachHere();
}
} else if (baseConstant instanceof PrimitiveConstant) {
PrimitiveConstant prim = (PrimitiveConstant) baseConstant;
if (!prim.getJavaKind().isNumericInteger()) {
return null;
}
Pointer basePointer = WordFactory.unsigned(prim.asLong());
if (basePointer.equal(0)) {
return null;
}
switch(bits) {
case Byte.SIZE:
rawValue = basePointer.readByte(offset);
break;
case Short.SIZE:
rawValue = basePointer.readShort(offset);
break;
case Integer.SIZE:
rawValue = basePointer.readInt(offset);
break;
case Long.SIZE:
rawValue = basePointer.readLong(offset);
break;
default:
throw shouldNotReachHere();
}
} else {
return null;
}
return toConstant(kind, rawValue);
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class ClassHistogramVisitor method initializeClassList.
/*
* This can be "interruptible" because all the pointers are to boot image heap objects, which do
* not move. In particular, it can allocate.
*/
private void initializeClassList(Object firstObject, Object lastObject) {
if ((firstObject == null) || (lastObject == null)) {
return;
}
final Pointer firstPointer = Word.objectToUntrackedPointer(firstObject);
final Pointer lastPointer = Word.objectToUntrackedPointer(lastObject);
Pointer currentPointer = firstPointer;
while (currentPointer.belowOrEqual(lastPointer)) {
Object currentObject = KnownIntrinsics.convertUnknownValue(currentPointer.toObject(), Object.class);
if ((currentObject != null) && (currentObject instanceof Class<?>)) {
classList.add((Class<?>) currentObject);
}
currentPointer = LayoutEncoding.getObjectEnd(currentObject);
}
}
use of org.graalvm.word.Pointer 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 org.graalvm.word.Pointer in project graal by oracle.
the class RealLog method hexdump.
@Override
public Log hexdump(PointerBase from, int wordSize, int numWords) {
Pointer base = WordFactory.pointer(from.rawValue());
int sanitizedWordsize = wordSize > 0 ? Integer.highestOneBit(Math.min(wordSize, 8)) : 2;
for (int offset = 0; offset < sanitizedWordsize * numWords; offset += sanitizedWordsize) {
if (offset % 16 == 0) {
zhex(base.add(offset).rawValue());
string(":");
}
string(" ");
switch(sanitizedWordsize) {
case 1:
zhex(base.readByte(offset));
break;
case 2:
zhex(base.readShort(offset));
break;
case 4:
zhex(base.readInt(offset));
break;
case 8:
zhex(base.readLong(offset));
break;
}
if ((offset + sanitizedWordsize) % 16 == 0) {
newline();
}
}
return this;
}
Aggregations