com.oracle.truffle.api.CompilerAsserts Java Examples
The following examples show how to use
com.oracle.truffle.api.CompilerAsserts.
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: HashemInvokeNode.java From mr-hashemi with Universal Permissive License v1.0 | 6 votes |
@ExplodeLoop @Override public Object executeGeneric(VirtualFrame frame) { Object function = functionNode.executeGeneric(frame); /* * The number of arguments is constant for one invoke node. During compilation, the loop is * unrolled and the execute methods of all arguments are inlined. This is triggered by the * ExplodeLoop annotation on the method. The compiler assertion below illustrates that the * array length is really constant. */ CompilerAsserts.compilationConstant(argumentNodes.length); Object[] argumentValues = new Object[argumentNodes.length]; for (int i = 0; i < argumentNodes.length; i++) { argumentValues[i] = argumentNodes[i].executeGeneric(frame); } try { return library.execute(function, argumentValues); } catch (ArityException | UnsupportedTypeException | UnsupportedMessageException e) { /* Execute was not successful. */ throw HashemUndefinedNameException.undefinedBebin(this, function); } }
Example #2
Source File: WeakVariablePointersObject.java From trufflesqueak with MIT License | 6 votes |
@Override public String toString() { CompilerAsserts.neverPartOfCompilation(); final StringBuilder sb = new StringBuilder(64); if (variablePart.length > 0) { final Object referent = variablePart[0].get(); sb.append('[').append(referent); if (variablePart[0].isEnqueued()) { sb.append(" (marked as garbage)"); } if (variablePart.length > 1) { sb.append("..."); } sb.append(']'); } return sb.append(" a ").append(getSqueakClassName()).append(" @").append(Integer.toHexString(hashCode())).append(" of size ").append(variablePart.length).toString(); }
Example #3
Source File: ObjectGraphUtils.java From trufflesqueak with MIT License | 6 votes |
private void addObjectsFromTruffleFrames() { CompilerAsserts.neverPartOfCompilation(); Truffle.getRuntime().iterateFrames(frameInstance -> { final Frame current = frameInstance.getFrame(FrameInstance.FrameAccess.READ_ONLY); if (!FrameAccess.isTruffleSqueakFrame(current)) { return null; } for (final Object argument : current.getArguments()) { addIfUnmarked(argument); } final CompiledCodeObject blockOrMethod = FrameAccess.getBlockOrMethod(current); addIfUnmarked(FrameAccess.getContext(current, blockOrMethod)); for (final FrameSlot slot : blockOrMethod.getStackSlotsUnsafe()) { if (slot == null) { return null; // Stop here, slot has not (yet) been created. } if (current.isObject(slot)) { addIfUnmarked(FrameUtil.getObjectSafe(current, slot)); } } return null; }); }
Example #4
Source File: CompiledCodeObject.java From trufflesqueak with MIT License | 6 votes |
public final Source getSource() { CompilerAsserts.neverPartOfCompilation(); if (source == null) { String name = null; String contents; try { name = toString(); contents = SqueakBytecodeDecoder.decodeToString(this); } catch (final RuntimeException e) { if (name == null) { name = SOURCE_UNAVAILABLE_NAME; } contents = SOURCE_UNAVAILABLE_CONTENTS; } source = Source.newBuilder(SqueakLanguageConfig.ID, contents, name).mimeType("text/plain").build(); } return source; }
Example #5
Source File: MapArgObject.java From grcuda with BSD 3-Clause "New" or "Revised" License | 6 votes |
@ExportMessage @TruffleBoundary Object execute(Object[] arguments) throws UnsupportedMessageException, UnsupportedTypeException, ArityException { if (value instanceof MapArgObjectMember) { MapArgObjectMember member = (MapArgObjectMember) value; if (MAP.equals(member.name)) { checkArity(arguments, 1); return new MapArgObject(member.parent).map(arguments[0]); } else if (SHRED.equals(member.name)) { checkArity(arguments, 0); CompilerAsserts.neverPartOfCompilation(); return new MapArgObject(member.parent).shred(); } else if (DESCRIBE.equals(member.name)) { checkArity(arguments, 0); CompilerAsserts.neverPartOfCompilation(); return new MapArgObject(member.parent).describe(); } else if (BIND.equals(member.name)) { checkArity(arguments, 3); return member.parent.bind(arguments[0], arguments[1], arguments[2]); } } CompilerDirectives.transferToInterpreter(); throw UnsupportedMessageException.create(); }
Example #6
Source File: SlotLocation.java From trufflesqueak with MIT License | 5 votes |
@Override public void write(final AbstractPointersObject object, final Object value) throws IllegalWriteException { CompilerAsserts.neverPartOfCompilation(); if (canStore(value)) { setMask(object); UnsafeUtils.putBoolIntoLongs(object.primitiveExtension, index, (boolean) value); } else { transferToInterpreterAndThrowIllegalWriteException(); } }
Example #7
Source File: CUBLASRegistry.java From grcuda with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void cuBLASShutdown() { CompilerAsserts.neverPartOfCompilation(); if (cublasHandle != null) { try { Object result = InteropLibrary.getFactory().getUncached().execute(cublasDestroyFunction, cublasHandle); checkCUBLASReturnCode(result, CUBLAS_CUBLASDESTROY.getName()); cublasHandle = null; } catch (InteropException e) { throw new GrCUDAInternalException(e); } } }
Example #8
Source File: SlotLocation.java From trufflesqueak with MIT License | 5 votes |
@Override public Object read(final AbstractPointersObject object) { CompilerAsserts.neverPartOfCompilation(); if (isSet(object)) { return UnsafeUtils.getBoolFromLongs(object.primitiveExtension, index); } else { return NilObject.SINGLETON; } }
Example #9
Source File: PushBytecodes.java From trufflesqueak with MIT License | 5 votes |
@Override public String toString() { CompilerAsserts.neverPartOfCompilation(); final int start = index + numBytecodes; final int end = start + blockSize; return "closureNumCopied: " + numCopied + " numArgs: " + numArgs + " bytes " + start + " to " + end; }
Example #10
Source File: ObjectLayouts.java From trufflesqueak with MIT License | 5 votes |
public static String getClassComment(final ClassObject squeakClass) { CompilerAsserts.neverPartOfCompilation("For instrumentation access only."); final AbstractSqueakObject organization = squeakClass.getOrganization(); if (organization == NilObject.SINGLETON) { return null; } final AbstractSqueakObjectWithClassAndHash classComment = (AbstractSqueakObjectWithClassAndHash) ((VariablePointersObject) organization).instVarAt0Slow(CLASS_ORGANIZER.CLASS_COMMENT); final NativeObject string = (NativeObject) classComment.send("string"); return string.asStringUnsafe(); }
Example #11
Source File: CompiledMethodObject.java From trufflesqueak with MIT License | 5 votes |
public ClassObject getMethodClassSlow() { CompilerAsserts.neverPartOfCompilation(); final AbstractPointersObjectReadNode readNode = AbstractPointersObjectReadNode.getUncached(); if (hasMethodClass(readNode)) { return getMethodClass(readNode); } return null; }
Example #12
Source File: CompiledMethodObject.java From trufflesqueak with MIT License | 5 votes |
@Override public String toString() { CompilerAsserts.neverPartOfCompilation(); String className = "UnknownClass"; final ClassObject methodClass = getMethodClassSlow(); if (methodClass != null) { className = methodClass.getClassName(); } return className + ">>" + getNotNilSelector(); }
Example #13
Source File: MiscellaneousPrimitives.java From trufflesqueak with MIT License | 5 votes |
@Override public final boolean acceptsMethod(final CompiledMethodObject method) { CompilerAsserts.neverPartOfCompilation(); if (method.getNumLiterals() > 0) { final Object literal1 = method.getLiterals()[1]; if (literal1 instanceof PointersObject && ((PointersObject) literal1).getSqueakClass().includesExternalFunctionBehavior(SqueakLanguage.getContext())) { externalFunction = (PointersObject) literal1; return true; } } return false; }
Example #14
Source File: BitBltPlugin.java From trufflesqueak with MIT License | 5 votes |
private static void respecializeArrayToLongOrPrimFail(final ArrayObject array) { CompilerAsserts.neverPartOfCompilation(); final Object[] values = ArrayObjectToObjectArrayCopyNode.getUncached().execute(array); final long[] longs = new long[values.length]; try { for (int i = 0; i < values.length; i++) { longs[i] = ((Number) values[i]).longValue(); } } catch (final ClassCastException e) { throw PrimitiveFailed.GENERIC_ERROR; } array.setStorage(longs); }
Example #15
Source File: NativeObject.java From trufflesqueak with MIT License | 5 votes |
@Override public int getNumSlots() { CompilerAsserts.neverPartOfCompilation(); if (isByteType()) { return (int) Math.ceil((double) getByteLength() / BYTE_TO_WORD); } else if (isShortType()) { return (int) Math.ceil((double) getShortLength() / SHORT_TO_WORD); } else if (isIntType()) { return (int) Math.ceil((double) getIntLength() / INTEGER_TO_WORD); } else if (isLongType()) { return getLongLength(); } else { throw SqueakException.create("Unexpected NativeObject"); } }
Example #16
Source File: AbstractBytecodeNode.java From trufflesqueak with MIT License | 5 votes |
@Override public final SourceSection getSourceSection() { CompilerAsserts.neverPartOfCompilation(); if (sourceSection == null) { final Source source = code.getSource(); if (CompiledCodeObject.SOURCE_UNAVAILABLE_CONTENTS.equals(source.getCharacters())) { sourceSection = source.createUnavailableSection(); } else { final int lineNumber = SqueakBytecodeDecoder.findLineNumber(code, index); sourceSection = source.createSection(lineNumber); } } return sourceSection; }
Example #17
Source File: HashemObjectType.java From mr-hashemi with Universal Permissive License v1.0 | 5 votes |
static Location lookupLocation(Shape shape, String name) throws UnknownIdentifierException { /* Initialization of cached values always happens in a slow path. */ CompilerAsserts.neverPartOfCompilation(); Property property = shape.getProperty(name); if (property == null) { /* Property does not exist. */ throw UnknownIdentifierException.create(name); } return property.getLocation(); }
Example #18
Source File: SlotLocation.java From trufflesqueak with MIT License | 5 votes |
@Override public Object read(final AbstractPointersObject object) { CompilerAsserts.neverPartOfCompilation(); if (isSet(object)) { return UnsafeUtils.getCharAt(object, address); } else { return NilObject.SINGLETON; } }
Example #19
Source File: SlotLocation.java From trufflesqueak with MIT License | 5 votes |
@Override public void write(final AbstractPointersObject object, final Object value) throws IllegalWriteException { CompilerAsserts.neverPartOfCompilation(); if (canStore(value)) { setMask(object); UnsafeUtils.putCharIntoLongs(object.primitiveExtension, index, (char) value); } else { transferToInterpreterAndThrowIllegalWriteException(); } }
Example #20
Source File: SlotLocation.java From trufflesqueak with MIT License | 5 votes |
@Override public void unset(final AbstractPointersObject object) { CompilerAsserts.neverPartOfCompilation(); unsetMask(object); if (object.primitiveExtension != null) { object.primitiveExtension[index] = 0L; } }
Example #21
Source File: SlotLocation.java From trufflesqueak with MIT License | 5 votes |
@Override public Object read(final AbstractPointersObject object) { CompilerAsserts.neverPartOfCompilation(); if (isSet(object)) { return UnsafeUtils.getLongAt(object, address); } else { return NilObject.SINGLETON; } }
Example #22
Source File: SlotLocation.java From trufflesqueak with MIT License | 5 votes |
@Override public void write(final AbstractPointersObject object, final Object value) throws IllegalWriteException { CompilerAsserts.neverPartOfCompilation(); if (canStore(value)) { setMask(object); UnsafeUtils.putLongAt(object, address, (long) value); } else { transferToInterpreterAndThrowIllegalWriteException(); } }
Example #23
Source File: DebugUtils.java From trufflesqueak with MIT License | 5 votes |
public static void printSqStackTrace() { CompilerAsserts.neverPartOfCompilation("For debugging purposes only"); final boolean isCIBuild = System.getenv().containsKey("GITHUB_ACTIONS"); final int[] depth = new int[1]; final Object[] lastSender = new Object[]{null}; final PrintWriter err = SqueakLanguage.getContext().getError(); err.println("== Truffle stack trace ==========================================================="); Truffle.getRuntime().iterateFrames(frameInstance -> { if (depth[0]++ > 50 && isCIBuild) { return null; } final Frame current = frameInstance.getFrame(FrameInstance.FrameAccess.READ_ONLY); if (!FrameAccess.isTruffleSqueakFrame(current)) { return null; } final CompiledMethodObject method = FrameAccess.getMethod(current); lastSender[0] = FrameAccess.getSender(current); final Object marker = FrameAccess.getMarker(current, method); final Object context = FrameAccess.getContext(current, method); final String prefix = FrameAccess.getClosure(current) == null ? "" : "[] in "; final String argumentsString = ArrayUtils.toJoinedString(", ", FrameAccess.getReceiverAndArguments(current)); err.println(MiscUtils.format("%s%s #(%s) [marker: %s, context: %s, sender: %s]", prefix, method, argumentsString, marker, context, lastSender[0])); return null; }); if (lastSender[0] instanceof ContextObject) { err.println("== Squeak frames ================================================================"); printSqStackTrace((ContextObject) lastSender[0]); } }
Example #24
Source File: SlotLocation.java From trufflesqueak with MIT License | 5 votes |
@Override public Object read(final AbstractPointersObject object) { CompilerAsserts.neverPartOfCompilation(); if (isSet(object)) { return UnsafeUtils.getLong(object.primitiveExtension, index); } else { return NilObject.SINGLETON; } }
Example #25
Source File: JumpBytecodes.java From trufflesqueak with MIT License | 5 votes |
@Override public String toString() { CompilerAsserts.neverPartOfCompilation(); if (isIfTrue) { return "jumpTrue: " + offset; } else { return "jumpFalse: " + offset; } }
Example #26
Source File: SlotLocation.java From trufflesqueak with MIT License | 5 votes |
@Override public Object read(final AbstractPointersObject object) { CompilerAsserts.neverPartOfCompilation(); if (isSet(object)) { return UnsafeUtils.getDoubleAt(object, address); } else { return NilObject.SINGLETON; } }
Example #27
Source File: SlotLocation.java From trufflesqueak with MIT License | 5 votes |
@Override public void write(final AbstractPointersObject object, final Object value) throws IllegalWriteException { CompilerAsserts.neverPartOfCompilation(); if (canStore(value)) { setMask(object); UnsafeUtils.putDoubleAt(object, address, (double) value); } else { transferToInterpreterAndThrowIllegalWriteException(); } }
Example #28
Source File: SlotLocation.java From trufflesqueak with MIT License | 5 votes |
@Override public Object read(final AbstractPointersObject obj) { CompilerAsserts.neverPartOfCompilation(); if (isSet(obj)) { return UnsafeUtils.getDoubleFromLongs(obj.primitiveExtension, index); } else { return NilObject.SINGLETON; } }
Example #29
Source File: SlotLocation.java From trufflesqueak with MIT License | 5 votes |
@Override public void write(final AbstractPointersObject object, final Object value) throws IllegalWriteException { CompilerAsserts.neverPartOfCompilation(); if (canStore(value)) { setMask(object); UnsafeUtils.putDoubleIntoLongs(object.primitiveExtension, index, (double) value); } else { transferToInterpreterAndThrowIllegalWriteException(); } }
Example #30
Source File: SqueakBytecodeDecoder.java From trufflesqueak with MIT License | 5 votes |
public static String decodeToString(final CompiledCodeObject code) { CompilerAsserts.neverPartOfCompilation(); final StringBuilder sb = new StringBuilder(); final int trailerPosition = trailerPosition(code); int bytecodeIndex = 0; int lineIndex = 1; int indent = 0; final byte[] bytes = code.getBytes(); while (bytecodeIndex < trailerPosition) { final int currentByte = Byte.toUnsignedInt(bytes[bytecodeIndex]); sb.append(lineIndex); for (int j = 0; j < 1 + indent; j++) { sb.append(' '); } final int numBytecodes = decodeNumBytes(code, bytecodeIndex); sb.append('<'); for (int j = bytecodeIndex; j < bytecodeIndex + numBytecodes; j++) { if (j > bytecodeIndex) { sb.append(' '); } if (j < bytes.length) { sb.append(String.format("%02X", bytes[j])); } } sb.append("> "); sb.append(decodeBytecodeToString(code, currentByte, bytecodeIndex)); if (currentByte == 143) { indent++; // increment indent on push closure } else if (currentByte == 125) { indent--; // decrement indent on block return } lineIndex++; bytecodeIndex += numBytecodes; if (bytecodeIndex < trailerPosition) { sb.append('\n'); } } return sb.toString(); }