com.oracle.truffle.api.dsl.CachedContext Java Examples

The following examples show how to use com.oracle.truffle.api.dsl.CachedContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WakeHighestPriorityNode.java    From trufflesqueak with MIT License 6 votes vote down vote up
@Specialization
protected static final void doWake(final VirtualFrame frame,
                @Cached final ArrayObjectReadNode arrayReadNode,
                @Cached final ArrayObjectSizeNode arraySizeNode,
                @Cached final AbstractPointersObjectReadNode pointersReadNode,
                @Cached final AbstractPointersObjectWriteNode pointersWriteNode,
                @Cached("create(true)") final GetOrCreateContextNode contextNode,
                @Cached final GetActiveProcessNode getActiveProcessNode,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    // Return the highest priority process that is ready to run.
    // Note: It is a fatal VM error if there is no runnable process.
    final ArrayObject schedLists = pointersReadNode.executeArray(image.getScheduler(), PROCESS_SCHEDULER.PROCESS_LISTS);
    for (long p = arraySizeNode.execute(schedLists) - 1; p >= 0; p--) {
        final PointersObject processList = (PointersObject) arrayReadNode.execute(schedLists, p);
        while (!processList.isEmptyList(pointersReadNode)) {
            final PointersObject newProcess = processList.removeFirstLinkOfList(pointersReadNode, pointersWriteNode);
            final Object newContext = pointersReadNode.execute(newProcess, PROCESS.SUSPENDED_CONTEXT);
            if (newContext instanceof ContextObject) {
                contextNode.executeGet(frame).transferTo(newProcess, pointersReadNode, pointersWriteNode, getActiveProcessNode);
                throw SqueakException.create("Should not be reached");
            }
        }
    }
    throw SqueakException.create("scheduler could not find a runnable process");
}
 
Example #2
Source File: DispatchSendNode.java    From trufflesqueak with MIT License 6 votes vote down vote up
@Specialization(guards = {"!isCompiledMethodObject(targetObject)"})
protected final Object doObjectAsMethod(final VirtualFrame frame, final NativeObject selector, final Object targetObject, @SuppressWarnings("unused") final ClassObject rcvrClass,
                final Object[] rcvrAndArgs,
                @Cached final SqueakObjectClassNode classNode,
                @Shared("writeNode") @Cached final AbstractPointersObjectWriteNode writeNode,
                @Cached final LookupMethodNode lookupNode,
                @Cached("createBinaryProfile()") final ConditionProfile isDoesNotUnderstandProfile,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    final Object[] arguments = ArrayUtils.allButFirst(rcvrAndArgs);
    final ClassObject targetClass = classNode.executeLookup(targetObject);
    final Object newLookupResult = lookupNode.executeLookup(targetClass, image.runWithInSelector);
    if (isDoesNotUnderstandProfile.profile(newLookupResult == null)) {
        final Object doesNotUnderstandMethod = lookupNode.executeLookup(targetClass, image.doesNotUnderstand);
        return dispatchNode.executeDispatch(frame, (CompiledMethodObject) doesNotUnderstandMethod,
                        new Object[]{targetObject, image.newMessage(writeNode, selector, targetClass, arguments)});
    } else {
        return dispatchNode.executeDispatch(frame, (CompiledMethodObject) newLookupResult, new Object[]{targetObject, selector, image.asArrayOfObjects(arguments), rcvrAndArgs[0]});
    }
}
 
