@TruffleBoundary private void onEnterCheck(Object valueToReallocate, long oldSize, long newSizeEstimate) { enterSizeCheck(valueToReallocate, oldSize, newSizeEstimate); if (valueToReallocate != null) { allocateValueCheck(valueToReallocate); } setValueCheck(valueToReallocate); }
allocateValueCheck(value); allocatedCheck(value, oldSize, newSize); notifyAllocated(value, oldSize, newSize);
enterSizeCheck(valueToReallocate, oldSize, newSizeEstimate); if (valueToReallocate != null) { allocateValueCheck(valueToReallocate); notifyAllocateOrReallocate(valueToReallocate, oldSize, newSizeEstimate);
onEnterCheck(valueToReallocate, oldSize, newSizeEstimate); notifyAllocateOrReallocate(valueToReallocate, oldSize, newSizeEstimate);
private AllocationReporter getAllocationReporter(LanguageInfo info) { AllocationReporter allocationReporter = new AllocationReporter(info); allocationReporters.add(allocationReporter); for (EventBinding.Allocation<? extends AllocationListener> binding : allocationBindings) { if (binding.getAllocationFilter().contains(info)) { allocationReporter.addListener(binding.getElement()); } } return allocationReporter; }
@TruffleBoundary private void onReturnValueCheck(Object value, long oldSize, long newSize) { allocateValueCheck(value); allocatedCheck(value, oldSize, newSize); }
/** * 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); }
private <T extends AllocationListener> EventBinding<T> addAllocationBinding(EventBinding.Allocation<T> binding) { if (TRACE) { trace("BEGIN: Adding allocation binding %s%n", binding.getElement()); } this.allocationBindings.add(binding); for (AllocationReporter allocationReporter : allocationReporters) { if (binding.getAllocationFilter().contains(allocationReporter.language)) { allocationReporter.addListener(binding.getElement()); } } if (TRACE) { trace("END: Added allocation binding %s%n", binding.getElement()); } return binding; }
for (AllocationReporter allocationReporter : allocationReporters) { if (allocationBinding.getAllocationFilter().contains(allocationReporter.language)) { allocationReporter.removeListener(l);
@ExplodeLoop private void notifyAllocateOrReallocate(Object value, long oldSize, long newSizeEstimate) { if (valueCheck != null) { setValueCheck(value); } CompilerAsserts.partialEvaluationConstant(this); if (!listenersNotChangedAssumption.isValid()) { CompilerDirectives.transferToInterpreterAndInvalidate(); } AllocationListener[] ls = this.listeners; if (ls != null) { AllocationEvent event = new AllocationEvent(language, value, oldSize, newSizeEstimate); for (AllocationListener l : ls) { l.onEnter(event); } } }
private AllocationReporter getAllocationReporter(LanguageInfo info) { AllocationReporter allocationReporter = new AllocationReporter(info); allocationReporters.add(allocationReporter); for (EventBinding.Allocation<? extends AllocationListener> binding : allocationBindings) { if (binding.getAllocationFilter().contains(info)) { allocationReporter.addListener(binding.getElement()); } } return allocationReporter; }
private <T extends AllocationListener> EventBinding<T> addAllocationBinding(EventBinding.Allocation<T> binding) { if (TRACE) { trace("BEGIN: Adding allocation binding %s%n", binding.getElement()); } this.allocationBindings.add(binding); for (AllocationReporter allocationReporter : allocationReporters) { if (binding.getAllocationFilter().contains(allocationReporter.language)) { allocationReporter.addListener(binding.getElement()); } } if (TRACE) { trace("END: Added allocation binding %s%n", binding.getElement()); } return binding; }
for (AllocationReporter allocationReporter : allocationReporters) { if (allocationBinding.getAllocationFilter().contains(allocationReporter.language)) { allocationReporter.removeListener(l);