/** * Report an allocation of a new one or re-allocation of an existing guest language value. This * method notifies all registered listeners * {@link AllocationListener#onReturnValue(com.oracle.truffle.api.instrumentation.AllocationEvent)} * . Only primitive types, String and {@link com.oracle.truffle.api.interop.TruffleObject} are * accepted value types. The change in memory consumption caused by the allocation is * <code>newSize - oldSize</code> when both old size and new size are known. The change can be * either positive or negative. * <p> * A call to {@link #onEnter(java.lang.Object, long, long)} must precede this call. In case of * re-allocation, the value object passed to {@link #onEnter(java.lang.Object, long, long)} must * be the same instance as the value passed to this method. * * @param value the value that was newly allocated, or the re-allocated value. Must not be * <code>null</code>. * @param oldSize size in bytes of an old value, if any. Must be <code>0</code> for newly * allocated values. In case of re-allocation it's the size of the original value * before re-allocation. Can be {@link #SIZE_UNKNOWN} when not known. * @param newSize the size of the allocated value in bytes. In case of re-allocation, it's the * size of the object after re-allocation. The <code>newSize</code> may be less than * <code>oldSize</code> when the object size shrinks. Can be {@link #SIZE_UNKNOWN} * when not known. * @since 0.27 */ public void onReturnValue(Object value, long oldSize, long newSize) { if (valueCheck != null) { onReturnValueCheck(value, oldSize, newSize); } notifyAllocated(value, oldSize, newSize); }