Example #3
Source File: FilePlugin.java    From trufflesqueak with MIT License 6 votes vote down vote up
@Specialization(guards = {"longIndex > 0", "nativePathName.isByteType()", "nativePathName.getByteLength() == 0"})
@TruffleBoundary(transferToInterpreterOnException = false)
protected static final Object doLookupEmptyString(@SuppressWarnings("unused") final Object receiver, @SuppressWarnings("unused") final NativeObject nativePathName, final long longIndex,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    assert OSDetector.SINGLETON.isWindows() : "Unexpected empty path on a non-Windows system.";
    final ArrayList<TruffleFile> fileList = new ArrayList<>();
    // TODO: avoid to use Path and FileSystems here.
    for (final Path path : FileSystems.getDefault().getRootDirectories()) {
        fileList.add(image.env.getPublicTruffleFile(path.toUri()));
    }
    final int index = (int) longIndex - 1;
    if (index < fileList.size()) {
        final TruffleFile file = fileList.get(index);
        // Use getPath here, getName returns empty string on root path.
        // Squeak strips the trailing backslash from C:\ on Windows.
        return newFileEntry(image, file, file.getPath().replace("\\", ""));
    } else {
        return NilObject.SINGLETON;
    }
}
 
Example #4
Source File: ArrayNode.java    From grcuda with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Specialization
Object doDefault(VirtualFrame frame,
                @CachedContext(GrCUDALanguage.class) GrCUDAContext context) {
    final CUDARuntime runtime = context.getCUDARuntime();
    long[] elementsPerDim = new long[sizeNodes.length];
    int dim = 0;
    for (ExpressionNode sizeNode : sizeNodes) {
        Object size = sizeNode.execute(frame);
        if (!(size instanceof Number)) {
            CompilerDirectives.transferToInterpreter();
            throw new GrCUDAInternalException("size in dimension " + dim + " must be a number", this);
        }
        elementsPerDim[dim] = ((Number) size).longValue();
        dim += 1;
    }
    if (sizeNodes.length == 1) {
        return new DeviceArray(runtime, elementsPerDim[0], elementType);
    } else {
        final boolean columnMajorOrder = false;
        return new MultiDimDeviceArray(runtime, elementType, elementsPerDim, columnMajorOrder);
    }
}
 
Example #5
Source File: HashemAdadBekhoonBuiltin.java    From mr-hashemi with Universal Permissive License v1.0 6 votes vote down vote up
@Specialization
public Integer adadBekhoon(@CachedContext(HashemLanguage.class) HashemContext context) {
    String input = doRead(context.getInput());
    int result = 0;
    if (input == null) {
        /*
         * We do not have a sophisticated end of file handling, so returning an empty string is
         * a reasonable alternative. Note that the Java null value should never be used, since
         * it can interfere with the specialization logic in generated source code.
         */
        result = 0;
    }
    try {
        return Integer.parseInt(input);
    } catch (NumberFormatException e) {
        throw new HashemException(String.format("%s is not a number!", input), this);
    }
}
 
Example #6
Source File: MaterializeContextOnMethodExitNode.java    From trufflesqueak with MIT License 6 votes vote down vote up
@Specialization(guards = {"image.lastSeenContext != null"})
protected static final void doMaterialize(final VirtualFrame frame,
                @Cached("createBinaryProfile()") final ConditionProfile isNotLastSeenContextProfile,
                @Cached("createBinaryProfile()") final ConditionProfile continueProfile,
                @Cached("create(true)") final GetOrCreateContextNode getOrCreateContextNode,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    final ContextObject lastSeenContext = image.lastSeenContext;
    final ContextObject context = getOrCreateContextNode.executeGet(frame);
    if (isNotLastSeenContextProfile.profile(context != lastSeenContext)) {
        assert context.hasTruffleFrame();
        if (lastSeenContext != null && !lastSeenContext.hasMaterializedSender()) {
            lastSeenContext.setSender(context);
        }
        if (continueProfile.profile(!context.isTerminated() && context.hasEscaped())) {
            // Materialization needs to continue in parent frame.
            image.lastSeenContext = context;
        } else {
            // If context has not escaped, materialization can terminate here.
            image.lastSeenContext = null;
        }
    }
}
 
