Search in sources :

Example 1 with WordBase

use of org.graalvm.word.WordBase in project graal by oracle.

the class VMThreadLocalInfosFeature method dumpToLog.

public static void dumpToLog(Log log, IsolateThread thread) {
    for (VMThreadLocalInfo info : ImageSingletons.lookup(VMThreadLocalInfos.class).infos) {
        log.signed(info.offset).string(" (").signed(info.sizeInBytes).string(" bytes): ").string(info.name).string(" = ");
        if (info.threadLocalClass == FastThreadLocalInt.class) {
            int value = primitiveData(thread).readInt(WordFactory.signed(info.offset));
            log.signed(value).string("  ").zhex(value);
        } else if (info.threadLocalClass == FastThreadLocalLong.class) {
            long value = primitiveData(thread).readLong(WordFactory.signed(info.offset));
            log.signed(value).string("  ").zhex(value);
        } else if (info.threadLocalClass == FastThreadLocalWord.class) {
            WordBase value = primitiveData(thread).readWord(WordFactory.signed(info.offset));
            log.signed(value).string("  ").zhex(value.rawValue());
        } else if (info.threadLocalClass == FastThreadLocalObject.class) {
            Object value = objectData(thread).readObject(WordFactory.signed(info.offset));
            if (value == null) {
                log.string("null");
            } else {
                log.string(value.getClass().getName()).string("  ").zhex(Word.objectToUntrackedPointer(value).rawValue());
            }
        } else if (info.threadLocalClass == FastThreadLocalBytes.class) {
            log.indent(true);
            log.hexdump(primitiveData(thread).add(WordFactory.signed(info.offset)), 8, info.sizeInBytes / 8);
            log.indent(false);
        } else {
            log.string("unknown class ").string(info.threadLocalClass.getName());
        }
        log.newline();
    }
}
Also used : WordBase(org.graalvm.word.WordBase)

Example 2 with WordBase

use of org.graalvm.word.WordBase in project graal by oracle.

the class AllocationSnippets method formatObjectImpl.

private static Object formatObjectImpl(Pointer memory, DynamicHub hub, UnsignedWord size, @ConstantParameter boolean constantSize, @ConstantParameter boolean fillContents, boolean rememberedSet) {
    if (fillContents) {
        emitPrefetchAllocate(memory, false);
    }
    WordBase header = ObjectHeaderImpl.getObjectHeaderImpl().formatHub(hub, rememberedSet, false);
    memory.writeWord(ConfigurationValues.getObjectLayout().getHubOffset(), header, LocationIdentity.INIT_LOCATION);
    if (fillContents) {
        UnsignedWord offset = WordFactory.unsigned(ConfigurationValues.getObjectLayout().getFirstFieldOffset());
        if (constantSize && ((size.subtract(offset).unsignedDivide(ConfigurationValues.getTarget().wordSize)).belowOrEqual(SubstrateOptions.MaxUnrolledObjectZeroingStores.getValue()))) {
            ExplodeLoopNode.explodeLoop();
        }
        while (offset.belowThan(size)) {
            memory.writeWord(offset, WordFactory.zero(), LocationIdentity.INIT_LOCATION);
            offset = offset.add(ConfigurationValues.getTarget().wordSize);
        }
    }
    return memory.toObjectNonNull();
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) WordBase(org.graalvm.word.WordBase)

Example 3 with WordBase

use of org.graalvm.word.WordBase in project graal by oracle.

the class WordTest method cast.

@Snippet
public static long cast(long input) {
    WordBase base = WordFactory.signed(input);
    UnsignedWord unsigned = (UnsignedWord) base;
    Pointer pointer = (Pointer) unsigned;
    Word word = (Word) pointer;
    return word.rawValue();
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) Word(org.graalvm.compiler.word.Word) UnsignedWord(org.graalvm.word.UnsignedWord) WordBase(org.graalvm.word.WordBase) Pointer(org.graalvm.word.Pointer) Snippet(org.graalvm.compiler.api.replacements.Snippet)

Example 4 with WordBase

use of org.graalvm.word.WordBase in project graal by oracle.

the class NativeImageHeap method writeConstant.

private void writeConstant(RelocatableBuffer buffer, int index, JavaKind kind, Object value, ObjectInfo info) {
    if (value instanceof RelocatedPointer) {
        addNonDataRelocation(buffer, index, (RelocatedPointer) value);
        return;
    }
    final JavaConstant con;
    if (value instanceof WordBase) {
        con = JavaConstant.forIntegerKind(FrameAccess.getWordKind(), ((WordBase) value).rawValue());
    } else if (value == null && kind == FrameAccess.getWordKind()) {
        con = JavaConstant.forIntegerKind(FrameAccess.getWordKind(), 0);
    } else {
        assert kind == JavaKind.Object || value != null : "primitive value must not be null";
        con = SubstrateObjectConstant.forBoxedValue(kind, value);
    }
    write(buffer, index, con, info);
}
Also used : RelocatedPointer(org.graalvm.nativeimage.c.function.RelocatedPointer) WordBase(org.graalvm.word.WordBase) JavaConstant(jdk.vm.ci.meta.JavaConstant)

Example 5 with WordBase

use of org.graalvm.word.WordBase in project graal by oracle.

the class NativeImageHeap method writeReference.

void writeReference(RelocatableBuffer buffer, int index, Object target, Object reason) {
    assert !(target instanceof WordBase) : "word values are not references";
    mustBeAligned(index);
    if (target != null) {
        ObjectInfo targetInfo = objects.get(target);
        verifyTargetDidNotChange(target, reason, targetInfo);
        if (useHeapBase()) {
            CompressEncoding compressEncoding = ImageSingletons.lookup(CompressEncoding.class);
            int shift = compressEncoding.getShift();
            writePointer(buffer, index, targetInfo.getOffsetInSection() >>> shift);
        } else {
            buffer.addDirectRelocationWithoutAddend(index, objectSize(), target);
        }
    }
}
Also used : WordBase(org.graalvm.word.WordBase) CompressEncoding(org.graalvm.compiler.core.common.CompressEncoding)

Aggregations

WordBase (org.graalvm.word.WordBase)9 UnsignedWord (org.graalvm.word.UnsignedWord)4 Snippet (org.graalvm.compiler.api.replacements.Snippet)2 Pointer (org.graalvm.word.Pointer)2 AnalysisType (com.oracle.graal.pointsto.meta.AnalysisType)1 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)1 CEntryPointOptions (com.oracle.svm.core.c.function.CEntryPointOptions)1 DynamicHub (com.oracle.svm.core.hub.DynamicHub)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 JavaConstant (jdk.vm.ci.meta.JavaConstant)1 CompressEncoding (org.graalvm.compiler.core.common.CompressEncoding)1 Word (org.graalvm.compiler.word.Word)1 PinnedObject (org.graalvm.nativeimage.PinnedObject)1 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)1 RelocatedPointer (org.graalvm.nativeimage.c.function.RelocatedPointer)1 CIntPointer (org.graalvm.nativeimage.c.type.CIntPointer)1