Search in sources :

Example 1 with MethodSubstitution

use of org.graalvm.compiler.api.replacements.MethodSubstitution in project graal by oracle.

the class SHA2Substitutions method implCompress0.

@MethodSubstitution(isStatic = false)
static void implCompress0(Object receiver, byte[] buf, int ofs) {
    Object realReceiver = PiNode.piCastNonNull(receiver, shaClass);
    Object state = RawLoadNode.load(realReceiver, stateOffset, JavaKind.Object, LocationIdentity.any());
    Word bufAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(buf, getArrayBaseOffset(JavaKind.Byte) + ofs));
    Word stateAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(state, getArrayBaseOffset(JavaKind.Int)));
    HotSpotBackend.sha2ImplCompressStub(bufAddr, stateAddr);
}
Also used : Word(org.graalvm.compiler.word.Word) MethodSubstitution(org.graalvm.compiler.api.replacements.MethodSubstitution)

Example 2 with MethodSubstitution

use of org.graalvm.compiler.api.replacements.MethodSubstitution in project graal by oracle.

the class SHASubstitutions method implCompress0.

@MethodSubstitution(isStatic = false)
static void implCompress0(Object receiver, byte[] buf, int ofs) {
    Object realReceiver = PiNode.piCastNonNull(receiver, shaClass);
    Object state = RawLoadNode.load(realReceiver, stateOffset, JavaKind.Object, LocationIdentity.any());
    Word bufAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(buf, getArrayBaseOffset(JavaKind.Byte) + ofs));
    Word stateAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(state, getArrayBaseOffset(JavaKind.Int)));
    HotSpotBackend.shaImplCompressStub(bufAddr, stateAddr);
}
Also used : Word(org.graalvm.compiler.word.Word) MethodSubstitution(org.graalvm.compiler.api.replacements.MethodSubstitution)

Example 3 with MethodSubstitution

use of org.graalvm.compiler.api.replacements.MethodSubstitution in project graal by oracle.

the class HotSpotClassSubstitutions method getSuperclass.

@MethodSubstitution(isStatic = false)
public static Class<?> getSuperclass(final Class<?> thisObj) {
    KlassPointer klass = ClassGetHubNode.readClass(thisObj);
    if (!klass.isNull()) {
        KlassPointer klassNonNull = ClassGetHubNode.piCastNonNull(klass, SnippetAnchorNode.anchor());
        int accessFlags = klassNonNull.readInt(klassAccessFlagsOffset(INJECTED_VMCONFIG), KLASS_ACCESS_FLAGS_LOCATION);
        if ((accessFlags & Modifier.INTERFACE) == 0) {
            if (klassIsArray(klassNonNull)) {
                return Object.class;
            } else {
                KlassPointer superKlass = klassNonNull.readKlassPointer(klassSuperKlassOffset(INJECTED_VMCONFIG), KLASS_SUPER_KLASS_LOCATION);
                if (superKlass.isNull()) {
                    return null;
                } else {
                    KlassPointer superKlassNonNull = ClassGetHubNode.piCastNonNull(superKlass, SnippetAnchorNode.anchor());
                    return HubGetClassNode.readClass(superKlassNonNull);
                }
            }
        }
    } else {
    // Class for primitive type
    }
    return null;
}
Also used : KlassPointer(org.graalvm.compiler.hotspot.word.KlassPointer) MethodSubstitution(org.graalvm.compiler.api.replacements.MethodSubstitution)

Example 4 with MethodSubstitution

use of org.graalvm.compiler.api.replacements.MethodSubstitution in project graal by oracle.

the class HotSpotUnsafeSubstitutions method copyMemory.

@SuppressWarnings("unused")
@MethodSubstitution(isStatic = false)
static void copyMemory(Object receiver, Object srcBase, long srcOffset, Object destBase, long destOffset, long bytes) {
    Word srcAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(srcBase, srcOffset));
    Word dstAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(destBase, destOffset));
    Word size = Word.signed(bytes);
    HotSpotBackend.unsafeArraycopy(srcAddr, dstAddr, size);
}
Also used : Word(org.graalvm.compiler.word.Word) MethodSubstitution(org.graalvm.compiler.api.replacements.MethodSubstitution)

Example 5 with MethodSubstitution

use of org.graalvm.compiler.api.replacements.MethodSubstitution in project graal by oracle.

the class AMD64StringSubstitutions method indexOf.

// Only exists in JDK <= 8
@MethodSubstitution(isStatic = true, optional = true)
public static int indexOf(char[] source, int sourceOffset, int sourceCount, @ConstantNodeParameter char[] target, int targetOffset, int targetCount, int origFromIndex) {
    int fromIndex = origFromIndex;
    if (fromIndex >= sourceCount) {
        return (targetCount == 0 ? sourceCount : -1);
    }
    if (fromIndex < 0) {
        fromIndex = 0;
    }
    if (targetCount == 0) {
        // The empty string is in every string.
        return fromIndex;
    }
    int totalOffset = sourceOffset + fromIndex;
    if (sourceCount - fromIndex < targetCount) {
        // The empty string contains nothing except the empty string.
        return -1;
    }
    assert sourceCount - fromIndex > 0 && targetCount > 0;
    Pointer sourcePointer = Word.objectToTrackedPointer(source).add(charArrayBaseOffset(INJECTED)).add(totalOffset * charArrayIndexScale(INJECTED));
    Pointer targetPointer = Word.objectToTrackedPointer(target).add(charArrayBaseOffset(INJECTED)).add(targetOffset * charArrayIndexScale(INJECTED));
    int result = AMD64StringIndexOfNode.optimizedStringIndexPointer(sourcePointer, sourceCount - fromIndex, targetPointer, targetCount);
    if (result >= 0) {
        return result + totalOffset;
    }
    return result;
}
Also used : Pointer(org.graalvm.word.Pointer) MethodSubstitution(org.graalvm.compiler.api.replacements.MethodSubstitution)

Aggregations

MethodSubstitution (org.graalvm.compiler.api.replacements.MethodSubstitution)8 Word (org.graalvm.compiler.word.Word)5 Pointer (org.graalvm.word.Pointer)2 KlassPointer (org.graalvm.compiler.hotspot.word.KlassPointer)1