Java Code Examples for com.oracle.truffle.api.profiles.ConditionProfile#profile()
The following examples show how to use
com.oracle.truffle.api.profiles.ConditionProfile#profile() .
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: MiscPrimitivePlugin.java From trufflesqueak with MIT License | 6 votes |
@Specialization protected static final long doFind(@SuppressWarnings("unused") final Object receiver, final NativeObject string, final NativeObject inclusionMap, final long start, @Cached("createBinaryProfile()") final ConditionProfile notFoundProfile) { if (start < 1 || !string.isByteType() || !inclusionMap.isByteType()) { CompilerDirectives.transferToInterpreter(); throw PrimitiveFailed.BAD_ARGUMENT; } if (inclusionMap.getByteLength() != 256) { CompilerDirectives.transferToInterpreter(); return 0L; } final int stringSize = string.getByteLength(); long index = start - 1; while (index < stringSize && inclusionMap.getByte(string.getByteUnsigned(index)) == 0) { index++; } return notFoundProfile.profile(index >= stringSize) ? 0L : index + 1; }
Example 2
Source File: IOPrimitives.java From trufflesqueak with MIT License | 6 votes |
@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 3
Source File: LargeIntegers.java From trufflesqueak with MIT License | 5 votes |
@Specialization protected static final long doLongLargeInteger(final long lhs, final LargeIntegerObject rhs, @Cached("createBinaryProfile()") final ConditionProfile fitsIntoLongProfile) { if (fitsIntoLongProfile.profile(rhs.fitsIntoLong())) { final long value = rhs.longValue(); return value == lhs ? 0L : value < lhs ? -1L : 1L; } else { return rhs.isNegative() ? 1L : -1L; } }
Example 4
Source File: LargeIntegers.java From trufflesqueak with MIT License | 5 votes |
@Specialization protected static final Object doLargeIntegerLong(final LargeIntegerObject lhs, final long rhs, @Cached("createBinaryProfile()") final ConditionProfile differentSignProfile) { if (differentSignProfile.profile(lhs.differentSign(rhs))) { return lhs.add(rhs); } else { return lhs.subtract(rhs); } }
Example 5
Source File: SocketPlugin.java From trufflesqueak with MIT License | 5 votes |
/** * 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 6
Source File: IOPrimitives.java From trufflesqueak with MIT License | 5 votes |
@Specialization(guards = {"repl.isByteType()"}) protected static final void doLargeIntegerNative(final LargeIntegerObject rcvr, final long start, final long stop, final NativeObject repl, final long replStart, @Shared("errorProfile") @Cached final BranchProfile errorProfile, @Cached("createBinaryProfile()") final ConditionProfile fitsEntirelyProfile) { if (fitsEntirelyProfile.profile(inBoundsEntirely(rcvr.instsize(), rcvr.size(), start, stop, repl.instsize(), repl.getByteLength(), replStart))) { rcvr.setBytes(repl.getByteStorage()); } else { if (inBounds(rcvr.size(), start, stop, repl.getByteLength(), replStart)) { rcvr.setBytes(repl.getByteStorage(), (int) replStart - 1, (int) start - 1, (int) (1 + stop - start)); } else { errorProfile.enter(); throw PrimitiveFailed.BAD_INDEX; } } }
Example 7
Source File: IOPrimitives.java From trufflesqueak with MIT License | 5 votes |
@Specialization protected static final void doLargeInteger(final LargeIntegerObject rcvr, final long start, final long stop, final LargeIntegerObject repl, final long replStart, @Shared("errorProfile") @Cached final BranchProfile errorProfile, @Cached("createBinaryProfile()") final ConditionProfile fitsEntirelyProfile) { if (fitsEntirelyProfile.profile(inBoundsEntirely(rcvr.instsize(), rcvr.size(), start, stop, repl.instsize(), repl.size(), replStart))) { rcvr.replaceInternalValue(repl); } else { if (inBounds(rcvr.size(), start, stop, repl.size(), replStart)) { rcvr.setBytes(repl, (int) replStart - 1, (int) start - 1, (int) (1 + stop - start)); } else { errorProfile.enter(); throw PrimitiveFailed.BAD_INDEX; } } }
Example 8
Source File: MiscellaneousPrimitives.java From trufflesqueak with MIT License | 5 votes |
@Specialization(guards = {"receiver.isEmptyType()"}) protected static final boolean doEmptyArray(final ArrayObject receiver, final Object thang, @Cached("createBinaryProfile()") final ConditionProfile noElementsProfile) { if (noElementsProfile.profile(receiver.getEmptyStorage() == 0)) { return BooleanObject.FALSE; } else { return BooleanObject.wrap(thang == NilObject.SINGLETON); } }
Example 9
Source File: GetOrCreateContextNode.java From trufflesqueak with MIT License | 5 votes |
@Specialization protected static final ContextObject doCreate(final VirtualFrame frame, @Cached("getBlockOrMethod(frame)") final CompiledCodeObject code, @Cached("createCountingProfile()") final ConditionProfile hasContextProfile) { final ContextObject context = FrameAccess.getContext(frame, code); if (hasContextProfile.profile(context != null)) { return context; } else { return ContextObject.create(frame.materialize(), code); } }
Example 10
Source File: BitBltPlugin.java From trufflesqueak with MIT License | 5 votes |
@Specialization protected static final Object doCopyTranslucent(final PointersObject receiver, final long factor, @Cached("createBinaryProfile()") final ConditionProfile resultProfile, @CachedContext(SqueakLanguage.class) final SqueakImageContext image) { image.bitblt.resetSuccessFlag(); final long result = image.bitblt.primitiveCopyBits(receiver, factor); return resultProfile.profile(result == -1) ? receiver : result; }
Example 11
Source File: LargeIntegers.java From trufflesqueak with MIT License | 5 votes |
@Specialization protected static final Object doLongLargeInteger(final long lhs, final LargeIntegerObject rhs, @Cached("createBinaryProfile()") final ConditionProfile differentSignProfile) { if (differentSignProfile.profile(rhs.differentSign(lhs))) { return LargeIntegerObject.subtract(lhs, rhs); } else { return rhs.add(lhs); } }
Example 12
Source File: NativeObject.java From trufflesqueak with MIT License | 5 votes |
@ExportMessage public String asString(@Cached("createBinaryProfile()") final ConditionProfile byteStringOrSymbolProfile, @Cached final BranchProfile errorProfile) throws UnsupportedMessageException { final ClassObject squeakClass = getSqueakClass(); if (byteStringOrSymbolProfile.profile(squeakClass.isStringClass() || squeakClass.isSymbolClass())) { return asStringUnsafe(); } else if (squeakClass.isWideStringClass()) { return asStringFromWideString(); } else { errorProfile.enter(); throw UnsupportedMessageException.create(); } }
Example 13
Source File: LargeIntegers.java From trufflesqueak with MIT License | 5 votes |
@Specialization(rewriteOn = ArithmeticException.class) protected static final long doLong(final long lhs, final long rhs, @Cached("createBinaryProfile()") final ConditionProfile differentSignProfile) { if (differentSignProfile.profile(differentSign(lhs, rhs))) { return Math.subtractExact(lhs, rhs); } else { return Math.addExact(lhs, rhs); } }
Example 14
Source File: LargeIntegers.java From trufflesqueak with MIT License | 5 votes |
@Specialization protected static final long doLong(final long lhs, final long rhs, @Cached("createBinaryProfile()") final ConditionProfile smallerProfile, @Cached("createBinaryProfile()") final ConditionProfile equalProfile) { if (smallerProfile.profile(lhs < rhs)) { return -1L; } else if (equalProfile.profile(lhs == rhs)) { return 0L; } else { return +1L; } }
Example 15
Source File: NilObject.java From trufflesqueak with MIT License | 4 votes |
public static AbstractSqueakObject nullToNil(final AbstractSqueakObject object, final ConditionProfile profile) { return profile.profile(object == null) ? SINGLETON : object; }
Example 16
Source File: ArrayObject.java From trufflesqueak with MIT License | 4 votes |
public static Object toObjectFromDouble(final double value, final ConditionProfile isNilTagProfile) { return isNilTagProfile.profile(isDoubleNilTag(value)) ? NilObject.SINGLETON : value; }
Example 17
Source File: ArrayObjectNodes.java From trufflesqueak with MIT License | 4 votes |
@Specialization(guards = "obj.isDoubleType()") protected static final Object doArrayOfDoubles(final ArrayObject obj, final long index, @Shared("nilProfile") @Cached("createBinaryProfile()") final ConditionProfile nilProfile) { final double value = obj.getDouble(index); return nilProfile.profile(Double.doubleToRawLongBits(value) == ArrayObject.DOUBLE_NIL_TAG_LONG) ? NilObject.SINGLETON : value; }
Example 18
Source File: ArrayObject.java From trufflesqueak with MIT License | 4 votes |
public static Object toObjectFromLong(final long value, final ConditionProfile isNilTagProfile) { return isNilTagProfile.profile(isLongNilTag(value)) ? NilObject.SINGLETON : value; }
Example 19
Source File: ArithmeticPrimitives.java From trufflesqueak with MIT License | 4 votes |
@Specialization(guards = "inSafeIntegerRange(receiver)") protected static final long doDouble(final double receiver, @Cached("createBinaryProfile()") final ConditionProfile positiveProfile) { return (long) (positiveProfile.profile(receiver >= 0) ? Math.floor(receiver) : Math.ceil(receiver)); }
Example 20
Source File: ArithmeticPrimitives.java From trufflesqueak with MIT License | 4 votes |
@Specialization(guards = "receiver.isInfinite()") protected static final double doFloatInfinite(@SuppressWarnings("unused") final FloatObject receiver, @Cached("createBinaryProfile()") final ConditionProfile isNegativeInfinityProfile) { return isNegativeInfinityProfile.profile(receiver.getValue() == Double.NEGATIVE_INFINITY) ? -0.0D : 0.0D; }