Example #7
Source File: BitBltPlugin.java    From trufflesqueak with MIT License 6 votes vote down vote up
@Specialization(guards = {"startIndex >= 1", "stopIndex > 0", "aString.isByteType()", "aString.getByteLength() > 0", "stopIndex <= aString.getByteLength()"})
protected static final PointersObject doDisplayString(final PointersObject receiver, final NativeObject aString, final long startIndex, final long stopIndex,
                final ArrayObject glyphMap, final ArrayObject xTable, final long kernDelta,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    if (!glyphMap.isLongType()) {
        CompilerDirectives.transferToInterpreter();
        respecializeArrayToLongOrPrimFail(glyphMap);
    }
    if (glyphMap.getLongLength() != 256) {
        throw PrimitiveFailed.andTransferToInterpreter();
    }
    if (!xTable.isLongType()) {
        CompilerDirectives.transferToInterpreter();
        respecializeArrayToLongOrPrimFail(xTable);
    }
    image.bitblt.resetSuccessFlag();
    image.bitblt.primitiveDisplayString(receiver, aString, startIndex, stopIndex, glyphMap.getLongStorage(), xTable.getLongStorage(), (int) kernDelta);
    return receiver;
}
 
Example #8
Source File: SqueakSSL.java    From trufflesqueak with MIT License 6 votes vote down vote up
@Specialization(guards = {"sourceBuffer.isByteType()", "targetBuffer.isByteType()"})
protected static final long doConnect(@SuppressWarnings("unused") final Object receiver,
                final PointersObject sslHandle,
                final NativeObject sourceBuffer,
                final long start,
                final long length,
                final NativeObject targetBuffer,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {

    final SqSSL ssl = getSSLOrNull(sslHandle);
    if (ssl == null) {
        return ReturnCode.INVALID_STATE.id();
    }

    final ByteBuffer source = asReadBuffer(sourceBuffer, start, length);
    final ByteBuffer target = asWriteBuffer(targetBuffer);

    try {
        return processHandshake(ssl, source, target);
    } catch (final SSLException e) {
        e.printStackTrace(image.getError());
        return ReturnCode.GENERIC_ERROR.id();
    }
}
 
Example #9
Source File: IOPrimitives.java    From trufflesqueak with MIT License 6 votes vote down vote up
@Specialization
protected final PointersObject doCursor(final PointersObject receiver, final PointersObject maskObject,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image,
                @Cached("createBinaryProfile()") final ConditionProfile depthProfile) {
    if (image.hasDisplay()) {
        final int[] words = receiver.getFormBits(cursorReadNode);
        final int depth = receiver.getFormDepth(cursorReadNode);
        final int height = receiver.getFormHeight(cursorReadNode);
        final int width = receiver.getFormWidth(cursorReadNode);
        final PointersObject offset = receiver.getFormOffset(cursorReadNode);
        final int offsetX = Math.abs(offsetReadNode.executeInt(offset, POINT.X));
        final int offsetY = Math.abs(offsetReadNode.executeInt(offset, POINT.Y));
        if (depthProfile.profile(depth == 1)) {
            final int[] mask = cursorReadNode.executeNative(maskObject, FORM.BITS).getIntStorage();
            image.getDisplay().setCursor(words, mask, width, height, 2, offsetX, offsetY);
        } else {
            image.getDisplay().setCursor(words, null, width, height, depth, offsetX, offsetY);
        }
    }
    return receiver;
}
 
Example #10
Source File: FilePlugin.java    From trufflesqueak with MIT License 6 votes vote down vote up
@Specialization(guards = {"index > 0", "nativePathName.isByteType()", "nativePathName.getByteLength() > 0"})
@TruffleBoundary(transferToInterpreterOnException = false)
protected static final Object doLookup(@SuppressWarnings("unused") final Object receiver, final NativeObject nativePathName, final long index,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    String pathName = nativePathName.asStringUnsafe();
    if (OSDetector.SINGLETON.isWindows() && !pathName.endsWith("\\")) {
        pathName += "\\"; // new File("C:") will fail, we need to add a trailing backslash.
    }
    final TruffleFile directory = asPublicTruffleFile(image, pathName);
    if (!directory.isDirectory()) {
        throw PrimitiveFailed.GENERIC_ERROR;
    }
    long count = index;
    try (DirectoryStream<TruffleFile> stream = directory.newDirectoryStream()) {
        for (final TruffleFile file : stream) {
            if (count-- <= 1 && file.exists()) {
                return newFileEntry(image, file);
            }
        }
    } catch (final IOException e) {
        log("Failed to access directory", e);
        throw PrimitiveFailed.GENERIC_ERROR;
    }
    return NilObject.SINGLETON;
}
 
Example #11
Source File: PolyglotPlugin.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization(guards = "name.isByteType()")
@TruffleBoundary
public static final Object exportSymbol(@SuppressWarnings("unused") final Object receiver, final NativeObject name, final Object value,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    try {
        image.env.exportSymbol(name.asStringUnsafe(), value);
        return value;
    } catch (final SecurityException e) {
        throw primitiveFailedInInterpreterCapturing(e);
    }
}
 
Example #12
Source File: IOPrimitives.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization(guards = {"receiver.size() >= 4"})
protected static final boolean doDisplay(final PointersObject receiver,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    if (image.hasDisplay()) {
        image.setSpecialObject(SPECIAL_OBJECT.THE_DISPLAY, receiver);
        image.getDisplay().open(receiver);
        return BooleanObject.TRUE;
    } else {
        return BooleanObject.FALSE;
    }
}
 
Example #13
Source File: UnixOSProcessPlugin.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization(guards = "pathString.isByteType()")
protected static final ArrayObject doFileStat(@SuppressWarnings("unused") final Object receiver, final NativeObject pathString,
                @Cached final BranchProfile errorProfile,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    try {
        final TruffleFile file = image.env.getPublicTruffleFile(pathString.asStringUnsafe());
        final long uid = file.getOwner().hashCode();
        final long gid = file.getGroup().hashCode();
        final ArrayObject mask = getProtectionMask(image, file.getPosixPermissions());
        return image.asArrayOfObjects(uid, gid, mask);
    } catch (final IOException | UnsupportedOperationException | SecurityException e) {
        errorProfile.enter();
        throw PrimitiveFailed.GENERIC_ERROR;
    }
}
 
Example #14
Source File: LargeIntegers.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization(replaces = "doLong")
protected static final Object doLongWithOverflow(final long lhs, final long rhs,
                @Cached("createBinaryProfile()") final ConditionProfile differentSignProfile,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    if (differentSignProfile.profile(differentSign(lhs, rhs))) {
        return LargeIntegerObject.add(image, lhs, rhs);
    } else {
        return LargeIntegerObject.subtract(image, lhs, rhs);
    }
}
 
Example #15
Source File: LargeIntegers.java    From trufflesqueak with MIT License 5 votes vote down vote up
/**
 * Left to support LargeIntegerObjects adapted from NativeObjects (see
 * SecureHashAlgorithmTest>>testEmptyInput).
 */
@TruffleBoundary
@Specialization(guards = {"receiver.isByteType()", "receiver.getSqueakClass().isLargeIntegerClass()"})
protected static final Object doNativeObject(final NativeObject receiver,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    return new LargeIntegerObject(image, receiver.getSqueakClass(), receiver.getByteStorage().clone()).reduceIfPossible();
}
 
Example #16
Source File: FilePlugin.java    From trufflesqueak with MIT License 5 votes vote down vote up
@SuppressWarnings("unused")
@Specialization(guards = {"isStdoutFileDescriptor(fd)"})
protected static final Object doFlushStdout(final Object receiver, final PointersObject fd,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    flushStdioOrFail(image.env.out());
    return receiver;
}
 
Example #17
Source File: PolyglotPlugin.java    From trufflesqueak with MIT License 5 votes vote down vote up
@SuppressWarnings("unused")
@Specialization(guards = {"member.isByteType()", "lib.isMemberReadable(object, member.asStringUnsafe())",
                "lib.hasMemberReadSideEffects(object, member.asStringUnsafe())"}, limit = "2")
protected static final NativeObject doReadMemberWithSideEffects(@SuppressWarnings("unused") final Object receiver, final Object object, final NativeObject member,
                @CachedLibrary("object") final InteropLibrary lib,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    return image.asByteString("[side-effect]");
}
 
Example #18
Source File: TruffleSqueakPlugin.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization
protected static final Object printArgs(final Object receiver, final Object value,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    if (value instanceof NativeObject && ((NativeObject) value).isByteType()) {
        image.printToStdOut(((NativeObject) value).asStringUnsafe());
    } else {
        image.printToStdOut(value);
    }
    return receiver;
}
 
Example #19
Source File: MiscellaneousPrimitives.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization(guards = "!classObject.isImmediateClassType()")
protected static final AbstractSqueakObject doSomeInstance(final ClassObject classObject,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    try {
        return ObjectGraphUtils.someInstanceOf(image, classObject);
    } catch (final IndexOutOfBoundsException e) {
        throw PrimitiveFailed.GENERIC_ERROR;
    }
}
 
Example #20
Source File: HandlePrimitiveFailedNode.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization(guards = {"reasonCode < sizeNode.execute(image.primitiveErrorTable)"}, limit = "1")
protected static final void doHandleWithLookup(final VirtualFrame frame, final int reasonCode,
                @SuppressWarnings("unused") @Shared("sizeNode") @Cached final ArrayObjectSizeNode sizeNode,
                @Cached final FrameStackPushNode pushNode,
                @Cached final ArrayObjectReadNode readNode,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    pushNode.execute(frame, readNode.execute(image.primitiveErrorTable, reasonCode));
}
 
Example #21
Source File: PolyglotPlugin.java    From trufflesqueak with MIT License 5 votes vote down vote up
@TruffleBoundary(transferToInterpreterOnException = false)
@Specialization(guards = {"inInnerContext", "languageIdOrMimeTypeObj.isByteType()", "path.isByteType()"})
protected static final Object doEvalInInnerContext(@SuppressWarnings("unused") final Object receiver, final NativeObject languageIdOrMimeTypeObj, final NativeObject path,
                @SuppressWarnings("unused") final boolean inInnerContext,
                @Cached final ConvertToSqueakNode convertNode,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    final TruffleContext innerContext = image.env.newContextBuilder().build();
    final Object p = innerContext.enter();
    try {
        return convertNode.executeConvert(evalFile(SqueakLanguage.getContext(), languageIdOrMimeTypeObj, path));
    } finally {
        innerContext.leave(p);
        innerContext.close();
    }
}
 
Example #22
Source File: LargeIntegers.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization
protected static final ArrayObject doLong(final long rcvr, final long arg, final boolean negative,
                @Cached final BranchProfile signProfile,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    long divide = rcvr / arg;
    if (negative && divide >= 0 || !negative && divide < 0) {
        signProfile.enter();
        if (divide == Long.MIN_VALUE) {
            return createArrayWithLongMinOverflowResult(image, rcvr, arg);
        }
        divide = -divide;
    }
    return image.asArrayOfLongs(divide, rcvr % arg);
}
 
Example #23
Source File: MiscellaneousPrimitives.java    From trufflesqueak with MIT License 5 votes vote down vote up
@SuppressWarnings("unused")
@Specialization
protected static final Object doSignal(final Object receiver, final NilObject semaphore, final long usecsUTC,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    resetTimerSemaphore(image);
    return receiver;
}
 
Example #24
Source File: IOPrimitives.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization
protected static final PointersObject doShow(final PointersObject receiver, final long left, final long right, final long top, final long bottom,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    if (image.hasDisplay() && left < right && top < bottom) {
        image.getDisplay().showDisplayRect((int) left, (int) right, (int) top, (int) bottom);
    }
    return receiver;
}
 
Example #25
Source File: PolyglotPlugin.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization(guards = "lib.isString(object)", limit = "2")
protected static final NativeObject doAsString(@SuppressWarnings("unused") final Object receiver, final Object object,
                @CachedLibrary("object") final InteropLibrary lib,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    try {
        return image.asByteString(lib.asString(object));
    } catch (final UnsupportedMessageException e) {
        throw primitiveFailedInInterpreterCapturing(e);
    }
}
 
Example #26
Source File: StoragePrimitives.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization(limit = "NEW_CACHE_SIZE", guards = {"receiver == cachedReceiver", "isInstantiable(cachedReceiver, size)"}, assumptions = {"cachedReceiver.getClassFormatStable()"})
protected static final AbstractSqueakObjectWithHash newWithArgDirect(@SuppressWarnings("unused") final ClassObject receiver, final long size,
                @Cached("createIdentityProfile()") final IntValueProfile sizeProfile,
                @Cached("receiver") final ClassObject cachedReceiver,
                @Cached final SqueakObjectNewNode newNode,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    try {
        return newNode.execute(image, cachedReceiver, sizeProfile.profile((int) size));
    } catch (final OutOfMemoryError e) {
        CompilerDirectives.transferToInterpreter();
        throw PrimitiveFailed.INSUFFICIENT_OBJECT_MEMORY;
    }
}
 
Example #27
Source File: ArithmeticPrimitives.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization(rewriteOn = ArithmeticException.class)
public static final Object doLongNoZeroCheck(final long lhs, final long rhs,
                @Cached final BranchProfile isOverflowDivisionProfile,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    if (SqueakGuards.isOverflowDivision(lhs, rhs)) {
        isOverflowDivisionProfile.enter();
        return LargeIntegerObject.createLongMinOverflowResult(image);
    } else {
        return lhs / rhs;
    }
}
 
Example #28
Source File: MiscellaneousPrimitives.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization(guards = "semaphore.getSqueakClass().isSemaphoreClass()")
protected static final Object doSignal(final Object receiver, final PointersObject semaphore, final long usecsUTC,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    final long msTime = MiscUtils.toJavaMicrosecondsUTC(usecsUTC) / 1000;
    signalAtMilliseconds(image, semaphore, msTime);
    return receiver;
}
 
Example #29
Source File: SocketPlugin.java    From trufflesqueak with MIT License 5 votes vote down vote up
/**
 * Return the host address found by the last host name lookup. Returns nil if the last
 * lookup was unsuccessful.
 */
@Specialization
protected static final AbstractSqueakObject doWork(@SuppressWarnings("unused") final Object receiver,
                @Cached("createBinaryProfile()") final ConditionProfile hasResultProfile,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    final byte[] lastNameLookup = Resolver.lastHostNameLookupResult();
    LogUtils.SOCKET.finer(() -> "Name Lookup Result: " + Resolver.addressBytesToString(lastNameLookup));
    return hasResultProfile.profile(lastNameLookup == null) ? NilObject.SINGLETON : image.asByteArray(lastNameLookup);
}
 
Example #30
Source File: Matrix2x3Plugin.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization(guards = {"receiver.isIntType()", "receiver.getIntLength() == 6"})
protected final PointersObject doInvert(final NativeObject receiver, final PointersObject point,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image,
                @Cached final AbstractPointersObjectReadNode readNode,
                @Cached final AbstractPointersObjectWriteNode writeNode,
                @Cached final BranchProfile errorProfile) {
    final double m23ArgX = loadArgumentPointX(point, readNode, errorProfile);
    final double m23ArgY = loadArgumentPointY(point, readNode, errorProfile);
    final float[] m = loadMatrixAsFloat(receiver);
    final double[] m23Result = matrix2x3InvertPoint(m, m23ArgX, m23ArgY, errorProfile);
    return roundAndStoreResultPoint(image, m23Result[0], m23Result[1], writeNode, errorProfile);
}